Hi ?? I have tested the osgwidget examples they fail for me when running in stereo. I'm not the author of osgWidget so can't comment too much on the internals, but the design is very much for 2D HUD style GUI's that overlay the scene, I have looked at generalizing it but couldn't find an easy way to do this as various parts of it's design assume 2D GUI.
I am currently working on project that needs GUI elements do be placed into a stereo scene and to achieve this am writing a new GUI NodeKit called osgUI. The osgUI library isn't ready for use, but it does work fully in a 3D scene or as a HUD, and both the graphics and event handling all work in the 3D scene and in stereo - I've just tested in anaglyphic and horizontal split and it all works fine. I plan to keep the osgUI library pretty simple but make sure it's very flexible to allow users to extend/customize it as required - it also fully supports scripting. osgUI not a direct replacement for osgWidget but overlaps enough that it will deprecated it. For OSG-3.4 I'll keep likely keep osgWidget for backwards in compatibility, but beyond this I'm thinking about annexing it into an dedicated osgWidget project so it can be maintained separately from the core OSG. Robert. On 25 May 2014 02:33, 12 <[email protected]> wrote: > Hi all: > > Recently I have to development a stereoscopic simulation program using osg's > stereo function, since I don't want to dependent on so much other UI > widgets, I decided to use the osgWidget. So I begin with the osgWidgetMenu > example, and added some stereo mode settings and active on stereo mode, for > simply thinking, I just using ANAGLYPHIC stereo mode. However everything > seems fine but the widgetMenu can't get any mouse events. I searched > answers, from > http://forum.openscenegraph.org/viewtopic.php?t=13670&view=next Rober said > that osgWidget isn't presently up to this task. So I want to confirm whether > osgWidget can be used for stereo visual development or is there any ways to > solve this. Thanks. I use osg3.2.0 Win7 VS2010, here is my code: > > #include <iostream> > > #include <osgDB/ReadFile> > > #include <osgWidget/Util> > > #include <osgWidget/WindowManager> > > #include <osgWidget/Box> > > #include <osgWidget/Label> > > > > const unsigned int MASK_2D = 0xF0000000; > > const unsigned int MASK_3D = 0x0F000000; > > > > struct ColorLabel: public osgWidget::Label { > > ColorLabel(const char* label): > > osgWidget::Label("", "") { > > setFont("fonts/Vera.ttf"); > > setFontSize(14); > > setFontColor(1.0f, 1.0f, 1.0f, 1.0f); > > setColor(0.3f, 0.3f, 0.3f, 1.0f); > > addHeight(18.0f); > > setCanFill(true); > > setLabel(label); > > setEventMask(osgWidget::EVENT_MOUSE_PUSH | > osgWidget::EVENT_MASK_MOUSE_MOVE); > > } > > > > bool mousePush(double, double, const osgWidget::WindowManager*) { > > return true; > > } > > > > bool mouseEnter(double, double, const osgWidget::WindowManager*) { > > setColor(0.6f, 0.6f, 0.6f, 1.0f); > > > > return true; > > } > > > > bool mouseLeave(double, double, const osgWidget::WindowManager*) { > > setColor(0.3f, 0.3f, 0.3f, 1.0f); > > > > return true; > > } > > }; > > > > class ColorLabelMenu: public ColorLabel { > > osg::ref_ptr<osgWidget::Window> _window; > > > > public: > > ColorLabelMenu(const char* label): > > ColorLabel(label) { > > _window = new osgWidget::Box( > > std::string("Menu_") + label, > > osgWidget::Box::VERTICAL, > > true > > ); > > > > _window->addWidget(new ColorLabel("Menu01")); > > _window->addWidget(new ColorLabel("Menu02")); > > _window->addWidget(new ColorLabel("Menu03")); > > > > _window->resize(); > > > > setColor(0.8f, 0.8f, 0.8f, 0.8f); > > } > > > > void managed(osgWidget::WindowManager* wm) { > > osgWidget::Label::managed(wm); > > > > wm->addChild(_window.get()); > > > > _window->hide(); > > } > > > > void positioned() { > > osgWidget::Label::positioned(); > > > > _window->setOrigin(getX(), getHeight()); > > _window->resize(getWidth()); > > } > > > > bool mousePush(double, double, const osgWidget::WindowManager*) { > > if(!_window->isVisible()) _window->show(); > > > > else _window->hide(); > > > > return true; > > } > > > > bool mouseLeave(double, double, const osgWidget::WindowManager*) { > > if(!_window->isVisible()) setColor(0.8f, 0.8f, 0.8f, 0.8f); > > > > return true; > > } > > }; > > > > int main(int argc, char** argv) { > > osgViewer::Viewer viewer; > > > > osg::DisplaySettings *displaysetting=new osg::DisplaySettings(); > > > > viewer.setDisplaySettings(displaysetting); > > > displaysetting->setStereoMode(osg::DisplaySettings::StereoMode::ANAGLYPHIC); > > displaysetting->setStereo(true); > > > > osgWidget::WindowManager* wm = new osgWidget::WindowManager( > > &viewer, > > 1280.0f, > > 1024.0f, > > MASK_2D, > > osgWidget::WindowManager::WM_PICK_DEBUG > > ); > > > > osgWidget::Window* menu = new osgWidget::Box("menu", > osgWidget::Box::HORIZONTAL); > > > > menu->addWidget(new ColorLabelMenu("File")); > > menu->addWidget(new ColorLabelMenu("View")); > > menu->addWidget(new ColorLabelMenu("Control")); > > menu->addWidget(new ColorLabelMenu("Setting")); > > > > wm->addChild(menu); > > > > menu->getBackground()->setColor(1.0f, 1.0f, 1.0f, 0.0f); > > menu->resizePercent(100.0f); > > > > osg::Node* model = osgDB::readNodeFile("osgcool.osgt"); > > > > model->setNodeMask(MASK_3D); > > > > return osgWidget::createExample(viewer, wm, model); > > } > > > > > > > > > > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

