Show
Ignore:
Timestamp:
09/20/06 14:58:34 (8 years ago)
Author:
robert
Message:

Created stress test of fade text labelling

Files:
1 modified

Legend:

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

    r5578 r5579  
    9292} 
    9393 
     94osgText::Text* createText(osg::EllipsoidModel* ellipsoid, double latitude, double longitude, double height, const std::string& str) 
     95{ 
     96    double X,Y,Z; 
     97    ellipsoid->convertLatLongHeightToXYZ( osg::DegreesToRadians(latitude), osg::DegreesToRadians(longitude), height, X, Y, Z); 
     98 
     99    osgText::FadeText* text = new osgText::FadeText; 
     100 
     101    text->setText(str); 
     102    text->setFont("fonts/arial.ttf"); 
     103    text->setPosition(osg::Vec3(X,Y,Z)); 
     104    text->setCharacterSize(300000.0f); 
     105    text->setCharacterSizeMode(osgText::Text::OBJECT_COORDS_WITH_MAXIMUM_SCREEN_SIZE_CAPPED_BY_FONT_HEIGHT); 
     106    text->setAutoRotateToScreen(true); 
     107     
     108    return text; 
     109} 
     110 
    94111osg::Node* createFadeText(osg::EllipsoidModel* ellipsoid) 
    95112{ 
    96113    osg::Group* group = new osg::Group; 
    97      
    98     osg::Vec3 position; 
    99  
    100     { 
    101         osg::Geode* geode = new osg::Geode; 
    102         osgText::FadeText* text = new osgText::FadeText; 
    103          
    104         text->setText("One"); 
    105         text->setFont("fonts/arial.ttf"); 
    106         text->setPosition(position); 
    107         text->setCharacterSize(300000.0f); 
    108         text->setCharacterSizeMode(osgText::Text::OBJECT_COORDS_WITH_MAXIMUM_SCREEN_SIZE_CAPPED_BY_FONT_HEIGHT); 
    109         text->setAutoRotateToScreen(true); 
    110          
    111         geode->addDrawable(text); 
    112         group->addChild(geode); 
    113     } 
    114      
    115     position.z() += 300000.0f; 
    116      
    117     { 
    118         osg::Geode* geode = new osg::Geode; 
    119         osgText::FadeText* text = new osgText::FadeText; 
    120          
    121         text->setText("Two"); 
    122         text->setFont("fonts/arial.ttf"); 
    123         text->setPosition(position); 
    124         text->setCharacterSize(300000.0f); 
    125         text->setCharacterSizeMode(osgText::Text::OBJECT_COORDS_WITH_MAXIMUM_SCREEN_SIZE_CAPPED_BY_FONT_HEIGHT); 
    126         text->setAutoRotateToScreen(true); 
    127          
    128         geode->addDrawable(text); 
    129         group->addChild(geode); 
     114 
     115    group->getOrCreateStateSet()->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF); 
     116     
     117    osg::Geode* geode = new osg::Geode; 
     118    group->addChild(geode); 
     119     
     120    std::vector<std::string> textList; 
     121    textList.push_back("Town"); 
     122    textList.push_back("City"); 
     123    textList.push_back("Village"); 
     124    textList.push_back("River"); 
     125    textList.push_back("Mountain"); 
     126    textList.push_back("Road"); 
     127    textList.push_back("Lake"); 
     128     
     129    unsigned int numLat = 15; 
     130    unsigned int numLong = 20; 
     131    double latitude = 50.0; 
     132    double longitude = 0.0; 
     133    double deltaLatitude = 1.0f; 
     134    double deltaLongitude = 1.0f; 
     135 
     136    unsigned int t = 0; 
     137    for(unsigned int i = 0; i < numLat; ++i, latitude += deltaLatitude) 
     138    { 
     139        longitude = 0.0; 
     140        for(unsigned int j = 0; j < numLong; ++j, ++t, longitude += deltaLongitude) 
     141        { 
     142            geode->addDrawable( createText( ellipsoid, latitude, longitude, 0, textList[t % textList.size()]) ); 
     143        } 
    130144    } 
    131145