diff --git a/Sources/Client/Client.h b/Sources/Client/Client.h index e226928e..bfd658b8 100644 --- a/Sources/Client/Client.h +++ b/Sources/Client/Client.h @@ -138,6 +138,7 @@ namespace spades { KeypadInput keypadInput; Player::ToolType lastTool; bool hasLastTool; + bool FirstPersonSpectate; Vector3 lastFront; float lastPosSentTime; int lastHealth; diff --git a/Sources/Client/Client_Input.cpp b/Sources/Client/Client_Input.cpp index cdc5e255..2fcb1307 100644 --- a/Sources/Client/Client_Input.cpp +++ b/Sources/Client/Client_Input.cpp @@ -92,6 +92,7 @@ namespace spades { return readyToClose; } + bool FirstPersonSpectate = false; void Client::Closing() { SPADES_MARK_FUNCTION(); @@ -382,6 +383,9 @@ namespace spades { }else if(CheckKey(cg_keySneak, name)){ playerInput.sneak = down; }else if(CheckKey(cg_keyJump, name)){ + if(down){ + FirstPersonSpectate = !FirstPersonSpectate; + } playerInput.jump = down; }else if(CheckKey(cg_keyAttack, name)){ weapInput.primary = down; diff --git a/Sources/Client/Client_Scene.cpp b/Sources/Client/Client_Scene.cpp index 21b1b434..9fb397d0 100644 --- a/Sources/Client/Client_Scene.cpp +++ b/Sources/Client/Client_Scene.cpp @@ -200,11 +200,17 @@ namespace spades { Vector3 front = center - eye; front = front.Normalize(); - def.viewOrigin = eye; - def.viewAxis[0] = -Vector3::Cross(up, front).Normalize(); - def.viewAxis[1] = -Vector3::Cross(front, def.viewAxis[0]).Normalize(); - def.viewAxis[2] = front; - + if(FirstPersonSpectate == false){ + def.viewOrigin = eye; + def.viewAxis[0] = -Vector3::Cross(up, front).Normalize(); + def.viewAxis[1] = -Vector3::Cross(front, def.viewAxis[0]).Normalize(); + def.viewAxis[2] = front; + }else{ + def.viewOrigin = player->GetEye(); + def.viewAxis[0] = player->GetRight(); + def.viewAxis[1] = player->GetUp(); + def.viewAxis[2] = player->GetFront(); + } def.fovY = (float)cg_fov * static_cast(M_PI) /180.f; def.fovX = atanf(tanf(def.fovY * .5f) *