Up to Summary of The Inventor Mentor
Back to Chapter 11 - File Format
A basic version of SoShapeKit is shown in Figure 14-4, page 365.
When a node kit is created, particular nodes are there by default. (Separator nodes and internal nodes, for example.) You must explicitly request other nodes to be created. The nodes can be created in any order, because the kit will put them in the right place as specified by the node-kit catalog. You don't have direct access to 'hidden children', which are the nodes you create and remove in the node kit. The node kit takes care of the details for you.
With a cat simulation package, there are a several objects representing cats. Each cat has the same general structure in the scene graph, for example, legs and head, as well as cat-specific actions, for example, ScratchingHead(). Each cat can be dealt with in a similar way. Knowing the details of the subgraph representing ScratchingHead() isn't necessary because the general ScratchingHead() method exists. To create these new specific objects and methods, you need to extend Open Inventor by subclassing, which is described in Inventor Toolmaker.
To select parts and set values, you use something called 'set()'. You can also specify part names in the nodes of the node kits. The other two basic methods are GetPart() which returns the requested node, and setPart(), which inserts the node given as a new part in the node kit. There are macros for the above two methods, called SO_GET_PART() and SO_CHECK_PART(), which perform casting and additionally, type checking.
Some nodekit parts are lists of parts. These children, of type SoNodeKitListPart, are restricted to certain classes. You still use the standard group methods to operate on the parts list; the difference with these is that the group checks the type of children.
SoSeparatorKit is a class of node kit which can be used to create motion hierarchies. Classes derived from separator node kits inherit a childList of type SoNodeKitListPart. This aspect allows your attention to wander from each element (individual parts of each group kit) to how the parts of an object would move relative to other parts.
Again, instead of creating each node individually, specifying values for their fields, and arranging them in the proper places in a subgraph, the node kit already knows how nodes should be arranged. All you have to do is specify which nodes you want to utilize, and get and set the desired values for the nodes.
In short, node kits are flexible, already organized (convenient), and efficient (only the nodes needed are created). You can tailor node kits to your own groupings; an added plus is that code is readable and relatively short. Node kits give short-cut routines for creating nodes and setting their values, and hierarchies of node kits can be nested so relative motion can be more easily achieved.
Use one today!
Note: For more information on node kits, see "Open Inventor C++ Reference Manual," and "The Inventor Toolmaker," Chapter 7. And "The Inventor Mentor", from which this summary was taken.
Author/Summarizer:
Sarah Ferguson <snpf@ugcs.caltech.edu>