An OpenGL ES Adventure – Part 2

As I mentioned in my previous post on this topic, I’ve been working on a scene graph, render manger and material system for my GL engine. Some of the stuff has induced a bit of head-scratching, but on the whole things are coming together pretty well. I thought I’d share a bit about what I have in place now, and a few things I hope to complete soon.

My current scene graph implementation is probably not very optimal, but it works for what I need now. It’s essentially just a hierarchy of SceneNode objects and their subclasses. Each SceneNode can have an arbitrary number of children, which are stored in a custom dynamic array class.  A SceneNode is the highest level class; it’s not a renderable object, but is used for grouping objects. It’ll be able to act as “folder” in the scene graph. The SceneObject, which is a direct subclass of SceneNode, is the base class for all renderable objects. Sky, water, meshes etc will all be in the class tree of SceneObject.

The second SceneNode subclass I have written at the moment is a SceneCell, which is the physical equivalent of a SceneNode. It groups SceneObjects into renderable cells, which allows for quick culling. Cell_0 is always visible, as it contains basic environment objects like the sky, terrain, large bodies of water, etc. From that point on, a maximum of 4 cells will be visible at any time depending on what’s in view. The cell the camera is in will obviously always be rendered, and any adjacent cells that are visible.The contents of the cells will be further culled based on the view. The maximum occurs at the corner case. For example, if the camera is in the yellow cell then the green, red and blue cells will have potential renderable objects in them:

When the scene is traversed, if an object is deemed fit for drawing it is added to the appropriate group in the RenderManager. This set of classes will handle materials, batching and the actual GL calls to render the frame. This code is really in its infancy at the moment.

Anyways, that’s all for now. Hopefully I’ll have some more attractive in-engine screenshots for the next blog post on this topic. I still have to write a mesh loader, since I’m just using const arrays of vertices for all my objects at the moment. I’m considering using Blender’s .blend format for all my models, since it contains all the data I’ll need. I’ll have to look into that in a bit more detail though. I’ve also heard Collada is a good format.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: