rnd-team-dev / plotoptix

Data visualisation and ray tracing in Python based on OptiX 7.7 framework.
https://rnd.team/plotoptix
Other
496 stars 26 forks source link

Loading multiple meshes from file. #53

Closed SamTov closed 11 months ago

SamTov commented 11 months ago

I have a setup where I load in one mesh and assign to it a material and then load in another with a different material like this:

rt.load_mesh_obj(
    "colloid_meshes/export_mesh_1997.obj", 
    c=np.array([100., 141., 229.])/255, 
    mat="matt_plastic_2", 
    make_normals=True
)
rt.load_mesh_obj(
    "rod_meshes/export_mesh_1997.obj",
     c=10.0, 
    mat="matt_plastic",
     make_normals=True
)

However, when I run this I receive the following error:

[ERROR] (MainThread) Mesh loading failed.

    Selected devices: [0]
    Primary device: 0
[Py-C# interop]
An item with the same key has already been added. Key: mesh
done

and only one mesh is displayed, namely, the first one I added. What is the best method for loading multiple meshes in like this?

SamTov commented 11 months ago

I resolved this by using the load_merged_mesh_obj method and specifying a name there. Interestingly, passing a name to the load_mesh_obj did not resolve it.

robertsulej commented 11 months ago

Hi, sorry for delay! You can load these meshes with load_mesh_obj() as well, just keep unique names of meshes exported to obj file. Names from obj's are directly used as geometry names in plotoptix scene and have to be unique.