Re: [osg-users] Testing osgUI library
Hi, I have already tried rotating the GUI, but it doesn't work. When you enter the mouse over the 3D TabWidget, you can see the message "Widget::enter()" on the console log. But, if you do the same with the TabWidget which is inside the HUD camera, you can't see any message. We think that the problem is in the method called "computeExtentsPositionInLocalCoordinates" of the Widget class (Widget.cpp file) on lines; 498matrix.postMult(camera->getViewMatrix()); 499matrix.postMult(camera->getProjectionMatrix()); because it uses the matrices of the 'default' camera instead of the HUD camera's matrices. We've replaced the two lines before with the next line. In this way, it detects the mouse over the TabWidget which is inside the HUD camera, but when I click on the tabs it doesn't work. We could write this line because we know the projection matrix of our HUD camera. matrix.postMult(osg::Matrix::ortho2D(0, 1400, 0, 760)); Thank you. Rocío 2016-01-05 11:52 GMT+01:00 Robert Osfield <robert.osfi...@gmail.com>: > Hi Rocio, > > I haven't yet had a chance to test the example (it's holidays here :-) > but in principle it should be possible to use osgUI within a HUD as > well as in the 3D scene. One of the motivations for developing osgUI > was the need to have a GUI in a 3D scene with full stereo rendering > (HMD's and powerwalls) so this is where I've done all the testing. > > My best guess for why it isn't working in the HUD case is a precision > issue with the intersection routines. As a test try rotating the GUI > very slightly so it has some depth rather being planner. If this gets > things working then we know that it's an issue with intersection tests > and these need to be adapted to handle the planar HUD case. > > Robert. > > On 23 December 2015 at 12:12, Rocio Tortajada > <rocio.tortaj...@mirage-tech.com> wrote: > > Hi! > > > > I've tried the osgUI library. I loaded the TabWidget.lua from the > osg-data > > into the scene and when I clicked on the tabs it worked as expected > > > > The problem arises when I added the TabWidget in the HUD camera, as far > as > > we tested the intersections to the widget seems not to be working. Is the > > osgUI library supporting HUD cameras? Are we missing something? > > > > Find attached an example with my test code, on the left of the scene > there > > is a 3D TabWidget and on the right there is a TabWidget inside the HUD > > camera. The test is very simple, but if you find it interesting it can > be > > added to the OSG examples. > > > > Thank you! > > > > Rocío > > > > ___ > > osg-users mailing list > > osg-users@lists.openscenegraph.org > > > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Testing osgUI library
Hi! I've tried the osgUI library. I loaded the TabWidget.lua from the osg-data into the scene and when I clicked on the tabs it worked as expected The problem arises when I added the TabWidget in the HUD camera, as far as we tested the intersections to the widget seems not to be working. Is the osgUI library supporting HUD cameras? Are we missing something? Find attached an example with my test code, on the left of the scene there is a 3D TabWidget and on the right there is a TabWidget inside the HUD camera. The test is very simple, but if you find it interesting it can be added to the OSG examples. Thank you! Rocío /** * * Example of osgUI * */ #include #include #include #include #include #include #include osg::ref_ptr createHUDCamera(){ osg::ref_ptr camera = new osg::Camera; camera->setReferenceFrame(osg::Camera::ABSOLUTE_RF); camera->setClearMask(GL_DEPTH_BUFFER_BIT); camera->setRenderOrder(osg::Camera::POST_RENDER); camera->setAllowEventFocus(true); camera->setProjectionMatrix(osg::Matrix::ortho2D(0, 1400, 0, 760)); camera->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); camera->setName("HUD Camera"); return camera; } // // MAIN // int main( int argc, char **argv ) { osg::ref_ptr tabWidget1 = osgDB::readNodeFile("ui/TabWidget.lua"); osg::ref_ptr tabWidget2 = osgDB::readNodeFile("ui/TabWidget.lua"); osg::ref_ptr transform1 = new osg::MatrixTransform; transform1->setMatrix(osg::Matrix::rotate(osg::PI_2, 1, 0, 0)*osg::Matrix::rotate(osg::PI_4, 0, 0, 1)*osg::Matrix::translate(-120.0, 0.0f, -50.0f)); transform1->addChild(tabWidget1); osg::ref_ptr transform2 = new osg::MatrixTransform; transform2->setMatrix(osg::Matrix::scale(3.0f, 3.0f, 3.0f)*osg::Matrix::translate(800.0f, 380.0f - 150.0f, 0.0f)); transform2->addChild(tabWidget2); osg::ref_ptr root = new osg::Group; auto hud = createHUDCamera(); hud->addChild(transform2.get()); root->addChild(hud.get()); root->addChild(transform1.get()); osgViewer::Viewer viewer; // Construct the viewer. viewer.setSceneData( root.get() ); // Set the final SceneData to show viewer.addEventHandler(new osgViewer::StatsHandler); viewer.setCameraManipulator(new osgGA::TrackballManipulator); viewer.setUpViewInWindow(50, 50, 1400, 760); osg::Vec3d eye, center, up; eye = osg::Vec3d(0.0,-400.0, 0.0f); center = osg::Vec3d(0.0, 0.0f, 0.0f); up = osg::Vec3d(0.0f, 0.0f, 1.0f); auto cm = viewer.getCameraManipulator(); cm->setHomePosition(eye, center, up, false); viewer.home(); while (!viewer.done()){ viewer.frame(); } return 0; } ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org