Hello Ulrich, So you mean that the setMatrix() function after the callback is not making any difference to the scene.
But i get different scene when i toggle the matrix setup after the callback. With setMatrix() after the callback i get two cows side by side and the left one is rotating around z Without setMatrix() after the callback i still do get two cows side by side and the left one is rotating around z by the left ones head is cut by the window view. http://code.google.com/p/osgqsg/source/browse/trunk/Examples/Callback/CallbackMain.cpp Sajjad ---------- Forwarded message ---------- From: Ulrich Hertlein <[email protected]> Date: Sat, Mar 28, 2009 at 12:26 PM Subject: Re: [osg-users] Fwd: Fwd: CallBack issue To: OpenSceneGraph Users <[email protected]> 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
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

