Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
Overview

The file SoSubNode.h contains the macros for defining new node classes. The SO_NODE_HEADER() macro declares type identifier and naming variables and methods that all node classes must support. The SO_NODE_SOURCE() macro defines the static variables and methods declared in the SO_NODE_HEADER() macro. Other macros useful in creating new node classes are mentioned in the following sections.

Creating a new node requires these steps:

  1. Select a name for the new node class and determine what class it is derived from.
  2. Define and name each field in the node.
  3. Define an initClass() method to initialize the type information and to ensure that the required elements are enabled in the state (see Initializing the Node Class).
  4. Define an exitClass() method to clean up the type information. In the exitClass() routine of your class, use the macro SO__NODE_EXIT_CLASS.
  5. Define a constructor (see Defining the Constructor).
  6. Implement the actions supported by the node (see Implementing Actions).

a. For a property node, you usually need to implement the GLRender() and callback() methods (see Creating a Property Node). You may also need to implement getBoundingBox(), getMatrix(), and other methods.

b. For a shape node, you need to implement the generate- Primitives() method for the SoCallbackAction as well as the getBoundingBox() method. You may want to implement a specific GLRender() or rayPick() method as well (see Creating a Shape Node). For vertex-based shapes, you may need to implement a generateDefaultNormals() method (see Generating Default Normals).

c. For a group node, you need to implement all actions to ensure that the children are traversed (see Creating a Group Node).

  1. Implement a copy() method if the node contains any non-field instance data (see The copy() Method).
  2. Implement an affectsState() method if it cannot be inherited from the parent class (see The affectsState() Method).