Show
Ignore:
Timestamp:
01/11/11 12:39:50 (4 years ago)
Author:
robert
Message:

Added more flexible testing of Text3D

Files:
1 modified

Legend:

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

    r11943 r12069  
    126126    while(arguments.read("--outline",r)) { style->setOutlineRatio(r); } 
    127127 
     128    viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) ); 
     129    viewer.addEventHandler(new osgViewer::StatsHandler); 
    128130 
     131#if 1 
     132    osg::Geode* geode = new osg::Geode; 
     133 
     134    float characterSize = 1.0f; 
     135    while(arguments.read("--size",characterSize)) {} 
     136 
     137    if (arguments.read("--2d")) 
     138    { 
     139        osgText::Text* text2D = new osgText::Text; 
     140        text2D->setFont(font.get()); 
     141        text2D->setCharacterSize(characterSize); 
     142        text2D->setFontResolution(256,256); 
     143        text2D->setDrawMode(osgText::Text::TEXT | osgText::Text::BOUNDINGBOX); 
     144        text2D->setAxisAlignment(osgText::Text::XZ_PLANE); 
     145        text2D->setText(word); 
     146        geode->addDrawable(text2D); 
     147    } 
     148        if (!arguments.read("--no-3d")) 
     149    { 
     150        osgText::Text3D* text3D = new osgText::Text3D; 
     151        text3D->setFont(font.get()); 
     152        text3D->setStyle(style.get()); 
     153        text3D->setCharacterSize(characterSize); 
     154        text3D->setDrawMode(osgText::Text3D::TEXT | osgText::Text3D::BOUNDINGBOX); 
     155        text3D->setAxisAlignment(osgText::Text3D::XZ_PLANE); 
     156        text3D->setText(word); 
     157        geode->addDrawable(text3D); 
     158    } 
     159     
     160 
     161    if (arguments.read("--size-quad")) 
     162    { 
     163        geode->addDrawable( osg::createTexturedQuadGeometry(osg::Vec3(0.0f,characterSize*thickness,0.0f),osg::Vec3(characterSize,0.0,0.0),osg::Vec3(0.0f,0.0,characterSize), 0.0, 0.0, 1.0, 1.0) ); 
     164    } 
     165     
     166    viewer.setSceneData(geode); 
     167#else 
    129168    osgText::TextNode* text = new osgText::TextNode; 
    130     text->setText(word); 
    131169    text->setFont(font.get()); 
    132170    text->setStyle(style.get()); 
    133171    text->setTextTechnique(new osgText::TextTechnique); 
     172    text->setText(word); 
    134173    text->update(); 
     174    viewer.setSceneData(text); 
     175#endif 
    135176 
    136     viewer.addEventHandler( new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()) ); 
    137     viewer.addEventHandler(new osgViewer::StatsHandler); 
    138     viewer.setSceneData(text); 
    139  
    140         return viewer.run(); 
     177    return viewer.run(); 
    141178}