Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 19, 2005, 4:52:01 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the spaceshipcontroll branche into the trunk
merged with command
svn merge -r6036:HEAD spaceshipcontrol/ ../trunk/
no conflicts

File:
1 edited

Legend:

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

    r6005 r6162  
    9999
    100100/**
    101  * initializes a Spaceship
     101 * initializes a Helicopter
    102102 */
    103103void Helicopter::init()
     
    240240void Helicopter::tick (float time)
    241241{
    242      cycle += time;
    243242  // spaceship controlled movement
    244243  this->calculateVelocity(time);
     
    246245  Vector move = (velocity)*time;
    247246
    248   //orient the spaceship model in the direction of movement.
    249 
    250247  // this is the air friction (necessary for a smooth control)
    251   if(velocity.len() != 0) velocity -= velocity*0.01;
    252 
     248  if(velocity.len() != 0) velocity -= velocity*0.1;
     249
     250
     251  //hoover effect
     252  cycle += time;
    253253  this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02);
     254
     255  //readjust
     256 // if (this->getAbsDirZ().y > 0.1) this->shiftDir(Quaternion(time*0.3, Vector(1,0,0)));
     257  //else if (this->getAbsDirZ().y < -0.1) this->shiftDir(Quaternion(-time*0.3, Vector(1,0,0)));
    254258
    255259  //SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2);
     
    269273{
    270274  Vector accel(0.0, 0.0, 0.0);
    271   //Vector rot(0.0, 0.0, 0.0);
    272   //float rotVal = 0.0;
     275  Vector rot(0.0, 0.0, 0.0);
     276  float rotVal = 0.0;
    273277  /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */
    274278  /* calculate the direction in which the craft is heading  */
     
    277281   {
    278282     //this->shiftCoor(this->getAbsDirX());
    279       accel += (this->getAbsDirX())*2;
     283
     284     accel += Vector(this->getAbsDirX().x,0,this->getAbsDirX().z).getNormalized()*2;
     285     if((this->getAbsDirX()).y > -.2)
     286     {
     287       rot += Vector (0,0,1);
     288       rotVal -= time/5;
     289     }
     290   }
     291   else
     292   {
     293       if(this->getAbsDirX().y < -.02) this->shiftDir(Quaternion(time/5, Vector(0,0,1)));
    280294   }
    281295
     
    283297   {
    284298     //this->shiftCoor((this->getAbsDirX())*-1);
    285      accel -= (this->getAbsDirX())*2;
     299     accel -= Vector(this->getAbsDirX().x,0,this->getAbsDirX().z).getNormalized()*2;
     300     if((this->getAbsDirX()).y < .2)
     301     {
     302       rot += Vector (0,0,1);
     303       rotVal += time/5;
     304     }
     305   }
     306   else
     307   {
     308         if(this->getAbsDirZ().y > 0.02) this->shiftDir(Quaternion(-time/5, Vector(0,0,1)));
    286309   }
    287310
    288311  if( this->bLeft /* > -this->getRelCoor().z*2*/)
    289312  {
    290     this->shiftDir(Quaternion(time, Vector(0,1,0)));
    291 //    accel -= rightDirection;
     313    //this->shiftDir(Quaternion(time, Vector(0,1,0)));
     314    accel -= Vector(this->getAbsDirZ().x,0,this->getAbsDirZ().z).getNormalized()*2;
     315    //velocityDir.normalize();
     316    if((this->getAbsDirZ()).y < .2)
     317    {
     318      rot +=Vector(1,0,0);
     319      rotVal -= time/5;
     320    }
     321  }
     322  else
     323   {
     324         if(this->getAbsDirZ().y > 0.02) this->shiftDir(Quaternion(time/5, Vector(1,0,0)));
     325   }
     326   
     327  if( this->bRight /* > this->getRelCoor().z*2*/)
     328  {
     329    //this->shiftDir(Quaternion(-time, Vector(0,1,0)));
     330
     331    accel += Vector(this->getAbsDirZ().x,0,this->getAbsDirZ().z).getNormalized()*2;
     332    //velocityDir.normalize();
     333    if((this->getAbsDirZ()).y > -.2)
     334    {
     335      rot += Vector(1,0,0);
     336      rotVal += time/5;
     337    }
     338  }
     339  else
     340   {
     341         if(this->getAbsDirZ().y < -0.02) this->shiftDir(Quaternion(-time/5, Vector(1,0,0)));
     342   }
     343
     344  if( this->bRollL /* > -this->getRelCoor().z*2*/)
     345  {
     346    this->shiftDir(Quaternion(-time, Vector(1,0,0)));
     347    //accel -= rightDirection;
    292348    //velocityDir.normalize();
    293349    //rot +=Vector(1,0,0);
    294350    //rotVal -= .4;
    295351  }
    296   if( this->bRight /* > this->getRelCoor().z*2*/)
    297   {
    298     this->shiftDir(Quaternion(-time, Vector(0,1,0)));
    299 
    300     //    accel += rightDirection;
     352  if( this->bRollR /* > this->getRelCoor().z*2*/)
     353  {
     354    this->shiftDir(Quaternion(time, Vector(1,0,0)));
     355
     356    //accel += rightDirection;
    301357    //velocityDir.normalize();
    302358    //rot += Vector(1,0,0);
    303359    //rotVal += .4;
    304360  }
    305 
    306   if( this->bRollL /* > -this->getRelCoor().z*2*/)
    307   {
    308     this->shiftDir(Quaternion(-time, Vector(1,0,0)));
    309 //    accel -= rightDirection;
    310     //velocityDir.normalize();
    311     //rot +=Vector(1,0,0);
    312     //rotVal -= .4;
    313   }
    314   if( this->bRollR /* > this->getRelCoor().z*2*/)
    315   {
    316     this->shiftDir(Quaternion(time, Vector(1,0,0)));
    317 
    318     //    accel += rightDirection;
    319     //velocityDir.normalize();
    320     //rot += Vector(1,0,0);
    321     //rotVal += .4;
    322   }
    323361  if (this->bAscend )
    324362  {
    325     this->shiftDir(Quaternion(time, Vector(0,0,1)));
    326 
    327 //    accel += upDirection;
     363    //this->shiftDir(Quaternion(time, Vector(0,0,1)));
     364
     365    accel += (this->getAbsDirY())*2;
    328366    //velocityDir.normalize();
    329367    //rot += Vector(0,0,1);
     
    332370  if (this->bDescend )
    333371  {
    334     this->shiftDir(Quaternion(-time, Vector(0,0,1)));
    335 
    336     //    accel -= upDirection;
     372    //this->shiftDir(Quaternion(-time, Vector(0,0,1)));
     373
     374    accel -= (this->getAbsDirY())*2;
    337375    //velocityDir.normalize();
    338376    //rot += Vector(0,0,1);
     
    341379
    342380  velocity += accel;
    343   //rot.normalize();
    344   //this->setRelDirSoft(Quaternion(rotVal, rot), 5);
     381  rot.normalize();
     382  this->shiftDir(Quaternion(rotVal, rot));
    345383}
    346384
     
    373411
    374412  if( event.type == SDLK_a)
    375       this->bRollL = event.bPressed;
     413      this->bLeft = event.bPressed;
    376414  else if( event.type == SDLK_d)
    377       this->bRollR = event.bPressed;
     415      this->bRight = event.bPressed;
    378416  else if( event.type == KeyMapper::PEV_FIRE1)
    379417      this->bFire = event.bPressed;
     
    382420  else if ( event.type == KeyMapper::PEV_PREVIOUS_WEAPON && event.bPressed)
    383421    this->getWeaponManager()->previousWeaponConfig();
    384 
     422  else if( event.type == SDLK_e)
     423    this->bAscend = event.bPressed; //this->shiftCoor(0,.1,0);
     424  else if( event.type == SDLK_c)
     425    this->bDescend = event.bPressed; //this->shiftCoor(0,-.1,0);
    385426  else if( event.type == SDLK_w)
    386427    this->bUp = event.bPressed; //this->shiftCoor(0,.1,0);
     
    391432    this->xMouse = event.xRel;
    392433    this->yMouse = event.yRel;
     434    if(((this->getAbsDirX().y) <= .2 && yMouse > 0) || ((this->getAbsDirX().y) >= -.2 && yMouse < 0)) yMouse = 0;
    393435    this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)));
    394436  }
Note: See TracChangeset for help on using the changeset viewer.