Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7339 in orxonox.OLD for trunk/src/world_entities/space_ships


Ignore:
Timestamp:
Apr 19, 2006, 2:11:14 AM (19 years ago)
Author:
bensch
Message:

some nice fixes

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  
    4646
    4747/**
    48  * loads a TurbineHover information from a specified file.
     48 * @brief loads a TurbineHover information from a specified file.
    4949 * @param fileName the name of the File to load the turbine_hover from (absolute path)
    5050 */
     
    6464
    6565/**
    66  * creates a new Spaceship from Xml Data
     66 * @brief creates a new Spaceship from Xml Data
    6767 * @param root the xml element containing spaceship data
    6868
     
    9696
    9797/**
    98  * initializes a TurbineHover
     98 * @brief initializes a TurbineHover
    9999 */
    100100void TurbineHover::init()
     
    102102  //  this->setRelDir(Quaternion(M_PI, Vector(1,0,0)));
    103103  this->setClassID(CL_TURBINE_HOVER, "TurbineHover");
     104
     105  this->setSupportedPlaymodes(Playable::Full3D | Playable::Horizontal);
    104106
    105107  this->loadModel("models/ships/hoverglider_wing.obj", 1.0f, 3);
     
    275277void TurbineHover::tick (float dt)
    276278{
    277 //  this->debugNode(1);
     279  //  this->debugNode(1);
    278280  Playable::tick(dt);
    279281
     
    324326  }
    325327
    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  }
    353396}
    354397
  • trunk/src/world_entities/space_ships/turbine_hover.h

    r7337 r7339  
    1717{
    1818  public:
    19 
    2019    TurbineHover(const std::string& fileName);
    2120    TurbineHover(const TiXmlElement* root = NULL);
Note: See TracChangeset for help on using the changeset viewer.