Changeset 10837 for code/branches/explosionChunksHS15/src
- Timestamp:
- Nov 23, 2015, 3:46:58 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
r10810 r10837 84 84 XMLPortParam(ExplosionPart, "effect2", setEffect2, getEffect2, xmlelement, mode).defaultValues(""); 85 85 XMLPortParam(ExplosionPart, "offset", setOffset, getOffset, xmlelement, mode).defaultValues(Vector3::ZERO); 86 87 86 XMLPortParam(ExplosionPart, "direction", setDirection, getDirection, xmlelement, mode).defaultValues(Vector3(1,1,1)); 87 XMLPortParam(ExplosionPart, "angle", setAngle, getAngle, xmlelement, mode).defaultValues(180); 88 XMLPortParam(ExplosionPart, "size", setSize, getSize, xmlelement, mode).defaultValues(4); 89 XMLPortParam(ExplosionPart, "delay", setDelay, getDelay, xmlelement, mode).defaultValues(0); 88 90 } 89 91 … … 91 93 void ExplosionPart::Explode() 92 94 { 93 orxout() << "Explode" << endl; 94 95 96 97 this->model_->setVisible(true); 98 99 //this->explosionEntity_->setSyncMode(0); 100 101 //this->model_->setSyncMode(0); 102 103 if(effect1_ != "") 104 { 105 this->effect1Particle_ = new ParticleInterface(this->getScene()->getSceneManager(), effect1_, this->LOD_); 106 this->model_->attachOgreObject(this->effect1Particle_->getParticleSystem()); 107 } 108 109 if(effect2_ != "") 110 { 111 this->effect2Particle_ = new ParticleInterface(this->getScene()->getSceneManager(), effect2_, this->LOD_); 112 this->model_->attachOgreObject(this->effect2Particle_->getParticleSystem()); 113 } 114 115 this->explosionEntity_->setVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1))*rnd(minSpeed_,maxSpeed_)); 116 this->explosionEntity_->setAngularVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1)).normalisedCopy() * Degree(400).valueRadians()); 117 this->explosionEntity_->setScale(4); 118 119 this->explosionEntity_->attach(model_); 120 121 this->attach(explosionEntity_); 122 123 if (GameMode::isMaster()) 124 { 125 this->destroyTimer_.setTimer(rnd(2, 4), false, createExecutor(createFunctor(&ExplosionPart::stop, this))); 126 } 127 95 this->destroyTimer_.setTimer(delay_, false, createExecutor(createFunctor(&ExplosionPart::ActuallyExplode, this))); 128 96 } 129 97 … … 144 112 } 145 113 114 void ExplosionPart::ActuallyExplode() 115 { 116 this->model_->setVisible(true); 117 118 //this->explosionEntity_->setSyncMode(0); 119 120 //this->model_->setSyncMode(0); 121 122 if(effect1_ != "") 123 { 124 this->effect1Particle_ = new ParticleInterface(this->getScene()->getSceneManager(), effect1_, this->LOD_); 125 this->model_->attachOgreObject(this->effect1Particle_->getParticleSystem()); 126 } 127 128 if(effect2_ != "") 129 { 130 this->effect2Particle_ = new ParticleInterface(this->getScene()->getSceneManager(), effect2_, this->LOD_); 131 this->model_->attachOgreObject(this->effect2Particle_->getParticleSystem()); 132 } 133 134 135 Vector3 velocityOffset = direction_.perpendicular(); 136 velocityOffset.normalise(); 137 Degree offsetDirection = Degree(rnd(0,360)); 138 velocityOffset = Quaternion(offsetDirection, direction_.normalisedCopy()) * velocityOffset; 139 velocityOffset.normalise(); 140 direction_.normalise(); 141 142 Vector3 finalDirection = direction_ + sin((rnd(0, angle_))*M_PI/180)*velocityOffset; 143 144 this->explosionEntity_->setVelocity(finalDirection*rnd(minSpeed_,maxSpeed_)); 145 this->explosionEntity_->setAngularVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1)).normalisedCopy() * Degree(400).valueRadians()); 146 this->explosionEntity_->setScale(size_); 147 148 this->explosionEntity_->attach(model_); 149 150 this->attach(explosionEntity_); 151 152 if (GameMode::isMaster()) 153 { 154 this->destroyTimer_.setTimer(rnd(2, 4), false, createExecutor(createFunctor(&ExplosionPart::stop, this))); 155 } 156 } 157 146 158 147 159 … … 180 192 { 181 193 this->posOffset_ = newVector; 182 this->setPosition(this->getPosition() + this->posOffset_); 194 this->explosionEntity_->setPosition(this->getPosition() + this->posOffset_); 195 } 196 197 void ExplosionPart::setDirection(Vector3 newDirection) 198 { 199 this->direction_ = newDirection; 200 } 201 202 void ExplosionPart::setAngle(float newAngle) 203 { 204 this->angle_ = newAngle; 205 } 206 207 void ExplosionPart::setSize(float newSize) 208 { 209 this->size_ = newSize; 210 } 211 212 void ExplosionPart::setDelay(float newDelay) 213 { 214 this->delay_ = newDelay; 183 215 } 184 216 … … 207 239 } 208 240 241 Vector3 ExplosionPart::getDirection() 242 { 243 return direction_; 244 } 245 246 float ExplosionPart::getAngle() 247 { 248 return angle_; 249 } 250 251 float ExplosionPart::getSize() 252 { 253 return size_; 254 } 255 256 float ExplosionPart::getDelay() 257 { 258 return delay_; 259 } 260 209 261 210 262 -
code/branches/explosionChunksHS15/src/orxonox/worldentities/ExplosionPart.h
r10810 r10837 54 54 void Explode(); 55 55 void stop(); 56 void ActuallyExplode(); 56 57 57 58 void setMesh(const std::string& newString); … … 67 68 void setOffset(Vector3 newVector); 68 69 Vector3 getOffset(); 70 void setDirection(Vector3 newDirection); 71 Vector3 getDirection(); 72 void setAngle(float newAgnle); 73 float getAngle(); 74 void setSize(float newSize); 75 float getSize(); 76 void setDelay(float newDelay); 77 float getDelay(); 69 78 70 79 … … 86 95 std::string effect2_; 87 96 Vector3 posOffset_; 97 Vector3 direction_; 98 float angle_; 99 float size_; 100 float delay_; 88 101 89 102 MovableEntity* explosionEntity_; -
code/branches/explosionChunksHS15/src/orxonox/worldentities/pawns/Pawn.cc
r10810 r10837 390 390 explosionPartList_.back()->setPosition(this->getPosition()); 391 391 explosionPartList_.back()->setVelocity(this->getVelocity()); 392 explosionPartList_.back()->setOrientation(this->getOrientation()); 392 393 explosionPartList_.back()->Explode(); 393 394 explosionPartList_.pop_back();
Note: See TracChangeset
for help on using the changeset viewer.