I have a Composite Viewer setup with multiple views/cameras, and a 2D Ortho HUD 
camera that I add to the root node of my scene to render HUD elements.

One of these elements is a textured quad with a QWidgetImage. I set up the 
InteractiveImageHandler and gave it to the drawable as event and cull 
callbacks. However, it is not handling my click presses. I think that it is 
because it is a child of the HUD camera, and not of the camera that I give to 
the views?

How do I get events to the interactive image handler?


Code:

//HUD Camera
osg::Camera *HUDCam = new osg::Camera();
group->addChild(HUDCam);
HUDCam->setProjectionMatrix(osg::Matrix::ortho2D(0, 1280, 0, 1024));
HUDCam->setViewMatrix(osg::Matrix::identity());
HUDCam->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
HUDCam->setClearMask(GL_DEPTH_BUFFER_BIT);
HUDCam->setRenderOrder(osg::Camera::POST_RENDER);
HUDCam->setAllowEventFocus(true);

//Quad
 osg::PositionAttitudeTransform *pat = new osg::PositionAttitudeTransform();
QWidget* widget = new HudWidget();
osg::ref_ptr<osgQt::QWidgetImage> widgetImage = new osgQt::QWidgetImage(widget);
widgetImage->getQGraphicsViewAdapter()->setBackgroundColor(QColor(0,0,0,0));
osg::ref_ptr<osgViewer::InteractiveImageHandler> handler = new 
osgViewer::InteractiveImageHandler( widgetImage.get() );
osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
texture->setImage( widgetImage.get() );
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
osg::ref_ptr<osg::Geometry> quad = osg::createTexturedQuadGeometry(osg::Vec3(), 
osg::Vec3(widgetImage->s(),0,0), osg::Vec3(0,widgetImage->t(),0));
pat->setPosition(osg::Vec3(0, 1024-widgetImage->t(), -1));
quad->setEventCallback( handler.get() );
quad->setCullCallback( handler.get() );
geode->addDrawable(quad);
geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, texture.get(), 
osg::StateAttribute::ON);
geode->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
geode->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
geode->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON);
pat->addChild(geode);
HUDCam->addChild(pat);


[/code]

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=58971#58971





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to