Show
Ignore:
Timestamp:
06/07/04 14:53:09 (10 years ago)
Author:
robert
Message:

Added sphere segment to osgsimulator.

Files:
1 modified

Legend:

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

    r3008 r3039  
    88 
    99#include <osgDB/ReadFile> 
     10 
     11#include <osgSim/SphereSegment> 
    1012 
    1113#include <osgParticle/ExplosionEffect> 
     
    5355 
    5456    osg::Geode* terrainGeode = new osg::Geode; 
     57    // create terrain 
    5558    { 
    5659        osg::StateSet* stateset = new osg::StateSet(); 
     
    8689    }     
    8790 
    88  
    89      
    90     osg::PositionAttitudeTransform* positionEffects = new osg::PositionAttitudeTransform; 
    91     positionEffects->setPosition(computeTerrainIntersection(terrainGeode,100.0f,100.0f)); 
    92     root->addChild(positionEffects); 
    93  
    94     osgParticle::ExplosionEffect* explosion = new osgParticle::ExplosionEffect; 
    95     osgParticle::SmokeEffect* smoke = new osgParticle::SmokeEffect; 
    96     osgParticle::FireEffect* fire = new osgParticle::FireEffect; 
    97  
    98     osg::Geode* geode = new osg::Geode; 
    99     geode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0.0f,0.0f,0.0f),10.0f))); 
    100     positionEffects->addChild(geode); 
    101  
    102     positionEffects->addChild(explosion); 
    103     positionEffects->addChild(smoke); 
    104     positionEffects->addChild(fire); 
    105  
    106     osgParticle::ParticleSystemUpdater *psu = new osgParticle::ParticleSystemUpdater; 
    107  
    108     psu->addParticleSystem(explosion->getParticleSystem()); 
    109     psu->addParticleSystem(smoke->getParticleSystem()); 
    110     psu->addParticleSystem(fire->getParticleSystem()); 
    111  
    112     // add the updater node to the scene graph 
    113     root->addChild(psu); 
    114  
     91    // create sphere segment 
     92    { 
     93        osgSim::SphereSegment* ss = new osgSim::SphereSegment( 
     94                        computeTerrainIntersection(terrainGeode,550.0f,780.0f), // center 
     95                        500.0f, // radius 
     96                        osg::DegreesToRadians(135.0f), 
     97                        osg::DegreesToRadians(245.0f), 
     98                        osg::DegreesToRadians(-10.0f), 
     99                        osg::DegreesToRadians(30.0f), 
     100                        60); 
     101        ss->setAllColors(osg::Vec4(1.0f,1.0f,1.0f,0.5f)); 
     102        ss->setSideColor(osg::Vec4(0.0f,1.0f,1.0f,0.1f)); 
     103 
     104        root->addChild(ss);         
     105    } 
     106 
     107 
     108    // create particle effects 
     109    {     
     110        osg::PositionAttitudeTransform* positionEffects = new osg::PositionAttitudeTransform; 
     111        positionEffects->setPosition(computeTerrainIntersection(terrainGeode,100.0f,100.0f)); 
     112        root->addChild(positionEffects); 
     113 
     114        osgParticle::ExplosionEffect* explosion = new osgParticle::ExplosionEffect; 
     115        osgParticle::SmokeEffect* smoke = new osgParticle::SmokeEffect; 
     116        osgParticle::FireEffect* fire = new osgParticle::FireEffect; 
     117 
     118        osg::Geode* geode = new osg::Geode; 
     119        geode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0.0f,0.0f,0.0f),10.0f))); 
     120        positionEffects->addChild(geode); 
     121 
     122        positionEffects->addChild(explosion); 
     123        positionEffects->addChild(smoke); 
     124        positionEffects->addChild(fire); 
     125 
     126        osgParticle::ParticleSystemUpdater *psu = new osgParticle::ParticleSystemUpdater; 
     127 
     128        psu->addParticleSystem(explosion->getParticleSystem()); 
     129        psu->addParticleSystem(smoke->getParticleSystem()); 
     130        psu->addParticleSystem(fire->getParticleSystem()); 
     131 
     132        // add the updater node to the scene graph 
     133        root->addChild(psu); 
     134    } 
    115135} 
    116136