I'll try to simplify the problem, because I think it is not easy to understand what the problem looks like. (I know I need to wait ... but it become urgent so I still stay trying ideas or waiting for yours)
Group | |_________________________ | | | Dragger1 Selection1 Plane | _____|________ | | Dragger2 Selection2 | Geode Dragger 1 is translation, Dragger2 is rotation When I use/dragg Drager2, Selection 2 changes, and the node rotate. What I need, is to get the transformation applied on the Geode, to set the same on Plane. (same place, same orientation) In the DraggerHandler, I get the Selection2 when rotating. So I copy matrix before and after rotation to compute the rotation done and apply it to Plane (osg::Plane). So I do : osg::Matrixd m = osg::Matrixd::translate(-afterMoving.getTrans()) * (afterMoving * osg::Matrixd::inverse(beforeMoving)) * osg::Matrixd::translate(afterMoving.getTrans()); Plane->transform(m); (because Plane is not a geometry, no Transform can be apply on it.) But the plane and the Geode not have the same orientation... I don't understand where the calculs are wrong. Thanks. Regards, Vincent. 2008/12/18 Vincent Bourdier <vincent.bourd...@gmail.com> > Hi, > > Using the draggerHandler (the copy of the one in osgManipulator example) to > rotate and translate a node, I need to get theses transformations to apply > it to an other node. > > In the Handler, I get the previous matrix of the dragger, and after > transformation (on release) I get the other matrix. > > If I print the values : > * > DISPVECT("relative trans", afterMoving.getTrans() - > _beforeMoving.getTrans()); > DISPQUAT("relative rot ", afterMoving.getRotate() * > _beforeMoving.getRotate().inverse());* > > It looks very good. > > Next, to apply theses transformation to an osg::Plane, I use this code : > * > osg::Vec3d trans = afterMoving.getTrans() - beforeMoving.getTrans(); > osg::Quat rot = afterMoving.getRotate() * > beforeMoving.getRotate().inverse(); > > //Create the transformation matrix to rotate and translate the plane. the > plane has its center int the center of the Dragger > osg::Matrixd m ; > m = osg::Matrixd::translate(-beforeMoving.getTrans()) * > osg::Matrixd::rotate(rot) * osg::Matrixd::translate(beforeMoving.getTrans()) > * osg::Matrixd::translate(trans); > > DISPVECT("relative plane trans", m.getTrans()); > DISPQUAT("relative plane rot ", m.getRotate()); > > myPlane->transform(m);* > > The value applied are not the same ! > > values returned : > *relative trans : 0 0 0 > relative rot : 1.63503e-008 -0.461046 2.45062e-008 0.920392 > relative plane trans : 3081.37 -7.26342e-005 -3422.35 > relative plane rot : 1.58832e-008 -0.447874 2.38061e-008 0.894097* > > The translation result looks good, but the rotation is not exactly the good > one... > > Do you have any idea of where to find why there is a difference ? May be a > math problem, or a plane->transform not adapted to that kind of computation > ... ? > > Thanks a lot. > > Regards, > Vincent. >
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org