Merge remote-tracking branch 'origin/GameServer' into Camera

Conflicts:
	Code/Game/DanBiasGame/GameClientState/GameClientState.h
	Code/Game/DanBiasGame/GameClientState/GameState.cpp
This commit is contained in:
Dander7BD 2014-02-11 14:56:43 +01:00
commit 3be98e6647
35 changed files with 1011 additions and 720 deletions

View File

@ -5,6 +5,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OysterGraphics", "OysterGra
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OysterMath", "OysterMath\OysterMath.vcxproj", "{F10CBC03-9809-4CBA-95D8-327C287B18EE}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OysterMath", "OysterMath\OysterMath.vcxproj", "{F10CBC03-9809-4CBA-95D8-327C287B18EE}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OysterPhysics3D", "OysterPhysics3D\OysterPhysics3D.vcxproj", "{4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sound", "Sound\Sound.vcxproj", "{34D6295A-00DD-4B1A-8258-97DA2818EC26}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WindowManager", "WindowManager\WindowManager.vcxproj", "{35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Input", "Input\Input.vcxproj", "{7E3990D2-3D94-465C-B58D-64A74B3ECF9B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Misc", "Misc\Misc.vcxproj", "{2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Misc", "Misc\Misc.vcxproj", "{2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Network", "Network", "{C27B926E-B3EF-4990-8822-47580E43A0BE}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Network", "Network", "{C27B926E-B3EF-4990-8822-47580E43A0BE}"
@ -15,36 +23,29 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OysterNetworkServer", "Netw
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NetworkDependencies", "Network\NetworkDependencies\NetworkDependencies.vcxproj", "{C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NetworkDependencies", "Network\NetworkDependencies\NetworkDependencies.vcxproj", "{C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tester", "Tester\Tester.vcxproj", "{1B3BEA4C-CF75-438A-9693-60FB8444BBF3}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GamePhysics", "GamePhysics\GamePhysics.vcxproj", "{104FA3E9-94D9-4E1D-A941-28A03BC8A095}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Game", "Game", "{B0AFF0DC-5C7E-43DC-9586-CD4E38EB037B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aDanBiasGameLauncher", "Game\aDanBiasGameLauncher\aDanBiasGameLauncher.vcxproj", "{666FEA52-975F-41CD-B224-B19AF3C0ABBA}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasGame", "Game\DanBiasGame\DanBiasGame.vcxproj", "{2A1BC987-AF42-4500-802D-89CD32FC1309}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasGame", "Game\DanBiasGame\DanBiasGame.vcxproj", "{2A1BC987-AF42-4500-802D-89CD32FC1309}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasLauncher", "Game\DanBiasLauncher\DanBiasLauncher.vcxproj", "{8690FDDF-C5B7-4C42-A337-BD5243F29B85}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Game", "Game", "{20720CA7-795C-45AD-A302-9383A6DD503A}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasServerLauncher", "Game\DanBiasServerLauncher\DanBiasServerLauncher.vcxproj", "{060B1890-CBF3-4808-BA99-A4776222093B}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameLogic", "Game\GameLogic\GameLogic.vcxproj", "{B1195BB9-B3A5-47F0-906C-8DEA384D1520}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameLogic", "Game\GameLogic\GameLogic.vcxproj", "{B1195BB9-B3A5-47F0-906C-8DEA384D1520}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameProtocols", "Game\GameProtocols\GameProtocols.vcxproj", "{DA2AA800-ED64-4649-8B3B-E7F1E3968B78}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasLauncher", "Game\DanBiasLauncher\DanBiasLauncher.vcxproj", "{8690FDDF-C5B7-4C42-A337-BD5243F29B85}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameServer", "Game\GameServer\GameServer.vcxproj", "{143BD516-20A1-4890-A3E4-F8BFD02220E7}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NetworkAPI", "Network\NetworkAPI\NetworkAPI.vcxproj", "{460D625F-2AC9-4559-B809-0BA89CEAEDF4}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NetworkAPI", "Network\NetworkAPI\NetworkAPI.vcxproj", "{460D625F-2AC9-4559-B809-0BA89CEAEDF4}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GamePhysics", "GamePhysics\GamePhysics.vcxproj", "{104FA3E9-94D9-4E1D-A941-28A03BC8A095}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameProtocols", "Game\GameProtocols\GameProtocols.vcxproj", "{DA2AA800-ED64-4649-8B3B-E7F1E3968B78}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Input", "Input\Input.vcxproj", "{7E3990D2-3D94-465C-B58D-64A74B3ECF9B}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameServer", "Game\GameServer\GameServer.vcxproj", "{143BD516-20A1-4890-A3E4-F8BFD02220E7}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameServer", "Game\GameServer\GameServer.vcxproj", "{143BD516-20A1-4890-A3E4-F8BFD02220E7}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OysterPhysics3D", "OysterPhysics3D\OysterPhysics3D.vcxproj", "{4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OysterPhysics3D", "OysterPhysics3D\OysterPhysics3D.vcxproj", "{4285BD3F-3C6C-4670-B7AF-A29AFEF5F6A8}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sound", "Sound\Sound.vcxproj", "{34D6295A-00DD-4B1A-8258-97DA2818EC26}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sound", "Sound\Sound.vcxproj", "{34D6295A-00DD-4B1A-8258-97DA2818EC26}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DanBiasServerLauncher", "Game\DanBiasServerLauncher\DanBiasServerLauncher.vcxproj", "{060B1890-CBF3-4808-BA99-A4776222093B}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WindowManager", "WindowManager\WindowManager.vcxproj", "{35AEA3C0-E0A7-4E1E-88CD-514AA5A442B1}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GameServer", "Game\GameServer\GameServer.vcxproj", "{143BD516-20A1-4890-A3E4-F8BFD02220E7}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aDanBiasGameLauncher", "Game\aDanBiasGameLauncher\aDanBiasGameLauncher.vcxproj", "{666FEA52-975F-41CD-B224-B19AF3C0ABBA}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Physics", "Physics", "{0D86E569-9C74-47F0-BDB2-390C0C9A084B}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Physics", "Physics", "{0D86E569-9C74-47F0-BDB2-390C0C9A084B}"
EndProject EndProject
@ -64,8 +65,8 @@ Global
RelWithDebInfo|x64 = RelWithDebInfo|x64 RelWithDebInfo|x64 = RelWithDebInfo|x64
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Mixed Platforms.ActiveCfg = Release|x64 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Mixed Platforms.Build.0 = Release|x64 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Win32.ActiveCfg = Debug|Win32 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Win32.ActiveCfg = Debug|Win32
{0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Win32.Build.0 = Debug|Win32 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Win32.Build.0 = Debug|Win32
{0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|x64.ActiveCfg = Debug|x64 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|x64.ActiveCfg = Debug|x64
@ -678,12 +679,12 @@ Global
{6A066806-F43F-4B31-A4E3-57179674F460} = {C27B926E-B3EF-4990-8822-47580E43A0BE} {6A066806-F43F-4B31-A4E3-57179674F460} = {C27B926E-B3EF-4990-8822-47580E43A0BE}
{C5AA09D0-6594-4CD3-BD92-1D380C7B3B50} = {C27B926E-B3EF-4990-8822-47580E43A0BE} {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50} = {C27B926E-B3EF-4990-8822-47580E43A0BE}
{460D625F-2AC9-4559-B809-0BA89CEAEDF4} = {C27B926E-B3EF-4990-8822-47580E43A0BE} {460D625F-2AC9-4559-B809-0BA89CEAEDF4} = {C27B926E-B3EF-4990-8822-47580E43A0BE}
{666FEA52-975F-41CD-B224-B19AF3C0ABBA} = {B0AFF0DC-5C7E-43DC-9586-CD4E38EB037B} {2A1BC987-AF42-4500-802D-89CD32FC1309} = {20720CA7-795C-45AD-A302-9383A6DD503A}
{2A1BC987-AF42-4500-802D-89CD32FC1309} = {B0AFF0DC-5C7E-43DC-9586-CD4E38EB037B} {B1195BB9-B3A5-47F0-906C-8DEA384D1520} = {20720CA7-795C-45AD-A302-9383A6DD503A}
{8690FDDF-C5B7-4C42-A337-BD5243F29B85} = {B0AFF0DC-5C7E-43DC-9586-CD4E38EB037B} {8690FDDF-C5B7-4C42-A337-BD5243F29B85} = {20720CA7-795C-45AD-A302-9383A6DD503A}
{060B1890-CBF3-4808-BA99-A4776222093B} = {B0AFF0DC-5C7E-43DC-9586-CD4E38EB037B} {DA2AA800-ED64-4649-8B3B-E7F1E3968B78} = {20720CA7-795C-45AD-A302-9383A6DD503A}
{B1195BB9-B3A5-47F0-906C-8DEA384D1520} = {B0AFF0DC-5C7E-43DC-9586-CD4E38EB037B} {060B1890-CBF3-4808-BA99-A4776222093B} = {20720CA7-795C-45AD-A302-9383A6DD503A}
{DA2AA800-ED64-4649-8B3B-E7F1E3968B78} = {B0AFF0DC-5C7E-43DC-9586-CD4E38EB037B} {143BD516-20A1-4890-A3E4-F8BFD02220E7} = {20720CA7-795C-45AD-A302-9383A6DD503A}
{143BD516-20A1-4890-A3E4-F8BFD02220E7} = {B0AFF0DC-5C7E-43DC-9586-CD4E38EB037B} {666FEA52-975F-41CD-B224-B19AF3C0ABBA} = {20720CA7-795C-45AD-A302-9383A6DD503A}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@ -42,34 +42,6 @@ namespace DanBias
} }
} }
break; break;
case protocol_Gameplay_PlayerMovement:
{
Client::GameClientState::KeyInput* protocolData = new Client::GameClientState::KeyInput;
for(int i = 0; i< 6; i++)
{
protocolData->key[i] = p[i+1].value.netBool;
}
if(dynamic_cast<Client::GameState*>(gameClientState))
((Client::GameState*)gameClientState)->Protocol(protocolData);
delete protocolData;
protocolData = NULL;
}
break;
//case protocol_Gameplay_PlayerPosition:
// {
// Client::GameClientState::PlayerPos* protocolData = new Client::GameClientState::PlayerPos;
// for(int i = 0; i< 3; i++)
// {
// protocolData->playerPos[i] = p[i].value.netFloat;
// }
// if(dynamic_cast<Client::GameState*>(gameClientState))
// ((Client::GameState*)gameClientState)->Protocol(protocolData);
// delete protocolData;
// protocolData = NULL;
// }
// break;
case protocol_Gameplay_ObjectCreate: case protocol_Gameplay_ObjectCreate:
{ {
Client::GameClientState::NewObj protocolData;// = new Client::GameClientState::NewObj; Client::GameClientState::NewObj protocolData;// = new Client::GameClientState::NewObj;
@ -128,11 +100,24 @@ namespace DanBias
((Client::GameState*)gameClientState)->Protocol(&protocolData); ((Client::GameState*)gameClientState)->Protocol(&protocolData);
} }
break; break;
case protocol_Gameplay_ObjectPositionRotation:
{
Client::GameClientState::ObjPos protocolData;
protocolData.object_ID = p[1].value.netInt;
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);
}
break;
case protocol_Lobby_Create: case protocol_Lobby_Create:
{ {
if(dynamic_cast<Client::LobbyState*>(gameClientState)) if(dynamic_cast<Client::LobbyState*>(gameClientState))
{ {
GameLogic::Protocol_LobbyCreateGame tp();
int id = p.Get(1).value.netInt; int id = p.Get(1).value.netInt;
std::string name = p.Get(19).value.netCharPtr; std::string name = p.Get(19).value.netCharPtr;
Oyster::Math::Float4x4 w; Oyster::Math::Float4x4 w;

View File

@ -5,6 +5,9 @@ void C_Object::Init(ModelInitData modelInit)
position = modelInit.position; position = modelInit.position;
rotation = modelInit.rotation; rotation = modelInit.rotation;
scale = modelInit.scale; scale = modelInit.scale;
id = modelInit.id;
model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
model->Visible = modelInit.visible;
updateWorld(); updateWorld();
} }
void C_Object::updateWorld() void C_Object::updateWorld()
@ -17,10 +20,12 @@ void C_Object::updateWorld()
scale.v[1].y = this->scale[1]; scale.v[1].y = this->scale[1];
scale.v[2].z = this->scale[2]; scale.v[2].z = this->scale[2];
world = translation * rot * scale; world = translation * rot * scale;
model->WorldMatrix = world;
} }
void C_Object::setWorld(Oyster::Math::Float4x4 world) void C_Object::setWorld(Oyster::Math::Float4x4 world)
{ {
model->WorldMatrix = world;
} }
Oyster::Math::Float4x4 C_Object::getWorld() const Oyster::Math::Float4x4 C_Object::getWorld() const
{ {
@ -68,7 +73,15 @@ Oyster::Math::Float3 C_Object::getScale() const
{ {
return this->scale; return this->scale;
} }
//int C_Object::GetId() const int C_Object::GetId() const
//{ {
// return return id;
//} }
void C_Object::Render()
{
Oyster::Graphics::API::RenderModel(model);
}
void C_Object::Release()
{
Oyster::Graphics::API::DeleteModel(model);
}

View File

@ -23,6 +23,8 @@ private:
Oyster::Math::Float3 position; Oyster::Math::Float3 position;
Oyster::Math::Quaternion rotation; Oyster::Math::Quaternion rotation;
Oyster::Math::Float3 scale; Oyster::Math::Float3 scale;
Oyster::Graphics::Model::Model *model;
int id;
void updateWorld(); void updateWorld();
public: public:
@ -40,8 +42,8 @@ public:
void addScale(Oyster::Math::Float3 deltaScale); void addScale(Oyster::Math::Float3 deltaScale);
Oyster::Math::Float3 getScale() const; Oyster::Math::Float3 getScale() const;
virtual void Render() = 0; virtual void Render();
virtual void Release() = 0; virtual void Release();
virtual int GetId() = 0; virtual int GetId() const;
};};}; };};};
#endif #endif

View File

@ -1,15 +1,7 @@
#include "C_DynamicObj.h" #include "C_DynamicObj.h"
#include "DllInterfaces/GFXAPI.h" #include "DllInterfaces/GFXAPI.h"
using namespace DanBias::Client; using namespace DanBias::Client;
struct C_DynamicObj::myData
{
myData(){}
Oyster::Graphics::Model::Model *model;
int ID;
// light
// sound
// effect
}privData;
C_DynamicObj::C_DynamicObj(void) C_DynamicObj::C_DynamicObj(void)
{ {
} }
@ -22,24 +14,4 @@ C_DynamicObj::~C_DynamicObj(void)
void C_DynamicObj::Init(ModelInitData modelInit) void C_DynamicObj::Init(ModelInitData modelInit)
{ {
C_Object::Init(modelInit); C_Object::Init(modelInit);
// load models
privData = new myData();
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
privData->model->Visible = modelInit.visible;
privData->model->WorldMatrix = getWorld();
privData->ID = modelInit.id;
}
void C_DynamicObj::Render()
{
Oyster::Graphics::API::RenderModel(privData->model);
}
void C_DynamicObj::Release()
{
Oyster::Graphics::API::DeleteModel(privData->model);
delete privData;
}
int C_DynamicObj::GetId()
{
return privData->ID;
} }

View File

@ -8,15 +8,10 @@ namespace DanBias
class C_DynamicObj : public C_Object class C_DynamicObj : public C_Object
{ {
private: private:
struct myData;
myData* privData;
public: public:
C_DynamicObj(void); C_DynamicObj(void);
virtual ~C_DynamicObj(void); virtual ~C_DynamicObj(void);
void Init(ModelInitData modelInit); void Init(ModelInitData modelInit);
void Render();
void Release();
int GetId();
};};}; };};};
#endif #endif

