Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6509 in orxonox.OLD


Ignore:
Timestamp:
Jan 16, 2006, 1:09:26 PM (18 years ago)
Author:
bknecht
Message:

Control: Major changes in Spaceshipcontrol. Go check it out! It's not perfect, though.

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

Legend:

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

    r6506 r6509  
    129129  xMouse = yMouse = 0;
    130130  mouseSensitivity = 0.001;
    131   airViscosity = 1.0;
    132   cycle = 0.0;
     131  airViscosity = 0.95;
     132//  cycle = 0.0;
    133133
    134134  this->setMaxEnergy(100);
    135135  this->setEnergy(80);
    136136
    137   travelSpeed = 15.0;
    138   acceleration = 5.0;
     137  travelSpeed = 40.0;
     138  acceleration = 3;
    139139  this->velocity = this->getAbsDirX()*travelSpeed;
    140140  this->mouseDir = this->getAbsDir();
     141  this->pitchDir = this->getAbsDir();
    141142
    142143//   GLGuiButton* button = new GLGuiPushButton();
     
    276277  this->calculateVelocity(time);
    277278
    278   Vector move = velocity.getNormalized()*travelSpeed;
    279 
     279  Vector move = velocity*time;
     280 
    280281  //orient the velocity in the direction of the spaceship.
    281282  travelSpeed = velocity.len();
     
    290291
    291292  // this is the air friction (necessary for a smooth control)
    292   if(velocity.len() != 0) velocity -= velocity*0.01;
     293  if(travelSpeed != 0) velocity -= velocity.getNormalized()*travelSpeed*travelSpeed*0.0005;
     294 
     295  //other physics (gravity)
     296  if((this->getAbsDirY()).y*travelSpeed < 60 && (this->getAbsDirY()).y>0)
     297  move += Vector(0,-1,0)*120*time + Vector(0,2,0)*(this->getAbsDirY()).y*travelSpeed*time;
     298  if((this->getAbsDirY()).y*travelSpeed < 60 && (this->getAbsDirY()).y<0)
     299  move += Vector(0,-1,0)*120*time - Vector(0,2,0)*(this->getAbsDirY()).y*travelSpeed*time;
    293300
    294301  //hoover effect
     
    302309  //SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2);
    303310
    304   this->shiftCoor (move);
     311  this->shiftCoor(move);
    305312
    306313  this->getWeaponManager()->tick(time);
     
    315322void SpaceShip::calculateVelocity (float time)
    316323{
    317   //Vector accel(0.0, 0.0, 0.0);
     324  Vector accel(0.0, 0.0, 0.0);
    318325  /*
    319326  Vector rot(0.0, 0.0, 0.0); // wird benötigt für Helicopter
     
    323330  /* calculate the direction in which the craft is heading  */
    324331
    325   Plane plane(Vector(0,1,0), Vector(0,0,0));
     332  //Plane plane(Vector(0,1,0), Vector(0,0,0));
    326333
    327334  if( this->bUp )
     
    329336     //this->shiftCoor(this->getAbsDirX());
    330337      //accel += (this->getAbsDirX())*2;
    331       if(travelSpeed < 30) travelSpeed += acceleration*time;
    332 
    333       /* Heli-Steuerung
    334          accel += (this->getAbsDirX()*2;
    335          if(
    336       */
     338     
     339      accel += (this->getAbsDirX())*3*acceleration;
     340
    337341   }
    338342
     
    341345     //this->shiftCoor((this->getAbsDirX())*-1);
    342346     //accel -= (this->getAbsDirX())*2;
    343      if(travelSpeed >= 0) travelSpeed -= acceleration*time;
     347     accel -= (this->getAbsDirX())*3*acceleration;
    344348   }
    345349
     
    399403  }
    400404
    401   //velocity += accel;
     405  velocity += accel;
    402406  //rot.normalize();
    403407  //this->setRelDirSoft(Quaternion(rotVal, rot), 5);
     
    442446    this->xMouse = event.xRel;
    443447    this->yMouse = event.yRel;
    444     mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)));
     448   
     449    int controlVelocity = 150;
     450   
     451    if (xMouse > controlVelocity) xMouse = controlVelocity;
     452    else if (xMouse < -controlVelocity) xMouse = -controlVelocity;
     453    if (yMouse > controlVelocity) yMouse = controlVelocity;
     454    else if (yMouse < -controlVelocity) yMouse = -controlVelocity;
     455   
     456    //pitchDir *= (Quaternion(xMouse*mouseSensitivity*0.01, Vector(1,0,0)));
     457   
     458    mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1))*pitchDir);
    445459   // if( xMouse*xMouse + yMouse*yMouse < 0.9)
    446460     //this->setAbsDir(mouseDir);
  • branches/spaceshipcontrol/src/world_entities/space_ships/space_ship.h

    r6443 r6509  
    6666    float                 yMouse;             //!< mouse moved in y-Direction
    6767    float                 mouseSensitivity;   //!< the mouse sensitivity
    68     float                 cycle;              //!< hovercycle
     68//    float                 cycle;              //!< hovercycle
    6969
    7070    Vector                velocity;           //!< the velocity of the player.
    7171    Quaternion            mouseDir;           //!< the direction where the player wants to fly
    7272    Quaternion            rotQuat;
     73    Quaternion            pitchDir;
    7374    float                 travelSpeed;        //!< the current speed of the player (to make soft movement)
    7475    float                 acceleration;       //!< the acceleration of the player.
Note: See TracChangeset for help on using the changeset viewer.