16.12. Using Separator Kits to Create Motion Hierarchies

SoSeparatorKit SoSeparatorKit SoSeparatorKit is a class of node kit. All classes derived from separator kit inherit a part called “childList,” of type SoNodeKitListPart SoNodeKitListPart SoNodeKitListPart . Through use of the “childList,” separator kits allow you to think in terms of how parts of an object move relative to each other. Each element of the child list is, in turn, an SoSeparatorKit SoSeparatorKit SoSeparatorKit and may contain its own transform node. By nesting separator kits, multiple levels of relative motion can be achieved.

Figure 16.12, “ Hierarchical Motion Relationships shows how you might group individual parts that move together. Assume you have already made an individual SoSeparatorKit SoSeparatorKit SoSeparatorKit for each part in a balance scale, shown in Figure 16.12, “ Hierarchical Motion Relationships. You want tray1 and string1 to move as a unit, and tray2 and string2 to move as a unit. But when the beam moves, both trays and both strings move with it.

As you arrange these group kits into a hierarchy, you don't need to think in terms of the individual parts each group kit contains (“material,” “complexity,” and so on). You can think of the objects themselves (beam, strings, trays) and how they move relative to each other. The childList for SoSeparatorKit SoSeparatorKit SoSeparatorKit can contain any node derived from SoSeparatorKit SoSeparatorKit SoSeparatorKit , so any type of separator kit is permissible as an entry in this list.

The following code constructs the hierarchy shown in Figure 16.12, “ Hierarchical Motion Relationships. A working version of this model is provided in Example 16.3, “ Using Node Kits to Create a Motion Hierarchy at the end of this chapter.

scale->setPart("childList[0]", support);
scale->setPart("childList[1]", beam);
beam->setPart("childList[0]", string1);
beam->setPart("childList[1]", string2);
string1->setPart("childList[0]", tray1);
string2->setPart("childList[0]", tray2);
scale.SetPart("childList[0]", support);
scale.SetPart("childList[1]", beam);
beam.SetPart("childList[0]", string1);
beam.SetPart("childList[1]", string2);
string1.SetPart("childList[0]", tray1);
string2.SetPart("childList[0]", tray2);
scale.setPart("childList[0]", support);
scale.setPart("childList[1]", beam);
beam.setPart("childList[0]", string1);
beam.setPart("childList[1]", string2);
string1.setPart("childList[0]", tray1);
string2.setPart("childList[0]", tray2);

Hierarchical Motion Relationships

Figure 16.12.  Hierarchical Motion Relationships