Show
Ignore:
Timestamp:
11/17/10 11:16:45 (4 years ago)
Author:
robert
Message:

Added quite size test.

Files:
1 modified

Legend:

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

    r11774 r11917  
    3232 
    3333#include <osgText/TextNode> 
     34#include <osgText/Text3D> 
    3435 
    3536extern int main_orig(int, char**); 
    3637extern int main_test(int, char**); 
     38 
     39 
     40int main_size(int argc, char** argv) 
     41{ 
     42    osg::ArgumentParser arguments(&argc, argv); 
     43 
     44    osgViewer::Viewer viewer(arguments); 
     45 
     46    std::string fontFile("arial.ttf"); 
     47    while(arguments.read("-f",fontFile)) {} 
     48 
     49    osg::ref_ptr<osgText::Font> font = osgText::readFontFile(fontFile); 
     50    if (!font) return 1; 
     51    OSG_NOTICE<<"Read font "<<fontFile<<" font="<<font.get()<<std::endl; 
     52 
     53    osg::Geode* geode = new osg::Geode; 
     54 
     55    geode->addDrawable( osg::createTexturedQuadGeometry(osg::Vec3(0.0f,0.0f,0.0f),osg::Vec3(1.0f,0.0,0.0),osg::Vec3(0.0f,0.0,1.0), 0.0, 0.0, 1.0, 1.0) ); 
     56 
     57    osgText::Text3D* text3d = new osgText::Text3D; 
     58    text3d->setPosition(osg::Vec3(1.0f,0.0f,0.0f)); 
     59    text3d->setFont(osgText::readFontFile("arial.ttf")); 
     60    text3d->setCharacterSizeMode(osgText::Text3D::OBJECT_COORDS); 
     61    text3d->setCharacterSize(1.0f); 
     62    text3d->setCharacterDepth(0.1f); 
     63    text3d->setAxisAlignment(osgText::Text3D::XZ_PLANE); 
     64    text3d->setText("This is a size test"); 
     65 
     66    geode->addDrawable(text3d); 
     67 
     68    viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) ); 
     69    viewer.addEventHandler(new osgViewer::StatsHandler); 
     70 
     71    viewer.setSceneData(geode); 
     72 
     73    return viewer.run(); 
     74} 
     75 
     76 
    3777 
    3878int main(int argc, char** argv) 
     
    4787    { 
    4888        return main_orig(argc,argv); 
     89    } 
     90    else if (arguments.read("--size-test")) 
     91    { 
     92        return main_size(argc,argv); 
    4993    } 
    5094 
     
    93137    viewer.setSceneData(text); 
    94138 
    95     return viewer.run(); 
     139        return viewer.run(); 
    96140}