Sign in to follow this  
Fabio de T P

Doubt on scene graph design

Recommended Posts

Hi, i have already coded my scene graph code.. my doubt is: should I put the transformation matrix inside the base node or as a new node type and put it as father of models that needs to move?? i put it inside the base node, because I was afraid of the overhead to enter in one more node when drawing the scene but making the transformation matrix as a node makes the base node more simple.. please, comment the pros e con about the two ways of doing that... thanks in advance ;-)

Share this post

Link to post
Share on other sites
Whether or not to put a transformation matrix in the base class of the scenegraph depends entirely on what you plan to derive for your scenegraph.

If your scenegraph contains nodes that cannot be logically or sensibly transformed via a matrix (think script-nodes, AI-nodes, or other nodes that dont usually contribute in any direct way to the rendering of geometry) then you would be imposing a memory overhead within those nodes to store this redundant matrix or even worse a performance overhead if you still accumulate this matrix when rendering the scene-graph.

Personally I use the composite pattern for my scenegraph, in this model only leaf-nodes can be rendered (nodes with no children), all other nodes with children are called group-nodes, derived from these group-nodes you can have the meat of the scene-graph including transform-nodes which do contain the transformation matrix. The overhead of traversing these extra nodes is pretty minimal in 'my' experience but your useage of your scenegraph could make all the difference as to which is more efficient.

This composite pattern is possibly one of the most common implementations of scene-graphs, its not necessarily the 'best' as that would depend on the intended purpose and what specifically you as a programmer envision the scene-graph to be, but the composite pattern is well understood by other programmers (who may or may not use your scenegraph in the future), it's well documented and incidentally easy to implement.

For more generic scenegraph info then snk_kid made a really good 'scenegraph resource thread' a while back. Or I myself (shameless plug, I know[smile]) wrote the majority of the wikipedia entry on scenegraphs, most of my contribution was mainly targeted at a people beginning to implement scenegraphs, more with the point of making them aware of 'what' can be done and the techniques often employed to implemented them, there are references to the composite pattern, the visitor pattern and the regular run-of-the-mill scenegraph that have a handful of virtual methods for each operation (like Render, Update, etc), so I think its worth a read though it only covers things briefy and basically a lot of it is cross-linked with other wikipages to follow things up (like the composite pattern that I've been going on about).

If you have more specific questions then by all means post here I'm sure myself or someone will follow them up.

Hope that was some help [smile]

Share this post

Link to post
Share on other sites

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

Sign in to follow this