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:
Select a name for the new node class and determine what class it is derived from.
Define and name each field in the node.
Define an initClass() method to initialize the type information and to ensure that the required elements are enabled in the state (see Section 2.2, “Initializing the Node Class”).
Define an exitClass() method to clean up the type information. In the exitClass() routine of your class, use the macro SO__NODE_EXIT_CLASS.
Define a constructor (see Section 2.3, “Defining the Constructor”).
Implement the actions supported by the node (see Section 2.4, “Implementing Actions”).
a. For a property node, you usually need to implement the GLRender() and callback() methods (see Section 2.5, “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 SoCallbackAction SoCallbackAction as well as the getBoundingBox() method. You may want to implement a specific GLRender() or rayPick() method as well (see Section 2.6, “Creating a Shape Node”). For vertex-based shapes, you may need to implement a generateDefaultNormals() method (see Section 2.14, “Generating Default Normals”).
c. For a group node, you need to implement all actions to ensure that the children are traversed (see Section 2.7, “Creating a Group Node”).
Implement a copy() method if the node contains any non-field instance data (see Section 2.10, “The copy() Method”).
Implement an affectsState() method if it cannot be inherited from the parent class (see Section 2.11, “The affectsState() Method”).