[osg-users] Converting an osg::Matrix to osg::PositionAttitudeTransform using decompose?
Jad Killian
m.hasani at outlook.com
Fri Jan 18 07:34:15 PST 2019
I have a matrix that is constructed as follows:
Code:
osg::Matrix final;
final.preMultScale(inverseParentScale);
final.preMultRotate((worldRotation * inverseWorld).getRotate());
final.preMultScale(parentScale);
What I'm basically trying to do is rotate a child by first calculating a world rotation and then converting it to a local rotation by multiplying by the inverse world transform. The problem is that if the parent is non-uniformly scaled, the result is weirdly sheared. So I thought I would remove the parent scale, rotate, then apply the parent scale back, which is what I think the above lines do, but please feel free to correct me.
Now what I want is to convert the result to a PositionAttitudeTransform. But I'm not getting correct results doing the following:
Code:
osg::Vec3d t, s;
osg::Quat r, so;
final.decompose(t, r, s, so);
_childTransform->setScale(s);
_childTransform->setAttitude(r);
I suspect that the "scale factor" parameter is the issue, since it has non-zero values and Im not using them, but I'm not sure what it even is.
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=75506#75506
More information about the osg-users
mailing list