Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 18, 2006, 4:32:47 PM (19 years ago)
Author:
snellen
Message:

space_ship.cc updated

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

Legend:

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

    r6497 r6584  
    5757    float                 xMouse;             //!< mouse moved in x-Direction
    5858    float                 yMouse;             //!< mouse moved in y-Direction
     59    int                   yInvert;
    5960    float                 mouseSensitivity;   //!< the mouse sensitivity
    6061    //float                 cycle;              //!< hovercycle
  • branches/spaceshipcontrol/src/world_entities/space_ships/space_ship.cc

    r6559 r6584  
    128128  bFire = false;
    129129  xMouse = yMouse = 0;
     130  yInvert = 1;
    130131  mouseSensitivity = 0.001;
    131   airViscosity = 0.95;
    132   controlVelocityX = 20;
     132  airViscosity = 0.01;
     133  controlVelocityX = 25;
    133134  controlVelocityY = 150;
    134   shipInertia = 3.0             ;
     135  shipInertia = 0.5             ;
    135136//  cycle = 0.0;
    136137
     
    276277void SpaceShip::tick (float time)
    277278{
     279  if( xMouse != 0 || yMouse != 0)
     280   {
     281    if (xMouse > controlVelocityX) xMouse = controlVelocityX;
     282    else if (xMouse < -controlVelocityX) xMouse = -controlVelocityX;
     283    if (yMouse > controlVelocityY) yMouse = controlVelocityY;
     284    else if (yMouse < -controlVelocityY) yMouse = -controlVelocityY;
     285   
     286    pitchDir = (Quaternion(xMouse*mouseSensitivity*0.5, Vector(1,0,0)));
     287   
     288    mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity*yInvert, Vector(0,0,1))*pitchDir);
     289    xMouse = yMouse = 0;
     290   }
    278291
    279292  // spaceship controlled movement
     
    338351     //this->shiftCoor(this->getAbsDirX());
    339352      //accel += (this->getAbsDirX())*2;
    340      
    341353      accel += (this->getAbsDirX())*acceleration;
    342354
     
    426438void SpaceShip::process(const Event &event)
    427439{
    428 
    429 
    430440  if( event.type == KeyMapper::PEV_LEFT)
    431441      this->bRollL = event.bPressed;
     
    446456  else if( event.type == EV_MOUSE_MOTION)
    447457  {
    448     this->xMouse = event.xRel;
    449     this->yMouse = event.yRel;
    450    
    451    
    452    
    453     if (xMouse > controlVelocityX) xMouse = controlVelocityX;
    454     else if (xMouse < -controlVelocityX) xMouse = -controlVelocityX;
    455     if (yMouse > controlVelocityY) yMouse = controlVelocityY;
    456     else if (yMouse < -controlVelocityY) yMouse = -controlVelocityY;
    457    
    458     pitchDir = (Quaternion(xMouse*mouseSensitivity*0.5, Vector(1,0,0)));
    459    
    460     mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1))*pitchDir);
    461    // if( xMouse*xMouse + yMouse*yMouse < 0.9)
    462      //this->setAbsDir(mouseDir);
     458    this->xMouse += event.xRel;
     459    this->yMouse += event.yRel;
    463460  }
    464461}
  • branches/spaceshipcontrol/src/world_entities/space_ships/space_ship.h

    r6544 r6584  
    6666    float                 yMouse;             //!< mouse moved in y-Direction
    6767    float                 mouseSensitivity;   //!< the mouse sensitivity
     68    int                   yInvert;
    6869    int                   controlVelocityX;
    6970    int                   controlVelocityY;
Note: See TracChangeset for help on using the changeset viewer.