Changeset 8254 for code/branches
- Timestamp:
- Apr 18, 2011, 4:04:40 PM (14 years ago)
- Location:
- code/branches/gameimmersion/src/orxonox/worldentities/pawns
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gameimmersion/src/orxonox/worldentities/pawns/SpaceShip.cc
r8191 r8254 83 83 this->cameraOriginalOrientation = c->getOrientation(); 84 84 85 this->shakeFrequency_ = 100;85 this->shakeFrequency_ = 20; 86 86 this->shakeAmplitude_ = 40; 87 this->shakeD eltaTime_ = 0;87 this->shakeDt_ = 0; 88 88 } 89 89 … … 106 106 XMLPortParamVariable(SpaceShip, "boostRate", boostRate_, xmlelement, mode); 107 107 XMLPortParamVariable(SpaceShip, "boostCooldownDuration", boostCooldownDuration_, xmlelement, mode); 108 XMLPortParamVariable(SpaceShip, "shakeFrequency", shakeFrequency_, xmlelement, mode); 108 109 } 109 110 … … 161 162 } 162 163 163 Camera* c = CameraManager::getInstance().getActiveCamera(); 164 165 Camera* c = this->getCamera(); 164 166 if(this->bBoost_) 165 167 { … … 174 176 else 175 177 { 176 this->shakeD eltaTime_ += dt;178 this->shakeDt_ += dt; 177 179 178 180 //Shaking Camera effect … … 183 185 { 184 186 c->setAngularVelocity(Vector3(2,0,0)); 185 this->shakeDeltaTime_ = 0; 187 188 //set the delta to half the period time, 189 //so the camera shakes up and down. 190 this->shakeDt_ = 1/(2 * this->shakeFrequency_); 186 191 } 187 192 188 193 189 194 //toggle the rotation 190 if (1/(this->shakeFrequency_) <= shakeD eltaTime_)195 if (1/(this->shakeFrequency_) <= shakeDt_) 191 196 { 192 197 c->setAngularVelocity(-c->getAngularVelocity()); 193 shakeD eltaTime_ = 0;198 shakeDt_ = 0; 194 199 } 195 196 197 /*198 COUT(1) << "Time since change: " << shakeDeltaTime_ << std::endl;199 COUT(1) << "Rotation Rate: " << c->getRotationRate() << std::endl;200 COUT(1) << "Angular Velocity: " << c->getAngularVelocity().length();201 COUT(1) << std::endl;202 */203 200 } 204 201 } … … 208 205 //reset the camera, if the boost is not active 209 206 //TODO: don't call this every tick 210 c->setAngularVelocity(Vector3(0,0,0)); 211 c->setPosition(this->cameraOriginalPosition); 212 c->setOrientation(this->cameraOriginalOrientation); 207 this->resetCamera(); 213 208 } 214 209 } … … 325 320 return list; 326 321 } 322 323 void SpaceShip::resetCamera() 324 { 325 Camera *c = this->getCamera(); 326 327 assert(c != 0); 328 329 c->setAngularVelocity(Vector3(0,0,0)); 330 c->setPosition(this->cameraOriginalPosition); 331 c->setOrientation(this->cameraOriginalOrientation); 332 } 327 333 } -
code/branches/gameimmersion/src/orxonox/worldentities/pawns/SpaceShip.h
r8191 r8254 106 106 float shakeFrequency_; 107 107 float shakeAmplitude_; 108 float shakeDeltaTime_;109 108 110 109 private: … … 115 114 116 115 void boostCooledDown(void); 116 117 void resetCamera(); 117 118 118 119 std::string enginetemplate_; … … 121 122 Vector3 cameraOriginalPosition; 122 123 Quaternion cameraOriginalOrientation; 124 125 float shakeDt_; 123 126 }; 124 127 }
Note: See TracChangeset
for help on using the changeset viewer.