drewish


Using Cinder's CameraOrtho and VBOMesh to draw cubes   23 August 2014

I was browsing through OTAKU GANGSTA when I came across this image:

grid of cubes

I thought it was beautiful, and trying to replicate it seemed like a great project.

I started by using gl::drawCube() to draw a few cubes. It uses triangles for the faces, rather than quads, so the wire-frame rendering didn’t look right. But it made it easy to get the cubes into a grid so I could start figuring out how the rotations should work:

Cubes with one axis of rotation

The next step was figuring out how to use Cinder’s CameraOrtho class to setup projection matrices with no perspective. Then I started trying to matching the number and size and spacing of the cubes:

Everything's looking good but triangular

At this point all that was left was to switch the cube drawing to use quads. I used the somewhat broken VBOMesh example code from the Guide to Meshes In Cinder by Joshua Noble as a starting point.

After a bit of tweaking the cube size and spacing I got a final result that I’m really happy with:

Final output

The source code:

← Back to the top