Changeset 10647 in orxonox.OLD
- Timestamp:
- May 3, 2007, 4:54:42 PM (18 years ago)
- Location:
- branches/hud/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/hud/src/defs/orxonox_globals.h
r10618 r10647 71 71 #define CONFIG_NAME_DEBUG_LEVEL "Debug-Level" 72 72 73 // even ets73 // events 74 74 #define CONFIG_NAME_PLAYER_FORWARD "Forward" 75 75 #define CONFIG_NAME_PLAYER_BACKWARD "Backward" … … 80 80 #define CONFIG_NAME_PLAYER_UP "Up" 81 81 #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" 82 86 83 87 #define CONFIG_NAME_PLAYER_FIRE "Fire" 88 #define CONFIG_NAME_PLAYER_FIRE2 "Fire2" 84 89 #define CONFIG_NAME_PLAYER_NEXT_WEAPON "Next-Weapon" 85 90 #define CONFIG_NAME_PLAYER_PREV_WEAPON "Previous-Weapon" -
branches/hud/src/lib/event/key_mapper.cc
r10618 r10647 46 46 int KeyMapper::PEV_STRAFE_RIGHT = EV_UNKNOWN; 47 47 int KeyMapper::PEV_JUMP = EV_UNKNOWN; 48 int KeyMapper::PEV_CROUCH = EV_UNKNOWN; 48 49 49 50 int KeyMapper::PEV_FIRE1 = EV_UNKNOWN; … … 82 83 {&KeyMapper::PEV_ROLL_RIGHT, CONFIG_NAME_PLAYER_ROLL_LEFT, SDLK_z}, 83 84 {&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}, 87 89 88 90 {&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}, 90 92 {&KeyMapper::PEV_NEXT_WEAPON, CONFIG_NAME_PLAYER_NEXT_WEAPON, EV_MOUSE_BUTTON_WHEELUP}, 91 93 {&KeyMapper::PEV_PREVIOUS_WEAPON, CONFIG_NAME_PLAYER_PREV_WEAPON, EV_MOUSE_BUTTON_WHEELDOWN}, -
branches/hud/src/lib/event/key_mapper.h
r9869 r10647 57 57 58 58 static int PEV_JUMP; //!< jump 59 static int PEV_CROUCH; //!< crouch 59 60 60 61 static int PEV_FIRE1; //!< fire button 1 -
branches/hud/src/world_entities/creatures/fps_player.cc
r10618 r10647 19 19 #include "interactive_model.h" 20 20 #include "state.h" 21 #include "tools/camera.h" 21 22 22 23 #include "src/lib/util/loading/factory.h" … … 117 118 registerEvent(KeyMapper::PEV_FIRE1); 118 119 registerEvent(KeyMapper::PEV_JUMP); 120 registerEvent(KeyMapper::PEV_CROUCH); 119 121 registerEvent(EV_MOUSE_MOTION); 120 122 … … 149 151 150 152 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); 152 155 153 156 … … 179 182 } 180 183 181 184 /** 185 * was probabably designed for setting direction of FPSPlayer 186 * but hey, this connot work like this, can it? 187 */ 182 188 void FPSPlayer::setPlayDirection(const Quaternion& quat, float speed) 183 189 { … … 186 192 } 187 193 188 194 /** 195 * Resets FPSPlayer stats and freezes its moving directions 196 * 197 */ 189 198 void FPSPlayer::reset() 190 199 { … … 199 208 } 200 209 201 210 /** 211 * Defines what happens to camera and other important elements when changing 212 * into FPS-view 213 */ 202 214 void FPSPlayer::enter() 203 215 { … … 206 218 State::getCameraNode()->setParentSoft(&this->cameraNode); 207 219 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); 211 226 212 227 if ( !State::isOnline() ) … … 216 231 } 217 232 233 /** 234 * Defines what happens if active player leaves FPSPlayer 235 * (basicly hides crosshair and frees camera) 236 */ 218 237 void FPSPlayer::leave() 219 238 { … … 239 258 this->getWeaponManager().getParentNode()->setParentMode(PNODE_ROTATE_AND_MOVE); 240 259 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); 242 262 243 263 … … 270 290 { 271 291 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); 272 293 } 273 294 … … 346 367 }*/ 347 368 369 348 370 velocity *= 100; 349 371 350 372 if( this->getModel( 0) != NULL && this->getModel(0)->isA(InteractiveModel::staticClassID())) 351 373 { 352 if( this->bJump) 353 { 354 if( this->jumpAcceleration < 1.0f) 374 if( this->bJump) 355 375 { 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 } 372 425 } 373 426 … … 390 443 this->fallVelocity = 0.0f; 391 444 } 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 { 394 448 velocity.normalize(); 395 449 velocity *= 10.0f; 396 450 this->shiftCoor( velocity ); 397 } 398 399 451 } 400 452 401 453 … … 426 478 427 479 /** 428 * process480 * checks events 429 481 */ 430 482 void FPSPlayer::process(const Event &event) … … 440 492 else if( event.type == KeyMapper::PEV_BACKWARD) 441 493 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; 442 500 else if( event.type == EV_MOUSE_MOTION) 443 501 { … … 445 503 this->yMouse += event.yRel; 446 504 } 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 */ 458 510 void FPSPlayer::respawn( ) 459 511 { … … 466 518 } 467 519 468 520 /** 521 * Kills the FPSplayer defining its killer 522 */ 469 523 void FPSPlayer::destroy( WorldEntity* killer ) 470 524 { -
branches/hud/src/world_entities/creatures/fps_player.h
r10566 r10647 43 43 void init(); 44 44 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 52 53 53 float xMouse; 54 float yMouse; 54 float xMouse; //!< mouse moved in x-Direction 55 float yMouse; //!< mouse moved in y-Direction 55 56 56 57 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 59 60 60 PNode cameraNode; 61 PNode cameraNode; //!< the "eyes" of the player (or call it head if you want) 61 62 62 float fallVelocity; 63 float jumpAcceleration; 63 float fallVelocity; //!< velocity for falling down 64 float jumpAcceleration; //!< the jump acceleration 64 65 65 66 bool initWeapon; 66 67 67 AimingSystem* aimingSystem; 68 AimingSystem* aimingSystem; //!< aiming system of the player 68 69 69 float damageTicker; //!< ticker for dealing damage 70 float damageTicker; //!< ticker for dealing damage 71 70 72 }; 71 73 -
branches/hud/src/world_entities/tools/camera.cc
r10618 r10647 203 203 this->setRelCoor(Vector(-0.05, this->viewTopDistance , 0)); 204 204 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); 205 213 } 206 214 } -
branches/hud/src/world_entities/tools/camera.h
r10618 r10647 34 34 ViewLeft, 35 35 ViewRight, 36 ViewTop 36 ViewTop, 37 ViewFPS 37 38 }; 38 39 public:
Note: See TracChangeset
for help on using the changeset viewer.