From my blog: http://www.mcfunkypants.com/2011/molehill-terrain-demo/
Molehill, Adobe's new Flash 3d API, can handle absolutely insane numbers of polygons and still render at 60 fps. I programmed a quick stress test demo (a heightmap terrain) that I was sure would bring Flash to its knees, but to my chagrin it was able to handle the scene with ease. In fact, I'm certain that I could double the number of polygons from 40 thousand to closer to 100 thousand without any framerate hiccups at all.
Note: Gamasutra strips out any Youtube Videos or Flash files - you will have to go to my blog to view the video or play the demo.
Controls: hold the mouse button down and move the mouse to look around, and use the keyboard arrow keys to fly around the mountainous landscape. Press the spacebar to make the world turn. Enjoy! (Flash Molehill Beta Required:)
Tested to work great in Firefox with the Flash Molehill beta drop 9 plugin as well as the new incubator release. Just remember to "enable hardware acelleration" in your Flash settings after installing the plugin. Once you have the new Molehill version of the Flash plugin installed on your computer, the .swf above should be redering a mega-complex 3d terrain at very fluid framerates. This will NOT work on the regular public Flash player: it you aren't a game developer you probably do not have the right Flash plugin version installed and you will not see anything. If you experience poor framerates or errors, not to worry: this is simple a tech demo using beta code. When the new version of Flash comes out that has Molehill, you can expect fabulous 3d graphics in your games the likes of which have never been seen in a Flash animation before. Just try to render 40,000 polies in software-only Flash and see what happens: the framerate would drop to the point that this animation would look like a slideshow. So how did I make it? I used FlashDevelop which compiles pure AS3 projects using Flex. In the code I set up a simple Molehill-compatible render loop using the beta SWC that Adobe has provided members of the pre-release program. In code, I use a BitmapData of a heightmap to describe the heights of the 40,000 points by generating x,y,z coordinates depending on how white each pixel is. Pure white is the top of a mountain and pure black is the lowest valley. This is what the heightmap image looks like:
These vertex coordinates are fed to the video card as a vertexbuffer, which allows your 3d video card to render all those polies in a single line of code once initialized. This is why Molehill is so insanely fast: your GPU does all the work. Even while rendering full-screen at 60fps, my CPU never goes above 10% use.
Incredible! I can't wait to continue to write tutorials and source code that uses Molehill.
Now for a little blatant self-promotion: I am in the process of writing a book, which will eventually be available on Amazon (and other stores), as both a PDF and a hardcopy version. Contracts have already been signed with my publisher, it already has an ISBN number, a chapter outline and everything! =D The book is called "Adobe Molehill Game Programming Beginner's Guide" and is written for complete Molehill beginners who are already comfortable with programming in Flash as3. If you are interested in reading about Molehill Game Programming, please get in touch with me and I would be happy to let you know when the book is published.
ChrisK aka McFunkypants
My blog: http://www.mcfunkypants.com
I warmly encourage you to follow me on Twitter
(I *only* post about game programming):