pre merge

This commit is contained in:
Dander7BD 2014-02-11 14:47:57 +01:00
parent 813a97cfbf
commit 0f3c5af04a
3 changed files with 90 additions and 72 deletions

View File

@ -9,6 +9,7 @@
#include "GameClientState\GameClientState.h"
#include "GameClientState\GameState.h"
#include <Utilities.h>
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<Client::GameState*>(gameClientState))
((Client::GameState*)gameClientState)->Protocol(&protocolData);

View File

@ -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

View File

@ -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]);