Many things are cool, like this screenshot of XCode for example…
this is what happens when debugging iOS apps that use OpenGL, there’s a handy button to click that lets you poke around in the OpenGL ES state. It shows running GLSL programs and the state of the buffers. Quite useful when you’re confronted with a black screen.
Anyway, that’s not what a scene graph is, I’m not even sure if what I constructed is really a scene graph either. I do know it’s a really handy concept that has made structuring my 3D code so much simpler. I always had the problem of how to put a 3D object in the game world at one position, and then have something like a ‘drone’ ship orbit that object, or make ‘bullets’ shoot out of the ship. Or something simple sounding like have a camera that follows an object (this is not simple BTW, it effectively involves undoing all the transforms made to your scene so that the bit the ‘camera’ looks at is positioned at 0,0,0. The maths is horrid but this thread explains matrix inversions well enough).
What I created was a simple tree structure that holds the relationships between game entities. Each Entity object has a list of pointers to child Entity objects and so on. This is just an STL vector of pointers to ‘Entity’ objects. There’s an update function that recursively goes down the tree calculating the ModelView matrix of each entity based on the ModelView matrix of its parent. Recursion is cool like that, if you’ve got a tree you need recursion it makes calculating things very easy.
However, traversing a deeply nested tree isn’t so useful if I want to find a specific entity (like the player ship because the user just poked the screen), so rather than the tree being a container for all the entities it merely defines relationships between entities. The entities themselves live in a bog standard array that I can quickly loop through pulling out things to draw on the screen, etc. Making an Entity first involves finding a free slot in the master Entity array, then adding its pointer to a suitable parent Entity.
Oh in the demo video ignore the missing right-hand edge of the canyon, I was testing out different camera angles. One day I’ll work out how to smoothly move the camera from one angle to another to do fly-bys and different game modes. I’ll probably work that out on the same day I make the enemy ships fly by themselves since it’s the same thing
Next thing – multi touch so there can be steering of the ship and shooting. I got rid of the tilt controls, they were annoying me (mostly because the light in my room was reflecting off the screen!).


