Dear All,
I implement the mouse oriented zooming with following code, where
customManipulator derives drectly from OrbitManipulator and I override simply
the handleMouseWheel eventhandler. This works to some extend , zooms to mouse
position but the more you scroll it seems that eye position reaches the center
positon (target) and zooming halts. My guess is I'm stucking to the
minimumDistance variable check in OrbitManipulator which doesn't allow to
further zooming and sets the _distance to minDistance.
To remedy it I've tried to change center position with LookAt position matrix
seting but this doesn't seems to take any effect,
Your helps will be appreicated,
bool customManipulator::handleMouseWheel( const osgGA::GUIEventAdapter& ea,
osgGA::GUIActionAdapter& us ){ osgViewer::View* view =
dynamic_cast<osgViewer::View*>(&us); osgGA::GUIEventAdapter::ScrollingMotion
sm = ea.getScrollingMotion(); switch( sm ) { // mouse
scroll up event case osgGA::GUIEventAdapter::SCROLL_UP: {
// perform zoom //zoomModel( _wheelZoomFactor,
true ); //us.requestRedraw();
//us.requestContinuousUpdate( isAnimating() || _thrown );
osg::Vec3d new_vec; double new_dist;
new_dist = _distance;
// CORRECT WORKING CODE osg::Matrix
MVPW(view->getCamera()->getViewMatrix()*view->getCamera()->getProjectionMatrix()
*
view->getCamera()->getViewport()->computeWindowMatrix() ); float
wid = ea.getX(); float hei = ea.getY();
osg::Vec3d mouse_move_pos =
osg::Vec3(ea.getX(),ea.getY(),0.0f)*osg::Matrix::inverse(MVPW);
// PART RESPONSIBLE FOR MOUSE POINT ORIENTED ZOOMING
osg::Vec3d curr_eye, curr_cnt, curr_up; osg::Matrixd mat1;
mat1 = view->getCameraManipulator()->getInverseMatrix();
osg::Vec3d trans = mat1.getTrans();
mat1.getLookAt(curr_eye,curr_cnt,curr_up );
osg::Vec3d delta_vec, dir_vec;
// CALCULATE THE DIRECTION dir_vec =
-curr_eye+curr_cnt; dir_vec *= 10; curr_cnt = dir_vec+ curr_cnt;
delta_vec = -mouse_move_pos+curr_eye; curr_eye =
curr_eye+delta_vec*(0.25); curr_cnt = curr_cnt+delta_vec*(0.25);
mat1.makeLookAt(curr_eye, curr_cnt, curr_up);
view->getCameraManipulator()->setByInverseMatrix(mat1);
return true; }
// mouse scroll down event case
osgGA::GUIEventAdapter::SCROLL_DOWN: {
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org