Changeset 2087 for code/trunk/src/orxonox/tools
- Timestamp:
- Nov 1, 2008, 7:04:09 PM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 2 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/tools/BillboardSet.cc
r1755 r2087 31 31 32 32 #include <sstream> 33 #include <cassert> 33 34 34 35 #include <OgreSceneManager.h> 36 #include <OgreBillboard.h> 35 37 36 #include " GraphicsEngine.h"37 #include "util/ Math.h"38 #include "util/Convert.h" 39 #include "util/String.h" 38 40 39 41 namespace orxonox … … 46 48 } 47 49 48 void BillboardSet::setBillboardSet(const std::string& file, int count)50 BillboardSet::~BillboardSet() 49 51 { 50 std::ostringstream name; 51 name << (BillboardSet::billboardSetCounter_s++); 52 this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count); 53 this->billboardSet_->createBillboard(Vector3::ZERO); 54 this->billboardSet_->setMaterialName(file); 52 this->destroyBillboardSet(); 55 53 } 56 54 57 void BillboardSet::setBillboardSet( const std::string& file, const ColourValue& colour, int count)55 void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, int count) 58 56 { 59 std::ostringstream name; 60 name << (BillboardSet::billboardSetCounter_s++); 61 this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count); 62 this->billboardSet_->createBillboard(Vector3::ZERO, colour); 63 this->billboardSet_->setMaterialName(file); 57 this->setBillboardSet(scenemanager, file, Vector3::ZERO, count); 64 58 } 65 59 66 void BillboardSet::setBillboardSet( const std::string& file, const Vector3& position, int count)60 void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, int count) 67 61 { 68 std::ostringstream name; 69 name << (BillboardSet::billboardSetCounter_s++); 70 this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count); 71 this->billboardSet_->createBillboard(position); 72 this->billboardSet_->setMaterialName(file); 62 this->setBillboardSet(scenemanager, file, colour, Vector3::ZERO, count); 73 63 } 74 64 75 void BillboardSet::setBillboardSet( const std::string& file, const ColourValue& colour, const Vector3& position, int count)65 void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const Vector3& position, int count) 76 66 { 77 std::ostringstream name; 78 name << (BillboardSet::billboardSetCounter_s++); 79 this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count); 80 this->billboardSet_->createBillboard(position, colour); 81 this->billboardSet_->setMaterialName(file); 67 assert(scenemanager); 68 this->destroyBillboardSet(); 69 70 try 71 { 72 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count); 73 this->billboardSet_->createBillboard(position); 74 this->billboardSet_->setMaterialName(file); 75 } 76 catch (...) 77 { 78 COUT(1) << "Error: Couln't load billboard \"" << file << "\"" << std::endl; 79 } 80 81 this->scenemanager_ = scenemanager; 82 82 } 83 83 84 BillboardSet::~BillboardSet() 84 void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, const Vector3& position, int count) 85 { 86 assert(scenemanager); 87 this->destroyBillboardSet(); 88 89 try 90 { 91 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count); 92 this->billboardSet_->createBillboard(position, colour); 93 this->billboardSet_->setMaterialName(file); 94 } 95 catch (...) 96 { 97 COUT(1) << "Error: Couln't load billboard \"" << file << "\"" << std::endl; 98 } 99 100 this->scenemanager_ = scenemanager; 101 } 102 103 void BillboardSet::destroyBillboardSet() 104 { 105 if (this->billboardSet_ && this->scenemanager_) 106 this->scenemanager_->destroyBillboardSet(this->billboardSet_); 107 } 108 109 const std::string& BillboardSet::getName() const 85 110 { 86 111 if (this->billboardSet_) 87 GraphicsEngine::getInstance().getLevelSceneManager()->destroyBillboardSet(this->billboardSet_); 112 return this->billboardSet_->getName(); 113 else 114 return BLANKSTRING; 115 } 116 117 void BillboardSet::setVisible(bool visible) 118 { 119 if (this->billboardSet_) 120 this->billboardSet_->setVisible(visible); 121 } 122 123 bool BillboardSet::getVisible() const 124 { 125 if (this->billboardSet_) 126 return this->billboardSet_->getVisible(); 127 else 128 return false; 129 } 130 131 void BillboardSet::setColour(const ColourValue& colour) 132 { 133 if (this->billboardSet_) 134 { 135 for (int i = 0; i < this->billboardSet_->getNumBillboards(); ++i) 136 this->billboardSet_->getBillboard(i)->setColour(colour); 137 } 138 } 139 140 const ColourValue& BillboardSet::getColour() const 141 { 142 if (this->billboardSet_ && this->billboardSet_->getNumBillboards() > 0) 143 { 144 return this->billboardSet_->getBillboard(0)->getColour(); 145 } 146 else 147 return ColourValue::White; 148 } 149 150 void BillboardSet::setMaterial(const std::string& material) 151 { 152 if (this->billboardSet_) 153 this->billboardSet_->setMaterialName(material); 154 } 155 156 const std::string& BillboardSet::getMaterial() const 157 { 158 if (this->billboardSet_) 159 return this->billboardSet_->getMaterialName(); 160 else 161 return BLANKSTRING; 88 162 } 89 163 } -
code/trunk/src/orxonox/tools/BillboardSet.h
r1602 r2087 44 44 BillboardSet(); 45 45 ~BillboardSet(); 46 void setBillboardSet(const std::string& file, int count = 1); 47 void setBillboardSet(const std::string& file, const ColourValue& colour, int count = 1); 48 void setBillboardSet(const std::string& file, const Vector3& position, int count = 1); 49 void setBillboardSet(const std::string& file, const ColourValue& colour, const Vector3& position, int count = 1); 46 47 void setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, int count = 1); 48 void setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, int count = 1); 49 void setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const Vector3& position, int count = 1); 50 void setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, const Vector3& position, int count = 1); 50 51 51 52 inline Ogre::BillboardSet* getBillboardSet() 52 53 { return this->billboardSet_; } 53 54 54 inline const std::string& getName() const 55 { return this->billboardSet_->getName(); } 55 const std::string& getName() const; 56 56 57 inline void setVisible(bool visible) 58 { this->billboardSet_->setVisible(visible); } 59 inline bool getVisible() const 60 { return this->billboardSet_->getVisible(); } 57 void setVisible(bool visible); 58 bool getVisible() const; 59 60 void setColour(const ColourValue& colour); 61 const ColourValue& getColour() const; 62 63 void setMaterial(const std::string& material); 64 const std::string& getMaterial() const; 61 65 62 66 private: 67 void destroyBillboardSet(); 68 63 69 static unsigned int billboardSetCounter_s; 64 70 Ogre::BillboardSet* billboardSet_; 71 Ogre::SceneManager* scenemanager_; 65 72 }; 66 73 } -
code/trunk/src/orxonox/tools/Mesh.cc
r1755 r2087 32 32 #include <sstream> 33 33 #include <OgreSceneManager.h> 34 #include "GraphicsEngine.h" 35 #include "Settings.h" 34 #include <cassert> 35 36 #include "core/Core.h" 37 #include "util/Convert.h" 38 #include "util/String.h" 36 39 37 40 namespace orxonox … … 39 42 unsigned int Mesh::meshCounter_s = 0; 40 43 41 Mesh::Mesh() : 42 entity_(0) 44 Mesh::Mesh() 43 45 { 44 } 45 46 void Mesh::setMesh(const std::string& file) 47 { 48 std::ostringstream name; 49 name << (Mesh::meshCounter_s++); 50 if (Settings::showsGraphics()) 51 this->entity_ = GraphicsEngine::getInstance().getLevelSceneManager()->createEntity("Mesh" + name.str(), file); 46 this->entity_ = 0; 47 this->bCastShadows_ = true; 52 48 } 53 49 54 50 Mesh::~Mesh() 55 51 { 56 if (this->entity_ && Settings::showsGraphics()) 57 GraphicsEngine::getInstance().getLevelSceneManager()->destroyEntity(this->entity_); 52 if (this->entity_ && this->scenemanager_) 53 this->scenemanager_->destroyEntity(this->entity_); 54 } 55 56 void Mesh::setMeshSource(Ogre::SceneManager* scenemanager, const std::string& meshsource) 57 { 58 assert(scenemanager); 59 60 this->scenemanager_ = scenemanager; 61 62 if (this->entity_) 63 this->scenemanager_->destroyEntity(this->entity_); 64 65 if (Core::showsGraphics()) 66 { 67 try 68 { 69 this->entity_ = this->scenemanager_->createEntity("Mesh" + convertToString(Mesh::meshCounter_s++), meshsource); 70 this->entity_->setCastShadows(this->bCastShadows_); 71 } 72 catch (...) 73 { 74 COUT(1) << "Error: Couln't load mesh \"" << meshsource << "\"" << std::endl; 75 } 76 } 77 } 78 79 void Mesh::setCastShadows(bool bCastShadows) 80 { 81 this->bCastShadows_ = bCastShadows; 82 if (this->entity_) 83 this->entity_->setCastShadows(this->bCastShadows_); 84 } 85 86 const std::string& Mesh::getName() const 87 { 88 if (this->entity_) 89 return this->entity_->getName(); 90 else 91 return BLANKSTRING; 92 } 93 94 void Mesh::setVisible(bool bVisible) 95 { 96 if (this->entity_) 97 this->entity_->setVisible(bVisible); 98 } 99 100 bool Mesh::isVisible() const 101 { 102 if (this->entity_) 103 return this->entity_->getVisible(); 104 else 105 return false; 58 106 } 59 107 } -
code/trunk/src/orxonox/tools/Mesh.h
r1627 r2087 21 21 * 22 22 * Author: 23 * ...23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 25 * ... … … 33 33 34 34 #include <string> 35 36 35 #include <OgreEntity.h> 37 36 … … 43 42 Mesh(); 44 43 ~Mesh(); 45 void setMesh(const std::string& file); 44 45 void setMeshSource(Ogre::SceneManager* scenemanager, const std::string& file); 46 46 47 47 inline Ogre::Entity* getEntity() 48 48 { return this->entity_; } 49 49 50 inline const std::string& getName() const 51 { return this->entity_->getName(); } 50 const std::string& getName() const; 52 51 53 inline void setVisible(bool visible) 54 { if (this->entity_) this->entity_->setVisible(visible); } 55 inline bool getVisible() const 56 { if (this->entity_) return this->entity_->getVisible(); else return false; } 52 void setVisible(bool bVisible); 53 bool isVisible() const; 54 55 void setCastShadows(bool bCastShadows); 56 inline bool getCastShadows() const 57 { return this->bCastShadows_; } 57 58 58 59 private: 59 60 static unsigned int meshCounter_s; 60 61 Ogre::Entity* entity_; 62 bool bCastShadows_; 63 Ogre::SceneManager* scenemanager_; 61 64 }; 62 65 } -
code/trunk/src/orxonox/tools/ParticleInterface.cc
r1755 r2087 1 1 /* 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * 4 * 5 * License notice: 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * Author: 22 * ... 23 * Co-authors: 24 * ... 25 * 26 */ 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 4 * 5 * 6 * License notice: 7 * 8 * This program is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU General Public License 10 * as published by the Free Software Foundation; either version 2 11 * of the License, or (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 21 * 22 * Author: 23 * Fabian 'x3n' Landau 24 * Co-authors: 25 * ... 26 * 27 */ 27 28 28 29 /** … … 37 38 #include <OgreParticleEmitter.h> 38 39 #include <OgreSceneManager.h> 40 #include <cassert> 39 41 40 42 #include "GraphicsEngine.h" … … 44 46 namespace orxonox 45 47 { 46 unsigned int ParticleInterface::counter_s = 0; 47 ParticleInterface* ParticleInterface::currentParticleInterface_s = 0; 48 49 ParticleInterface::ParticleInterface(const std::string& templateName, LODParticle::LOD detaillevel) 50 { 51 RegisterRootObject(ParticleInterface); 52 53 this->sceneNode_ = 0; 54 this->bEnabled_ = true; 55 this->detaillevel_ = (unsigned int)detaillevel; 56 this->particleSystem_ = GraphicsEngine::getInstance().getLevelSceneManager()->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName); 57 //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor()); 58 this->particleSystem_->setSpeedFactor(1.0f); 59 60 if (GraphicsEngine::getInstance().getDetailLevelParticle() < (unsigned int)this->detaillevel_) 61 { 62 this->bVisible_ = false; 63 this->updateVisibility(); 64 } 65 else 66 { 67 this->bVisible_ = true; 68 } 69 } 70 71 ParticleInterface::~ParticleInterface() 72 { 73 this->particleSystem_->removeAllEmitters(); 74 GraphicsEngine::getInstance().getLevelSceneManager()->destroyParticleSystem(particleSystem_); 75 } 76 77 void ParticleInterface::addToSceneNode(Ogre::SceneNode* sceneNode) 78 { 79 this->sceneNode_ = sceneNode; 80 this->sceneNode_->attachObject(this->particleSystem_); 81 } 82 83 void ParticleInterface::detachFromSceneNode() 84 { 85 if (this->sceneNode_) 86 { 87 this->sceneNode_->detachObject(this->particleSystem_); 88 this->sceneNode_ = 0; 89 } 90 } 91 92 Ogre::ParticleEmitter* ParticleInterface::createNewEmitter() 93 { 94 if (this->particleSystem_->getNumEmitters() > 0) 95 { 96 Ogre::ParticleEmitter* newemitter = this->particleSystem_->addEmitter(this->particleSystem_->getEmitter(0)->getType()); 97 this->particleSystem_->getEmitter(0)->copyParametersTo(newemitter); 98 return newemitter; 99 } 100 else 101 return 0; 102 } 103 Ogre::ParticleEmitter* ParticleInterface::getEmitter(unsigned int emitterNr) const 104 { 105 if (emitterNr < this->particleSystem_->getNumEmitters()) 106 return this->particleSystem_->getEmitter(emitterNr); 107 else 108 return 0; 109 } 110 void ParticleInterface::removeEmitter(unsigned int emitterNr) 111 { 112 if (emitterNr < this->particleSystem_->getNumEmitters()) 113 this->particleSystem_->removeEmitter(emitterNr); 114 } 115 void ParticleInterface::removeAllEmitters() 116 { 117 this->particleSystem_->removeAllEmitters(); 118 } 119 unsigned int ParticleInterface::getNumEmitters() const 120 { 121 return this->particleSystem_->getNumEmitters(); 122 } 123 124 Ogre::ParticleAffector* ParticleInterface::addAffector(const std::string& name) 125 { 126 return this->particleSystem_->addAffector(name); 127 } 128 Ogre::ParticleAffector* ParticleInterface::getAffector(unsigned int affectorNr) const 129 { 130 if (affectorNr < this->particleSystem_->getNumAffectors()) 131 return this->particleSystem_->getAffector(affectorNr); 132 else 133 return 0; 134 } 135 void ParticleInterface::removeAffector(unsigned int affectorNr) 136 { 137 if (affectorNr < this->particleSystem_->getNumAffectors()) 138 this->particleSystem_->removeAffector(affectorNr); 139 } 140 void ParticleInterface::removeAllAffectors() 141 { 142 this->particleSystem_->removeAllAffectors(); 143 } 144 unsigned int ParticleInterface::getNumAffectors() const 145 { 146 return this->particleSystem_->getNumAffectors(); 147 } 148 149 void ParticleInterface::setEnabled(bool enable) 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 { 167 for (unsigned int i = 0; i < this->particleSystem_->getNumEmitters(); i++) 168 this->particleSystem_->getEmitter(i)->setEnabled(this->bEnabled_ && this->bVisible_); 169 } 170 171 void ParticleInterface::setSpeedFactor(float factor) 172 { 173 //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor() * factor); 174 this->particleSystem_->setSpeedFactor(1.0f * factor); 175 } 176 float ParticleInterface::getSpeedFactor() const 177 { 178 //return (this->particleSystem_->getSpeedFactor() / Orxonox::getInstance().getTimeFactor()); 179 return (this->particleSystem_->getSpeedFactor() / 1.0f); 180 } 181 182 bool ParticleInterface::getKeepParticlesInLocalSpace() const 183 { 184 return this->particleSystem_->getKeepParticlesInLocalSpace(); 185 } 186 void ParticleInterface::setKeepParticlesInLocalSpace(bool keep) 187 { 188 this->particleSystem_->setKeepParticlesInLocalSpace(keep); 189 } 48 unsigned int ParticleInterface::counter_s = 0; 49 ParticleInterface* ParticleInterface::currentParticleInterface_s = 0; 50 51 ParticleInterface::ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::LOD detaillevel) 52 { 53 RegisterRootObject(ParticleInterface); 54 55 assert(scenemanager); 56 57 this->scenemanager_ = scenemanager; 58 this->sceneNode_ = 0; 59 60 this->bEnabled_ = true; 61 this->bVisible_ = true; 62 this->bAllowedByLOD_ = true; 63 64 this->particleSystem_ = this->scenemanager_->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName); 65 this->particleSystem_->setSpeedFactor(1.0f); 66 //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor()); 67 68 this->setDetailLevel((unsigned int)detaillevel); 69 } 70 71 ParticleInterface::~ParticleInterface() 72 { 73 this->particleSystem_->removeAllEmitters(); 74 this->detachFromSceneNode(); 75 this->scenemanager_->destroyParticleSystem(particleSystem_); 76 } 77 78 void ParticleInterface::addToSceneNode(Ogre::SceneNode* sceneNode) 79 { 80 if (this->sceneNode_) 81 this->detachFromSceneNode(); 82 83 this->sceneNode_ = sceneNode; 84 this->sceneNode_->attachObject(this->particleSystem_); 85 } 86 87 void ParticleInterface::detachFromSceneNode() 88 { 89 if (this->sceneNode_) 90 { 91 this->sceneNode_->detachObject(this->particleSystem_); 92 this->sceneNode_ = 0; 93 } 94 } 95 96 Ogre::ParticleEmitter* ParticleInterface::createNewEmitter() 97 { 98 if (this->particleSystem_->getNumEmitters() > 0) 99 { 100 Ogre::ParticleEmitter* newemitter = this->particleSystem_->addEmitter(this->particleSystem_->getEmitter(0)->getType()); 101 this->particleSystem_->getEmitter(0)->copyParametersTo(newemitter); 102 return newemitter; 103 } 104 else 105 return 0; 106 } 107 Ogre::ParticleEmitter* ParticleInterface::getEmitter(unsigned int emitterNr) const 108 { 109 if (emitterNr < this->particleSystem_->getNumEmitters()) 110 return this->particleSystem_->getEmitter(emitterNr); 111 else 112 return 0; 113 } 114 void ParticleInterface::removeEmitter(unsigned int emitterNr) 115 { 116 if (emitterNr < this->particleSystem_->getNumEmitters()) 117 this->particleSystem_->removeEmitter(emitterNr); 118 } 119 void ParticleInterface::removeAllEmitters() 120 { 121 this->particleSystem_->removeAllEmitters(); 122 } 123 unsigned int ParticleInterface::getNumEmitters() const 124 { 125 return this->particleSystem_->getNumEmitters(); 126 } 127 128 Ogre::ParticleAffector* ParticleInterface::addAffector(const std::string& name) 129 { 130 return this->particleSystem_->addAffector(name); 131 } 132 Ogre::ParticleAffector* ParticleInterface::getAffector(unsigned int affectorNr) const 133 { 134 if (affectorNr < this->particleSystem_->getNumAffectors()) 135 return this->particleSystem_->getAffector(affectorNr); 136 else 137 return 0; 138 } 139 void ParticleInterface::removeAffector(unsigned int affectorNr) 140 { 141 if (affectorNr < this->particleSystem_->getNumAffectors()) 142 this->particleSystem_->removeAffector(affectorNr); 143 } 144 void ParticleInterface::removeAllAffectors() 145 { 146 this->particleSystem_->removeAllAffectors(); 147 } 148 unsigned int ParticleInterface::getNumAffectors() const 149 { 150 return this->particleSystem_->getNumAffectors(); 151 } 152 153 void ParticleInterface::setEnabled(bool enable) 154 { 155 this->bEnabled_ = enable; 156 157 for (unsigned int i = 0; i < this->particleSystem_->getNumEmitters(); i++) 158 this->particleSystem_->getEmitter(i)->setEnabled(this->bEnabled_ && this->bAllowedByLOD_); 159 } 160 161 void ParticleInterface::setVisible(bool visible) 162 { 163 this->bVisible_ = visible; 164 165 this->particleSystem_->setVisible(this->bVisible_ && this->bAllowedByLOD_); 166 } 167 168 void ParticleInterface::setDetailLevel(unsigned int level) 169 { 170 this->detaillevel_ = level; 171 this->detailLevelChanged(GraphicsEngine::getInstance().getDetailLevelParticle()); 172 } 173 174 void ParticleInterface::detailLevelChanged(unsigned int newlevel) 175 { 176 if (newlevel >= (unsigned int)this->detaillevel_) 177 this->bAllowedByLOD_ = true; 178 else 179 this->bAllowedByLOD_ = false; 180 181 this->updateVisibility(); 182 } 183 184 void ParticleInterface::updateVisibility() 185 { 186 this->setEnabled(this->isEnabled()); 187 this->setVisible(this->isVisible()); 188 } 189 190 void ParticleInterface::setSpeedFactor(float factor) 191 { 192 //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor() * factor); 193 this->particleSystem_->setSpeedFactor(1.0f * factor); 194 } 195 float ParticleInterface::getSpeedFactor() const 196 { 197 //return (this->particleSystem_->getSpeedFactor() / Orxonox::getInstance().getTimeFactor()); 198 return (this->particleSystem_->getSpeedFactor() / 1.0f); 199 } 200 201 bool ParticleInterface::getKeepParticlesInLocalSpace() const 202 { 203 return this->particleSystem_->getKeepParticlesInLocalSpace(); 204 } 205 void ParticleInterface::setKeepParticlesInLocalSpace(bool keep) 206 { 207 this->particleSystem_->setKeepParticlesInLocalSpace(keep); 208 } 190 209 } -
code/trunk/src/orxonox/tools/ParticleInterface.h
r1563 r2087 21 21 * 22 22 * Author: 23 * ...23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 25 * ... … … 45 45 namespace orxonox 46 46 { 47 class _OrxonoxExport ParticleInterface : public OrxonoxClass48 {49 public:50 ParticleInterface(const std::string& templateName, LODParticle::LOD detaillevel);51 ~ParticleInterface();47 class _OrxonoxExport ParticleInterface : public OrxonoxClass 48 { 49 public: 50 ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::LOD detaillevel); 51 virtual ~ParticleInterface(); 52 52 53 inline Ogre::ParticleSystem* getParticleSystem() const54 { return this->particleSystem_; }53 inline Ogre::ParticleSystem* getParticleSystem() const 54 { return this->particleSystem_; } 55 55 56 void addToSceneNode(Ogre::SceneNode* sceneNode);57 void detachFromSceneNode();56 void addToSceneNode(Ogre::SceneNode* sceneNode); 57 void detachFromSceneNode(); 58 58 59 Ogre::ParticleEmitter* createNewEmitter();60 Ogre::ParticleEmitter* getEmitter(unsigned int emitterNr) const;61 void removeEmitter(unsigned int emitterNr);62 void removeAllEmitters();63 unsigned int getNumEmitters() const;59 Ogre::ParticleEmitter* createNewEmitter(); 60 Ogre::ParticleEmitter* getEmitter(unsigned int emitterNr) const; 61 void removeEmitter(unsigned int emitterNr); 62 void removeAllEmitters(); 63 unsigned int getNumEmitters() const; 64 64 65 Ogre::ParticleAffector* addAffector(const std::string& name);66 Ogre::ParticleAffector* getAffector(unsigned int affectorNr) const;67 void removeAffector(unsigned int affectorNr);68 void removeAllAffectors();69 unsigned int getNumAffectors() const;65 Ogre::ParticleAffector* addAffector(const std::string& name); 66 Ogre::ParticleAffector* getAffector(unsigned int affectorNr) const; 67 void removeAffector(unsigned int affectorNr); 68 void removeAllAffectors(); 69 unsigned int getNumAffectors() const; 70 70 71 float getSpeedFactor() const;72 void setSpeedFactor(float factor);73 bool getKeepParticlesInLocalSpace() const;74 void setKeepParticlesInLocalSpace(bool keep);71 float getSpeedFactor() const; 72 void setSpeedFactor(float factor); 73 bool getKeepParticlesInLocalSpace() const; 74 void setKeepParticlesInLocalSpace(bool keep); 75 75 76 void setEnabled(bool enable); 77 void detailLevelChanged(unsigned int newlevel); 76 void setEnabled(bool enable); 77 inline bool isEnabled() const 78 { return this->bEnabled_; } 78 79 79 inline void storeThisAsCurrentParticleInterface() 80 { ParticleInterface::currentParticleInterface_s = this; } 81 inline static ParticleInterface* getCurrentParticleInterface() 82 { return ParticleInterface::currentParticleInterface_s; } 80 void setVisible(bool visible); 81 inline bool isVisible() const 82 { return this->bVisible_; } 83 83 84 private:85 void updateVisibility();84 void detailLevelChanged(unsigned int newlevel); 85 void setDetailLevel(unsigned int level); 86 86 87 static ParticleInterface* currentParticleInterface_s; 88 static unsigned int counter_s; 89 Ogre::SceneNode* sceneNode_; 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) 94 }; 87 inline void storeThisAsCurrentParticleInterface() 88 { ParticleInterface::currentParticleInterface_s = this; } 89 inline static ParticleInterface* getCurrentParticleInterface() 90 { return ParticleInterface::currentParticleInterface_s; } 91 92 private: 93 void updateVisibility(); 94 95 static ParticleInterface* currentParticleInterface_s; 96 static unsigned int counter_s; 97 98 Ogre::SceneNode* sceneNode_; 99 Ogre::ParticleSystem* particleSystem_; 100 bool bVisible_; 101 bool bEnabled_; 102 bool bAllowedByLOD_; 103 unsigned int detaillevel_; //!< Detail level of this particle effect (0: off, 1: low, 2: normal, 3: high) 104 Ogre::SceneManager* scenemanager_; 105 }; 95 106 } 96 107 -
code/trunk/src/orxonox/tools/Timer.cc
r1755 r2087 92 92 this->bLoop_ = false; 93 93 this->bActive_ = false; 94 this->bKillAfterCall_ = false; 94 95 95 96 this->time_ = 0; … … 111 112 void TimerBase::run() const 112 113 { 114 bool temp = this->bKillAfterCall_; // to avoid errors with bKillAfterCall_=false and an exutors which destroy the timer 115 113 116 (*this->executor_)(); 117 118 if (temp) 119 delete this; 114 120 } 115 121 … … 136 142 { 137 143 // It's time to call the function 138 if (this->bLoop_ )144 if (this->bLoop_ && !this->bKillAfterCall_) 139 145 { 140 146 this->time_ += this->interval_; // Q: Why '+=' and not '='? A: Think about it. It's more accurate like that. Seriously. -
code/trunk/src/orxonox/tools/Timer.h
r1755 r2087 116 116 TimerBase(); 117 117 118 Executor* executor_; //!< The executor of the function that should be called when the time expires 119 120 long long interval_; //!< The time-interval in micro seconds 121 bool bLoop_; //!< If true, the function gets called every 'interval' seconds 122 bool bActive_; //!< If true, the Timer ticks and calls the function if the time's up 123 124 long long time_; //!< Internal variable, counting the time till the next function-call 118 Executor* executor_; //!< The executor of the function that should be called when the time expires 119 120 long long interval_; //!< The time-interval in micro seconds 121 bool bLoop_; //!< If true, the function gets called every 'interval' seconds 122 bool bActive_; //!< If true, the Timer ticks and calls the function if the time's up 123 bool bKillAfterCall_; //!< If true the timer gets deleted after it called the function 124 125 long long time_; //!< Internal variable, counting the time till the next function-call 125 126 }; 126 127 … … 139 140 @param exeuctor A executor of the function to call 140 141 */ 141 Timer(float interval, bool bLoop, T* object, ExecutorMember<T>* exeuctor )142 { 143 this->setTimer(interval, bLoop, object, exeuctor );142 Timer(float interval, bool bLoop, T* object, ExecutorMember<T>* exeuctor, bool bKillAfterCall = false) 143 { 144 this->setTimer(interval, bLoop, object, exeuctor, bKillAfterCall); 144 145 } 145 146 … … 151 152 @param exeuctor A executor of the function to call 152 153 */ 153 void setTimer(float interval, bool bLoop, T* object, ExecutorMember<T>* executor )154 void setTimer(float interval, bool bLoop, T* object, ExecutorMember<T>* executor, bool bKillAfterCall = false) 154 155 { 155 156 this->deleteExecutor(); … … 162 163 163 164 this->time_ = this->interval_; 165 this->bKillAfterCall_ = bKillAfterCall; 164 166 } 165 167 }; … … 177 179 @param exeuctor A executor of the function to call 178 180 */ 179 StaticTimer(float interval, bool bLoop, ExecutorStatic* executor )180 { 181 this->setTimer(interval, bLoop, executor );181 StaticTimer(float interval, bool bLoop, ExecutorStatic* executor, bool bKillAfterCall = false) 182 { 183 this->setTimer(interval, bLoop, executor, bKillAfterCall); 182 184 } 183 185 … … 189 191 @param executor A executor of the function to call 190 192 */ 191 void setTimer(float interval, bool bLoop, ExecutorStatic* executor )193 void setTimer(float interval, bool bLoop, ExecutorStatic* executor, bool bKillAfterCall = false) 192 194 { 193 195 this->deleteExecutor(); … … 199 201 200 202 this->time_ = this->interval_; 203 this->bKillAfterCall_ = bKillAfterCall; 201 204 } 202 205 };
Note: See TracChangeset
for help on using the changeset viewer.