Changeset 7339 in orxonox.OLD for trunk/src/world_entities/space_ships
- Timestamp:
- Apr 19, 2006, 2:11:14 AM (19 years ago)
- Location:
- trunk/src/world_entities/space_ships
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/space_ships/turbine_hover.cc
r7337 r7339 46 46 47 47 /** 48 * loads a TurbineHover information from a specified file.48 * @brief loads a TurbineHover information from a specified file. 49 49 * @param fileName the name of the File to load the turbine_hover from (absolute path) 50 50 */ … … 64 64 65 65 /** 66 * creates a new Spaceship from Xml Data66 * @brief creates a new Spaceship from Xml Data 67 67 * @param root the xml element containing spaceship data 68 68 … … 96 96 97 97 /** 98 * initializes a TurbineHover98 * @brief initializes a TurbineHover 99 99 */ 100 100 void TurbineHover::init() … … 102 102 // this->setRelDir(Quaternion(M_PI, Vector(1,0,0))); 103 103 this->setClassID(CL_TURBINE_HOVER, "TurbineHover"); 104 105 this->setSupportedPlaymodes(Playable::Full3D | Playable::Horizontal); 104 106 105 107 this->loadModel("models/ships/hoverglider_wing.obj", 1.0f, 3); … … 275 277 void TurbineHover::tick (float dt) 276 278 { 277 // this->debugNode(1);279 // this->debugNode(1); 278 280 Playable::tick(dt); 279 281 … … 324 326 } 325 327 326 Vector accelerationDir = this->getAbsDir().apply(accel * this->acceleration); 327 328 // this is the air friction (necessary for a smooth control) 329 Vector damping = (this->velocity * this->airFriction); 330 331 332 this->velocity += (accelerationDir - damping)* dt; 333 this->shiftCoor (this->velocity * dt); 334 335 // limit the maximum rotation speed. 336 if (this->rotation != 0.0f) 337 { 338 float maxRot = 10.0 * dt; 339 if (unlikely(this->rotation > maxRot)) this->rotation = maxRot; 340 if (unlikely(this->rotation < -maxRot)) this->rotation = -maxRot; 341 this->direction *= Quaternion(-M_PI/4.0*this->rotation, Vector(0,1,0)); 342 343 this->rotation = 0.0f; 344 } 345 346 this->setRelDirSoft(this->direction * Quaternion(-cameraLook, Vector(0,0,1)), 5); 347 348 this->wingNodeLeft.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5); 349 this->rotorNodeLeft.setRelDirSoft(Quaternion(-accel.x * .07+this->rotation + cameraLook, Vector(0,0,1)), 5); 350 351 this->wingNodeRight.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5); 352 this->rotorNodeRight.setRelDirSoft(Quaternion(-accel.x*.07 -this->rotation + cameraLook, Vector(0,0,1)), 5); 328 switch(this->getPlaymode()) 329 { 330 case Playable::Full3D: 331 { 332 Vector accelerationDir = this->getAbsDir().apply(accel * this->acceleration); 333 334 // this is the air friction (necessary for a smooth control) 335 Vector damping = (this->velocity * this->airFriction); 336 337 338 this->velocity += (accelerationDir - damping)* dt; 339 this->shiftCoor (this->velocity * dt); 340 341 // limit the maximum rotation speed. 342 if (this->rotation != 0.0f) 343 { 344 float maxRot = 10.0 * dt; 345 if (unlikely(this->rotation > maxRot)) this->rotation = maxRot; 346 if (unlikely(this->rotation < -maxRot)) this->rotation = -maxRot; 347 this->direction *= Quaternion(-M_PI/4.0*this->rotation, Vector(0,1,0)); 348 349 this->rotation = 0.0f; 350 } 351 352 this->setRelDirSoft(this->direction * Quaternion(-cameraLook, Vector(0,0,1)), 5); 353 354 this->wingNodeLeft.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5); 355 this->rotorNodeLeft.setRelDirSoft(Quaternion(-accel.x * .07+this->rotation + cameraLook, Vector(0,0,1)), 5); 356 357 this->wingNodeRight.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5); 358 this->rotorNodeRight.setRelDirSoft(Quaternion(-accel.x*.07 -this->rotation + cameraLook, Vector(0,0,1)), 5); 359 } 360 break; 361 362 case Playable::Horizontal: 363 { 364 accel.z = 0.0; 365 Vector accelerationDir = this->getAbsDir().apply(accel * this->acceleration); 366 accelerationDir.z = 0.0; 367 368 // this is the air friction (necessary for a smooth control) 369 Vector damping = (this->velocity * this->airFriction); 370 371 372 this->velocity += (accelerationDir - damping)* dt; 373 this->shiftCoor (this->velocity * dt); 374 375 // limit the maximum rotation speed. 376 if (this->rotation != 0.0f) 377 { 378 float maxRot = 10.0 * dt; 379 if (unlikely(this->rotation > maxRot)) this->rotation = maxRot; 380 if (unlikely(this->rotation < -maxRot)) this->rotation = -maxRot; 381 this->direction *= Quaternion(-M_PI/4.0*this->rotation, Vector(0,1,0)); 382 383 this->rotation = 0.0f; 384 } 385 386 this->setRelDirSoft(this->direction, 5); 387 388 this->wingNodeLeft.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5); 389 this->rotorNodeLeft.setRelDirSoft(Quaternion(-accel.x * .07+this->rotation, Vector(0,0,1)), 5); 390 391 this->wingNodeRight.setRelDirSoft(Quaternion(accel.z * .05 +this->rotation, Vector(1,0,0)), 5); 392 this->rotorNodeRight.setRelDirSoft(Quaternion(-accel.x*.07 -this->rotation, Vector(0,0,1)), 5); 393 } 394 break; 395 } 353 396 } 354 397 -
trunk/src/world_entities/space_ships/turbine_hover.h
r7337 r7339 17 17 { 18 18 public: 19 20 19 TurbineHover(const std::string& fileName); 21 20 TurbineHover(const TiXmlElement* root = NULL);
Note: See TracChangeset
for help on using the changeset viewer.