Hi,

I am attempting to build a system that lets the users move/rotate objects in my 
scene. When the user selects an object an axis is shown that also has thin 
toruses around each axis. If they click on one of the axises they can move the 
part along that axis. If they click on one of the toruses they can rotate about 
that axis. All of the rotation information given to the user is in Euler 
angles, but internally that is converted into quaterions. Initially, when I was 
trying to get the rotation to work I was simply adding movement values of the 
selected rotation axis to the corresponding euler angle and re-calculating the 
matrix for the transform. This appeared to work at first, but if I rotated it 
along a couple of axises, then future rotations were not along the correct axis 
anymore. 

To get around this problem I split the transform up into 2 parts. One transform 
that was for the current position/orientation, and the second one was used by 
the gripper to let them rotate it around the chosen axis based on the current 
orientation. When the user quit dragging I tried to multiply those to matrices 
together, got the rotation quaterion, and then converted that back to euler 
angles. I then reset the current orientation matrix using the new euler angles, 
and reset the grip matrix back to default. However, this is still not really 
working. I 



Thank you!

Cheers,
David


Code:

void VsBody::EndGripDrag(VsGripElement *lpGrip)
{
        osg::Matrix mtCombined;
        mtCombined.set(m_osgGripMatrix * m_osgLocalMatrix);
        osg::Quat qRot = mtCombined.getRotate();
        CStdFPoint vGripRot = QuaterionToEuler(qRot);

if(vGripRot != m_lpThis->Rotation())
                m_lpThis->Rotation(vGripRot);
}



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





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to