Gameduino is 2D graphics shield, but it can still hustle up some 3D when it needs to. Here it is spinning a DNA-like double helix molecule in 3D.
The spheres are sprites - all 250 of them, close to the Gameduino’s maximum of 256. The sphere is a 64 frame animation (generated with povray) with the sphere at a varying distance. To plot a sphere, the code draws a sprite at a certain (x,y) coordinate. The z coordinate determines the sprite frame: frame 0 is a big sphere, 63 is a small one.
There are four palettes for the sprites, which give the four sphere colors.
The 3D molecule itself is stored as an array of 250 (x,y,z) points in flash, and the demo runs a full floating-point matrix transform on them, does a depth-sort to order them from back-to-front, then loads the sprites into the Gameduino’s sprite hardware. The 3D math code is the same as in wireframe.
On an Arduino, it runs at a respectable 14 fps, but on a LeafLabs Maple it runs at 75 fps.
Here is the sketch for download and here is me showing the speed difference.
Last modified $Date: 2011-10-09 18:27:00 -0700 (Sun, 09 Oct 2011) $