From ea593743ad312603020f321d5db3889b2814545e Mon Sep 17 00:00:00 2001 From: Linda Andersson Date: Mon, 9 Dec 2013 12:01:36 +0100 Subject: [PATCH] GL - added UI object --- Code/Game/DanBiasGame/DanBiasGame.vcxproj | 2 + .../DanBiasGame/GameClientState/C_Object.h | 11 ++++- .../DanBiasGame/GameClientState/GameState.cpp | 7 ++- .../GameState/C_DynamicObj.cpp | 6 ++- .../GameClientState/GameState/C_DynamicObj.h | 5 ++- .../GameClientState/GameState/C_Player.cpp | 8 +++- .../GameClientState/GameState/C_Player.h | 2 +- .../GameClientState/GameState/C_StaticObj.cpp | 7 ++- .../GameClientState/GameState/C_StaticObj.h | 2 +- .../GameClientState/GameState/C_UIobject.cpp | 43 +++++++++++++++++++ .../GameClientState/GameState/C_UIobject.h | 20 +++++++++ .../GameClientState/LobbyState.cpp | 8 +++- .../DanBiasGame/GameClientState/LobbyState.h | 5 ++- 13 files changed, 112 insertions(+), 14 deletions(-) create mode 100644 Code/Game/DanBiasGame/GameClientState/GameState/C_UIobject.cpp create mode 100644 Code/Game/DanBiasGame/GameClientState/GameState/C_UIobject.h diff --git a/Code/Game/DanBiasGame/DanBiasGame.vcxproj b/Code/Game/DanBiasGame/DanBiasGame.vcxproj index ec283376..41093543 100644 --- a/Code/Game/DanBiasGame/DanBiasGame.vcxproj +++ b/Code/Game/DanBiasGame/DanBiasGame.vcxproj @@ -189,6 +189,7 @@ + @@ -200,6 +201,7 @@ + diff --git a/Code/Game/DanBiasGame/GameClientState/C_Object.h b/Code/Game/DanBiasGame/GameClientState/C_Object.h index 0f2bdf81..adb79f54 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_Object.h +++ b/Code/Game/DanBiasGame/GameClientState/C_Object.h @@ -1,15 +1,24 @@ #pragma once +#include "DllInterfaces/GFXAPI.h" namespace DanBias { namespace Client { + + struct ModelInitData + { + std::wstring modelPath; + Oyster::Math::Float4x4 world; + bool visible; + }; + class C_Object { private: public: - virtual void Init() = 0; + virtual void Init(ModelInitData modelInit) = 0; virtual void setPos() = 0; virtual void Render() = 0; diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index 0914f259..1b5926b0 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -22,10 +22,15 @@ GameState::~GameState(void) } bool GameState::Init() { + ModelInitData modelData; + + modelData.world = Oyster::Math3D::Float4x4::identity; + modelData.visible = true; + modelData.modelPath = L"worldDummy"; // load models privData = new myData(); privData->player = new C_Player; - privData->player->Init(); + privData->player->Init(modelData); privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,1000); Oyster::Graphics::API::SetProjection(privData->proj); diff --git a/Code/Game/DanBiasGame/GameClientState/GameState/C_DynamicObj.cpp b/Code/Game/DanBiasGame/GameClientState/GameState/C_DynamicObj.cpp index 79d89eb9..686bbca9 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState/C_DynamicObj.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState/C_DynamicObj.cpp @@ -18,11 +18,13 @@ C_DynamicObj::~C_DynamicObj(void) { } -void C_DynamicObj::Init() +void C_DynamicObj::Init(ModelInitData modelInit) { // load models privData = new myData(); - privData->model = Oyster::Graphics::API::CreateModel(L"crate"); + privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath); + privData->model->WorldMatrix = modelInit.world; + privData->model->Visible = modelInit.visible; } void C_DynamicObj::setPos() { diff --git a/Code/Game/DanBiasGame/GameClientState/GameState/C_DynamicObj.h b/Code/Game/DanBiasGame/GameClientState/GameState/C_DynamicObj.h index 01638550..35a6e401 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState/C_DynamicObj.h +++ b/Code/Game/DanBiasGame/GameClientState/GameState/C_DynamicObj.h @@ -1,9 +1,10 @@ #pragma once +#include "../C_Object.h" namespace DanBias { namespace Client { -class C_DynamicObj +class C_DynamicObj : private C_Object { private: struct myData; @@ -11,7 +12,7 @@ private: public: C_DynamicObj(void); virtual ~C_DynamicObj(void); - void Init(); + void Init(ModelInitData modelInit); void setPos(); void Render(); diff --git a/Code/Game/DanBiasGame/GameClientState/GameState/C_Player.cpp b/Code/Game/DanBiasGame/GameClientState/GameState/C_Player.cpp index 6c0e327f..e47d98ef 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState/C_Player.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState/C_Player.cpp @@ -20,11 +20,15 @@ C_Player::~C_Player(void) } -void C_Player::Init() +void C_Player::Init(ModelInitData modelInit) { // load models privData = new myData(); - privData->model = Oyster::Graphics::API::CreateModel(L"crate"); + privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath); + privData->model->WorldMatrix = modelInit.world; + privData->model->Visible = modelInit.visible; + + } void C_Player::setPos() { diff --git a/Code/Game/DanBiasGame/GameClientState/GameState/C_Player.h b/Code/Game/DanBiasGame/GameClientState/GameState/C_Player.h index 43f12e5d..e9bdfa89 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState/C_Player.h +++ b/Code/Game/DanBiasGame/GameClientState/GameState/C_Player.h @@ -13,7 +13,7 @@ private: public: C_Player(void); ~C_Player(void); - void Init(); + void Init(ModelInitData modelInit); void setPos(); void Render(); diff --git a/Code/Game/DanBiasGame/GameClientState/GameState/C_StaticObj.cpp b/Code/Game/DanBiasGame/GameClientState/GameState/C_StaticObj.cpp index d3ceaf3f..54c36c2a 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState/C_StaticObj.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState/C_StaticObj.cpp @@ -20,11 +20,14 @@ C_StaticObj::~C_StaticObj(void) { } -void C_StaticObj::Init() +void C_StaticObj::Init(ModelInitData modelInit) { // load models privData = new myData(); - privData->model = Oyster::Graphics::API::CreateModel(L"worldDummy"); + privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath); + privData->model->WorldMatrix = modelInit.world; + privData->model->Visible = modelInit.visible; + } void C_StaticObj::setPos() { diff --git a/Code/Game/DanBiasGame/GameClientState/GameState/C_StaticObj.h b/Code/Game/DanBiasGame/GameClientState/GameState/C_StaticObj.h index 06be4a55..9da24351 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState/C_StaticObj.h +++ b/Code/Game/DanBiasGame/GameClientState/GameState/C_StaticObj.h @@ -12,7 +12,7 @@ private: public: C_StaticObj(void); virtual ~C_StaticObj(void); - void Init(); + void Init(ModelInitData modelInit); void setPos(); void Render(); diff --git a/Code/Game/DanBiasGame/GameClientState/GameState/C_UIobject.cpp b/Code/Game/DanBiasGame/GameClientState/GameState/C_UIobject.cpp new file mode 100644 index 00000000..b07ec6fa --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/GameState/C_UIobject.cpp @@ -0,0 +1,43 @@ +#include "C_UIobject.h" +#include "DllInterfaces/GFXAPI.h" +using namespace DanBias::Client; + +struct C_UIobject::myData +{ + myData(){} + Oyster::Math3D::Float4x4 view; + Oyster::Math3D::Float4x4 proj; + Oyster::Graphics::Model::Model *model; +}privData; + +C_UIobject::C_UIobject(void) +{ +} + + +C_UIobject::~C_UIobject(void) +{ +} +void C_UIobject::Init(ModelInitData modelInit) +{ + // load models + privData = new myData(); + privData->model = Oyster::Graphics::API::CreateModel(modelInit.modelPath); + privData->model->WorldMatrix = modelInit.world; + privData->model->Visible = modelInit.visible; + +} +void C_UIobject::setPos() +{ + +} + +void C_UIobject::Render() +{ + Oyster::Graphics::API::RenderModel(*(privData->model)); +} +void C_UIobject::Release() +{ + Oyster::Graphics::API::DeleteModel(privData->model); + delete privData; +} \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/GameState/C_UIobject.h b/Code/Game/DanBiasGame/GameClientState/GameState/C_UIobject.h new file mode 100644 index 00000000..6052a414 --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/GameState/C_UIobject.h @@ -0,0 +1,20 @@ +#pragma once +#include "../C_Object.h" +namespace DanBias +{ + namespace Client + { + class C_UIobject : public C_Object + { + private: + struct myData; + myData* privData; + public: + C_UIobject(void); + virtual ~C_UIobject(void); + void Init(ModelInitData modelInit); + void setPos(); + + void Render(); + void Release(); + };};}; \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp index 4cd06d01..5e956176 100644 --- a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp @@ -26,10 +26,16 @@ LobbyState::~LobbyState(void) } bool LobbyState::Init() { + ModelInitData modelData; + + modelData.world = Oyster::Math3D::Float4x4::identity; + modelData.visible = true; + modelData.modelPath = L"crate"; // load models privData = new myData(); privData->object = new C_StaticObj(); - privData->object->Init(); + + privData->object->Init(modelData); privData->proj = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1024.0f/768.0f,.1f,1000); //privData->proj = Oyster::Math3D::ProjectionMatrix_Orthographic(1024, 768, 1, 1000); diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyState.h b/Code/Game/DanBiasGame/GameClientState/LobbyState.h index 8002238e..cba06547 100644 --- a/Code/Game/DanBiasGame/GameClientState/LobbyState.h +++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.h @@ -1,4 +1,6 @@ -#pragma once +#ifndef DANBIAS_CLIENT_GAMECLIENTSTATE_H +#define DANBIAS_CLIENT_GAMECLIENTSTATE_H + #include "GameClientState.h" namespace DanBias { @@ -18,3 +20,4 @@ public: bool Render(); bool Release(); };};}; +#endif // ! DANBIAS_CLIENT_GAMECLIENTSTATE_H