Papervision3D: Materials and Collada

Today I spent a little of my spare time playing with Papervision3D, in order to participate in a Papervision3D Competition. I quickly ran into a problem, to which I couldn’t find the solution the usual way (i.e. Google). However, I finally got it working, and I’m glad to write up my findings here for those of you who might face the same problem.

The Problem

The problem I faced was simple. I downloaded a few Collada files from Google 3D Warehouse, expecting it to work in my project out of the box. It did work, but it gave me a completely untextured model, like so.

Image1

After a little looking around, I spotted a post which suggested looking inside the DAE file, to check if its materials are pointing to the right locations!

The DAE File

I thought this might solve my problems, but unfortunately it was not the end of the story. When looking inside the file, I eventually came across these lines of markup.

Image2

While this gave me a little more insight, it did not help me much, since the Collada file did not come with any texture files at all. I did, however, spot an interesting attribute called “name”, which specifies the name of the material it is looking for.

The Actionscript

Back I went to my code, and had a look through the MaterialsList API. I decided to have a crack at the “addMaterials” method, which allowed me to specify a name for each material I add.

Image3

The Result

Image4

Lo and Behold! It worked! My Collada model was now “textured” with basic colours (though it isn’t too hard to make it use BitmapFileMaterial or even MovieMaterial).

The wonderful model shown here is the Spaceship/Fighter by SciFiDude.

Did this article help you? Be sure to post a comment below!

Share this post: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • Reddit
  • Facebook
  • Google Bookmarks

4 Responses to “Papervision3D: Materials and Collada”

  1. hey Daryl, thanks for the post it helped me a lot, well done for cracking it!

  2. Many thanks!!

  3. thanks :)

  4. Tkx m8, made my day:P

Leave a Reply

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