Changeset 2171 for code/trunk/src/orxonox/tools
- Timestamp:
- Nov 10, 2008, 12:05:03 AM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/objecthierarchy merged: 2111-2115,2123,2132-2134,2143-2144,2153-2158,2160-2169
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/tools/BillboardSet.cc
r2087 r2171 36 36 #include <OgreBillboard.h> 37 37 38 #include "core/Core.h" 38 39 #include "util/Convert.h" 39 40 #include "util/String.h" … … 70 71 try 71 72 { 72 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count); 73 this->billboardSet_->createBillboard(position); 74 this->billboardSet_->setMaterialName(file); 73 if (Core::showsGraphics()) 74 { 75 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count); 76 this->billboardSet_->createBillboard(position); 77 this->billboardSet_->setMaterialName(file); 78 } 75 79 } 76 80 catch (...) 77 81 { 78 82 COUT(1) << "Error: Couln't load billboard \"" << file << "\"" << std::endl; 83 this->billboardSet_ = 0; 79 84 } 80 85 … … 89 94 try 90 95 { 91 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count); 92 this->billboardSet_->createBillboard(position, colour); 93 this->billboardSet_->setMaterialName(file); 96 if (Core::showsGraphics()) 97 { 98 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count); 99 this->billboardSet_->createBillboard(position, colour); 100 this->billboardSet_->setMaterialName(file); 101 } 94 102 } 95 103 catch (...) 96 104 { 97 105 COUT(1) << "Error: Couln't load billboard \"" << file << "\"" << std::endl; 106 this->billboardSet_ = 0; 98 107 } 99 108 … … 105 114 if (this->billboardSet_ && this->scenemanager_) 106 115 this->scenemanager_->destroyBillboardSet(this->billboardSet_); 116 this->billboardSet_ = 0; 107 117 } 108 118 -
code/trunk/src/orxonox/tools/Mesh.cc
r2087 r2171 73 73 { 74 74 COUT(1) << "Error: Couln't load mesh \"" << meshsource << "\"" << std::endl; 75 this->entity_ = 0; 75 76 } 76 77 } -
code/trunk/src/orxonox/tools/ParticleInterface.cc
r2087 r2171 28 28 29 29 /** 30 * @file ParticleInterface.cc30 * @file 31 31 * @brief class to control praticle effects 32 32 */ … … 41 41 42 42 #include "GraphicsEngine.h" 43 #include "core/Core.h" 43 44 #include "core/CoreIncludes.h" 44 45 #include "util/Convert.h" … … 57 58 this->scenemanager_ = scenemanager; 58 59 this->sceneNode_ = 0; 60 this->particleSystem_ = 0; 59 61 60 62 this->bEnabled_ = true; … … 62 64 this->bAllowedByLOD_ = true; 63 65 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()); 66 if (Core::showsGraphics()) 67 { 68 try 69 { 70 this->particleSystem_ = this->scenemanager_->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName); 71 this->particleSystem_->setSpeedFactor(1.0f); 72 // this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor()); 73 } 74 catch (...) 75 { 76 COUT(1) << "Error: Couln't load particle system \"" << templateName << "\"" << std::endl; 77 this->particleSystem_ = 0; 78 } 79 } 67 80 68 81 this->setDetailLevel((unsigned int)detaillevel); … … 71 84 ParticleInterface::~ParticleInterface() 72 85 { 73 this->particleSystem_->removeAllEmitters(); 74 this->detachFromSceneNode(); 75 this->scenemanager_->destroyParticleSystem(particleSystem_); 86 if (this->particleSystem_) 87 { 88 this->particleSystem_->removeAllEmitters(); 89 this->detachFromSceneNode(); 90 this->scenemanager_->destroyParticleSystem(this->particleSystem_); 91 } 76 92 } 77 93 … … 81 97 this->detachFromSceneNode(); 82 98 83 this->sceneNode_ = sceneNode; 84 this->sceneNode_->attachObject(this->particleSystem_); 99 if (this->particleSystem_) 100 { 101 this->sceneNode_ = sceneNode; 102 this->sceneNode_->attachObject(this->particleSystem_); 103 } 85 104 } 86 105 … … 89 108 if (this->sceneNode_) 90 109 { 91 this->sceneNode_->detachObject(this->particleSystem_); 110 if (this->particleSystem_) 111 this->sceneNode_->detachObject(this->particleSystem_); 92 112 this->sceneNode_ = 0; 93 113 } … … 96 116 Ogre::ParticleEmitter* ParticleInterface::createNewEmitter() 97 117 { 98 if (this->particleSystem_ ->getNumEmitters() > 0)118 if (this->particleSystem_ && this->particleSystem_->getNumEmitters() > 0) 99 119 { 100 120 Ogre::ParticleEmitter* newemitter = this->particleSystem_->addEmitter(this->particleSystem_->getEmitter(0)->getType()); … … 107 127 Ogre::ParticleEmitter* ParticleInterface::getEmitter(unsigned int emitterNr) const 108 128 { 109 if ( emitterNr < this->particleSystem_->getNumEmitters())129 if (this->particleSystem_ && (emitterNr < this->particleSystem_->getNumEmitters())) 110 130 return this->particleSystem_->getEmitter(emitterNr); 111 131 else … … 114 134 void ParticleInterface::removeEmitter(unsigned int emitterNr) 115 135 { 116 if ( emitterNr < this->particleSystem_->getNumEmitters())136 if (this->particleSystem_ && (emitterNr < this->particleSystem_->getNumEmitters())) 117 137 this->particleSystem_->removeEmitter(emitterNr); 118 138 } 119 139 void ParticleInterface::removeAllEmitters() 120 140 { 121 this->particleSystem_->removeAllEmitters(); 141 if (this->particleSystem_) 142 this->particleSystem_->removeAllEmitters(); 122 143 } 123 144 unsigned int ParticleInterface::getNumEmitters() const 124 145 { 125 return this->particleSystem_->getNumEmitters(); 146 if (this->particleSystem_) 147 return this->particleSystem_->getNumEmitters(); 148 else 149 return 0; 126 150 } 127 151 128 152 Ogre::ParticleAffector* ParticleInterface::addAffector(const std::string& name) 129 153 { 130 return this->particleSystem_->addAffector(name); 154 if (this->particleSystem_) 155 return this->particleSystem_->addAffector(name); 156 else 157 return 0; 131 158 } 132 159 Ogre::ParticleAffector* ParticleInterface::getAffector(unsigned int affectorNr) const 133 160 { 134 if ( affectorNr < this->particleSystem_->getNumAffectors())161 if (this->particleSystem_ && (affectorNr < this->particleSystem_->getNumAffectors())) 135 162 return this->particleSystem_->getAffector(affectorNr); 136 163 else … … 139 166 void ParticleInterface::removeAffector(unsigned int affectorNr) 140 167 { 141 if ( affectorNr < this->particleSystem_->getNumAffectors())168 if (this->particleSystem_ && (affectorNr < this->particleSystem_->getNumAffectors())) 142 169 this->particleSystem_->removeAffector(affectorNr); 143 170 } 144 171 void ParticleInterface::removeAllAffectors() 145 172 { 146 this->particleSystem_->removeAllAffectors(); 173 if (this->particleSystem_) 174 this->particleSystem_->removeAllAffectors(); 147 175 } 148 176 unsigned int ParticleInterface::getNumAffectors() const 149 177 { 150 return this->particleSystem_->getNumAffectors(); 178 if (this->particleSystem_) 179 return this->particleSystem_->getNumAffectors(); 180 else 181 return 0; 151 182 } 152 183 … … 155 186 this->bEnabled_ = enable; 156 187 157 for (unsigned int i = 0; i < this->particleSystem_->getNumEmitters(); i++) 158 this->particleSystem_->getEmitter(i)->setEnabled(this->bEnabled_ && this->bAllowedByLOD_); 188 if (this->particleSystem_) 189 for (unsigned int i = 0; i < this->particleSystem_->getNumEmitters(); i++) 190 this->particleSystem_->getEmitter(i)->setEnabled(this->bEnabled_ && this->bAllowedByLOD_); 159 191 } 160 192 … … 163 195 this->bVisible_ = visible; 164 196 165 this->particleSystem_->setVisible(this->bVisible_ && this->bAllowedByLOD_); 197 if (this->particleSystem_) 198 this->particleSystem_->setVisible(this->bVisible_ && this->bAllowedByLOD_); 166 199 } 167 200 … … 169 202 { 170 203 this->detaillevel_ = level; 171 this->detailLevelChanged(GraphicsEngine::getInstance().getDetailLevelParticle()); 204 if (GraphicsEngine::getInstancePtr()) 205 this->detailLevelChanged(GraphicsEngine::getInstance().getDetailLevelParticle()); 172 206 } 173 207 … … 190 224 void ParticleInterface::setSpeedFactor(float factor) 191 225 { 192 //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor() * factor); 193 this->particleSystem_->setSpeedFactor(1.0f * factor); 226 if (this->particleSystem_) 227 { 228 // this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor() * factor); 229 this->particleSystem_->setSpeedFactor(1.0f * factor); 230 } 194 231 } 195 232 float ParticleInterface::getSpeedFactor() const 196 233 { 197 //return (this->particleSystem_->getSpeedFactor() / Orxonox::getInstance().getTimeFactor()); 198 return (this->particleSystem_->getSpeedFactor() / 1.0f); 234 if (this->particleSystem_) 235 { 236 // return (this->particleSystem_->getSpeedFactor() / Orxonox::getInstance().getTimeFactor()); 237 return (this->particleSystem_->getSpeedFactor() / 1.0f); 238 } 239 else 240 return 1.0f; 199 241 } 200 242 201 243 bool ParticleInterface::getKeepParticlesInLocalSpace() const 202 244 { 203 return this->particleSystem_->getKeepParticlesInLocalSpace(); 245 if (this->particleSystem_) 246 return this->particleSystem_->getKeepParticlesInLocalSpace(); 247 else 248 return false; 204 249 } 205 250 void ParticleInterface::setKeepParticlesInLocalSpace(bool keep) 206 251 { 207 this->particleSystem_->setKeepParticlesInLocalSpace(keep); 252 if (this->particleSystem_) 253 this->particleSystem_->setKeepParticlesInLocalSpace(keep); 208 254 } 209 255 } -
code/trunk/src/orxonox/tools/Timer.h
r2087 r2171 28 28 29 29 /*! 30 @file Timer.h30 @file 31 31 @brief Definition and Implementation of the Timer class. 32 32
Note: See TracChangeset
for help on using the changeset viewer.