Re: [osg-users] how to insert a QWidgetImage in a osgWidget::Window?
Hi Julien, no I would like to show a Qt Widget in an osgWidget::Window. I found an example that shows a Qt Widget in a HUD (with camera and so on) but in that case I have two problems: 1) global coordinates sent to the Qt widget by osgViewer::InteractiveImageHandler are wrong (I debugged the code and coords are sent to the Qt widget wrt the 3D viewer widget, so not "global" like in Qt framework are usually handled, at least in my scenario). 2) I would like to drag and resize the widget and osgwidget::Window and that can be easily done with: window->attachMoveCallback() and attachScaleCallback(). Regards, Gianni -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64025#64025 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] how to insert a QWidgetImage in a osgWidget::Window?
Hello, I don't understand what you're doing but if you want to display both Qt widgets and osg 3D in the same window, I think you should take a look at osgviewerQt example. Hope it help..:/ gambr wrote: > Hi all, > I would like to show a Qt widget in a 3D viewer. I would like to drag it > around, scale it and interact with it. > > I looked at the osgQtWidgets example but didn't find exactly what I need. > Since I already implemented objects that are osgWidget::Window, I thought to > add the geometry got from osg::createTexturedQuadGeometry() to the > osgWidget::Window geode. So I created a Texture2D object and set to the > osgWidget::Window with setTextureAttributeAndModes(0, texture). I also set an > InteractiveImageHandler as cull callback. > > The problem is that I can't see the image. > > For testing I set an image loaded from file to the texture object and it > works fine. So what is missing in my code to see the Qt widget image? > > > Code: > >osg::ref_ptr window = new osgWidget::Canvas; > >float x = 0.0; >float y = 0.0; >float width = widget->size().width(); >float height = widget->size().height(); >osg::ref_ptr texture = new osg::Texture2D; >osg::ref_ptr quad; > >//std::string imageFile = "C:/Users/User/Desktop/test.jpg"; >//osg::ref_ptr image = osgDB::readImageFile(imageFile); >//texture->setImage(image.get()); >osg::ref_ptr widgetImage = new > osgQt::QWidgetImage(widget); >texture->setImage(widgetImage.get()); > >quad = osg::createTexturedQuadGeometry(osg::Vec3(x, y,0.0f),//center > osg::Vec3(width,0.0f,0.0f),//width > osg::Vec3(0.0f,height,0.0) > );//height >osg::StateSet* stateset = quad->getOrCreateStateSet(); >stateset->setTextureAttributeAndModes(0, texture.get()); >stateset->setRenderBinDetails(1, "DepthSortedBin", > osg::StateSet::OVERRIDE_RENDERBIN_DETAILS); > >osgViewer::InteractiveImageHandler* handler = new > osgViewer::InteractiveImageHandler(widgetImage.get()); >quad->setCullCallback(handler); > >window->getGeode()->addDrawable(quad); > > > > > Regards, > Gianni -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64006#64006 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] how to insert a QWidgetImage in a osgWidget::Window?
Hi all, I would like to show a Qt widget in a 3D viewer. I would like to drag it around, scale it and interact with it. I looked at the osgQtWidgets example but didn't find exactly what I need. Since I already implemented objects that are osgWidget::Window, I thought to add the geometry got from osg::createTexturedQuadGeometry() to the osgWidget::Window geode. So I created a Texture2D object and set to the osgWidget::Window with setTextureAttributeAndModes(0, texture). I also set an InteractiveImageHandler as cull callback. The problem is that I can't see the image. For testing I set an image loaded from file to the texture object and it works fine. So what is missing in my code to see the Qt widget image? Code: osg::ref_ptr window = new osgWidget::Canvas; float x = 0.0; float y = 0.0; float width = widget->size().width(); float height = widget->size().height(); osg::ref_ptr texture = new osg::Texture2D; osg::ref_ptr quad; //std::string imageFile = "C:/Users/User/Desktop/test.jpg"; //osg::ref_ptr image = osgDB::readImageFile(imageFile); //texture->setImage(image.get()); osg::ref_ptr widgetImage = new osgQt::QWidgetImage(widget); texture->setImage(widgetImage.get()); quad = osg::createTexturedQuadGeometry(osg::Vec3(x, y,0.0f),//center osg::Vec3(width,0.0f,0.0f),//width osg::Vec3(0.0f,height,0.0) );//height osg::StateSet* stateset = quad->getOrCreateStateSet(); stateset->setTextureAttributeAndModes(0, texture.get()); stateset->setRenderBinDetails(1, "DepthSortedBin", osg::StateSet::OVERRIDE_RENDERBIN_DETAILS); osgViewer::InteractiveImageHandler* handler = new osgViewer::InteractiveImageHandler(widgetImage.get()); quad->setCullCallback(handler); window->getGeode()->addDrawable(quad); Regards, Gianni -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=63994#63994 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org