I am working on loading a collada dae file from sketchup into a program, and I’ve figured out most of how the Collada Dom works, but there are a couple of details I can’t seem to find in the documentation.
My dae file looks something like this:
...
<library_materials>
<material id="material0ID" name="material0">
<instance_effect url="#material0-effect"/>
</material>
<material id="material1ID" name="material1">
<instance_effect url="#material1-effect"/>
</material>
</library_materials>
...
<triangles material="material0" count="6">
<input semantic="VERTEX" source="#mesh1-geometry-vertex" offset="0"/>
<input semantic="NORMAL" source="#mesh1-geometry-normal" offset="1"/>
<input semantic="TEXCOORD" source="#mesh1-geometry-uv" offset="2" set="0"/>
...</p>
</triangles>
<triangles material="material1" count="6">
<input semantic="VERTEX" source="#mesh1-geometry-vertex" offset="0"/>
<input semantic="NORMAL" source="#mesh1-geometry-normal" offset="1"/>
<input semantic="TEXCOORD" source="#mesh1-geometry-uv" offset="2" set="0"/>
...</p>
</triangles>
So I get down to reading my triangles into my program’s object for rendering later and I have two triangle lists part of the same mesh each with a different material. I have the material name there which references the material tag’s name attribute. A domTriangles object has a getMaterial() call, but it returns a xsNCName which is basically just a string. I have read you can find a dom or dae element by id, but this is by name.
How would I go about finding that material tag?
Or is there a better way to go about it than what I’m doing?