openrr / mesh-loader

Fast parser for 3D-model-formats.
Apache License 2.0
4 stars 2 forks source link

Handle mesh with multiple <triangles> that having material #69

Open EtaLoop opened 1 month ago

EtaLoop commented 1 month ago

In this collada 1.4.1 file, there are multiple <triangles> described. Please correct me if I'm wrong, but the parser does not seem to handle it. Multiple <triangles> involve vertex positions, normals but also multiple materials.

EDIT : I assume, using multiple <triangles> aims at having different materials/color for a mesh. So, maybe we could use some kind of vertex_color which would be a list of color for each vertex? It would permit to describe both materials.

https://github.com/Gepetto/example-robot-data/blob/master/robots/ur_description/meshes/ur3/visual/base.dae

taiki-e commented 3 weeks ago

Thanks for the report!

The multiple primitives themselves are parsed fine, and all are taken into account when building the mesh. However, when building the material, only the first one specified is taken into account. We need to figure out some way to represent this well...

https://github.com/openrr/mesh-loader/blob/8754042b36ce88606d44e7c77f1190032ab5699b/src/collada/geometry.rs#L232-L235

https://github.com/openrr/mesh-loader/blob/e1148890a05d1f86894161ac51ff653d80bbe791/src/collada/instance.rs#L113

https://github.com/openrr/mesh-loader/blob/e1148890a05d1f86894161ac51ff653d80bbe791/src/collada/instance.rs#L87-L93