Hi all,

I have a hopefully simple question. I'm setting up an app that will
manually adjust the camera with each frame, no camera manipulators are used.

With each adjustment I want to increment the translation and rotation of
the camera.  The translation works, but the camera rotation seems to be
around a point far away (origin?).  How can I make the camera rotate or
spin around its current position?  Is there an example somewhere I could
look at?

osg::Matrixd cameraRotation,
  newRotation,
  cameraTranslation,
  finalPosition;
osg::Matrixd viewMatrix = viewer.getCamera()->getViewMatrix();

cameraRotation.setRotate(viewMatrix.getRotate());
newRotation.makeRotate(osg::DegreesToRadians(0.0f), osg::Vec3d(1.0, 0.0,
0.0),
  osg::DegreesToRadians(2.0), osg::Vec3d(0.0, 1.0, 0.0),
  osg::DegreesToRadians(0.0f), osg::Vec3d(0.0, 0.0, 1.0));
cameraRotation = cameraRotation * newRotation;
cameraTranslation.setTrans(viewMatrix.getTrans());
newTranslation.makeTranslate(osg::Vec3f(2.0, 0.0, 0.0));
cameraTranslation = cameraTranslation * newTranslation;
finalPosition = cameraRotation * cameraTranslation;
viewer.getCamera()->setViewMatrix(finalPosition);

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

Reply via email to