I am experimenting with the osgQTviewer.I am not able to zoom in when
the mouse wheel is scrolled.I am using trackballmanipulator.I am not
able to find a good documentation about camera manipulators.Even the
Reference doc doesn't mention the explanation of manipulators.
AdapterWidget::AdapterWidget( ViewerQT *source ,QWidget * parent, const
char * name, const QGLWidget * shareWidget, WindowFlags f):
#if USE_QT4
QGLWidget(parent, shareWidget, f)
#else
QGLWidget(parent, name, shareWidget, f)
#endif
{
m_source = source;
resize( 800 ,600 );
/* To Remove this */
/*
* // create the window to draw to.
* */
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new
osg::GraphicsContext::Traits;
traits->x = 200;
traits->y = 200;
traits->width = 800;
traits->height = 600;
traits->windowDecoration = true;
traits->doubleBuffer = true;
traits->sharedContext = 0;
osg::ref_ptr<osg::GraphicsContext> gc =
osg::GraphicsContext::createGraphicsContext(traits.get());
_gw = new osgViewer::GraphicsWindowEmbedded(traits.get());
#if USE_QT4
setFocusPolicy(Qt::ClickFocus);
#else
setFocusPolicy(QWidget::ClickFocus);
#endif
}
..
... all the other event handling
...
void AdapterWidget::mouseMoveEvent( QMouseEvent* event )
{
_gw->getEventQueue()->mouseMotion(event->x(), event->y());
}
void AdapterWidget::wheelEvent( QWheelEvent *event )
{
//m_source->wheelEvent( event );
if( event->delta() > 0 )
_gw->getEventQueue()->mouseScroll(osgGA::GUIEventAdapter::SCROLL_UP );
else
_gw->getEventQueue()->mouseScroll(osgGA::GUIEventAdapter::SCROLL_DOWN );
}
ViewerQT::
ViewerQT(QWidget * parent, const char * name, const QGLWidget *
shareWidget , WindowFlags f ):
AdapterWidget( this , parent, name, shareWidget, f )
{
znear = 1.0f;
zfar = 10000.0f;
getCamera()->setViewport(new osg::Viewport(0,0,width(),height()));
//getCamera()->setProjectionMatrixAsPerspective(30.0f,
static_cast<double>(width())/static_cast<double>(height()), 1.0f, 10000.0f);
getCamera()->setGraphicsContext(getGraphicsWindow());
/* To Remove*/
osg::ref_ptr<osgGA::StateSetManipulator> statesetManipulator = new
osgGA::StateSetManipulator(getCamera()->getStateSet());
addEventHandler(statesetManipulator.get());
/*to remove end*/
addEventHandler(new PickHandler());
setThreadingModel(osgViewer::Viewer::SingleThreaded);
connect(&_timer, SIGNAL(timeout()), this, SLOT(updateGL()));
_timer.start(10);
_manipulator = new osgGA::TrackballManipulator;
setCameraManipulator(_manipulator);
cout<<"Minimum distance "<<_manipulator->getMinimumDistance()<<endl;
cout<<"Homepostion
compute"<<_manipulator->getAutoComputeHomePosition()<<endl;
//_manipulator->setAutoComputeHomePosition(false);
_manipulator->setMinimumDistance(1000);
osg::Vec3d eye;
osg::Vec3d center;
osg::Vec3d up;
_manipulator->getHomePosition( eye , center , up );
cout<<"x y z "<< eye.x()<<eye.y()<<eye.z()<<endl;
cout<<"x y z "<< center.x()<<center.y()<<center.z()<<endl;
cout<<"x y z "<< up.x()<<up.y()<<up.z()<<endl;
}
void
ViewerQT::
VwheelEvent( QWheelEvent *event )
{
cout<<event->delta()<<endl;
if( event->delta() > 0 )
{
znear = znear + 120.0f;
}
else
{
if( (znear - 120) >= 1.0 )
{
znear = znear - 120;
}
}
}
void
ViewerQT::
paintGL()
{
osg::Vec3d eye;
osg::Vec3d center;
osg::Vec3d up;
_manipulator->getHomePosition( eye , center , up );
cout<<"eye x y z "<< eye.x()<<" "<<eye.y()<<" "<<eye.z()<<endl;
cout<<"center x y z "<<center.x()<<" "<<center.y()<<"
"<<center.z()<<endl;
cout<<"up x y z "<< up.x()<<" "<<up.y()<<" "<<up.z()<<endl;
frame();
}
and this is how I am creating the Viewer window.
I tried to move the perspective view.
I tried to translate the camera matrix.
I tried to set the home positon
but none of the above things seems to work in moving the camera or
zooming.I am new to opengl and open scene graph any guide would be
really helpful.
Thank You
--
With Regards
Srikanth Bemineni
Geotrace Technologies
281-497-8440 extn 228
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org