[Up] [Previous] [Next]

6. Grouping Nodes

There are times when you will want to treat a collection of nodes has being related to each other in some sibling-like manner, instead of the more usual parent-child relationship between nodes in a scene graph. By grouping nodes together in this way, you can apply operations like transformations consistently to all member nodes of the group. The group actually becomes a node in the scene graph, and all the sibling nodes are children of the group node. The simplest type of group node class is Group. The usage is:

    Group {
        FirstNode
        SecondNode
        ...
    }

6.1 Separators

You might have noticed some of the examples so far contained something called a Separator node enclosing the description of the scene. Separators let you form a group of nodes and separate their effects from the rest of the scene. For example, if you added a Material node to make all objects red, then if that node was within the group of a Separator node, only the other nodes in the same group would be coloured red. Nodes outside of the group wouldn't turn red; they would remain whatever colour they are by default or through the actions of Material nodes outside of the group. It is a good idea to enclose your entire scene in a single Separator node, particularly if you want to include .iv files within each other.

In addition to containing child nodes, a Separator has the following fields, each shown with its default value:

     Separator {
          renderCaching       AUTO
          boundingBoxCaching  AUTO
          renderCulling       AUTO
          pickCulling         AUTO
     }

You will rarely have reason to use any of these fields.

6.2 Switch

Another type of grouping node is the Switch node. This node lets you specify exactly one child node to be available for traversal. Each child node has an index number, beginning with 0 for the first child. The child that can be traversed is specified by the value of the whichChild field; any other nodes in the group are ignored when rendering the scene. The default value for this field is -1, which means that none of the children are traversed.

It is important to understand what it means for the other child nodes to be ignored when rendering the scene. If a portion of a scene graph is not traversed, it won't have any effect on the image you see. This means, for example, that objects not traversed won't appear in the image, and material properties not traversed won't effect the appearance of objects in the image. If you create an animation by connecting the whichChild field to the output of some engine, then as the value of this field changes, a newly-selected child object would appear and any no-longer-selected sibling objects would vanish. This is essentially how the Blinker engine works.

More Information

More information about group nodes in Open Inventor is available in chapter 3 of Inventor Mentor, and in the man pages for SoSeparator and SoSwitch. Note that there is a somewhat related concept referred to as node kits. You can ignore discussions about node kits, since they are really only useful to C++ programmers.


MIT home page HTML written and maintained by Reid M. Pinchback (reidmp@mit.edu)
Last modified 96/06/10; copyright © 1996 MIT