Changeset 1608 for code/trunk/src/orxonox/objects/ParticleSpawner.cc
- Timestamp:
- Jun 17, 2008, 3:33:03 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/objects/ParticleSpawner.cc
r1602 r1608 33 33 #include "core/Executor.h" 34 34 #include "tools/ParticleInterface.h" 35 #include "GraphicsEngine.h" 35 36 36 37 namespace orxonox … … 44 45 } 45 46 46 ParticleSpawner::ParticleSpawner(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime, float delay, const Vector3& direction)47 ParticleSpawner::ParticleSpawner(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime, float startdelay, float destroydelay, const Vector3& direction) 47 48 { 48 49 RegisterObject(ParticleSpawner); 49 this->setParticle(templateName, detaillevel, lifetime, delay, direction);50 this->setParticle(templateName, detaillevel, lifetime, startdelay, destroydelay, direction); 50 51 } 51 52 52 void ParticleSpawner::setParticle(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime, float delay, const Vector3& direction)53 void ParticleSpawner::setParticle(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime, float startdelay, float destroydelay, const Vector3& direction) 53 54 { 54 55 ExecutorMember<ParticleSpawner>* executor = createExecutor(createFunctor(&ParticleSpawner::createParticleSpawner)); 56 this->destroydelay_ = destroydelay; 55 57 executor->setDefaultValues(lifetime); 56 this->timer_.setTimer( delay, false, this, executor);58 this->timer_.setTimer(startdelay, false, this, executor); 57 59 this->particle_ = new ParticleInterface(templateName, detaillevel); 58 60 this->particle_->addToSceneNode(this->getNode()); … … 72 74 } 73 75 }; 76 77 void ParticleSpawner::destroy() 78 { 79 this->setPosition(this->getNode()->getParent()->getPosition()); 80 this->getNode()->getParent()->removeChild(this->getNode()); 81 GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->addChild(this->getNode()); 82 if (this->particle_) 83 this->particle_->setEnabled(false); 84 if (!this->timer_.isActive() || this->timer_.getRemainingTime() > this->destroydelay_) 85 this->timer_.setTimer(this->destroydelay_, false, this, createExecutor(createFunctor(&ParticleSpawner::destroyParticleSpawner))); 86 } 74 87 75 88 void ParticleSpawner::createParticleSpawner(float lifetime)
Note: See TracChangeset
for help on using the changeset viewer.