Checked in osgParticle, writtten by Marco Jez.
This commit is contained in:
33
src/osgParticle/ModularEmitter.cpp
Normal file
33
src/osgParticle/ModularEmitter.cpp
Normal 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 ©, const osg::CopyOp ©op)
|
||||
: 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user