PDA

View Full Version : How do I traverse to a child of a SoSeparator pointer?



MisterWanderer
9th March 2012, 00:11
First off I am working in a large code base that I do not as yet completely understand.
For this reason I am not entirely sure which functions were called to load the scenegraph from the file to create the structure I have but I do know that it is loading AOK and displaying. Also I am using C++.

To the problem:
I have a SoSeparator pointer with 3 children. The I am not sure what the first 2 are but the 3rd one seems to be all of my geometry from the file I loaded. I THINK this means that the 3rd child is the top level SoSeparator loaded from the file (see below).

My ultimate goal here is to get a pointer to the Separators with the translations,rotations and scaling in them.
Once I get there I can replace things on the fly. (I know how do do that bit)

In addition, If anyone knows a good tutorial with varied SoQt coding examples in C++ I would LOVE to hear about it.

File loaded as below
#Inventor V2.1 ascii
Separator {
Material {
ambientColor 0.55 0.45 0.25
diffuseColor 0.55 0.45 0.25
shininess 1.0
}
Separator {
Translation {translation -30 -5.75 0 }
RotationXYZ{
axis Z
angle -0.785398163
}
Transform {
scaleFactor 20 8 12
}
Transform {
scaleFactor 1.5 1 1
}
Cube {width 1 height 1 depth 1}
}
Separator {
Translation { translation -10 -5.75 0 }
RotationXYZ {
axis Z
angle 0.785398163
}
Transform {
scaleFactor 20 8 12
}
Transform {
scaleFactor 1.5 1 1
}
Cube {width 1 height 1 depth 1}
}
}

ChrisW67
9th March 2012, 01:31
You'd be far better off asking a Coin (http://www.coin3d.org) API (http://www.coin3d.org/doc) question in a Coin forum (http://www.coin3d.org/support/lists).

MisterWanderer
9th March 2012, 01:45
Ahh I understand. Sorry about that. I have yet to find a good one is all. The one you linked is more of a mailing list than a forum.

Just in case someone else stumbles in here looking for the answer I think I figured it out.
Just type cast your SoNode into a SoSeparator and it will work. (not sure this is the correct way to do things but hey it works!)

SoSeparator * parent;
SoSeparator * left;
SoSeparator * right;

parent= (SoSeparator *) Root->getChild(2); //Root->getChild(2) resolves to the top of the file I put above.
left = (SoSeparator *) parent->getChild(2);
right = (SoSeparator *) parent->getChild(3);