GL - added id in object, vector
This commit is contained in:
parent
057dce0aca
commit
ba6f7114b5
|
@ -8,6 +8,7 @@ namespace DanBias
|
||||||
|
|
||||||
struct ModelInitData
|
struct ModelInitData
|
||||||
{
|
{
|
||||||
|
int id;
|
||||||
std::wstring modelPath;
|
std::wstring modelPath;
|
||||||
Oyster::Math::Float4x4 world;
|
Oyster::Math::Float4x4 world;
|
||||||
bool visible;
|
bool visible;
|
||||||
|
@ -24,5 +25,6 @@ public:
|
||||||
|
|
||||||
virtual void Render() = 0;
|
virtual void Render() = 0;
|
||||||
virtual void Release() = 0;
|
virtual void Release() = 0;
|
||||||
|
virtual int GetId() = 0;
|
||||||
};};};
|
};};};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -5,6 +5,7 @@ struct C_DynamicObj::myData
|
||||||
{
|
{
|
||||||
myData(){}
|
myData(){}
|
||||||
Oyster::Graphics::Model::Model *model;
|
Oyster::Graphics::Model::Model *model;
|
||||||
|
int ID;
|
||||||
// light
|
// light
|
||||||
// sound
|
// sound
|
||||||
// effect
|
// effect
|
||||||
|
@ -39,4 +40,8 @@ void C_DynamicObj::Release()
|
||||||
{
|
{
|
||||||
Oyster::Graphics::API::DeleteModel(privData->model);
|
Oyster::Graphics::API::DeleteModel(privData->model);
|
||||||
delete privData;
|
delete privData;
|
||||||
|
}
|
||||||
|
int C_DynamicObj::GetId()
|
||||||
|
{
|
||||||
|
return privData->ID;
|
||||||
}
|
}
|
|
@ -18,5 +18,6 @@ public:
|
||||||
|
|
||||||
void Render();
|
void Render();
|
||||||
void Release();
|
void Release();
|
||||||
|
int GetId();
|
||||||
};};};
|
};};};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -8,6 +8,7 @@ struct C_Player::myData
|
||||||
Oyster::Math3D::Float4x4 view;
|
Oyster::Math3D::Float4x4 view;
|
||||||
Oyster::Math3D::Float4x4 proj;
|
Oyster::Math3D::Float4x4 proj;
|
||||||
Oyster::Graphics::Model::Model *model;
|
Oyster::Graphics::Model::Model *model;
|
||||||
|
int ID;
|
||||||
}privData;
|
}privData;
|
||||||
|
|
||||||
C_Player::C_Player(void)
|
C_Player::C_Player(void)
|
||||||
|
@ -44,3 +45,7 @@ void C_Player::Release()
|
||||||
Oyster::Graphics::API::DeleteModel(privData->model);
|
Oyster::Graphics::API::DeleteModel(privData->model);
|
||||||
delete privData;
|
delete privData;
|
||||||
}
|
}
|
||||||
|
int C_Player::GetId()
|
||||||
|
{
|
||||||
|
return privData->ID;
|
||||||
|
}
|
|
@ -19,6 +19,7 @@ public:
|
||||||
|
|
||||||
void Render();
|
void Render();
|
||||||
void Release();
|
void Release();
|
||||||
|
int GetId();
|
||||||
|
|
||||||
};};};
|
};};};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -7,6 +7,7 @@ struct C_StaticObj::myData
|
||||||
{
|
{
|
||||||
myData(){}
|
myData(){}
|
||||||
Oyster::Graphics::Model::Model *model;
|
Oyster::Graphics::Model::Model *model;
|
||||||
|
int ID;
|
||||||
// light
|
// light
|
||||||
// sound
|
// sound
|
||||||
// effect
|
// effect
|
||||||
|
@ -42,4 +43,8 @@ void C_StaticObj::Release()
|
||||||
{
|
{
|
||||||
Oyster::Graphics::API::DeleteModel(privData->model);
|
Oyster::Graphics::API::DeleteModel(privData->model);
|
||||||
delete privData;
|
delete privData;
|
||||||
|
}
|
||||||
|
int C_StaticObj::GetId()
|
||||||
|
{
|
||||||
|
return privData->ID;
|
||||||
}
|
}
|
|
@ -18,5 +18,6 @@ public:
|
||||||
|
|
||||||
void Render();
|
void Render();
|
||||||
void Release();
|
void Release();
|
||||||
|
int GetId();
|
||||||
};};};
|
};};};
|
||||||
#endif
|
#endif
|
|
@ -5,9 +5,8 @@ using namespace DanBias::Client;
|
||||||
struct C_UIobject::myData
|
struct C_UIobject::myData
|
||||||
{
|
{
|
||||||
myData(){}
|
myData(){}
|
||||||
Oyster::Math3D::Float4x4 view;
|
|
||||||
Oyster::Math3D::Float4x4 proj;
|
|
||||||
Oyster::Graphics::Model::Model *model;
|
Oyster::Graphics::Model::Model *model;
|
||||||
|
int ID;
|
||||||
}privData;
|
}privData;
|
||||||
|
|
||||||
C_UIobject::C_UIobject(void)
|
C_UIobject::C_UIobject(void)
|
||||||
|
@ -40,4 +39,8 @@ void C_UIobject::Release()
|
||||||
{
|
{
|
||||||
Oyster::Graphics::API::DeleteModel(privData->model);
|
Oyster::Graphics::API::DeleteModel(privData->model);
|
||||||
delete privData;
|
delete privData;
|
||||||
|
}
|
||||||
|
int C_UIobject::GetId()
|
||||||
|
{
|
||||||
|
return privData->ID;
|
||||||
}
|
}
|
|
@ -18,5 +18,6 @@ namespace DanBias
|
||||||
|
|
||||||
void Render();
|
void Render();
|
||||||
void Release();
|
void Release();
|
||||||
|
int GetId();
|
||||||
};};};
|
};};};
|
||||||
#endif
|
#endif
|
|
@ -15,7 +15,7 @@ struct GameState::myData
|
||||||
myData(){}
|
myData(){}
|
||||||
Oyster::Math3D::Float4x4 view;
|
Oyster::Math3D::Float4x4 view;
|
||||||
Oyster::Math3D::Float4x4 proj;
|
Oyster::Math3D::Float4x4 proj;
|
||||||
C_Object* object[3];
|
std::vector<C_Object*> object;
|
||||||
int modelCount;
|
int modelCount;
|
||||||
Oyster::Network::NetworkClient* nwClient;
|
Oyster::Network::NetworkClient* nwClient;
|
||||||
gameStateState state;
|
gameStateState state;
|
||||||
|
@ -59,15 +59,17 @@ bool GameState::LoadModels(std::wstring mapFile)
|
||||||
modelData.visible = true;
|
modelData.visible = true;
|
||||||
modelData.modelPath = L"worldDummy";
|
modelData.modelPath = L"worldDummy";
|
||||||
// load models
|
// load models
|
||||||
privData->object[0] = new C_Player();
|
C_Object* obj = new C_Player();
|
||||||
privData->object[0]->Init(modelData);
|
privData->object.push_back(obj);
|
||||||
|
privData->object[privData->object.size() -1 ]->Init(modelData);
|
||||||
|
|
||||||
Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(2,2,2));
|
Oyster::Math3D::Float4x4 translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(2,2,2));
|
||||||
modelData.world = modelData.world * translate;
|
modelData.world = modelData.world * translate;
|
||||||
modelData.modelPath = L"crate";
|
modelData.modelPath = L"crate";
|
||||||
|
|
||||||
privData->object[1] = new C_DynamicObj();
|
obj = new C_DynamicObj();
|
||||||
privData->object[1]->Init(modelData);
|
privData->object.push_back(obj);
|
||||||
|
privData->object[privData->object.size() -1 ]->Init(modelData);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool GameState::InitCamera(Oyster::Math::Float3 startPos)
|
bool GameState::InitCamera(Oyster::Math::Float3 startPos)
|
||||||
|
@ -174,7 +176,7 @@ bool GameState::Render()
|
||||||
}
|
}
|
||||||
bool GameState::Release()
|
bool GameState::Release()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < privData->modelCount; i++)
|
for (int i = 0; i < privData->object.size(); i++)
|
||||||
{
|
{
|
||||||
privData->object[i]->Release();
|
privData->object[i]->Release();
|
||||||
delete privData->object[i];
|
delete privData->object[i];
|
||||||
|
@ -209,7 +211,11 @@ void GameState::Protocol( ObjPos* pos )
|
||||||
{
|
{
|
||||||
world[i] = pos->worldPos[i];
|
world[i] = pos->worldPos[i];
|
||||||
}
|
}
|
||||||
privData->object[pos->object_ID]->setPos(world);
|
for (int i = 0; i < privData->object.size(); i++)
|
||||||
|
{
|
||||||
|
if(privData->object[i]->GetId() == pos->object_ID)
|
||||||
|
privData->object[i]->setPos(world);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameState::Protocol( NewObj* pos )
|
void GameState::Protocol( NewObj* pos )
|
||||||
|
@ -224,45 +230,29 @@ void GameState::Protocol( NewObj* pos )
|
||||||
|
|
||||||
modelData.world = world;
|
modelData.world = world;
|
||||||
modelData.visible = true;
|
modelData.visible = true;
|
||||||
|
modelData.id = pos->object_ID;
|
||||||
//not sure if this is good parsing rom char* to wstring
|
//not sure if this is good parsing rom char* to wstring
|
||||||
const char* path = pos->path;
|
const char* path = pos->path;
|
||||||
modelData.modelPath = std::wstring(path, path + strlen(path));
|
modelData.modelPath = std::wstring(path, path + strlen(path));
|
||||||
// load models
|
// load models
|
||||||
privData->object[pos->object_ID] = new C_Player();
|
C_Object* player = new C_Player();
|
||||||
privData->object[pos->object_ID]->Init(modelData);
|
player->Init(modelData);
|
||||||
}
|
|
||||||
|
privData->object.push_back(player);
|
||||||
|
|
||||||
void GameState::Protocol( KeyInput* pos )
|
|
||||||
{
|
|
||||||
bool key = false;
|
|
||||||
for (int i = 0; i < 6; i++)
|
|
||||||
{
|
|
||||||
key = pos->key[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DanBias::Client::GameState::Protocol( RemoveObj* obj )
|
void DanBias::Client::GameState::Protocol( RemoveObj* obj )
|
||||||
{
|
{
|
||||||
privData->object[obj->object_ID]->Release( );
|
for (int i = 0; i < privData->object.size(); i++)
|
||||||
}
|
|
||||||
|
|
||||||
void GameState::PlayerPosProtocol(PlayerPos* pos)
|
|
||||||
{
|
|
||||||
Oyster::Math::Float4x4 world, translate;
|
|
||||||
|
|
||||||
world = Oyster::Math::Float4x4::identity;
|
|
||||||
translate = Oyster::Math::Float4x4::identity;
|
|
||||||
translate = Oyster::Math3D::TranslationMatrix(Oyster::Math::Float3(pos->playerPos[0],pos->playerPos[1],pos->playerPos[2] ));
|
|
||||||
world = translate;
|
|
||||||
privData->object[0]->setPos( world );
|
|
||||||
}
|
|
||||||
void GameState::ObjectPosProtocol(ObjPos* pos)
|
|
||||||
{
|
|
||||||
Oyster::Math::Float4x4 world;
|
|
||||||
for(int i = 0; i<16; i++)
|
|
||||||
{
|
{
|
||||||
world[i] = pos->worldPos[i];
|
if(privData->object[i]->GetId() == obj->object_ID)
|
||||||
|
{
|
||||||
|
privData->object.at(i)->Release();
|
||||||
|
privData->object.erase(privData->object.begin() + i );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
privData->object[1]->setPos(world);
|
//privData->object[obj->object_ID]->Release( );
|
||||||
}
|
}
|
||||||
|
|
||||||
//void GameState::Protocol(LightPos pos);
|
//void GameState::Protocol(LightPos pos);
|
|
@ -34,11 +34,8 @@ public:
|
||||||
void Protocol(ProtocolStruct* pos)override;
|
void Protocol(ProtocolStruct* pos)override;
|
||||||
void Protocol(PlayerPos* pos);
|
void Protocol(PlayerPos* pos);
|
||||||
void Protocol(ObjPos* pos);
|
void Protocol(ObjPos* pos);
|
||||||
void Protocol(KeyInput* pos);
|
|
||||||
void Protocol( NewObj* pos );
|
void Protocol( NewObj* pos );
|
||||||
void Protocol(RemoveObj* obj);
|
void Protocol(RemoveObj* obj);
|
||||||
void PlayerPosProtocol(PlayerPos* pos);
|
|
||||||
void ObjectPosProtocol(ObjPos* pos);
|
|
||||||
//void Protocol(LightPos pos);
|
//void Protocol(LightPos pos);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <vld.h>
|
#include <vld.h>
|
||||||
|
|
||||||
#include "DanBiasServerAPI.h"
|
//#include "DanBiasServerAPI.h"
|
||||||
//#include "DanBiasGame.h"
|
#include "DanBiasGame.h"
|
||||||
|
|
||||||
|
|
||||||
int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdShow)
|
int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdShow)
|
||||||
|
@ -29,7 +29,8 @@ int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdSh
|
||||||
// Game client starter code goes here
|
// Game client starter code goes here
|
||||||
DanBias::DanBiasGameDesc gameDesc;
|
DanBias::DanBiasGameDesc gameDesc;
|
||||||
gameDesc.port = 15151;
|
gameDesc.port = 15151;
|
||||||
gameDesc.IP = "193.11.184.196";
|
//gameDesc.IP = "193.11.184.196"; //Erik
|
||||||
|
gameDesc.IP = "193.11.186.101";
|
||||||
gameDesc.hinst = hinst;
|
gameDesc.hinst = hinst;
|
||||||
gameDesc.nCmdShow = cmdShow;
|
gameDesc.nCmdShow = cmdShow;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue