Recently a client asked me to do something which involved a lot of 3D cubes. I did some tests with cubes in the past and I knew the number of cubes you can render in Flash are relatively limited. Lets say you want 10×10x10 cubes = 1000 cubes =6000 sides = 12000 triangles, which is near or already over the limit. So I decided to take a different approach.

When you use an isometric perspective, the cubes are all the same. So instead of rendering each cube every frame, you can render only one cube and use that cube as a particle to render a full scene. This way you can easily extend the limit of +-1000 cubes to 20000 or more cubes.

Motivated by the very cool 3D pixel editor Q-BLOCK by Okuyama Kazuya, but mostly because it was great fun to make, I decided to take it one step further and started to build a simple 3D pixel engine.

3D pixel engine

Use the arrow keys to move the character, drag to rotate the scene.

» View 3D Pixel Engine

At this point, the Pixel3DObjects have x, y, z, rotationX, rotationY, rotationZ properties + they  support very basic animation (gotoAndStop). As input it uses transparent bitmapdata (I use pngs) Where the horizontal “sprites” are the depth layers, and the vertical “sprites” the animation frames (see img below).
3D pixel engine

But a 3D engine wouldn’t be complete without a possibility to import external generated 3D objects, so I also made a Collada parser witch converts a standard 3D mesh to a 3D pixel object:

3D pixel engine collada

» View Collada Elephant

For a good result I had to raytrace the mesh from different angles and regularly check for duplicated cubes. But for big or complicated objects it takes a while to generate all the needed data. So the elephant is actually pre-rendered and just uses the output data from the raytrace object.

I include the source code (with the two examples) but its not what you call user friendly and most features are incomplete or buggy at this point. So you are warned.
Source code: Pixel3D_source

  • Share and enjoy:
  • del.icio.us
  • Technorati
  • TwitThis
  • Digg
  • StumbleUpon
  • Google
  • Reddit
  • Facebook
  • description
  • E-mail this story to a friend!

Related posts:

  1. 3D Normal Mapping with Pixel Bender
  2. Round Pixel Flash Filter (FlashPlayer 10)
  3. FlashPlayer 10 Collada Parser
  4. 3D Fur Renderer
  5. Nurbs!

14 Responses

WP_Cloudy

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.