Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6051 in orxonox.OLD for branches/spaceshipcontrol/src/world_entities


Ignore:
Timestamp:
Dec 11, 2005, 5:18:43 PM (19 years ago)
Author:
bknecht
Message:

first try of a helicopter control

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

Legend:

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

    r6005 r6051  
    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.
     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;
    249251
    250252  // this is the air friction (necessary for a smooth control)
    251253  if(velocity.len() != 0) velocity -= velocity*0.01;
    252254
     255  //hoover effect
     256  cycle += time;
    253257  this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02);
     258
     259  //readjust
     260 // if (this->getAbsDirZ().y > 0.1) this->shiftDir(Quaternion(time*0.3, Vector(1,0,0)));
     261  //else if (this->getAbsDirZ().y < -0.1) this->shiftDir(Quaternion(-time*0.3, Vector(1,0,0)));
    254262
    255263  //SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2);
     
    269277{
    270278  Vector accel(0.0, 0.0, 0.0);
    271   //Vector rot(0.0, 0.0, 0.0);
    272   //float rotVal = 0.0;
     279  Vector rot(0.0, 0.0, 0.0);
     280  float rotVal = 0.0;
    273281  /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */
    274282  /* calculate the direction in which the craft is heading  */
     
    278286     //this->shiftCoor(this->getAbsDirX());
    279287      accel += (this->getAbsDirX())*2;
     288      rot += Vector (0,0,1);
     289      rotVal -= .4;
    280290   }
    281291
     
    284294     //this->shiftCoor((this->getAbsDirX())*-1);
    285295     accel -= (this->getAbsDirX())*2;
     296     rot += Vector (0,0,1);
     297     rotVal += .4;
    286298   }
    287299
    288300  if( this->bLeft /* > -this->getRelCoor().z*2*/)
    289301  {
    290     this->shiftDir(Quaternion(time, Vector(0,1,0)));
    291 //    accel -= rightDirection;
     302    //this->shiftDir(Quaternion(time, Vector(0,1,0)));
     303    accel -= (this->getAbsDirZ());
     304    //velocityDir.normalize();
     305    rot +=Vector(1,0,0);
     306    rotVal -= .2;
     307  }
     308  if( this->bRight /* > this->getRelCoor().z*2*/)
     309  {
     310    //this->shiftDir(Quaternion(-time, Vector(0,1,0)));
     311
     312    accel += (this->getAbsDirZ());
     313    //velocityDir.normalize();
     314    rot += Vector(1,0,0);
     315    rotVal += .2;
     316  }
     317
     318  if( this->bRollL /* > -this->getRelCoor().z*2*/)
     319  {
     320    this->shiftDir(Quaternion(-time, Vector(1,0,0)));
     321    //accel -= rightDirection;
    292322    //velocityDir.normalize();
    293323    //rot +=Vector(1,0,0);
    294324    //rotVal -= .4;
    295325  }
    296   if( this->bRight /* > this->getRelCoor().z*2*/)
    297   {
    298     this->shiftDir(Quaternion(-time, Vector(0,1,0)));
    299 
    300     //    accel += rightDirection;
     326  if( this->bRollR /* > this->getRelCoor().z*2*/)
     327  {
     328    this->shiftDir(Quaternion(time, Vector(1,0,0)));
     329
     330    //accel += rightDirection;
    301331    //velocityDir.normalize();
    302332    //rot += Vector(1,0,0);
    303333    //rotVal += .4;
    304334  }
    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   }
    323335  if (this->bAscend )
    324336  {
    325     this->shiftDir(Quaternion(time, Vector(0,0,1)));
    326 
    327 //    accel += upDirection;
     337    //this->shiftDir(Quaternion(time, Vector(0,0,1)));
     338
     339    accel += (this->getAbsDirY())*2;
    328340    //velocityDir.normalize();
    329341    //rot += Vector(0,0,1);
     
    332344  if (this->bDescend )
    333345  {
    334     this->shiftDir(Quaternion(-time, Vector(0,0,1)));
    335 
    336     //    accel -= upDirection;
     346    //this->shiftDir(Quaternion(-time, Vector(0,0,1)));
     347
     348    accel -= (this->getAbsDirY())*2;
    337349    //velocityDir.normalize();
    338350    //rot += Vector(0,0,1);
     
    341353
    342354  velocity += accel;
    343   //rot.normalize();
    344   //this->setRelDirSoft(Quaternion(rotVal, rot), 5);
     355  rot.normalize();
     356  this->setRelDirSoft(Quaternion(rotVal, rot), 5);
    345357}
    346358
     
    373385
    374386  if( event.type == SDLK_a)
    375       this->bRollL = event.bPressed;
     387      this->bLeft = event.bPressed;
    376388  else if( event.type == SDLK_d)
    377       this->bRollR = event.bPressed;
     389      this->bRight = event.bPressed;
    378390  else if( event.type == KeyMapper::PEV_FIRE1)
    379391      this->bFire = event.bPressed;
     
    382394  else if ( event.type == KeyMapper::PEV_PREVIOUS_WEAPON && event.bPressed)
    383395    this->getWeaponManager()->previousWeaponConfig();
    384 
     396  else if( event.type == SDLK_e)
     397    this->bAscend = event.bPressed; //this->shiftCoor(0,.1,0);
     398  else if( event.type == SDLK_c)
     399    this->bDescend = event.bPressed; //this->shiftCoor(0,-.1,0);
    385400  else if( event.type == SDLK_w)
    386401    this->bUp = event.bPressed; //this->shiftCoor(0,.1,0);
  • branches/spaceshipcontrol/src/world_entities/space_ships/helicopter.h

    r6005 r6051  
    6565    float                 travelSpeed;        //!< the current speed of the player (to make soft movement)
    6666    float                 acceleration;       //!< the acceleration of the player.
     67   
     68    float                 airViscosity;
    6769
    6870};
  • branches/spaceshipcontrol/src/world_entities/space_ships/space_ship.cc

    r6044 r6051  
    292292{
    293293  Vector accel(0.0, 0.0, 0.0);
    294   //Vector rot(0.0, 0.0, 0.0);
     294  /*
     295  Vector rot(0.0, 0.0, 0.0); // wird benötigt für Helicopter
     296  */
    295297  //float rotVal = 0.0;
    296298  /* FIXME: calculating the direction and orthDirection every timeSlice is redundant! save it somewhere */
     
    301303     //this->shiftCoor(this->getAbsDirX());
    302304      accel += (this->getAbsDirX())*2;
     305     
     306      /* Heli-Steuerung
     307         accel += (this->getAbsDirX()*2;
     308         if(
     309      */
    303310   }
    304311
Note: See TracChangeset for help on using the changeset viewer.