Scenegraphs and spatial indices

Published October 14, 2005
Advertisement
I've been reading a lot about scenegraphs in order to get a reasonable design for my current project. I thought it might help me to get some of the ideas straight in my head to think out loud. Perhaps you can set me right if I'm barking up any glaringly wrong trees.

All my objects will derive from a base object class; this includes the world, patches of the terrain, monsters and the player.

There is a logical relationship scene graph, whereby objects can have child-parent relationships with others. For example the World will contain the terrain and items, but also World>Monster>Weapon>dripping blood etc. relations are covered.

I'm also planning a spatial index. For this project it's a quadtree because all the action is on a height field based terrain. Pointers to the same objects as above are added to the appropriate node. This can then be used to speedup spatial queries: collision detection and AI. I guess that Monster>Weapon>Blood type relations are broken down and each object added to the spatial index on its own.

I believe operation is something like this:
. Every object in the scene graph is iterated through and updated for movement, animation etc.
. World matrices are combined for child objects, so that appropriate motion is made for Weapons held by Monsters etc.
. Check to see whether objects have moved out of their spatial index node. If not move them to the correct node. Either pop the object from the current node and add them back at the top to filter down to the correct node, or pop them from the current node and try to place it in another child of the parent node, if this can't be done then move to a higher parent until it fits again.
. Render based on the spatial index, culling branches that are not in the camera view frustum. Position is rendered using the world matrix that was stored while iterating the scene graph.
Next Entry Untitled
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

Advertisement