Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10647 in orxonox.OLD


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
Location:
branches/hud/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/hud/src/defs/orxonox_globals.h

    r10618 r10647  
    7171#define   CONFIG_NAME_DEBUG_LEVEL          "Debug-Level"
    7272
    73 // evenets
     73// events
    7474#define   CONFIG_NAME_PLAYER_FORWARD       "Forward"
    7575#define   CONFIG_NAME_PLAYER_BACKWARD      "Backward"
     
    8080#define   CONFIG_NAME_PLAYER_UP            "Up"
    8181#define   CONFIG_NAME_PLAYER_DOWN          "Down"
     82#define   CONFIG_NAME_PLAYER_STRAFE_LEFT   "StrafeLeft"
     83#define   CONFIG_NAME_PLAYER_STRAFE_RIGHT  "StrafeRight"
     84#define   CONFIG_NAME_PLAYER_JUMP          "Jump"
     85#define   CONFIG_NAME_PLAYER_CROUCH        "Crouch"
    8286
    8387#define   CONFIG_NAME_PLAYER_FIRE          "Fire"
     88#define   CONFIG_NAME_PLAYER_FIRE2         "Fire2"
    8489#define   CONFIG_NAME_PLAYER_NEXT_WEAPON   "Next-Weapon"
    8590#define   CONFIG_NAME_PLAYER_PREV_WEAPON   "Previous-Weapon"
  • branches/hud/src/lib/event/key_mapper.cc

    r10618 r10647  
    4646int KeyMapper::PEV_STRAFE_RIGHT      = EV_UNKNOWN;
    4747int KeyMapper::PEV_JUMP              = EV_UNKNOWN;
     48int KeyMapper::PEV_CROUCH            = EV_UNKNOWN;
    4849
    4950int KeyMapper::PEV_FIRE1             = EV_UNKNOWN;
     
    8283      {&KeyMapper::PEV_ROLL_RIGHT,           CONFIG_NAME_PLAYER_ROLL_LEFT,       SDLK_z},
    8384      {&KeyMapper::PEV_ROLL_LEFT,            CONFIG_NAME_PLAYER_ROLL_RIGHT,      SDLK_c},
    84       {&KeyMapper::PEV_STRAFE_LEFT,          "StrafeLeft",                       SDLK_q},
    85       {&KeyMapper::PEV_STRAFE_RIGHT,         "StrafeRight",                      SDLK_e},
    86       {&KeyMapper::PEV_JUMP,                 "Jump",                             SDLK_SPACE},
     85      {&KeyMapper::PEV_STRAFE_LEFT,          CONFIG_NAME_PLAYER_STRAFE_LEFT,     SDLK_q},
     86      {&KeyMapper::PEV_STRAFE_RIGHT,         CONFIG_NAME_PLAYER_STRAFE_RIGHT,    SDLK_e},
     87      {&KeyMapper::PEV_JUMP,                 CONFIG_NAME_PLAYER_JUMP,            SDLK_SPACE},
     88      {&KeyMapper::PEV_CROUCH,               CONFIG_NAME_PLAYER_CROUCH,          SDLK_LCTRL},
    8789
    8890      {&KeyMapper::PEV_FIRE1,                CONFIG_NAME_PLAYER_FIRE,            EV_MOUSE_BUTTON_LEFT},
    89       {&KeyMapper::PEV_FIRE2,                "Fire2",                            EV_MOUSE_BUTTON_RIGHT},
     91      {&KeyMapper::PEV_FIRE2,                CONFIG_NAME_PLAYER_FIRE2,           EV_MOUSE_BUTTON_RIGHT},
    9092      {&KeyMapper::PEV_NEXT_WEAPON,          CONFIG_NAME_PLAYER_NEXT_WEAPON,     EV_MOUSE_BUTTON_WHEELUP},
    9193      {&KeyMapper::PEV_PREVIOUS_WEAPON,      CONFIG_NAME_PLAYER_PREV_WEAPON,     EV_MOUSE_BUTTON_WHEELDOWN},
  • branches/hud/src/lib/event/key_mapper.h

    r9869 r10647  
    5757
    5858  static int PEV_JUMP;              //!< jump
     59  static int PEV_CROUCH;            //!< crouch
    5960
    6061  static int PEV_FIRE1;             //!< fire button 1
  • 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{
  • branches/hud/src/world_entities/creatures/fps_player.h

    r10566 r10647  
    4343    void init();
    4444
    45     bool                  bLeft;
    46     bool                  bRight;
    47     bool                  bForward;
    48     bool                  bBackward;
    49     bool                  bJump;              //!< jumping
    50     bool                  bPosBut;             //!< position button
    51     bool                  bFire;              //!< fire button
     45    bool                  bLeft;             //!< strafe left
     46    bool                  bRight;            //!< strafe right
     47    bool                  bForward;          //!< walk forward
     48    bool                  bBackward;         //!< walk backward
     49    bool                  bJump;             //!< jumping
     50    bool                  bPosBut;           //!< position button
     51    bool                  bFire;             //!< fire button
     52    bool                  bCrouch;           //!< crouch button
    5253
    53     float                 xMouse;             //!< mouse moved in x-Direction
    54     float                 yMouse;             //!< mouse moved in y-Direction
     54    float                 xMouse;            //!< mouse moved in x-Direction
     55    float                 yMouse;            //!< mouse moved in y-Direction
    5556
    5657
    57     float                 heading;
    58     float                 attitude;
     58    float                 heading;           //!< the direction where the player heads to
     59    float                 attitude;          //!< defines the camera angle to the x-z-plane
    5960
    60     PNode                 cameraNode;
     61    PNode                 cameraNode;        //!< the "eyes" of the player (or call it head if you want)
    6162
    62     float                 fallVelocity;        //!< velocity for falling down
    63     float                 jumpAcceleration;    //!< the jump acceleration
     63    float                 fallVelocity;      //!< velocity for falling down
     64    float                 jumpAcceleration;  //!< the jump acceleration
    6465
    6566    bool                  initWeapon;
    6667
    67     AimingSystem*         aimingSystem;        //!< aiming system of the player
     68    AimingSystem*         aimingSystem;      //!< aiming system of the player
    6869
    69     float                 damageTicker;        //!< ticker for dealing damage
     70    float                 damageTicker;      //!< ticker for dealing damage
     71   
    7072};
    7173
  • branches/hud/src/world_entities/tools/camera.cc

    r10618 r10647  
    203203      this->setRelCoor(Vector(-0.05, this->viewTopDistance , 0));
    204204      this->target->setRelCoor(0,0,0);
     205      break;
     206    }
     207    case Camera::ViewFPS:
     208    {
     209      this->fovy = viewNormalFovy;
     210      this->toFovy = viewNormalFovy;
     211      this->setRelCoorSoft(this->viewFrontDistance, 0, 0, 5);
     212      this->target->setRelCoorSoft(Vector(10,0,0), 5);
    205213    }
    206214  }
  • branches/hud/src/world_entities/tools/camera.h

    r10618 r10647  
    3434    ViewLeft,
    3535    ViewRight,
    36     ViewTop
     36    ViewTop,
     37    ViewFPS
    3738  };
    3839  public:
Note: See TracChangeset for help on using the changeset viewer.