Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Scenegraphs and spatial indices

Sign in to follow this  


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.
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!