Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 20, 2005, 4:42:53 PM (19 years ago)
Author:
patrick
Message:

christmas: some work on the creature control. not yet finished

Location:
branches/christmas_branche/src/world_entities
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/christmas_branche/src/world_entities/creatures/md2_creature.cc

    r6181 r6195  
    115115  EventHandler::getInstance()->grabEvents(true);
    116116
    117   bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = false;
     117  bUp = bDown = bLeft = bRight = bAscend = bDescend = bRollL = bRollR = bStrafeL = bStrafeR = false;
    118118  bFire = false;
    119119  xMouse = yMouse = 0;
    120   mouseSensitivity = 0.001;
    121   airViscosity = 1.0;
     120  mouseSensitivity = 0.003;
     121  airViscosity = 0.0;
    122122  cycle = 0.0;
    123123
     
    241241}
    242242
     243
    243244/**
    244245 *  the function called for each passing timeSnap
     
    251252
    252253
    253 
    254 
    255254  // MD2Creature controlled movement
    256255  this->calculateVelocity(time);
    257 
    258   Vector move = (velocity)*time;
    259 
    260   //orient the velocity in the direction of the MD2Creature.
    261   travelSpeed = velocity.len();
    262   velocity += ((this->getAbsDirX())*travelSpeed-velocity)*airViscosity;
    263   velocity = (velocity.getNormalized())*travelSpeed;
     256  Vector move = this->velocity * time;
     257  this->shiftCoor (move);
    264258
    265259  //orient the MD2Creature in direction of the mouse
    266    rotQuat = Quaternion::quatSlerp( this->getAbsDir(),mouseDir,fabsf(time)*3);
    267    if (this->getAbsDir().distance(rotQuat) > 0.001)
    268     this->setAbsDir( rotQuat);
    269    //this->setAbsDirSoft(mouseDir,5);
    270 
    271   // this is the air friction (necessary for a smooth control)
    272   if(velocity.len() != 0) velocity -= velocity*0.01;
    273 
    274   //hoover effect
    275   cycle += time;
    276   this->shiftCoor(Vector(0,1,0)*cos(this->cycle*2.0)*0.02);
    277 
    278   //readjust
    279  // if (this->getAbsDirZ().y > 0.1) this->shiftDir(Quaternion(time*0.3, Vector(1,0,0)));
    280   //else if (this->getAbsDirZ().y < -0.1) this->shiftDir(Quaternion(-time*0.3, Vector(1,0,0)));
    281 
    282   //SDL_WarpMouse(GraphicsEngine::getInstance()->getResolutionX()/2, GraphicsEngine::getInstance()->getResolutionY()/2);
    283 
    284   this->shiftCoor (move);
     260  this->setAbsDir( /*rotQuat*/ mouseDir);
    285261
    286262  this->getWeaponManager()->tick(time);
     
    306282  if( this->bUp )
    307283   {
    308      //this->shiftCoor(this->getAbsDirX());
    309284      accel += (this->getAbsDirX())*2;
    310 
    311       /* Heli-Steuerung
    312          accel += (this->getAbsDirX()*2;
    313          if(
    314       */
    315285   }
    316286
    317287  if( this->bDown )
    318288   {
    319      //this->shiftCoor((this->getAbsDirX())*-1);
    320289     accel -= (this->getAbsDirX())*2;
    321290   }
     
    324293  {
    325294    this->shiftDir(Quaternion(time, Vector(0,1,0)));
    326 //    accel -= rightDirection;
    327     //velocityDir.normalize();
    328     //rot +=Vector(1,0,0);
    329     //rotVal -= .4;
    330295  }
    331296  if( this->bRight /* > this->getRelCoor().z*2*/)
    332297  {
    333298    this->shiftDir(Quaternion(-time, Vector(0,1,0)));
    334 
    335     //    accel += rightDirection;
    336     //velocityDir.normalize();
    337     //rot += Vector(1,0,0);
    338     //rotVal += .4;
    339   }
    340 
    341 
    342   if( this->bRollL /* > -this->getRelCoor().z*2*/)
    343   {
    344     mouseDir *= Quaternion(-time, Vector(1,0,0));
    345 //    accel -= rightDirection;
    346     //velocityDir.normalize();
    347     //rot +=Vector(1,0,0);
    348     //rotVal -= .4;
    349   }
    350   if( this->bRollR /* > this->getRelCoor().z*2*/)
    351   {
    352     mouseDir *= Quaternion(time, Vector(1,0,0));
    353 
    354     //    accel += rightDirection;
    355     //velocityDir.normalize();
    356     //rot += Vector(1,0,0);
    357     //rotVal += .4;
     299  }
     300
     301
     302  if( this->bStrafeL /* > -this->getRelCoor().z*2*/)
     303  {
     304    accel -= this->getAbsDirZ() * 2.0f;
     305  }
     306  if( this->bStrafeR /* > this->getRelCoor().z*2*/)
     307  {
     308    accel += this->getAbsDirZ() * 2.0f;
    358309  }
    359310  if (this->bAscend )
    360311  {
    361312    this->shiftDir(Quaternion(time, Vector(0,0,1)));
    362 
    363 //    accel += upDirection;
    364     //velocityDir.normalize();
    365     //rot += Vector(0,0,1);
    366     //rotVal += .4;
    367313  }
    368314  if (this->bDescend )
    369315  {
    370316    this->shiftDir(Quaternion(-time, Vector(0,0,1)));
    371 
    372     //    accel -= upDirection;
    373     //velocityDir.normalize();
    374     //rot += Vector(0,0,1);
    375     //rotVal -= .4;
    376   }
    377 
    378   velocity += accel;
     317  }
     318
     319  velocity = accel * 30.0f;
    379320  //rot.normalize();
    380321  //this->setRelDirSoft(Quaternion(rotVal, rot), 5);
    381322}
     323
    382324
    383325/**
     
    397339void MD2Creature::process(const Event &event)
    398340{
    399 
    400 
    401341  if( event.type == SDLK_a)
    402       this->bRollL = event.bPressed;
     342      this->bStrafeL = event.bPressed;
    403343  else if( event.type == SDLK_d)
    404       this->bRollR = event.bPressed;
     344      this->bStrafeR = event.bPressed;
    405345  else if( event.type == KeyMapper::PEV_FIRE1)
    406346      this->bFire = event.bPressed;
     
    417357  {
    418358    this->xMouse = event.xRel;
    419     this->yMouse = event.yRel;
    420     mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0))*Quaternion(-M_PI/4*yMouse*mouseSensitivity, Vector(0,0,1)));
    421     if( xMouse*xMouse + yMouse*yMouse < 0.9)
    422      this->setAbsDir(mouseDir);
     359    mouseDir *= (Quaternion(-M_PI/4*xMouse*mouseSensitivity, Vector(0,1,0)));
     360//     if( xMouse*xMouse < 0.9)
     361//      this->setAbsDir(mouseDir);
    423362  }
    424363}
  • branches/christmas_branche/src/world_entities/creatures/md2_creature.h

    r6166 r6195  
    5858    bool                  bRollL;             //!< rolling button pressed (left)
    5959    bool                  bRollR;             //!< rolling button pressed (right)
     60    bool                  bStrafeL;           //!< strafe to the left side
     61    bool                  bStrafeR;           //!< strafe to the rith side
    6062
    6163    float                 xMouse;             //!< mouse moved in x-Direction
  • branches/christmas_branche/src/world_entities/world_entity.cc

    r6191 r6195  
    138138    {
    139139      PRINTF(4)("fetching MD2 file: %s\n", fileName);
    140 //         MD2Model* m = (MD2Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN);
    141140      Model* m = new MD2Model(fileName, this->md2TextureFileName);
    142141        //this->setModel((Model*)ResourceManager::getInstance()->load(fileName, MD2, RP_CAMPAIGN), 0);
Note: See TracChangeset for help on using the changeset viewer.