diff --git a/Code/Game/DanBiasGame/DanBiasGame.vcxproj b/Code/Game/DanBiasGame/DanBiasGame.vcxproj index 1f0bf1ce..81fd9ebf 100644 --- a/Code/Game/DanBiasGame/DanBiasGame.vcxproj +++ b/Code/Game/DanBiasGame/DanBiasGame.vcxproj @@ -215,6 +215,7 @@ + @@ -237,6 +238,7 @@ + diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index 923e53fc..c88739ff 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -8,6 +8,7 @@ #include "GameClientState\LobbyAdminState.h" #include "GameClientState\MainState.h" #include "GameClientState\LanMenuState.h" +#include "GameClientState\NetLoadState.h" #include #include "NetworkClient.h" #include @@ -56,7 +57,6 @@ namespace DanBias //-------------------------------------------------------------------------------------- DanBiasClientReturn DanBiasGame::Initiate(DanBiasGameDesc& desc) { - WindowShell::CreateConsoleWindow(); //if(! data.window->CreateWin(WindowShell::WINDOW_INIT_DESC(L"Window", cPOINT(1600, 900), cPOINT()))) if(! data.window->CreateWin(WindowShell::WINDOW_INIT_DESC())) @@ -151,7 +151,21 @@ namespace DanBias DanBiasGame::Result DanBiasGame::Update(float deltaTime) { - data.inputObj->Update(); + { // updating mouse input + POINT mousePos; + GetCursorPos( &mousePos ); + + RECT windowVertex; + GetWindowRect( data.window->GetHWND(), &windowVertex ); + + float mouseNormalisedX = (float)(mousePos.x - windowVertex.left); + mouseNormalisedX /= (float)(windowVertex.right - windowVertex.left); + + float mouseNormalisedY = (float)(mousePos.y - windowVertex.top); + mouseNormalisedY /= (float)(windowVertex.bottom - windowVertex.top); + + data.inputObj->Update( mouseNormalisedX, mouseNormalisedY ); + } if( data.serverOwner ) { @@ -169,8 +183,8 @@ namespace DanBias switch (state) { - case Client::GameClientState::ClientState_LobbyCreate: - data.state = new Client::LobbyAdminState(); + case Client::GameClientState::ClientState_Main: + data.state = new Client::MainState(); stateChanged = true; break; case Client::GameClientState::ClientState_Lan: @@ -181,10 +195,18 @@ namespace DanBias data.state = new Client::LobbyState(); stateChanged = true; break; + case Client::GameClientState::ClientState_LobbyCreate: + data.state = new Client::LobbyAdminState(); + stateChanged = true; + break; case Client::GameClientState::ClientState_Game: data.state = new Client::GameState(); stateChanged = true; break; + case Client::GameClientState::ClientState_NetLoad: + data.state = new Client::NetLoadState(); + stateChanged = true; + break; case Client::GameClientState::ClientState_Quit: data.state->Release(); return Result_quit; diff --git a/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h b/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h index 72ac354a..d4981c23 100644 --- a/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h +++ b/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h @@ -78,21 +78,24 @@ namespace DanBias { if(EventButton::Enabled()) { + // let the using dev decide what is rendered + Oyster::Graphics::API::RenderGuiElement(texture, pos, size, Oyster::Math::Float3(1.0f, 1.0f, 1.0f)); + //Render att xPos and yPos //With width and height - if(EventButton::GetState() == ButtonState_None) - { - //Oyster::Graphics::API::RenderGuiElement(texture, pos.xy, size, Oyster::Math::Float3(1.0f, 1.0f, 1.0f)); - } - else if(EventButton::GetState() == ButtonState_Hover) - { - //Oyster::Graphics::API::RenderGuiElement(texture, pos.xy, size, Oyster::Math::Float3(0.0f, 1.0f, 0.0f)); - } - else - { - //Oyster::Graphics::API::RenderGuiElement(texture, pos.xy, size, Oyster::Math::Float3(1.0f, 0.0f, 0.0f)); - } + //if(EventButton::GetState() == ButtonState_None) + //{ + // Oyster::Graphics::API::RenderGuiElement(texture, pos, size, Oyster::Math::Float3(1.0f, 1.0f, 1.0f)); + //} + //else if(EventButton::GetState() == ButtonState_Hover) + //{ + // Oyster::Graphics::API::RenderGuiElement(texture, pos, size, Oyster::Math::Float3(0.0f, 1.0f, 0.0f)); + //} + //else + //{ + // Oyster::Graphics::API::RenderGuiElement(texture, pos, size, Oyster::Math::Float3(1.0f, 0.0f, 0.0f)); + //} } } @@ -101,7 +104,7 @@ namespace DanBias { if(buttonText.size() > 0) { - //Oyster::Graphics::API::RenderText(buttonText, pos.xy, size, textColor); + Oyster::Graphics::API::RenderText(buttonText, pos - Float3(size.x * 0.5f, size.y * 0.25f, 0.0f), size*2.0f, size.y * 0.5f, textColor); } } diff --git a/Code/Game/DanBiasGame/GameClientState/Buttons/TextField.h b/Code/Game/DanBiasGame/GameClientState/Buttons/TextField.h index 4333f1da..af9c4346 100644 --- a/Code/Game/DanBiasGame/GameClientState/Buttons/TextField.h +++ b/Code/Game/DanBiasGame/GameClientState/Buttons/TextField.h @@ -28,7 +28,7 @@ namespace DanBias { namespace Client const ::std::wstring & operator[]( unsigned int i ) const; ::std::wstring & operator[]( unsigned int i ); - void SetTextHeight( ::Oyster::Math::Float h ); + void SetFontHeight( ::Oyster::Math::Float h ); void SetLineSpacing( ::Oyster::Math::Float ls ); void SetBottomAligned(); @@ -46,7 +46,7 @@ namespace DanBias { namespace Client private: bool isBottomAligned; - ::Oyster::Math::Float textHeight, lineSpacing; + ::Oyster::Math::Float fontHeight, lineSpacing; ::std::vector<::std::wstring> lines; }; @@ -56,7 +56,7 @@ namespace DanBias { namespace Client TextField::TextField() : ButtonRectangle() { - this->textHeight = 0.025f; + this->fontHeight = 0.025f; this->lineSpacing = 0.001f; this->isBottomAligned = true; } @@ -65,7 +65,7 @@ namespace DanBias { namespace Client TextField::TextField( ::std::wstring backgroundTexture, ::Oyster::Math::Float3 textColor, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize ) : ButtonRectangle( backgroundTexture, L"", textColor, owner, pos, size, resize ) { - this->textHeight = 0.025f; + this->fontHeight = 0.025f; this->lineSpacing = 0.001f; this->isBottomAligned = true; } @@ -76,38 +76,37 @@ namespace DanBias { namespace Client template void TextField::RenderText() { - ::Oyster::Math::Float lineStep = this->textHeight + this->lineSpacing; - ::Oyster::Math::Float2 rowSize = ::Oyster::Math::Float2( this->size.x, this->textHeight ); + ::Oyster::Math::Float lineStep = this->fontHeight + this->lineSpacing; + ::Oyster::Math::Float2 rowSize = ::Oyster::Math::Float2( this->size.x, this->fontHeight ); + ::Oyster::Math::Float3 fieldTopLeft = this->pos - Float3( this->size * 0.25f, 0.0f ); + ::Oyster::Math::Float3 topLeft = fieldTopLeft; if( this->isBottomAligned ) { - ::Oyster::Math::Float2 topLeft = this->pos; topLeft.y += this->size.y - lineStep; auto line = this->lines.rbegin(); for( ; line != this->lines.rend(); ++line ) { - if( topLeft.y - lineStep >= this->pos.y ) - { - ::Oyster::Graphics::API::RenderText( (*line), topLeft, rowSize, this->textColor ); - topLeft.y -= lineStep; - } - else break; + if( topLeft.y < fieldTopLeft.y ) + break; + + ::Oyster::Graphics::API::RenderText( (*line), topLeft, rowSize, this->fontHeight, this->textColor ); + topLeft.y -= lineStep; } } else { - ::Oyster::Math::Float2 topLeft = this->pos; + topLeft.y += this->lineSpacing; auto line = this->lines.begin(); for( ; line != this->lines.end(); ++line ) { - if( topLeft.y + lineStep < this->size.y ) - { - ::Oyster::Graphics::API::RenderText( (*line), topLeft, rowSize, this->textColor ); - topLeft.y += lineStep; - } - else break; + if( topLeft.y >= fieldTopLeft.y + this->size.y ) + break; + + ::Oyster::Graphics::API::RenderText( (*line), topLeft, rowSize, this->fontHeight, this->textColor ); + topLeft.y += lineStep; } } } @@ -125,9 +124,9 @@ namespace DanBias { namespace Client } template - void TextField::SetTextHeight( ::Oyster::Math::Float h ) + void TextField::SetFontHeight( ::Oyster::Math::Float h ) { - this->textHeight = h; + this->fontHeight = h; } template @@ -173,7 +172,7 @@ namespace DanBias { namespace Client split.reserve( 10 ); ::Utility::String::Split( split, text, L"\n", 0 ); auto line = split.begin(); - for( ; line != split.end; ++line ) + for( ; line != split.end(); ++line ) { this->lines.push_back( (*line) ); } diff --git a/Code/Game/DanBiasGame/GameClientState/C_Object.cpp b/Code/Game/DanBiasGame/GameClientState/C_Object.cpp index 3f9e08c1..d44d9201 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_Object.cpp +++ b/Code/Game/DanBiasGame/GameClientState/C_Object.cpp @@ -1,14 +1,31 @@ #include "C_Object.h" using namespace DanBias::Client; -void C_Object::Init(ModelInitData modelInit) +C_Object::C_Object() +{ + world = Oyster::Math::Float4x4::identity; + position = Oyster::Math::Float3::null; + rotation = Oyster::Math::Quaternion::identity; + scale = Oyster::Math::Float3::null; + + id = 0; + model = NULL; +} +C_Object::~C_Object() +{ + +} +bool C_Object::Init(ModelInitData modelInit) { position = modelInit.position; rotation = modelInit.rotation; scale = modelInit.scale; id = modelInit.id; model = Oyster::Graphics::API::CreateModel(modelInit.modelPath); + if(model == NULL) + return false; model->Visible = modelInit.visible; updateWorld(); + return true; } void C_Object::updateWorld() { diff --git a/Code/Game/DanBiasGame/GameClientState/C_Object.h b/Code/Game/DanBiasGame/GameClientState/C_Object.h index 1b50b73d..ae9dc3a5 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_Object.h +++ b/Code/Game/DanBiasGame/GameClientState/C_Object.h @@ -5,6 +5,7 @@ namespace DanBias { namespace Client { + struct ModelInitData { int id; @@ -15,52 +16,37 @@ namespace DanBias bool visible; }; - class C_Object - { - protected: - Oyster::Graphics::Model::Model *model; - private: - Oyster::Math::Float4x4 world; - Oyster::Math::Float3 position; - Oyster::Math::Quaternion rotation; - Oyster::Math::Float3 scale; - - int id; - void updateWorld(); - public: - - virtual void Init(ModelInitData modelInit); +class C_Object +{ +private: + Oyster::Math::Float4x4 world; + Oyster::Math::Float3 position; + Oyster::Math::Quaternion rotation; + Oyster::Math::Float3 scale; - void setWorld(Oyster::Math::Float4x4 world); - Oyster::Math::Float4x4 getWorld() const; - void setPos(Oyster::Math::Float3 newPos); - Oyster::Math::Float3 getPos() const; - void addPos(Oyster::Math::Float3 deltaPos); - void setRot(Oyster::Math::Quaternion newRot); - Oyster::Math::Quaternion getRotation() const; - void addRot(Oyster::Math::Quaternion deltaRot); - void setScale(Oyster::Math::Float3 newScale); - void addScale(Oyster::Math::Float3 deltaScale); - Oyster::Math::Float3 getScale() const; - - virtual void Render(); - virtual void Release(); - virtual int GetId() const; - }; - } -} - -namespace Utility { namespace DynamicMemory -{ // template specializationto allowuse of dynamicmemory tools - template<> - inline void SafeDeleteInstance( ::DanBias::Client::C_Object *dynamicInstance ) - { - if( dynamicInstance ) - { - dynamicInstance->Release(); - delete dynamicInstance; - } - } -} } + int id; + void updateWorld(); +protected: + Oyster::Graphics::Model::Model *model; +public: + C_Object(); + virtual ~C_Object(); + virtual bool Init(ModelInitData modelInit); + + void setWorld(Oyster::Math::Float4x4 world); + Oyster::Math::Float4x4 getWorld() const; + void setPos(Oyster::Math::Float3 newPos); + Oyster::Math::Float3 getPos() const; + void addPos(Oyster::Math::Float3 deltaPos); + void setRot(Oyster::Math::Quaternion newRot); + Oyster::Math::Quaternion getRotation() const; + void addRot(Oyster::Math::Quaternion deltaRot); + void setScale(Oyster::Math::Float3 newScale); + void addScale(Oyster::Math::Float3 deltaScale); + Oyster::Math::Float3 getScale() const; + virtual void Render(); + virtual void Release(); + virtual int GetId() const; +};};}; #endif diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp index e654348f..73dd20b5 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.cpp @@ -11,7 +11,7 @@ C_DynamicObj::~C_DynamicObj(void) { } -void C_DynamicObj::Init(ModelInitData modelInit) +bool C_DynamicObj::Init(ModelInitData modelInit) { - C_Object::Init(modelInit); + return C_Object::Init(modelInit); } diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.h b/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.h index ecb874d1..3f5a9dd1 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.h +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_DynamicObj.h @@ -11,7 +11,7 @@ private: public: C_DynamicObj(void); virtual ~C_DynamicObj(void); - void Init(ModelInitData modelInit); + bool Init(ModelInitData modelInit); };};}; #endif \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp index 916a6d16..b6420f53 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp @@ -3,14 +3,22 @@ using namespace DanBias::Client; C_Player::C_Player(void) - :C_DynamicObj() {} - -C_Player::~C_Player(void) {} - -void C_Player::Init(ModelInitData modelInit) + :C_DynamicObj() { - C_Object::Init(modelInit); - Oyster::Graphics::API::PlayAnimation( this->model, L"movement" ); - //Oyster::Graphics::API::Update(0.002f); } + +C_Player::~C_Player(void) +{ + +} + +bool C_Player::Init(ModelInitData modelInit) +{ + return C_Object::Init(modelInit); +} +void C_Player::playAnimation(std::wstring animation, bool loop) +{ + if(model) + Oyster::Graphics::API::PlayAnimation(model, L"movement", loop); +} \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.h b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.h index e08d2589..3ef96702 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.h +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.h @@ -5,15 +5,14 @@ namespace DanBias { namespace Client { - class C_Player : public C_DynamicObj - { - private: - public: - C_Player(void); - virtual ~C_Player(void); - void Init(ModelInitData modelInit); +class C_Player : public C_DynamicObj +{ +private: +public: + C_Player(void); + virtual ~C_Player(void); + bool Init(ModelInitData modelInit); + void playAnimation(std::wstring animation, bool loop); - }; - } -} +};};}; #endif diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.cpp index a61768e4..42a12acd 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.cpp +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.cpp @@ -10,7 +10,7 @@ C_StaticObj::~C_StaticObj(void) { } -void C_StaticObj::Init(ModelInitData modelInit) +bool C_StaticObj::Init(ModelInitData modelInit) { - C_Object::Init(modelInit); + return C_Object::Init(modelInit); } diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.h b/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.h index d2bcb2a9..60b09046 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.h +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_StaticObj.h @@ -11,7 +11,7 @@ private: public: C_StaticObj(void); virtual ~C_StaticObj(void); - void Init(ModelInitData modelInit); + bool Init(ModelInitData modelInit); };};}; #endif \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp b/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp index 570fa22f..4cc57a98 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.cpp @@ -10,7 +10,7 @@ C_UIobject::C_UIobject(void) C_UIobject::~C_UIobject(void) { } -void C_UIobject::Init(ModelInitData modelInit) +bool C_UIobject::Init(ModelInitData modelInit) { - C_Object::Init(modelInit); + return C_Object::Init(modelInit); } diff --git a/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.h b/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.h index f002fcb2..fe4b68d0 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.h +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_UIobject.h @@ -12,7 +12,7 @@ namespace DanBias public: C_UIobject(void); virtual ~C_UIobject(void); - void Init(ModelInitData modelInit); + bool Init(ModelInitData modelInit); void setPos(Oyster::Math::Float4x4 world); };};}; #endif \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/GameClientState.h b/Code/Game/DanBiasGame/GameClientState/GameClientState.h index a1936bab..9317413e 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameClientState.h +++ b/Code/Game/DanBiasGame/GameClientState/GameClientState.h @@ -12,11 +12,12 @@ namespace DanBias { namespace Client public: enum ClientState { - ClientState_Login, + ClientState_Main, ClientState_Lan, ClientState_Lobby, ClientState_LobbyCreate, ClientState_LobbyReady, + ClientState_NetLoad, ClientState_Game, ClientState_Same, ClientState_Quit diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index 9e42c87b..66ca6c12 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -2,20 +2,20 @@ #include "DllInterfaces/GFXAPI.h" #include #include "NetworkClient.h" -#include "Camera.h" +#include "Camera_FPS.h" #include -#include "LevelLoader\ObjectDefines.h" -using namespace GameLogic; -using namespace DanBias::Client; -using namespace Oyster::Math; -struct GameState::myData +using namespace ::DanBias::Client; +using namespace ::Oyster; +using namespace ::Oyster::Network; +using namespace ::Oyster::Math3D; + +struct GameState::MyData { - myData(){} - int modelCount; - Oyster::Network::NetworkClient* nwClient; - gameStateState state; -}privData; + MyData(){} + GameClientState::ClientState nextState; + NetworkClient *nwClient; +} privData; GameState::GameState(void) { @@ -23,145 +23,36 @@ GameState::GameState(void) key_backward = false; key_strafeRight = false; key_strafeLeft = false; - timer = 0; } - GameState::~GameState(void) { - delete this->camera; - delete this->privData; + if( this->privData ) + this->Release(); } -bool GameState::Init(Oyster::Network::NetworkClient* nwClient) + +bool GameState::Init(NetworkClient* nwClient) { // load models - camera = new Camera; - privData = new myData(); - privData->state = gameStateState_loading; - privData->nwClient = nwClient; - privData->state = LoadGame(); - pitch = 0; + privData = new MyData(); - //tELL SERver ready - nwClient->Send(GameLogic::Protocol_General_Status(GameLogic::Protocol_General_Status::States_ready)); + this->privData->nextState = GameClientState::ClientState_Same; + this->privData->nwClient = nwClient; + + LoadGame(); + + //tell server ready + nwClient->Send( GameLogic::Protocol_General_Status(GameLogic::Protocol_General_Status::States_ready) ); return true; } + GameState::gameStateState GameState::LoadGame() { - Oyster::Graphics::Definitions::Pointlight plight; - plight.Pos = Float3(615, 0 ,5); - plight.Color = Float3(0.9f,0.7f,0.2f); - plight.Radius = 100; - plight.Bright = 0.5f; - Oyster::Graphics::API::AddLight(plight); - plight.Pos = Float3(10,800,5); - plight.Color = Float3(0.9f,0.7f,0.3f); - plight.Radius = 300; - plight.Bright = 0.5f; - Oyster::Graphics::API::AddLight(plight); - // use level loader - LoadModels("../Content/Worlds/ccc.bias"); - - // hardcoded objects - Float3 startPos = Float3(0,0,20.0f); - InitCamera(startPos); return gameStateState_playing; } -bool GameState::LoadModels() -{ - // open file - // read file - // init models - int nrOfBoxex = 5; - int id = 100; - // add world model - ModelInitData modelData; - - modelData.position = Oyster::Math::Float3(0,0,0); - modelData.rotation = Oyster::Math::Quaternion::identity; - modelData.scale = Oyster::Math::Float3(2,2,2); - - modelData.modelPath = L"world_earth.dan"; - modelData.id = id++; - - this->staticObjects.Push(new C_StaticObj()); - this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData); - - - // add box model - modelData.position = Oyster::Math::Float3(0,0,0); - modelData.rotation = Oyster::Math::Quaternion::identity; - modelData.scale = Oyster::Math::Float3(1,1,1); - modelData.modelPath = L"crate_colonists.dan"; - - - for(int i =0; i< nrOfBoxex; i ++) - { - modelData.position = Oyster::Math::Float3(4,320,0); - modelData.id = id++; - - this->dynamicObjects.Push(new C_DynamicObj()); - this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); - } - - // add crystal model - modelData.position = Oyster::Math::Float3(10, 601, 0); - modelData.modelPath = L"crystalformation_b.dan"; - modelData.id = id++; - // load models - this->dynamicObjects.Push(new C_DynamicObj()); - this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); - - // add house model - modelData.position = Oyster::Math::Float3(-50, 590, 0); - //Oyster::Math3D::Float4x4 rot = Oyster::Math3D::RotationMatrix(Oyster::Math::Float3(0 ,Utility::Value::Radian(90.0f), 0)); - - modelData.visible = true; - modelData.modelPath = L"building_corporation.dan"; - modelData.id = id++; - // load models - this->staticObjects.Push(new C_StaticObj()); - this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData); - - // add jumppad - modelData.position = Oyster::Math::Float3(4, 600.3f, 0); - modelData.modelPath = L"jumppad_round.dan"; - modelData.id = id++; - // load models - this->staticObjects.Push(new C_StaticObj()); - this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData); - - // add player model - modelData.position = Oyster::Math::Float3(0, 602, 0); - modelData.modelPath = L"char_still_sizeref.dan"; - modelData.id = id++; - // load models - this->dynamicObjects.Push(new C_DynamicObj()); - this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); - - // add player model 2 - modelData.position = Oyster::Math::Float3(50, 602, 0); - modelData.modelPath = L"char_still_sizeref.dan"; - modelData.id = id++; - // load models - this->dynamicObjects.Push(new C_DynamicObj()); - this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); - - - - // add sky sphere - modelData.position = Oyster::Math::Float3(0,0,0); - modelData.scale = Oyster::Math::Float3(800,800,800); - modelData.modelPath = L"skysphere.dan"; - modelData.id = id++; - // load models - this->dynamicObjects.Push(new C_DynamicObj()); - this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); - return true; -} bool GameState::LoadModels(std::string mapFile) { GameLogic::LevelLoader levelLoader; @@ -169,7 +60,7 @@ bool GameState::LoadModels(std::string mapFile) objects = levelLoader.LoadLevel(mapFile); int objCount = objects.size(); - int modelId = 100; + int modelId = 0; ModelInitData modelData; for (int i = 0; i < objCount; i++) { @@ -186,9 +77,9 @@ bool GameState::LoadModels(std::string mapFile) modelData.modelPath.assign(staticObjData->ModelFile.begin(), staticObjData->ModelFile.end()); modelData.visible = true; - modelData.position = staticObjData->position; - modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(staticObjData->rotation), staticObjData->rotation[3]); - modelData.scale = staticObjData->scale; + //modelData.position = ; + //modelData.rotation = Quaternion(Float3(2,2,-2), 1); + //modelData.scale = Float3(2,2,2); modelData.id = modelId++; this->staticObjects.Push(new C_StaticObj()); @@ -198,11 +89,11 @@ bool GameState::LoadModels(std::string mapFile) case GameLogic::ObjectType::ObjectType_Dynamic: { GameLogic::ObjectHeader* dynamicObjData = ((GameLogic::ObjectHeader*)obj); + //modelData.position = ; + //modelData.rotation = Quaternion(Float3(2,2,-2), 1); + //modelData.scale = Float3(2,2,2); modelData.modelPath.assign(dynamicObjData->ModelFile.begin(), dynamicObjData->ModelFile.end()); modelData.visible = true; - modelData.position = dynamicObjData->position; - modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(dynamicObjData->rotation), dynamicObjData->rotation[3]); - modelData.scale = dynamicObjData->scale; modelData.id = modelId++; this->dynamicObjects.Push(new C_DynamicObj()); @@ -213,14 +104,19 @@ bool GameState::LoadModels(std::string mapFile) { GameLogic::BasicLight* lightData = ((GameLogic::BasicLight*)obj); - if(lightData->lightType == GameLogic::LightType_PointLight) + switch( lightData->lightType ) { - Oyster::Graphics::Definitions::Pointlight plight; - plight.Pos = ((GameLogic::BasicLight*)lightData)->position; - plight.Color = lightData->color; - plight.Radius = 100; - plight.Bright = 0.9f; - Oyster::Graphics::API::AddLight(plight); + case GameLogic::LightType_PointLight: + { + //Oyster::Graphics::Definitions::Pointlight plight; + //plight.Pos = ((GameLogic::PointLight*)lightData)->position; + //plight.Color = lightData->diffuseColor; + //plight.Radius = 100; + //plight.Bright = 0.9f; + //Oyster::Graphics::API::AddLight(plight); + } + break; + default: break; } } break; @@ -228,67 +124,39 @@ bool GameState::LoadModels(std::string mapFile) break; } } - - Oyster::Math::Quaternion first = Oyster::Math::Quaternion(Float3(0.3536,0.3536,-0.146), 0.8536); - Oyster::Math::Quaternion second = Oyster::Math::Quaternion(Float3(0.3536,0.3536,-0.146), 0.8536); - Oyster::Math::Quaternion result = first * second; - Oyster::Math::Quaternion total = Oyster::Math::Quaternion(Float3(0.5,0.5,-0.5), 0.5); - modelData.visible = true; - modelData.position = Oyster::Math::Float3(20, 127,0); - modelData.rotation = first; - modelData.scale = Oyster::Math::Float3(1,1,1); - modelData.modelPath = L"char_still_sizeref.dan"; - modelData.id = myId; + myId += modelId++; + // add player model + //modelData.position = ; + //modelData.rotation = Quaternion(Float3(2,2,-2), 1); + //modelData.scale = Float3(2,2,2); - this->staticObjects.Push(new C_StaticObj()); - this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData); modelData.visible = true; - modelData.position = Oyster::Math::Float3(22, 127,0); - modelData.rotation = second; - modelData.scale = Oyster::Math::Float3(1,1,1); modelData.modelPath = L"char_still_sizeref.dan"; modelData.id = myId; + // load models + this->dynamicObjects.Push(new C_DynamicObj()); + this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); - this->staticObjects.Push(new C_StaticObj()); - this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData); - - modelData.visible = true; - modelData.position = Oyster::Math::Float3(24, 127,0); - modelData.rotation = result; - modelData.scale = Oyster::Math::Float3(1,1,1); - modelData.modelPath = L"char_still_sizeref.dan"; - modelData.id = myId; - - this->staticObjects.Push(new C_StaticObj()); - this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData); - - modelData.visible = true; - modelData.position = Oyster::Math::Float3(26, 127,0); - modelData.rotation = total; - modelData.scale = Oyster::Math::Float3(1,1,1); - modelData.modelPath = L"char_still_sizeref.dan"; - modelData.id = myId; - - this->staticObjects.Push(new C_StaticObj()); - this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData); - + /*C_Player* obj = new C_Player(); + privData->object.push_back(obj); + privData->object[privData->object.size() -1 ]->Init(modelData); + */ return true; } + bool GameState::InitCamera(Float3 startPos) { - Float3 dir = Float3(0,0,1); - Float3 up = Float3(0,1,0); - 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.SetHeadOffset( Float3(0.0f, 1.0f, 1.0f) ); + camera.SetPerspectiveProjection( pi / 4.0f, 1024.0f/768.0f, 1.0f, 1000.0f ); + camera.UpdateOrientation(); + Oyster::Graphics::API::SetProjection(camera.GetProjectionMatrix()); 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; @@ -296,87 +164,61 @@ void GameState::InitiatePlayer(int id, std::wstring modelName, Oyster::Math::Flo C_Object* obj; modelData.visible = true; //modelData.world = world; - modelData.position = Oyster::Math::Float3(world[12], world[13], world[14]); - modelData.rotation = Oyster::Math::Quaternion(Oyster::Math::Float3(0,0,0), 1); - modelData.scale = Oyster::Math::Float3(1,1,1); + modelData.position = Float3(world[12], world[13], world[14]); + modelData.rotation = Quaternion(Float3(0,0,0), 1); + modelData.scale = Float3(1,1,1); modelData.modelPath = modelName; modelData.id = myId; - obj = new C_Player(); + obj = new C_Player(); this->dynamicObjects.Push(obj); this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); - - - Oyster::Math::Float3 right = Oyster::Math::Float3(world[0], world[1], world[2]); - Oyster::Math::Float3 up = Oyster::Math::Float3(world[4], world[5], world[6]); - Oyster::Math::Float3 objForward = (Oyster::Math::Float3(world[8], world[9], world[10])); - Oyster::Math::Float3 pos = Oyster::Math::Float3(world[12], world[13], world[14]); - Oyster::Math::Float3 cameraLook = camera->GetLook(); - Oyster::Math::Float3 cameraUp = camera->GetUp(); - - + Float3 pos = Float3(world[12], world[13], world[14]); - /*Oyster::Math::Float3 newUp = cameraUp.Dot(up); - up *= newUp; - up.Normalize(); - Oyster::Math::Float3 newLook = up.Cross(right); - newLook.Normalize();*/ - - camera->setRight(right); - camera->setUp(up); - camera->setLook(objForward); - - up *= 2; - objForward *= 3; - Oyster::Math::Float3 cameraPos = up + pos + objForward; - camera->SetPosition(cameraPos); - - camera->UpdateViewMatrix(); - + camera.SetPosition( pos ); + camera.UpdateOrientation(); } + GameClientState::ClientState GameState::Update(float deltaTime, InputClass* KeyInput) { - switch (privData->state) - { - case gameStateState_loading: //Will this ever happen in this scope?? - { - // load map - // wait for all players - LoadGame(); - GameLogic::Protocol_General_Status gameStatus; - gameStatus.status = GameLogic::Protocol_General_Status::States_ready; - privData->nwClient->Send(gameStatus); - privData->state = gameStateState_playing; - } - break; - case gameStateState_playing: - // read server data - // update objects - { - timer += deltaTime; - if(timer > 0.03) - { - readKeyInput(KeyInput); - timer = 0; - } - camera->UpdateViewMatrix(); + //switch (privData->state) + //{ + //case gameStateState_loading: //Will this ever happen in this scope?? + // { + // // load map + // // wait for all players + // LoadGame(); + // GameLogic::Protocol_General_Status gameStatus; + // gameStatus.status = GameLogic::Protocol_General_Status::States_ready; + // privData->nwClient->Send(gameStatus); + // privData->state = gameStateState_playing; + // } + // break; + //case gameStateState_playing: + // // read server data + // // update objects + // { + // readKeyInput(KeyInput); + // camera.UpdateOrientation(); + // } + // break; + //case gameStateState_end: + // return ClientState_Lobby; + // break; + //default: + // break; + //} + // + //// send key input to server. + //return ClientState_Same; - } - break; - case gameStateState_end: - return ClientState_Lobby; - break; - default: - break; - } - - // send key input to server. - return ClientState_Same; + return this->privData->nextState; } -bool GameState::Render(float dt) + +bool GameState::Render() { - Oyster::Graphics::API::SetView(camera->View()); + Oyster::Graphics::API::SetView( camera.GetViewMatrix() ); Oyster::Graphics::API::NewFrame(); for (unsigned int i = 0; i < staticObjects.Size(); i++) @@ -387,34 +229,28 @@ bool GameState::Render(float dt) { dynamicObjects[i]->Render(); } - Oyster::Graphics::API::StartTextRender(); - std::wstring fps; - float f = 1/dt; - fps = std::to_wstring(f); - //Oyster::Graphics::API::RenderText(fps,Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.2f,0.05f)); Oyster::Graphics::API::EndFrame(); return true; } + bool GameState::Release() { - /*for (unsigned int i = 0; i < privData->object.size(); i++) - { - privData->object[i]->Release(); - delete privData->object[i]; - privData->object[i] = NULL; - }*/ - delete privData; privData = NULL; return true; } + +void GameState::ChangeState( ClientState next ) +{ + this->privData->nextState = next; +} + void GameState::readKeyInput(InputClass* KeyInput) { - if(KeyInput->IsKeyPressed(DIK_W)) { - //if(!key_forward) + if(!key_forward) { privData->nwClient->Send(GameLogic::Protocol_PlayerMovementForward()); key_forward = true; @@ -425,7 +261,7 @@ void GameState::readKeyInput(InputClass* KeyInput) if(KeyInput->IsKeyPressed(DIK_S)) { - //if(!key_backward) + if(!key_backward) { privData->nwClient->Send(GameLogic::Protocol_PlayerMovementBackward()); key_backward = true; @@ -436,7 +272,7 @@ void GameState::readKeyInput(InputClass* KeyInput) if(KeyInput->IsKeyPressed(DIK_A)) { - //if(!key_strafeLeft) + if(!key_strafeLeft) { privData->nwClient->Send(GameLogic::Protocol_PlayerMovementLeft()); key_strafeLeft = true; @@ -447,7 +283,7 @@ void GameState::readKeyInput(InputClass* KeyInput) if(KeyInput->IsKeyPressed(DIK_D)) { - //if(!key_strafeRight) + if(!key_strafeRight) { privData->nwClient->Send(GameLogic::Protocol_PlayerMovementRight()); key_strafeRight = true; @@ -458,17 +294,16 @@ void GameState::readKeyInput(InputClass* KeyInput) //send delta mouse movement - if (KeyInput->IsMousePressed()) + //if (KeyInput->IsMousePressed()) { - camera->Yaw(-KeyInput->GetYaw()); - camera->Pitch(KeyInput->GetPitch()); - pitch = KeyInput->GetPitch(); - camera->UpdateViewMatrix(); - Oyster::Math::Float3 look = camera->GetLook(); - Oyster::Math::Float3 right = camera->GetRight(); - GameLogic::Protocol_PlayerLook playerLook(look, right); + camera.YawRight( -KeyInput->GetYaw() ); + camera.PitchUp( KeyInput->GetPitch() ); + camera.UpdateOrientation(); - privData->nwClient->Send(playerLook); + GameLogic::Protocol_PlayerLook playerLookDir; + Float4 look = camera.GetLook(); + + privData->nwClient->Send( playerLookDir ); } // shoot @@ -486,7 +321,6 @@ void GameState::readKeyInput(InputClass* KeyInput) } else key_Shoot = false; - if(KeyInput->IsKeyPressed(DIK_X)) { if(!key_Shoot) @@ -501,7 +335,6 @@ void GameState::readKeyInput(InputClass* KeyInput) } else key_Shoot = false; - if(KeyInput->IsKeyPressed(DIK_C)) { if(!key_Shoot) @@ -531,98 +364,141 @@ void GameState::readKeyInput(InputClass* KeyInput) // send event data // - if(KeyInput->IsKeyPressed(DIK_L)) - privData->state = GameState::gameStateState_end; + //if(KeyInput->IsKeyPressed(DIK_L)) + // privData->state = GameState::gameStateState_end; } -void GameState::Protocol(ProtocolStruct* pos) +using namespace ::Oyster::Network; +using namespace ::Utility::DynamicMemory; + +// returns -1 if none found +int FindObject( const DynamicArray> &collection, int id ) { + int num = collection.Size(); + for( int i = 0; i < num; ++i ) if( id == collection[i]->GetId() ) + return i; + return -1; +} + +void GameState::DataRecieved( NetEvent e ) +{ + CustomNetProtocol data = e.args.data.protocol; + short ID = data[0].value.netShort; // fetching the id data. -} - -void GameState::Protocol( 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 = world * translate; - ////privData->object[0]->setPos( world ); - //for (unsigned int i = 0; i < dynamicObjects.Size(); i++) - //{ - // dynamicObjects[i]->Render(); - //} -} - -void GameState::Protocol( ObjPos* pos ) -{ - Oyster::Math::Float4x4 world; - for(int i = 0; i<16; i++) + if( ProtocolIsGameplay(ID) ) { - world[i] = pos->worldPos[i]; - } - - for (unsigned int i = 0; i < dynamicObjects.Size(); i++) - { - if(dynamicObjects[i]->GetId() == pos->object_ID) + switch(ID) { - dynamicObjects[i]->setPos(Float3(world[0], world[1], world[2])); - dynamicObjects[i]->setRot(Quaternion(Float3(world[3], world[4], world[5]), world[6])); - //dynamicObjects[i]->setWorld(world); - - if(dynamicObjects[i]->GetId() == myId) // playerobj + case protocol_Gameplay_ObjectPickup: break; /** @todo TODO: implement */ + case protocol_Gameplay_ObjectDamage: break; /** @todo TODO: implement */ + case protocol_Gameplay_ObjectHealthStatus: break; /** @todo TODO: implement */ + case protocol_Gameplay_ObjectPosition: { + GameLogic::Protocol_ObjectPosition decoded(data); + // if is this player. Remember to change camera + if( this->myId == decoded.object_ID ) + camera.SetPosition( decoded.position ); - Float3 pos = dynamicObjects[i]->getPos(); - Float3 up = dynamicObjects[i]->getWorld().v[1]; - Float3 objForward = dynamicObjects[i]->getWorld().v[2]; - up *= 3; - objForward *= -4; - Oyster::Math::Float3 cameraPos = pos + up + objForward; - camera->SetPosition(cameraPos); + int i = FindObject( this->dynamicObjects, decoded.object_ID ); + if( i > -1 ) + this->dynamicObjects[i]->setPos( decoded.position ); } + break; + case protocol_Gameplay_ObjectScale: + { + GameLogic::Protocol_ObjectScale decoded(data); + int i = FindObject( this->dynamicObjects, decoded.object_ID ); + if( i > -1 ) + this->dynamicObjects[i]->setScale( decoded.scale ); + } + break; + case protocol_Gameplay_ObjectRotation: + { + GameLogic::Protocol_ObjectRotation decoded(data); + Quaternion rotation = Quaternion( Float3(decoded.rotationQ), decoded.rotationQ[3] ); + + // if is this player. Remember to change camera + if( this->myId == decoded.object_ID ) + camera.SetAngular( AngularAxis(rotation) ); + + int i = FindObject( this->dynamicObjects, decoded.object_ID ); + if( i > -1 ) + this->dynamicObjects[i]->setRot( rotation ); + } + break; + case protocol_Gameplay_ObjectPositionRotation: + { + GameLogic::Protocol_ObjectPositionRotation decoded(data); + Float3 position = decoded.position; + Quaternion rotation = Quaternion( Float3(decoded.rotationQ), decoded.rotationQ[3] ); + + // if is this player. Remember to change camera + if( this->myId == decoded.object_ID ) + { + camera.SetPosition( position ); + camera.SetAngular( AngularAxis(rotation) ); + } + + int i = FindObject( this->dynamicObjects, decoded.object_ID ); + if( i > -1 ) + { + this->dynamicObjects[i]->setPos( position ); + this->dynamicObjects[i]->setRot( rotation ); + } + } + break; + case protocol_Gameplay_ObjectEnabled: break; /** @todo TODO: implement */ + case protocol_Gameplay_ObjectDisabled: + { + GameLogic::Protocol_ObjectDisable decoded(data); + + int i = FindObject( this->dynamicObjects, decoded.objectID ); + if( i > -1 ) + { + this->dynamicObjects[i].Release(); + this->dynamicObjects.Pop(i); + } + } + break; + case protocol_Gameplay_ObjectCreate: + { + GameLogic::Protocol_ObjectCreate decoded(data); + C_DynamicObj* object = new C_DynamicObj(); + + ModelInitData modelData; + { + modelData.position = Float3( decoded.position ); + modelData.rotation = Quaternion( Float3(decoded.rotationQ), decoded.rotationQ[3] ); + modelData.scale = Float3( decoded.scale ); + modelData.visible = true; + modelData.id = decoded.object_ID; + + ::Utility::String::StringToWstring( decoded.name, modelData.modelPath ); + } + object->Init(modelData); + + dynamicObjects.Push(object); + + } + break; + case protocol_Gameplay_ObjectCreatePlayer: break; /** @todo TODO: implement */ + case protocol_Gameplay_ObjectJoinTeam: break; /** @todo TODO: implement */ + case protocol_Gameplay_ObjectLeaveTeam: break; /** @todo TODO: implement */ + case protocol_Gameplay_ObjectWeaponCooldown: break; /** @todo TODO: implement */ + case protocol_Gameplay_ObjectWeaponEnergy: break; /** @todo TODO: implement */ + case protocol_Gameplay_ObjectRespawn: break; /** @todo TODO: implement */ + case protocol_Gameplay_ObjectDie: break; /** @todo TODO: implement */ + default: break; } } -} - -void GameState::Protocol( NewObj* newObj ) -{ - - Oyster::Math::Float4x4 world; - for(int i = 0; i<16; i++) + else if( ProtocolIsGeneral(ID) ) { - world[i] = newObj->worldPos[i]; - } - ModelInitData modelData; - - //modelData.world = world; - modelData.visible = true; - modelData.id = newObj->object_ID; - //not sure if this is good parsing rom char* to wstring - const char* path = newObj->path; - modelData.modelPath = std::wstring(path, path + strlen(path)); - // load models - C_DynamicObj* player = new C_DynamicObj(); - player->Init(modelData); - - dynamicObjects.Push(player); - -} - -void DanBias::Client::GameState::Protocol( RemoveObj* obj ) -{ - for (unsigned int i = 0; i < dynamicObjects.Size(); i++) - { - if(dynamicObjects[i]->GetId() == obj->object_ID) + switch( ID ) { - //dynamicObjects[i]->Release(); - dynamicObjects[i].Release(); - //dynamicObjects.erase(privData->object.begin() + i ); + case protocol_General_Status: break; /** @todo TODO: implement */ + case protocol_General_Text: break; /** @todo TODO: implement */ + default: break; } } - //privData->object[obj->object_ID]->Release( ); } - -//void GameState::Protocol(LightPos pos); \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp b/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp index c4d2b41d..6a836a36 100644 --- a/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp @@ -36,6 +36,7 @@ struct LanMenuState::MyData } privData; void OnButtonInteract_Connect( Oyster::Event::ButtonEvent& e ); +void OnButtonInteract_Exit( Oyster::Event::ButtonEvent& e ); LanMenuState::LanMenuState() {} @@ -55,19 +56,22 @@ bool LanMenuState::Init(Network::NetworkClient* nwClient) this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" ); // create guiElements - ButtonRectangle *guiElements; - //0.5f, 0.2f, 0.3f, 0.1f, - guiElements = new ButtonRectangle( L"earth_md.png", L"Connect", Float3(1.0f), OnButtonInteract_Connect, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width ); - this->privData->guiElements.AddButton( guiElements ); - - this->privData->connectIP = new TextField( L"earth_md.png", Float3(1.0f), this, Float3(0.1f, 0.2f, 0.5f), Float2(0.45f, 0.1f), ResizeAspectRatio_Width ); + this->privData->connectIP = new TextField( L"earth_md.png", Float3(1.0f), this, Float3(0.5f, 0.3f, 0.5f), Float2(0.8f, 0.09f), ResizeAspectRatio_None ); this->privData->connectIP->ReserveLines( 1 ); - (*this->privData->connectIP)[0] = L"127.0.0.1"; - this->privData->connectIP->SetTextHeight( 0.1f ); - this->privData->connectIP->SetLineSpacing( 0.0f ); + this->privData->connectIP->AppendText( L"127.0.0.1" ); + this->privData->connectIP->SetFontHeight( 0.08f ); + this->privData->connectIP->SetLineSpacing( 0.005f ); + this->privData->connectIP->SetTopAligned(); this->privData->guiElements.AddButton( this->privData->connectIP ); + ButtonRectangle *guiElements; + guiElements = new ButtonRectangle( L"earth_md.png", L"Connect", Float3(1.0f), OnButtonInteract_Connect, this, Float3(0.5f, 0.4f, 0.5f), Float2(0.3f, 0.05f), ResizeAspectRatio_None ); + this->privData->guiElements.AddButton( guiElements ); + + guiElements = new ButtonRectangle( L"earth_md.png", L"Exit", Float3(1.0f), OnButtonInteract_Exit, this, Float3(0.5f, 0.5f, 0.5f), Float2(0.3f, 0.05f), ResizeAspectRatio_None ); + this->privData->guiElements.AddButton( guiElements ); + // bind guiElements collection to the singleton eventhandler EventHandler::Instance().AddCollection( &this->privData->guiElements ); @@ -80,8 +84,7 @@ GameClientState::ClientState LanMenuState::Update(float deltaTime, InputClass* K { MouseInput mouseState; { - mouseState.x = KeyInput->GetPitch(); - mouseState.y = KeyInput->GetYaw(); + KeyInput->GetMousePos( mouseState.x, mouseState.y ); mouseState.mouseButtonPressed = KeyInput->IsMousePressed(); } @@ -96,7 +99,7 @@ bool LanMenuState::Render( ) Graphics::API::StartGuiRender(); - Graphics::API::RenderGuiElement( this->privData->background, Float2(0.5f), Float2(1.0f) ); + Graphics::API::RenderGuiElement( this->privData->background, Float3(0.5f, 0.5f, 1.0f), Float2(1.0f) ); this->privData->guiElements.RenderTexture(); Graphics::API::StartTextRender(); @@ -118,8 +121,8 @@ void LanMenuState::ChangeState( ClientState next ) { case GameClientState::ClientState_Lobby: // attempt to connect to lobby - if( !this->privData->nwClient->Connect(this->privData->connectPort, (*this->privData->connectIP)[0]) ) - return; + //if( !this->privData->nwClient->Connect(this->privData->connectPort, (*this->privData->connectIP)[0]) ) + // return; // TODO: temporary commented out break; default: break; } @@ -132,8 +135,19 @@ void OnButtonInteract_Connect( Oyster::Event::ButtonEvent& e ) switch( e.state ) { case ButtonState_Released: - e.owner->ChangeState( GameClientState::ClientState_LobbyCreate ); + e.owner->ChangeState( GameClientState::ClientState_Lobby ); break; default: break; } -} \ No newline at end of file +} + +void OnButtonInteract_Exit( Oyster::Event::ButtonEvent& e ) +{ + switch( e.state ) + { + case ButtonState_Released: + e.owner->ChangeState( GameClientState::ClientState_Main ); + break; + default: break; + } +} diff --git a/Code/Game/DanBiasGame/GameClientState/LevelLoader/LevelParser.cpp b/Code/Game/DanBiasGame/GameClientState/LevelLoader/LevelParser.cpp index c5dfa8cc..39d2f625 100644 --- a/Code/Game/DanBiasGame/GameClientState/LevelLoader/LevelParser.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LevelLoader/LevelParser.cpp @@ -59,6 +59,27 @@ std::vector> LevelParser::Parse(std::string filen break; } + case ObjectType_SpawnPoint: + { + loadCgf = false; + ObjectHeader* header = new ObjectHeader; + ParseObject(&buffer[counter], *header, counter, loadCgf); + + SpawnPointAttributes* spawn = new SpawnPointAttributes; + + spawn->typeID = header->typeID; + + for(int i = 0; i < 3; i++) + { + spawn->position[i] = header->position[i]; + } + + delete header; + //objects.push_back(header); + objects.push_back(spawn); + break; + } + //This is by design, static and dynamic is using the same converter. Do not add anything inbetween them. //Unless they are changed to not be the same. case ObjectType_Static: case ObjectType_Dynamic: @@ -133,13 +154,8 @@ std::vector> LevelParser::Parse(std::string filen objects.push_back(header); break; } - - case ObjectSpecialType_SpawnPoint: - { - loadCgf = false; - ObjectHeader* header = new ObjectHeader; - ParseObject(&buffer[counter], *header, counter, loadCgf); - } + //this is a hotfix, fix so you only load the relevant data when the file is updated + default: //Couldn't find specialType diff --git a/Code/Game/DanBiasGame/GameClientState/LevelLoader/ObjectDefines.h b/Code/Game/DanBiasGame/GameClientState/LevelLoader/ObjectDefines.h index 09556cdc..bb2ae439 100644 --- a/Code/Game/DanBiasGame/GameClientState/LevelLoader/ObjectDefines.h +++ b/Code/Game/DanBiasGame/GameClientState/LevelLoader/ObjectDefines.h @@ -16,6 +16,7 @@ namespace GameLogic ObjectType_Static, ObjectType_Dynamic, ObjectType_Light, + ObjectType_SpawnPoint, //Etc ObjectType_NUM_OF_TYPES, @@ -38,7 +39,6 @@ namespace GameLogic ObjectSpecialType_CrystalShard, ObjectSpecialType_JumpPad, ObjectSpecialType_Portal, - ObjectSpecialType_SpawnPoint, ObjectSpecialType_Player, @@ -206,6 +206,13 @@ namespace GameLogic virtual ~ObjectHeader(){} }; + //inheritance from the base class because there is no use for ModelFile, Rotation and Scale + //so this is a special struct for just spawnpoints + struct SpawnPointAttributes : public ObjectTypeHeader + { + float position[3]; + }; + /************************************ Special objects *************************************/ @@ -234,6 +241,8 @@ namespace GameLogic + + /************************************ Lights *************************************/ diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.cpp b/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.cpp index 21afb54b..c157226e 100644 --- a/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.cpp @@ -70,8 +70,7 @@ GameClientState::ClientState LobbyAdminState::Update(float deltaTime, InputClass MouseInput mouseState; { - mouseState.x = KeyInput->GetPitch(); - mouseState.y = KeyInput->GetYaw(); + KeyInput->GetMousePos( mouseState.x, mouseState.y ); mouseState.mouseButtonPressed = KeyInput->IsMousePressed(); } @@ -84,7 +83,7 @@ bool LobbyAdminState::Render( ) Graphics::API::NewFrame(); Graphics::API::StartGuiRender(); - Graphics::API::RenderGuiElement( this->privData->background, Float2(0.5f), Float2(1.0f) ); + Graphics::API::RenderGuiElement( this->privData->background, Float3(0.5f, 0.5f, 1.0f), Float2(1.0f) ); this->privData->guiElements.RenderTexture(); Graphics::API::StartTextRender(); @@ -121,14 +120,14 @@ void LobbyAdminState::DataRecieved( NetEvent *button; - button = new ButtonRectangle( L"earth_md.png", L"", Float3(1.0f), OnButtonInteract_Ready, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width ); + button = new ButtonRectangle( L"earth_md.png", L"Ready", Float3(1.0f), OnButtonInteract_Ready, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width ); this->privData->guiElements.AddButton( button ); // bind button collection to the singleton eventhandler @@ -70,8 +70,7 @@ GameClientState::ClientState LobbyState::Update(float deltaTime, InputClass* Key MouseInput mouseState; { - mouseState.x = KeyInput->GetPitch(); - mouseState.y = KeyInput->GetYaw(); + KeyInput->GetMousePos( mouseState.x, mouseState.y ); mouseState.mouseButtonPressed = KeyInput->IsMousePressed(); } @@ -84,7 +83,7 @@ bool LobbyState::Render( ) Graphics::API::NewFrame(); Graphics::API::StartGuiRender(); - Graphics::API::RenderGuiElement( this->privData->background, Float2(0.5f), Float2(1.0f) ); + Graphics::API::RenderGuiElement( this->privData->background, Float3(0.5f, 0.5f, 1.0f), Float2(1.0f) ); this->privData->guiElements.RenderTexture(); Graphics::API::StartTextRender(); @@ -103,7 +102,7 @@ void LobbyState::ChangeState( ClientState next ) { if( next == GameClientState::ClientState_LobbyReady ) { // Send ready signal to server lobby - + this->ChangeState( GameClientState::ClientState_NetLoad ); } else this->privData->nextState = next; @@ -121,14 +120,14 @@ void LobbyState::DataRecieved( NetEvent - -using namespace DanBias::Client; - -//Menu buttons -#include "Buttons/ButtonEllipse.h" -#include "Buttons/ButtonRectangle.h" -#include "../Misc/EventHandler/EventHandler.h" -using namespace Oyster::Event; - -struct LoginState::myData -{ - myData(){} - Oyster::Math3D::Float4x4 view; - Oyster::Math3D::Float4x4 proj; - C_Object* object[2]; - int modelCount; - // UI object - // game client* - - //Menu button collection - EventButtonCollection collection; - bool createGame; - int testNumber; -}privData; - - -enum TestEnum -{ - Create, - Options, - Incr, - Decr, - Exit, -}; - -LoginState::LoginState(void) -{ -} - -void LoginState::ButtonCallback(Oyster::Event::ButtonEvent& e) -{ - TestEnum type = TestEnum((int)e.userData); - - switch(type) - { - case Create: - if(e.state == ButtonState_None) - { - int a = 0; - std::cout << "None" << std::endl; - } - else if(e.state == ButtonState_Hover) - { - int a = 0; - std::cout << "Hover" << std::endl; - } - else if(e.state == ButtonState_Down) - { - int a = 0; - std::cout << "Down" << std::endl; - } - else if(e.state == ButtonState_Pressed) - { - int a = 0; - std::cout << "Pressed" << std::endl; - } - else if(e.state == ButtonState_Released) - { - //Change to create state or something similar - int a = 0; - std::cout << "Released" << std::endl; - e.owner->privData->createGame = true; - } - break; - case Options: - break; - case Exit: - break; - - case Incr: - if(e.state == ButtonState_Released) - e.owner->privData->testNumber++; - break; - case Decr: - if(e.state == ButtonState_Released) - e.owner->privData->testNumber--; - break; - } -} - -LoginState::~LoginState(void) -{ - -} - -bool LoginState::Init(Oyster::Network::NetworkClient* nwClient) -{ - privData = new myData(); - this->nwClient = nwClient; - // load models - //LoadModels(L"UImodels.txt"); - InitCamera(Oyster::Math::Float3(0,0,5.4f)); - - //Create menu buttons - EventHandler::Instance().AddCollection(&privData->collection); - privData->collection.AddButton(new ButtonEllipse(L"circle.png", L"Hej", Oyster::Math::Float3(1, 1, 0), &LoginState::ButtonCallback, this, - (void*)Options, Oyster::Math::Float3(0.2f, 0.2f, 0.0f), Oyster::Math::Float2(0.1f, 0.1f), ResizeAspectRatio_Width)); - privData->collection.AddButton(new ButtonEllipse(L"circle.png", L"Hej", Oyster::Math::Float3(1, 0, 0), &LoginState::ButtonCallback, this, - (void*)Options, Oyster::Math::Float3(0.2f, 0.3f, 0.0f), Oyster::Math::Float2(0.1f, 0.1f), ResizeAspectRatio_Width)); - privData->collection.AddButton(new ButtonEllipse(L"circle.png", L"Hej", Oyster::Math::Float3(1, 0, 0), &LoginState::ButtonCallback, this, - (void*)Options, Oyster::Math::Float3(0.2f, 0.4f, 0.0f), Oyster::Math::Float2(0.1f, 0.1f), ResizeAspectRatio_Width)); - privData->collection.AddButton(new ButtonEllipse(L"circle.png", L"Hej", Oyster::Math::Float3(1, 0, 0), &LoginState::ButtonCallback, this, - (void*)Options, Oyster::Math::Float3(0.2f, 0.5f, 0.0f), Oyster::Math::Float2(0.1f, 0.1f), ResizeAspectRatio_Width)); - - privData->collection.AddButton(new ButtonRectangle(L"button.png", L"", Oyster::Math::Float3(1, 0, 0), &LoginState::ButtonCallback, this, - (void*)Options, Oyster::Math::Float3(0.15f, 0.05f, 0.0f), Oyster::Math::Float2(0.1f, 0.1f))); - privData->collection.AddButton(new ButtonRectangle(L"button.png", L"Hej", Oyster::Math::Float3(1, 0, 0), &LoginState::ButtonCallback, this, - (void*)Options, Oyster::Math::Float3(0.25f, 0.05f, 0.0f), Oyster::Math::Float2(0.1f, 0.1f))); - privData->collection.AddButton(new ButtonRectangle(L"button.png", L"Hej", Oyster::Math::Float3(1, 0, 0), &LoginState::ButtonCallback, this, - (void*)Options, Oyster::Math::Float3(0.35f, 0.05f, 0.0f), Oyster::Math::Float2(0.1f, 0.1f))); - privData->collection.AddButton(new ButtonRectangle(L"button.png", L"Hej", Oyster::Math::Float3(1, 0, 0), &LoginState::ButtonCallback, this, - (void*)Options, Oyster::Math::Float3(0.45f, 0.05f, 0.0f), Oyster::Math::Float2(0.1f, 0.1f))); - - privData->collection.AddButton(new ButtonRectangle(L"button.png", L"Create Game", Oyster::Math::Float3(1, 0, 0), &LoginState::ButtonCallback, this, - (void*)Create, Oyster::Math::Float3(0.5f, 0.5f, 0.0f), Oyster::Math::Float2(0.3f, 0.3f))); - - //Incr/decr buttons . - privData->collection.AddButton(new ButtonRectangle(L"button.png", L"Hej", Oyster::Math::Float3(1, 0, 0), &LoginState::ButtonCallback, this, - (void*)Incr, Oyster::Math::Float3(0.85f, 0.2f, 0.0f), Oyster::Math::Float2(0.1f, 0.1f))); - privData->collection.AddButton(new ButtonRectangle(L"button.png", L"Hej", Oyster::Math::Float3(1, 0, 0), &LoginState::ButtonCallback, this, - (void*)Decr, Oyster::Math::Float3(0.55f, 0.2f, 0.0f), Oyster::Math::Float2(0.1f, 0.1f))); - - privData->createGame = false; - privData->testNumber = 0; - - return true; -} -bool LoginState::LoadModels(std::wstring file) -{ - Oyster::Graphics::Definitions::Pointlight plight; - plight.Pos = Oyster::Math::Float3(0,0,5); - plight.Color = Oyster::Math::Float3(1,0,1); - plight.Radius = 100; - plight.Bright = 1; - Oyster::Graphics::API::AddLight(plight); - // open file - // read file - // init models - privData->modelCount = 2; - - ModelInitData modelData; - - modelData.rotation = Oyster::Math::Quaternion::identity; - modelData.scale = Oyster::Math::Float3(1,1,1); - modelData.visible = true; - modelData.modelPath = L"box.dan"; - - - modelData.position = Oyster::Math::Float3(2,2,2); - privData->object[0] = new C_StaticObj(); - privData->object[0]->Init(modelData); - - modelData.position = Oyster::Math::Float3(-2,0,-2); - privData->object[1] = new C_StaticObj(); - privData->object[1]->Init(modelData); - return true; -} - -bool LoginState::InitCamera(Oyster::Math::Float3 startPos) -{ - 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); - Oyster::Graphics::API::SetProjection(privData->proj); - - privData->view = Oyster::Math3D::OrientationMatrix_LookAtDirection(Oyster::Math::Float3(0,0,-1),Oyster::Math::Float3(0,1,0),startPos); - privData->view = Oyster::Math3D::InverseOrientationMatrix(privData->view); - return true; -} -GameClientState::ClientState LoginState::Update(float deltaTime, InputClass* KeyInput) -{ - // picking - // mouse events - // different menus - // play sounds - // update animation - // send data to server - // check data from server - - // create game - if( KeyInput->IsKeyPressed(DIK_C) || privData->createGame) - { - DanBias::GameServerAPI::ServerInitDesc desc; - - DanBias::GameServerAPI::ServerInitiate(desc); - DanBias::GameServerAPI::ServerStart(); - // my ip - nwClient->Connect(15152, "127.0.0.1"); - - if (!nwClient->IsConnected()) - { - // failed to connect - return ClientState_Same; - } - privData->collection.SetState(EventCollectionState_Disabled); - return ClientState_LobbyCreated; - } - // join game - if( KeyInput->IsKeyPressed(DIK_J)) - { - // game ip - nwClient->Connect(15152, "127.0.0.1"); - //nwClient->Connect(15152, "83.254.217.248"); - - if (!nwClient->IsConnected()) - { - // failed to connect - return ClientState_Same; - } - privData->collection.SetState(EventCollectionState_Disabled); - return ClientState_Lobby; - } - return ClientState_Same; -} -bool LoginState::Render(float dt) -{ - Oyster::Graphics::API::SetView(privData->view); - Oyster::Graphics::API::SetProjection( privData->proj); - - Oyster::Graphics::API::NewFrame(); - // render objects - for (int i = 0; i < privData->modelCount; i++) - { - privData->object[i]->Render(); - } - - // render effects - - // render lights - - //Render buttons - Oyster::Graphics::API::StartGuiRender(); - EventHandler::Instance().RenderTexture(); - - std::wstring number; - wchar_t temp[10]; - _itow_s(privData->testNumber, temp, 10); - number = temp; - - Oyster::Graphics::API::StartTextRender(); - EventHandler::Instance().RenderText(); - //Oyster::Graphics::API::RenderText(number, Oyster::Math::Float2(0.7f, 0.2f), Oyster::Math::Float2(0.1f, 0.1f*(1008.0f/730.0f)), Oyster::Math::Float3(1.0f, 0.0f, 0.0f)); - - Oyster::Graphics::API::EndFrame(); - return true; -} -bool LoginState::Release() -{ - Oyster::Graphics::API::ClearLights(); - for (int i = 0; i < privData->modelCount; i++) - { - privData->object[i]->Release(); - delete privData->object[i]; - privData->object[i] = NULL; - } - - EventHandler::Instance().ReleaseCollection(&privData->collection); - - delete privData; - privData = NULL; - return true; -} -void LoginState::Protocol(ProtocolStruct* protocol) -{ - if((PlayerName*)protocol) - PlayerJoinProtocol((PlayerName*)protocol); - -} -void LoginState::PlayerJoinProtocol(PlayerName* name) -{ - -} \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/NetLoadState.cpp b/Code/Game/DanBiasGame/GameClientState/NetLoadState.cpp new file mode 100644 index 00000000..c8fd1e64 --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/NetLoadState.cpp @@ -0,0 +1,84 @@ +#include "NetLoadState.h" +#include "NetworkClient.h" +#include "../Game/GameProtocols/Protocols.h" + +using namespace ::DanBias::Client; +using namespace ::Oyster; +using namespace ::Oyster::Network; +using namespace ::GameLogic; + +struct NetLoadState::MyData +{ + MyData() {} + + GameClientState::ClientState nextState; + NetworkClient *nwClient; + bool loading; +}; + +NetLoadState::NetLoadState(void) {} + +NetLoadState::~NetLoadState(void) +{ + if( this->privData ) + this->Release(); +} + +bool NetLoadState::Init( NetworkClient* nwClient ) +{ + this->privData = new MyData(); + + this->privData->nextState = GameClientState::ClientState_Same; + this->privData->nwClient = nwClient; + this->privData->loading = false; + + // we may assume that nwClient is properly connected to the server + // signals querry to server for loading instructions + nwClient->Send( Protocol_QuerryGameType() ); + + return true; +} + +GameClientState::ClientState NetLoadState::Update(float deltaTime, InputClass* KeyInput) +{ + return this->privData->nextState; +} + +bool NetLoadState::Render() +{ + return true; +} + +bool NetLoadState::Release() +{ + if( this->privData ) + { + this->privData = NULL; + } + return true; +} + +void NetLoadState::ChangeState( ClientState next ) +{ + this->privData->nextState = next; +} + +void NetLoadState::DataRecieved( NetEvent e ) +{ + // fetching the id data. + short ID = e.args.data.protocol[0].value.netShort; + + if( ID == protocol_Lobby_CreateGame && !this->privData->loading ) + { + this->LoadGame( Protocol_LobbyCreateGame(e.args.data.protocol).modelName ); + } +} + +void NetLoadState::LoadGame( const ::std::string &fileName ) +{ + this->privData->loading = true; + + // TODO: ask Sam about level loader + + this->privData->nextState = ClientState::ClientState_Game; +} diff --git a/Code/Game/DanBiasGame/GameClientState/NetLoadState.h b/Code/Game/DanBiasGame/GameClientState/NetLoadState.h new file mode 100644 index 00000000..ff2d1acc --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/NetLoadState.h @@ -0,0 +1,34 @@ +#ifndef DANBIAS_CLIENT_NETLOADSTATE_H +#define DANBIAS_CLIENT_NETLOADSTATE_H + +#include "GameClientState.h" +#include "NetworkClient.h" + +namespace DanBias +{ + namespace Client + { + class NetLoadState : public GameClientState + { + public: + NetLoadState( ); + virtual ~NetLoadState( ); + + bool Init( Oyster::Network::NetworkClient* nwClient ); + ClientState Update( float deltaTime, InputClass* KeyInput ); + + bool Render(); + bool Release(); + void ChangeState( ClientState next ); + + void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e ); + + private: + struct MyData; + ::Utility::DynamicMemory::UniquePointer privData; + + void LoadGame( const ::std::string &fileName ); + }; + } +} +#endif // ! DANBIAS_CLIENT_LOGINSTATE_H \ No newline at end of file diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index 80562b2c..0b817975 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -95,9 +95,16 @@ using namespace GameLogic; { int forceThreashHold = 200000; //how much force for the box to explode of the impact + Object *realObj = (Object*)obj->GetCustomTag(); //needs to be changed? - if(kineticEnergyLoss > forceThreashHold) + switch (realObj->GetObjectType()) { + case ObjectSpecialType::ObjectSpecialType_Generic: + break; + case ObjectSpecialType::ObjectSpecialType_StandardBox: + + break; + case ObjectSpecialType::ObjectSpecialType_Player: ExplosiveCrate* crate = ((ExplosiveCrate*)rigidBodyCrate->GetCustomTag()); @@ -107,7 +114,20 @@ using namespace GameLogic; Oyster::Physics::API::Instance().ApplyEffect(hitSphere,crate,Explode); delete hitSphere; + break; } + /*if(kineticEnergyLoss > forceThreashHold) + { + ExplosiveCrate* crate = ((ExplosiveCrate*)rigidBodyCrate->GetCustomTag()); + + + Oyster::Math::Float3 pos = rigidBodyCrate->GetState().centerPos; + Oyster::Collision3D::Sphere *hitSphere = new Oyster::Collision3D::Sphere(pos,crate->ExplosionRadius); + + Oyster::Physics::API::Instance().ApplyEffect(hitSphere,crate,Explode); + + delete hitSphere; + }*/ } void ExplosiveCrate::Explode(Oyster::Physics::ICustomBody *obj, void* args) @@ -123,7 +143,7 @@ using namespace GameLogic; { Player *hitPlayer = (Player*)realObj; - hitPlayer->DamageLife(ExplosionSource->getExtraDamageOnCollision()); + //hitPlayer->DamageLife(ExplosionSource->getExtraDamageOnCollision()); //do shredding damage } diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index 275866b9..1b725b02 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -17,12 +17,12 @@ Game::PlayerData::PlayerData() //sbDesc.quaternion = Oyster::Math::Float3(0, Oyster::Math::pi, 0); //create rigid body - Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCharacter(2.0f, 0.5f, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass, 0.5f, 0.8f, 0.6f ); + Oyster::Physics::ICustomBody* rigidBody = Oyster::Physics::API::Instance().AddCollisionBox(size, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass, 0.5f, 0.8f, 0.6f ); rigidBody->SetAngularFactor(0.0f); //create player with this rigid body this->player = new Player(rigidBody, Player::PlayerCollision, ObjectSpecialType_Player,0,0); - this->player->GetRigidBody()->SetCustomTag(this); + //this->player->GetRigidBody()->SetCustomTag(this); player->EndFrame(); } Game::PlayerData::PlayerData(int playerID,int teamID) diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 9ba44ede..6b9081d7 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -33,7 +33,7 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody) case ObjectSpecialType_Sky: { float skySize = ((SkyAttributes*)obj)->skySize; - gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++); + //gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++); } break; case ObjectSpecialType_World: @@ -96,7 +96,7 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody) break; case ObjectSpecialType_JumpPad: { - float power = ((JumpPadAttributes*)obj)->power; + float power = 500; //((JumpPadAttributes*)obj)->power; Oyster::Math::Float3 dir = ((JumpPadAttributes*)obj)->direction; Oyster::Math::Float3 pushForce = dir * power; gameObj = new JumpPad(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++ , pushForce); @@ -108,16 +108,15 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody) gameObj = new Portal(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++, destination); } break; - case ObjectSpecialType_SpawnPoint: - { + //case ObjectSpecialType_SpawnPoint: + //{ // save - gameObj = new StaticObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++); - } + + //} break; case ObjectSpecialType_Player: { // should not be read from the lvl format - //gameObj = new Player(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID,objID++); } break; case ObjectSpecialType_Generic: @@ -206,12 +205,10 @@ void Level::InitiateLevel(std::string levelPath) API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0)); API::Instance().SetGravity(200); int objCount = objects.size(); - int modelCount = 100; for (int i = 0; i < objCount; i++) { ObjectTypeHeader* obj = objects.at(i); - int id = obj->typeID; switch (obj->typeID) { case ObjectType::ObjectType_LevelMetaData: @@ -223,7 +220,6 @@ void Level::InitiateLevel(std::string levelPath) break; case ObjectType::ObjectType_Static: { - ObjectHeader* staticObjData = ((ObjectHeader*)obj); staticObjData->ModelFile; @@ -237,7 +233,6 @@ void Level::InitiateLevel(std::string levelPath) else if(staticObjData->boundingVolume.geoType == CollisionGeometryType_Box) { - rigidBody_Static = InitRigidBodyCube(staticObjData); } @@ -248,22 +243,13 @@ void Level::InitiateLevel(std::string levelPath) if(rigidBody_Static != NULL) { - // create game object Object* staticGameObj = createGameObj(staticObjData, rigidBody_Static); - //Object* staticGameObj = new StaticObject(rigidBody_Static, Object::DefaultCollisionAfter, (ObjectSpecialType)staticObjData->specialTypeID); if(staticGameObj != NULL) { this->staticObjects.Push((StaticObject*)staticGameObj); - //this->staticObjects[this->staticObjects.Size()-1]->objectID = modelCount++; - //rigidBody_Static->SetCustomTag(this->staticObjects[this->staticObjects.Size()-1]); } - - //this->staticObjects.Push(new StaticObject(rigidBody_Static, Object::DefaultCollisionAfter, (ObjectSpecialType)staticObjData->specialTypeID, 0)); - //this->staticObjects[staticObjCount]->objectID = modelCount++; - } - } break; case ObjectType::ObjectType_Dynamic: @@ -293,12 +279,9 @@ void Level::InitiateLevel(std::string levelPath) { // create game object Object* dynamicGameObj = createGameObj(dynamicObjData, rigidBody_Dynamic); - //Object* dynamicGameObj =new DynamicObject(rigidBody_Dynamic, Object::DefaultCollisionAfter, (ObjectSpecialType)dynamicObjData->specialTypeID); if (dynamicGameObj != NULL) { this->dynamicObjects.Push((DynamicObject*)dynamicGameObj); - //this->dynamicObjects[this->dynamicObjects.Size()-1]->objectID = modelCount++; - //rigidBody_Dynamic->SetCustomTag(this->dynamicObjects[this->dynamicObjects.Size()-1]); } } } @@ -334,9 +317,6 @@ void Level::InitiateLevel(float radius) 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, 605 + i*5, 10), 5, 0.5f, 0.8f, 0.6f); this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox, Object::DefaultCollisionAfter, ObjectSpecialType_StandardBox, idCount++)); - - //this->dynamicObjects[i]->objectID = idCount++; - rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i]); } /*offset += nrOfBoxex; for(int i =0; i< nrOfBoxex; i ++) @@ -365,31 +345,18 @@ void Level::InitiateLevel(float radius) }*/ - - - - // 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, 0.5f, 0.8f, 0.6f); - this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal, Object::DefaultCollisionAfter, ObjectSpecialType_StandardBox, idCount++)); - rigidBody_Crystal->SetCustomTag(this->dynamicObjects[nrOfBoxex]); - //this->dynamicObjects[nrOfBoxex]->objectID = idCount++; - - // add house ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(20, 20, 20), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(-50, 590, 0), 0, 0.5f, 0.8f, 0.6f); this->staticObjects.Push(new StaticObject(rigidBody_House, Object::DefaultCollisionAfter, ObjectSpecialType_Generic, idCount++)); - rigidBody_House->SetCustomTag(this->staticObjects[0]); - //this->staticObjects[0]->objectID = idCount++; // add jumppad - ICustomBody* rigidBody_Jumppad = API::Instance().AddCollisionBox(Oyster::Math::Float3(1, 1, 1), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(4, 600.3, 0), 0, 0.5f, 0.8f, 0.6f); + ICustomBody* rigidBody_Jumppad = API::Instance().AddCollisionBox(Oyster::Math::Float3(1, 1, 1), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(4, 600.3, 0), 5, 0.5f, 0.8f, 0.6f); this->staticObjects.Push(new JumpPad(rigidBody_Jumppad, ObjectSpecialType_JumpPad,idCount++ ,Oyster::Math::Float3(0,2000,0))); - rigidBody_Jumppad->SetCustomTag(this->staticObjects[1]); - //this->staticObjects[1]->objectID = idCount++; } void Level::AddPlayerToTeam(Player *player, int teamID) diff --git a/Code/Game/GameLogic/Level.h b/Code/Game/GameLogic/Level.h index 0b6c2a31..623d04b2 100644 --- a/Code/Game/GameLogic/Level.h +++ b/Code/Game/GameLogic/Level.h @@ -77,6 +77,7 @@ namespace GameLogic Utility::DynamicMemory::SmartPointer rigidBodyLevel; StaticObject *levelObj; int objID; + Utility::DynamicMemory::DynamicArray spawnPoints; }; diff --git a/Code/Game/GameLogic/LevelLoader/LevelParser.cpp b/Code/Game/GameLogic/LevelLoader/LevelParser.cpp index 038b9a40..1e33361d 100644 --- a/Code/Game/GameLogic/LevelLoader/LevelParser.cpp +++ b/Code/Game/GameLogic/LevelLoader/LevelParser.cpp @@ -3,7 +3,6 @@ ///////////////////////////////////// #include "LevelParser.h" - #include "Loader.h" #include "ParseFunctions.h" @@ -59,6 +58,27 @@ std::vector> LevelParser::Parse(std::string filen break; } + case ObjectType_SpawnPoint: + { + loadCgf = false; + ObjectHeader* header = new ObjectHeader; + ParseObject(&buffer[counter], *header, counter, loadCgf); + + SpawnPointAttributes* spawn = new SpawnPointAttributes; + + spawn->typeID = header->typeID; + + for(int i = 0; i < 3; i++) + { + spawn->position[i] = header->position[i]; + } + + delete header; + //objects.push_back(header); + objects.push_back(spawn); + break; + } + //This is by design, static and dynamic is using the same converter. Do not add anything inbetween them. //Unless they are changed to not be the same. case ObjectType_Static: case ObjectType_Dynamic: @@ -134,13 +154,6 @@ std::vector> LevelParser::Parse(std::string filen break; } - case ObjectSpecialType_SpawnPoint: - { - loadCgf = false; - ObjectHeader* header = new ObjectHeader; - ParseObject(&buffer[counter], *header, counter, loadCgf); - } - default: //Couldn't find specialType break; diff --git a/Code/Game/GameLogic/LevelLoader/ObjectDefines.h b/Code/Game/GameLogic/LevelLoader/ObjectDefines.h index 50c722b6..01d17c3e 100644 --- a/Code/Game/GameLogic/LevelLoader/ObjectDefines.h +++ b/Code/Game/GameLogic/LevelLoader/ObjectDefines.h @@ -16,6 +16,7 @@ namespace GameLogic ObjectType_Static, ObjectType_Dynamic, ObjectType_Light, + ObjectType_SpawnPoint, //Etc ObjectType_NUM_OF_TYPES, @@ -38,7 +39,6 @@ namespace GameLogic ObjectSpecialType_CrystalShard, ObjectSpecialType_JumpPad, ObjectSpecialType_Portal, - ObjectSpecialType_SpawnPoint, ObjectSpecialType_Player, ObjectSpecialType_Generic, @@ -207,6 +207,11 @@ namespace GameLogic virtual ~ObjectHeader(){} }; + struct SpawnPointAttributes : public ObjectTypeHeader + { + ObjectSpecialType specialTypeID; + float position[3]; + }; /************************************ Special objects *************************************/ diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 508857b9..625a0663 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -20,16 +20,16 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, void (*EventOnCollision) weapon = new Weapon(2,this); this->life = 100; - this->teamID = -1; + this->teamID = teamID; this->playerState = PLAYER_STATE_IDLE; this->lookDir = Oyster::Math::Float3(0,0,-1); - this->moveDir = Oyster::Math::Float3(0,0,0); key_forward = 0; key_backward = 0; key_strafeRight = 0; key_strafeLeft = 0; this->previousPosition = Oyster::Math::Float3(0,0,0); + this->moveDir = Oyster::Math::Float3(0,0,0); this->moveSpeed = 100; this->previousMoveSpeed = Oyster::Math::Float3(0,0,0); @@ -38,20 +38,6 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, void (*EventOnCollision) Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, int teamID) :DynamicObject(rigidBody, EventOnCollision, type, objectID) { - this->rigidBody = rigidBody; - - Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(0,400,0); - - Oyster::Math::Float3 size = Oyster::Math::Float3(0.25f,1.0f,0.5f); - Oyster::Math::Float mass = 60; - Oyster::Math::Float restitutionCoeff = 0.5; - Oyster::Math::Float frictionCoeff_Static = 0.4; - Oyster::Math::Float frictionCoeff_Dynamic = 0.3; - - - this->rigidBody = Oyster::Physics::API::Instance().AddCollisionBox(size, Oyster::Math::Float4(0, 0, 0, 1), centerPosition, mass, 0.5f, 0.8f, 0.6f ); - this->rigidBody->SetAngularFactor(0.0f); - weapon = new Weapon(2,this); this->life = 100; @@ -67,7 +53,6 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustom this->moveDir = Oyster::Math::Float3(0,0,0); this->moveSpeed = 100; this->previousMoveSpeed = Oyster::Math::Float3(0,0,0); - } Player::~Player(void) diff --git a/Code/Game/GameLogic/StaticObject.cpp b/Code/Game/GameLogic/StaticObject.cpp index 158ee87e..7124b14a 100644 --- a/Code/Game/GameLogic/StaticObject.cpp +++ b/Code/Game/GameLogic/StaticObject.cpp @@ -14,25 +14,25 @@ StaticObject::StaticObject() StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID) :Object(rigidBody, EventOnCollision, type, objectID) { - //use setMass(when it is made) and set the mass to 0 in order to ensure that the object is static + rigidBody->SetMass(0); } StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID) :Object(rigidBody, EventOnCollision, type, objectID) { - //use setMass(when it is made) and set the mass to 0 in order to ensure that the object is static + rigidBody->SetMass(0); } StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , void (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, Oyster::Math::Float extraDamageOnCollision) { this->extraDamageOnCollision = extraDamageOnCollision; - //use setMass(when it is made) and set the mass to 0 in order to ensure that the object is static + rigidBody->SetMass(0); } StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*EventOnCollision)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), ObjectSpecialType type, int objectID, Oyster::Math::Float extraDamageOnCollision) { this->extraDamageOnCollision = extraDamageOnCollision; - //use setMass(when it is made) and set the mass to 0 in order to ensure that the object is static + rigidBody->SetMass(0); } StaticObject::~StaticObject(void) { diff --git a/Code/Game/GameProtocols/LobbyProtocols.h b/Code/Game/GameProtocols/LobbyProtocols.h index c821137b..71202898 100644 --- a/Code/Game/GameProtocols/LobbyProtocols.h +++ b/Code/Game/GameProtocols/LobbyProtocols.h @@ -21,6 +21,24 @@ namespace GameLogic { + struct Protocol_QuerryGameType :public Oyster::Network::CustomProtocolObject + { + public: + Protocol_QuerryGameType() + { + this->protocol[0].type = ::Oyster::Network::NetAttributeType_Short; + this->protocol[0].value = protocol_Lobby_QuerryGameType; + } + + ::Oyster::Network::CustomNetProtocol GetProtocol() override + { + return this->protocol; + } + + private: + Oyster::Network::CustomNetProtocol protocol; + }; + struct Protocol_LobbyCreateGame :public Oyster::Network::CustomProtocolObject { short clientID; // The unuiqe id reprsenting a specific client @@ -30,7 +48,7 @@ namespace GameLogic Protocol_LobbyCreateGame() { int c = 0; - this->protocol[c].value = protocol_Lobby_Create; + this->protocol[c].value = protocol_Lobby_CreateGame; this->protocol[c++].type = Oyster::Network::NetAttributeType_Short; this->protocol[c++].type = Oyster::Network::NetAttributeType_Short; @@ -43,7 +61,7 @@ namespace GameLogic Protocol_LobbyCreateGame(short _clientID, std::string name, float world[16]) { int c = 0; - this->protocol[c].value = protocol_Lobby_Create; + this->protocol[c].value = protocol_Lobby_CreateGame; this->protocol[c++].type = Oyster::Network::NetAttributeType_Short; this->protocol[c++].type = Oyster::Network::NetAttributeType_Short; @@ -92,14 +110,14 @@ namespace GameLogic Protocol_LobbyStartGame() { - this->protocol[0].value = protocol_Lobby_Start; + this->protocol[0].value = protocol_Lobby_StartGame; this->protocol[0].type = Oyster::Network::NetAttributeType_Short; this->protocol[1].type = Oyster::Network::NetAttributeType_Float; seconds = 0; } Protocol_LobbyStartGame(float _seconds) { - this->protocol[0].value = protocol_Lobby_Start; + this->protocol[0].value = protocol_Lobby_StartGame; this->protocol[0].type = Oyster::Network::NetAttributeType_Short; this->protocol[1].type = Oyster::Network::NetAttributeType_Float; seconds = _seconds; @@ -119,17 +137,17 @@ namespace GameLogic }; - struct Protocol_LobbyLogin :public Oyster::Network::CustomProtocolObject + struct Protocol_LobbyJoinGame :public Oyster::Network::CustomProtocolObject { // Login stuff - Protocol_LobbyLogin() + Protocol_LobbyJoinGame() { - this->protocol[0].value = protocol_Lobby_Join; + this->protocol[0].value = protocol_Lobby_JoinGame; this->protocol[0].type = Oyster::Network::NetAttributeType_Short; this->protocol[1].type = Oyster::Network::NetAttributeType_Short; } - Protocol_LobbyLogin(Oyster::Network::CustomNetProtocol& p) + Protocol_LobbyJoinGame(Oyster::Network::CustomNetProtocol& p) { } diff --git a/Code/Game/GameProtocols/ProtocolIdentificationID.h b/Code/Game/GameProtocols/ProtocolIdentificationID.h index 8d311b93..25df7b78 100644 --- a/Code/Game/GameProtocols/ProtocolIdentificationID.h +++ b/Code/Game/GameProtocols/ProtocolIdentificationID.h @@ -27,14 +27,15 @@ /********* LOBBY PROTOCOLS ***************************************************************************************************/ /***********[ 200 - 299 ]***********/ #define protocol_LobbyMIN 200 -#define protocol_Lobby_Create 200 -#define protocol_Lobby_Start 201 -#define protocol_Lobby_Join 202 +#define protocol_Lobby_CreateGame 200 +#define protocol_Lobby_StartGame 201 +#define protocol_Lobby_JoinGame 202 #define protocol_Lobby_Login 203 #define protocol_Lobby_Refresh 204 #define protocol_Lobby_ClientData 205 #define protocol_Lobby_GameData 206 -#define protocol_Lobby_ClientReadyState 207 +#define protocol_Lobby_QuerryGameType 207 +#define protocol_Lobby_ClientReadyState 208 #define protocol_LobbyMAX 299 diff --git a/Code/Game/GameServer/GameLobby.h b/Code/Game/GameServer/GameLobby.h index 5a996e63..86cd498a 100644 --- a/Code/Game/GameServer/GameLobby.h +++ b/Code/Game/GameServer/GameLobby.h @@ -41,7 +41,7 @@ namespace DanBias //void LobbyCreateGame(GameLogic::Protocol_LobbyCreateGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Create: void LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Start: //void LobbyJoin(GameLogic::Protocol_LobbyJoin& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Join: - void LobbyLogin(GameLogic::Protocol_LobbyLogin& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Login: + void LobbyLogin(GameLogic::Protocol_LobbyJoinGame& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Login: void LobbyRefresh(GameLogic::Protocol_LobbyRefresh& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_Refresh: void LobbyGameData(GameLogic::Protocol_LobbyGameData& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_GameData: void LobbyMainData(GameLogic::Protocol_LobbyClientData& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_MainData: diff --git a/Code/Game/GameServer/Implementation/GameLobby_ProtocolParser.cpp b/Code/Game/GameServer/Implementation/GameLobby_ProtocolParser.cpp index 35f6f4ee..eba91b28 100644 --- a/Code/Game/GameServer/Implementation/GameLobby_ProtocolParser.cpp +++ b/Code/Game/GameServer/Implementation/GameLobby_ProtocolParser.cpp @@ -15,11 +15,11 @@ void GameLobby::ParseProtocol(Oyster::Network::CustomNetProtocol& p, NetworkClie break; //case protocol_Lobby_Create: this->LobbyCreateGame (Protocol_LobbyCreateGame (p), c); //break; - case protocol_Lobby_Start: this->LobbyStartGame (Protocol_LobbyStartGame (p), c); + case protocol_Lobby_StartGame: this->LobbyStartGame (Protocol_LobbyStartGame (p), c); break; //case protocol_Lobby_Join: this->LobbyJoin (Protocol_LobbyJoin (p), c); //break; - case protocol_Lobby_Login: this->LobbyLogin (Protocol_LobbyLogin (p), c); + case protocol_Lobby_Login: this->LobbyLogin (Protocol_LobbyJoinGame (p), c); break; case protocol_Lobby_Refresh: this->LobbyRefresh (Protocol_LobbyRefresh (p), c); break; @@ -82,7 +82,7 @@ void GameLobby::LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Ne // // } // //} //} -void GameLobby::LobbyLogin(GameLogic::Protocol_LobbyLogin& p, Oyster::Network::NetworkClient* c) +void GameLobby::LobbyLogin(GameLogic::Protocol_LobbyJoinGame& p, Oyster::Network::NetworkClient* c) { } diff --git a/Code/Game/aDanBiasGameLauncher/Launcher.cpp b/Code/Game/aDanBiasGameLauncher/Launcher.cpp index f05f021d..74af84d5 100644 --- a/Code/Game/aDanBiasGameLauncher/Launcher.cpp +++ b/Code/Game/aDanBiasGameLauncher/Launcher.cpp @@ -38,7 +38,7 @@ void ClientFnc() gameDesc.IP = "127.0.0.1"; //gameDesc.IP = "194.47.150.184"; - if( DanBias::DanBiasGame::Initiate(gameDesc) == DanBias::DanBiasClientReturn_Sucess) + if( DanBias::DanBiasGame::Initiate(gameDesc) == DanBias::DanBiasClientReturn_Success) { DanBias::DanBiasGame::Run(); DanBias::DanBiasGame::Release(); diff --git a/Code/Misc/Resource/ResourceManager.cpp b/Code/Misc/Resource/ResourceManager.cpp index 6f4b0360..04c03a6f 100644 --- a/Code/Misc/Resource/ResourceManager.cpp +++ b/Code/Misc/Resource/ResourceManager.cpp @@ -71,7 +71,7 @@ const wchar_t* FindResourceKey(std::map& resources, { for (auto i = resources.begin(); i != resources.end() ; i++) { - if(i->second->resource == h) + if(i->second && i->second->resource == h) { return i->first.c_str(); } diff --git a/Code/OysterGraphics/Core/PipelineManager.cpp b/Code/OysterGraphics/Core/PipelineManager.cpp index d60c1641..9004ec3d 100644 --- a/Code/OysterGraphics/Core/PipelineManager.cpp +++ b/Code/OysterGraphics/Core/PipelineManager.cpp @@ -362,6 +362,7 @@ namespace Oyster } Core::deviceContext->RSSetState(se.RenderStates.Rasterizer); Core::deviceContext->PSSetSamplers(0,se.RenderStates.SampleCount,se.RenderStates.SampleState); + Core::deviceContext->CSSetSamplers(0,se.RenderStates.SampleCount,se.RenderStates.SampleState); Core::deviceContext->OMSetDepthStencilState(se.RenderStates.DepthStencil,0); float test[4] = {0}; Core::deviceContext->OMSetBlendState(se.RenderStates.BlendState,test,-1); diff --git a/Code/OysterGraphics/Definitions/GraphicalDefinition.h b/Code/OysterGraphics/Definitions/GraphicalDefinition.h index 958904a8..ffd2869a 100644 --- a/Code/OysterGraphics/Definitions/GraphicalDefinition.h +++ b/Code/OysterGraphics/Definitions/GraphicalDefinition.h @@ -27,8 +27,6 @@ namespace Oyster Oyster::Math::Float3 pos; Oyster::Math::Float2 uv; Oyster::Math::Float3 normal; - Oyster::Math::Float3 tangent; - Oyster::Math::Float3 biTangent; Oyster::Math::Float4 boneIndex; Oyster::Math::Float4 boneWeights; }; diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp index 381b12cf..537ed63d 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp @@ -94,6 +94,8 @@ namespace Oyster if(!mi || mi->Vertices->GetBufferPointer() == NULL) { delete m; + Core::loader.ReleaseResource(mi); + delete mi; return NULL; } @@ -176,6 +178,8 @@ namespace Oyster float API::PlayAnimation(Model::Model* m, std::wstring name,bool looping) { + if(m==NULL) + return 0; m->Animation.AnimationPlaying = &(*m->info->Animations.find(name)).second; m->Animation.AnimationTime=0; m->Animation.LoopAnimation = looping; diff --git a/Code/OysterGraphics/FileLoader/DanLoader.cpp b/Code/OysterGraphics/FileLoader/DanLoader.cpp index 99302266..b6d8ed28 100644 --- a/Code/OysterGraphics/FileLoader/DanLoader.cpp +++ b/Code/OysterGraphics/FileLoader/DanLoader.cpp @@ -5,12 +5,11 @@ #include #include -#define DANFILEVERSIONMAJOR 1 +#define DANFILEVERSIONMAJOR 2 #define DANFILEVERSIONMINOR 1 #define FILEHEADERSIZE 8 #define VERTEXHEADERSIZE 4 -#define VERTEXSIZE 88 @@ -176,7 +175,6 @@ static void ReadData(void* Destination, std::ifstream& file, int size) /// void* Oyster::Graphics::Loading::LoadDAN(const wchar_t filename[]) { - // Oyster::Graphics::Model::ModelInfo* modelInfo = new Oyster::Graphics::Model::ModelInfo(); modelInfo->Indexed = false; modelInfo->Animated = false; @@ -185,7 +183,10 @@ void* Oyster::Graphics::Loading::LoadDAN(const wchar_t filename[]) std::ifstream danFile; danFile.open(filename, std::ios::binary); if (!danFile.is_open()) + { + delete modelInfo; return NULL; + } // Read file header char* buffer = new char[sizeof(FileHeader)]; @@ -196,6 +197,7 @@ void* Oyster::Graphics::Loading::LoadDAN(const wchar_t filename[]) // If problem with compatability then close file and return from method if (fileHeader.versionMajor != DANFILEVERSIONMAJOR) { + delete modelInfo; danFile.close(); return NULL; } @@ -220,7 +222,7 @@ void* Oyster::Graphics::Loading::LoadDAN(const wchar_t filename[]) delete[] buffer; // ( note: may crash here.) // Fetch all vertices - unsigned int bufferSize = VERTEXSIZE * vertexHeader.numVertices; + unsigned int bufferSize = sizeof(Vertex) * vertexHeader.numVertices; buffer = new char[bufferSize]; danFile.read(buffer, bufferSize); @@ -291,7 +293,7 @@ void* Oyster::Graphics::Loading::LoadDAN(const wchar_t filename[]) //read normal map name length ReadData(&materialHeader.normalMapPathLength,danFile,4); - //read difuse map name + //read normal map name materialHeader.normalMapPath = new char[materialHeader.normalMapPathLength + 1]; ReadData(materialHeader.normalMapPath,danFile,materialHeader.normalMapPathLength); materialHeader.normalMapPath[materialHeader.normalMapPathLength] = 0; diff --git a/Code/OysterGraphics/FileLoader/ModelLoader.cpp b/Code/OysterGraphics/FileLoader/ModelLoader.cpp index 96fa0362..ba0928cc 100644 --- a/Code/OysterGraphics/FileLoader/ModelLoader.cpp +++ b/Code/OysterGraphics/FileLoader/ModelLoader.cpp @@ -645,6 +645,7 @@ static HRESULT CreateTextureFromWIC( _In_ ID3D11Device* d3dDevice, if ( SUCCEEDED(hr) && ( fmtSupport & D3D11_FORMAT_SUPPORT_MIP_AUTOGEN ) ) { autogen = true; + autogen = false; } } diff --git a/Code/OysterGraphics/Render/GuiRenderer.cpp b/Code/OysterGraphics/Render/GuiRenderer.cpp index 78b2f771..8eda0bf5 100644 --- a/Code/OysterGraphics/Render/GuiRenderer.cpp +++ b/Code/OysterGraphics/Render/GuiRenderer.cpp @@ -91,8 +91,8 @@ namespace Oyster { tmpInst.coff=(1.0f/TEXT_NR_LETTERS); tmpInst.offset=text[i]-32; - tmpInst.pos=i*(FontSize * 0.8f * TEXT_SPACING); - if(tmpInst.pos > size.x) + tmpInst.pos=i*(FontSize * 0.7f * TEXT_SPACING); + if(tmpInst.pos > size.x*2) { text = text.substr(0,i-1); break; diff --git a/Code/OysterGraphics/Render/Resources.cpp b/Code/OysterGraphics/Render/Resources.cpp index 450a075b..0c5bf592 100644 --- a/Code/OysterGraphics/Render/Resources.cpp +++ b/Code/OysterGraphics/Render/Resources.cpp @@ -340,13 +340,11 @@ namespace Oyster { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 }, { "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "TANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 32, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "BITANGENT", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 44, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "BONEINDEX", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 56, D3D11_INPUT_PER_VERTEX_DATA, 0 }, - { "BONEWEIGHT", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 72, D3D11_INPUT_PER_VERTEX_DATA, 0 } + { "BONEINDEX", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 32, D3D11_INPUT_PER_VERTEX_DATA, 0 }, + { "BONEWEIGHT", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 48, D3D11_INPUT_PER_VERTEX_DATA, 0 } }; - Shader::CreateInputLayout(indesc,7,GetShader::Vertex(L"Gather"),Gather::Pass.IAStage.Layout); + Shader::CreateInputLayout(indesc,5,GetShader::Vertex(L"Gather"),Gather::Pass.IAStage.Layout); Gather::Pass.IAStage.Topology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; Gather::Pass.CBuffers.Vertex.push_back(Gather::AnimationData); Gather::Pass.CBuffers.Vertex.push_back(Gather::ModelData); diff --git a/Code/OysterGraphics/Shader/Passes/2D/2DGeometry.hlsl b/Code/OysterGraphics/Shader/Passes/2D/2DGeometry.hlsl index 56b6294f..86fea579 100644 --- a/Code/OysterGraphics/Shader/Passes/2D/2DGeometry.hlsl +++ b/Code/OysterGraphics/Shader/Passes/2D/2DGeometry.hlsl @@ -4,19 +4,19 @@ void main(point Vertex2DIn input[1],inout TriangleStream Quads) { Pixel2DIn output; - output.Pos = mul(float4(-1,-1,0,1) ,Translation); + output.Pos = mul(float4(-1,-1,1,1) ,Translation); output.Uv = float2(0,1); Quads.Append(output); - output.Pos = mul(float4(-1,1,0,1), Translation); + output.Pos = mul(float4(-1,1,1,1), Translation); output.Uv = float2(0,0); Quads.Append(output); - output.Pos = mul(float4(1,-1,0,1), Translation); + output.Pos = mul(float4(1,-1,1,1), Translation); output.Uv = float2(1,1); Quads.Append(output); - output.Pos = mul(float4(1,1,0,1), Translation); + output.Pos = mul(float4(1,1,1,1), Translation); output.Uv = float2(1,0); Quads.Append(output); } \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextGeometry.hlsl b/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextGeometry.hlsl index feefbed7..4e0bed02 100644 --- a/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextGeometry.hlsl +++ b/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextGeometry.hlsl @@ -7,22 +7,22 @@ void main(point Text2DIn input[1],inout TriangleStream Quads) float endoff=startoff+input[0].coff; Pixel2DIn output; - output.Pos = mul(float4(-1,-1,0,1), Translation); + output.Pos = mul(float4(-1,-1,1,1), Translation); output.Pos.x += input[0].Pos; output.Uv = float2(startoff,1); Quads.Append(output); - output.Pos = mul(float4(-1,1,0,1), Translation); + output.Pos = mul(float4(-1,1,1,1), Translation); output.Pos.x += input[0].Pos; output.Uv = float2(startoff,0); Quads.Append(output); - output.Pos = mul(float4(1,-1,0,1), Translation); + output.Pos = mul(float4(1,-1,1,1), Translation); output.Pos.x += input[0].Pos; output.Uv = float2(endoff,1); Quads.Append(output); - output.Pos = mul(float4(1,1,0,1), Translation); + output.Pos = mul(float4(1,1,1,1), Translation); output.Pos.x += input[0].Pos; output.Uv = float2(endoff,0); Quads.Append(output); diff --git a/Code/OysterGraphics/Shader/Passes/Gather/Header.hlsli b/Code/OysterGraphics/Shader/Passes/Gather/Header.hlsli index ea144417..7584fcd3 100644 --- a/Code/OysterGraphics/Shader/Passes/Gather/Header.hlsli +++ b/Code/OysterGraphics/Shader/Passes/Gather/Header.hlsli @@ -3,8 +3,6 @@ struct VertexIn float3 pos : POSITION; float2 UV : TEXCOORD; float3 normal : NORMAL; - float3 tangent : TANGENT; - float3 biTangent : BITANGENT; float4 boneIndex : BONEINDEX; float4 boneWeight : BONEWEIGHT; }; @@ -15,8 +13,6 @@ struct VertexOut float4 ViewPos : POSITION; float2 UV : TEXCOORD; float3 normal : NORMAL; - //float3 tangent : TANGENT; - //float3 biTangent : BITANGENT; }; struct PixelOut diff --git a/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl b/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl index 8e303455..3504a6a8 100644 --- a/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl +++ b/Code/OysterGraphics/Shader/Passes/Light/LightPass.hlsl @@ -36,7 +36,8 @@ void main( uint3 DTid : SV_DispatchThreadID, uint3 GTid : SV_GroupThreadID ) float AmbValue = GetSSAO(ViewPos, UV, DTid.xy, GTid.xy/2); Ambient[DTid.xy/2] = float4(DiffuseGlow[DTid.xy].xyz, AmbValue); Ambient[DTid.xy/2 + float2(Pixels.x/2, 0)] = GUI[DTid.xy]; - Ambient[DTid.xy/2 + float2(0, Pixels.y/2)] = float4(DiffuseGlow[DTid.xy].xyz * DiffuseGlow[DTid.xy].w*10,1); + Ambient[DTid.xy/2 + float2(0, Pixels.y/2)] = float4(DiffuseGlow[DTid.xy].xyz * DiffuseGlow[DTid.xy].w,1); + Ambient[DTid.xy/2 + Pixels/2] = float4(NormalSpec[DTid.xy].xyz,1); } } \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl b/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl index 9588cbab..26c9e941 100644 --- a/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl +++ b/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl @@ -11,7 +11,7 @@ cbuffer Size : register(b0) int2 Pixels; } -#define AmbFactor 0.8f; +#define AmbFactor 0.1f; float4 SuperSample(float4 Glow, uint3 DTid) { @@ -20,12 +20,7 @@ float4 SuperSample(float4 Glow, uint3 DTid) index += float2(0,Output.Length.y/2); index = index / Output.Length; Glow = Ambient.SampleLevel(S1, index,1); - //Line Y+1 - //Glow += Ambient[DTid.xy/2 + uint2(1,(Output.Length.y/2)+1)] + Ambient[DTid.xy/2 + uint2(0,(Output.Length.y/2)+1)] + Ambient[DTid.xy/2 + uint2(-1,(Output.Length.y/2)+1)]; - //Line Y-1 - //Glow += Ambient[DTid.xy/2 + uint2(1,(Output.Length.y/2)-1)] + Ambient[DTid.xy/2 + uint2(0,(Output.Length.y/2)-1)] + Ambient[DTid.xy/2 + uint2(-1,(Output.Length.y/2)-1)]; - - //Glow = Glow/9; + Glow = Glow * Glow.w*10; return Glow; } @@ -34,7 +29,7 @@ float4 SuperSample(float4 Glow, uint3 DTid) void main( uint3 DTid : SV_DispatchThreadID ) { float4 Light = Diffuse[DTid.xy] + saturate(Specular[DTid.xy]); - float4 Amb = float4(Ambient[DTid.xy/2].xyz/* * Ambient[DTid.xy/2].w */, 0); + float4 Amb = float4(Ambient[DTid.xy/2].xyz /* * Ambient[DTid.xy/2].w*/, 0); //float4 Glow = Ambient[DTid.xy/2 + uint2(0,Output.Length.y/2)]; float4 Glow = Ambient[DTid.xy/2 + uint2(0,Output.Length.y/2)]; @@ -43,10 +38,10 @@ void main( uint3 DTid : SV_DispatchThreadID ) float4 GUI; uint2 index = DTid.xy/2 + uint2((uint)Pixels.x/(uint)2,0); float3 PostLight = Amb.xyz * AmbFactor; - PostLight = PostLight + Light.xyz; // + Glow; + PostLight = PostLight + Light.xyz + Glow; GUI = float4(Ambient[index]); PostLight = PostLight * (1 - GUI.w); Output[DTid.xy] = float4((GUI.xyz * GUI.w) + PostLight, 1); - //Output[DTid.xy] = Glow; + //Output[DTid.xy] = Ambient[DTid.xy]; } \ No newline at end of file diff --git a/Code/OysterMath/LinearMath.h b/Code/OysterMath/LinearMath.h index a6d48eb2..25b65331 100644 --- a/Code/OysterMath/LinearMath.h +++ b/Code/OysterMath/LinearMath.h @@ -373,6 +373,14 @@ namespace LinearAlgebra3D return (rotation*localAxis*rotation.GetConjugate()).imaginary; } + template + inline ::LinearAlgebra::Vector3 AngularAxis( const ::LinearAlgebra::Quaternion &rotation ) + { // see http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm + ScalarType angle = ScalarType(2) * (ScalarType)::std::acos( rotation.real ), + multiplier = angle / (ScalarType)::std::sqrt( ScalarType(1) - rotation.real * rotation.real ); + return multiplier * rotation.imaginary; + } + // All Matrix to AngularAxis conversions here is incorrect //template //inline ::LinearAlgebra::Vector4 AngularAxis( const ::LinearAlgebra::Matrix3x3 &rotationMatrix ) diff --git a/Code/OysterMath/OysterMath.cpp b/Code/OysterMath/OysterMath.cpp index 3906a1db..deac2d0b 100644 --- a/Code/OysterMath/OysterMath.cpp +++ b/Code/OysterMath/OysterMath.cpp @@ -81,6 +81,12 @@ namespace Oyster { namespace Math2D namespace Oyster { namespace Math3D { + //! Converts a rotationQuaternion to an angularAxis + Float3 AngularAxis( const Quaternion &rotation ) + { + return ::LinearAlgebra3D::AngularAxis( rotation ); + } + //Float4 AngularAxis( const Float3x3 &rotationMatrix ) //{ // return ::LinearAlgebra3D::AngularAxis( rotationMatrix ); @@ -96,52 +102,6 @@ namespace Oyster { namespace Math3D // return ::LinearAlgebra3D::ExtractAngularAxis( orientationMatrix ); //} - Float4 QuaternionToAngularAxis(Float4 quaternion) - { - Float4 axis = Float4::null; - Float s = sqrtf(1 - quaternion.w*quaternion.w); - - axis.w = 2*acos(quaternion.w*quaternion.w); - - if(1 - quaternion.w > 0.001f) - { - axis.x = quaternion.x/s; - axis.y = quaternion.y/s; - axis.z = quaternion.z/s; - } - else - { - axis.x = quaternion.x; - axis.y = quaternion.y; - axis.z = quaternion.z; - } - - return axis; - } - - Float4 QuaternionToAngularAxis(Quaternion quaternion) - { - Float4 axis = Float4::null; - Float s = sqrtf(1 - quaternion.real*quaternion.real); - - axis.w = 2*acos(quaternion.real*quaternion.real); - - if(1 - quaternion.real > 0.001f) - { - axis.x = quaternion.imaginary.x/s; - axis.y = quaternion.imaginary.y/s; - axis.z = quaternion.imaginary.z/s; - } - else - { - axis.x = quaternion.imaginary.x; - axis.y = quaternion.imaginary.y; - axis.z = quaternion.imaginary.z; - } - - return axis; - } - Float4x4 & TranslationMatrix( const Float3 &position, Float4x4 &targetMem ) { return ::LinearAlgebra3D::TranslationMatrix( position, targetMem ); diff --git a/Code/OysterMath/OysterMath.h b/Code/OysterMath/OysterMath.h index 23ba55ff..da23e16d 100644 --- a/Code/OysterMath/OysterMath.h +++ b/Code/OysterMath/OysterMath.h @@ -140,6 +140,9 @@ namespace Oyster { namespace Math3D //! Oyster's native math library specialized { using namespace ::Oyster::Math; // deliberate inheritance from ::Oyster::Math namespace + //! Converts a rotationQuaternion to an angularAxis + Float3 AngularAxis( const Quaternion &rotation ); + //! Extracts the angularAxis from rotationMatrix //Float4 AngularAxis( const Float3x3 &rotationMatrix ); @@ -149,12 +152,6 @@ namespace Oyster { namespace Math3D //! Oyster's native math library specialized ////! Extracts the angularAxis from orientationMatrix //Float4 ExtractAngularAxis( const Float4x4 &orientationMatrix ); - //! Converts a quaternion as Float4 to angular axis as Float4 - Float4 QuaternionToAngularAxis(Float4 quaternion); - - //! Converts a quaternion to angular axis as Float4 - Float4 QuaternionToAngularAxis(Quaternion quaternion); - //! Sets and returns targetMem to a translationMatrix with position as translation. Float4x4 & TranslationMatrix( const Float3 &position, Float4x4 &targetMem = Float4x4() ); diff --git a/Code/Tester/MainTest.cpp b/Code/Tester/MainTest.cpp index ad71dabb..e854e1f9 100644 --- a/Code/Tester/MainTest.cpp +++ b/Code/Tester/MainTest.cpp @@ -171,18 +171,14 @@ HRESULT InitDirect3D() } m = Oyster::Graphics::API::CreateModel(L"crate_colonists.dan"); - //m->WorldMatrix.m[0][0] = 50; - //m->WorldMatrix.m[1][1] = 50; - //m->WorldMatrix.m[2][2] = 0.00000005f; - m2 = Oyster::Graphics::API::CreateModel(L"char_temporary.dan"); + m2 = Oyster::Graphics::API::CreateModel(L"char_orca.dan"); m2->Tint = Oyster::Math::Float3(0.1f,0.1f,1); - m3 = Oyster::Graphics::API::CreateModel(L"char_temporary.dan"); - m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(4,0,0),Oyster::Math::Float3::null); - Oyster::Graphics::API::PlayAnimation(m2, L"movement", true); + m3 = Oyster::Graphics::API::CreateModel(L"char_orca.dan"); + //Oyster::Graphics::API::PlayAnimation(m2, L"movement", true); Oyster::Graphics::API::PlayAnimation(m3, L"movement", true); t = Oyster::Graphics::API::CreateTexture(L"structure_corp_mdg.png"); - t2 = Oyster::Graphics::API::CreateTexture(L"whiteGui.png"); + t2 = Oyster::Graphics::API::CreateTexture(L"color_white.png"); P = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1280.0f/720.0f,.1f,10000); Oyster::Graphics::API::SetProjection(P); @@ -217,15 +213,13 @@ HRESULT InitDirect3D() return S_OK; } float angle = 0; +float z=0; HRESULT Update(float deltaTime) { - //angle += Oyster::Math::pi/16 * deltaTime; - m->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(1,0,0) * angle,Oyster::Math::Float3(0,0,0),Oyster::Math::Float3::null); + m->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0) * angle,Oyster::Math::Float3(0,0,z),Oyster::Math::Float3::null); m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0) * angle,Oyster::Math::Float3(4,0,0),Oyster::Math::Float3::null); m3->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0) * -angle,Oyster::Math::Float3(-4,0,0),Oyster::Math::Float3::null); - //Oyster::Math::Matrix ma = Oyster::Math::Matrix::identity; Oyster::Graphics::API::Update(deltaTime); - //m2->Animation.data.AnimationTime += deltaTime;// * 0.5f; return S_OK; } @@ -238,7 +232,7 @@ HRESULT Render(float deltaTime) Oyster::Graphics::API::RenderModel(m2); Oyster::Graphics::API::RenderModel(m3); Oyster::Graphics::API::StartGuiRender(); - //Oyster::Graphics::API::RenderGuiElement(t,Oyster::Math::Float2(0.5f,0.5f),Oyster::Math::Float2(1,1), Oyster::Math::Float3(0,0,1)); + Oyster::Graphics::API::RenderGuiElement(t2,Oyster::Math::Float3(0.5f,0.7f,0.1f),Oyster::Math::Float2(0.2f,0.2f), Oyster::Math::Float3(1,1,1)); //Oyster::Graphics::API::RenderGuiElement(t2,Oyster::Math::Float2(0.5f,0.5f),Oyster::Math::Float2(1,1),Oyster::Math::Float3(1,0,0)); Oyster::Graphics::API::StartTextRender(); std::wstring fps; @@ -246,7 +240,7 @@ HRESULT Render(float deltaTime) fps = std::to_wstring(f); //Oyster::Graphics::API::RenderText(L"Lanariel",Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f)); //Oyster::Graphics::API::RenderText(L"Lanariel WAS HERE",Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f)); - Oyster::Graphics::API::RenderText(fps,Oyster::Math::Float3(0.5f,0.1f,1.0f),Oyster::Math::Float2(0.5f,0.1f), 0.08f, Oyster::Math::Float3(0,1,0)); + Oyster::Graphics::API::RenderText(fps,Oyster::Math::Float3(0.5f,0.1f,0.1f),Oyster::Math::Float2(0.5f,0.1f), 0.08f, Oyster::Math::Float3(0,1,0)); Oyster::Graphics::API::EndFrame(); return S_OK; @@ -286,16 +280,26 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam break; //Z - case 0x5A: - //m2->AnimationTime -= 0.1f; - //if(m2->AnimationTime < 0) - //m2->AnimationTime = 0; angle += Oyster::Math::pi / 16; break; //X + case 0x58: - //m2->AnimationTime += 0.1f; angle -= Oyster::Math::pi / 16; break; + //A + case 0x41: + break; + //D + case 0x44: + break; + //W + case 0x57: + z-=0.5f; + break; + //S + case 0x53: + z+=0.5f; + break; } break;