UNDERSTANDING SCENE GRAPHS
What is a Scene Graph?
A hierarchical arrangement of nodes which are used to create a scene. The following
example shows a very simple Scene Graph that contains only four nodes. The Root Node
(ROOT) , a Light Node (LIGHT), a Transform Node (XFORM) , and a Geometry Node (GEO).
figure1
Some nodes like transform nodes and lights are used to affect the state of
the scene you are creating. This state stays in effect until modified by another similar
node.
Advantages of Scene Graphs
- Object grouping
- Level of detail switching
- Instancing of geometry and entire scene graphs sub-trees, provides better memory usage
- More powerful culling and more efficient database representation provides higher frame
rates
- Support for VRML and Open Inventor-style formats
- Lights and environmental effects enabled only in parts of database
- Multiple scenes
Definitions of Scene Graph Terminology
- Scene Graph Tree -- All of the nodes in a scene graph, arranged in a hierarchical
order. The nodes in the following figure are all in one scene graph
figure 2
- Scene Graph sub-tree A node and all of its descendants. A sub-tree in the
previous figure is shaded dark gray.
- Descendant Any node that is contained in the sub-tree of another node is
considered to be a descendant of that node. In the previous figure nodes F, G, H,
and I are descendants of node E.
- Ancestor Since node E has a sub-tree that includes nodes F, G, H, and I, it is
considered to be the ancestor of these nodes.
- Child Nodes A nodes direct descendant. Nodes B and C are
considered child nodes of node A. Node J is not a child of node A since it is not a direct
descendant of node A.
- Parent Nodes A nodes direct ancestor. Node A is a parent of
node C but not of node E since it is not the direct ancestor of node E (node C is the
parent on node E)
- Sibling Children of the same parent node are siblings.
Nodes F, G, H, and I are siblings.
- Root Node Each scene graph has only one root node. The root node
represents the start of the scene graph. Node A is the root node.
- Traversal Order The order in which the nodes in a scene graph are processed
while the simulation is running. The nodes in the previous example have been lettered to
show their traversal order.
- Predecessor Since nodes B and C are processed before node J they are considered
its predecessor. A nodes predecessor can affect the rendering of that node,
even though they might not be ancestors.
figure3
Scene Graph Traversal
- The scene graph above is used to represent a motorcycle. The following table lists the
contents of each node.
Node Letter |
Node Type |
Explanation |
A |
ROOT NODE |
start of the scene graph |
B |
TRANSFORM NODE |
sets position and orientation state. This state will affect all the
nodes in the scene graph. |
C |
GROUP NODE |
Groups other nodes beneath it. |
D |
GEOMETRY NODE |
This node would contain the geometry used to represent the motorcycle
chassis. Its position and orientation are affected by node B |
E |
SEPARATOR NODE |
Used to separate information from propagating through the scene graph.
In this case it will separate transform information |
F |
TRANSFORM NODE |
Used to set position and orientation information. This node will affect
all the nodes beneath the separator but not node J since it is after the separator in the
scene graph traversal order. |
G |
GEOMETRY NODE |
This node contains the geometry used to represent the front wheel of
the cycle it is affected by both transform nodes (B and F). |
H |
TRANSFORM NODE |
Used to set position and orientation information. This node will affect
all the nodes beneath the separator but not node J since it is after the separator in the
scene graph traversal order |
I |
GEOMETRY NODE |
This nodes contains the geometry that represents the rear wheel of the
motorcycle. It is affected by transforms B, F, and H since they are not predecessors of I. |
J |
GEOMETRY NODE |
This node contains the geometry that represent the motorcycles
headlight. It IS NOT affected by transforms F and H, since they are beneath a separator
node. However it IS affects by transform node B. |
chart 1
Options for creating Scene Graph
- A number of methods for creating scene graphs.
- Parts may be constructed using different methods
- Function calls for:
- Disassembling
- Re-assembling
- Re-arranging
- The methods are:
- Load a scene graph description for a file. VRML 1.0, Open Inventor, and Multigen all
create files that are suitable for this use.
- Construct the graph node by node. WTK provides function for creating nodes and placing
them at specific positions in the scene graph.
WorldToolKit Node Types
- Nodes in WTK can be grouped into 3 distinct types
- Geometry Nodes
- Contain the representation of visible entities.
- Node types include:
- Geometry nodes
- Movable Geometry nodes
- 3d text
- Attribute Nodes
- Used to affect the way geometry nodes are rendered.
- Node types include:
- Fog Nodes
- Light Nodes
- Movable Light nodes
- Transform Nodes
- Procedural Nodes
- Used to control the way a scene graph is put together and processed.
- Node types include:
- Anchor nodes
- Group nodes
- Inline nodes
- LOD nodes
- Movable LOD nodes
- Switch nodes
- Movable Switch nodes
- Separator nodes
- Movable Separator nodes
- Transform nodes
Node Definitions
Node |
Definition |
Can it have children? |
Does it effect state? |
Geometry |
Displays a set of polygons, together with a material |
NO |
NO |
Fog |
Simulates fog, smoke, or mist |
NO |
YES |
Light |
Specifies a light (point, directed, or spot) |
NO |
YES |
Transform |
Sets position and/or orientation information |
NO |
YES |
Anchor |
Contains a string property. Used of URLs for non-geometric information |
YES |
NO |
Group |
Has children by no other properties |
YES |
NO |
Inline |
Children are read in from a file |
YES |
NO |
Level of Detail (LOD) |
Swaps in objects as a function of the viewpoint distance |
YES |
NO |
Root |
Acts as the topmost node in a scene graph. Each scene graph can have only one root
node. This node CANNOT be shared with any other graph. As the top node in its hierarchy,
this node can have no parent node |
YES |
NO |
Separator |
Prevents state information from propagating from its descendant nodes to its sibling
nodes |
YES |
NO |
Switch |
Controls which of its children will be traversed |
YES |
NO |
Transform Separator |
Prevents just the transform state from propagating from its descendant node to its
sibling node |
YES |
NO |
chart 2
How the Scene Graph is Rendered
- Every WTK window has a scene graph associated with it
- Scene graph rendered automatically into the window as the simulation runs
- WTK windows can reference different scene graphs or the same scene graph
- Different scene graphs may have common sub-trees. This means that the same geometry can
be referenced by more than one scene graph
- Each scene graph has a single root node
- Traversal begins at the root node of the scene graph
- Traverses tree top to bottom and left to right
- Nodes are evaluated and processed.
- Depending on the type of node WTK will do different things:
- Geometry nodes -- Draws the specified set of polys
- Procedural nodes -- Process the children of this node. Depending on the type of
traversal directed by the node.
- Attribute nodes -- Modifies the current state, which determines the
appearance of subsequent geometry.
Scene Graph State
- The state of the scene graph can be described as how your geometry is being rendered at
any particular point in the scene graph.
Figure 4
- In figure 4 the Light Node would light the geometry in the GEO node since
its state is pushed onto the stack before the geometry node is traversed. The transform
node would also affect the state of the geometry since it precedes it in the scene graph
figure 5
- In figure 5 a light node is added at the end of the scene graph. This node
WILL NOT affect the state of the geometry since it is traversed after the geometry node,
therefore the geometry node will not be lit by this light.
Managing the state of the Scene Graph
- Separator and Transform Separator Nodes are used to manage the state of the scene graph
by isolating the effects of the attribute nodes.
- Note that neither actively modifies the state of the scene graph, they prevent the
descendant attribute nodes from affecting the state of the sibling nodes.
Separator Nodes Vs Transform Separators
figure 6
- In figure 6 the separator node blocks the transform (xform2) from
affecting the state of the geometry (geo1). It effectively blocks the information from
propagating back up the tree.
- The transform (xform1) affects geo1 and geo2 because the separator DOES NOT block
the state coming into a branch in the scene graph
- Now you can independently move geo2 without it affecting geo1. But what happens if we
want to move a light around?
figure 7
- In figure 7 the geo2 has been replaced with a light (light2). If we want to carry this
flash light around in our hand without allowing the state information in xform2 to move
geo1 we run into a problem. Remember that separator nodes stop attribute information from
propagating back up the scene graph tree. Therefore the geo1 WILL NOT be affected by the
state information in light2. This is not the desired result since our flashlight should
illuminate the way through the scene. There is a special separator node called a Transform
Separator that will allow only lighting state information to "trickle" through
and affect the state of geo1 while still blocking the transform information from
propagating back up the tree.
figure 8
- Figure 8 shows the proper way to handle this problem using a Transform
Separator Node instead of a regular separator. Now you can move the light around without
xform2 affecting geo1 and light2 affecting geo1.