I am trying to implement my own pan functionality in osg scene using Qt.
Please tell me if it is right ?.....But it's not happening.

Check my snippet.

void CSGraphicsView::mousePressEvent(QMouseEvent *e)
{
lastPos = e->pos();
}

void CSGraphicsView::mouseMoveEvent(QMouseEvent *e)
{
 float dx = (e->y() - lastPos.y());
     float dy = (e->x() - lastPos.x());



     const bool panFlag    = ( e->buttons() & Qt::MidButton   );
     const bool rotateFlag = ( e->buttons() & Qt::LeftButton  );
     const bool zoomFlag   = ( e->buttons() & Qt::RightButton );


     if ( zoomFlag )
     {
         zoom( dy );
     }
     else if ( rotateFlag )
     {
         rotate( dx, dy );
     }
     else if ( panFlag )
     {
         pan( dx, dy );
     }

 viewer->frame();

 lastPos = e->pos();
}

void CSGraphicsView::pan( int dx, int dy )
{
viewer->getView()->getCamera()->setViewMatrix(osg::Matrix::translate(dx,dy,0));
}

//viewer is composite viewer osg
//getView() returns the osgViewer::View

//but my object is not moving what s wrong in this. please help.

-- 
Thanks & Regards
Sujan
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to