Creating Scene Graphs
67
Figure 5-2 Multiple Root Nodes
Applying Actions to Multiple Root Nodes
If a scene graph has multiple root nodes, an action applied to one of the roots would only
traverse the descendants of the specific root node. While this hierarchy of nodes is legal,
if your application is going to draw both scene graphs anyway, you should create a single
root node common to both scene graphs. In Figure 5-2, this could be done by adding a
group node above the root nodes shown, thus making them children of the single group
node. The advantage to this construction is that you do not have to apply the same action
repeatedly to different root nodes.
Actions applied to a root node flow (potentially) to all of the other nodes in the scene
graph. Passing the action from one node to another is called traversing. As an action
traverses a scene graph, variables set by the nodes in the scene graph change the
graphical context, which, in turn, changes the objects in the scene according to the node
values.