Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6058 in orxonox.OLD


Ignore:
Timestamp:
Dec 12, 2005, 1:04:24 PM (18 years ago)
Author:
bknecht
Message:

new helicopter control

File:
1 edited

Legend:

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

    r6052 r6058  
    245245  Vector move = (velocity)*time;
    246246
    247   //orient the velocity in the direction of the spaceship.
    248   //travelSpeed = velocity.len();
    249   //velocity += ((this->getAbsDirX())*travelSpeed-velocity)*airViscosity;
    250   //velocity = (velocity.getNormalized())*travelSpeed;
    251 
    252247  // this is the air friction (necessary for a smooth control)
    253   if(velocity.len() != 0) velocity -= velocity*0.01;
     248  if(velocity.len() != 0) velocity -= velocity*0.1;
    254249 
    255   if(this->getAbsDirX().y < -0.2) this->shiftDir(Quaternion(time, Vector(0,0,1)));
    256   else if(this->getAbsDirX().y > 0.2) this->shiftDir(Quaternion(-time, Vector(0,0,1)));
    257250
    258251  //hoover effect
     
    289282     //this->shiftCoor(this->getAbsDirX());
    290283     accel += Vector(this->getAbsDirX().x,0,this->getAbsDirX().z).getNormalized()*2;
    291      rot += Vector (0,0,1);
    292      rotVal -= .004;
     284     if((this->getAbsDirX()).y > -.2)
     285     {
     286       rot += Vector (0,0,1);
     287       rotVal -= .4;
     288     }
     289   }
     290   else
     291   {
     292       if(this->getAbsDirX().y < -.02) this->shiftDir(Quaternion(time/5, Vector(0,0,1)));
    293293   }
    294294
     
    297297     //this->shiftCoor((this->getAbsDirX())*-1);
    298298     accel -= Vector(this->getAbsDirX().x,0,this->getAbsDirX().z).getNormalized()*2;
    299      rot += Vector (0,0,1);
    300      rotVal += .004;
     299     if((this->getAbsDirX()).y < .2)
     300     {
     301       rot += Vector (0,0,1);
     302       rotVal += .4;
     303     }
    301304   }
     305   else
     306   {
     307         if(this->getAbsDirX().y > 0.02) this->shiftDir(Quaternion(-time/5, Vector(0,0,1)));
     308   }
    302309
    303310  if( this->bLeft /* > -this->getRelCoor().z*2*/)
    304311  {
    305312    //this->shiftDir(Quaternion(time, Vector(0,1,0)));
    306     accel -= (this->getAbsDirZ());
    307     //velocityDir.normalize();
    308     rot +=Vector(1,0,0);
    309     rotVal -= .002;
     313    accel -= Vector(this->getAbsDirZ().x,0,this->getAbsDirZ().z).getNormalized()*2;
     314    //velocityDir.normalize();
     315    if((this->getAbsDirZ()).y < .2)
     316    {
     317      rot +=Vector(1,0,0);
     318      rotVal -= .06;
     319    }
    310320  }
    311321  if( this->bRight /* > this->getRelCoor().z*2*/)
     
    313323    //this->shiftDir(Quaternion(-time, Vector(0,1,0)));
    314324
    315     accel += (this->getAbsDirZ());
    316     //velocityDir.normalize();
    317     rot += Vector(1,0,0);
    318     rotVal += .002;
     325    accel += Vector(this->getAbsDirZ().x,0,this->getAbsDirZ().z).getNormalized()*2;
     326    //velocityDir.normalize();
     327    if((this->getAbsDirZ()).y > -.2)
     328    {
     329      rot += Vector(1,0,0);
     330      rotVal += .06;
     331    }
    319332  }
    320333
     
    409422    this->xMouse = event.xRel;
    410423    this->yMouse = event.yRel;
    411     //this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)));
     424    if(((this->getAbsDirX().y) <= .2 && yMouse > 0) || ((this->getAbsDirX().y) >= -.2 && yMouse < 0)) yMouse = 0;
     425    this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)));
    412426  }
    413427}
Note: See TracChangeset for help on using the changeset viewer.