8.2. General Model

Performing any action on the scene graph follows the general model described in this section.

  1. Initialize the action by constructing an instance of the action class. You can construct the action on the stack as follows:


    C++
    SbViewportRegion region(300, 200);
    SoGLRenderAction renderAction(region);
        

    .NET
    SbViewportRegion region = new SbViewportRegion(300, 200);
    SoGLRenderAction renderAction = new SoGLRenderAction(region);
        

    Java
    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:


    C++
    renderAction = new SoGLRenderAction(region); 
        

    If you create the action with new, don't forget to delete the action when you finish using it.

  2. Set up special parameters for the action. For example, the constructor for SoGLRenderAction( C++ | Java | .NET ) 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.

  3. Apply the action to a node, a path, or a path list. For example: renderAction->apply(root);

  4. Obtain the results of the action, if applicable. Some actions have additional methods that can be used with them. For example, the SoGetBoundingBoxAction( C++ | Java | .NET ) has one method, getBoundingBox(), that returns the bounding box computed by the action and another method, getCenter(), that returns the computed center.