Archived

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

SceneGraph how the hell do they work?

This topic is 5129 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

I really need some easy explanation on how to implement it.. maybe some easy code or pseudo code I know I store them into nodes somehow but I can''t figure out how to begin coding a simple SceneGraph..

Share this post


Link to post
Share on other sites
Then get "Interactive Computer Graphics" by Edward Angel. In Chapter 9 he discusses scenegraphs and how to implement a simple scenegraph API in OpenGL.



"Yeah, I would''ve killed you, but I''m glad I didn''t - the paperwork is a bitch"

Share this post


Link to post
Share on other sites
Some links that might help:

http://www.gamedev.net/reference/articles/article1267.asp
http://www.cc.gatech.edu/classes/AY2004/cs4451a_fall/scene.pdf

They both are more OpenGL-specific, but the theory is there.

Share this post


Link to post
Share on other sites
I want more specefic examples of how to create the Nodes and what should I store into the nodes and how should I store my objects in the tree?

I have no problems of understanding how a tree is buildt it is one RootNode with some children inside and each child has there own children and so on.. but where is my objects?
are they derived from the cNode class ?
or are they in a list in the End node or something?
should the node be at the base of everything.. not derived from any other class?

e.g.
class cNode : public cRenderAble {

list ChildNodes;

};

class cEntity : public cNode {
// stuff for my entity.
};

or like this

class cNode {
list ChildNodes;
list Items;
};

class cEntity : public cRenderAble {
};


in my first example I can create a SpaceShip model like this

cEntity *spaceship = new cEntity;
spaceship->LoadModel("spaceship.mesh");

World->addChildNode( spaceship );

or in my second example i have to create both a node and an entity

cNode *shipNode = new cNode;
cEntity *ship = new cEntity;
ship->LoadModel("spaceship.mesh");
shipNode->AttachModel(ship);

World->addChildNode( shipNode );


The first example only needs one instance of an cEntity.. becouse it is derived from cNode it has the posibility to have children tagged to it.

while the second example has a base Node for my entity and then I can attach children to that node to derive the translation & rotations... the problem with this solution is that I have to create one Node instance and one entity instance for every thing I need to display..

if I go back to the first solution I only need one instance of an cEntity object that represent both a node and an object..



[edited by - McZ on November 29, 2003 2:43:37 PM]

Share this post


Link to post
Share on other sites
I would make the entity a Node. The reason behind this is flexibility. You can use this to say define a skeleton for a model using the same distance, but when traversing for rendering just stop at the mesh level, hence having some control over the depth of access to the tree, in this example you don''t need bone info to render, but the bones are very much part of the hierarchy in terms of transformations and when it comes to processing physics.

James

Share this post


Link to post
Share on other sites
The first thing to realise is that there is no single right way to create a scene graph. A scene graph is quite a vague concept.

quote:

While the second example has a base Node for my entity and then I can attach children to that node to derive the translation & rotations... the problem with this solution is that I have to create one Node instance and one entity instance for every thing I need to display..



This is the solution that I prefer. Consider that you''ll have functions for placing entities in the scene, so the housekeeping for having the two seperate objects only needs to be written once.

For me this method makes more sense, because you are seperating two related, but independent concepts. The concept of a coordinate space, and the concept of an entity in the scene, which occupies that space.





Share this post


Link to post
Share on other sites
quote:
Original post by treething
The first thing to realise is that there is no single right way to create a scene graph. A scene graph is quite a vague concept.



A scenegraph really means the hierarichal relationship between objects within the scene, however the term is sometimes used to describe spatial trees since a really useful scenegraph combines the two techniques to allow for an efficient method of performing operations upon the scene. Of course it ultimately depends on whether your engine is purely for graphics, or whether you need physics / fully dynamic world etc..

In the case of pure graphics you can get away with using a single spatial tree e.g. BSP or octree and in some simple cases you can even use these to apply some physics as well. However as your scene gets larger and there are more potential interactions between objects you will need more ways to cull non-potential objects for different applications.

Can I suggest that if this is the first time you''ve programmed this that you look at getting a structure such as an Octree running, but bear in mind the potential to expand the system as outlined here and countless other threads.

James

Share this post


Link to post
Share on other sites
I have created an octree once in a small Terrain engine I made for fun and to try Frustum culling and Octree... and so I have made a verry simple BSP tree too.. I havn''t tested that engine very much though.. but I can''t figure out how/where to begin coding..

Share this post


Link to post
Share on other sites