Hi Robert,
Sorry for my english so poor, i've some difficulties just to explain
simple thing.
In fact I just want to know the center of a node, wich is at the end
or an articulated arm. The user can move all the arm's part with a
mouse (picking fontion). And after, when the movement are finished,
I'need to know the center's coordinate value.
I sure there is a simple way to do this just like setting up a
callback function or something to follow the center from the initial
position but I don't know the right way to do this.
Or isn't there a very simple function like myNode.getWorldPosition()
wich give me the position of the node in the world coordinate sytem ?
If there is no simpler solution, I'll try the trick with multiple
matrix, but the CVS access is down from my working place... Can anyone
send me the <osg/Node> of the cvs Version or just the part of code for
the getWorldMatrices function
Thanks in advance for your answer
Simon
On 6/7/06, Robert Osfield <[EMAIL PROTECTED]> wrote:
Hi Simon,
I'm a little confused reading through your posts, but think what you
are after is in the CVS version of the OSG. In osg::Node there is now
the method:
/** Get the list of matrices that transform this node from
local coordinates to world coordinates.
* The optional Node* haltTraversalAtNode allows the user to
prevent traversal beyond a specifed node. */
MatrixList getWorldMatrices(osg::Node* haltTraversalAtNode=0) const;
Note this passes back a list of matrices, rather than one, typically
this list will have just one matrix in it, but it could have many if
your node is shared between multiple parents (or their parents have
multiple parents etc.).
Then to compute the center just use the center of the bounding sphere:
osg::MatrixList matrices = node->getWorldMatrices();
osg::Vec3 pos = matricex.empty() ? node->getBound().center() :
node->getBound().center() * matrices[0];
This example ignores the case of multiple parents, but I'm sure you
can work out the more general solution.
Robert.
On 6/7/06, Simon ESNEAULT <[EMAIL PROTECTED]> wrote:
> Hello, my question must seems a bit stupid, I have build a tree like this
>
> //
> // /-- mNoNav
> // mRootNode
> // -- mNavTrans -- Xmodel1 -- model1 -- Xmodel2 -- model2 --
> Xmodel3 -- model3 ----Rest of the tree (all the object)
>
> With some 3ds models, and where Xmodel is a Matrix transform that I use just
> to move the object form the parent's position. So after a while and after
> some mouvement of each part of the tree (it's something like an articulated
> robot), it became difficult to find a given node's center. And I want to
> find the model6 (for exemple) center's real coordinate, but i don't know
> wich fonction should I use. What's the best solution ?
>
> - I've try to compute a boundsphere on the Node, but the center is not the
> right one, given in Local coordinate system
> - try to compute the local to world matrix of the TransformMatrix, with
> something like this, but it doesn't work either (give me an identity matrix)
>
> osg::Matrix mat;
> Xbase_laser->computeLocalToWorldMatrix(mat, new
> osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_PARENTS));
>
> - try to use a PositionAttitudeTransform instead of a MatrixTransform so I
> can use the getPosition but it steel in a Local World ...
>
> Sorry to ask for a such simple problem, I am just an OSG Newbie ...
>
>
> Simon
>
> _______________________________________________
> 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/
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/