diff --git a/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp b/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp index b1863242..12506d3c 100644 --- a/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp +++ b/Code/Game/GameClient/GameClientState/Camera_FPSV2.cpp @@ -36,11 +36,15 @@ void Camera_FPSV2::SetPosition( const Float3 &translation ) this->body.translation = translation; } +void Camera_FPSV2::SetRotation( const Quaternion &rotation ) +{ + this->body.rotation = rotation; + this->head.SetRotation( rotation * Rotation(this->pitchUp, this->GetNormalOf(Float3::standard_unit_x) ) ); +} + void Camera_FPSV2::SetAngular( const Float3 &axis ) { - this->body.rotation = Rotation( axis ); - this->head.SetRotation( this->body.rotation ); - this->pitchUp = 0.0f; + this->SetRotation( Rotation(axis) ); } void Camera_FPSV2::SetProjection( const Float4x4 &matrix ) diff --git a/Code/Game/GameClient/GameClientState/Camera_FPSV2.h b/Code/Game/GameClient/GameClientState/Camera_FPSV2.h index 968053c7..7f66b185 100644 --- a/Code/Game/GameClient/GameClientState/Camera_FPSV2.h +++ b/Code/Game/GameClient/GameClientState/Camera_FPSV2.h @@ -14,6 +14,7 @@ public: void SetHeadOffset( const ::Oyster::Math::Float3 &translation ); void SetPosition( const ::Oyster::Math::Float3 &translation ); + void SetRotation( const ::Oyster::Math::Quaternion &rotation ); void SetAngular( const ::Oyster::Math::Float3 &axis ); void SetProjection( const ::Oyster::Math::Float4x4 &matrix ); void SetOrthographicProjection( ::Oyster::Math::Float width, ::Oyster::Math::Float height, ::Oyster::Math::Float nearClip, ::Oyster::Math::Float farClip ); diff --git a/Code/Game/GameClient/GameClientState/GameState.cpp b/Code/Game/GameClient/GameClientState/GameState.cpp index c6d77f76..bfd15532 100644 --- a/Code/Game/GameClient/GameClientState/GameState.cpp +++ b/Code/Game/GameClient/GameClientState/GameState.cpp @@ -2,7 +2,7 @@ #include "DllInterfaces/GFXAPI.h" #include #include "NetworkClient.h" -#include "Camera_FPS.h" +#include "Camera_FPSV2.h" #include #include "C_obj/C_Player.h" @@ -39,7 +39,7 @@ struct GameState::MyData bool key_Reload_Shaders; C_Player player; - Camera_FPS camera; + Camera_FPSV2 camera; int myId; @@ -357,7 +357,7 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState // if is this player. Remember to change camera if( this->privData->myId == decoded.object_ID ) - this->privData->camera.SetAngular( AngularAxis(rotation) ); + this->privData->camera.SetRotation( rotation ); (*this->privData->dynamicObjects)[decoded.object_ID]->setRot( rotation ); } @@ -372,7 +372,7 @@ const GameClientState::NetEvent & GameState::DataRecieved( const GameClientState if( this->privData->myId == decoded.object_ID ) { this->privData->camera.SetPosition( position ); - this->privData->camera.SetAngular( AngularAxis(rotation) ); + this->privData->camera.SetRotation( rotation ); } C_DynamicObj *object = (*this->privData->dynamicObjects)[decoded.object_ID];