Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5897 in orxonox.OLD for branches/spaceshipcontrol


Ignore:
Timestamp:
Dec 3, 2005, 5:34:09 PM (19 years ago)
Author:
snellen
Message:

space_ship.cc updated

File:
1 edited

Legend:

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

    r5894 r5897  
    108108
    109109  PRINTF(4)("SPACESHIP INIT\n");
    110   travelSpeed = 100.0;
     110
     111
    111112  bUp = bDown = bLeft = bRight = bAscend = bDescend = false;
    112113  bFire = false;
    113   acceleration = 50.0;
     114
     115  travelSpeed = 15.0;
     116  this->velocity = Vector(0.0,0.0,0.0);
    114117
    115118//   GLGuiButton* button = new GLGuiPushButton();
     
    253256  Vector move = (velocity)*time;
    254257
     258  if( velocity.len() != 0 )
     259   {
     260     this->setAbsDir(Quaternion(velocity, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)));
     261   }
     262
    255263  this->shiftCoor (move);
    256264
     
    267275{
    268276  Vector accel(0.0, 0.0, 0.0);
    269   Vector rot(0.0, 0.0, 0.0);
    270   float rotVal = 0.0;
     277  //Vector rot(0.0, 0.0, 0.0);
     278  //float rotVal = 0.0;
    271279  /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */
    272280  /* calculate the direction in which the craft is heading  */
    273281  Vector direction (1.0, 0.0, 0.0);
    274282  //direction = this->absDirection.apply (direction);
    275   Vector orthDirection (0.0, 0.0, 1.0);
     283   Vector orthDirection (0.0, 0.0, 1.0);
    276284  //orthDirection = orthDirection.cross (direction);
    277285
    278   if( this->bUp)
    279     accel += direction;
    280   if( this->bDown)
    281     accel -= direction;
     286
     287  if( this->bUp )
     288    travelSpeed++;
     289  if( this->bDown )
     290    travelSpeed--;
     291
    282292
    283293  if( this->bLeft /* > -this->getRelCoor().z*2*/)
    284294  {
    285295    accel -=(orthDirection);
    286     rot +=Vector(1,0,0);
    287     rotVal -= .4;
     296    //rot +=Vector(1,0,0);
     297    //rotVal -= .4;
    288298  }
    289299  if( this->bRight /* > this->getRelCoor().z*2*/)
    290300  {
    291301    accel += orthDirection;
    292     rot += Vector(1,0,0);
    293     rotVal += .4;
     302    //rot += Vector(1,0,0);
     303    //rotVal += .4;
    294304  }
    295305  if (this->bAscend )
    296306  {
    297307    accel += Vector(0,1,0);
    298     rot += Vector(0,0,1);
    299     rotVal += .4;
     308    //rot += Vector(0,0,1);
     309    //rotVal += .4;
    300310  }
    301311  if (this->bDescend )
    302312  {
    303313    accel -= Vector(0,1,0);
    304     rot += Vector(0,0,1);
    305     rotVal -= .4;
     314    //rot += Vector(0,0,1);
     315    //rotVal -= .4;
    306316  }
    307317
    308318  velocity += accel*time;
    309   rot.normalize();
    310   this->setRelDirSoft(Quaternion(rotVal, rot), 5);
     319  velocity = (velocity.getNormalized() ) *travelSpeed;
     320  //rot.normalize();
     321  //this->setRelDirSoft(Quaternion(rotVal, rot), 5);
    311322}
    312323
Note: See TracChangeset for help on using the changeset viewer.