Performing any action on the scene graph follows the general model described in this section.
Initialize the action by constructing an instance of the action class. You can construct the action on the stack as follows:
SbViewportRegion region(300, 200); SoGLRenderAction renderAction(region);
SbViewportRegion region = new SbViewportRegion(300, 200); SoGLRenderAction renderAction = new SoGLRenderAction(region);
SbViewportRegion region = new SbViewportRegion((short)300, (short)200); SoGLRenderAction renderAction = new SoGLRenderAction(region);
You can also use the new operator to allocate an instance of the action:
renderAction = new SoGLRenderAction(region);
If you create the action with new, don't forget to delete the action when you finish using it.
Set up special parameters for the action. For example, the constructor for SoGLRenderAction SoGLRenderAction SoGLRenderAction allows you to specify the viewport region as well as whether to inherit the current OpenGL settings. If you specify SoGLRenderAction renderAction(region, TRUE); you can use the current OpenGL values for line width, material, and so on. If you specify FALSE (or omit this parameter), Inventor sets up its own defaults.
Apply the action to a node, a path, or a path list. For example: renderAction->apply(root);
Obtain the results of the action, if applicable. Some actions have additional methods that can be used with them. For example, the SoGetBoundingBoxAction SoGetBoundingBoxAction SoGetBoundingBoxAction has one method, getBoundingBox(), that returns the bounding box computed by the action and another method, getCenter(), that returns the computed center.