Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10654 in orxonox.OLD for branches/hud/src/world_entities/creatures


Ignore:
Timestamp:
May 12, 2007, 12:13:13 AM (18 years ago)
Author:
bknecht
Message:

Implemented zooming function

Location:
branches/hud/src/world_entities/creatures
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/hud/src/world_entities/creatures/fps_player.cc

    r10647 r10654  
    9696  this->bPosBut = false;
    9797  this->bFire = false;
     98  this->bFire2 = false;
     99  this->changeZoom = true;
     100  this->inZoomMode = false;
     101  this->changingZoom = false;
    98102
    99103  this->xMouse = 0.0f;
     
    117121  registerEvent(KeyMapper::PEV_RIGHT);
    118122  registerEvent(KeyMapper::PEV_FIRE1);
     123  registerEvent(KeyMapper::PEV_FIRE2);
    119124  registerEvent(KeyMapper::PEV_JUMP);
    120125  registerEvent(KeyMapper::PEV_CROUCH);
     
    204209  this->xMouse = 0.0f;
    205210  this->yMouse = 0.0f;
     211  this->inZoomMode = false;
    206212
    207213  this->setHealth(80);
     
    249255void FPSPlayer::tick (float time)
    250256{
    251 
     257     // Second init-step
    252258  if ( !this->initWeapon )
    253259  {
     
    271277    }
    272278
    273 
    274     AABB* box = this->getModelAABB();
    275     if( box != NULL)
    276     {
     279  }
     280  // end of second init-step
     281 
     282  // This box represents the dimension of the used model
     283  AABB* box = this->getModelAABB();
     284
     285  if( box != NULL)
     286  {
    277287      float f = 1.0;
     288      if( this->bCrouch )
     289          f = 0.3*f;
     290     
    278291      this->cameraNode.setRelCoor(0, box->halfLength[1] * f, 0);
    279 //       this->cameraNode.setRelCoor(10, box->halfLength[1] * f, 0);
    280 
    281       float v = 0.1f;
    282       this->getWeaponManager().setSlotPosition(0, Vector(-8.0, box->halfLength[1] * v, 1.1));
    283       this->getWeaponManager().setSlotPosition(1, Vector(5.0, box->halfLength[1] * v, 0.0));
    284     }
    285   }
    286 
     292//      this->cameraNode.setRelCoor(10, box->halfLength[1] * f, 0);
     293     float v = 0.1f;
     294     this->getWeaponManager().setSlotPosition(0, Vector(-8.0, box->halfLength[1] * v, 1.1));
     295     this->getWeaponManager().setSlotPosition(1, Vector(5.0, box->halfLength[1] * v, 0.0));
     296  }
     297 
     298  /*
     299  if( this->bFire2 )
     300  {
     301     
     302      // to change Zoom on click
     303      if( this->changeZoom )
     304      {
     305          this->changeZoom = false;
     306          if( this->inZoomMode )
     307          {
     308              State::getCamera()->setViewMode(Camera::ViewFPS);
     309              this->inZoomMode = false;
     310          }
     311          else
     312          {
     313              State::getCamera()->setViewMode(Camera::ViewFPSZoom);
     314              this->inZoomMode = true;
     315          }
     316         
     317      }
     318     
     319  }
     320  else
     321  {
     322      this->changeZoom = true;
     323  }*/
     324  if( this->bFire2 )
     325  {
     326      if( this->changeZoom )
     327      {
     328          if( !this->inZoomMode || this->changingZoom )
     329          {
     330              this->inZoomMode = true;
     331              this->changingZoom = true;
     332              float fovy = State::getCamera()->getFovy();
     333              if( fovy > 30 )
     334                  State::getCamera()->setFovy( fovy - 10*time );
     335          }
     336          else
     337          {
     338                State::getCamera()->setViewMode(Camera::ViewFPS);
     339                this->inZoomMode = false;
     340                this->changeZoom = false;
     341          }
     342      }
     343  }
     344  else
     345  {
     346      this->changeZoom = true;
     347      this->changingZoom = false;
     348  }
    287349
    288350  this->getWeaponManager().tick(time);
     
    322384    xMouse *= time ;
    323385    yMouse *= time ;
    324 
    325     heading -= xMouse/5.;
    326     attitude-= yMouse/5.;
     386   
     387    float amount;
     388   
     389    if( this->inZoomMode )
     390        amount = 2.;
     391    else
     392        amount = 5.;
     393
     394    heading -= xMouse/amount;
     395    attitude-= yMouse/amount;
    327396
    328397
     
    367436    }*/
    368437
    369 
    370   velocity *= 100;
     438  int speed;
     439  if( this->bCrouch )
     440      speed = 50;
     441  else
     442      speed = 100;
     443  velocity *= speed;
    371444
    372445  if( this->getModel( 0) != NULL && this->getModel(0)->isA(InteractiveModel::staticClassID()))
     
    461534  if( this->aimingSystem != NULL)
    462535    this->aimingSystem->flushList();
     536   
    463537}
    464538
     
    496570  else if( event.type == KeyMapper::PEV_FIRE1)
    497571    this->bFire = event.bPressed;
     572  else if( event.type == KeyMapper::PEV_FIRE2)
     573    this->bFire2 = event.bPressed;
    498574  else if( event.type == KeyMapper::PEV_CROUCH)
    499575    this->bCrouch = event.bPressed;
  • branches/hud/src/world_entities/creatures/fps_player.h

    r10647 r10654  
    5050    bool                  bPosBut;           //!< position button
    5151    bool                  bFire;             //!< fire button
     52    bool                  bFire2;            //!< alternate fire button
    5253    bool                  bCrouch;           //!< crouch button
    5354
     
    6566
    6667    bool                  initWeapon;
     68    bool                  changeZoom;        //!< zoom sight of player
     69    bool                  inZoomMode;        //!< zoomsight
     70    bool                  changingZoom;
    6771
    6872    AimingSystem*         aimingSystem;      //!< aiming system of the player
Note: See TracChangeset for help on using the changeset viewer.