Changeset 1563 for code/trunk/src/orxonox/tools
- Timestamp:
- Jun 7, 2008, 11:40:50 PM (16 years ago)
- Location:
- code/trunk/src/orxonox/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/tools/ParticleInterface.cc
r1555 r1563 40 40 #include "GraphicsEngine.h" 41 41 #include "Orxonox.h" 42 #include "core/CoreIncludes.h" 42 43 #include "util/Convert.h" 43 44 … … 47 48 ParticleInterface* ParticleInterface::currentParticleInterface_s = 0; 48 49 49 ParticleInterface::ParticleInterface(const std::string& templateName )50 ParticleInterface::ParticleInterface(const std::string& templateName, LODParticle::LOD detaillevel) 50 51 { 52 RegisterRootObject(ParticleInterface); 53 51 54 this->sceneNode_ = 0; 55 this->bEnabled_ = true; 56 this->detaillevel_ = (unsigned int)detaillevel; 52 57 this->particleSystem_ = GraphicsEngine::getSingleton().getSceneManager()->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName); 53 58 this->particleSystem_->setSpeedFactor(Orxonox::getSingleton()->getTimeFactor()); 59 60 if (GraphicsEngine::getSingleton().getDetailLevelParticle() < (unsigned int)this->detaillevel_) 61 { 62 this->bVisible_ = false; 63 this->updateVisibility(); 64 } 65 else 66 { 67 this->bVisible_ = true; 68 } 54 69 } 55 70 … … 134 149 void ParticleInterface::setEnabled(bool enable) 135 150 { 151 this->bEnabled_ = enable; 152 this->updateVisibility(); 153 } 154 155 void ParticleInterface::detailLevelChanged(unsigned int newlevel) 156 { 157 if (newlevel >= (unsigned int)this->detaillevel_) 158 this->bVisible_ = true; 159 else 160 this->bVisible_ = false; 161 162 this->updateVisibility(); 163 } 164 165 void ParticleInterface::updateVisibility() 166 { 136 167 for (unsigned int i = 0; i < this->particleSystem_->getNumEmitters(); i++) 137 this->particleSystem_->getEmitter(i)->setEnabled( enable);168 this->particleSystem_->getEmitter(i)->setEnabled(this->bEnabled_ && this->bVisible_); 138 169 } 139 170 … … 144 175 float ParticleInterface::getSpeedFactor() const 145 176 { 146 return this->particleSystem_->getSpeedFactor();177 return (this->particleSystem_->getSpeedFactor() / Orxonox::getSingleton()->getTimeFactor()); 147 178 } 148 179 -
code/trunk/src/orxonox/tools/ParticleInterface.h
r1553 r1563 35 35 #include <OgreParticleEmitter.h> 36 36 37 #include "core/OrxonoxClass.h" 37 38 #include "util/Math.h" 38 39 … … 44 45 namespace orxonox 45 46 { 46 class _OrxonoxExport ParticleInterface 47 class _OrxonoxExport ParticleInterface : public OrxonoxClass 47 48 { 48 49 public: 49 ParticleInterface(const std::string& templateName );50 ParticleInterface(const std::string& templateName, LODParticle::LOD detaillevel); 50 51 ~ParticleInterface(); 51 52 … … 74 75 75 76 void setEnabled(bool enable); 77 void detailLevelChanged(unsigned int newlevel); 76 78 77 79 inline void storeThisAsCurrentParticleInterface() … … 81 83 82 84 private: 85 void updateVisibility(); 86 83 87 static ParticleInterface* currentParticleInterface_s; 84 88 static unsigned int counter_s; 85 89 Ogre::SceneNode* sceneNode_; 86 90 Ogre::ParticleSystem* particleSystem_; 91 bool bVisible_; 92 bool bEnabled_; 93 unsigned int detaillevel_; //!< Detail level of this particle effect (0: off, 1: low, 2: normal, 3: high) 87 94 }; 88 95 }
Note: See TracChangeset
for help on using the changeset viewer.