Skip to main content
GameDev.net gamedev.net
🔒 Locked

Scene Graphs

Started by MelvinElvin Nov 20, 2003 at 11:01 PM 3 replies 1.2k views
Original Post
MelvinElvin
MelvinElvin
Hi guys, just looking over some scene graph stuff for the first time. I certainly understand the underlying principle, but it seems like 1 obvious optimisation is missing. As far as i read, internal nodes store transformation and parameter sort of stuff (textures to bind, translations and rotations to perform etc.) and the leaf nodes contain the vertex data. Now say if you had a model of a human which was made up of a head, torso and legs. Wouldn''t it be sensible to store an internal node that contained essentially a bounding box of vertex data of all of those sub-parts which represented the whole model, then check that against the frustrum and then if that fails you can cull all of the 3 parts, if it succeeds you go on to test each one individually? maybe this is already the concept and i''ve just misunderstood. if not, why isn''t it the way to do it? seems like an obvious and helpful optimisation that stood out to me as i was reading it.
GSACP: GameDev Society Against Crap PostingTo join: Put these lines in your signature and don't post crap!
treething
treething
Most scene graphs are hierarchical in nature. So if you have 3 grouped meshes (head, torso, arms), then they could all be children of a node labelled "person". The bounding volume for a node should be the bounding volume of any attached geometry plus the bounding volumes of any child nodes.

MelvinElvin
MelvinElvin
okay cool, but then you''d need to make a distinction between drawable and non-drawable geometry? since if a person is made up solely of head, torso and arms then the actual person node won''t contain any vertex data that you actually want rendered, just vertex data you want to check against the frustrum etc.

thx for your help.
GSACP: GameDev Society Against Crap PostingTo join: Put these lines in your signature and don't post crap!
treething
treething
It helps to have some level of abstraction in a scene graph. The graph should be composed of an abstract type called Node and links between these nodes (e.g, child nodes). The node class should have several abstract methods such as GetBoundingVolume and Render. Then you derive 2 classes from Node. The first is Mesh, which would probably be the same as your current node type. It returns its bounding box in the GetBoundingVolume method, and renders itself in Render. The other type would be a placeholder type, used to define hierarchies. Its GetBoundingVolume method returns the sum of the bounds of its child nodes. Its Render function would be empty.

In my scene graph I do things a little differently. I have a class called Frame that defines the actual hierarchies. It contains a transformation matrix, pointers to its child Frames, and pointers to Nodes. The Node is an abstract type like above, but in my scene graph it doesnt have children. Thats the job of the Frame class.

There is no single right way to create a scene graph, but abstraction is good because it allows you to add new node types later on (eg, particle effects, skinned meshes) without changing the graph itself.

HTH,
Chris
MelvinElvin
MelvinElvin
cool, thanks a lot, you''ve been really helpful.

yeah i figured a polymorphic call would be the way to go over an ever expanding bunch of if statements.

I''m getting some ideas for my own abstractions already; you''ve inspired the thought processes
GSACP: GameDev Society Against Crap PostingTo join: Put these lines in your signature and don't post crap!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.