Hello Sajjad,
On 28/3/09 10:00 PM, ami guru wrote:
The following snippet may elaborate more:
******************************'
mtLeft->setUpdateCallback(new RotateCB);
osg::Matrix m;
m.makeTranslate(-6.0f,0.0f,0.0f);
mtLeft->setMatrix(m);
*****************************'
On the above snippet we have made a translation after the callback. And
that one is appended to the one that has been called inside the RotateCB.
First of all, the fact that you set a translation matrix is irrelevant. The callback (as
you have posted in a previous mail) will always overwrite whatever matrix you set during
setup.
I understand the point you're trying to make. What I'm saying is that when you use
MatrixTransform->setMatrix(m) you're loosing anything that has been set before. If you
want to preserve that (i.e. the translation in your example) you have to take care of that
yourself.
From what I grok you're looking for a way to keep the translation part and only change
the rotation. You could try to do something like:
Matrix m = mt->getMatrix();
m.setRotate(quat)
mt->setMatrix(m);
Or use decompose(), change the rotation and re-assemble the matrix: scaling, rotation,
transform and all.
Or pass the translation to the update callback so that it can assemble and set the proper
transformation matrix. Or split the translation and the rotation into different
MatrixTransforms.
Many roads lead to Rome.
matrixTransform->setMatrix(Matrix::makeRotate(...)) is not one of them. ;-)
Hope this helps,
/ulrich
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org