Show
Ignore:
Timestamp:
05/28/07 17:44:37 (7 years ago)
Author:
robert
Message:

Added --object, --ortho and --persp OverlayNode? options

Files:
1 modified

Legend:

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

    r6767 r6779  
    330330////////////////////////////////////////////////////////////////////////////// 
    331331 
    332 void build_world(osg::Group *root, unsigned int testCase) 
     332void build_world(osg::Group *root, unsigned int testCase, bool useOverlay, osgSim::OverlayNode::OverlayTechnique technique) 
    333333{ 
    334334 
     
    568568     
    569569 
    570     root->addChild(terrainGeode.get()); 
    571  
     570    if (useOverlay) 
     571    { 
     572        osgSim::OverlayNode* overlayNode = new osgSim::OverlayNode(technique); 
     573        overlayNode->getOrCreateStateSet()->setTextureAttribute(1, new osg::TexEnv(osg::TexEnv::DECAL)); 
     574 
     575        const osg::BoundingSphere& bs = terrainGeode->getBound(); 
     576        osg::Group* overlaySubgraph = createOverlay(bs.center(), bs.radius()*0.5f); 
     577        overlaySubgraph->addChild(ss.get()); 
     578        overlayNode->setOverlaySubgraph(overlaySubgraph); 
     579        overlayNode->setOverlayTextureSizeHint(1024); 
     580        overlayNode->setOverlayBaseHeight(0.0); 
     581        overlayNode->addChild(terrainGeode.get()); 
     582 
     583        root->addChild(overlayNode); 
     584    } 
     585    else 
     586    { 
     587      root->addChild(terrainGeode.get()); 
     588    } 
     589     
    572590    // create particle effects 
    573591    {     
     
    627645    // if user request help write it out to cout. 
    628646    unsigned int testCase = 0; 
    629     if (arguments.read("-t", testCase)) {} 
    630  
     647    while (arguments.read("-t", testCase)) {} 
     648 
     649    bool useOverlay = false; 
    631650    osgSim::OverlayNode::OverlayTechnique technique = osgSim::OverlayNode::OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY; 
    632     while (arguments.read("--object")) technique = osgSim::OverlayNode::OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY; 
    633     while (arguments.read("--ortho") || arguments.read("--orthographic")) technique = osgSim::OverlayNode::VIEW_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY; 
    634     while (arguments.read("--persp") || arguments.read("--perspective")) technique = osgSim::OverlayNode::VIEW_DEPENDENT_WITH_PERSPECTIVE_OVERLAY; 
     651    while (arguments.read("--object")) { useOverlay = true; technique = osgSim::OverlayNode::OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY; } 
     652    while (arguments.read("--ortho") || arguments.read("--orthographic")) { useOverlay = true; technique = osgSim::OverlayNode::VIEW_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY; } 
     653    while (arguments.read("--persp") || arguments.read("--perspective")) { useOverlay = true; technique = osgSim::OverlayNode::VIEW_DEPENDENT_WITH_PERSPECTIVE_OVERLAY; } 
    635654     
    636655 
     
    653672     
    654673    osg::Group *root = new osg::Group; 
    655     build_world(root, testCase); 
     674    build_world(root, testCase, useOverlay, technique); 
    656675    
    657676    // add a viewport to the viewer and attach the scene graph.