Checked in osgParticle, writtten by Marco Jez.

This commit is contained in:
Robert Osfield
2002-06-05 12:44:55 +00:00
parent f8ffc692be
commit 9ba7505d1e
110 changed files with 10467 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
#include <osgParticle/ModularEmitter>
#include <osgParticle/Emitter>
osgParticle::ModularEmitter::ModularEmitter()
: Emitter(),
counter_(osgNew RandomRateCounter),
placer_(osgNew PointPlacer),
shooter_(osgNew RadialShooter)
{
}
osgParticle::ModularEmitter::ModularEmitter(const ModularEmitter &copy, const osg::CopyOp &copyop)
: Emitter(copy, copyop),
counter_(static_cast<Counter *>(copyop(copy.counter_.get()))),
placer_(static_cast<Placer *>(copyop(copy.placer_.get()))),
shooter_(static_cast<Shooter *>(copyop(copy.shooter_.get())))
{
}
void osgParticle::ModularEmitter::emit(double dt)
{
int n = counter_->numParticlesToCreate(dt);
for (int i=0; i<n; ++i) {
Particle *P = getParticleSystem()->createParticle(getUseDefaultTemplate()? 0: &getParticleTemplate());
if (P) {
placer_->place(P);
shooter_->shoot(P);
if (getReferenceFrame() == RELATIVE_TO_PARENTS) {
P->transformPositionVelocity(getLocalToWorldMatrix());
}
}
}
}