View File

@ -2,21 +2,11 @@
#include "DllInterfaces/GFXAPI.h" #include "DllInterfaces/GFXAPI.h"
using namespace DanBias::Client; using namespace DanBias::Client;
struct C_Player::myData
{
myData(){}
Oyster::Math3D::Float4x4 view;
Oyster::Math3D::Float4x4 proj;
Oyster::Graphics::Model::Model *model;
Oyster::Math3D::Float4 lookDir;
int ID;
}privData;
C_Player::C_Player(void) C_Player::C_Player(void)
:C_DynamicObj() :C_DynamicObj()
{ {
}
}
C_Player::~C_Player(void) C_Player::~C_Player(void)
{ {
@ -26,26 +16,4 @@ C_Player::~C_Player(void)
void C_Player::Init(ModelInitData modelInit) void C_Player::Init(ModelInitData modelInit)
{ {
C_Object::Init(modelInit); C_Object::Init(modelInit);
// load models
privData = new myData();
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
privData->model->Visible = modelInit.visible;
privData->model->WorldMatrix = getWorld();
privData->ID = modelInit.id;
privData->lookDir = Oyster::Math3D::Float4 (0,0,1,0);
}
void C_Player::Render()
{
Oyster::Graphics::API::RenderModel(privData->model);
}
void C_Player::Release()
{
Oyster::Graphics::API::DeleteModel(privData->model);
delete privData;
}
int C_Player::GetId()
{
return privData->ID;
} }

View File

@ -8,18 +8,10 @@ namespace DanBias
class C_Player : public C_DynamicObj class C_Player : public C_DynamicObj
{ {
private: private:
struct myData;
myData* privData;
public: public:
C_Player(void); C_Player(void);
virtual ~C_Player(void); virtual ~C_Player(void);
void Init(ModelInitData modelInit); void Init(ModelInitData modelInit);
void Render();
void Release();
int GetId();
};};}; };};};
#endif #endif

View File

@ -1,20 +1,11 @@
#include "C_StaticObj.h" #include "C_StaticObj.h"
#include "DllInterfaces/GFXAPI.h" #include "DllInterfaces/GFXAPI.h"
using namespace DanBias::Client; using namespace DanBias::Client;
struct C_StaticObj::myData
{
myData(){}
Oyster::Graphics::Model::Model *model;
int ID;
}privData;
C_StaticObj::C_StaticObj(void) C_StaticObj::C_StaticObj(void)
{ {
} }
C_StaticObj::~C_StaticObj(void) C_StaticObj::~C_StaticObj(void)
{ {
@ -22,26 +13,4 @@ C_StaticObj::~C_StaticObj(void)
void C_StaticObj::Init(ModelInitData modelInit) void C_StaticObj::Init(ModelInitData modelInit)
{ {
C_Object::Init(modelInit); C_Object::Init(modelInit);
// load models
privData = new myData();
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
privData->model->Visible = modelInit.visible;
privData->model->WorldMatrix = getWorld();
privData->ID = modelInit.id;
}
void C_StaticObj::Render()
{
Oyster::Graphics::API::RenderModel(privData->model);
}
void C_StaticObj::Release()
{
Oyster::Graphics::API::DeleteModel(privData->model);
delete privData;
}
int C_StaticObj::GetId()
{
return privData->ID;
} }

View File

@ -8,15 +8,10 @@ namespace DanBias
class C_StaticObj : public C_Object class C_StaticObj : public C_Object
{ {
private: private:
struct myData;
myData* privData;
public: public:
C_StaticObj(void); C_StaticObj(void);
virtual ~C_StaticObj(void); virtual ~C_StaticObj(void);
void Init(ModelInitData modelInit); void Init(ModelInitData modelInit);
void Render();
void Release();
int GetId();
};};}; };};};
#endif #endif

View File

@ -2,13 +2,6 @@
#include "DllInterfaces/GFXAPI.h" #include "DllInterfaces/GFXAPI.h"
using namespace DanBias::Client; using namespace DanBias::Client;
struct C_UIobject::myData
{
myData(){}
Oyster::Graphics::Model::Model *model;
int ID;
}privData;
C_UIobject::C_UIobject(void) C_UIobject::C_UIobject(void)
{ {
} }
@ -20,29 +13,4 @@ C_UIobject::~C_UIobject(void)
void C_UIobject::Init(ModelInitData modelInit) void C_UIobject::Init(ModelInitData modelInit)
{ {
C_Object::Init(modelInit); C_Object::Init(modelInit);
// load models
privData = new myData();
privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath);
privData->model->Visible = modelInit.visible;
privData->model->WorldMatrix = getWorld();
privData->ID = modelInit.id;
}
void C_UIobject::setPos(Oyster::Math::Float4x4 world)
{
privData->model->WorldMatrix = world;
}
void C_UIobject::Render()
{
Oyster::Graphics::API::RenderModel(privData->model);
}
void C_UIobject::Release()
{
Oyster::Graphics::API::DeleteModel(privData->model);
delete privData;
}
int C_UIobject::GetId()
{
return privData->ID;
} }

View File

@ -8,16 +8,11 @@ namespace DanBias
class C_UIobject : public C_Object class C_UIobject : public C_Object
{ {
private: private:
struct myData;
myData* privData;
public: public:
C_UIobject(void); C_UIobject(void);
virtual ~C_UIobject(void); virtual ~C_UIobject(void);
void Init(ModelInitData modelInit); void Init(ModelInitData modelInit);
void setPos(Oyster::Math::Float4x4 world); void setPos(Oyster::Math::Float4x4 world);
void Render();
void Release();
int GetId();
};};}; };};};
#endif #endif

View File

