Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

kkitchin

Scene Graphs, the Universe and Everything

This topic is 6085 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm a reasonably experienced programmer who has just started out with OpenGL. Its always been an ambition of mine to write a game engine, so now I am finally getting around to it. Thanks to plenty of beer and Doritos I've got to a point where my first graphics engine is coming along quite nicely, I've got MD2 models loading and animating (ok,ok _slowly_ animating ), terrain, particles etc. All pretty basic stuff. Now I want to move this engine out of nursery school and into the real world (so to speak). I want to start implementing a real scene graph. I have some ideas, but before I plunge into the code I thought I'd turn to the Nehe gurus for comments and advice. As I understand it, a scene graph is a hierarchical structure used to display the scene. Its hierarchical to allow you to do nifty things like cull parts of the scene outside of the view volume, work out what objects to test for collision detection, support local lighting and other environmental stuff etc etc Here is my design for a scene graph for your comment, let me know if I'm getting remotely warm: The scene graph will be a tree of Nodes. Each Node will contain the following things: a bounding box a list of surfaces (optionally) an environment controller The bounding box is just a simple axis aligned box that defines the space occupied by the node. A child node must fit within the bounding box of its parent. The list of surfaces is just the triangles, quads etc that will be drawn when this node of the graph is rendered. The environment controller will set up local lighting effects and other environmental stuff (fogging/gravity/wierd stuff i can't think of yet)for this node. So what does this give me? The two main benefits I can see are for rendering and collision detection. For rendering I would draw the scene like this:

 Start at the root node (which contains all other nodes)
  For each child node
    If the child node is visible 
        If the child node has an environment controller
           save the current environment
           set up the child environment
        end if
        render the child node (draw all surfaces) 
        recurse to the child node (so its children are processed)
        restore the current environment (if necessary)
    end if

  
This would only draw the nodes of the graph that are visible, and would set up local lighting conditions etc as needed. For collision detection, I would descend down the tree until i find the smallest node that contains the object (eg a player model) I am testing against, then test the object against all the surfaces in this node and the children of this node. This should ensure that I'm only testing against the bare minimum of surfaces. This design should work for an octree style graph (I hope). A possible variation would be to use a bounding sphere instead of a bounding box for simpler testing. Thanks for reading this far! Any suggestions would be welcome. Keef ------------------ Trouble is my business ------------------ Edited by - kkitchin on November 21, 2001 4:08:04 AM

Share this post


Link to post
Share on other sites
Advertisement
LOL... I think you got it better than most of us....
anyway, your plan looks good to me !!

good luck

Share this post


Link to post
Share on other sites
Hi,
looks good so far. There is one suggestion i can give you. You "loose" Octrees instead of normal Octrees. With a normal Octree you will have many faces or objects that are between 2 nodes an a loose Octree will help you to create an 90% perfect Octree.

Bye

Punika

Share this post


Link to post
Share on other sites
Hey,
What exactly is the difference? I''m gonna be doing this soon myself, so I should probably get this figured out. "loose" Octrees?? I have everything set up with recursive linked list. eg:

3-obj
1-obj
2-obj
3-obj

would be the hierarchy. So what SHOULD I be doing?

Alex Broadwin
A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."
"The answer is out there."
"Please help, I''m using Windows!"

Share this post


Link to post
Share on other sites


Thanks all for your comments, the loose octree idea sounds great.

(
I found a good explanation of the concept here at
http://www.tulrich.com/geekstuff/partitioning.html
)

Cheers

Keef

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!