On 5/19/2011 1:15 AM, ms yang wrote:
Hi:
     I am a beginner of OSG. I have a problem about how can I get the main
camera's rotation relative to x,y,z axis.
     I can get the view matrix by osg::Matrix matrix =
viewer->camera()->getViewMatrix(),after I get the view matrix,there is only one
member function getRotate which  returns the quat but not the rotation angle
relative to x,y,z axis.

Get the view matrix lookat components:
  osg;;vec3 eye, at, up;
  view->getLookAt( eye, at, up );

Then get the normalized view direction:
  osg::Vec3 viewDir = at - eye;
  viewDir.normalize();

Then use linear algebra and trigonometry: The dot product of two unit vectors is the cosine of the angle between the two vectors.
   -Paul
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to