Chapter 14: Node Kits

Node Kits are a collection of nodes with a specified arrangement, which make the creation of consistent, structured databases easier. Node kits also support nesting hierarchies, so many levels of relative motion can occur.

Up to Summary of The Inventor Mentor
Back to Chapter 11 - File Format


Summary

Node kits are a collection of nodes with a specified arrangement. The template associated with the node kit decides which nodes can be added and where they should be placed. This makes it so that with node kits, you don't have to create and arrange each node individually.

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.

Example

Here is an example of the ease of using node kits for application-specific objects:

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.

Paths

A path can be returned from a pick or search action. The default is SoPath which ends the path at the node kit. You can also choose to cast SoFullPath, which includes hidden and public children of the node kit, or SoNodeKitPath, which only contains the node kits (not the intermediate nodes). It is also possible to create paths to a particular node kit part.

Catalogs

Each node kit class has an associated catalog, which lists all the nodes available in the kit. The node kit catalog describes how nodes are arranged in the subgraph (when they are selected), and it lists the available parts. For example: name of part, type of node, default type, is this the default?, name of parent, name of right sibling, etc.

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.

Glossary

Node Kit
Convenient mechanism to make Inventor node groupings.
Nodes
Basic item to create 3-dimensional scene databases. Each holds one piece of info (description of shape, light, etc.)
Scene graph
Collection of nodes, which is stored in a database managed by Inventor.
Node-kit catalogs
Describes how selected nodes in a subgraph are arranged, and lists the available parts.
Hidden children
Children of a node kit which are operated on, but you don't have direct access to them.

Author/Summarizer:
Sarah Ferguson <snpf@ugcs.caltech.edu>


Up to Summary of The Inventor Mentor
Back to Chapter 11 - File Format