Moved ParticleSystemUpdater into ParticleEffect nodes to simplify usage

of nodes.
This commit is contained in:
Robert Osfield
2005-03-22 20:26:45 +00:00
parent 1c808e4959
commit 0b2ac40fe8
4 changed files with 36 additions and 21 deletions

View File

@@ -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);
}

View File

@@ -21,6 +21,7 @@
#include <osgParticle/RadialShooter>
#include <osgParticle/AccelOperator>
#include <osgParticle/FluidFrictionOperator>
#include <osgParticle/ParticleSystemUpdater>
#include <osg/Geode>
@@ -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);
}

View File

@@ -20,6 +20,7 @@
#include <osgParticle/RadialShooter>
#include <osgParticle/AccelOperator>
#include <osgParticle/FluidFrictionOperator>
#include <osgParticle/ParticleSystemUpdater>
#include <osg/Geode>
@@ -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);
}

View File

@@ -20,6 +20,7 @@
#include <osgParticle/AccelOperator>
#include <osgParticle/FluidFrictionOperator>
#include <osgParticle/SectorPlacer>
#include <osgParticle/ParticleSystemUpdater>
#include <osg/Geode>
@@ -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);
}