[osg-users] rotation and scale in the same MatrixTransform

1,243 views
Skip to first unread message

Manuel Garea

unread,
May 26, 2010, 11:03:21 PM5/26/10
to osg-...@lists.openscenegraph.org
Hi, now I'm using 3 MatrixTransform for scale, rotate and translate an object, something like this:


Code:
osg::MatrixTransform *m_rotation = new osg::MatrixTransform();
osg::Quat rotacion(transform2->getRotation()->a, OSGTypesMapping::sFRotationPtrToOsgVec3_ShiftAxis(transform2->getRotation()));
osg::Matrix m;
m.setRotate(rotacion);
m_rotation->setMatrix(m);
m_rotation->addChild(<<NodeIWantToTransform>>);

osg::MatrixTransform *scale = new osg::MatrixTransform();
osg::Matrix m2;
m2.makeScale(transform2->getScale());
scale->setMatrix(m2);
scale->addChild(m_rotation.get());

osg::MatrixTransform *translate = new osg::MatrixTransform();
osg::Matrix m3;
m3.setTrans(transform2->getTranslation());
translate->setMatrix(m3);
translate->addChild(scale);

and then I add the translate node to my camera view.

My problem is that I need to use only one MatrixTransform, but if I make:


Code:
osg::MatrixTransform *mt = new osg::MatrixTransform;
osg::Matrix m;
m.setRotate(...);
m.makeScale(...);
m.setTrans(...);
mt->setMatrix(m);

It doesn't work, rotations doesn't make any effect!!!!

Do someone know how can I make it using only one MatrixTransform??? Is it possible???

Thank you!!!

Cheers,
Manuel

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=28265#28265

_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Torben Dannhauer

unread,
May 27, 2010, 1:26:23 AM5/27/10
to osg-...@lists.openscenegraph.org
Hi,

as far as I know, you can only make rotate/translate/scale once on a matrix because it resets the prior values.

But you can always create a matrix as you did, and add its operation via multiplying your temporary matrix with the final matrix. This way you can sum up your operations in one matrix.

Cheers,
Torben

------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=28266#28266

Robert Osfield

unread,
May 27, 2010, 3:42:47 AM5/27/10
to osg-...@lists.openscenegraph.org
Hi Manuel,

If you want to set the scale, rotation and translation seperately then
use an osg::PositionAttitudeTransform.

Robert.

Reply all
Reply to author
Forward
0 new messages