[osg-users] TrackballManipulator rotate camera about a point different from lookat point

HITESH Singhal ug201211016 at iitj.ac.in
Mon Jun 22 23:28:15 PDT 2015


Hi,

R u working on Vizard software?

-- 
Regards
Hitesh Singhal
Electrical Engineering
+91-8386837430


On Fri, Jun 19, 2015 at 8:23 AM, shilpa varri <shil.reddy9 at gmail.com> wrote:

> Hi,
>
> I'm using trackball manipulator to rotate my camera.
> I have following inputs:
> eye position, lookAtCenter position, up vector and spin center.
> So basically I need to setup my trackballmanipulator such that it is
> located at 'eye' position looking at 'lookAtCenter' position with 'up'
> vector. But when I  move my mouse I need the manipulator to rotate about
> 'spin center' and not 'lookAtCenter'.
> So the camera is looking at one point but rotating around a different
> point.
>
> Now if I use the 'trackballmanipulator->setTransformation(eye,
> lookAtCenter , up)' when I move the mouse it automatically moves along the
> sphere of 'lookAtCenter'.
> I'm not sure how to overwrite this behavior so that it's looking at
> 'lookAtCenter' position but rotating about sphere of 'spin center'.
>
> I've calculated the rotation matrix to rotate about 'spin center'. But how
> do I feed this to the trackballmanipulator to achieve the result?
> Can anyone please help me?
>
>
> Here's the code:
>   osg::Vec3d eye = osg::Vec3d(cameraPos.at(0), cameraPos.at(1),
> cameraPos.at(2));
>   osg::Vec3d viewVector = osg::Vec3d(cameraViewDirection.at(0),
> cameraViewDirection.at(1), cameraViewDirection.at(2));
>   osg::Vec3d lookAtCenter(eye + viewVector);
>   osg::Vec3d up = osg::Vec3d(cameraUpDirection.at(0),
> cameraUpDirection.at(1), cameraUpDirection.at(2));
>
>   osg::Vec3d spinCenterVec = osg::Vec3d(spinCenter.at(0),
> spinCenter.at(1), spinCenter.at(2));
>
>     osg::Matrixd transSpinToOrigin, transToSpinCenter, rotationAboutOrigin;
>
>     transSpinToOrigin.makeTranslate(-spinCenterVec );
>     transToSpinCenter.makeTranslate( spinCenterVec );
>     rotationAboutOrigin.makeRotate( osg::DegreesToRadians(0.5),
> osg::Vec3d(1,0,0),
>                         osg::DegreesToRadians(0.5), osg::Vec3d(0,1,0),
>                         osg::DegreesToRadians(0.5), osg::Vec3d(0,0,1) );
>
>     m_customRotationMat = new osg::Matrixd(transToSpinCenter * rotationMat
> * transSpinToOrigin);
>
>     trackBallManipulator->setTransformation(eye, referencePtVector, up);
>
> //After this, how do I use 'm_customRotationMat'? I've started overriding
> the manipulator class so I can use this somewhere. But I still don't know
> how?
>
> Any help is much appreciated!
> Thank you!
>
> Cheers,
> avatarZ
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=64125#64125
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150623/0bf837f9/attachment-0003.htm>


More information about the osg-users mailing list