Spinning DNA

System Message: WARNING/2 (<string>, line 5)

Explicit markup ends without a blank line; unexpected unindent.

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 :ref:`256 <sprites256>`. 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.

System Message: ERROR/3 (<string>, line 14); backlink

Unknown interpreted text role "ref".

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 the wireframe demo.

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.