Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 14, 2006, 3:41:50 PM (19 years ago)
Author:
snellen
Message:

space-ship control modified

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

Legend:

Unmodified
Added
Removed
  • branches/control/src/world_entities/space_ships/space_ship.cc

    r7122 r7138  
    144144  xMouse = yMouse = 0;
    145145  yInvert = 1;
    146   mouseSensitivity = 0.001;
    147   airViscosity = 0.9;
     146  mouseSensitivity = 0.01;
     147  airViscosity = 0.8;
    148148  controlVelocityX = 25;
    149149  controlVelocityY = 150;
    150   shipInertia = 1.5;
     150  shipInertia = M_PI_4;
     151  maxRudderAmplitude = 0.6 ;
    151152//  cycle = 0.0;
    152153
     
    176177  registerEvent(KeyMapper::PEV_LEFT);
    177178  registerEvent(KeyMapper::PEV_RIGHT);
    178   //registerEvent(SDLK_q);
     179
    179180  //registerEvent(SDLK_e);
     181  //registerEvent(SDLK_e);
     182  //registerEvent(SDLK_e);
     183  //registerEvent(SDLK_e);
     184
    180185  registerEvent(KeyMapper::PEV_FIRE1);
    181186  registerEvent(KeyMapper::PEV_NEXT_WEAPON);
     
    334339{
    335340  Playable::tick(time);
    336 
    337   if( ( xMouse != 0 || yMouse != 0 ) && this->getOwner() == this->getHostID() )
     341 
     342  if( ( xMouse != 0
     343        || yMouse != 0 )
     344        && this->getOwner() == this->getHostID()  )
    338345   {
    339346    if (xMouse > controlVelocityX) xMouse = controlVelocityX;
     
    344351    pitchDir = (Quaternion(xMouse*mouseSensitivity*0.5, Vector(1,0,0)));
    345352
     353    if( fabsf(mouseDir.distance(this->getAbsDir())) < maxRudderAmplitude )//prevent 'jumping'
    346354    mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity*yInvert, Vector(0,0,1))*pitchDir);
     355
    347356    xMouse = yMouse = 0;
    348357   }
    349358
     359 
    350360
    351361//   if( this != State::getPlayer()->getControllable())
     
    367377
    368378  //orient the spaceship in direction of the mouse
    369    rotQuat = Quaternion::quatSlerp( this->getAbsDir(), mouseDir, 0.5);//fabsf(time)*shipInertia);
     379   rotQuat = Quaternion::quatSlerp( this->getAbsDir(), mouseDir,fabsf(time)*shipInertia);
    370380   if (this->getAbsDir().distance(rotQuat) > 0.00000000000001)
    371381    this->setAbsDir( rotQuat);
     
    451461  if( this->bRollL /* > -this->getRelCoor().z*2*/)
    452462  {
     463    if( fabsf(mouseDir.distance(this->getAbsDir())) < maxRudderAmplitude )//prevent 'jumping'
    453464    mouseDir *= Quaternion(-time*2, Vector(1,0,0));
    454465//    accel -= rightDirection;
     
    459470  if( this->bRollR /* > this->getRelCoor().z*2*/)
    460471  {
     472    if( fabsf(mouseDir.distance(this->getAbsDir())) < maxRudderAmplitude )//prevent 'jumping'
    461473    mouseDir *= Quaternion(time*2, Vector(1,0,0));
    462474
  • branches/control/src/world_entities/space_ships/space_ship.h

    r7116 r7138  
    7878    Quaternion            oldMouseDir;        //!< the direction where the player wanted to fly
    7979    float                 shipInertia;        //!< the inertia of the ship(how fast the ship reacts to a mouse input)
     80    float                 maxRudderAmplitude; //!< the higher this value the biger the max rudderamplitude [0...2PI]
    8081    Quaternion            rotQuat;
    8182    Quaternion            pitchDir;
Note: See TracChangeset for help on using the changeset viewer.