Moving an abitary subgraph in the scene is done using one of the osg::Transform subclasses. If you physics code works with 4x4 matrices then use MatrixTransform, if you have a position, attitude (quaternion) then PositionAttitudeTransform would be ideal.
Inserting these transform nodes is easist done at scene graph construction time, i.e. when you load the seperate items and place them in your scene.
If you have a preexisting scene graph that you want to insert new transforms into move previous static objects then you'll need to insert a transform node above the subgraph of interest. To do this you need to create the transfrom, add the subgraph to it, then on the subgraph's original parent(s) you do a parent-.replaceChild(subgraph, transform).
Now if you subgraph has parents you need to work out what to do, you have move this one instance around of create multiple transform one for each parent, the later is typically what would work best.
Robert.
On 9/21/06, Eric Maslowski <[EMAIL PROTECTED]> wrote:
Hello all,
In line with recent discussions regarding documentation and such, what is
the recommended way to grab a arbitrary node from the scenegraph and move it
manually? I'm working on integrating a physics engine with OSG and I would
like to simply "bind" an osg node to the physics-based object so that the
physics transform overwrites that of the OSG node. All nodes are previously
loaded before building the physics objects so I have to query the scenegraph
for the necessary elements.
I can grab a node from the scene graph without issue, but just moving the
object seems problematic. I have tried dynamic_cast, using
asTransform/asMatrixTransform routines, grabbing the parent and
casting/modifying that, but it never moves. What is the recommended method?
Thanks
E.
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/
_______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
