Changeset 2161
- Timestamp:
- Nov 9, 2008, 4:28:42 AM (16 years ago)
- Location:
- code/branches/objecthierarchy/src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/core/Loader.cc
r2019 r2161 37 37 #include "Namespace.h" 38 38 #include "util/Debug.h" 39 #include "util/Exception.h" 39 40 40 41 #include "tinyxml/ticpp.h" … … 157 158 return true; 158 159 } 159 catch(ticpp::Exception& ex) 160 catch (ticpp::Exception& ex) 161 { 162 COUT(1) << std::endl; 163 COUT(1) << "An XML-error occurred in Loader.cc while loading " << file->getFilename() << ":" << std::endl; 164 COUT(1) << ex.what() << std::endl; 165 COUT(1) << "Loading aborted." << std::endl; 166 return false; 167 } 168 catch (Exception& ex) 169 { 170 COUT(1) << std::endl; 171 COUT(1) << "A loading-error occurred in Loader.cc while loading " << file->getFilename() << ":" << std::endl; 172 COUT(1) << ex.what() << std::endl; 173 COUT(1) << "Loading aborted." << std::endl; 174 return false; 175 } 176 catch (std::exception& ex) 160 177 { 161 178 COUT(1) << std::endl; 162 179 COUT(1) << "An error occurred in Loader.cc while loading " << file->getFilename() << ":" << std::endl; 163 180 COUT(1) << ex.what() << std::endl; 181 COUT(1) << "Loading aborted." << std::endl; 182 return false; 183 } 184 catch (...) 185 { 186 COUT(1) << std::endl; 187 COUT(1) << "An unknown error occurred in Loader.cc while loading " << file->getFilename() << ":" << std::endl; 164 188 COUT(1) << "Loading aborted." << std::endl; 165 189 return false; -
code/branches/objecthierarchy/src/core/XMLPort.h
r2114 r2161 44 44 45 45 #include "util/Debug.h" 46 #include "util/Exception.h" 46 47 #include "util/MultiType.h" 47 48 #include "tinyxml/ticpp.h" … … 495 496 if (this->identifierIsIncludedInLoaderMask(identifier)) 496 497 { 497 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl; 498 499 BaseObject* newObject = identifier->fabricate((BaseObject*)object); 500 assert(newObject); 501 newObject->setLoaderIndentation(((BaseObject*)object)->getLoaderIndentation() + " "); 502 503 O* castedObject = dynamic_cast<O*>(newObject); 504 assert(castedObject); 505 506 if (this->bLoadBefore_) 498 try 507 499 { 508 newObject->XMLPort(*child, XMLPort::LoadObject); 509 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl; 500 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl; 501 502 BaseObject* newObject = identifier->fabricate((BaseObject*)object); 503 assert(newObject); 504 newObject->setLoaderIndentation(((BaseObject*)object)->getLoaderIndentation() + " "); 505 506 O* castedObject = dynamic_cast<O*>(newObject); 507 assert(castedObject); 508 509 if (this->bLoadBefore_) 510 { 511 newObject->XMLPort(*child, XMLPort::LoadObject); 512 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl; 513 } 514 else 515 { 516 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl; 517 } 518 519 COUT(5) << ((BaseObject*)object)->getLoaderIndentation(); 520 (*this->loadexecutor_)(object, castedObject); 521 522 if (!this->bLoadBefore_) 523 newObject->XMLPort(*child, XMLPort::LoadObject); 524 525 COUT(5) << ((BaseObject*)object)->getLoaderIndentation() << "...fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << std::endl; 510 526 } 511 else527 catch (AbortLoadingException& ex) 512 528 { 513 COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl; 529 COUT(1) << "An error occurred while loading object, abort loading..." << std::endl; 530 throw ex; 514 531 } 515 516 COUT(5) << ((BaseObject*)object)->getLoaderIndentation(); 517 (*this->loadexecutor_)(object, castedObject); 518 519 if (!this->bLoadBefore_) 520 newObject->XMLPort(*child, XMLPort::LoadObject); 521 522 COUT(5) << ((BaseObject*)object)->getLoaderIndentation() << "...fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << std::endl; 532 catch (std::exception& ex) 533 { 534 COUT(1) << "An error occurred while loading object:" << std::endl; 535 COUT(1) << ex.what() << std::endl; 536 } 537 catch (...) 538 { 539 COUT(1) << "An unknown error occurred while loading object." << std::endl; 540 } 523 541 } 524 542 } -
code/branches/objecthierarchy/src/orxonox/gamestates/GSDedicated.cc
r2112 r2161 32 32 #include "core/CommandLine.h" 33 33 #include "core/Core.h" 34 #include "core/Iterator.h" 34 35 #include "network/Server.h" 36 #include "objects/Tickable.h" 35 37 36 38 namespace orxonox … … 73 75 server_->tick(time.getDeltaTime()); 74 76 this->tickChild(time); 77 78 /*** HACK *** HACK ***/ 79 // Call the Tickable objects 80 for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it) 81 it->tick(time.getDeltaTime()); 82 /*** HACK *** HACK ***/ 75 83 } 76 84 } -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/Billboard.cc
r2112 r2161 75 75 { 76 76 this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1); 77 this->getNode()->attachObject(this->billboard_.getBillboardSet()); 77 if (this->billboard_.getBillboardSet()) 78 this->getNode()->attachObject(this->billboard_.getBillboardSet()); 78 79 this->billboard_.setVisible(this->isVisible()); 79 80 } … … 90 91 { 91 92 this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1); 92 this->getNode()->attachObject(this->billboard_.getBillboardSet()); 93 if (this->billboard_.getBillboardSet()) 94 this->getNode()->attachObject(this->billboard_.getBillboardSet()); 93 95 this->billboard_.setVisible(this->isVisible()); 94 96 } -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/Camera.cc
r2073 r2161 38 38 #include <OgreViewport.h> 39 39 40 #include "util/Exception.h" 40 41 #include "core/CoreIncludes.h" 41 42 #include "core/ConfigValueIncludes.h" … … 51 52 RegisterObject(Camera); 52 53 53 assert(this->getScene());54 assert(this->getScene()->getSceneManager());54 if (!this->getScene() || !this->getScene()->getSceneManager()) 55 throw AbortLoadingException("Can't create Camera, no scene or no scene manager given."); 55 56 56 57 this->camera_ = this->getScene()->getSceneManager()->createCamera(getUniqueNumberString()); -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/ParticleEmitter.cc
r2114 r2161 37 37 38 38 #include "tools/ParticleInterface.h" 39 #include "util/Exception.h" 39 40 #include "core/CoreIncludes.h" 40 41 #include "core/XMLPort.h" … … 49 50 RegisterObject(ParticleEmitter); 50 51 51 assert(this->getScene());52 assert(this->getScene()->getSceneManager());52 if (!this->getScene() || !this->getScene()->getSceneManager()) 53 throw AbortLoadingException("Can't create Camera, no scene or no scene manager given."); 53 54 54 55 this->particles_ = 0; -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/WorldEntity.cc
r2112 r2161 36 36 #include "core/XMLPort.h" 37 37 #include "util/Convert.h" 38 #include "util/Exception.h" 38 39 39 40 #include "objects/Scene.h" … … 52 53 RegisterObject(WorldEntity); 53 54 54 assert(this->getScene());55 assert(this->getScene()->getRootSceneNode());55 if (!this->getScene() || !this->getScene()->getRootSceneNode()) 56 throw AbortLoadingException("Can't create WorldEntity, no scene or no root-scenenode given."); 56 57 57 58 this->node_ = this->getScene()->getRootSceneNode()->createChildSceneNode(); -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/pawns/Spectator.cc
r2155 r2161 62 62 this->greetingFlare_ = new BillboardSet(); 63 63 this->greetingFlare_->setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(1.0, 1.0, 0.8), Vector3(0, 20, 0), 1); 64 this->getNode()->attachObject(this->greetingFlare_->getBillboardSet()); 64 if (this->greetingFlare_->getBillboardSet()) 65 this->getNode()->attachObject(this->greetingFlare_->getBillboardSet()); 65 66 this->greetingFlare_->setVisible(false); 66 67 this->bGreetingFlareVisible_ = false; … … 76 77 if (this->greetingFlare_) 77 78 { 78 this->getNode()->detachObject(this->greetingFlare_->getBillboardSet()); 79 if (this->greetingFlare_->getBillboardSet()) 80 this->getNode()->detachObject(this->greetingFlare_->getBillboardSet()); 79 81 delete this->greetingFlare_; 80 82 } -
code/branches/objecthierarchy/src/orxonox/objects/worldentities/triggers/Trigger.cc
r2078 r2161 69 69 this->debugBillboard_.setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1); 70 70 this->debugBillboard_.setVisible(false); 71 } 72 73 this->getNode()->attachObject(this->debugBillboard_.getBillboardSet()); 71 72 if (this->debugBillboard_.getBillboardSet()) 73 this->getNode()->attachObject(this->debugBillboard_.getBillboardSet()); 74 } 75 74 76 this->setObjectMode(0x0); 75 77 } … … 310 312 void Trigger::setBillboardColour(const ColourValue& colour) 311 313 { 312 this->debugBillboard_. getBillboardSet()->getBillboard(0)->setColour(colour);314 this->debugBillboard_.setColour(colour); 313 315 } 314 316 -
code/branches/objecthierarchy/src/orxonox/overlays/OrxonoxOverlay.cc
r2084 r2161 40 40 #include <OgrePanelOverlayElement.h> 41 41 #include "util/Convert.h" 42 #include "util/Exception.h" 42 43 #include "util/String.h" 44 #include "core/Core.h" 43 45 #include "core/CoreIncludes.h" 44 46 #include "core/XMLPort.h" … … 58 60 { 59 61 RegisterObject(OrxonoxOverlay); 62 63 if (!Core::showsGraphics()) 64 throw NoGraphicsException("Can't create OrxonoxOverlay, graphics engine not initialized"); 60 65 61 66 // add this overlay to the static map of OrxonoxOverlays -
code/branches/objecthierarchy/src/orxonox/tools/BillboardSet.cc
r2044 r2161 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/branches/objecthierarchy/src/orxonox/tools/Mesh.cc
r2023 r2161 73 73 { 74 74 COUT(1) << "Error: Couln't load mesh \"" << meshsource << "\"" << std::endl; 75 this->entity_ = 0; 75 76 } 76 77 } -
code/branches/objecthierarchy/src/orxonox/tools/ParticleInterface.cc
r2114 r2161 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/branches/objecthierarchy/src/util/Exception.h
r2111 r2161 63 63 InitialisationFailed, 64 64 NotImplemented, 65 GameState 65 GameState, 66 NoGraphics, 67 AbortLoading 66 68 }; 67 69 … … 127 129 RETURN_EXCEPTION_CODE(NotImplemented); 128 130 RETURN_EXCEPTION_CODE(GameState); 131 RETURN_EXCEPTION_CODE(NoGraphics); 132 RETURN_EXCEPTION_CODE(AbortLoading); 129 133 default: 130 134 return ""; … … 141 145 CREATE_ORXONOX_EXCEPTION(NotImplemented); 142 146 CREATE_ORXONOX_EXCEPTION(GameState); 147 CREATE_ORXONOX_EXCEPTION(NoGraphics); 148 CREATE_ORXONOX_EXCEPTION(AbortLoading); 143 149 } 144 150
Note: See TracChangeset
for help on using the changeset viewer.