Hi all,
I am trying to get a Dragger on my HUD display, but I am not able to
manipulate it at all. If I add it the identical dragger to the normal
scene, it works as expected. Any insight in this is appreciated as I have
reached the end of trying to traverse the scene trying to gain
understanding in this matter.
The core of my code is:
#include <QtGui/QApplication>
#include <osgViewer/Viewer>
#include <osgGA/TrackballManipulator>
#include <osgQt/GraphicsWindowQt>
#include <osg/ShapeDrawable>
#include <osg/MatrixTransform>
#include <osgManipulator/TabBoxDragger>
int main( int argc, char** argv )
{
QApplication app(argc, argv);
osgQt::initQtWindowingSystem();
osg::Group* sceneroot = new osg::Group;
osg::Camera* hudcamera = new osg::Camera;
sceneroot->addChild( hudcamera );
hudcamera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
hudcamera->setViewMatrix(osg::Matrix::identity());
hudcamera->setClearMask(GL_DEPTH_BUFFER_BIT);
hudcamera->setRenderOrder(osg::Camera::POST_RENDER);
hudcamera->setAllowEventFocus(false);
hudcamera->setName("HUD Camera" );
osg::Matrix mat;
mat.makeTranslate( 200, 200, -200 );
mat.preMult( osg::Matrix::scale( 200, 200, 200 ) );
osgManipulator::TabBoxDragger* tbd = new osgManipulator::TabBoxDragger;
hudcamera->addChild( tbd );
tbd->setupDefaultGeometry();
tbd->setMatrix( mat );
tbd->setHandleEvents( true );
osg::Geode* geode = new osg::Geode;
geode->addDrawable( new osg::ShapeDrawable(new osg::Box) );
sceneroot->addChild( geode );
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer;
viewer->setSceneData( sceneroot );
viewer->setCameraManipulator( new osgGA::TrackballManipulator );
osgQt::setViewer( viewer.get() );
osgQt::GLWidget* glw = new osgQt::GLWidget;
osgQt::GraphicsWindowQt* graphicswin = new osgQt::GraphicsWindowQt( glw
);
hudcamera->setProjectionMatrix(osg::Matrix::ortho2D(0,glw->width(),0,glw->height()));
viewer->getCamera()->setViewport( new osg::Viewport(0, 0, glw->width(),
glw->height() ) );
viewer->getCamera()->setGraphicsContext( graphicswin );
glw->show();
return app.exec();
}
- Kristofer
--
Kristofer Tingdahl, Ph. D.
dGB Earth Sciences
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org