A SERVICE OF

logo

68
Chapter 5: Building a Scene Graph
Creating A Sample Scene Graph
Example 5-1 is a simple scene graph.
Example 5-1 A Simple Scene Graph
// create the root node of the scene graph
csGroup *root = new csGroup;
// create the nodes for the scene graph
csSpotLight *mySpotLight = new csSpotLight;
csShape *myShape1 = new csShape;
csShape *myShape2 = new csShape;
// Add the nodes to the group node to create a scene graph
root->addChild(mySpotLight);
root->addChild(myShape1);
root->addChild(myShape2);
In this example, a root node is created using the new directive and children nodes are
added to it using the csGroup::addChild() method. The order in which the children are
added to the root node is the order in which the nodes are acted upon when an action is
applied to the root node.