Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6879 in orxonox.OLD for trunk


Ignore:
Timestamp:
Jan 31, 2006, 2:04:29 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: smoother control of the Hover

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/space_ships/hover.cc

    r6871 r6879  
    3939 */
    4040Hover::~Hover ()
    41 {
    42 
    43 }
     41{}
    4442
    4543/**
     
    112110  this->cameraLook = 0.0f;
    113111  this->rotation = 0.0f;
     112  this->acceleration = 1.0;
    114113
    115114  // camera - issue
     
    241240  this->movement(dt);
    242241  this->rotorCycle += this->rotorSpeed * dt;
    243 
    244   Vector move = (velocity)*dt;
    245 
    246   // this is the air friction (necessary for a smooth control)
    247   if(velocity.len() != 0)
    248     velocity -= velocity*0.1;
    249   this->shiftCoor (move);
    250 
    251   this->rotation = 0.0f;
    252242}
    253243
     
    259249{
    260250  Vector accel(0.0, 0.0, 0.0);
    261   float rotVal = .3;
     251  float rotSpeed = .3;
    262252
    263253  if( this->bForward )
    264254  {
    265     accel += Vector(rotVal, 0, 0);
     255    accel += Vector(this->acceleration, 0, 0);
    266256  }
    267257
    268258  if( this->bBackward )
    269259  {
    270     accel -= Vector(rotVal,0,0);
     260    accel -= Vector(this->acceleration, 0, 0);
    271261  }
    272262  if( this->bLeft)
    273263  {
    274     accel -= Vector(0,0,rotVal);
     264    accel -= Vector(0, 0, this->acceleration);
    275265  }
    276266
    277267  if( this->bRight)
    278268  {
    279     accel += Vector(0,0,rotVal);
     269    accel += Vector(0, 0, this->acceleration);
    280270  }
    281271
    282272  if (this->bAscend )
    283273  {
    284     accel += Vector(0,rotVal,0);
     274    accel += Vector(0, this->acceleration, 0);
    285275  }
    286276  if (this->bDescend )
    287277  {
    288     accel -= Vector(0,rotVal,0);
    289   }
    290 
    291   Vector tmp = this->getAbsDir().apply(accel * 30.0);
    292   tmp.y = accel.y * 1000.0 * dt;
    293   velocity += tmp;
    294 
    295 
     278    accel -= Vector(0, this->acceleration, 0);
     279  }
     280
     281  Vector tmp = this->getAbsDir().apply(accel * 500.0);
     282  tmp.y = accel.y * 500.0 ;
     283  velocity += tmp * dt;
     284
     285  accel -= velocity * .0005;
     286
     287  // this is the air friction (necessary for a smooth control)
     288  this->velocity *= 0.95;
     289  this->shiftCoor (velocity * dt);
     290  this->rotation = 0.0f;
     291
     292  accel *=.5;
    296293  this->setRelDirSoft(this->direction * Quaternion(-accel.x, Vector(0,0,1)) * Quaternion(accel.z, Vector(1,0,0)), 5);
    297294
    298   this->wingNodeLeft.setRelDirSoft(Quaternion(accel.z+this->rotation, Vector(1,0,0)), 10);
    299   this->rotorNodeLeft.setRelDirSoft(Quaternion(-2.0*accel.x+this->rotation, Vector(0,0,1)), 10);
    300 
    301   this->wingNodeRight.setRelDirSoft(Quaternion(accel.z+this->rotation, Vector(1,0,0)), 10);
    302   this->rotorNodeRight.setRelDirSoft(Quaternion(-2.0*accel.x-this->rotation, Vector(0,0,1)), 10);
     295  this->wingNodeLeft.setRelDirSoft(Quaternion(accel.z+this->rotation, Vector(1,0,0)), 5);
     296  this->rotorNodeLeft.setRelDirSoft(Quaternion(-2.0*accel.x+this->rotation, Vector(0,0,1)), 5);
     297
     298  this->wingNodeRight.setRelDirSoft(Quaternion(accel.z+this->rotation, Vector(1,0,0)), 5);
     299  this->rotorNodeRight.setRelDirSoft(Quaternion(-2.0*accel.x-this->rotation, Vector(0,0,1)), 5);
    303300}
    304301
     
    391388    else if (cameraLook < -M_PI_2)
    392389      cameraLook = -M_PI_2;
    393     this->cameraNode.setRelDirSoft(Quaternion(-cameraLook, Vector(0,0,1)),5);
    394   }
    395 }
     390    this->cameraNode.setRelDirSoft(Quaternion(-cameraLook, Vector(0,0,1)),10);
     391  }
     392}
Note: See TracChangeset for help on using the changeset viewer.