Show
Ignore:
Timestamp:
09/06/05 17:48:18 (9 years ago)
Author:
robert
Message:

Added osgSim::OverlayNode? to osganimate and osgspheresegment examples, and
added support for setting texture size hint and coping with scene graphs
with CoordinateSystemNode? in them.

Files:
1 modified

Legend:

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

    r4175 r4506  
    1313 
    1414#include <osgSim/SphereSegment> 
     15#include <osgSim/OverlayNode> 
    1516 
    1617#include <osgParticle/ExplosionEffect> 
     
    174175{ 
    175176 
    176     osg::Geode* terrainGeode = new osg::Geode; 
    177177    // create terrain 
    178     { 
     178    osg::ref_ptr<osg::Geode> terrainGeode = 0; 
     179    { 
     180        terrainGeode = new osg::Geode; 
     181 
    179182        osg::StateSet* stateset = new osg::StateSet(); 
    180183        osg::Image* image = osgDB::readImageFile("Images/lz.rgb"); 
     
    206209        terrainGeode->addDrawable(new osg::ShapeDrawable(grid)); 
    207210         
    208         root->addChild(terrainGeode); 
     211         
    209212    }     
    210213 
     214 
    211215    // create sphere segment 
    212     { 
    213         osgSim::SphereSegment* ss = new osgSim::SphereSegment( 
    214                         computeTerrainIntersection(terrainGeode,550.0f,780.0f), // center 
     216    osg::ref_ptr<osgSim::SphereSegment> ss = 0; 
     217    { 
     218        ss = new osgSim::SphereSegment( 
     219                        computeTerrainIntersection(terrainGeode.get(),550.0f,780.0f), // center 
    215220                        500.0f, // radius 
    216221                        osg::DegreesToRadians(135.0f), 
     
    222227        ss->setSideColor(osg::Vec4(0.0f,1.0f,1.0f,0.1f)); 
    223228 
    224         root->addChild(ss);         
    225     } 
     229        root->addChild(ss.get()); 
     230    } 
     231 
     232#if 1 
     233    osgSim::OverlayNode* overlayNode = new osgSim::OverlayNode; 
     234    overlayNode->setOverlaySubgraph(ss.get()); 
     235    overlayNode->setOverlayTextureSizeHint(2048); 
     236    overlayNode->addChild(terrainGeode.get()); 
     237 
     238    root->addChild(overlayNode); 
     239#else 
     240    root->addChild(terrainGeode); 
     241#endif 
    226242 
    227243 
    228244    // create particle effects 
    229245    {     
    230         osg::Vec3 position = computeTerrainIntersection(terrainGeode,100.0f,100.0f); 
     246        osg::Vec3 position = computeTerrainIntersection(terrainGeode.get(),100.0f,100.0f); 
    231247 
    232248        osgParticle::ExplosionEffect* explosion = new osgParticle::ExplosionEffect(position, 10.0f); 
     
    241257    // create particle effects 
    242258    {     
    243         osg::Vec3 position = computeTerrainIntersection(terrainGeode,200.0f,100.0f); 
     259        osg::Vec3 position = computeTerrainIntersection(terrainGeode.get(),200.0f,100.0f); 
    244260 
    245261        osgParticle::ExplosionEffect* explosion = new osgParticle::ExplosionEffect(position, 1.0f);