I can't tell you the right answer, but maybe this might help a little bit. [rant] OSG matrices are not "correct" homogeneous transformation matrices. They are transposed. When you come up with a solution that involves multiplication of transformation matrices on paper, you have to reverse the order of multiplications when implementing it with OSG to get things working.
This problem arises from the confusion that OpenGL stores matrices in column-major order and OSG treats that data as if it was stored in row-major order, effectively transposing the matrix. There is no such thing as "row-major matrix" since matrices are mathematical entities that have nothing to do with storage. So, if you have a linear algebra and theoretical computer graphics background, every time you multiply matrices by hand in OSG you are likely to make mistakes. Looking at your problem again with this light might help. Just my 0.02. I didn't want to offend anybody, OSG is an amazing piece of library. It just hurts me that there is such a fundamental issue with it. [/rant] Apart from that, docs for osg::Matrixd::getRotate() state: "Note that this function assumes a non-scaled matrix and will return incorrect results for scaled matrixces. Consider decompose() instead." That would probably help. -Gazi 2009/1/15 Dorosky, Christopher G <christopher.g.doro...@lmco.com> > > 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 > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org