Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
EtaLoop opened this issue Oct 22, 2024 · 1 comment
Open

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

EtaLoop opened this issue Oct 22, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@EtaLoop
Copy link
Contributor

EtaLoop commented Oct 22, 2024

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
Copy link
Contributor

taiki-e commented Oct 31, 2024

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...

"lines" | "linestrips" | "polygons" | "polylist" | "triangles" | "trifans"
| "tristrips" => {
primitives.push(parse_primitive(node, name.parse().unwrap())?);
}

for prim in (iter::Mesh { doc, xml: geometry }).primitives() {

for mat in geometry.mesh.primitives.iter().filter_map(|m| m.material) {
if let Some(&(name, effect)) = instance_material_map.get(mat) {
material = Some(build_material(doc, name, effect, dir));
// TODO: multiple materials from geometry.mesh.primitives?
break;
}
}

@taiki-e taiki-e added the bug Something isn't working label Oct 31, 2024
@taiki-e taiki-e changed the title Handle mesh with multiple <triangles> Handle mesh with multiple <triangles> that having material Oct 31, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants