From 8c297d1e9b3818ec914c99c08e213a7a42607d8e Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Thu, 23 Jan 2014 09:24:55 +0100 Subject: [PATCH] GL - starting to send lookdir to server --- .../DanBiasGame/GameClientState/GameState.cpp | 10 +++++--- .../GameSession/GameSession_Events.cpp | 10 +++++--- Code/Game/GameLogic/Game.h | 2 +- Code/Game/GameLogic/GameAPI.h | 2 +- Code/Game/GameLogic/Game_PlayerData.cpp | 4 +-- Code/Game/GameLogic/Player.cpp | 2 +- Code/Game/GameLogic/Player.h | 2 +- Code/Game/GameProtocols/PlayerProtocols.h | 25 +++++++++++-------- .../GameProtocols/ProtocolIdentificationID.h | 2 +- 9 files changed, 34 insertions(+), 25 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index 665ba668..bb2703c4 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -267,12 +267,14 @@ void GameState::readKeyInput(InputClass* KeyInput) //send delta mouse movement if (KeyInput->IsMousePressed()) { - GameLogic::Protocol_PlayerMouse deltaMouseMove; - deltaMouseMove.dxMouse = KeyInput->GetYaw(); - deltaMouseMove.dyMouse = KeyInput->GetPitch(); - //privData->nwClient->Send(deltaMouseMove); + + camera->Yaw(KeyInput->GetYaw()); camera->Pitch(KeyInput->GetPitch()); + camera->UpdateViewMatrix(); + GameLogic::Protocol_PlayerLook playerLookDir; + //deltaMouseMove.camera->GetLook(); + //privData->nwClient->Send(playerLookDir); } diff --git a/Code/Game/DanBiasServer/GameSession/GameSession_Events.cpp b/Code/Game/DanBiasServer/GameSession/GameSession_Events.cpp index 5dac3c3e..44392da0 100644 --- a/Code/Game/DanBiasServer/GameSession/GameSession_Events.cpp +++ b/Code/Game/DanBiasServer/GameSession/GameSession_Events.cpp @@ -54,10 +54,14 @@ namespace DanBias c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT); } break; - case protocol_Gameplay_PlayerMouseMovement: + case protocol_Gameplay_PlayerLookDir: { - Protocol_PlayerMouse m; m = p; - c->GetPlayer()->Rotate(m.dxMouse, m.dyMouse); + Protocol_PlayerLook m; m = p; + Oyster::Math3D::Float3 lookDir; + lookDir.x = p.Get(1).value.netFloat; + lookDir.y = p.Get(2).value.netFloat; + lookDir.z = p.Get(3).value.netFloat; + c->GetPlayer()->Rotate(lookDir); } break; case protocol_Gameplay_PlayerChangeWeapon: diff --git a/Code/Game/GameLogic/Game.h b/Code/Game/GameLogic/Game.h index 11c8d325..7d40a3c5 100644 --- a/Code/Game/GameLogic/Game.h +++ b/Code/Game/GameLogic/Game.h @@ -39,7 +39,7 @@ namespace GameLogic Oyster::Math::Float4x4 GetOrientation() override; int GetID() const override; OBJECT_TYPE GetObjectType() const override; - void Rotate(const float x, const float y) override; + void Rotate(const Oyster::Math3D::Float3 lookDir) override; Player *player; }; diff --git a/Code/Game/GameLogic/GameAPI.h b/Code/Game/GameLogic/GameAPI.h index 12f5022f..889466c7 100644 --- a/Code/Game/GameLogic/GameAPI.h +++ b/Code/Game/GameLogic/GameAPI.h @@ -79,7 +79,7 @@ namespace GameLogic * @param x: The relative x axis * @param y: The relative y axis **/ - virtual void Rotate(const float x, const float y) = 0; + virtual void Rotate(const const Oyster::Math3D::Float3 lookDir) = 0; /******************************************************** * Uses the chosen players weapon based on input diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index e651a02f..1c7de849 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -49,7 +49,7 @@ OBJECT_TYPE Game::PlayerData::GetObjectType() const { return this->player->GetType(); } -void Game::PlayerData::Rotate(const float x, const float y) +void Game::PlayerData::Rotate(const Oyster::Math3D::Float3 lookDir) { - this->player->Rotate(x, y); + this->player->Rotate(lookDir); } \ No newline at end of file diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index a6320bd5..cdd32090 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -92,7 +92,7 @@ void Player::Respawn(Oyster::Math::Float3 spawnPoint) this->lookDir = Oyster::Math::Float4(1,0,0); } -void Player::Rotate(float dx, float dy) +void Player::Rotate(const Oyster::Math3D::Float3 lookDir) { //this->lookDir = lookDir; diff --git a/Code/Game/GameLogic/Player.h b/Code/Game/GameLogic/Player.h index 6d1f0424..371460c8 100644 --- a/Code/Game/GameLogic/Player.h +++ b/Code/Game/GameLogic/Player.h @@ -42,7 +42,7 @@ namespace GameLogic void Respawn(Oyster::Math::Float3 spawnPoint); - void Rotate(float x, float y); + void Rotate(const Oyster::Math3D::Float3 lookDir); /******************************************************** * Collision function for player, this is to be sent to physics through the subscribe function with the rigidbody diff --git a/Code/Game/GameProtocols/PlayerProtocols.h b/Code/Game/GameProtocols/PlayerProtocols.h index b91cb46d..9ad819e8 100644 --- a/Code/Game/GameProtocols/PlayerProtocols.h +++ b/Code/Game/GameProtocols/PlayerProtocols.h @@ -56,33 +56,36 @@ namespace GameLogic Oyster::Network::CustomNetProtocol protocol; }; - struct Protocol_PlayerMouse :public Oyster::Network::CustomProtocolObject + struct Protocol_PlayerLook :public Oyster::Network::CustomProtocolObject { - float dxMouse; - float dyMouse; - + float lookDirX; + float lookDirY; + float lookDirZ; - Protocol_PlayerMouse() + Protocol_PlayerLook() { - this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_PlayerMouseMovement; + this->protocol[protocol_INDEX_ID].value = protocol_Gameplay_PlayerLookDir; this->protocol[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short; this->protocol[1].type = Oyster::Network::NetAttributeType_Float; this->protocol[2].type = Oyster::Network::NetAttributeType_Float; + this->protocol[3].type = Oyster::Network::NetAttributeType_Float; } - const Protocol_PlayerMouse& operator=(Oyster::Network::CustomNetProtocol& val) + const Protocol_PlayerLook& operator=(Oyster::Network::CustomNetProtocol& val) { - dxMouse = val[1].value.netFloat; - dyMouse = val[2].value.netFloat; + lookDirX = val[1].value.netFloat; + lookDirY = val[2].value.netFloat; + lookDirZ = val[3].value.netFloat; return *this; } Oyster::Network::CustomNetProtocol* GetProtocol() override { - this->protocol[1].value = dxMouse; - this->protocol[2].value = dyMouse; + this->protocol[1].value = lookDirX; + this->protocol[2].value = lookDirY; + this->protocol[3].value = lookDirZ; return &protocol; } diff --git a/Code/Game/GameProtocols/ProtocolIdentificationID.h b/Code/Game/GameProtocols/ProtocolIdentificationID.h index 7b742eb9..353338b6 100644 --- a/Code/Game/GameProtocols/ProtocolIdentificationID.h +++ b/Code/Game/GameProtocols/ProtocolIdentificationID.h @@ -47,7 +47,7 @@ /***********[ 300 - 399 ]***********/ #define protocol_GameplayMIN 300 #define protocol_Gameplay_PlayerMovement 300 -#define protocol_Gameplay_PlayerMouseMovement 301 +#define protocol_Gameplay_PlayerLookDir 301 #define protocol_Gameplay_PlayerChangeWeapon 302 #define protocol_Gameplay_ObjectPickup 303 #define protocol_Gameplay_ObjectDamage 304