|> We've recently converted to Open Inventor, and I'm running into problems
|> converting Node Kits. I'm using SoShapeKits that have an arbitrary number of
|> children, but the addChild function is no longer available for SoShapeKits (at
|> least not obviously). Is there a way to get around that, or do I have to keep
|> track of the number of children in another way? I need to be able to add and
|> remove an arbitrary number of children from an SoShapeKit object.
You are correct, the old method is gone. Instead, we've actually made
it possible for you to have more control over the childList than in
THE OLD WAY;
I take it you are refering to the method that took this form:
myShapeKit->addChild( "childList", myNewChildKit );
It's purpose was to add the kit "myNewChildKit" as the last kit in the
childList. Childlist, in turn, was a part of the SoShapekit myShapeKit.
THE NEW WAY:
In OpenInventor, this method is gone (reason explained below) and you
can achieve the same effect as follows:
// First get the list part
myChildList = (SoNodeKitListPart *) myShapeKit->getPart("childList", TRUE);
// Add to the list
myChildList->addChild( myNewChildKit );
In Inventor 1.0, you could only add/delete children to lists by working
through the nodekit that owned it. You could never actually get at the
list node itself and work with it directly.
Hence, the methods SoBaseKit::addChild(), SoBaseKit::removeChilde(), etc,
(each of which had a 1st argument that was the
name of the list) were provided to allow this indirect access.
We got a number of requests to be able to get an actual pointer to
the list part itself, so we created a new class of node, SoNodeKitListPart.
This class is a lot like a group node, except it restricts the types of
the child nodes you can add. By created this new safeguarded class,
we obviated the need to have such tight control of the list node itself.
So now you can just ask for the "childList" part and then work with it
using the same methods you would use with a group or separator.
Just be careful that you only add nodes of type SoSeparatorKit -- otherwise
the node will not be added! (If you use the debug library, errors will
be printed out when this happens).
---- New York Serenity Prayer: -------------------------------------------
God give me the strength to crush those in my way, the money to bribe
those who can help me, and the wisdom to know the difference.