Changeset 7339 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Apr 19, 2006, 2:11:14 AM (19 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/playable.cc
r7338 r7339 128 128 * @returns true on success, false otherwise 129 129 */ 130 bool Playable::setPlay Mode(Playable::Playmode playmode)130 bool Playable::setPlaymode(Playable::Playmode playmode) 131 131 { 132 132 if (!this->playmodeSupported(playmode)) … … 302 302 303 303 /** 304 * remove an event to the event list this Playable can capture.304 * @brief remove an event to the event list this Playable can capture. 305 305 * @param event the event to unregister. 306 306 */ … … 431 431 return flags!=oldFlags; 432 432 } 433 434 435 Playable::Playmode Playable::stringToPlaymode(const std::string& playmode) 436 { 437 if (playmode == "Vertical") 438 return Playable::Vertical; 439 if (playmode == "Horizontal") 440 return Playable::Horizontal; 441 if (playmode == "FromBehind") 442 return Playable::FromBehind; 443 if (playmode == "Full3D") 444 return Playable::Full3D; 445 446 return Playable::Full3D; 447 } 448 449 const char* Playable::playmodeToString(Playable::Playmode playmode) 450 { 451 switch(playmode) 452 { 453 case Playable::Vertical: 454 return "Vertical"; 455 case Playable::Horizontal: 456 return "Horizontal"; 457 case Playable::FromBehind: 458 return "FromBehind"; 459 case Playable::Full3D: 460 return "Full3D"; 461 462 default: 463 return "Full3D"; 464 } 465 466 } -
trunk/src/world_entities/playable.h
r7338 r7339 61 61 virtual void setCameraMode(unsigned int cameraMode = 0); 62 62 bool playmodeSupported(Playable::Playmode playmode) const { return this->supportedPlaymodes & playmode; }; 63 bool setPlayMode(Playable::Playmode playmode); 63 bool setPlaymode(Playable::Playmode playmode); 64 Playable::Playmode getPlaymode() const { return this->playmode; }; 64 65 65 66 virtual void collidesWith(WorldEntity* entity, const Vector& location); … … 83 84 inline int getScore() { return this->score; } 84 85 86 87 // Transformations: 88 static Playable::Playmode stringToPlaymode(const std::string& playmode); 89 static const char* playmodeToString(Playable::Playmode playmode); 85 90 protected: 86 91 Playable(); -
trunk/src/world_entities/player.h
r6986 r7339 29 29 30 30 bool setPlayable(Playable* controllalble); 31 bool eject(); 31 32 inline Playable* getPlayable() const { return this->playable; }; 32 bool eject();33 33 34 34 void weaponConfigChanged(); … … 39 39 private: 40 40 Playable* playable; //!< The one we controll or NULL if none 41 Hud hud; 41 Hud hud; //!< The HUD to be displayed for this Player. 42 42 }; 43 43 -
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.