Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
Adding Nodes and Actions to Inventor

If it weren't for extensibility, all actions could have been implemented simply as virtual functions on nodes. For example, GL rendering could have been a virtual function on the

SoNode class. Adding a new node class would require implementing virtual functions for those actions that could not be inherited from the base class.

However, adding a new action would be considerably harder. It is impossible for you to add a new virtual function to the SoNode class or to any of the existing Inventor node classes. The only way to add a new action would be to derive classes from all nodes that would support it and to define the new method for those classes.

Summary of SoEXTENDER Classes

Inventor implements actions as separate classes to solve this problem. Each action maintains a list of static methods, one for each node class (see Method List ). When an action is applied to the root of a scene graph, Inventor uses the method list to look up the method for each node in the scene graph, based on the type identifier for the node class. See Runtime Types for more information on class type identifiers.

Method List

For convenience, the base SoNode class registers static methods for all built-in Inventor actions; each of these methods calls a corresponding virtual function for that action. For example, SoNode registers a static method for SoGetBoundingBoxAction that calls the virtual getBoundingBox() method. All classes derived from SoNode can redefine getBoundingBox() in standard object-oriented fashion. If a class does not redefine a method, it inherits the method from its parent class

Most of the virtual methods on SoNode do nothing and must be redefined by the individual node classes. A few, however, such as the SoNode virtual methods for search() and write(), actually implement the action, since most nodes perform the action in the same way. In most cases, nodes can simply inherit these methods without redefining them.

Details on how to add a new node class are given in Creating a Node. Adding a new field class is described in Creating a Field.

If you add a new action class to Inventor, you need to set up the list of methods for the nodes that support the action (shown in Method List ). This list contains one pointer to the static action method for each node class that supports the action. Adding a new action is described in Creating an Action.