A SERVICE OF

logo

Scene Graph Actions
85
You invoke an action by creating an instance of an action class and applying it to a node
(commonly the root node), for example:
csGroup* rootNode = new csGroup;
...
csDrawAction* renderAction = new csDrawAction;
renderAction->apply(rootNode);
In this example, a draw action, renderAction, is applied to the root node, rootNode, of a
scene graph.
When an action is applied to a node, each kind of node responds in its own way. When
a draw action is invoked on a leaf node, for example, it sets the values that describe a
shape. When a draw action is invoked on a group node, it applies the action to some or
all of its children.
Rendering the Scene
A csDrawAction causes leaf nodes to set the variables that affect the rendering of the
shapes in a scene graph and causes the shapes to be rendered.
A csDrawAction has the following get and set methods:
void reset();
virtual csTravDirective apply(csNode *node);
reset() resets the cull stack and transformation stack.
The virtual function apply() is the method you use to apply the draw action on a node in
a scene graph, for example:
renderAction->apply(rootNode);
where renderAction is a csDrawAction instance and rootNode is the root node of a scene
graph. A draw action can be applied to any node in a scene graph. If you apply a draw
action to a leaf node, the node may set a value but the action does not spread to any other
nodes.