diff --git a/Code/Game/DanBiasGame/GameClientState/Camera_FPS.cpp b/Code/Game/DanBiasGame/GameClientState/Camera_FPS.cpp index f4d46f69..d1884cef 100644 --- a/Code/Game/DanBiasGame/GameClientState/Camera_FPS.cpp +++ b/Code/Game/DanBiasGame/GameClientState/Camera_FPS.cpp @@ -116,7 +116,7 @@ void Camera_FPS::PitchUp( Float radian ) void Camera_FPS::PitchDown( Float radian ) { - this->PitchDown( -radian ); + this->PitchUp( -radian ); } void Camera_FPS::YawRight( Float radian ) diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index d8547943..e1b129a3 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -4,23 +4,22 @@ #include "C_obj/C_DynamicObj.h" #include #include "NetworkClient.h" -#include "Camera.h" +//#include "Camera.h" #include using namespace DanBias::Client; +using namespace ::Oyster::Math3D; struct GameState::myData { myData(){} - Oyster::Math3D::Float4x4 view; - Oyster::Math3D::Float4x4 proj; + //Oyster::Math3D::Float4x4 view; + //Oyster::Math3D::Float4x4 proj; std::vector object; int modelCount; Oyster::Network::NetworkClient* nwClient; gameStateState state; - - -}privData; +} privData; GameState::GameState(void) { @@ -38,12 +37,12 @@ GameState::~GameState(void) bool GameState::Init(Oyster::Network::NetworkClient* nwClient) { // load models - camera = new Camera; + //camera = new Camera; privData = new myData(); privData->state = gameStateState_loading; privData->nwClient = nwClient; privData->state = LoadGame(); - pitch = 0; + //pitch = 0; return true; } GameState::gameStateState GameState::LoadGame() @@ -203,29 +202,37 @@ bool GameState::LoadModels(std::wstring mapFile) return true; } -bool GameState::InitCamera(Oyster::Math::Float3 startPos) +bool GameState::InitCamera( Oyster::Math::Float3 startPos ) { - Oyster::Math::Float3 dir = Oyster::Math::Float3(0,0,1); - Oyster::Math::Float3 up =Oyster::Math::Float3(0,1,0); - Oyster::Math::Float3 pos = Oyster::Math::Float3(0, 0, 20); + camera.SetHeadOffset( Float3(0.0f, 1.0f, -2.0f) ); - camera->LookAt(pos, dir, up); - camera->SetLens(3.14f/2, 1024/768, 1, 1000); + //Oyster::Math::Float3 dir = Oyster::Math::Float3(0,0,1); + //Oyster::Math::Float3 up =Oyster::Math::Float3(0,1,0); + //Oyster::Math::Float3 pos = Oyster::Math::Float3(0, 0, 20); - privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1024.0f/768.0f,.1f,1000); + camera.SetPerspectiveProjection( Oyster::Math::pi/2.0f, 1024.0f/768.0f, 1.0f, 1000.0f ); + Oyster::Graphics::API::SetProjection( Float4x4(camera.GetProjectionMatrix()) ); // TODO: remove copy wrapper when no longer needed + + //camera->LookAt(pos, dir, up); + //camera->SetLens(3.14f/2, 1024/768, 1, 1000); + + //privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1024.0f/768.0f,.1f,1000); //privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000); - Oyster::Graphics::API::SetProjection(privData->proj); - camera->UpdateViewMatrix(); - privData->view = camera->View(); - privData->view = Oyster::Math3D::ViewMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos); - privData->view = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos); - privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view); + //Oyster::Graphics::API::SetProjection( privData->proj ); + + //camera->UpdateViewMatrix(); + //privData->view = camera->View(); + //privData->view = Oyster::Math3D::ViewMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos); + //privData->view = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos); + //privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view); return true; } + void GameState::setClientId(int id) { myId = id; } + GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyInput) { switch (privData->state) @@ -246,7 +253,8 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI // update objects { readKeyInput(KeyInput); - camera->UpdateViewMatrix(); + camera.UpdateOrientation(); + //camera->UpdateViewMatrix(); } break; @@ -262,10 +270,13 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI } bool GameState::Render() { - Oyster::Graphics::API::SetView(camera->View()); + Oyster::Graphics::API::SetView( camera.GetViewMatrix() ); + + //Oyster::Graphics::API::SetView(camera->View()); //Oyster::Graphics::API::SetProjection(camera->Proj()); //Oyster::Graphics::API::SetView(privData->view); - Oyster::Graphics::API::SetProjection(privData->proj); + //Oyster::Graphics::API::SetProjection(privData->proj); + Oyster::Graphics::API::NewFrame(); for (unsigned int i = 0; i < privData->object.size(); i++) { @@ -355,18 +366,23 @@ void GameState::readKeyInput(InputClass* KeyInput) //send delta mouse movement if (KeyInput->IsMousePressed()) { - camera->Yaw(-KeyInput->GetYaw()); - camera->Pitch(KeyInput->GetPitch()); - pitch = KeyInput->GetPitch(); - camera->UpdateViewMatrix(); + camera.YawRight( KeyInput->GetYaw() ); + camera.PitchUp( KeyInput->GetPitch() ); + camera.UpdateOrientation(); + + //camera->Yaw(-KeyInput->GetYaw()); + //->Pitch(KeyInput->GetPitch()); + //pitch = KeyInput->GetPitch(); + //camera->UpdateViewMatrix(); GameLogic::Protocol_PlayerLook playerLookDir; - Oyster::Math::Float4 look = camera->GetLook(); + Float4 look = Float4( camera.GetLook(), 0.0f ); + //Float4 look = camera->GetLook(); playerLookDir.lookDirX = look.x; playerLookDir.lookDirY = look.y; playerLookDir.lookDirZ = look.z; playerLookDir.deltaX = -KeyInput->GetYaw(); - privData->nwClient->Send(playerLookDir); + privData->nwClient->Send( playerLookDir ); } // shoot @@ -470,10 +486,8 @@ void GameState::Protocol( ObjPos* pos ) Oyster::Math::Float3 objForward = (Oyster::Math::Float3(world[8], world[9], world[10])); Oyster::Math::Float3 pos = Oyster::Math::Float3(world[12], world[13], world[14]); - Oyster::Math::Float3 cameraLook = camera->GetLook(); - Oyster::Math::Float3 cameraUp = camera->GetUp(); - - + //Oyster::Math::Float3 cameraLook = camera->GetLook(); + //Oyster::Math::Float3 cameraUp = camera->GetUp(); /*Oyster::Math::Float3 newUp = cameraUp.Dot(up); up *= newUp; @@ -481,6 +495,7 @@ void GameState::Protocol( ObjPos* pos ) Oyster::Math::Float3 newLook = up.Cross(right); newLook.Normalize();*/ + camera->setRight(right); camera->setUp(up); camera->setLook(objForward); diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.h b/Code/Game/DanBiasGame/GameClientState/GameState.h index d555134c..8a5fb4ff 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.h +++ b/Code/Game/DanBiasGame/GameClientState/GameState.h @@ -3,7 +3,10 @@ #include "GameClientState.h" #include "OysterMath.h" #include -#include "Camera.h" + +//#include "Camera.h" +#include "Camera_FPS.h" + namespace DanBias { namespace Client @@ -24,10 +27,11 @@ private: bool key_strafeLeft; bool key_Shoot; bool key_Jump; - Camera* camera; + Camera_FPS camera; + //Camera* camera; int myId; - float pitch; + //float pitch; struct myData; myData* privData; public: diff --git a/Code/Game/GameServer/GameServer.vcxproj b/Code/Game/GameServer/GameServer.vcxproj index 23bf0eb0..387afb29 100644 --- a/Code/Game/GameServer/GameServer.vcxproj +++ b/Code/Game/GameServer/GameServer.vcxproj @@ -200,6 +200,9 @@ {f10cbc03-9809-4cba-95d8-327c287b18ee} + + {35aea3c0-e0a7-4e1e-88cd-514aa5a442b1} + {b1195bb9-b3a5-47f0-906c-8dea384d1520} diff --git a/Code/OysterMath/OysterMath.h b/Code/OysterMath/OysterMath.h index 4449db83..f0ff076b 100644 --- a/Code/OysterMath/OysterMath.h +++ b/Code/OysterMath/OysterMath.h @@ -165,7 +165,7 @@ namespace Oyster { namespace Math3D //! Oyster's native math library specialized Quaternion Rotation( const Float4 &angularAxis ); /** @todo TODO: add doc */ - Float3x3 & RotationMatrix( const Quaternion &rotationQuaternion, Float3x3 &targetMem = Float3x3() ); + Float3x3 & RotationMatrix( const Quaternion &rotationQuaternion, Float3x3 &targetMem ); /** @todo TODO: add doc */ Float4x4 & RotationMatrix( const Quaternion &rotationQuaternion, Float4x4 &targetMem = Float4x4() );