FlashPlayer 10 Collada Parser
// May 25th, 2009 // Experiments, Flash 3D, Source code & tutorials
In a project I have recently done, I had (still have actually) some memory leak issues with the papervision3D DAEs. And since we have now “3D support” in the FlashPlayer, I tried to make my own collada parser from scratch.
But I soon stumbled on some problems.
- The drawTriangles method uses the same indices for the uv mapping and the vertices. In the collada they are separated (witch makes actually more sense)
- Drawtriangles doesn’t do z-sorting.
- Drawtriangles only takes one bitmap for the mapping.
Overcoming these problems is actually pretty simple. Just calculate and draw each triangle individually and do the z-sorting in between. But thats very very slow… So I had to drop the live mapping.
Instructions: Click on the stage to “render”, click on the blue circle to switch between models. If you don’t see anything, or the models are very small, you need to update your FlashPlayer.
» View example
Anyway, learned a lot of new things about 3D and I’m looking forward to the release of PapervisionX to see how they handled it, and how much of the new API they actually use.
Source code: collada_source (only works with Google sketchup colladas with bitmap materials)

















Hi, I’m working on something similar myself. I’ve done support for multiple meshes as well but still having trouble applying the transformations from the Collada file. Maybe you could point me as to how to use the data in the visual_scene node.
I just ignored these nodes in my implementation, but I know that they are important for some models. I assume you have to use the matrices in the nodes to transform and position the objects?
Yeah, I tried using the FP10 Matrix3D class methods for it but I can’t find a proper documentation for the collada format. The COLLADA specs at http://www.khronos.org/files/collada_spec_1_5.pdf seem to be broken. I seem to be implementing it wrongly, especially the rotation node.
[...] But when I saw all those normals on my test triangles, they reminded me of hair. So I combined my Collada Parser with my new knowledge, and created a fur renderer in [...]
Hey, it’s wrong:
> – Drawtriangles doesn’t do z-sorting.
Drawtriangles can be sorted
.. i have working example.
“The drawTriangles method uses the same indices for the uv mapping and the vertices. In the collada they are separated (witch makes actually more sense)”
I ran into the same problem. I fixed it by re-indexing the uvs. I created a new vector for the uv[t]s the same length as the vertex vector, looped though the vertex indices and filled the uv vector so that they match the indices. It’s not too hard since you can figure out the uv of a vertex from the Collada data.
But one bitmap per drawTriangles call is a pain. Instead of having a single indice vector for the whole mesh, I compute one for every texture.
For z-sorting I used the t values generated by projectVectors (on an unrelated note I finally figured out how the flash projection matrix works, and it has nothing in common with transform matrices, but now I can finally do off-center projections). Depending on the scene, I either sort the triangles per mesh or for the entire scene, which is slow because then I have to divide a mesh when part of it is behind another object and part of it is in front… But it works. Well up to triangle level, which still produces a lot of artifacts in some situations.
Nice blog by the way.
I know it was not the best way to do it. I was still learning these things
I have have an improved version here: http://www.neuroproductions.be/experiments/3d-normal-mapping-pixelbender/
But if you really want to see how a to render it fast, you should check out the Away3D FP10 lite source code.
So don’t use my source code to learn things. Its just a snapshot in my personal exploration of 3D in Flash.