| | 74 | osg::Node * createScalarBar_HUD() |
| | 75 | { |
| | 76 | osgSim::ScalarBar * geode = new osgSim::ScalarBar; |
| | 77 | osgSim::ScalarBar::TextProperties tp; |
| | 78 | tp._fontFile = "fonts/times.ttf"; |
| | 79 | geode->setTextProperties(tp); |
| | 80 | osg::StateSet * stateset = geode->getOrCreateStateSet(); |
| | 81 | stateset->setMode(GL_LIGHTING, osg::StateAttribute::OFF); |
| | 82 | |
| | 83 | stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF); |
| | 84 | stateset->setRenderBinDetails(11, "RenderBin"); |
| | 85 | |
| | 86 | osg::MatrixTransform * modelview = new osg::MatrixTransform; |
| | 87 | modelview->setReferenceFrame(osg::Transform::RELATIVE_TO_ABSOLUTE); |
| | 88 | osg::Matrixd matrix(osg::Matrixd::scale(1000,1000,1000) * osg::Matrixd::translate(120,10,0)); // I've played with these values a lot and it seems to work, but I have no idea why |
| | 89 | modelview->setMatrix(matrix); |
| | 90 | modelview->addChild(geode); |
| | 91 | |
| | 92 | osg::Projection * projection = new osg::Projection; |
| | 93 | projection->setMatrix(osg::Matrix::ortho2D(0,1280,0,1024)); // or whatever the OSG window res is |
| | 94 | projection->addChild(modelview); |
| | 95 | |
| | 96 | return projection; //make sure you delete the return sb line |
| | 97 | } |
| | 98 | |