PDA

View Full Version : What is a scene graph?



juggernaut
03-20-2012, 04:32 PM
So far, it makes sense to me why you would put objects in a hierarchy in relation to other, where objects "down the hierarchy" inherit the transformations of the object above it. So like a sword, in addition to its own transformations, inherits the transformations of the person holding it, which in turn inherits the transformation of the horse it's on.

This technique is explained in depth here:
http://www.arcsynthesis.org/gltut/Positioning/Tut06%20Fun%20with%20Matrices.html

Where does the idea of a "scene graph" come into play? I tried reading the wikipedia article: http://en.wikipedia.org/wiki/Scene_graph
But it does not really make sense to me why they use a graph or tree to model an entire scene. What I would do is just keep all the objects in a list and render them in order (maybe after some frustum culling), using the "hierarchy" technique as needed. Why do we need a tree or graph model?

Bruce Wheaton
03-20-2012, 11:00 PM
You seem to be saying:

I can put all my drawing into a simple scene graph and render that.

Why would I need a scene graph then?

Good question.

Bruce

Alfonse Reinheart
03-21-2012, 01:20 AM
This technique is explained in depth here:
http://www.arcsynthesis.org/gltut/Positioning/Tut06%20Fun%20with%20Matrices.html

Where does the idea of a "scene graph" come into play?

That is a scene graph. Just because that tutorial didn't call it a "scene graph" doesn't mean that it isn't.

The parent-child relationship of nodes in the scene is a data structure called a tree. Trees are a restricted form of graph. So you have a scene of nodes in a graph. Scene graph.

Indeed, the "Further Study" (http://www.arcsynthesis.org/gltut/Positioning/Tut06%20In%20Review.html) section of that tutorial has this:


Reimplement the Hierarchy tutorial, instead using a more generic data structure. Have each node be a struct/class that can be attached to an arbitrary node. The scene will simply be the root node. The individual angle values should be stored in the node object. The node should have a render function that will render this node, given the matrix stack. It would render itself, then recursively render its children. The node would also have a way to define the size (in world-space) and origin point of the rectangle to be drawn.

This is could more easily called "Implement a generalized scene graph."

thokra
03-21-2012, 01:54 AM
A quite informative survey about scene graphs, although a bit dated, can be found here:

http://www.realityprime.com/articles/scenegraphs-past-present-and-future

Please note, the über-scene-graph approach, as proposed in literature on 3D engines etc. is considered outdated even by their authors.

Über-scene-graph meaning that you want to centralize all tasks, all responsibilitites and all rendering, state management, animation a.s.o. in a single data structure.

Edit: I just remember the crucial observation made by Gregory in Game Engine Architecture, that the choice of data structure to represent the scene is highly dependent on the type of application. You need to find out what your app needs and then select the appropriate data structure. Not just code a huge system and find out it doesn't exactly fit your purpose.