Tito Dal Canton

Physics is reverse engineering

Rockland screenshot


Certainly one of my biggest programming efforts, Rockland is my little contribution to the vast world of realtime 3D engines. It loads a scene description from a simple text file and renders it in realtime. Just like a first-person shooter game, you can then walk inside the scene, with correct collision-detection on walls. Simple objects can also be placed in this 3D world. I was not interested on shooting at things, so there are no enemies and basically no animated characters to interact with. I was rather interested on the 3D engine itself: the math behind 3D projections and collision detection, how to render 3D objects in realtime and similar difficult topics.

The code

Rockland is written in C/C++, it uses SDL as its graphics and input layer, and exploits OpenGL for fast 3D rendering.

It loads a text file written in an HTML-like language (I called it Rockland markup language), which describes a simple 3D world, basically a set of connected rooms (called map sections) with textured walls. Textures are loaded from separate bitmap files. When the world description has been correctly parsed, you are dropped into the virtual world and you can wander around it. You can build even complex spaces, but the rendering engine is not very intelligent and you can't go beyond a small number of polygons without drastically affecting performance.

A nifty feature is the automatic calculation of shadows, which are then rendered using lightmaps and OpenGL multitexturing. Other features include fog, a decent collision detection engine and working physics (you can put balls into the world and they will bounce, both on walls and on other balls).

Get Rockland (2003/05/02 version)

Be aware that this experimental code is not really meant to be distributed, so you will probably find it messy and difficult to build (if you manage to do so).


Rockland was originally born as a MacOS application, and it exploited QuickDraw 3D RAVE for rendering acceleration through the video card. That was a great bench for learning the math behind 3D rendering on 2D screens, because with RAVE you could basically just render 2D textured triangles, not real 3D objects: you had to do all the projections and clippings yourself.

When OpenGL appeared on Macs and on my Linux box, I quickly realized it was a more human and interesting thing to work with. Rockland was then converted to OpenGL and was also ported to SDL so that I could develop it on my Linux box. I could then add other features like fog, shadows and loading the scene from files. Implementing physics was a lot of fun, because improper handling of numerical errors can make objects behave in strange ways. As a funny example, pairs of objects in Rockland tend to "attach" after a violent collision and start levitating together in the air, until they hit a wall or are detached by numerical errors. So you can create "blobs" of balls that levitate up to a certain height and then "explode" throwing the balls all around.

It was interesting to build different worlds and test the power of my little 3D engine. The main limiting factors were the lack of a human world editor (I had to write every coordinate of every point of every polygon in the description files, a real nightmare!) and the excessive simplicity of the rendering engine, which basically just blasted every polygon to the video card every time. It would have been interesting to implement an octree or a b-tree to better store the scene, but I never did it.

Despite my progress, Rockland never aimed at being a finite or usable application, and I ceased to work on it when my interest on realtime 3D programming faded. It was really amazing to work on such a project.


A room of my first world description. No shadows yet.

Testing OpenGL lighting.

"Debugging" a new area of the world (you can see face and vertex normals).

First tests for implementing shadow casting.

Bugs in some math can produce funny things in 3D engines, like in this experimental shadow implementation.

The power of lightmaps and multitexturing when applied to create shadows. You can also see a few of the famous balls on the left.

Links about 3D engines

Powerful 3D OpenSource engines are e.g. Crystal Space and Sauerbraten. Here you can find a list with many 3D engine projects and experiments around the net.

Last update: 2009-02-22