Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 31, 2005, 5:06:56 PM (19 years ago)
Author:
bknecht
Message:

Control: new helicopter control

Location:
branches/spaceshipcontrol/src/world_entities/space_ships
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/spaceshipcontrol/src/world_entities/space_ships/helicopter.cc

    r6242 r6378  
    117117  xMouse = yMouse = 0;
    118118  mouseSensitivity = 0.001;
     119  rotorspeed = 1;
     120  tailrotorspeed = 0;
    119121
    120122  cycle = 0.0;
     
    258260*/
    259261void Helicopter::tick (float time)
    260 {
     262{
     263  tailrotorspeed += xMouse/20;
     264  if (tailrotorspeed >= 0.07) tailrotorspeed = 0.07;
     265  else if (tailrotorspeed <= -0.07) tailrotorspeed = -0.07;
     266 
     267  if (tailrotorspeed > 0.0008) tailrotorspeed -= 0.001;
     268  else if (tailrotorspeed < -0.0008) tailrotorspeed += 0.001;
     269  if (tailrotorspeed <= 0.001 && tailrotorspeed >= -0.001) tailrotorspeed = 0;
     270 
    261271  // spaceship controlled movement
    262272  this->calculateVelocity(time);
    263273
    264   Vector move = (velocity)*time;
     274  Vector move = (velocity);
    265275
    266276  // this is the air friction (necessary for a smooth control)
     
    268278
    269279  //physics: Gravity
    270   this->shiftCoor(Vector(0,-0.05,0));
     280  this->shiftCoor(Vector(0,-1,0));
     281 
     282  this->shiftCoor(getAbsDirY()*rotorspeed);
    271283
    272284  //hoover effect
     
    281293
    282294  this->shiftCoor (move);
     295  this->shiftDir(Quaternion(-M_PI/4*tailrotorspeed, Vector(0,1,0)));
    283296
    284297  this->getWeaponManager()->tick(time);
     
    302315   {
    303316     //this->shiftCoor(this->getAbsDirX());
    304 
    305      accel += this->getAbsDirX()*2;
     317     //accel -= this->getAbsDirY();
    306318     rot += Vector (0,0,1);
    307      rotVal -= time/8;
     319     rotVal -= time/5;
    308320   }
    309321   else
     
    315327   {
    316328     //this->shiftCoor((this->getAbsDirX())*-1);
    317      accel -= this->getAbsDirX()*2;
     329     //accel -= this->getAbsDirY();
    318330     rot += Vector (0,0,1);
    319      rotVal += time/8;
     331     rotVal += time/5;
    320332   }
    321333   else
     
    327339  {
    328340    //this->shiftDir(Quaternion(time, Vector(0,1,0)));
    329     accel -= this->getAbsDirZ()*2;
     341    //accel -= this->getAbsDirY();
    330342    //velocityDir.normalize();
    331343    rot += Vector(1,0,0);
    332     rotVal -= time/8;
     344    rotVal -= time/5;
    333345  }
    334346  else
     
    340352  {
    341353    //this->shiftDir(Quaternion(-time, Vector(0,1,0)));
    342     accel += this->getAbsDirZ()*2;
     354    accel += this->getAbsDirY();
    343355    //velocityDir.normalize();
    344356    rot += Vector(1,0,0);
     
    371383    //this->shiftDir(Quaternion(time, Vector(0,0,1)));
    372384
    373     accel += (this->getAbsDirY())*3;
     385    rotorspeed += 0.05;
     386    if (rotorspeed >= 2) rotorspeed = 2;
    374387    //velocityDir.normalize();
    375388    //rot += Vector(0,0,1);
    376389    //rotVal += .4;
    377390  }
     391  else
     392  {
     393    if(rotorspeed >= 1.05) rotorspeed -= 0.05;
     394  }
     395 
    378396  if (this->bDescend )
    379397  {
    380398    //this->shiftDir(Quaternion(-time, Vector(0,0,1)));
    381399
    382     accel -= (this->getAbsDirY())*3;
     400    rotorspeed -= 0.05;
     401    if (rotorspeed <= 0) rotorspeed = 0;
    383402    //velocityDir.normalize();
    384403    //rot += Vector(0,0,1);
    385404    //rotVal -= .4;
    386405  }
    387 
    388   velocity += accel;
     406  else
     407  {
     408    if(rotorspeed <= 0.05) rotorspeed += 0.05;
     409  }
     410
     411  //velocity += accel;
    389412  rot.normalize();
    390413  this->shiftDir(Quaternion(rotVal, rot));
     
    438461  else if( event.type == EV_MOUSE_MOTION)
    439462  {
    440     this->xMouse = event.xRel;
    441     this->yMouse = event.yRel;
    442     if(((this->getAbsDirX().y) <= .2 && yMouse > 0) || ((this->getAbsDirX().y) >= -.2 && yMouse < 0)) yMouse = 0;
    443     this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)));
     463    this->xMouse = event.xRel*mouseSensitivity;
     464    this->yMouse = event.yRel*mouseSensitivity;
     465   
     466    //this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)));
    444467  }
    445468}
  • branches/spaceshipcontrol/src/world_entities/space_ships/helicopter.h

    r6222 r6378  
    6767    float                 travelSpeed;        //!< the current speed of the player (to make soft movement)
    6868    float                 acceleration;       //!< the acceleration of the player.
     69    float                 rotorspeed;         //!< the speed of the rotor.
     70    float                 tailrotorspeed;     //!< the relativ speed ot the tail rotor
    6971
    7072    float                 airViscosity;
Note: See TracChangeset for help on using the changeset viewer.