GL - starting to send lookdir to server

This commit is contained in:
lindaandersson 2014-01-23 09:24:55 +01:00
parent 121fd51c45
commit 8c297d1e9b
9 changed files with 34 additions and 25 deletions

View File

@ -267,12 +267,14 @@ void GameState::readKeyInput(InputClass* KeyInput)
//send delta mouse movement //send delta mouse movement
if (KeyInput->IsMousePressed()) if (KeyInput->IsMousePressed())
{ {
GameLogic::Protocol_PlayerMouse deltaMouseMove;
deltaMouseMove.dxMouse = KeyInput->GetYaw();
deltaMouseMove.dyMouse = KeyInput->GetPitch();
//privData->nwClient->Send(deltaMouseMove);
camera->Yaw(KeyInput->GetYaw()); camera->Yaw(KeyInput->GetYaw());
camera->Pitch(KeyInput->GetPitch()); camera->Pitch(KeyInput->GetPitch());
camera->UpdateViewMatrix();
GameLogic::Protocol_PlayerLook playerLookDir;
//deltaMouseMove.camera->GetLook();
//privData->nwClient->Send(playerLookDir);
} }

View File

@ -54,10 +54,14 @@ namespace DanBias
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT); c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
} }
break; break;
case protocol_Gameplay_PlayerMouseMovement: case protocol_Gameplay_PlayerLookDir:
{ {
Protocol_PlayerMouse m; m = p; Protocol_PlayerLook m; m = p;
c->GetPlayer()->Rotate(m.dxMouse, m.dyMouse); 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; break;
case protocol_Gameplay_PlayerChangeWeapon: case protocol_Gameplay_PlayerChangeWeapon:

View File

@ -39,7 +39,7 @@ namespace GameLogic
Oyster::Math::Float4x4 GetOrientation() override; Oyster::Math::Float4x4 GetOrientation() override;
int GetID() const override; int GetID() const override;
OBJECT_TYPE GetObjectType() 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; Player *player;
}; };

View File

@ -79,7 +79,7 @@ namespace GameLogic
* @param x: The relative x axis * @param x: The relative x axis
* @param y: The relative y 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 * Uses the chosen players weapon based on input

View File

@ -49,7 +49,7 @@ OBJECT_TYPE Game::PlayerData::GetObjectType() const
{ {
return this->player->GetType(); 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);
} }

View File

@ -92,7 +92,7 @@ void Player::Respawn(Oyster::Math::Float3 spawnPoint)
this->lookDir = Oyster::Math::Float4(1,0,0); 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; //this->lookDir = lookDir;

View File

@ -42,7 +42,7 @@ namespace GameLogic
void Respawn(Oyster::Math::Float3 spawnPoint); 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 * Collision function for player, this is to be sent to physics through the subscribe function with the rigidbody

View File

@ -56,33 +56,36 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol; Oyster::Network::CustomNetProtocol protocol;
}; };
struct Protocol_PlayerMouse :public Oyster::Network::CustomProtocolObject struct Protocol_PlayerLook :public Oyster::Network::CustomProtocolObject
{ {
float dxMouse; float lookDirX;
float dyMouse; float lookDirY;
float lookDirZ;
Protocol_PlayerLook()
Protocol_PlayerMouse()
{ {
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[protocol_INDEX_ID].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Float; this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
this->protocol[2].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; lookDirX = val[1].value.netFloat;
dyMouse = val[2].value.netFloat; lookDirY = val[2].value.netFloat;
lookDirZ = val[3].value.netFloat;
return *this; return *this;
} }
Oyster::Network::CustomNetProtocol* GetProtocol() override Oyster::Network::CustomNetProtocol* GetProtocol() override
{ {
this->protocol[1].value = dxMouse; this->protocol[1].value = lookDirX;
this->protocol[2].value = dyMouse; this->protocol[2].value = lookDirY;
this->protocol[3].value = lookDirZ;
return &protocol; return &protocol;
} }

View File

@ -47,7 +47,7 @@
/***********[ 300 - 399 ]***********/ /***********[ 300 - 399 ]***********/
#define protocol_GameplayMIN 300 #define protocol_GameplayMIN 300
#define protocol_Gameplay_PlayerMovement 300 #define protocol_Gameplay_PlayerMovement 300
#define protocol_Gameplay_PlayerMouseMovement 301 #define protocol_Gameplay_PlayerLookDir 301
#define protocol_Gameplay_PlayerChangeWeapon 302 #define protocol_Gameplay_PlayerChangeWeapon 302
#define protocol_Gameplay_ObjectPickup 303 #define protocol_Gameplay_ObjectPickup 303
#define protocol_Gameplay_ObjectDamage 304 #define protocol_Gameplay_ObjectDamage 304