@ -38,6 +38,11 @@ namespace DanBias { namespace Client
struct KeyInput : public ProtocolStruct struct KeyInput : public ProtocolStruct
{ {
/*
* key[0] =
*
*
*/
bool key[6]; bool key[6];
}; };

View File

@ -2,13 +2,11 @@
#include "DllInterfaces/GFXAPI.h" #include "DllInterfaces/GFXAPI.h"
#include <Protocols.h> #include <Protocols.h>
#include "NetworkClient.h" #include "NetworkClient.h"
//#include "Camera.h" #include "Camera.h"
#include <GameServerAPI.h> #include <GameServerAPI.h>
using namespace ::DanBias::Client; using namespace DanBias::Client;
using namespace ::Oyster::Math3D; using namespace Oyster::Math;
using namespace ::Oyster::Math;
struct GameState::myData struct GameState::myData
{ {
myData(){} myData(){}
@ -16,6 +14,8 @@ struct GameState::myData
int modelCount; int modelCount;
Oyster::Network::NetworkClient* nwClient; Oyster::Network::NetworkClient* nwClient;
gameStateState state; gameStateState state;
}privData; }privData;
GameState::GameState(void) GameState::GameState(void)
@ -29,18 +29,18 @@ GameState::GameState(void)
GameState::~GameState(void) GameState::~GameState(void)
{ {
//delete this->camera; delete this->camera;
delete this->privData; delete this->privData;
} }
bool GameState::Init(Oyster::Network::NetworkClient* nwClient) bool GameState::Init(Oyster::Network::NetworkClient* nwClient)
{ {
// load models // load models
//camera = new Camera; camera = new Camera;
privData = new myData(); privData = new myData();
privData->state = gameStateState_loading; privData->state = gameStateState_loading;
privData->nwClient = nwClient; privData->nwClient = nwClient;
privData->state = LoadGame(); privData->state = LoadGame();
//pitch = 0; pitch = 0;
//tELL SERver ready //tELL SERver ready
nwClient->Send(GameLogic::Protocol_General_Status(GameLogic::Protocol_General_Status::States_ready)); nwClient->Send(GameLogic::Protocol_General_Status(GameLogic::Protocol_General_Status::States_ready));
@ -50,34 +50,34 @@ bool GameState::Init(Oyster::Network::NetworkClient* nwClient)
GameState::gameStateState GameState::LoadGame() GameState::gameStateState GameState::LoadGame()
{ {
Oyster::Graphics::Definitions::Pointlight plight; Oyster::Graphics::Definitions::Pointlight plight;
plight.Pos = Float3(315.0f, 0.0f ,5.0f); plight.Pos = Oyster::Math::Float3(315.0f, 0.0f ,5.0f);
plight.Color = Float3(0.9f, 0.7f, 0.2f); plight.Color = Oyster::Math::Float3(0.9f,0.7f,0.2f);
plight.Radius = 100.0f; plight.Radius = 100.0f;
plight.Bright = 0.9f; plight.Bright = 0.9f;
Oyster::Graphics::API::AddLight(plight); Oyster::Graphics::API::AddLight(plight);
plight.Pos = Float3(10.0f, 350.0f, 5.0f); plight.Pos = Oyster::Math::Float3(10.0f,350.0f,5.0f);
plight.Color = Float3(0.9f, 0.7f, 0.3f); plight.Color = Oyster::Math::Float3(0.9f,0.7f,0.3f);
plight.Radius = 200.0f; plight.Radius = 200.0f;
plight.Bright = 0.7f; plight.Bright = 0.7f;
Oyster::Graphics::API::AddLight(plight); Oyster::Graphics::API::AddLight(plight);
plight.Pos = Float3(350.0f, 350.0f, 5.0f); plight.Pos = Oyster::Math::Float3(350.0f,350.0f,5.0f);
plight.Color = Float3(0.9f, 0.7f, 0.3f); plight.Color = Oyster::Math::Float3(0.9f,0.7f,0.3f);
plight.Radius = 200.0f; plight.Radius = 200.0f;
plight.Bright = 0.7f; plight.Bright = 0.7f;
Oyster::Graphics::API::AddLight(plight); Oyster::Graphics::API::AddLight(plight);
plight.Pos = Float3(10.0f, 350.0f, 350.0f); plight.Pos = Oyster::Math::Float3(10.0f,350.0f,350.0f);
plight.Color = Float3(0.9f, 0.7f, 0.3f); plight.Color = Oyster::Math::Float3(0.9f,0.7f,0.3f);
plight.Radius = 200.0f; plight.Radius = 200.0f;
plight.Bright = 0.7f; plight.Bright = 0.7f;
Oyster::Graphics::API::AddLight(plight); Oyster::Graphics::API::AddLight(plight);
plight.Pos = Float3(10.0f, -15.0f, 5.0f); plight.Pos = Oyster::Math::Float3(10.0f,-15.0f,5.0f);
plight.Color = Float3(0.0f, 0.0f, 1.0f); plight.Color = Oyster::Math::Float3(0.0f,0.0f,1.0f);
plight.Radius = 50.0f; plight.Radius = 50.0f;
plight.Bright = 2.0f; plight.Bright = 2.0f;
Oyster::Graphics::API::AddLight(plight); Oyster::Graphics::API::AddLight(plight);
// use level loader LoadModels();
InitCamera( Float3(0.0f, 0.0f, 20.0f) ); InitCamera(Oyster::Math::Float3(0.0f,0.0f,20.0f));
// hardcoded objects // hardcoded objects
LoadModels(); LoadModels();
Float3 startPos = Float3(0,0,20.0f); Float3 startPos = Float3(0,0,20.0f);
@ -95,9 +95,9 @@ bool GameState::LoadModels()
// add world model // add world model
ModelInitData modelData; ModelInitData modelData;
modelData.position = Float3(0,0,0); modelData.position = Oyster::Math::Float3(0,0,0);
modelData.rotation = Quaternion::identity; modelData.rotation = Oyster::Math::Quaternion::identity;
modelData.scale = Float3(2,2,2); modelData.scale = Oyster::Math::Float3(2,2,2);
modelData.modelPath = L"world_earth.dan"; modelData.modelPath = L"world_earth.dan";
modelData.id = id++; modelData.id = id++;
@ -105,17 +105,17 @@ bool GameState::LoadModels()
this->staticObjects.Push(new C_StaticObj()); this->staticObjects.Push(new C_StaticObj());
this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData); this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData);
/*
// add box model // add box model
modelData.position = Float3(0,0,0); modelData.position = Oyster::Math::Float3(0,0,0);
modelData.rotation = Quaternion::identity; modelData.rotation = Oyster::Math::Quaternion::identity;
modelData.scale = Float3(1,1,1); modelData.scale = Oyster::Math::Float3(1,1,1);
modelData.modelPath = L"crate_colonists.dan"; modelData.modelPath = L"crate_colonists.dan";
for(int i =0; i< nrOfBoxex; i ++) for(int i =0; i< nrOfBoxex; i ++)
{ {
modelData.position = Float3(4,320,0); modelData.position = Oyster::Math::Float3(4,320,0);
modelData.id = id++; modelData.id = id++;
this->dynamicObjects.Push(new C_DynamicObj()); this->dynamicObjects.Push(new C_DynamicObj());
@ -124,7 +124,7 @@ bool GameState::LoadModels()
// add crystal model // add crystal model
modelData.position = Float3(10, 301, 0); modelData.position = Oyster::Math::Float3(10, 301, 0);
modelData.modelPath = L"crystalformation_b.dan"; modelData.modelPath = L"crystalformation_b.dan";
modelData.id = id++; modelData.id = id++;
// load models // load models
@ -132,8 +132,8 @@ bool GameState::LoadModels()
this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);
// add house model // add house model
modelData.position = Float3(-50, 290, 0); modelData.position = Oyster::Math::Float3(-50, 290, 0);
//Oyster::Math3D::Float4x4 rot = Oyster::Math3D::RotationMatrix(Float3(0 ,Utility::Value::Radian(90.0f), 0)); //Oyster::Math3D::Float4x4 rot = Oyster::Math3D::RotationMatrix(Oyster::Math::Float3(0 ,Utility::Value::Radian(90.0f), 0));
modelData.visible = true; modelData.visible = true;
modelData.modelPath = L"building_corporation.dan"; modelData.modelPath = L"building_corporation.dan";
@ -144,7 +144,7 @@ bool GameState::LoadModels()
// add player model // add player model
modelData.position = Float3(0, 320, 0); modelData.position = Oyster::Math::Float3(0, 320, 0);
modelData.modelPath = L"char_still_sizeref.dan"; modelData.modelPath = L"char_still_sizeref.dan";
modelData.id = id++; modelData.id = id++;
// load models // load models
@ -152,7 +152,7 @@ bool GameState::LoadModels()
this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);
// add player model 2 // add player model 2
modelData.position = Float3(50, 320, 0); modelData.position = Oyster::Math::Float3(50, 320, 0);
modelData.modelPath = L"char_still_sizeref.dan"; modelData.modelPath = L"char_still_sizeref.dan";
modelData.id = id++; modelData.id = id++;
// load models // load models
@ -160,7 +160,7 @@ bool GameState::LoadModels()
this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);
// add jumppad // add jumppad
modelData.position = Float3(4.0f, 300.3f, 0.0f); modelData.position = Oyster::Math::Float3(4, 300.3, 0);
modelData.modelPath = L"jumppad_round.dan"; modelData.modelPath = L"jumppad_round.dan";
modelData.id = id++; modelData.id = id++;
// load models // load models
@ -168,13 +168,13 @@ bool GameState::LoadModels()
this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);
// add sky sphere // add sky sphere
modelData.position = Float3(0,0,0); modelData.position = Oyster::Math::Float3(0,0,0);
modelData.scale = Float3(800,800,800); modelData.scale = Oyster::Math::Float3(800,800,800);
modelData.modelPath = L"skysphere.dan"; modelData.modelPath = L"skysphere.dan";
modelData.id = id++; modelData.id = id++;
// load models // load models
this->dynamicObjects.Push(new C_DynamicObj()); this->dynamicObjects.Push(new C_DynamicObj());
this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);*/
return true; return true;
} }
bool GameState::LoadModels(std::string mapFile) bool GameState::LoadModels(std::string mapFile)
@ -202,8 +202,8 @@ bool GameState::LoadModels(std::string mapFile)
modelData.modelPath.assign(staticObjData->ModelFile.begin(), staticObjData->ModelFile.end()); modelData.modelPath.assign(staticObjData->ModelFile.begin(), staticObjData->ModelFile.end());
modelData.visible = true; modelData.visible = true;
//modelData.position = ; //modelData.position = ;
//modelData.rotation = Quaternion(Float3(2,2,-2), 1); //modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(2,2,-2), 1);
//modelData.scale = Float3(2,2,2); //modelData.scale = Oyster::Math::Float3(2,2,2);
modelData.id = modelId++; modelData.id = modelId++;
this->staticObjects.Push(new C_StaticObj()); this->staticObjects.Push(new C_StaticObj());
@ -214,8 +214,8 @@ bool GameState::LoadModels(std::string mapFile)
{ {
GameLogic::ObjectHeader* dynamicObjData = ((GameLogic::ObjectHeader*)obj); GameLogic::ObjectHeader* dynamicObjData = ((GameLogic::ObjectHeader*)obj);
//modelData.position = ; //modelData.position = ;
//modelData.rotation = Quaternion(Float3(2,2,-2), 1); //modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(2,2,-2), 1);
//modelData.scale = Float3(2,2,2); //modelData.scale = Oyster::Math::Float3(2,2,2);
modelData.modelPath.assign(dynamicObjData->ModelFile.begin(), dynamicObjData->ModelFile.end()); modelData.modelPath.assign(dynamicObjData->ModelFile.begin(), dynamicObjData->ModelFile.end());
modelData.visible = true; modelData.visible = true;
modelData.id = modelId++; modelData.id = modelId++;
@ -246,8 +246,8 @@ bool GameState::LoadModels(std::string mapFile)
myId += modelId++; myId += modelId++;
// add player model // add player model
//modelData.position = ; //modelData.position = ;
//modelData.rotation = Quaternion(Float3(2,2,-2), 1); //modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(2,2,-2), 1);
//modelData.scale = Float3(2,2,2); //modelData.scale = Oyster::Math::Float3(2,2,2);
modelData.visible = true; modelData.visible = true;
@ -266,33 +266,17 @@ bool GameState::LoadModels(std::string mapFile)
} }
bool GameState::InitCamera(Float3 startPos) bool GameState::InitCamera(Float3 startPos)
{ {
camera.SetHeadOffset( Float3(0.0f, 1.0f, -2.0f) ); Float3 dir = Float3(0,0,1);
//Float3 dir = Float3(0,0,1); Float3 up = Float3(0,1,0);
//Float3 up = Float3(0,1,0); Float3 pos = Float3(0, 0, 20);
//Float3 pos = Float3(0, 0, 20); camera->LookAt(pos, dir, up);
camera->SetLens(pi/4, 1024/768, 1, 1000);
camera->UpdateViewMatrix();
Oyster::Graphics::API::SetProjection(camera->Proj());
//camera->LookAt(pos, dir, up);
//camera->SetLens(3.14f/2, 1024/768, 1, 1000);
camera.SetPerspectiveProjection( pi/2.0f, 1024.0f/768.0f, 1.0f, 1000.0f );
Oyster::Graphics::API::SetProjection( Float4x4(camera.GetProjectionMatrix()) ); // TODO: remove copy wrapper when no longer needed
//camera->LookAt(pos, dir, up);
//camera->SetLens(3.14f/2, 1024/768, 1, 1000);
//privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(pi/4,1024.0f/768.0f,.1f,1000);
//camera->UpdateViewMatrix();
//privData->view = camera->View();
//privData->view = Oyster::Math3D::ViewMatrix_LookAtDirection(Float3(0,0,-1),Float3(0,1,0),startPos);
//privData->view = Oyster::Math3D::OrientationMatrix_LookAtDirection(Float3(0,0,-1),Float3(0,1,0),startPos);
//Oyster::Graphics::API::SetProjection(camera->Proj());
//privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view);
return true; return true;
} }
void GameState::InitiatePlayer(int id, std::wstring modelName, Oyster::Math::Float4x4 world)
void GameState::InitiatePlayer(int id, std::wstring modelName, Float4x4 world)
{ {
myId = id; myId = id;
@ -300,9 +284,9 @@ void GameState::InitiatePlayer(int id, std::wstring modelName, Float4x4 world)
C_Object* obj; C_Object* obj;
modelData.visible = true; modelData.visible = true;
//modelData.world = world; //modelData.world = world;
modelData.position = Float3(world[12], world[13], world[14]); modelData.position = Oyster::Math::Float3(world[12], world[13], world[14]);
modelData.rotation = Quaternion(Float3(0,0,0), 1); modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(0,0,0), 1);
modelData.scale = Float3(1,1,1); modelData.scale = Oyster::Math::Float3(1,1,1);
modelData.modelPath = modelName; modelData.modelPath = modelName;
modelData.id = myId; modelData.id = myId;
@ -311,33 +295,34 @@ void GameState::InitiatePlayer(int id, std::wstring modelName, Float4x4 world)
this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);
Float3 right = Float3(world[0], world[1], world[2]); Oyster::Math::Float3 right = Oyster::Math::Float3(world[0], world[1], world[2]);
Float3 up = Float3(world[4], world[5], world[6]); Oyster::Math::Float3 up = Oyster::Math::Float3(world[4], world[5], world[6]);
Float3 objForward = (Float3(world[8], world[9], world[10])); Oyster::Math::Float3 objForward = (Oyster::Math::Float3(world[8], world[9], world[10]));
Float3 pos = Float3(world[12], world[13], world[14]); Oyster::Math::Float3 pos = Oyster::Math::Float3(world[12], world[13], world[14]);
//Float3 cameraLook = camera->GetLook(); Oyster::Math::Float3 cameraLook = camera->GetLook();
//Float3 cameraUp = camera->GetUp(); Oyster::Math::Float3 cameraUp = camera->GetUp();
/*Float3 newUp = cameraUp.Dot(up);
/*Oyster::Math::Float3 newUp = cameraUp.Dot(up);
up *= newUp; up *= newUp;
up.Normalize(); up.Normalize();
Float3 newLook = up.Cross(right); Oyster::Math::Float3 newLook = up.Cross(right);
newLook.Normalize();*/ newLook.Normalize();*/
//camera->setRight(right); camera->setRight(right);
//camera->setUp(up); camera->setUp(up);
//camera->setLook(objForward); camera->setLook(objForward);
//up *= 2; up *= 2;
//objForward *= -3; objForward *= 3;
//Float3 cameraPos = up + pos + objForward; Oyster::Math::Float3 cameraPos = up + pos + objForward;
//camera->SetPosition(cameraPos); camera->SetPosition(cameraPos);
//camera->UpdateViewMatrix(); camera->UpdateViewMatrix();
} }
GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyInput) GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyInput)
{ {
switch (privData->state) switch (privData->state)
@ -358,8 +343,7 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
// update objects // update objects
{ {
readKeyInput(KeyInput); readKeyInput(KeyInput);
camera.UpdateOrientation(); camera->UpdateViewMatrix();
//camera->UpdateViewMatrix();
} }
break; break;
@ -375,12 +359,7 @@ GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyI
} }
bool GameState::Render() bool GameState::Render()
{ {
Oyster::Graphics::API::SetView( camera.GetViewMatrix() ); Oyster::Graphics::API::SetView(camera->View());
//Oyster::Graphics::API::SetView(camera->View());
//Oyster::Graphics::API::SetProjection(camera->Proj());
//Oyster::Graphics::API::SetView(privData->view);
//Oyster::Graphics::API::SetProjection(privData->proj);
Oyster::Graphics::API::NewFrame(); Oyster::Graphics::API::NewFrame();
for (unsigned int i = 0; i < staticObjects.Size(); i++) for (unsigned int i = 0; i < staticObjects.Size(); i++)
@ -411,20 +390,11 @@ bool GameState::Release()
void GameState::readKeyInput(InputClass* KeyInput) void GameState::readKeyInput(InputClass* KeyInput)
{ {
bool send = false;
GameLogic::Protocol_PlayerMovement movePlayer;
movePlayer.bForward = false;
movePlayer.bBackward = false;
movePlayer.bLeft = false;
movePlayer.bRight = false;
if(KeyInput->IsKeyPressed(DIK_W)) if(KeyInput->IsKeyPressed(DIK_W))
{ {
if(!key_forward) if(!key_forward)
{ {
movePlayer.bForward = true; privData->nwClient->Send(GameLogic::Protocol_PlayerMovementForward());
send = true;
key_forward = true; key_forward = true;
} }
} }
@ -435,8 +405,7 @@ void GameState::readKeyInput(InputClass* KeyInput)
{ {
if(!key_backward) if(!key_backward)
{ {
movePlayer.bBackward = true; privData->nwClient->Send(GameLogic::Protocol_PlayerMovementBackward());
send = true;
key_backward = true; key_backward = true;
} }
} }
@ -447,8 +416,7 @@ void GameState::readKeyInput(InputClass* KeyInput)
{ {
if(!key_strafeLeft) if(!key_strafeLeft)
{ {
movePlayer.bLeft = true; privData->nwClient->Send(GameLogic::Protocol_PlayerMovementLeft());
send = true;
key_strafeLeft = true; key_strafeLeft = true;
} }
} }
@ -459,8 +427,7 @@ void GameState::readKeyInput(InputClass* KeyInput)
{ {
if(!key_strafeRight) if(!key_strafeRight)
{ {
movePlayer.bRight = true; privData->nwClient->Send(GameLogic::Protocol_PlayerMovementRight());
send = true;
key_strafeRight = true; key_strafeRight = true;
} }
} }
@ -468,25 +435,15 @@ void GameState::readKeyInput(InputClass* KeyInput)
key_strafeRight = false; key_strafeRight = false;
if (privData->nwClient->IsConnected() && send)
{
privData->nwClient->Send(movePlayer);
}
//send delta mouse movement //send delta mouse movement
//if (KeyInput->IsMousePressed()) //if (KeyInput->IsMousePressed())
{ {
camera.YawRight( KeyInput->GetYaw() ); camera->Yaw(-KeyInput->GetYaw());
camera.PitchUp( KeyInput->GetPitch() ); camera->Pitch(KeyInput->GetPitch());
camera.UpdateOrientation(); pitch = KeyInput->GetPitch();
camera->UpdateViewMatrix();
//camera->Yaw(-KeyInput->GetYaw());
//->Pitch(KeyInput->GetPitch());
//pitch = KeyInput->GetPitch();
//camera->UpdateViewMatrix();
GameLogic::Protocol_PlayerLook playerLookDir; GameLogic::Protocol_PlayerLook playerLookDir;
Float4 look = Float4( camera.GetLook(), 0.0f ); Oyster::Math::Float4 look = camera->GetLook();
//Float4 look = camera->GetLook();
playerLookDir.lookDirX = look.x; playerLookDir.lookDirX = look.x;
playerLookDir.lookDirY = look.y; playerLookDir.lookDirY = look.y;
playerLookDir.lookDirZ = look.z; playerLookDir.lookDirZ = look.z;
@ -544,9 +501,7 @@ void GameState::readKeyInput(InputClass* KeyInput)
{ {
if(!key_Jump) if(!key_Jump)
{ {
GameLogic::Protocol_PlayerJump playerJump; privData->nwClient->Send(GameLogic::Protocol_PlayerJump());
playerJump.hasJumped = true;
privData->nwClient->Send(playerJump);
key_Jump = true; key_Jump = true;
} }
} }
@ -566,14 +521,11 @@ void GameState::Protocol(ProtocolStruct* pos)
void GameState::Protocol( PlayerPos* pos ) void GameState::Protocol( PlayerPos* pos )
{ {
//camera.SetPosition( pos->position ); //Oyster::Math::Float4x4 world, translate;
//camera.SetAngular( pos->angularAxis );
//Float4x4 world, translate; //world = Oyster::Math::Float4x4::identity;
//translate = Oyster::Math::Float4x4::identity;
//world = Float4x4::identity; //translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(pos->playerPos[0],pos->playerPos[1],pos->playerPos[2]));
//translate = Float4x4::identity;
//translate = Oyster::Math3D::TranslationMatrix(Float3(pos->playerPos[0],pos->playerPos[1],pos->playerPos[2]));
//world = world * translate; //world = world * translate;
////privData->object[0]->setPos( world ); ////privData->object[0]->setPos( world );
//for (unsigned int i = 0; i < dynamicObjects.Size(); i++) //for (unsigned int i = 0; i < dynamicObjects.Size(); i++)
@ -584,50 +536,46 @@ void GameState::Protocol( PlayerPos* pos )
void GameState::Protocol( ObjPos* pos ) void GameState::Protocol( ObjPos* pos )
{ {
//Float4x4 world; Oyster::Math::Float4x4 world;
//for(int i = 0; i<16; i++) for(int i = 0; i<16; i++)
//{ {
// world[i] = pos->worldPos[i]; world[i] = pos->worldPos[i];
//} }
//printf("pos for obj %d, ",pos->object_ID ); //printf("pos for obj %d, ",pos->object_ID );
for (unsigned int i = 0; i < dynamicObjects.Size(); i++) for (unsigned int i = 0; i < dynamicObjects.Size(); i++)
{ {
if(dynamicObjects[i]->GetId() == pos->object_ID) if(dynamicObjects[i]->GetId() == pos->object_ID)
{ {
dynamicObjects[i]->setPos( pos->position );
dynamicObjects[i]->setRot( Quaternion(Float3(pos->rotation), pos->rotation[3]) );
//dynamicObjects[i]->setPos(Float3(world[12], world[13], world[14])); //dynamicObjects[i]->setPos(Float3(world[12], world[13], world[14]));
dynamicObjects[i]->setWorld(world);
if(dynamicObjects[i]->GetId() == myId) // playerobj if(dynamicObjects[i]->GetId() == myId) // playerobj
{ {
camera.SetPosition( pos->position ); Float3 right = Float3(world[0], world[1], world[2]);
camera.SetAngular( QuaternionToAngularAxis(Quaternion(pos->rotation, pos->rotation[3])).xyz ); Float3 up = Float3(world[4], world[5], world[6]);
Float3 objForward = Float3(world[8], world[9], world[10]);
Float3 pos = Float3(world[12], world[13], world[14]);
//Float3 right = Float3(world[0], world[1], world[2]); Float3 cameraLook = camera->GetLook();
//Float3 up = Float3(world[4], world[5], world[6]); Float3 cameraUp = camera->GetUp();
//Float3 objForward = Float3(world[8], world[9], world[10]);
//Float3 pos = Float3(world[12], world[13], world[14]);
//Float3 cameraLook = camera->GetLook();
//Float3 cameraUp = camera->GetUp();
/*Float3 newUp = cameraUp.Dot(up);
/*Oyster::Math::Float3 newUp = cameraUp.Dot(up);
up *= newUp; up *= newUp;
up.Normalize(); up.Normalize();
Float3 newLook = up.Cross(right); Oyster::Math::Float3 newLook = up.Cross(right);
newLook.Normalize();*/ newLook.Normalize();*/
//camera->setRight(right); //camera->setRight(right);
//camera->setUp(up); //camera->setUp(up);
//camera->setLook(objForward); //camera->setLook(objForward);
//up *= 1; up *= 1;
//objForward *= -2; objForward *= -2;
//Float3 cameraPos = pos + up + objForward; Oyster::Math::Float3 cameraPos = pos + up + objForward;
//camera->SetPosition(cameraPos); //camera->SetPosition(cameraPos);
//camera->UpdateViewMatrix(); //camera->UpdateViewMatrix();
@ -639,7 +587,7 @@ void GameState::Protocol( ObjPos* pos )
void GameState::Protocol( NewObj* newObj ) void GameState::Protocol( NewObj* newObj )
{ {
Float4x4 world; Oyster::Math::Float4x4 world;
for(int i = 0; i<16; i++) for(int i = 0; i<16; i++)
{ {
world[i] = newObj->worldPos[i]; world[i] = newObj->worldPos[i];

View File

@ -36,6 +36,8 @@ namespace GameLogic
int GetTeamID() const override; int GetTeamID() const override;
PLAYER_STATE GetState() const override; PLAYER_STATE GetState() const override;
Oyster::Math::Float3 GetPosition() override; Oyster::Math::Float3 GetPosition() override;
Oyster::Math::Quaternion GetRotation() override;
Oyster::Math::Float3 GetScale() override;
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;
@ -50,6 +52,8 @@ namespace GameLogic
LevelData(); LevelData();
~LevelData(); ~LevelData();
Oyster::Math::Float3 GetPosition() override; Oyster::Math::Float3 GetPosition() override;
Oyster::Math::Quaternion GetRotation() override;
Oyster::Math::Float3 GetScale() override;
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;

View File

@ -36,10 +36,22 @@ namespace GameLogic
public: public:
/******************************************************** /********************************************************
* Gets players position * Gets players position
* @param playerID: ID of the player whos position you want * @return Returns the players position
********************************************************/ ********************************************************/
virtual Oyster::Math::Float3 GetPosition() = 0; virtual Oyster::Math::Float3 GetPosition() = 0;
/********************************************************
* Gets players rotation as quaternion
* @return Returns a quaternion
********************************************************/
virtual Oyster::Math::Quaternion GetRotation() = 0;
/********************************************************
* Gets players position
* @return Returns the player scale
********************************************************/
virtual Oyster::Math::Float3 GetScale() = 0;
/******************************************************** /********************************************************
* Gets players current orientation * Gets players current orientation
* @param playerID: ID of the player whos position you want * @param playerID: ID of the player whos position you want

View File

@ -20,6 +20,14 @@ Oyster::Math::Float3 Game::LevelData::GetPosition()
//return this->level->GetCenter(); //return this->level->GetCenter();
return Oyster::Math::Float3(); return Oyster::Math::Float3();
} }
Oyster::Math::Quaternion Game::LevelData::GetRotation()
{
return Oyster::Math::Quaternion();
}
Oyster::Math::Float3 Game::LevelData::GetScale()
{
return Oyster::Math::Float3();
}
Oyster::Math::Float4x4 Game::LevelData::GetOrientation() Oyster::Math::Float4x4 Game::LevelData::GetOrientation()
{ {
//return this->level->GetOrientation(); //return this->level->GetOrientation();

View File

@ -6,9 +6,9 @@ using namespace GameLogic;
Game::PlayerData::PlayerData() Game::PlayerData::PlayerData()
{ {
//set some stats that are appropriate to a player //set some stats that are appropriate to a player
Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(0,608,-5); Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(0,628,-25);
Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,1.0f,0.5f); Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,1.0f,0.5f);
Oyster::Math::Float mass = 15; Oyster::Math::Float mass = 60;
Oyster::Math::Float restitutionCoeff = 0.5; Oyster::Math::Float restitutionCoeff = 0.5;
Oyster::Math::Float frictionCoeff_Static = 0.4; Oyster::Math::Float frictionCoeff_Static = 0.4;
Oyster::Math::Float frictionCoeff_Dynamic = 0.3; Oyster::Math::Float frictionCoeff_Dynamic = 0.3;
@ -48,6 +48,14 @@ Oyster::Math::Float3 Game::PlayerData::GetPosition()
{ {
return this->player->GetPosition(); return this->player->GetPosition();
} }
Oyster::Math::Quaternion Game::PlayerData::GetRotation()
{
return this->player->GetRotation();
}
Oyster::Math::Float3 Game::PlayerData::GetScale()
{
return this->player->GetScale();
}
Oyster::Math::Float4x4 Game::PlayerData::GetOrientation() Oyster::Math::Float4x4 Game::PlayerData::GetOrientation()
{ {
return this->player->GetOrientation(); return this->player->GetOrientation();

View File

@ -112,36 +112,6 @@ void Level::InitiateLevel(std::string levelPath)
} }
void Level::InitiateLevel(float radius) void Level::InitiateLevel(float radius)
{ {
float heading = Utility::Value::Radian(180.0f);
float attitude = Utility::Value::Radian(0.0f);
float bank = Utility::Value::Radian(0);
double c1 = cos(heading/2);
double s1 = sin(heading/2);
double c2 = cos(attitude/2);
double s2 = sin(attitude/2);
double c3 = cos(bank/2);
double s3 = sin(bank/2);
double c1c2 = c1*c2;
double s1s2 = s1*s2;
double w =c1c2*c3 - s1s2*s3;
double x =c1c2*s3 + s1s2*c3;
double y =s1*c2*c3 + c1*s2*s3;
double z =c1*s2*c3 - s1*c2*s3;
double angle = 2 * acos(w);
double norm = x*x+y*y+z*z;
if (norm < 0.001) { // when all euler angles are zero angle =0 so
// we can set axis to anything to avoid divide by zero
x=1;
y=z=0;
} else {
norm = sqrt(norm);
x /= norm;
y /= norm;
z /= norm;
}
int idCount = 100; int idCount = 100;
// add level sphere // add level sphere
ICustomBody* rigidBody = API::Instance().AddCollisionSphere(599.2f, Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f); ICustomBody* rigidBody = API::Instance().AddCollisionSphere(599.2f, Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f);
@ -149,7 +119,7 @@ void Level::InitiateLevel(float radius)
this->levelObj->objectID = idCount++; this->levelObj->objectID = idCount++;
rigidBody->SetCustomTag(levelObj); rigidBody->SetCustomTag(levelObj);
/*
ICustomBody* rigidBody_TestBox; ICustomBody* rigidBody_TestBox;
int nrOfBoxex = 5; int nrOfBoxex = 5;
@ -162,7 +132,8 @@ void Level::InitiateLevel(float radius)
this->dynamicObjects[i]->objectID = idCount++; this->dynamicObjects[i]->objectID = idCount++;
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i]); rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i]);
} }
/*offset += nrOfBoxex;
offset += nrOfBoxex;
for(int i =0; i< nrOfBoxex; i ++) for(int i =0; i< nrOfBoxex; i ++)
{ {
rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0,5, -605 -( i*5)), 5); rigidBody_TestBox = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0,5, -605 -( i*5)), 5);
@ -187,26 +158,19 @@ void Level::InitiateLevel(float radius)
this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i]); rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i]);
}*/ }
// add crystal
ICustomBody* rigidBody_Crystal = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(10, 605, 0), 5);
this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX));
rigidBody_Crystal->SetCustomTag(this->dynamicObjects[nrOfBoxex]);
//// add crystal // add house
ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(10, 905, 0), 0);
//ICustomBody* rigidBody_Crystal = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(10, 605, 0), 5); this->staticObjects.Push(new StaticObject(rigidBody_House,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_GENERIC));
rigidBody_House->SetCustomTag(this->staticObjects[0]);
//this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); */
//rigidBody_Crystal->SetCustomTag(this->dynamicObjects[nrOfBoxex]);
//
//// add house
//ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(10, 905, 0), 0);
//this->staticObjects.Push(new StaticObject(rigidBody_House,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_GENERIC));
//rigidBody_House->SetCustomTag(this->staticObjects[0]);
} }
void Level::AddPlayerToTeam(Player *player, int teamID) void Level::AddPlayerToTeam(Player *player, int teamID)

View File

@ -20,8 +20,6 @@ Object::Object()
this->type = OBJECT_TYPE::OBJECT_TYPE_UNKNOWN; this->type = OBJECT_TYPE::OBJECT_TYPE_UNKNOWN;
this->objectID = GID(); this->objectID = GID();
this->currPhysicsState = this->rigidBody->GetState();
this->newPhysicsState = this->currPhysicsState;
} }
Object::Object(OBJECT_TYPE type) Object::Object(OBJECT_TYPE type)
@ -29,8 +27,6 @@ Object::Object(OBJECT_TYPE type)
this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f); this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f);
this->type = type; this->type = type;
this->objectID = GID(); this->objectID = GID();
this->currPhysicsState = this->rigidBody->GetState();
this->newPhysicsState = this->currPhysicsState;
} }
Object::Object(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type) Object::Object(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type)
@ -38,8 +34,6 @@ Object::Object(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type)
this->rigidBody = rigidBody; this->rigidBody = rigidBody;
this->type = type; this->type = type;
this->objectID = GID(); this->objectID = GID();
this->currPhysicsState = this->rigidBody->GetState();
this->newPhysicsState = this->currPhysicsState;
} }
Object::Object(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) Object::Object(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type)
@ -48,8 +42,6 @@ Object::Object(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE
this->type = type; this->type = type;
this->objectID = GID(); this->objectID = GID();
this->currPhysicsState = this->rigidBody->GetState();
this->newPhysicsState = this->currPhysicsState;
} }
Object::Object(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) Object::Object(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type)
@ -58,19 +50,14 @@ Object::Object(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefor
this->type = type; this->type = type;
this->objectID = GID(); this->objectID = GID();
this->currPhysicsState = this->rigidBody->GetState();
this->newPhysicsState = this->currPhysicsState;
} }
Object::Object(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) Object::Object(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type)
{ {
this->rigidBody = rigidBody; this->rigidBody = rigidBody;
this->type = type; this->type = type;
this->objectID = GID(); this->objectID = GID();
this->currPhysicsState = this->rigidBody->GetState();
this->newPhysicsState = this->currPhysicsState;
} }
void Object::ApplyLinearImpulse(Oyster::Math::Float3 force) void Object::ApplyLinearImpulse(Oyster::Math::Float3 force)
@ -102,12 +89,11 @@ Oyster::Physics::ICustomBody* Object::GetRigidBody()
void Object::BeginFrame() void Object::BeginFrame()
{ {
this->rigidBody->SetState(this->newPhysicsState);
} }
// update physic // update physic
void Object::EndFrame() void Object::EndFrame()
{ {
this->newPhysicsState = this->currPhysicsState;
} }
void Object::setBeforeCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter)) void Object::setBeforeCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter))
@ -125,6 +111,18 @@ Oyster::Math::Float3 Object::GetPosition()
state = this->rigidBody->GetState(); state = this->rigidBody->GetState();
return state.centerPos; return state.centerPos;
} }
Oyster::Math::Quaternion Object::GetRotation()
{
Oyster::Physics::ICustomBody::State state;
state = this->rigidBody->GetState();
return state.quaternion;
}
Oyster::Math::Float3 Object::GetScale()
{
Oyster::Physics::ICustomBody::State state;
state = this->rigidBody->GetState();
return Float3();
}
Oyster::Math::Float4x4 Object::GetOrientation() Oyster::Math::Float4x4 Object::GetOrientation()
{ {
Oyster::Physics::ICustomBody::State state; Oyster::Physics::ICustomBody::State state;

View File

@ -25,13 +25,14 @@ namespace GameLogic
Object(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type); Object(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type);
~Object(void); ~Object(void);
// API overrides OBJECT_TYPE GetObjectType() const override;
OBJECT_TYPE GetObjectType() const; int GetID() const override;
void setID(int id); Oyster::Math::Float3 GetPosition() override;
int GetID() const; Oyster::Math::Quaternion GetRotation() override;
Oyster::Math::Float3 GetPosition(); Oyster::Math::Float3 GetScale() override;
Oyster::Math::Float4x4 GetOrientation(); Oyster::Math::Float4x4 GetOrientation() override;
void setID(int id);
Oyster::Physics::ICustomBody* GetRigidBody(); Oyster::Physics::ICustomBody* GetRigidBody();
void ApplyLinearImpulse(Oyster::Math::Float3 force); void ApplyLinearImpulse(Oyster::Math::Float3 force);
@ -45,14 +46,12 @@ namespace GameLogic
static Oyster::Physics::ICustomBody::SubscriptMessage DefaultCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj); static Oyster::Physics::ICustomBody::SubscriptMessage DefaultCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj);
static Oyster::Physics::ICustomBody::SubscriptMessage DefaultCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss); static Oyster::Physics::ICustomBody::SubscriptMessage DefaultCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss);
public: //TODO: Hax This should be private when level is dynamic public: //HACK: This should be private when level is dynamic
OBJECT_TYPE type; OBJECT_TYPE type;
int objectID; int objectID;
protected: protected:
Oyster::Physics::ICustomBody *rigidBody; Oyster::Physics::ICustomBody *rigidBody;
Oyster::Physics::ICustomBody::State newPhysicsState;
Oyster::Physics::ICustomBody::State currPhysicsState;
static const Game* gameInstance; static const Game* gameInstance;
Oyster::Math::Float3 currLook; Oyster::Math::Float3 currLook;

