diff --git a/examples/osgspheresegment/osgspheresegment.cpp b/examples/osgspheresegment/osgspheresegment.cpp index fc5f4b7d8..02bb9e514 100644 --- a/examples/osgspheresegment/osgspheresegment.cpp +++ b/examples/osgspheresegment/osgspheresegment.cpp @@ -116,6 +116,21 @@ osg::Node* createMovingModel(const osg::Vec3& center, float radius) xform->setUpdateCallback(new osg::AnimationPathCallback(animationPath,0.0f,2.0)); xform->addChild(positioned); + // add particle effects to cessna. + { + osg::PositionAttitudeTransform* positionEffects = new osg::PositionAttitudeTransform; + positionEffects->setPosition(osg::Vec3(0.0f,0.0f,0.0f)); + xform->addChild(positionEffects); + + osgParticle::ExplosionEffect* explosion = new osgParticle::ExplosionEffect; + osgParticle::SmokeEffect* smoke = new osgParticle::SmokeEffect; + osgParticle::FireEffect* fire = new osgParticle::FireEffect; + + positionEffects->addChild(explosion); + positionEffects->addChild(smoke); + positionEffects->addChild(fire); + } + model->addChild(xform); } @@ -220,22 +235,10 @@ void build_world(osg::Group *root) osgParticle::SmokeEffect* smoke = new osgParticle::SmokeEffect; osgParticle::FireEffect* fire = new osgParticle::FireEffect; - //osg::Geode* geode = new osg::Geode; - //geode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0.0f,0.0f,0.0f),10.0f))); - //positionEffects->addChild(geode); - positionEffects->addChild(explosion); positionEffects->addChild(smoke); positionEffects->addChild(fire); - osgParticle::ParticleSystemUpdater *psu = new osgParticle::ParticleSystemUpdater; - - psu->addParticleSystem(explosion->getParticleSystem()); - psu->addParticleSystem(smoke->getParticleSystem()); - psu->addParticleSystem(fire->getParticleSystem()); - - // add the updater node to the scene graph - root->addChild(psu); } diff --git a/src/osgParticle/ExplosionEffect.cpp b/src/osgParticle/ExplosionEffect.cpp index 9ddad3b93..fa49e5ab6 100644 --- a/src/osgParticle/ExplosionEffect.cpp +++ b/src/osgParticle/ExplosionEffect.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -128,10 +129,13 @@ void ExplosionEffect::buildEffect() // add the program to update the particles addChild(_program.get()); - osg::Geode *geode = new osg::Geode; - geode->addDrawable(_particleSystem.get()); - //geode->setCullingActive(false); + // add the particle system updater. + osgParticle::ParticleSystemUpdater *psu = new osgParticle::ParticleSystemUpdater; + psu->addParticleSystem(_particleSystem.get()); + addChild(psu); // add the geode to the scene graph + osg::Geode *geode = new osg::Geode; + geode->addDrawable(_particleSystem.get()); addChild(geode); } diff --git a/src/osgParticle/FireEffect.cpp b/src/osgParticle/FireEffect.cpp index 442f08075..a21eaff85 100644 --- a/src/osgParticle/FireEffect.cpp +++ b/src/osgParticle/FireEffect.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -125,10 +126,13 @@ void FireEffect::buildEffect() // add the program to update the particles addChild(_program.get()); - osg::Geode *geode = new osg::Geode; - geode->addDrawable(_particleSystem.get()); - //geode->setCullingActive(false); + // add the particle system updater. + osgParticle::ParticleSystemUpdater *psu = new osgParticle::ParticleSystemUpdater; + psu->addParticleSystem(_particleSystem.get()); + addChild(psu); // add the geode to the scene graph + osg::Geode *geode = new osg::Geode; + geode->addDrawable(_particleSystem.get()); addChild(geode); } diff --git a/src/osgParticle/SmokeEffect.cpp b/src/osgParticle/SmokeEffect.cpp index 65553c8eb..85b30bfb5 100644 --- a/src/osgParticle/SmokeEffect.cpp +++ b/src/osgParticle/SmokeEffect.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include @@ -124,10 +125,13 @@ void SmokeEffect::buildEffect() // add the program to update the particles addChild(_program.get()); - osg::Geode *geode = new osg::Geode; - geode->addDrawable(_particleSystem.get()); -// geode->setCullingActive(false); + // add the particle system updater. + osgParticle::ParticleSystemUpdater *psu = new osgParticle::ParticleSystemUpdater; + psu->addParticleSystem(_particleSystem.get()); + addChild(psu); // add the geode to the scene graph + osg::Geode *geode = new osg::Geode; + geode->addDrawable(_particleSystem.get()); addChild(geode); }