Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6497 in orxonox.OLD for branches


Ignore:
Timestamp:
Jan 11, 2006, 5:45:38 PM (19 years ago)
Author:
bknecht
Message:

Control: Helicoptercontrol updated

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

Legend:

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

    r6443 r6497  
    117117  bFire = false;
    118118  xMouse = yMouse = 0;
    119   mouseSensitivity = 0.001;
    120   rotorspeed = 1;
    121   tailrotorspeed = 0;
    122 
    123   cycle = 0.0;
    124 
    125 
    126   travelSpeed = 15.0;
     119  mouseSensitivity = 0.05;
     120  //rotorspeed = 1;
     121  //tailrotorspeed = 0;
     122
     123  //cycle = 0.0;
     124
     125
     126  //travelSpeed = 15.0;
    127127  this->velocity = Vector(0.0,0.0,0.0);
    128128  this->velocityDir = Vector(1.0,0.0,0.0);
     
    249249void Helicopter::tick (float time)
    250250{
     251  /*
    251252  tailrotorspeed += xMouse/20;
    252253  if (tailrotorspeed >= 0.07) tailrotorspeed = 0.07;
     
    256257  else if (tailrotorspeed < -0.0008) tailrotorspeed += 0.001;
    257258  if (tailrotorspeed <= 0.001 && tailrotorspeed >= -0.001) tailrotorspeed = 0;
    258 
     259  */
     260 
    259261  // spaceship controlled movement
    260262  this->calculateVelocity(time);
    261263
    262   Vector move = (velocity);
     264  Vector move = (velocity)*time;
    263265
    264266  // this is the air friction (necessary for a smooth control)
    265267  if(velocity.len() != 0) velocity -= velocity*0.1;
     268 
     269  //travelSpeed = velocity.len();
    266270
    267271  //physics: Gravity
    268   this->shiftCoor(Vector(0,-1,0));
     272  /*this->shiftCoor(Vector(0,-1,0));
    269273
    270274  this->shiftCoor(getAbsDirY()*rotorspeed);
    271 
     275  */
     276 
     277  /*
    272278  //hoover effect
    273279  cycle += time;
    274280  this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02);
     281  */
    275282
    276283  //readjust
     
    281288
    282289  this->shiftCoor (move);
    283   this->shiftDir(Quaternion(-M_PI/4*tailrotorspeed, Vector(0,1,0)));
     290  //this->shiftDir(Quaternion(-M_PI/4*tailrotorspeed, Vector(0,1,0)));
    284291
    285292  this->getWeaponManager()->tick(time);
     
    295302{
    296303  Vector accel(0.0, 0.0, 0.0);
    297   Vector rot(0.0, 0.0, 0.0);
    298   float rotVal = 0.0;
     304  float rotValX = 0.0;
     305  float rotValZ = 0.0;
    299306  /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */
    300307  /* calculate the direction in which the craft is heading  */
     
    304311     //this->shiftCoor(this->getAbsDirX());
    305312     //accel -= this->getAbsDirY();
    306      rot += Vector (0,0,1);
    307      rotVal -= time/5;
     313     
     314     accel += Vector((this->getAbsDirX()).x,0,(this->getAbsDirX()).z);
     315     if((this->getAbsDirX()).y >= -0.1) rotValZ -= time;
    308316   }
    309317   else
    310318   {
    311        if(this->getAbsDirX().y < -.02) this->shiftDir(Quaternion(time/8, Vector(0,0,1)));
     319       if(this->getAbsDirX().y < -.02) this->shiftDir(Quaternion(time, Vector(0,0,1)));
    312320   }
    313321
     
    316324     //this->shiftCoor((this->getAbsDirX())*-1);
    317325     //accel -= this->getAbsDirY();
    318      rot += Vector (0,0,1);
    319      rotVal += time/5;
     326     
     327     accel -= Vector((this->getAbsDirX()).x,0,(this->getAbsDirX()).z);
     328     rotValZ += time;
    320329   }
    321330   else
    322331   {
    323          if(this->getAbsDirX().y > 0.02) this->shiftDir(Quaternion(-time/8, Vector(0,0,1)));
     332         if(this->getAbsDirX().y > 0.02) this->shiftDir(Quaternion(-time, Vector(0,0,1)));
    324333   }
    325334
     
    329338    //accel -= this->getAbsDirY();
    330339    //velocityDir.normalize();
    331     rot += Vector(1,0,0);
    332     rotVal -= time/5;
     340   
     341    accel -= Vector((this->getAbsDirZ()).x,0,(this->getAbsDirZ()).z);
     342    rotValX -= time;
    333343  }
    334344  else
    335345   {
    336          if(this->getAbsDirZ().y > 0.02) this->shiftDir(Quaternion(time/5, Vector(1,0,0)));
     346         if(this->getAbsDirZ().y > 0.02) this->shiftDir(Quaternion(time, Vector(1,0,0)));
    337347   }
    338348
     
    340350  {
    341351    //this->shiftDir(Quaternion(-time, Vector(0,1,0)));
    342     accel += this->getAbsDirY();
     352    //accel += this->getAbsDirY();
    343353    //velocityDir.normalize();
    344     rot += Vector(1,0,0);
    345     rotVal += time/5;
     354   
     355    accel += Vector((this->getAbsDirZ()).x,0,(this->getAbsDirZ()).z);
     356    rotValX += time;
    346357  }
    347358  else
    348359   {
    349          if(this->getAbsDirZ().y < -0.02) this->shiftDir(Quaternion(-time/5, Vector(1,0,0)));
     360         if(this->getAbsDirZ().y < -0.02) this->shiftDir(Quaternion(-time, Vector(1,0,0)));
    350361   }
    351362
     
    371382    //this->shiftDir(Quaternion(time, Vector(0,0,1)));
    372383
    373     rotorspeed += 0.05;
    374     if (rotorspeed >= 2) rotorspeed = 2;
     384    accel += this->getAbsDirY();
     385    //rotorspeed += 0.05;
     386    //if (rotorspeed >= 2) rotorspeed = 2;
    375387    //velocityDir.normalize();
    376388    //rot += Vector(0,0,1);
     
    379391  else
    380392  {
    381     if(rotorspeed >= 1.05) rotorspeed -= 0.05;
     393    //if(rotorspeed >= 1.05) rotorspeed -= 0.05;
    382394  }
    383395
     
    386398    //this->shiftDir(Quaternion(-time, Vector(0,0,1)));
    387399
    388     rotorspeed -= 0.05;
    389     if (rotorspeed <= 0) rotorspeed = 0;
     400    accel -= this->getAbsDirY();
     401    //rotorspeed -= 0.05;
     402    //if (rotorspeed <= 0) rotorspeed = 0;
    390403    //velocityDir.normalize();
    391404    //rot += Vector(0,0,1);
     
    394407  else
    395408  {
    396     if(rotorspeed <= 0.05) rotorspeed += 0.05;
    397   }
    398 
    399   //velocity += accel;
    400   rot.normalize();
    401   this->shiftDir(Quaternion(rotVal, rot));
     409    //if(rotorspeed <= 0.05) rotorspeed += 0.05;
     410  }
     411
     412  velocity += accel;
     413  if((this->getAbsDirX()).y <= 0.2 && (this->getAbsDirX()).y >= -0.2) this->shiftDir(Quaternion(rotValZ, Vector(0,0,1)));
     414  if((this->getAbsDirZ()).y <= 0.2 && (this->getAbsDirZ()).y >= -0.2) this->shiftDir(Quaternion(rotValX, Vector(1,0,0)));
    402415}
    403416
     
    452465    this->yMouse = event.yRel*mouseSensitivity;
    453466
    454     //this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)));
     467    this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))/*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1))*/);
    455468  }
    456469}
  • branches/spaceshipcontrol/src/world_entities/space_ships/helicopter.h

    r6443 r6497  
    5858    float                 yMouse;             //!< mouse moved in y-Direction
    5959    float                 mouseSensitivity;   //!< the mouse sensitivity
    60     float                 cycle;              //!< hovercycle
     60    //float                 cycle;              //!< hovercycle
    6161
    6262    Vector                velocity;           //!< the velocity of the player.
     
    6464    float                 travelSpeed;        //!< the current speed of the player (to make soft movement)
    6565    float                 acceleration;       //!< the acceleration of the player.
    66     float                 rotorspeed;         //!< the speed of the rotor.
    67     float                 tailrotorspeed;     //!< the relativ speed ot the tail rotor
     66    //float                 rotorspeed;         //!< the speed of the rotor.
     67    //float                 tailrotorspeed;     //!< the relativ speed ot the tail rotor
    6868
    6969    float                 airViscosity;
  • branches/spaceshipcontrol/src/world_entities/space_ships/space_ship.cc

    r6444 r6497  
    292292
    293293  //hoover effect
    294   cycle += time;
    295   this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02);
     294  //cycle += time;
     295  //this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02);
    296296
    297297  //readjust
Note: See TracChangeset for help on using the changeset viewer.