View File

@ -70,12 +70,11 @@ void Player::EndFrame()
Object::EndFrame(); Object::EndFrame();
// rotate // rotate
Oyster::Math::Float3 up = currPhysicsState.GetOrientation().v[1]; //Oyster::Math::Float3 up = currPhysicsState.GetOrientation().v[1];
Oyster::Math::Float3 deltaAxis = up * (-dx * 0.02) ; //Oyster::Math::Float3 deltaAxis = up * (-dx * 0.02) ;
//currPhysicsState.AddRotation(deltaAxis); //currPhysicsState.AddRotation(deltaAxis);
dx = 0;
this->newPhysicsState = this->currPhysicsState;
} }
void Player::Move(const PLAYER_MOVEMENT &movement) void Player::Move(const PLAYER_MOVEMENT &movement)
@ -106,33 +105,32 @@ void Player::Move(const PLAYER_MOVEMENT &movement)
void Player::MoveForward() void Player::MoveForward()
{ {
Oyster::Math::Float3 forward = currPhysicsState.GetOrientation().v[2]; Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2];
//Oyster::Math::Float3 forward = lookDir; //Oyster::Math::Float3 forward = lookDir;
//newPhysicsState.ApplyLinearImpulse(forward * (MOVE_FORCE * this->gameInstance->GetFrameTime())); rigidBody->SetLinearVelocity( 10 * forward.GetNormalized() );
//rigidBody->SetLinearVelocity( 10 * this->gameInstance->GetFrameTime() );
} }
void Player::MoveBackwards() void Player::MoveBackwards()
{ {
Oyster::Math::Float3 forward = currPhysicsState.GetOrientation().v[2]; Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2];
//Oyster::Math::Float3 forward = lookDir; //Oyster::Math::Float3 forward = lookDir;
//newPhysicsState.ApplyLinearImpulse(-forward * MOVE_FORCE * this->gameInstance->GetFrameTime()); rigidBody->SetLinearVelocity( 10 * -forward.GetNormalized() );
} }
void Player::MoveRight() void Player::MoveRight()
{ {
//Do cross product with forward vector and negative gravity vector //Do cross product with forward vector and negative gravity vector
Oyster::Math::Float3 forward = currPhysicsState.GetOrientation().v[2]; Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2];
//Oyster::Math::Float3 forward = lookDir; //Oyster::Math::Float3 forward = lookDir;
Oyster::Math::Float3 r = (-currPhysicsState.centerPos.Normalize()).Cross(forward); Oyster::Math::Float3 r = (-this->rigidBody->GetState().centerPos.Normalize()).Cross(forward);
//rigidBody->SetLinearVelocity(-r * 10 * this->gameInstance->GetFrameTime() ); rigidBody->SetLinearVelocity(r * 10);
} }
void Player::MoveLeft() void Player::MoveLeft()
{ {
//Do cross product with forward vector and negative gravity vector //Do cross product with forward vector and negative gravity vector
Oyster::Math::Float3 forward = currPhysicsState.GetOrientation().v[2]; Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2];
//Oyster::Math::Float3 forward = lookDir; //Oyster::Math::Float3 forward = lookDir;
//Oyster::Math::Float3 r = (-currPhysicsState.GetGravityNormal()).Cross(forward); //Still get zero Oyster::Math::Float3 r = (-this->rigidBody->GetState().centerPos.Normalize()).Cross(forward);
//newPhysicsState.ApplyLinearImpulse(r * MOVE_FORCE * this->gameInstance->GetFrameTime()); rigidBody->SetLinearVelocity(-r * 10);
} }
void Player::UseWeapon(const WEAPON_FIRE &usage) void Player::UseWeapon(const WEAPON_FIRE &usage)
@ -145,7 +143,7 @@ void Player::Respawn(Oyster::Math::Float3 spawnPoint)
this->life = 100; this->life = 100;
this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE; this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE;
this->lookDir = Oyster::Math::Float4(1,0,0); this->lookDir = Oyster::Math::Float4(1,0,0);
this->newPhysicsState.centerPos = spawnPoint; //this->newPhysicsState.centerPos = spawnPoint;
} }
void Player::Rotate(const Oyster::Math3D::Float4 lookDir) void Player::Rotate(const Oyster::Math3D::Float4 lookDir)
@ -162,7 +160,7 @@ void Player::Rotate(const Oyster::Math3D::Float4 lookDir)
void Player::Jump() void Player::Jump()
{ {
Oyster::Math::Float3 up = currPhysicsState.GetOrientation().v[1]; Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1];
//newPhysicsState.ApplyLinearImpulse(up * MOVE_FORCE * this->gameInstance->GetFrameTime()); //newPhysicsState.ApplyLinearImpulse(up * MOVE_FORCE * this->gameInstance->GetFrameTime());
} }
@ -181,11 +179,11 @@ bool Player::IsIdle()
Oyster::Math::Float3 Player::GetPosition() const Oyster::Math::Float3 Player::GetPosition() const
{ {
return (Oyster::Math::Float3)currPhysicsState.centerPos; return (Oyster::Math::Float3) this->rigidBody->GetState().centerPos;
} }
Oyster::Math::Float4x4 Player::GetOrientation() const Oyster::Math::Float4x4 Player::GetOrientation() const
{ {
return this->currPhysicsState.GetOrientation(); return this->rigidBody->GetState().GetOrientation();
} }
Oyster::Math::Float3 Player::GetLookDir() const Oyster::Math::Float3 Player::GetLookDir() const
{ {

View File

@ -1,3 +1,8 @@
//////////////////////////////////////////////////////////
// Created 2013 //
// Dennis Andersen, Linda Andersson //
//////////////////////////////////////////////////////////
#ifndef GAMELOGIC_OBJECT_PROTOCOLS_H #ifndef GAMELOGIC_OBJECT_PROTOCOLS_H
#define GAMELOGIC_OBJECT_PROTOCOLS_H #define GAMELOGIC_OBJECT_PROTOCOLS_H
@ -6,6 +11,7 @@
namespace GameLogic namespace GameLogic
{ {
//#define protocol_Gameplay_ObjectPickup 350
struct Protocol_ObjectPickup :public Oyster::Network::CustomProtocolObject struct Protocol_ObjectPickup :public Oyster::Network::CustomProtocolObject
{ {
short object_ID; short object_ID;
@ -50,10 +56,11 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol; Oyster::Network::CustomNetProtocol protocol;
}; };
//#define protocol_Gameplay_ObjectDamage 351
struct Protocol_ObjectDamage :public Oyster::Network::CustomProtocolObject struct Protocol_ObjectDamage :public Oyster::Network::CustomProtocolObject
{ {
int object_ID; int object_ID;
float health; //Precentage% float healthLost; //Precentage%
Protocol_ObjectDamage() Protocol_ObjectDamage()
{ {
@ -64,7 +71,7 @@ namespace GameLogic
this->protocol[2].type = Oyster::Network::NetAttributeType_Float; this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
object_ID = -1; object_ID = -1;
health = 0.0f; healthLost = 0.0f;
} }
Protocol_ObjectDamage(Oyster::Network::CustomNetProtocol& p) Protocol_ObjectDamage(Oyster::Network::CustomNetProtocol& p)
{ {
@ -78,12 +85,12 @@ namespace GameLogic
this->protocol[2].type = Oyster::Network::NetAttributeType_Float; this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
object_ID = id; object_ID = id;
health = hp; healthLost = hp;
} }
Oyster::Network::CustomNetProtocol GetProtocol() override Oyster::Network::CustomNetProtocol GetProtocol() override
{ {
this->protocol[1].value = object_ID; this->protocol[1].value = object_ID;
this->protocol[2].value = health; this->protocol[2].value = healthLost;
return protocol; return protocol;
} }
@ -91,51 +98,89 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol; Oyster::Network::CustomNetProtocol protocol;
}; };
//#define protocol_Gameplay_ObjectHealthStatus 352
struct Protocol_ObjectHealthStatus :public Oyster::Network::CustomProtocolObject
{
float currentHealth;
int id;
Protocol_ObjectHealthStatus()
{
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value.netShort = protocol_Gameplay_ObjectHealthStatus;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->id = 0;
this->currentHealth = 0.0f;
}
Protocol_ObjectHealthStatus(int id, float health)
{
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value.netShort = protocol_Gameplay_ObjectHealthStatus;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->id = id; this->currentHealth = health;
}
Protocol_ObjectHealthStatus(Oyster::Network::CustomNetProtocol& p)
{
this->id = p[1].value.netInt;
this->currentHealth = p[2].value.netFloat;
}
Oyster::Network::CustomNetProtocol GetProtocol() override
{
this->protocol[1].value = this->id;
this->protocol[2].value = this->currentHealth;
return protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
//#define protocol_Gameplay_ObjectPosition 353
struct Protocol_ObjectPosition :public Oyster::Network::CustomProtocolObject struct Protocol_ObjectPosition :public Oyster::Network::CustomProtocolObject
{ {
int object_ID; short object_ID;
float worldMatrix[16]; float position[3];
Protocol_ObjectPosition() Protocol_ObjectPosition()
{ {
this->protocol[0].value = protocol_Gameplay_ObjectPosition; this->protocol[0].value = protocol_Gameplay_ObjectPosition;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short; this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int; object_ID = 0;
memset(&position[0], 0, sizeof(float) * 3);
for (int i = 2; i <= 17; i++)
{
this->protocol[i].type = Oyster::Network::NetAttributeType_Float;
}
object_ID = -1;
memset(&worldMatrix[0], 0, sizeof(float) * 16);
} }
Protocol_ObjectPosition(Oyster::Network::CustomNetProtocol& p) Protocol_ObjectPosition(Oyster::Network::CustomNetProtocol& p)
{ {
object_ID = p[1].value.netShort;
position[0] = p[2].value.netFloat;
position[1] = p[3].value.netFloat;
position[2] = p[4].value.netFloat;
} }
Protocol_ObjectPosition(float m[16], int id) Protocol_ObjectPosition(float v[3], int id)
{ {
this->protocol[0].value = protocol_Gameplay_ObjectPosition; this->protocol[0].value = protocol_Gameplay_ObjectPosition;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short; this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int; this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
for (int i = 2; i <= 17; i++) this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
{
this->protocol[i].type = Oyster::Network::NetAttributeType_Float;
}
object_ID = id; object_ID = id;
memcpy(&worldMatrix[0], &m[0], sizeof(float)*16); memcpy(&position[0], &v[0], sizeof(float) * 3);
} }
Oyster::Network::CustomNetProtocol GetProtocol() override Oyster::Network::CustomNetProtocol GetProtocol() override
{ {
this->protocol[1].value = object_ID; this->protocol[1].value = object_ID;
for (int i = 2; i <= 17; i++) this->protocol[2].value = position[0];
{ this->protocol[3].value = position[1];
this->protocol[i].value = worldMatrix[i-2]; this->protocol[4].value = position[2];
}
return protocol; return protocol;
} }
@ -143,49 +188,202 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol; Oyster::Network::CustomNetProtocol protocol;
}; };
//#define protocol_Gameplay_ObjectScale 354
struct Protocol_ObjectScale :public Oyster::Network::CustomProtocolObject
{
short object_ID;
float position[3];
Protocol_ObjectScale()
{
this->protocol[0].value = protocol_Gameplay_ObjectScale;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
object_ID = 0;
memset(&position[0], 0, sizeof(float) * 3);
}
Protocol_ObjectScale(Oyster::Network::CustomNetProtocol& p)
{
object_ID = p[1].value.netShort;
position[0] = p[2].value.netFloat;
position[1] = p[3].value.netFloat;
position[2] = p[4].value.netFloat;
}
Protocol_ObjectScale(float v[3], int id)
{
this->protocol[0].value = protocol_Gameplay_ObjectScale;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
object_ID = id;
memcpy(&position[0], &v[0], sizeof(float) * 3);
}
Oyster::Network::CustomNetProtocol GetProtocol() override
{
this->protocol[1].value = object_ID;
this->protocol[2].value = position[0];
this->protocol[3].value = position[1];
this->protocol[4].value = position[2];
return protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
//#define protocol_Gameplay_ObjectRotation 355
struct Protocol_ObjectRotation :public Oyster::Network::CustomProtocolObject
{
short object_ID;
float position[3];
Protocol_ObjectRotation()
{
this->protocol[0].value = protocol_Gameplay_ObjectRotation;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
object_ID = 0;
memset(&position[0], 0, sizeof(float) * 3);
}
Protocol_ObjectRotation(Oyster::Network::CustomNetProtocol& p)
{
object_ID = p[1].value.netShort;
position[0] = p[2].value.netFloat;
position[1] = p[3].value.netFloat;
position[2] = p[4].value.netFloat;
}
Protocol_ObjectRotation(float v[3], int id)
{
this->protocol[0].value = protocol_Gameplay_ObjectRotation;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
object_ID = id;
memcpy(&position[0], &v[0], sizeof(float) * 3);
}
Oyster::Network::CustomNetProtocol GetProtocol() override
{
this->protocol[1].value = object_ID;
this->protocol[2].value = position[0];
this->protocol[3].value = position[1];
this->protocol[4].value = position[2];
return protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_ObjectPositionRotation :public Oyster::Network::CustomProtocolObject
{
short object_ID;
float position[3];
float rotation[3];
Protocol_ObjectPositionRotation()
{
this->protocol[0].value = protocol_Gameplay_ObjectPositionRotation;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
//POSITION
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
//ROTATION
this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
this->protocol[6].type = Oyster::Network::NetAttributeType_Float;
this->protocol[7].type = Oyster::Network::NetAttributeType_Float;
this->object_ID = 0;
memset(&this->position[0], 0, sizeof(float) * 3);
memset(&this->rotation[0], 0, sizeof(float) * 3);
}
Protocol_ObjectPositionRotation(Oyster::Network::CustomNetProtocol& p)
{
this->object_ID = p[1].value.netShort;
//POSITION
this->position[0] = p[2].value.netFloat;
this->position[1] = p[3].value.netFloat;
this->position[2] = p[4].value.netFloat;
//ROTATION
this->rotation[0] = p[5].value.netFloat;
this->rotation[1] = p[6].value.netFloat;
this->rotation[2] = p[7].value.netFloat;
}
Protocol_ObjectPositionRotation(float p[3], float r[3], int id)
{
this->protocol[0].value = protocol_Gameplay_ObjectPositionRotation;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Short;
//POSITION
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
this->protocol[4].type = Oyster::Network::NetAttributeType_Float;
//ROTATION
this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
this->protocol[6].type = Oyster::Network::NetAttributeType_Float;
this->protocol[7].type = Oyster::Network::NetAttributeType_Float;
object_ID = id;
memcpy(&this->position[0], &p[0], sizeof(float) * 3);
memcpy(&this->rotation[0], &r[0], sizeof(float) * 3);
}
Oyster::Network::CustomNetProtocol GetProtocol() override
{
this->protocol[1].value = this->object_ID;
this->protocol[2].value = this->position[0];
this->protocol[3].value = this->position[1];
this->protocol[4].value = this->position[2];
this->protocol[5].value = this->rotation[0];
this->protocol[6].value = this->rotation[1];
this->protocol[7].value = this->rotation[2];
return protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
//#define protocol_Gameplay_ObjectEnabled 356
struct Protocol_ObjectEnable :public Oyster::Network::CustomProtocolObject struct Protocol_ObjectEnable :public Oyster::Network::CustomProtocolObject
{ {
int object_ID; int objectID;
float worldMatrix[16];
Protocol_ObjectEnable() Protocol_ObjectEnable()
{ {
this->protocol[0].value = protocol_Gameplay_ObjectEnabled; this->protocol[0].value = protocol_Gameplay_ObjectEnabled;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short; this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int; this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->objectID = -1;
for (int i = 2; i <= 17; i++)
{
this->protocol[i].type = Oyster::Network::NetAttributeType_Float;
} }
object_ID = -1; Protocol_ObjectEnable(int objectID)
memset(&worldMatrix[0], 0, sizeof(float) * 16);
}
Protocol_ObjectEnable(Oyster::Network::CustomNetProtocol& p)
{
}
Protocol_ObjectEnable(float m[16], int id)
{ {
this->protocol[0].value = protocol_Gameplay_ObjectEnabled; this->protocol[0].value = protocol_Gameplay_ObjectEnabled;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short; this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int; this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->objectID = objectID;
for (int i = 2; i <= 17; i++) }
{ this->protocol[i].type = Oyster::Network::NetAttributeType_Float; } Protocol_ObjectEnable(Oyster::Network::CustomNetProtocol& p)
{
object_ID = id; this->objectID = p[1].value.netInt;
memcpy(&worldMatrix[0], &m[0], sizeof(float)*16);
} }
Oyster::Network::CustomNetProtocol GetProtocol() override Oyster::Network::CustomNetProtocol GetProtocol() override
{ {
this->protocol[1].value = object_ID; this->protocol[1].value = this->objectID;
for (int i = 2; i <= 17; i++)
{
this->protocol[i].value = worldMatrix[i-2];
}
return protocol; return protocol;
} }
@ -193,38 +391,39 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol; Oyster::Network::CustomNetProtocol protocol;
}; };
//#define protocol_Gameplay_ObjectDisabled 357
struct Protocol_ObjectDisable :public Oyster::Network::CustomProtocolObject struct Protocol_ObjectDisable :public Oyster::Network::CustomProtocolObject
{ {
int object_ID; int objectID;
float timer; float seconds;
Protocol_ObjectDisable() Protocol_ObjectDisable()
{ {
this->protocol[0].value = protocol_Gameplay_ObjectDisabled; this->protocol[0].value = protocol_Gameplay_ObjectDisabled;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short; this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int; this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float; this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->objectID = 0;
this->seconds = 0.0f;
} }
Protocol_ObjectDisable(Oyster::Network::CustomNetProtocol& p) Protocol_ObjectDisable(int objctID, float seconds)
{
}
Protocol_ObjectDisable(int id, float time)
{ {
this->protocol[0].value = protocol_Gameplay_ObjectDisabled; this->protocol[0].value = protocol_Gameplay_ObjectDisabled;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short; this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int; this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float; this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->objectID = objctID;
object_ID = id; this->seconds = seconds;
timer = time; }
Protocol_ObjectDisable(Oyster::Network::CustomNetProtocol& p)
{
this->objectID = p[1].value.netInt;
this->seconds = p[2].value.netFloat;
} }
Oyster::Network::CustomNetProtocol GetProtocol() override Oyster::Network::CustomNetProtocol GetProtocol() override
{ {
this->protocol[1].value = object_ID; this->protocol[1].value = this->objectID;
this->protocol[2].value = timer; this->protocol[2].value = this->seconds;
return protocol; return protocol;
} }
@ -232,6 +431,7 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol; Oyster::Network::CustomNetProtocol protocol;
}; };
//#define protocol_Gameplay_ObjectCreate 358
struct Protocol_ObjectCreate :public Oyster::Network::CustomProtocolObject struct Protocol_ObjectCreate :public Oyster::Network::CustomProtocolObject
{ {
//ObjectType type; //ie player, box or whatever //ObjectType type; //ie player, box or whatever
@ -304,6 +504,330 @@ namespace GameLogic
private: private:
Oyster::Network::CustomNetProtocol protocol; Oyster::Network::CustomNetProtocol protocol;
}; };
//#define protocol_Gameplay_ObjectCreatePlayer 359
struct Protocol_ObjectCreatePlayer :public Oyster::Network::CustomProtocolObject
{
//ObjectType type; //ie player, box or whatever
int object_ID;
int teamId;
std::string name;
std::string meshName;
float position[3];
float rotation[3];
float scale[3];
Protocol_ObjectCreatePlayer()
{
this->protocol[0].value = protocol_Gameplay_ObjectCreatePlayer;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
//PLAYER_ID
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
//TEAM_ID
this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
//PLAYER-NAME
this->protocol[3].type = Oyster::Network::NetAttributeType_CharArray;
//MESH-NAME
this->protocol[4].type = Oyster::Network::NetAttributeType_CharArray;
//POSITION
this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
this->protocol[6].type = Oyster::Network::NetAttributeType_Float;
this->protocol[7].type = Oyster::Network::NetAttributeType_Float;
//ROTATION
this->protocol[8].type = Oyster::Network::NetAttributeType_Float;
this->protocol[9].type = Oyster::Network::NetAttributeType_Float;
this->protocol[10].type = Oyster::Network::NetAttributeType_Float;
//SCALE
this->protocol[11].type = Oyster::Network::NetAttributeType_Float;
this->protocol[12].type = Oyster::Network::NetAttributeType_Float;
this->protocol[13].type = Oyster::Network::NetAttributeType_Float;
}
Protocol_ObjectCreatePlayer(Oyster::Network::CustomNetProtocol& p)
{
}
Protocol_ObjectCreatePlayer(float position[3], float rotation[3], float scale[3], int ObjectID, int teamID, std::string name, std::string meshName)
{
this->protocol[0].value = protocol_Gameplay_ObjectCreatePlayer;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
//PLAYER_ID
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
//TEAM_ID
this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
//PLAYER-NAME
this->protocol[3].type = Oyster::Network::NetAttributeType_CharArray;
//MESH-NAME
this->protocol[4].type = Oyster::Network::NetAttributeType_CharArray;
//POSITION
this->protocol[5].type = Oyster::Network::NetAttributeType_Float;
this->protocol[6].type = Oyster::Network::NetAttributeType_Float;
this->protocol[7].type = Oyster::Network::NetAttributeType_Float;
//ROTATION
this->protocol[8].type = Oyster::Network::NetAttributeType_Float;
this->protocol[9].type = Oyster::Network::NetAttributeType_Float;
this->protocol[10].type = Oyster::Network::NetAttributeType_Float;
//SCALE
this->protocol[11].type = Oyster::Network::NetAttributeType_Float;
this->protocol[12].type = Oyster::Network::NetAttributeType_Float;
this->protocol[13].type = Oyster::Network::NetAttributeType_Float;
this->object_ID = ObjectID;
this->teamId = teamID;
this->name = name;
this->meshName = meshName;
memcpy(&this->position[0], &position[0], sizeof(float)*3);
memcpy(&this->rotation[0], &rotation[0], sizeof(float)*3);
memcpy(&this->scale[0], &scale[0], sizeof(float)*3);
}
Oyster::Network::CustomNetProtocol GetProtocol() override
{
this->protocol[1].value = this->object_ID;
this->protocol[2].value = this->teamId;
this->protocol.Set(3, this->name);
this->protocol.Set(4, this->meshName);
//POSITION
this->protocol[5].value = this->position[0];
this->protocol[6].value = this->position[1];
this->protocol[7].value = this->position[2];
//ROTATION
this->protocol[8].value = this->rotation[0];
this->protocol[9].value = this->rotation[1];
this->protocol[10].value = this->rotation[2];
//SCALE
this->protocol[11].value = this->scale[0];
this->protocol[12].value = this->scale[1];
this->protocol[13].value = this->scale[2];
return protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
//#define protocol_Gameplay_ObjectJoinTeam 360
struct Protocol_ObjectJoinTeam :public Oyster::Network::CustomProtocolObject
{
int objectID;
int teamID;
Protocol_ObjectJoinTeam()
{
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value.netShort = protocol_Gameplay_ObjectJoinTeam;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
this->objectID = 0;
this->teamID = 0;
}
Protocol_ObjectJoinTeam(int objID, int teamID)
{
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value.netShort = protocol_Gameplay_ObjectJoinTeam;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->protocol[2].type = Oyster::Network::NetAttributeType_Int;
this->objectID = objID;
this->teamID = teamID;
}
Protocol_ObjectJoinTeam(Oyster::Network::CustomNetProtocol& p)
{
this->objectID = p[1].value.netInt;
this->teamID = p[2].value.netInt;
}
Oyster::Network::CustomNetProtocol GetProtocol() override
{
this->protocol[1].value = this->objectID;
this->protocol[2].value = this->teamID;
return protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
//#define protocol_Gameplay_ObjectLeaveTeam 361
struct Protocol_ObjectLeaveTeam :public Oyster::Network::CustomProtocolObject
{
int objectID;
Protocol_ObjectLeaveTeam()
{
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value.netShort = protocol_Gameplay_ObjectLeaveTeam;
this->protocol[0].type = Oyster::Network::NetAttributeType_Int;
this->objectID = 0;
}
Protocol_ObjectLeaveTeam(int objectID)
{
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value.netShort = protocol_Gameplay_ObjectLeaveTeam;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->objectID = objectID;
}
Protocol_ObjectLeaveTeam(Oyster::Network::CustomNetProtocol& p)
{
this->objectID = p[1].value.netInt;
}
Oyster::Network::CustomNetProtocol GetProtocol() override
{
this->protocol[1].value = this->objectID;
return protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
//#define protocol_Gameplay_ObjectWeaponCooldown 362
struct Protocol_ObjectWeaponCooldown :public Oyster::Network::CustomProtocolObject
{
float seconds;
Protocol_ObjectWeaponCooldown()
{
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value.netShort = protocol_Gameplay_ObjectWeaponCooldown;
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
this->seconds = 0.0f;
}
Protocol_ObjectWeaponCooldown(float seconds)
{
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value.netShort = protocol_Gameplay_ObjectWeaponCooldown;
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
this->seconds = seconds;
}
Protocol_ObjectWeaponCooldown(Oyster::Network::CustomNetProtocol& p)
{
this->seconds = p[1].value.netFloat;
}
Oyster::Network::CustomNetProtocol GetProtocol() override
{
this->protocol[1].value = this->seconds;
return protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
//#define protocol_Gameplay_ObjectWeaponEnergy 363
struct Protocol_ObjectWeaponEnergy :public Oyster::Network::CustomProtocolObject
{
float energy;
Protocol_ObjectWeaponEnergy()
{
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value.netShort = protocol_Gameplay_ObjectWeaponEnergy;
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
this->energy = 0.0f;
}
Protocol_ObjectWeaponEnergy(float energy)
{
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value.netShort = protocol_Gameplay_ObjectWeaponEnergy;
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
this->energy = energy;
}
Protocol_ObjectWeaponEnergy(Oyster::Network::CustomNetProtocol& p)
{
this->energy = p[1].value.netFloat;
}
Oyster::Network::CustomNetProtocol GetProtocol() override
{
this->protocol[1].value = this->energy;
return protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
//#define protocol_Gameplay_ObjectRespawn 364
struct Protocol_ObjectRespawn :public Oyster::Network::CustomProtocolObject
{
float position[3];
Protocol_ObjectRespawn()
{
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value.netShort = protocol_Gameplay_ObjectRespawn;
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
memset(&this->position[0], 0, sizeof(float) * 3);
}
Protocol_ObjectRespawn(float position[3])
{
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value.netShort = protocol_Gameplay_ObjectRespawn;
this->protocol[1].type = Oyster::Network::NetAttributeType_Float;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->protocol[3].type = Oyster::Network::NetAttributeType_Float;
memcpy(&this->position[0], &position[0], sizeof(float) * 3);
}
Protocol_ObjectRespawn(Oyster::Network::CustomNetProtocol& p)
{
this->position[0] = p[1].value.netFloat;
this->position[1] = p[2].value.netFloat;
this->position[2] = p[3].value.netFloat;
}
Oyster::Network::CustomNetProtocol GetProtocol() override
{
this->protocol[1].value = this->position[0];
this->protocol[2].value = this->position[1];
this->protocol[3].value = this->position[2];
return protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
//#define protocol_Gameplay_ObjectDie 365
struct Protocol_ObjectDie :public Oyster::Network::CustomProtocolObject
{
int objectID;
float seconds;
Protocol_ObjectDie()
{
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value.netShort = protocol_Gameplay_ObjectDie;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->objectID = 0;
this->seconds = 0.0f;
}
Protocol_ObjectDie(int objectID, float seconds)
{
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[0].value.netShort = protocol_Gameplay_ObjectDie;
this->protocol[1].type = Oyster::Network::NetAttributeType_Int;
this->protocol[2].type = Oyster::Network::NetAttributeType_Float;
this->objectID = objectID;
this->seconds = seconds;
}
Protocol_ObjectDie(Oyster::Network::CustomNetProtocol& p)
{
this->objectID = p[1].value.netInt;
this->seconds = p[2].value.netFloat;
}
Oyster::Network::CustomNetProtocol GetProtocol() override
{
this->protocol[1].value = this->objectID;
this->protocol[2].value = this->seconds;
return protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
} }
#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H #endif // !GAMELOGIC_PLAYER_PROTOCOLS_H

View File

@ -8,56 +8,67 @@
#include <CustomNetProtocol.h> #include <CustomNetProtocol.h>
#include "ProtocolIdentificationID.h" #include "ProtocolIdentificationID.h"
#include <bitset>
//protocol_Gameplay_PlayerMovement 300
//protocol_Gameplay_PlayerMouseMovement 301
//protocol_Gameplay_PlayerChangeWeapon 302
namespace GameLogic namespace GameLogic
{ {
struct Protocol_PlayerMovement :public Oyster::Network::CustomProtocolObject struct Protocol_PlayerMovementRight :public Oyster::Network::CustomProtocolObject
{ {
bool bForward; Protocol_PlayerMovementRight()
bool bBackward;
bool bLeft;
bool bRight;
Protocol_PlayerMovement()
{ {
this->protocol[0].value = protocol_Gameplay_PlayerMovement; this->protocol[0].value = protocol_Gameplay_PlayerMovementRight;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short; this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
this->protocol[2].type = Oyster::Network::NetAttributeType_Bool;
this->protocol[3].type = Oyster::Network::NetAttributeType_Bool;
this->protocol[4].type = Oyster::Network::NetAttributeType_Bool;
}
Protocol_PlayerMovement(Oyster::Network::CustomNetProtocol& p)
{
bForward = p[1].value.netBool;
bBackward = p[2].value.netBool;
bLeft = p[3].value.netBool;
bRight = p[4].value.netBool;
}
const Protocol_PlayerMovement& operator=(Oyster::Network::CustomNetProtocol& val)
{
bForward = val[1].value.netBool;
bBackward = val[2].value.netBool;
bLeft = val[3].value.netBool;
bRight = val[4].value.netBool;
return *this;
} }
Oyster::Network::CustomNetProtocol GetProtocol() override Oyster::Network::CustomNetProtocol GetProtocol() override
{ { return protocol; }
this->protocol[1].value = bForward;
this->protocol[2].value = bBackward;
this->protocol[3].value = bLeft;
this->protocol[4].value = bRight;
return protocol; private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_PlayerMovementLeft :public Oyster::Network::CustomProtocolObject
{
Protocol_PlayerMovementLeft()
{
this->protocol[0].value = protocol_Gameplay_PlayerMovementLeft;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
} }
Oyster::Network::CustomNetProtocol GetProtocol() override { return protocol; }
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_PlayerMovementForward :public Oyster::Network::CustomProtocolObject
{
Protocol_PlayerMovementForward()
{
this->protocol[0].value = protocol_Gameplay_PlayerMovementForward;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
}
Oyster::Network::CustomNetProtocol GetProtocol() override { return protocol; }
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_PlayerMovementBackward :public Oyster::Network::CustomProtocolObject
{
Protocol_PlayerMovementBackward()
{
this->protocol[0].value = protocol_Gameplay_PlayerMovementBackward;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
}
Oyster::Network::CustomNetProtocol GetProtocol() override { return protocol; }
private:
Oyster::Network::CustomNetProtocol protocol;
};
struct Protocol_PlayerJump :public Oyster::Network::CustomProtocolObject
{
Protocol_PlayerJump()
{
this->protocol[0].value = protocol_Gameplay_PlayerJump;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
}
Oyster::Network::CustomNetProtocol GetProtocol() override { return protocol; }
private: private:
Oyster::Network::CustomNetProtocol protocol; Oyster::Network::CustomNetProtocol protocol;
@ -65,7 +76,6 @@ namespace GameLogic
struct Protocol_PlayerLook :public Oyster::Network::CustomProtocolObject struct Protocol_PlayerLook :public Oyster::Network::CustomProtocolObject
{ {
float lookDirX; float lookDirX;
float lookDirY; float lookDirY;
float lookDirZ; float lookDirZ;
@ -180,35 +190,6 @@ namespace GameLogic
Oyster::Network::CustomNetProtocol protocol; Oyster::Network::CustomNetProtocol protocol;
}; };
struct Protocol_PlayerJump :public Oyster::Network::CustomProtocolObject
{
bool hasJumped;
Protocol_PlayerJump()
{
this->protocol[0].value = protocol_Gameplay_PlayerJump;
this->protocol[0].type = Oyster::Network::NetAttributeType_Short;
this->protocol[1].type = Oyster::Network::NetAttributeType_Bool;
}
Protocol_PlayerJump(Oyster::Network::CustomNetProtocol& p)
{
hasJumped = p[1].value.netBool;
}
const Protocol_PlayerJump& operator=(Oyster::Network::CustomNetProtocol& val)
{
hasJumped = val[1].value.netBool;
return *this;
}
Oyster::Network::CustomNetProtocol GetProtocol() override
{
this->protocol[1].value = hasJumped;
return protocol;
}
private:
Oyster::Network::CustomNetProtocol protocol;
};
} }
#endif // !GAMELOGIC_PLAYER_PROTOCOLS_H #endif // !GAMELOGIC_PLAYER_PROTOCOLS_H

View File

@ -41,17 +41,32 @@
/********* GAMEPLAY PROTOCOLS ***************************************************************************************************/ /********* GAMEPLAY PROTOCOLS ***************************************************************************************************/
/***********[ 300 - 399 ]***********/ /***********[ 300 - 399 ]***********/
#define protocol_GameplayMIN 300 #define protocol_GameplayMIN 300
#define protocol_Gameplay_PlayerMovement 300 #define protocol_Gameplay_PlayerMovementRight 300
#define protocol_Gameplay_PlayerLookDir 301 #define protocol_Gameplay_PlayerMovementLeft 301
#define protocol_Gameplay_PlayerChangeWeapon 302 #define protocol_Gameplay_PlayerMovementForward 302
#define protocol_Gameplay_PlayerShot 303 #define protocol_Gameplay_PlayerMovementBackward 303
#define protocol_Gameplay_PlayerJump 304 #define protocol_Gameplay_PlayerLookDir 304
#define protocol_Gameplay_ObjectPickup 305 #define protocol_Gameplay_PlayerChangeWeapon 305
#define protocol_Gameplay_ObjectDamage 306 #define protocol_Gameplay_PlayerShot 306
#define protocol_Gameplay_ObjectPosition 307 #define protocol_Gameplay_PlayerJump 307
#define protocol_Gameplay_ObjectEnabled 308
#define protocol_Gameplay_ObjectDisabled 309 #define protocol_Gameplay_ObjectPickup 350
#define protocol_Gameplay_ObjectCreate 310 #define protocol_Gameplay_ObjectDamage 351
#define protocol_Gameplay_ObjectHealthStatus 352
#define protocol_Gameplay_ObjectPosition 353
#define protocol_Gameplay_ObjectScale 354
#define protocol_Gameplay_ObjectRotation 355
#define protocol_Gameplay_ObjectPositionRotation 356
#define protocol_Gameplay_ObjectEnabled 357
#define protocol_Gameplay_ObjectDisabled 358
#define protocol_Gameplay_ObjectCreate 359
#define protocol_Gameplay_ObjectCreatePlayer 360
#define protocol_Gameplay_ObjectJoinTeam 361
#define protocol_Gameplay_ObjectLeaveTeam 362
#define protocol_Gameplay_ObjectWeaponCooldown 363
#define protocol_Gameplay_ObjectWeaponEnergy 364
#define protocol_Gameplay_ObjectRespawn 365
#define protocol_Gameplay_ObjectDie 366
#define protocol_GameplayMAX 399 #define protocol_GameplayMAX 399

View File

@ -74,11 +74,14 @@ namespace DanBias
private: private:
void ParseProtocol ( Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c ); void ParseProtocol ( Oyster::Network::CustomNetProtocol& p, DanBias::GameClient* c );
void Gameplay_PlayerMovement ( GameLogic::Protocol_PlayerMovement& p, DanBias::GameClient* c ); void Gameplay_PlayerMovementRight ( DanBias::GameClient* c );
void Gameplay_PlayerMovementLeft ( DanBias::GameClient* c );
void Gameplay_PlayerMovementBack ( DanBias::GameClient* c );
void Gameplay_PlayerMovementForth ( DanBias::GameClient* c );
void Gameplay_PlayerJump ( DanBias::GameClient* c );
void Gameplay_PlayerLookDir ( GameLogic::Protocol_PlayerLook& p, DanBias::GameClient* c ); void Gameplay_PlayerLookDir ( GameLogic::Protocol_PlayerLook& p, DanBias::GameClient* c );
void Gameplay_PlayerChangeWeapon ( GameLogic::Protocol_PlayerChangeWeapon& p, DanBias::GameClient* c ); void Gameplay_PlayerChangeWeapon ( GameLogic::Protocol_PlayerChangeWeapon& p, DanBias::GameClient* c );
void Gameplay_PlayerShot ( GameLogic::Protocol_PlayerShot& p, DanBias::GameClient* c ); void Gameplay_PlayerShot ( GameLogic::Protocol_PlayerShot& p, DanBias::GameClient* c );
void Gameplay_PlayerJump ( GameLogic::Protocol_PlayerJump& p, DanBias::GameClient* c );
void Gameplay_ObjectPickup ( GameLogic::Protocol_ObjectPickup& p, DanBias::GameClient* c ); void Gameplay_ObjectPickup ( GameLogic::Protocol_ObjectPickup& p, DanBias::GameClient* c );
void Gameplay_ObjectDamage ( GameLogic::Protocol_ObjectDamage& p, DanBias::GameClient* c ); void Gameplay_ObjectDamage ( GameLogic::Protocol_ObjectDamage& p, DanBias::GameClient* c );
void Gameplay_ObjectPosition ( GameLogic::Protocol_ObjectPosition& p, DanBias::GameClient* c ); void Gameplay_ObjectPosition ( GameLogic::Protocol_ObjectPosition& p, DanBias::GameClient* c );

View File

@ -85,7 +85,7 @@ namespace DanBias
void GameSession::ObjectMove(GameLogic::IObjectData* movedObject) void GameSession::ObjectMove(GameLogic::IObjectData* movedObject)
{ {
float dt = GameSession::gameSession->networkTimer.getElapsedSeconds(); //float dt = (float)GameSession::gameSession->networkTimer.getElapsedSeconds();
//Duh... This was causing alot of problems, it's in the wrong place... //Duh... This was causing alot of problems, it's in the wrong place...
//Need to figure out where to put this frame locker. //Need to figure out where to put this frame locker.
//We only need to send network packages when necessary, ie not 120 times per frame. //We only need to send network packages when necessary, ie not 120 times per frame.
@ -93,64 +93,13 @@ namespace DanBias
//graphics update (60 fps) on the client side. To send more than this would be lost //graphics update (60 fps) on the client side. To send more than this would be lost
//bandwidth. //bandwidth.
//if( dt >= GameSession::gameSession->networkFrameTime ) //if( dt >= GameSession::gameSession->networkFrameTime )
{ //{
GameSession::gameSession->networkTimer.reset(); // GameSession::gameSession->networkTimer.reset();
int id = movedObject->GetID();
GameLogic::IObjectData* obj = movedObject; //Protocol_ObjectPosition p(movedObject->GetPosition(), id);
if(movedObject->GetID() == testID) //TODO: TEST Protocol_ObjectPositionRotation p(movedObject->GetPosition(), movedObject->GetRotation(), id);
{
float sec = (float)testTimer.getElapsedSeconds();
sec = 0;
}
int id = obj->GetID();
Protocol_ObjectPosition p(obj->GetOrientation(), id);
//if(id != 1)
GameSession::gameSession->Send(p.GetProtocol()); GameSession::gameSession->Send(p.GetProtocol());
//}
/*
if(dynamic_cast<GameLogic::ILevelData*>(obj))
{
obj = ((GameLogic::ILevelData*)movedObject)->GetObjectAt(0);
if(obj)
{
if(obj->GetObjectType() == OBJECT_TYPE_WORLD)
{
int id = obj->GetID();
Oyster::Math::Float4x4 world =obj->GetOrientation();
Protocol_ObjectPosition p(world, id);
gameSession->Send(p.GetProtocol());
}
}
obj =((GameLogic::ILevelData*)movedObject)->GetObjectAt(1);
if(obj)
{
if(obj->GetObjectType() == OBJECT_TYPE_BOX)
{
int id = obj->GetID();
Oyster::Math::Float4x4 world = obj->GetOrientation();
Protocol_ObjectPosition p(world, id);
gameSession->Send(p.GetProtocol());
}
}
obj =((GameLogic::ILevelData*)movedObject)->GetObjectAt(2);
if(obj)
{
if(obj->GetObjectType() == OBJECT_TYPE_BOX)
{
int id = obj->GetID();
Oyster::Math::Float4x4 world = obj->GetOrientation();
Protocol_ObjectPosition p(world, id);
GameSession::gameSession->Send(p.GetProtocol());
}
}
}
*/
}
} }
void GameSession::ObjectDisabled( GameLogic::IObjectData* movedObject, float seconds ) void GameSession::ObjectDisabled( GameLogic::IObjectData* movedObject, float seconds )
@ -168,7 +117,15 @@ namespace DanBias
switch (p[0].value.netShort) switch (p[0].value.netShort)
{ {
case protocol_Gameplay_PlayerMovement: this->Gameplay_PlayerMovement ( Protocol_PlayerMovement (p), c ); case protocol_Gameplay_PlayerMovementBackward: this->Gameplay_PlayerMovementBack ( c );
break;
case protocol_Gameplay_PlayerMovementForward: this->Gameplay_PlayerMovementForth ( c );
break;
case protocol_Gameplay_PlayerMovementLeft: this->Gameplay_PlayerMovementLeft ( c );
break;
case protocol_Gameplay_PlayerMovementRight: this->Gameplay_PlayerMovementRight ( c );
break;
case protocol_Gameplay_PlayerJump: this->Gameplay_PlayerJump ( c );
break; break;
case protocol_Gameplay_PlayerLookDir: this->Gameplay_PlayerLookDir ( Protocol_PlayerLook (p), c ); case protocol_Gameplay_PlayerLookDir: this->Gameplay_PlayerLookDir ( Protocol_PlayerLook (p), c );
break; break;
@ -176,8 +133,7 @@ namespace DanBias
break; break;
case protocol_Gameplay_PlayerShot: this->Gameplay_PlayerShot ( Protocol_PlayerShot (p), c ); case protocol_Gameplay_PlayerShot: this->Gameplay_PlayerShot ( Protocol_PlayerShot (p), c );
break; break;
case protocol_Gameplay_PlayerJump: this->Gameplay_PlayerJump ( Protocol_PlayerJump (p), c );
break;
case protocol_Gameplay_ObjectPickup: this->Gameplay_ObjectPickup ( Protocol_ObjectPickup (p), c ); case protocol_Gameplay_ObjectPickup: this->Gameplay_ObjectPickup ( Protocol_ObjectPickup (p), c );
break; break;
case protocol_Gameplay_ObjectDamage: this->Gameplay_ObjectDamage ( Protocol_ObjectDamage (p), c ); case protocol_Gameplay_ObjectDamage: this->Gameplay_ObjectDamage ( Protocol_ObjectDamage (p), c );
@ -190,6 +146,7 @@ namespace DanBias
break; break;
case protocol_Gameplay_ObjectCreate: this->Gameplay_ObjectCreate ( Protocol_ObjectCreate (p), c ); case protocol_Gameplay_ObjectCreate: this->Gameplay_ObjectCreate ( Protocol_ObjectCreate (p), c );
break; break;
case protocol_General_Status: this->General_Status ( Protocol_General_Status (p), c ); case protocol_General_Status: this->General_Status ( Protocol_General_Status (p), c );
break; break;
case protocol_General_Text: this->General_Text ( Protocol_General_Text (p), c ); case protocol_General_Text: this->General_Text ( Protocol_General_Text (p), c );
@ -197,12 +154,25 @@ namespace DanBias
} }
} }
void GameSession::Gameplay_PlayerMovement ( Protocol_PlayerMovement& p, DanBias::GameClient* c ) void GameSession::Gameplay_PlayerMovementBack ( DanBias::GameClient* c )
{ {
if(p.bForward) c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD); c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD);
if(p.bBackward) c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_BACKWARD); }
if(p.bLeft) c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_LEFT); void GameSession::Gameplay_PlayerMovementForth ( DanBias::GameClient* c )
if(p.bRight) c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT); {
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_FORWARD);
}
void GameSession::Gameplay_PlayerMovementLeft ( DanBias::GameClient* c )
{
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_LEFT);
}
void GameSession::Gameplay_PlayerMovementRight ( DanBias::GameClient* c )
{
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_RIGHT);
}
void GameSession::Gameplay_PlayerJump ( DanBias::GameClient* c )
{
c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_JUMP);
} }
void GameSession::Gameplay_PlayerLookDir ( Protocol_PlayerLook& p, DanBias::GameClient* c ) void GameSession::Gameplay_PlayerLookDir ( Protocol_PlayerLook& p, DanBias::GameClient* c )
{ {
@ -224,10 +194,8 @@ namespace DanBias
if(p.utilityPressed) c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_UTILLITY_PRESS); if(p.utilityPressed) c->GetPlayer()->UseWeapon(GameLogic::WEAPON_USE_UTILLITY_PRESS);
} }
void GameSession::Gameplay_PlayerJump ( Protocol_PlayerJump& p, DanBias::GameClient* c )
{
if(p.hasJumped) c->GetPlayer()->Move(GameLogic::PLAYER_MOVEMENT_JUMP);
}
void GameSession::Gameplay_ObjectPickup ( Protocol_ObjectPickup& p, DanBias::GameClient* c ) void GameSession::Gameplay_ObjectPickup ( Protocol_ObjectPickup& p, DanBias::GameClient* c )
{ {

View File

@ -156,6 +156,7 @@ namespace DanBias
{ {
if((this->clients[k] && readyList[i]) && readyList[i]->GetClient()->GetID() != this->clients[k]->GetClient()->GetID()) if((this->clients[k] && readyList[i]) && readyList[i]->GetClient()->GetID() != this->clients[k]->GetClient()->GetID())
{ {
//Protocol_ObjectCreatePlayer
Protocol_ObjectCreate p(this->clients[k]->GetPlayer()->GetOrientation(), this->clients[k]->GetPlayer()->GetID(), "char_white.dan"); //The model name will be custom later.. Protocol_ObjectCreate p(this->clients[k]->GetPlayer()->GetOrientation(), this->clients[k]->GetPlayer()->GetID(), "char_white.dan"); //The model name will be custom later..
readyList[i]->GetClient()->Send(p); readyList[i]->GetClient()->Send(p);
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.