- Timestamp:
- Nov 9, 2015, 3:51:17 PM (9 years ago)
- Location:
- code/branches/explosionChunksHS15/src/orxonox/worldentities
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/explosionChunksHS15/src/orxonox/worldentities/ExplosionPart.cc
r10755 r10786 43 43 this->LOD_ = LODParticle::Normal; 44 44 this->mesh_ = ""; 45 this->effect_ = ""; 45 this->effect1_ = ""; 46 this->effect2_ = ""; 46 47 this->model_= new Model(this->getContext()); 47 this->particleInterface_= NULL; 48 this->effect1Particle_= NULL; 49 this->effect2Particle_= NULL; 48 50 this->explosionEntity_ = new MovableEntity(this->getContext()); 49 51 … … 53 55 54 56 57 ExplosionPart::~ExplosionPart() 58 { 59 if (this->isInitialized()) 60 { 61 if (this->effect1Particle_) 62 { 63 this->model_->detachOgreObject(this->effect1Particle_->getParticleSystem()); 64 delete this->effect1Particle_; 65 } 66 if (this->effect2Particle_) 67 { 68 this->model_->detachOgreObject(this->effect2Particle_->getParticleSystem()); 69 delete this->effect2Particle_; 70 } 71 } 72 } 73 74 55 75 void ExplosionPart::XMLPort(Element& xmlelement, XMLPort::Mode mode) 56 76 { 57 77 SUPER(ExplosionPart, XMLPort, xmlelement, mode); 58 78 59 XMLPortParam(ExplosionPart, "mesh", setMesh, getMesh, xmlelement, mode); 60 XMLPortParam(ExplosionPart, "effect", setEffect, getEffect, xmlelement, mode); 79 XMLPortParam(ExplosionPart, "mesh", setMesh, getMesh, xmlelement, mode).defaultValues(""); 80 XMLPortParam(ExplosionPart, "minspeed", setMinSpeed, getMinSpeed, xmlelement, mode).defaultValues(50); 81 XMLPortParam(ExplosionPart, "maxspeed", setMaxSpeed, getMaxSpeed, xmlelement, mode).defaultValues(100); 82 XMLPortParam(ExplosionPart, "effect1", setEffect1, getEffect1, xmlelement, mode).defaultValues(""); 83 XMLPortParam(ExplosionPart, "effect2", setEffect2, getEffect2, xmlelement, mode).defaultValues(""); 61 84 62 85 … … 68 91 orxout() << "Explode" << endl; 69 92 70 orxout() << getMesh() << endl;71 orxout() << getEffect() << endl;72 93 73 94 this->model_->setVisible(true); … … 77 98 //this->model_->setSyncMode(0); 78 99 79 this->particleInterface_ = new ParticleInterface(this->getScene()->getSceneManager(), effect_, this->LOD_); 100 if(effect1_ != "") 101 { 102 this->effect1Particle_ = new ParticleInterface(this->getScene()->getSceneManager(), effect1_, this->LOD_); 103 this->model_->attachOgreObject(this->effect1Particle_->getParticleSystem()); 104 } 80 105 81 this->model_->attachOgreObject(this->particleInterface_->getParticleSystem()); 106 if(effect2_ != "") 107 { 108 this->effect2Particle_ = new ParticleInterface(this->getScene()->getSceneManager(), effect2_, this->LOD_); 109 this->model_->attachOgreObject(this->effect2Particle_->getParticleSystem()); 110 } 82 111 83 84 85 this->explosionEntity_->setVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1))*rnd(50,100)); 112 this->explosionEntity_->setVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1))*rnd(minSpeed_,maxSpeed_)); 86 113 this->explosionEntity_->setAngularVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1)).normalisedCopy() * Degree(400).valueRadians()); 87 114 this->explosionEntity_->setScale(4); … … 91 118 this->attach(explosionEntity_); 92 119 120 if (GameMode::isMaster()) 121 { 122 this->destroyTimer_.setTimer(rnd(2, 3), false, createExecutor(createFunctor(&ExplosionPart::stop, this))); 123 } 124 125 } 126 127 void ExplosionPart::stop() 128 { 129 if (this->effect1Particle_) 130 this->effect1Particle_->setEnabled(false); 131 if (this->effect2Particle_) 132 this->effect2Particle_->setEnabled(false); 133 if (this->model_) 134 this->model_->setVisible(false); 135 136 if (GameMode::isMaster()) 137 { 138 this->bStop_ = true; 139 this->destroyTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&ExplosionPart::destroy, this))); 140 } 93 141 } 94 142 … … 98 146 void ExplosionPart::setMesh(const std::string& newString) 99 147 { 100 this->mesh_ = newString; 101 this->model_->setMeshSource(mesh_); 102 this->model_->setVisible(false); 103 orxout() << newString << endl; 148 if(newString != "") 149 { 150 this->mesh_ = newString; 151 this->model_->setMeshSource(mesh_); 152 this->model_->setVisible(false); 153 } 104 154 } 105 155 106 void ExplosionPart::setEffect (const std::string& newString)156 void ExplosionPart::setEffect1(const std::string& newString) 107 157 { 108 this->effect_ = newString; 158 this->effect1_ = newString; 159 } 160 161 void ExplosionPart::setEffect2(const std::string& newString) 162 { 163 this->effect2_ = newString; 164 } 165 166 void ExplosionPart::setMinSpeed(float speed) 167 { 168 this->minSpeed_ = speed; 169 } 170 171 void ExplosionPart::setMaxSpeed(float speed) 172 { 173 this->maxSpeed_ = speed; 109 174 } 110 175 … … 112 177 { return this->mesh_; } 113 178 114 std::string& ExplosionPart::getEffect() 115 { return this->effect_; } 179 std::string& ExplosionPart::getEffect1() 180 { return this->effect1_; } 181 182 std::string& ExplosionPart::getEffect2() 183 { return this->effect2_; } 184 185 float ExplosionPart::getMinSpeed() 186 { 187 return this->minSpeed_; 188 } 189 190 float ExplosionPart::getMaxSpeed() 191 { 192 return this->maxSpeed_; 193 } 194 116 195 117 196 -
code/branches/explosionChunksHS15/src/orxonox/worldentities/ExplosionPart.h
r10752 r10786 41 41 #include "core/command/Executor.h" 42 42 #include "Scene.h" 43 #include "tools/Timer.h" 43 44 44 45 … … 49 50 public: 50 51 ExplosionPart(Context* context); 52 ~ExplosionPart(); 51 53 void XMLPort(Element& xmlelement, XMLPort::Mode mode); 52 54 void Explode(); 55 void stop(); 53 56 54 57 void setMesh(const std::string& newString); 55 58 std::string& getMesh(); 56 void setEffect(const std::string& newString); 57 std::string& getEffect(); 59 void setEffect1(const std::string& newString); 60 std::string& getEffect1(); 61 void setEffect2(const std::string& newString); 62 std::string& getEffect2(); 63 void setMinSpeed(float speed); 64 float getMinSpeed(); 65 void setMaxSpeed(float speed); 66 float getMaxSpeed(); 58 67 59 68 … … 65 74 66 75 Model* model_; 67 ParticleInterface* particleInterface_; 76 ParticleInterface* effect1Particle_; 77 ParticleInterface* effect2Particle_; 68 78 79 80 float minSpeed_; 81 float maxSpeed_; 69 82 std::string mesh_; 70 std::string effect_; 83 std::string effect1_; 84 std::string effect2_; 71 85 72 86 MovableEntity* explosionEntity_; 87 88 Timer destroyTimer_; 73 89 74 90 -
code/branches/explosionChunksHS15/src/orxonox/worldentities/pawns/Pawn.cc
r10755 r10786 374 374 if (GameMode::isMaster()) 375 375 { 376 this->deatheffect();376 //this->deatheffect(); 377 377 this->goWithStyle(); 378 378 }
Note: See TracChangeset
for help on using the changeset viewer.