I understood part of the issue, and thus I corrected (part of) the error. Now
seems that the rotation and the translation is formally right, but visually
translation is wrong. I enclosed 3 pics of the scene, before rotating, after
1st rotation and after 2nd rotation. I correct the source as follows:
Code:
printVector(" Original amtRod trans: ",
amtRod->getWorldMatrices()[0].getTrans());
printVector(" Original amtRod rotate: ",
amtRod->getWorldMatrices()[0].getRotate());
printVector("\t amtRod center: ",
amtRod->getBound().center());
osg::Vec3 offset = amtRod->getWorldMatrices()[0].getTrans();
printVector("\t amtRod offset = ", offset);
osg::Matrix get = osg::Matrix::translate(- offset);
osg::Matrix m = amtRod->getMatrix() *
osg::Matrix::rotate(rotation, osg::Vec3(0,1,0));
osg::Matrix put = osg::Matrix::translate( offset);
amtRod->setMatrix( get * m * put );
printVector("\t get.getTrans = ", get.getTrans());
printVector("\t m.getRotate = ", m.getRotate());
printVector("\t m.getTrans = ", m.getTrans());
printVector(" Current amtRod trans: ",
amtRod->getWorldMatrices()[0].getTrans());
printVector(" Current amtRod rotate: ",
amtRod->getWorldMatrices()[0].getRotate());
Now the output is:
Original amtRod trans: (0, 0, -309)
Original amtRod rotate: (0, 0, 0)
amtRod center: (6.55547, 150.952, -142.15)
amtRod offset = (0, 0, -309)
get.getTrans = (-0, -0, 309)
m.getRotate = (0, -0.130526, 0)
m.getTrans = (79.9751, 0, -298.471)
Current amtRod trans: (0, 0, -309)
Current amtRod rotate: (0, -0.130526, 0)
Original amtRod trans: (0, 0, -309)
Original amtRod rotate: (0, -0.130526, 0)
amtRod center: (-36.8519, 150.952, -146.139)
amtRod offset = (0, 0, -309)
get.getTrans = (-0, -0, 309)
m.getRotate = (0, -0.258819, 0)
m.getTrans = (79.9751, 0, -298.471)
Current amtRod trans: (-74.5249, 0, -339.869)
Current amtRod rotate: (0, -0.258819, 0)
Are there suggestions?
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=35587#35587
Attachments:
http://forum.openscenegraph.org//files/after_2nd_rotation_175.png
http://forum.openscenegraph.org//files/after_1st_rotation_272.png
http://forum.openscenegraph.org//files/before_rotating_202.png
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org