Categories
3d

drawTriangles, z-sorting and culling in flash player 10

My first real post woop!

Ok here’s the scoop, if you have every played with 3d in flash and want your meshes to render correctly you will need to ensure its polygons are drawn in the right order (from back to front).

Simple, just sort them on the average z-value of their transformed vertices (or centroid).

Well you can stop right there, with the new flash player 10 extracting the z values can be a bit tricky, I have seen the uvt data generated used with some success to solve this issue but I don’t know if there is a better way lurking out there. Any ideas?

Following on from that is another issue… back-face-culling, this used be easy and only took a couple of ms to run through about 10,000 polygons to check their winding.

But what’s that you say?  “drawTriangles can do the culling for you if you only but tell it to!”

Well, although it can (using TriangleCulling.POSITIVE/NEGATIVE) that’s no use to me!!!!

I wan’t my triangles culled BEFORE I draw them, meaning I don’t waste time sorting polygons (the painful bit) that will never end up being rendered!

Now as yet, I’ve not come up with a method that can simply project all my vertices, cull all my triangles, then sort the badgers, then draw them. I am sure it’s got to be doable.. I just don’t have the brains.

I expect dozens of solutions and corrections…so hit me.

Leave a Reply

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