Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 3, 2007, 4:54:42 PM (18 years ago)
Author:
bknecht
Message:

Camera:

  • Added new ViewMode ViewFPS

FPSPlayer:

  • fixed crosshair bug

FPSPlayer/KeyMapper/Globals:

  • started to implement crouch function
File:
1 edited

Legend:

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

    r10618 r10647  
    1919#include "interactive_model.h"
    2020#include "state.h"
     21#include "tools/camera.h"
    2122
    2223#include "src/lib/util/loading/factory.h"
     
    117118  registerEvent(KeyMapper::PEV_FIRE1);
    118119  registerEvent(KeyMapper::PEV_JUMP);
     120  registerEvent(KeyMapper::PEV_CROUCH);
    119121  registerEvent(EV_MOUSE_MOTION);
    120122
     
    149151
    150152  this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode);
    151   this->getWeaponManager().getFixedTarget()->setRelCoor(1000,0,0);
     153  this->getWeaponManager().getFixedTarget()->setParentMode(PNODE_ALL);
     154  this->getWeaponManager().getFixedTarget()->setRelCoor(10,0,0);
    152155
    153156
     
    179182}
    180183
    181 
     184/**
     185 * was probabably designed for setting direction of FPSPlayer
     186 * but hey, this connot work like this, can it?
     187 */
    182188void FPSPlayer::setPlayDirection(const Quaternion& quat, float speed)
    183189{
     
    186192}
    187193
    188 
     194/**
     195 * Resets FPSPlayer stats and freezes its moving directions
     196 *
     197 */
    189198void FPSPlayer::reset()
    190199{
     
    199208}
    200209
    201 
     210/**
     211 * Defines what happens to camera and other important elements when changing
     212 * into FPS-view
     213 */
    202214void FPSPlayer::enter()
    203215{
     
    206218  State::getCameraNode()->setParentSoft(&this->cameraNode);
    207219  State::getCameraTargetNode()->setParentSoft(&this->cameraNode);
    208 
    209   this->getWeaponManager().getFixedTarget()->setParent(State::getCameraTargetNode());
    210   this->getWeaponManager().getFixedTarget()->setRelCoor(0,0,0);
     220 
     221  State::getCamera()->setViewMode(Camera::ViewFPS);
     222 
     223  this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode);
     224  //this->getWeaponManager().getFixedTarget()->setParentMode(PNODE_ALL);
     225  //this->getWeaponManager().getFixedTarget()->setRelCoor(100,0,0);
    211226
    212227  if ( !State::isOnline() )
     
    216231}
    217232
     233/**
     234 * Defines what happens if active player leaves FPSPlayer
     235 * (basicly hides crosshair and frees camera)
     236 */
    218237void FPSPlayer::leave()
    219238{
     
    239258    this->getWeaponManager().getParentNode()->setParentMode(PNODE_ROTATE_AND_MOVE);
    240259    this->getWeaponManager().getFixedTarget()->setParent(&this->cameraNode);
    241     this->getWeaponManager().getFixedTarget()->setParentMode(PNODE_ROTATE_AND_MOVE);
     260    //this->getWeaponManager().getFixedTarget()->setParentMode(PNODE_ROTATE_AND_MOVE);
     261    State::getCamera()->setViewMode(Camera::ViewFPS);
    242262
    243263
     
    270290  {
    271291    this->getWeaponManager().fire();
     292    PRINTF(0)("Crosshair at position: %f, %f, %f\n", this->getWeaponManager().getFixedTarget()->getAbsCoor().x, this->getWeaponManager().getFixedTarget()->getAbsCoor().y, this->getWeaponManager().getFixedTarget()->getAbsCoor().z);
    272293  }
    273294
     
    346367    }*/
    347368
     369
    348370  velocity *= 100;
    349371
    350372  if( this->getModel( 0) != NULL && this->getModel(0)->isA(InteractiveModel::staticClassID()))
    351373  {
    352     if( this->bJump)
    353     {
    354       if( this->jumpAcceleration < 1.0f)
     374      if( this->bJump)
    355375      {
    356         this->jumpAcceleration = 300.0f;
    357 
    358         if( ((InteractiveModel*)this->getModel(0))->getAnimation() != JUMP)
    359           ((InteractiveModel*)this->getModel(0))->setAnimation(JUMP);
    360       }
    361     }
    362     else if(velocity.len() != 0.0f)
    363     {
    364       if( ((InteractiveModel*)this->getModel(0))->getAnimation() != RUN)
    365         ((InteractiveModel*)this->getModel(0))->setAnimation(RUN);
    366     }
    367     else
    368     {
    369       if( ((InteractiveModel*)this->getModel(0))->getAnimation() != STAND)
    370         ((InteractiveModel*)this->getModel(0))->setAnimation(STAND);
    371     }
     376          if( this->jumpAcceleration < 1.0f)
     377          {
     378              this->jumpAcceleration = 300.0f;
     379
     380              if( ((InteractiveModel*)this->getModel(0))->getAnimation() != JUMP)
     381                  ((InteractiveModel*)this->getModel(0))->setAnimation(JUMP);
     382          }
     383       }
     384       else if(velocity.len() != 0.0f)
     385       {
     386            if( this->bCrouch )
     387            {
     388                if( ((InteractiveModel*)this->getModel(0))->getAnimation() != CROUCH_WALK)
     389                    ((InteractiveModel*)this->getModel(0))->setAnimation(CROUCH_WALK);
     390            }
     391            else
     392            {
     393                if( ((InteractiveModel*)this->getModel(0))->getAnimation() != RUN)
     394                    ((InteractiveModel*)this->getModel(0))->setAnimation(RUN);
     395            }
     396                 
     397       }
     398       else
     399       {
     400           if( this->bCrouch )
     401           {
     402               if( ((InteractiveModel*)this->getModel(0))->getAnimation() != CROUCH_STAND)
     403                   ((InteractiveModel*)this->getModel(0))->setAnimation(CROUCH_STAND);
     404           }
     405           else
     406           {
     407               if( ((InteractiveModel*)this->getModel(0))->getAnimation() != STAND)
     408                   ((InteractiveModel*)this->getModel(0))->setAnimation(STAND);
     409           }
     410       }
     411       
     412       if( this->bFire )
     413       {
     414           if( this->bCrouch )
     415           {
     416               if( ((InteractiveModel*)this->getModel(0))->getAnimation() != CROUCH_ATTACK)
     417                   ((InteractiveModel*)this->getModel(0))->setAnimation(CROUCH_ATTACK);
     418           }
     419           else
     420           {
     421               if( ((InteractiveModel*)this->getModel(0))->getAnimation() != ATTACK)
     422                   ((InteractiveModel*)this->getModel(0))->setAnimation(ATTACK);
     423           }
     424       }
    372425  }
    373426
     
    390443    this->fallVelocity = 0.0f;
    391444  }
    392   if((velocity *time).len() < 10.0f) this->shiftCoor( velocity*time );
    393   else{ 
     445  if((velocity * time).len() < 10.0f) this->shiftCoor( velocity*time );
     446  else
     447  {     
    394448         velocity.normalize();
    395449         velocity *= 10.0f;
    396450         this->shiftCoor( velocity );
    397        }
    398 
    399 
     451  }
    400452
    401453
     
    426478
    427479/**
    428  * process
     480 * checks events
    429481 */
    430482void FPSPlayer::process(const Event &event)
     
    440492  else if( event.type == KeyMapper::PEV_BACKWARD)
    441493    this->bBackward = event.bPressed; //this->shiftCoor(0,-.1,0);
     494  else if( event.type == KeyMapper::PEV_JUMP)
     495    this->bJump = event.bPressed;
     496  else if( event.type == KeyMapper::PEV_FIRE1)
     497    this->bFire = event.bPressed;
     498  else if( event.type == KeyMapper::PEV_CROUCH)
     499    this->bCrouch = event.bPressed;
    442500  else if( event.type == EV_MOUSE_MOTION)
    443501  {
     
    445503    this->yMouse += event.yRel;
    446504  }
    447   else if( event.type == KeyMapper::PEV_JUMP)
    448   {
    449     this->bJump = event.bPressed;
    450   }
    451   else if( event.type == KeyMapper::PEV_FIRE1)
    452   {
    453     this->bFire = event.bPressed;
    454   }
    455 }
    456 
    457 
     505}
     506
     507/**
     508 * respawns FPSplayer
     509 */
    458510void FPSPlayer::respawn( )
    459511{
     
    466518}
    467519
    468 
     520/**
     521 * Kills the FPSplayer defining its killer
     522 */
    469523void FPSPlayer::destroy( WorldEntity* killer )
    470524{
Note: See TracChangeset for help on using the changeset viewer.