Way back in the days of Flash player 10, I started looking into the different technologies available for drawing extruded shapes. At the time, the Flash player could only handle unshaded scenes of about 3,000 polygons…" />
Way back in the days of Flash player 10, I started looking into the different technologies available for drawing extruded shapes. At the time, the Flash player could only handle unshaded scenes of about 3,000 polygons before falling over, because it was running entirely on the CPU. Because that wasn’t going to be satisfactory, I concluded that the best available alternative to Flash was Unity3D. Version 11 of Flash has added hardware-accelerated 3D, though, so I wanted to look at whether it’s practical to use it again. Unfortunately, Stage3D – and the things built on it like Away3D 4 – are still pretty new so there are a lot of features still missing that you’d normally expect to be standard. One of those things is ‘complex polygon tessellation’ . Since everything in a 3D engine has to be made out of triangles, it’s necessary to break up more complex objects into triangles before they can be drawn properly. It’s a pretty ubiquitous problem with some well-known solutions, so it’s only a matter of time before someone converts one of those solutions to Flash. In the meantime, though, I want to build complex extrusions!
The code above is using Away3D 4. I’m using the ‘LinearExtrude’ class for the height component of the object, and standard Plane primitives for the caps. The caps have a bitmap texture with transparency on them, which I have generated at the same time as the height component. A bitmap cap has the advantage of having a significantly lower polygon count than a tessellated extrusion cap, particularly for more complex objects, but has the disadvantage that the engine can’t do the same object culling with the cap triangles – because some of the faces are transparent, it has to draw everything that might be behind one of these planes in order to make sure that an object isn’t being incorrectly missed out. Another downside is the resolution of the cap texture – you can see when an object is too close or when the angle is too oblique that the polygon cap is slightly blurry and doesn’t quite match up with the height component. It’s not perfect, but it’s working well enough to keep going with.
No comments yet.
RSS feed for comments on this post. TrackBack URL
Powered by WordPress