16.11. Using List Parts

Some node-kit parts are actually lists of parts. These lists, of type SoNodeKitListPart( C++ | Java | .NET ), are a special type of group that restricts its children to certain classes of nodes. Examples are “childList” (found in SoSeparatorKit( C++ | Java | .NET ) and SoSceneKit( C++ | Java | .NET )) and “cameraList” and “lightList” (both found in SoSceneKit( C++ | Java | .NET )). Whenever you add a child to a node-kit list, the group checks to see if that child is legitimate. If the child is not legitimate, it is not added (and if you are using the debugging library, an error is printed).

Use getPart() to obtain the requested list, then use any of the standard group methods for adding, removing, replacing, and inserting children in the parts list. (But remember that each of these methods is redefined to check the types of children before adding them.) For example:


C++
SoPointLight *myLight = new SoPointLight;
ls = (SoNodeKitListPart *) k->getPart("lightList", TRUE);

ls->addChild(myLight);
  

.NET
SoPointLight myLight = new SoPointLight();
ls = (SoNodeKitListPart) k.GetPart("lightList", true);

ls.AddChild(myLight);

Java
SoPointLight myLight = new SoPointLight();
ls = (SoNodeKitListPart) k.getPart("lightList", true);

ls.addChild(myLight);