Jump to content

Multimaterial problem with Blender exporter


hw3web
 Share

Recommended Posts

Hi There

 

is there any one realize that if you load some .babylon file with multi material mesh , and then add mesh to this scene by import next multi material mesh from another .babylon, second loaded mesh will take material from multi material loaded on beginning.

 

It is happen because of tag: "materialId":"Multimaterial#0" in . babylon file - 

 

is there any chance Multimaterial ID will be created as dynamic name in Blender Exporter :

 

maybe number of milliseconds - epoch time , that it will be each time different and at least will be not repeated ,

or as combine name of sub material : mat1 + mat2 + mat3 => Multi#mat1mat2mat3 

 

by now I must go and edit .babylon files to give them individual names just to no repate it self

 

thank you

 

Python line in Blender Exporter

 

601 : multimat.name = "Multimaterial#" + str(len(multiMaterials))

 

I do not want mess with it as I prefer that it will be done and share with all users BabylonJS

 

Link to comment
Share on other sites

I changed to this stuff:

 

multimat.name = "Multimaterial#" + str(len(multiMaterials))            multimat.materials = []            Export_babylon.write_string(file_handler, "materialId", multimat.name)            for mat in object.material_slots:                multimat.materials.append(mat.name)multimat.name = multimat.name + "-" + mat.name 
Link to comment
Share on other sites

  • 4 weeks later...

I do not understand. The change is online:

multimat.name = "Multimaterial#" + str(len(multiMaterials))            multimat.materials = []            Export_babylon.write_string(file_handler, "materialId", multimat.name)            for mat in object.material_slots:                multimat.materials.append(mat.name)                            multiMaterials.append(multimat)
Link to comment
Share on other sites

is that

 

multimat.name = "Multimaterial#" + str(len(multiMaterials))

 

not mean the name of multimaterial will be :

 

Multimaterial#(number)

 

and if you loading few meshes from different babylon files where all will be only one multi-texture all of them will be  Multimaterial#0 and last or first one will decide upon the rest material .

 

 

?

 

 

solution it could be to add:

 

import time

 

and then replace :

 

multimat.name = "Multimaterial#" + str(len(multiMaterials))

 

with 

 

multimat.name = "Multimaterial#" + str(math.floor(time.time()))

 

 

I did it and it is working fine, but I would it will be helping everyone .

Link to comment
Share on other sites

but we set this way just multi-material name that must be individual for specific mesh.

 

problem with other is when you load more then one multi material mesh from different Babylon file , if all of them has only one multi material mesh then all multimaterial names will be Multimaterial#0 , so if in first babylon file we have sphere(half white half black) and in second box ( half red half blue) we will have  sphere and box half black half white :(

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...