Changeset 8490 for code/branches/gameimmersion/src/orxonox/worldentities
- Timestamp:
- May 16, 2011, 3:52:31 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
r8427 r8490 38 38 #include "graphics/Camera.h" 39 39 #include "CameraManager.h" 40 #include "util/Math.h" 40 41 41 42 namespace orxonox … … 82 83 this->cameraOriginalOrientation = c->getOrientation(); 83 84 84 this->shakeFrequency_ = 50;85 this->shakeAmplitude_ = 40;85 this->shakeFrequency_ = 15; 86 this->shakeAmplitude_ = 5; 86 87 this->shakeDt_ = 0; 87 88 } … … 117 118 registerVariable(this->boostRate_, VariableDirection::ToClient); 118 119 registerVariable(this->boostCooldownDuration_, VariableDirection::ToClient); 120 registerVariable(this->shakeFrequency_, VariableDirection::ToClient); 119 121 } 120 122 … … 179 181 180 182 } 181 if (this->getVelocity().squaredLength() > 20) 182 { 183 this->shakeDt_ += dt; 184 185 Camera* c = this->getCamera(); 186 187 this->shakeFrequency_ = this->getVelocity().squaredLength() / 10000; 188 189 COUT(0) << "ShakeFrequency: " << this->shakeFrequency_ << std::endl; 190 191 //Shaking Camera effect 192 if (c != 0) 193 { 194 c->setAngularVelocity(Vector3(shakeFrequency_,0 , 0)); 195 196 //if (c->getAngularVelocity() == Vector3(0,0,0)) 197 //{ 198 // c->setAngularVelocity(Vector3(2,0,0)); 199 200 //set the delta to half the period time, 201 //so the camera shakes up and down. 202 // this->shakeDt_ = 1/(2 * this->shakeFrequency_); 203 //} 204 205 206 //toggle the rotation 207 if (1/(this->shakeFrequency_) <= shakeDt_) 208 { 209 c->setAngularVelocity(-c->getAngularVelocity()); 210 shakeDt_ = 0; 211 } 212 } 213 } 183 184 shakeCamera(dt); 214 185 } 215 186 } 187 } 188 189 void SpaceShip::shakeCamera(float dt) 190 { 191 if (this->getVelocity().squaredLength() > 80) 192 { 193 this->shakeDt_ += dt; 194 195 int frequency = this->shakeFrequency_ * (this->getVelocity().squaredLength()); 196 197 if (this->shakeDt_ >= 1 /(frequency)) 198 { 199 this->shakeDt_ -= 1/(frequency); 200 } 201 202 Degree angle = Degree(sin(this->shakeDt_ * 2* math::pi * frequency) * this->shakeAmplitude_); 203 204 // COUT(0) << "Angle: " << angle << std::endl; 205 Camera* c = this->getCamera(); 206 207 //Shaking Camera effect 208 if (c != 0) 209 { 210 c->setOrientation(Vector3::UNIT_X, angle); 211 } 212 } 216 213 } 217 214 … … 274 271 { 275 272 if(bBoost && !this->bBoostCooldown_) 273 { 274 // COUT(0) << "Boost startet!\n"; 276 275 this->bBoost_ = true; 276 } 277 277 if(!bBoost) 278 278 { 279 // COUT(0) << "Boost stoppt\n"; 279 280 this->resetCamera(); 280 281 this->bBoost_ = false; … … 327 328 void SpaceShip::resetCamera() 328 329 { 329 //COUT(0) << "Resetting camera\n"; 330 331 // COUT(0) << "Resetting camera\n"; 330 332 Camera *c = this->getCamera(); 331 333 … … 337 339 338 340 shakeDt_ = 0; 339 340 c->setAngularVelocity(Vector3(0,0,0)); 341 // 341 342 c->setPosition(this->cameraOriginalPosition); 342 343 c->setOrientation(this->cameraOriginalOrientation); -
code/branches/gameimmersion/src/orxonox/worldentities/pawns/SpaceShip.h
r8379 r8490 109 109 110 110 void resetCamera(); 111 void shakeCamera(float dt); 111 112 112 113 std::string enginetemplate_;
Note: See TracChangeset
for help on using the changeset viewer.