Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6605 in orxonox.OLD


Ignore:
Timestamp:
Jan 18, 2006, 5:50:18 PM (18 years ago)
Author:
bknecht
Message:

Control: Implementation of Hovercraftcontrol

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

Legend:

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

    r6580 r6605  
    118118  xMouse = yMouse = 0;
    119119  mouseSensitivity = 0.05;
    120   //rotorspeed = 1;
    121   //tailrotorspeed = 0;
    122 
    123   //cycle = 0.0;
    124 
    125 
    126   //travelSpeed = 15.0;
     120
     121
    127122  this->velocity = Vector(0.0,0.0,0.0);
    128123  this->velocityDir = Vector(1.0,0.0,0.0);
     
    138133  registerEvent(KeyMapper::PEV_LEFT);
    139134  registerEvent(KeyMapper::PEV_RIGHT);
    140   //registerEvent(SDLK_q);
    141135  registerEvent(SDLK_e);
    142136  registerEvent(SDLK_c);
     
    144138  registerEvent(KeyMapper::PEV_NEXT_WEAPON);
    145139  registerEvent(KeyMapper::PEV_PREVIOUS_WEAPON);
    146   //registerEvent(SDLK_PAGEUP);
    147   //registerEvent(SDLK_PAGEDOWN);
    148140  registerEvent(EV_MOUSE_MOTION);
    149141
     
    249241void Hover::tick (float time)
    250242{
    251   /*
    252   tailrotorspeed += xMouse/20;
    253   if (tailrotorspeed >= 0.07) tailrotorspeed = 0.07;
    254   else if (tailrotorspeed <= -0.07) tailrotorspeed = -0.07;
    255 
    256   if (tailrotorspeed > 0.0008) tailrotorspeed -= 0.001;
    257   else if (tailrotorspeed < -0.0008) tailrotorspeed += 0.001;
    258   if (tailrotorspeed <= 0.001 && tailrotorspeed >= -0.001) tailrotorspeed = 0;
    259   */
     243 
     244 
     245  Quaternion xDir = Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0));
     246  Quaternion yDir = Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1));
     247   
     248  if ((this->getAbsDirY()).y < 0.8)
     249  {
     250     if((this->getAbsDirX()).y > 0)
     251     {
     252        if(yMouse > 0)  this->shiftDir(xDir*yDir);
     253        else this->shiftDir(xDir);
     254     }
     255     else
     256     {
     257         if(yMouse < 0) this->shiftDir(xDir*yDir);
     258         else this->shiftDir(xDir);
     259     }
     260  }
     261  else this->shiftDir(xDir*yDir);
     262 
     263  if((this->getAbsDirZ()).y > 0.1) this->shiftDir(Quaternion(0.01,Vector(1,0,0)));
     264  else if((this->getAbsDirZ()).y < -0.1) this->shiftDir(Quaternion(-0.01,Vector(1,0,0)));
     265
    260266 
    261267  // spaceship controlled movement
     
    266272  // this is the air friction (necessary for a smooth control)
    267273  if(velocity.len() != 0) velocity -= velocity*0.1;
    268  
    269   //travelSpeed = velocity.len();
    270 
    271   //physics: Gravity
    272   /*this->shiftCoor(Vector(0,-1,0));
    273 
    274   this->shiftCoor(getAbsDirY()*rotorspeed);
    275   */
    276  
    277   /*
    278   //hoover effect
    279   cycle += time;
    280   this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02);
    281   */
    282274
    283275  //readjust
     
    313305     
    314306     accel += Vector((this->getAbsDirX()).x,0,(this->getAbsDirX()).z);
    315      if((this->getAbsDirX()).y >= -0.1) rotValZ -= time;
    316    }
    317    else
    318    {
    319        if(this->getAbsDirX().y < -.02) this->shiftDir(Quaternion(time, Vector(0,0,1)));
     307     //if((this->getAbsDirX()).y >= -0.1) rotValZ -= time;
    320308   }
    321309
     
    326314     
    327315     accel -= Vector((this->getAbsDirX()).x,0,(this->getAbsDirX()).z);
    328      rotValZ += time;
    329    }
    330    else
    331    {
    332          if(this->getAbsDirX().y > 0.02) this->shiftDir(Quaternion(-time, Vector(0,0,1)));
     316     //rotValZ += time;
    333317   }
    334318
     
    340324   
    341325    accel -= Vector((this->getAbsDirZ()).x,0,(this->getAbsDirZ()).z);
    342     rotValX -= time;
    343   }
    344   else
    345    {
    346          if(this->getAbsDirZ().y > 0.02) this->shiftDir(Quaternion(time, Vector(1,0,0)));
    347    }
     326    //rotValX -= time;
     327  }
    348328
    349329  if( this->bRight /* > this->getRelCoor().z*2*/)
     
    354334   
    355335    accel += Vector((this->getAbsDirZ()).x,0,(this->getAbsDirZ()).z);
    356     rotValX += time;
    357   }
    358   else
    359    {
    360          if(this->getAbsDirZ().y < -0.02) this->shiftDir(Quaternion(-time, Vector(1,0,0)));
    361    }
     336    //rotValX += time;
     337  }
    362338
    363339  if( this->bRollL /* > -this->getRelCoor().z*2*/)
     
    410386  }
    411387
    412   velocity += accel*3;
    413   if((this->getAbsDirX()).y <= 0.3 && (this->getAbsDirX()).y >= -0.3) this->shiftDir(Quaternion(rotValZ, Vector(0,0,1)));
    414   if((this->getAbsDirZ()).y <= 0.3 && (this->getAbsDirZ()).y >= -0.3) this->shiftDir(Quaternion(rotValX, Vector(1,0,0)));
     388  velocity += accel*4;
     389  //if((this->getAbsDirX()).y <= 0.3 && (this->getAbsDirX()).y >= -0.3) this->shiftDir(Quaternion(rotValZ, Vector(0,0,1)));
     390  //if((this->getAbsDirZ()).y <= 0.3 && (this->getAbsDirZ()).y >= -0.3) this->shiftDir(Quaternion(rotValX, Vector(1,0,0)));
    415391}
    416392
     
    464440    this->xMouse = event.xRel*mouseSensitivity;
    465441    this->yMouse = event.yRel*mouseSensitivity;
    466 
    467     this->shiftDir(Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))/*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1))*/);
    468442  }
    469443}
  • branches/spaceshipcontrol/src/world_entities/space_ships/hover.h

    r6572 r6605  
    5858    float                 yMouse;             //!< mouse moved in y-Direction
    5959    float                 mouseSensitivity;   //!< the mouse sensitivity
    60     //float                 cycle;              //!< hovercycle
    6160
    6261    Vector                velocity;           //!< the velocity of the player.
     
    6463    float                 travelSpeed;        //!< the current speed of the player (to make soft movement)
    6564    float                 acceleration;       //!< the acceleration of the player.
    66     //float                 rotorspeed;         //!< the speed of the rotor.
    67     //float                 tailrotorspeed;     //!< the relativ speed ot the tail rotor
    68 
     65   
    6966    float                 airViscosity;
    7067
Note: See TracChangeset for help on using the changeset viewer.