As usual, when I spend a day or two on something, I figure out the answer immediately after I post a question to this list.
Problem was, I was fooling with the matrix afterwards, and recomposing it. GetRotate and GetScale mess up if matrix has both. Decompose is needed. Heh... I just noticed that Gazi posted this as well. Thanks!!!! Chris -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Dorosky, Christopher G Sent: Thursday, January 15, 2009 11:40 AM To: [email protected] Subject: [osg-users] getting translate rotate scale right. I thought I understood this just fine, but I apparently don't. I have a model that is half the size it needs to be. So, I need to scale it by 2.0 in all directions. It is also in the wrong position, so I need to translate it out to (1000, 2000, 3000); Once it is translated, I need to rotate it. This involves quats, but for simplicities sake, lets say the rotations are 10,20,30. Order is irrelevant, since I am just trying to print these things for now. So, I have a matrix transform. I set the matrix by: Mt->setMatrix(osg::Matrix::scale( scalevec) * osg::Matrix::rotate( rotquat) * osg::Matrix::trans (transvec)); Seems fine. Then, if I print out the values, I get some goofiness. Using the matrix getScale(), getTrans(), getRot() routines, I get them and print out values. Trans is fine. Rot and scale are goofy. This doesn't entirely surprise me, since the order of operations is dependent. In the scene graph, it looks wrong. If I use a position attitude transform, and explicitly set the trans, rot, scale separately, then it works. Before, I would have had a series of matricies that looks like this: Scenegraph root ->trans->rot->scale->model; What's the right way to do this? I'm thinking a translate -> rotate -> -translate is involved somehow. BTW if the scale is 1.0 in all directions, this works just fine. Thanks... Chris _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or g _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

