Show
Ignore:
Timestamp:
02/27/07 12:51:32 (8 years ago)
Author:
robert
Message:

Added --label and --subscript options to allow us to create custom logos

Files:
1 modified

Legend:

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

    r5928 r6280  
    2121 
    2222#include <iostream> 
    23  
    24 static bool s_ProfessionalServices = false; 
    2523 
    2624class MyBillboardTransform : public osg::PositionAttitudeTransform 
     
    123121} 
    124122 
    125 osg:: Node* createTextBelow(const osg::BoundingBox& bb) 
     123osg:: Node* createTextBelow(const osg::BoundingBox& bb, const std::string& label, const std::string&) 
    126124{ 
    127125    osg::Geode* geode = new osg::Geode(); 
     
    137135    text->setPosition(bb.center()-osg::Vec3(0.0f,0.0f,(bb.zMax()-bb.zMin()))); 
    138136    text->setColor(osg::Vec4(0.37f,0.48f,0.67f,1.0f)); 
    139     text->setText("OpenSceneGraph"); 
     137    text->setText(label); 
    140138 
    141139    geode->addDrawable( text ); 
     
    144142} 
    145143 
    146 osg:: Node* createTextLeft(const osg::BoundingBox& bb) 
     144osg:: Node* createTextLeft(const osg::BoundingBox& bb, const std::string& label, const std::string& subscript) 
    147145{ 
    148146    osg::Geode* geode = new osg::Geode(); 
     
    166164    //text->setColor(osg::Vec4(0.37f,0.48f,0.67f,1.0f)); // Neil's orignal OSG colour 
    167165    text->setColor(osg::Vec4(0.20f,0.45f,0.60f,1.0f)); // OGL logo colour 
    168     text->setText("OpenSceneGraph"); 
     166    text->setText(label); 
    169167 
    170168#if 1 
     
    198196 
    199197 
    200     if (s_ProfessionalServices) 
     198    if (!subscript.empty()) 
    201199    { 
    202200        //osgText::Text* subscript = new  osgText::Text(new osgText::TextureFont(font,45)); 
    203201 
    204         osgText::Text* subscript = new osgText::Text; 
    205         subscript->setFont(font); 
    206         subscript->setText("Professional Services"); 
    207         subscript->setAlignment(osgText::Text::RIGHT_CENTER); 
    208         subscript->setAxisAlignment(osgText::Text::XZ_PLANE); 
    209         subscript->setPosition(bb.center()-osg::Vec3((bb.xMax()-bb.xMin())*4.3f,-(bb.yMax()-bb.yMin())*0.5f,(bb.zMax()-bb.zMin())*0.6f)); 
    210         subscript->setColor(osg::Vec4(0.0f,0.0f,0.0f,1.0f)); // black 
    211  
    212         geode->addDrawable( subscript ); 
     202        osgText::Text* subscriptText = new osgText::Text; 
     203        subscriptText->setFont(font); 
     204        subscriptText->setText(subscript); 
     205        subscriptText->setAlignment(osgText::Text::RIGHT_CENTER); 
     206        subscriptText->setAxisAlignment(osgText::Text::XZ_PLANE); 
     207        subscriptText->setPosition(bb.center()-osg::Vec3((bb.xMax()-bb.xMin())*4.3f,-(bb.yMax()-bb.yMin())*0.5f,(bb.zMax()-bb.zMin())*0.6f)); 
     208        subscriptText->setColor(osg::Vec4(0.0f,0.0f,0.0f,1.0f)); // black 
     209 
     210        geode->addDrawable( subscriptText ); 
    213211    } 
    214212         
     
    374372} 
    375373 
    376 osg::Node* createLogo(const std::string& filename) 
     374osg::Node* createLogo(const std::string& filename, const std::string& label, const std::string& subscript) 
    377375{ 
    378376    osg::BoundingBox bb(osg::Vec3(0.0f,0.0f,0.0f),osg::Vec3(100.0f,100.0f,100.0f)); 
     
    413411    // add the text to the group. 
    414412    //group->addChild(createTextBelow(bb)); 
    415     logo_group->addChild(createTextLeft(bb)); 
     413    logo_group->addChild(createTextLeft(bb, label, subscript)); 
    416414     
    417415     
     
    460458    } 
    461459     
    462     while (arguments.read("ps")) s_ProfessionalServices = true; 
    463      
    464     osg::Node* node = 0; 
    465      
    466     if (arguments.argc()>1) createLogo(arguments[1]); 
    467     else node = createLogo(""); 
     460    std::string label = "OpenSceneGraph"; 
     461    std::string subscript = ""; 
     462 
     463    while (arguments.read("--label", label)) {}  
     464    while (arguments.read("--subscript", subscript)) {}  
     465     
     466    osg::ref_ptr<osg::Node> node; 
     467     
     468    if (arguments.argc()>1) node = createLogo(arguments[1], label, subscript); 
     469    else node = createLogo("", label, subscript); 
    468470 
    469471    // add model to viewer. 
    470     viewer.setSceneData( node ); 
     472    viewer.setSceneData( node.get() ); 
    471473 
    472474    return viewer.run();