<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'><font face="Comic Sans MS,sans-serif" color="#000000">Dear All,</font><div><font face="Comic Sans MS,sans-serif" color="#000000"><br></font></div><div><font face="Comic Sans MS, sans-serif">I implement the mouse oriented zooming with following code, where customManipulator derives drectly from </font></div><div><font face="Comic Sans MS, sans-serif">OrbitManipulator and I override simply the handleMouseWheel eventhandler. This works to some extend , </font></div><div><font face="Comic Sans MS, sans-serif">zooms to mouse position but </font><span style="font-family: 'Comic Sans MS', sans-serif; font-size: 12pt;">the more you scroll it seems that eye position reaches the center positon (target) </span></div><div><span style="font-family: 'Comic Sans MS', sans-serif; font-size: 12pt;">and zooming halts. My guess is I'm stucking to the minimumDistance variable check in OrbitManipulator which doesn't </span></div><div><span style="font-family: 'Comic Sans MS', sans-serif; font-size: 12pt;">allow to further zooming and sets the _distance to minDistance.</span></div><div><span style="font-family: 'Comic Sans MS', sans-serif; font-size: 12pt;"><br></span></div><div><span style="font-family: 'Comic Sans MS', sans-serif; font-size: 12pt;">To remedy it I've tried to change center position with LookAt position matrix seting but this doesn't seems to </span></div><div><span style="font-family: 'Comic Sans MS', sans-serif; font-size: 12pt;">take any effect,</span></div><div><span style="font-family: 'Comic Sans MS', sans-serif; font-size: 12pt;"><br></span></div><div><span style="font-family: 'Comic Sans MS', sans-serif; font-size: 12pt;">Your helps will be appreicated,</span></div><div><br></div><div><font size="2" style="font-size: 10pt;"><div>bool customManipulator::handleMouseWheel( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us )</div><div>{</div><div> osgViewer::View* view = dynamic_cast<osgViewer::View*>(&us);</div><div> osgGA::GUIEventAdapter::ScrollingMotion sm = ea.getScrollingMotion();</div><div> switch( sm )</div><div> {</div><div> // mouse scroll up event</div><div> case osgGA::GUIEventAdapter::SCROLL_UP:</div><div> {</div><div> // perform zoom</div><div> //zoomModel( _wheelZoomFactor, true );</div><div> //us.requestRedraw();</div><div> //us.requestContinuousUpdate( isAnimating() || _thrown );</div><div><br></div><div> osg::Vec3d new_vec;</div><div> double new_dist;</div><div> new_dist = _distance;</div><div><br></div><div> // CORRECT WORKING CODE</div><div> osg::Matrix MVPW(view->getCamera()->getViewMatrix()*view->getCamera()->getProjectionMatrix() *</div><div> view->getCamera()->getViewport()->computeWindowMatrix() );</div><div> float wid = ea.getX();</div><div> float hei = ea.getY();</div><div> osg::Vec3d mouse_move_pos = osg::Vec3(ea.getX(),ea.getY(),0.0f)*osg::Matrix::inverse(MVPW);</div><div><br></div><div> // PART RESPONSIBLE FOR MOUSE POINT ORIENTED ZOOMING</div><div> osg::Vec3d curr_eye, curr_cnt, curr_up;</div><div> osg::Matrixd mat1;</div><div> mat1 = view->getCameraManipulator()->getInverseMatrix();</div><div> osg::Vec3d trans = mat1.getTrans();</div><div> mat1.getLookAt(curr_eye,curr_cnt,curr_up );</div><div><br></div><div> osg::Vec3d delta_vec, dir_vec;</div><div><br></div><div> // CALCULATE THE DIRECTION</div><div> dir_vec = -curr_eye+curr_cnt;</div><div> dir_vec *= 10; curr_cnt = dir_vec+ curr_cnt;</div><div><br></div><div> delta_vec = -mouse_move_pos+curr_eye;</div><div> curr_eye = curr_eye+delta_vec*(0.25);</div><div> curr_cnt = curr_cnt+delta_vec*(0.25);</div><div> mat1.makeLookAt(curr_eye, curr_cnt, curr_up);</div><div> view->getCameraManipulator()->setByInverseMatrix(mat1);</div><div><br></div><div> return true;</div><div> }</div><div><br></div><div> // mouse scroll down event</div><div> case osgGA::GUIEventAdapter::SCROLL_DOWN:</div><div> {</div></font></div> </div></body>
</html>