PV3D: Access, Swap & Replace Collada / Dae-Material

Wow. In Papervision3D, the function to replace materials on a cube I’ve mentioned earlier also works on Collada models, which I wouldn’t have expected. Considering how well implemented Collada is (in all engines I’ve tried), I was seriously expecting that this isn’t possible. But it is. Just be sure to get the right material name and it works like a blast. Collada files are XML-based, so the name can be traced rather quickly:

   <material id="_1_-_Default-material" name="_1_-_Default">
     <instance_effect url="#_1_-_Default"/>

It’s the id, not the name. You can also trace it from AS3 with:


, which is surprisingly simple. Replacing it works the same way as with a cube:

dae.replaceMaterialByName(material, "_1_-_Default-material");

I suppose this was especially easy because I used a UV-Mapped model with only one material, but it should work the same for models with multiple materials.

1 Thought.

Leave a Reply

Your email address will not be published. Required fields are marked *



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>