GL - can move a obj on the client via the server
This commit is contained in:
parent
52ba5602d5
commit
c541d032e7
|
@ -24,6 +24,7 @@ namespace DanBias
|
|||
Oyster::Network::NetworkClient* nwClient;
|
||||
Client::GameClientState* gameClientState;
|
||||
|
||||
|
||||
void NetworkCallback(Oyster::Network::CustomNetProtocol& p) override
|
||||
{
|
||||
int pType = p[0].value.netInt;
|
||||
|
@ -159,7 +160,7 @@ namespace DanBias
|
|||
|
||||
m_data->recieverObj = new MyRecieverObject;
|
||||
|
||||
// m_data->recieverObj->nwClient = new Oyster::Network::NetworkClient(m_data->recieverObj, Oyster::Network::NetworkProtocolCallbackType_Object);
|
||||
m_data->recieverObj->nwClient = new Oyster::Network::NetworkClient(m_data->recieverObj, Oyster::Network::NetworkProtocolCallbackType_Object);
|
||||
m_data->recieverObj->nwClient->Connect(desc.port, desc.IP);
|
||||
|
||||
if (!m_data->recieverObj->nwClient->IsConnected())
|
||||
|
|
|
@ -26,6 +26,7 @@ void C_DynamicObj::Init(ModelInitData modelInit)
|
|||
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
|
||||
privData->model->WorldMatrix = modelInit.world;
|
||||
privData->model->Visible = modelInit.visible;
|
||||
privData->ID = modelInit.id;
|
||||
}
|
||||
void C_DynamicObj::setPos(Oyster::Math::Float4x4 world)
|
||||
{
|
||||
|
|
|
@ -28,7 +28,7 @@ void C_Player::Init(ModelInitData modelInit)
|
|||
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
|
||||
privData->model->WorldMatrix = modelInit.world;
|
||||
privData->model->Visible = modelInit.visible;
|
||||
|
||||
privData->ID = modelInit.id;
|
||||
|
||||
}
|
||||
void C_Player::setPos(Oyster::Math::Float4x4 world)
|
||||
|
|
|
@ -28,6 +28,7 @@ void C_StaticObj::Init(ModelInitData modelInit)
|
|||
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
|
||||
privData->model->WorldMatrix = modelInit.world;
|
||||
privData->model->Visible = modelInit.visible;
|
||||
privData->ID = modelInit.id;
|
||||
|
||||
}
|
||||
void C_StaticObj::setPos(Oyster::Math::Float4x4 world)
|
||||
|
|
|
@ -24,6 +24,7 @@ void C_UIobject::Init(ModelInitData modelInit)
|
|||
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
|
||||
privData->model->WorldMatrix = modelInit.world;
|
||||
privData->model->Visible = modelInit.visible;
|
||||
privData->ID = modelInit.id;
|
||||
|
||||
}
|
||||
void C_UIobject::setPos(Oyster::Math::Float4x4 world)
|
||||
|
|
|
@ -40,6 +40,12 @@ bool GameState::Init(Oyster::Network::NetworkClient* nwClient)
|
|||
}
|
||||
GameState::gameStateState GameState::LoadGame()
|
||||
{
|
||||
Oyster::Graphics::Definitions::Pointlight plight;
|
||||
plight.Pos = Oyster::Math::Float3(0,3,0);
|
||||
plight.Color = Oyster::Math::Float3(0,1,0);
|
||||
plight.Radius = 5;
|
||||
plight.Bright = 2;
|
||||
Oyster::Graphics::API::AddLight(plight);
|
||||
LoadModels(L"map");
|
||||
InitCamera(Oyster::Math::Float3(0,0,5.4f));
|
||||
return gameStateState_playing;
|
||||
|
@ -56,18 +62,22 @@ bool GameState::LoadModels(std::wstring mapFile)
|
|||
modelData.world = Oyster::Math3D::Float4x4::identity;
|
||||
modelData.visible = true;
|
||||
modelData.modelPath = L"..\\Content\\worldDummy";
|
||||
modelData.id = 0;
|
||||
// load models
|
||||
C_Object* obj = new C_Player();
|
||||
privData->object.push_back(obj);
|
||||
privData->object[privData->object.size() -1 ]->Init(modelData);
|
||||
|
||||
Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(2,2,2));
|
||||
Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(-2,2,2));
|
||||
modelData.world = modelData.world * translate;
|
||||
modelData.modelPath = L"..\\Content\\worldDummy";
|
||||
modelData.id ++;
|
||||
|
||||
obj = new C_DynamicObj();
|
||||
privData->object.push_back(obj);
|
||||
privData->object[privData->object.size() -1 ]->Init(modelData);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
bool GameState::InitCamera(Oyster::Math::Float3 startPos)
|
||||
|
@ -209,6 +219,7 @@ void GameState::Protocol( ObjPos* pos )
|
|||
{
|
||||
world[i] = pos->worldPos[i];
|
||||
}
|
||||
|
||||
for (int i = 0; i < privData->object.size(); i++)
|
||||
{
|
||||
if(privData->object[i]->GetId() == pos->object_ID)
|
||||
|
|
|
@ -156,19 +156,25 @@ namespace DanBias
|
|||
{
|
||||
case protocol_Gameplay_PlayerNavigation:
|
||||
{
|
||||
if(p[1].value.netBool) //bool bForward;
|
||||
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD);
|
||||
if(p[2].value.netBool) //bool bBackward;
|
||||
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD);
|
||||
if(p[5].value.netBool) //bool bStrafeRight;
|
||||
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
|
||||
if(p[6].value.netBool) //bool bStrafeLeft;
|
||||
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_LEFT);
|
||||
|
||||
//Oyster::Math::Float4x4 p;
|
||||
Protocol_ObjectPosition op;//(c.GetPlayer()->GetRigidBody(), c.GetPlayer()->GetID());
|
||||
//op.object_ID = c.GetPlayer()->GetID();
|
||||
Send(op.GetProtocol());
|
||||
Oyster::Math::Float4x4 world = Oyster::Math::Matrix::identity;
|
||||
if(p[1].value.netBool) //bool bForward;
|
||||
world.v[3].x = 2;
|
||||
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD);
|
||||
if(p[2].value.netBool) //bool bBackward;
|
||||
world.v[3].x = -2;
|
||||
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD);
|
||||
if(p[5].value.netBool) //bool bStrafeRight;
|
||||
world.v[3].y = 2;
|
||||
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
|
||||
if(p[6].value.netBool) //bool bStrafeLeft;
|
||||
world.v[3].y = -2;
|
||||
//c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_LEFT);
|
||||
|
||||
Protocol_ObjectPosition res(world, 0);
|
||||
Send(res.GetProtocol());
|
||||
|
||||
|
||||
}
|
||||
break;
|
||||
case protocol_Gameplay_PlayerMouseMovement:
|
||||
|
|
|
@ -9,15 +9,8 @@
|
|||
|
||||
#include "GameLogicStates.h"
|
||||
#include "GameLogicDef.h"
|
||||
#include <PhysicsAPI.h>
|
||||
|
||||
namespace Oyster
|
||||
{
|
||||
namespace Physics
|
||||
{
|
||||
class ICustomBody;
|
||||
class State;
|
||||
}
|
||||
}
|
||||
namespace GameLogic
|
||||
{
|
||||
class DANBIAS_GAMELOGIC_DLL Object
|
||||
|
|
Loading…
Reference in New Issue