Show
Ignore:
Timestamp:
05/21/04 00:20:39 (10 years ago)
Author:
robert
Message:

Added HUD scalar bar.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgscalarbar/osgscalarbar.cpp

    r2688 r3012  
    77#include <osg/BlendFunc> 
    88#include <osg/ClearNode> 
     9#include <osg/Projection> 
    910 
    1011#include <osgUtil/Tesselator> 
     
    7172} 
    7273 
     74osg::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 
    7399int main( int argc, char **argv ) 
    74100{ 
     
    108134    } 
    109135 
    110     osg::Node* node = createScalarBar(); 
     136    osg::Group* group = new osg::Group; 
     137    group->addChild(createScalarBar()); 
     138    group->addChild(createScalarBar_HUD()); 
    111139 
    112140    // add model to viewer. 
    113     viewer.setSceneData( node ); 
     141    viewer.setSceneData( group ); 
    114142 
    115143    // create the windows and run the threads.