diff --git a/Code/Game/DanBiasGame/GameClientRecieverFunc.h b/Code/Game/DanBiasGame/GameClientRecieverFunc.h index 0112e2b2..37d504ec 100644 --- a/Code/Game/DanBiasGame/GameClientRecieverFunc.h +++ b/Code/Game/DanBiasGame/GameClientRecieverFunc.h @@ -9,6 +9,7 @@ #include "GameClientState\GameClientState.h" #include "GameClientState\GameState.h" + #include namespace DanBias @@ -101,13 +102,27 @@ namespace DanBias break; case protocol_Gameplay_ObjectPosition: { + // 0: reserved + // 1: objectID + // 2,3,4: position + // 5,6,7,8: rotation quaternion + + GameLogic::Protocol_ObjectPosition data; Client::GameClientState::ObjPos protocolData; protocolData.object_ID = p[1].value.netInt; - for(int i = 0; i< 16; i++) + + for( int i = 0; i < 3; ++i ) { - protocolData.worldPos[i] = p[i+2].value.netFloat; + protocolData.position[i] = p[i+2].value.netFloat; + protocolData.rotation[i] = p[i+5].value.netFloat; } + protocolData.rotation[3] = p[8].value.netFloat; + + //for(int i = 0; i< 16; i++) + //{ + // protocolData.worldPos[i] = p[i+2].value.netFloat; + //} if(dynamic_cast(gameClientState)) ((Client::GameState*)gameClientState)->Protocol(&protocolData); diff --git a/Code/Game/DanBiasGame/GameClientState/GameClientState.h b/Code/Game/DanBiasGame/GameClientState/GameClientState.h index 5629a4b6..183e8174 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameClientState.h +++ b/Code/Game/DanBiasGame/GameClientState/GameClientState.h @@ -5,75 +5,78 @@ #include "L_inputClass.h" #include "NetworkClient.h" -namespace DanBias +namespace DanBias { namespace Client { -namespace Client -{ - -class GameClientState -{ -public: - struct ProtocolStruct + class GameClientState { + public: + struct ProtocolStruct + { + + }; + + struct ObjPos : public ProtocolStruct + { + int object_ID; + //float worldPos[16]; + float position[3]; + float rotation[4]; + }; + + struct NewObj : public ProtocolStruct + { + int object_ID; + char* path; + float worldPos[16]; + }; + + struct RemoveObj : public ProtocolStruct + { + int object_ID; + //particle effect + }; + + struct KeyInput : public ProtocolStruct + { + bool key[6]; + }; + + struct PlayerPos : public ProtocolStruct + { + float position[3]; + float angularAxis[3]; + // float playerPos[3]; + }; + + struct PlayerMove : public ProtocolStruct + { + float playerPos[3]; + }; + + struct PlayerName : public ProtocolStruct + { + char name[255]; + }; + + enum ClientState + { + ClientState_Login, + ClientState_Lobby, + ClientState_Lan, + ClientState_LobbyCreated, + ClientState_Game, + ClientState_Same, + }; + + public: + GameClientState(void); + virtual ~GameClientState(void); + virtual bool Init(Oyster::Network::NetworkClient* nwClient) = 0; + virtual ClientState Update(float deltaTime, InputClass* KeyInput) = 0; + virtual bool Render() = 0; + virtual bool Release() = 0; + virtual void Protocol(ProtocolStruct* protocolStruct) = 0; }; - struct ObjPos :public ProtocolStruct - { - int object_ID; - //float worldPos[16]; - float position[3]; - float angularAxis[3]; - float rotation[4]; - }; - struct NewObj :public ProtocolStruct - { - int object_ID; - char* path; - float worldPos[16]; - }; - struct RemoveObj :public ProtocolStruct - { - int object_ID; - //particle effect - }; - struct KeyInput :public ProtocolStruct - { - bool key[6]; - }; - struct PlayerPos :public ProtocolStruct - { - float position[3]; - float angularAxis[3]; -// float playerPos[3]; - }; - struct PlayerMove :public ProtocolStruct - { - float playerPos[3]; - }; - struct PlayerName :public ProtocolStruct - { - char name[255]; - }; - enum ClientState - { - ClientState_Login, - ClientState_Lobby, - ClientState_Lan, - ClientState_LobbyCreated, - ClientState_Game, - ClientState_Same, - }; - -public: - GameClientState(void); - virtual ~GameClientState(void); - virtual bool Init(Oyster::Network::NetworkClient* nwClient) = 0; - virtual ClientState Update(float deltaTime, InputClass* KeyInput) = 0; - virtual bool Render() = 0; - virtual bool Release() = 0; - virtual void Protocol(ProtocolStruct* protocolStruct) = 0; - -}; -}; -}; +} } #endif \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index 05ccd23f..9759fa09 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -566,8 +566,8 @@ void GameState::Protocol(ProtocolStruct* pos) void GameState::Protocol( PlayerPos* pos ) { - camera.SetPosition( pos->position ); - camera.SetAngular( pos->angularAxis ); + //camera.SetPosition( pos->position ); + //camera.SetAngular( pos->angularAxis ); //Float4x4 world, translate; @@ -604,7 +604,7 @@ void GameState::Protocol( ObjPos* pos ) if(dynamicObjects[i]->GetId() == myId) // playerobj { camera.SetPosition( pos->position ); - camera.SetAngular( pos->angularAxis ); + camera.SetAngular( QuaternionToAngularAxis(Quaternion(pos->rotation, pos->rotation[3])).xyz ); //Float3 right = Float3(world[0], world[1], world[2]); //Float3 up = Float3(world[4], world[5], world[6]);