From 8e783088208b93a4a47384fa26b2b301f1adf6d7 Mon Sep 17 00:00:00 2001 From: lanariel Date: Fri, 14 Feb 2014 10:08:39 +0100 Subject: [PATCH 01/22] New Vertex format NOT STABLE UNTIL NEW MODELS --- .../Definitions/GraphicalDefinition.h | 2 -- Code/OysterGraphics/FileLoader/DanLoader.cpp | 5 ++--- Code/OysterGraphics/Render/GuiRenderer.cpp | 2 +- Code/OysterGraphics/Render/Resources.cpp | 4 +--- .../Shader/Passes/Gather/Header.hlsli | 2 -- Code/Tester/MainTest.cpp | 14 +++++++++----- 6 files changed, 13 insertions(+), 16 deletions(-) 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/FileLoader/DanLoader.cpp b/Code/OysterGraphics/FileLoader/DanLoader.cpp index 99302266..69af2158 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 @@ -220,7 +219,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); diff --git a/Code/OysterGraphics/Render/GuiRenderer.cpp b/Code/OysterGraphics/Render/GuiRenderer.cpp index 78b2f771..86f6fe0e 100644 --- a/Code/OysterGraphics/Render/GuiRenderer.cpp +++ b/Code/OysterGraphics/Render/GuiRenderer.cpp @@ -91,7 +91,7 @@ namespace Oyster { tmpInst.coff=(1.0f/TEXT_NR_LETTERS); tmpInst.offset=text[i]-32; - tmpInst.pos=i*(FontSize * 0.8f * TEXT_SPACING); + tmpInst.pos=i*(FontSize * 0.7f * TEXT_SPACING); if(tmpInst.pos > size.x) { text = text.substr(0,i-1); diff --git a/Code/OysterGraphics/Render/Resources.cpp b/Code/OysterGraphics/Render/Resources.cpp index 450a075b..696ee6f1 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 } }; - 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/Gather/Header.hlsli b/Code/OysterGraphics/Shader/Passes/Gather/Header.hlsli index ea144417..8747e46d 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; }; diff --git a/Code/Tester/MainTest.cpp b/Code/Tester/MainTest.cpp index ad71dabb..c6956971 100644 --- a/Code/Tester/MainTest.cpp +++ b/Code/Tester/MainTest.cpp @@ -170,10 +170,10 @@ HRESULT InitDirect3D() return E_FAIL; } - 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; + m = Oyster::Graphics::API::CreateModel(L"building_corporation.dan"); + m->WorldMatrix.m[0][0] = 0.0002f; + m->WorldMatrix.m[1][1] = 0.0002f; + m->WorldMatrix.m[2][2] = 0.0002f; m2 = Oyster::Graphics::API::CreateModel(L"char_temporary.dan"); m2->Tint = Oyster::Math::Float3(0.1f,0.1f,1); m3 = Oyster::Graphics::API::CreateModel(L"char_temporary.dan"); @@ -223,7 +223,11 @@ HRESULT Update(float deltaTime) m->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(1,0,0) * angle,Oyster::Math::Float3(0,0,0),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::Math::Matrix ma = Oyster::Math::Matrix::identity; + ma.m[0][0] = 0.2f; + ma.m[1][1] = 0.2f; + ma.m[2][2] = 0.2f; + m->WorldMatrix = m->WorldMatrix * ma; Oyster::Graphics::API::Update(deltaTime); //m2->Animation.data.AnimationTime += deltaTime;// * 0.5f; return S_OK; From 6f9483041bd1de0adaefa6570657ef7947e2d9aa Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Fri, 14 Feb 2014 11:26:50 +0100 Subject: [PATCH 02/22] Temporary mouse pos add + other stuff --- Code/Game/DanBiasGame/DanBiasGame_Impl.cpp | 17 +++++++++++++-- .../GameClientState/LanMenuState.cpp | 2 +- .../DanBiasGame/GameClientState/MainState.cpp | 3 +-- Code/Input/L_inputClass.cpp | 21 +++++++++++++++++++ Code/Input/L_inputClass.h | 7 +++++-- 5 files changed, 43 insertions(+), 7 deletions(-) diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index 923e53fc..8691436d 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -56,7 +56,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 +150,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 ) { diff --git a/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp b/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp index c4d2b41d..0d92ee72 100644 --- a/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp @@ -56,7 +56,7 @@ bool LanMenuState::Init(Network::NetworkClient* nwClient) // 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 ); diff --git a/Code/Game/DanBiasGame/GameClientState/MainState.cpp b/Code/Game/DanBiasGame/GameClientState/MainState.cpp index 3c82fc05..aefb4b26 100644 --- a/Code/Game/DanBiasGame/GameClientState/MainState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/MainState.cpp @@ -73,8 +73,7 @@ GameClientState::ClientState MainState::Update(float deltaTime, InputClass* KeyI { MouseInput mouseState; { - mouseState.x = KeyInput->GetPitch(); - mouseState.y = KeyInput->GetYaw(); + KeyInput->GetMousePos( mouseState.x, mouseState.y ); mouseState.mouseButtonPressed = KeyInput->IsMousePressed(); } diff --git a/Code/Input/L_inputClass.cpp b/Code/Input/L_inputClass.cpp index 5fd15a54..03271333 100644 --- a/Code/Input/L_inputClass.cpp +++ b/Code/Input/L_inputClass.cpp @@ -5,6 +5,8 @@ InputClass::InputClass() m_directInput = NULL; m_keyboard = NULL; m_mouse = NULL; + mousePosX = 0.0f; + mousePosY = 0.0f; } InputClass::~InputClass() @@ -128,6 +130,13 @@ bool InputClass::Update() return true; } +bool InputClass::Update( float mousePosX, float mousePosY ) +{ + this->mousePosX = mousePosX; + this->mousePosY = mousePosY; + return this->Update(); +} + bool InputClass::ReadKeyboard() { HRESULT result; @@ -198,3 +207,15 @@ bool InputClass::IsKeyPressed(int key) return false; } + +void InputClass::SetMousePos( float x, float y ) +{ + this->mousePosX = y; + this->mousePosY = x; +} + +void InputClass::GetMousePos( float &x, float &y ) +{ + x = this->mousePosX; + y = this->mousePosY; +} \ No newline at end of file diff --git a/Code/Input/L_inputClass.h b/Code/Input/L_inputClass.h index 08358135..8ed8e528 100644 --- a/Code/Input/L_inputClass.h +++ b/Code/Input/L_inputClass.h @@ -14,8 +14,6 @@ #include - - class InputClass { private: @@ -26,6 +24,8 @@ private: unsigned char m_keyboardState[256]; DIMOUSESTATE m_mouseState; + float mousePosX, mousePosY; + bool ReadKeyboard(); bool ReadMouse(); @@ -40,6 +40,7 @@ public: //read the mouse and keyboard and send back // delta mouse pos and if any button is pressed bool Update(); + bool Update( float mousePosX, float mousePosY ); bool IsKeyPressed(int key); bool IsMousePressed(); @@ -48,6 +49,8 @@ public: float GetYaw(); float GetPitch(); + void SetMousePos( float x, float y ); + void GetMousePos( float &x, float &y ); }; #endif \ No newline at end of file From 22f8a6c9ea8f8c8ab0298e79021f23241b010f5a Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Fri, 14 Feb 2014 11:27:23 +0100 Subject: [PATCH 03/22] Revert "Revert this" This reverts commit 76f0b712b17d90d84792a5fedd9ab9103dcae797. --- Code/Game/DanBiasGame/GameClientState/MainState.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/MainState.cpp b/Code/Game/DanBiasGame/GameClientState/MainState.cpp index aefb4b26..b0b226e6 100644 --- a/Code/Game/DanBiasGame/GameClientState/MainState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/MainState.cpp @@ -67,8 +67,6 @@ bool MainState::Init( NetworkClient* nwClient ) return true; } -float mouseX, mouseY; // debug test - GameClientState::ClientState MainState::Update(float deltaTime, InputClass* KeyInput) { MouseInput mouseState; @@ -79,9 +77,6 @@ GameClientState::ClientState MainState::Update(float deltaTime, InputClass* KeyI EventHandler::Instance().Update( mouseState ); - mouseX = mouseState.x; // debug test - mouseY = mouseState.y; // debug test - return this->privData->nextState; } @@ -96,9 +91,6 @@ bool MainState::Render() Graphics::API::StartTextRender(); this->privData->guiElements.RenderText(); - Graphics::API::RenderText( ::std::to_wstring(mouseX), Float2(0.2f, 0.5f), Float2(0.2f, 0.05f) ); // debug test - Graphics::API::RenderText( ::std::to_wstring(mouseY), Float2(0.5f, 0.5f), Float2(0.2f, 0.05f) ); // debug test - Graphics::API::EndFrame(); return true; } From 2bfcda3b506c1b5641c441f2c9705edc9ee5486c Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Fri, 14 Feb 2014 11:32:16 +0100 Subject: [PATCH 04/22] MousePos available in all relevant states --- Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp | 3 +-- Code/Game/DanBiasGame/GameClientState/LobbyAdminState.cpp | 3 +-- Code/Game/DanBiasGame/GameClientState/LobbyState.cpp | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp b/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp index 0d92ee72..63ea4228 100644 --- a/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp @@ -80,8 +80,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(); } diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.cpp b/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.cpp index 21afb54b..ccf6bbf0 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(); } diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp index 37f10f1d..5dd2bc9b 100644 --- a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp @@ -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(); } From 36c6689c7a16fbbbb8d9642fc42e0b49dd931ace Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Fri, 14 Feb 2014 11:37:20 +0100 Subject: [PATCH 05/22] bug fixes --- Code/Game/DanBiasGame/GameClientState/Buttons/TextField.h | 2 +- Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/Buttons/TextField.h b/Code/Game/DanBiasGame/GameClientState/Buttons/TextField.h index 4333f1da..62866834 100644 --- a/Code/Game/DanBiasGame/GameClientState/Buttons/TextField.h +++ b/Code/Game/DanBiasGame/GameClientState/Buttons/TextField.h @@ -173,7 +173,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/LanMenuState.cpp b/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp index 63ea4228..bf713d85 100644 --- a/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp @@ -62,7 +62,7 @@ bool LanMenuState::Init(Network::NetworkClient* nwClient) 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->ReserveLines( 1 ); - (*this->privData->connectIP)[0] = L"127.0.0.1"; + this->privData->connectIP->AppendText( L"127.0.0.1" ); this->privData->connectIP->SetTextHeight( 0.1f ); this->privData->connectIP->SetLineSpacing( 0.0f ); From 9fc8a8840f3c6d2310f20168a2a878ac0cf85aa9 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Fri, 14 Feb 2014 12:03:29 +0100 Subject: [PATCH 06/22] GL - fixed movement(pretty unstable but its working) --- Code/Game/GameLogic/Player.cpp | 21 +++++++++++++++++++-- Code/Game/GameLogic/StaticObject.cpp | 8 ++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 0fb93995..54841b39 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -17,17 +17,34 @@ Player::Player() Player::Player(Oyster::Physics::ICustomBody *rigidBody, void (*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; - 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->moveDir = Oyster::Math::Float3(0,0,0); + this->moveSpeed = 100; + this->previousMoveSpeed = Oyster::Math::Float3(0,0,0); } 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) 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) { From e6c5f1f6e50ed8679410e6ddc0031405b831f209 Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Fri, 14 Feb 2014 12:09:59 +0100 Subject: [PATCH 07/22] Merge errors dealt with --- .../GameClientState/Buttons/EventButtonGUI.h | 29 ++++++++++--------- .../GameClientState/Buttons/TextField.h | 24 +++++++-------- .../GameClientState/LanMenuState.cpp | 4 +-- .../GameClientState/LobbyAdminState.cpp | 2 +- .../GameClientState/LobbyState.cpp | 2 +- .../DanBiasGame/GameClientState/MainState.cpp | 4 +-- 6 files changed, 34 insertions(+), 31 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h b/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h index 72ac354a..554365ea 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, size, size.y, textColor); } } diff --git a/Code/Game/DanBiasGame/GameClientState/Buttons/TextField.h b/Code/Game/DanBiasGame/GameClientState/Buttons/TextField.h index 62866834..3cfc7380 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,12 +76,12 @@ 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 ); if( this->isBottomAligned ) { - ::Oyster::Math::Float2 topLeft = this->pos; + ::Oyster::Math::Float3 topLeft = this->pos; topLeft.y += this->size.y - lineStep; auto line = this->lines.rbegin(); @@ -89,7 +89,7 @@ namespace DanBias { namespace Client { if( topLeft.y - lineStep >= this->pos.y ) { - ::Oyster::Graphics::API::RenderText( (*line), topLeft, rowSize, this->textColor ); + ::Oyster::Graphics::API::RenderText( (*line), topLeft, rowSize, this->fontHeight, this->textColor ); topLeft.y -= lineStep; } else break; @@ -97,14 +97,14 @@ namespace DanBias { namespace Client } else { - ::Oyster::Math::Float2 topLeft = this->pos; + ::Oyster::Math::Float3 topLeft = this->pos; 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 ); + ::Oyster::Graphics::API::RenderText( (*line), topLeft, rowSize, this->fontHeight, this->textColor ); topLeft.y += lineStep; } else break; @@ -125,9 +125,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 diff --git a/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp b/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp index bf713d85..936d7c3c 100644 --- a/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp @@ -63,7 +63,7 @@ bool LanMenuState::Init(Network::NetworkClient* nwClient) 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->ReserveLines( 1 ); this->privData->connectIP->AppendText( L"127.0.0.1" ); - this->privData->connectIP->SetTextHeight( 0.1f ); + this->privData->connectIP->SetFontHeight( 0.1f ); this->privData->connectIP->SetLineSpacing( 0.0f ); this->privData->guiElements.AddButton( this->privData->connectIP ); @@ -95,7 +95,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(); diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.cpp b/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.cpp index ccf6bbf0..9416f01e 100644 --- a/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.cpp @@ -83,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(); diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp index 5dd2bc9b..8643c777 100644 --- a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp @@ -83,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(); diff --git a/Code/Game/DanBiasGame/GameClientState/MainState.cpp b/Code/Game/DanBiasGame/GameClientState/MainState.cpp index b0b226e6..81794252 100644 --- a/Code/Game/DanBiasGame/GameClientState/MainState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/MainState.cpp @@ -85,7 +85,7 @@ bool MainState::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(); @@ -99,7 +99,7 @@ bool MainState::Release() { if( this->privData ) { - Graphics::API::DeleteTexture( this->privData->background ); // TODO: @todo bug caught when exiting by X + Graphics::API::DeleteTexture( this->privData->background ); EventHandler::Instance().ReleaseCollection( &this->privData->guiElements ); this->privData = NULL; From c5c0047b5c80a6240209ccb37474de018885a2be Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Fri, 14 Feb 2014 12:20:58 +0100 Subject: [PATCH 08/22] some minor temporary button edits --- Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h b/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h index 554365ea..d4981c23 100644 --- a/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h +++ b/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h @@ -104,7 +104,7 @@ namespace DanBias { if(buttonText.size() > 0) { - Oyster::Graphics::API::RenderText(buttonText, pos, size, size.y, 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); } } From 8110b677ff2704bc72607d1d2e61abef6e5fae12 Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Fri, 14 Feb 2014 13:09:55 +0100 Subject: [PATCH 09/22] GL - added spawnpoint array --- .../DanBiasGame/GameClientState/GameState.cpp | 5 ++- Code/Game/GameLogic/Level.cpp | 37 +------------------ Code/Game/GameLogic/Level.h | 1 + 3 files changed, 7 insertions(+), 36 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index 9e42c87b..c4da14bb 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -183,7 +183,10 @@ bool GameState::LoadModels(std::string mapFile) case GameLogic::ObjectType::ObjectType_Static: { GameLogic::ObjectHeader* staticObjData = ((GameLogic::ObjectHeader*)obj); - + if((ObjectSpecialType)staticObjData->specialTypeID == ObjectSpecialType_Sky) + { + int i = 0; + } modelData.modelPath.assign(staticObjData->ModelFile.begin(), staticObjData->ModelFile.end()); modelData.visible = true; modelData.position = staticObjData->position; diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 6d3de52c..a828f30b 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: @@ -111,13 +111,12 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody) 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), 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; }; From 25b0162b59c51f0422323e367c4994df6e4be29c Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Fri, 14 Feb 2014 13:54:50 +0100 Subject: [PATCH 10/22] GL - explosive crate testing --- Code/Game/GameLogic/CollisionManager.cpp | 24 ++++++++++++++++++-- Code/Game/GameLogic/Game_PlayerData.cpp | 4 ++-- Code/Game/GameLogic/Level.cpp | 6 +---- Code/Game/GameLogic/Player.cpp | 29 ------------------------ 4 files changed, 25 insertions(+), 38 deletions(-) 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 11c8324e..1b1692d9 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -57,11 +57,7 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody) break; case ObjectSpecialType_StandardBox: { - int dmg = 50; - Oyster::Math::Float force = 50; - int radie = 10; - gameObj = new ExplosiveCrate(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++, dmg, force, radie); - //gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++); + gameObj = new DynamicObject(rigidBody, Object::DefaultCollisionAfter, (ObjectSpecialType)obj->specialTypeID, objID++); } break; case ObjectSpecialType_RedExplosiveBox: diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index b6888bf2..625a0663 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -17,20 +17,6 @@ Player::Player() Player::Player(Oyster::Physics::ICustomBody *rigidBody, void (*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; @@ -52,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; @@ -81,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) From adcac0ec129880ccd42f7cf28a0d07f4e69c84ff Mon Sep 17 00:00:00 2001 From: lanariel Date: Fri, 14 Feb 2014 14:27:38 +0100 Subject: [PATCH 11/22] Random Updates --- Code/OysterGraphics/Core/PipelineManager.cpp | 1 + Code/OysterGraphics/DllInterfaces/GFXAPI.cpp | 4 ++++ Code/OysterGraphics/FileLoader/DanLoader.cpp | 7 ++++-- .../OysterGraphics/FileLoader/ModelLoader.cpp | 1 + .../Shader/Passes/2D/2DGeometry.hlsl | 8 +++---- .../Shader/Passes/2D/Text/2DTextGeometry.hlsl | 8 +++---- .../Shader/Passes/Light/LightPass.hlsl | 3 ++- .../Shader/Passes/Post/PostPass.hlsl | 5 ++-- Code/Tester/MainTest.cpp | 24 +++++++++---------- 9 files changed, 36 insertions(+), 25 deletions(-) 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/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 69af2158..b6d8ed28 100644 --- a/Code/OysterGraphics/FileLoader/DanLoader.cpp +++ b/Code/OysterGraphics/FileLoader/DanLoader.cpp @@ -175,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; @@ -184,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)]; @@ -195,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; } @@ -290,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/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/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 85c74fb7..ba835e18 100644 --- a/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl +++ b/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl @@ -20,6 +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); + Glow = Glow * Glow.w*10; //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 @@ -34,7 +35,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)]; @@ -48,5 +49,5 @@ void main( uint3 DTid : SV_DispatchThreadID ) 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/Tester/MainTest.cpp b/Code/Tester/MainTest.cpp index c6956971..d30529a8 100644 --- a/Code/Tester/MainTest.cpp +++ b/Code/Tester/MainTest.cpp @@ -170,19 +170,19 @@ HRESULT InitDirect3D() return E_FAIL; } - m = Oyster::Graphics::API::CreateModel(L"building_corporation.dan"); - m->WorldMatrix.m[0][0] = 0.0002f; - m->WorldMatrix.m[1][1] = 0.0002f; - m->WorldMatrix.m[2][2] = 0.0002f; - m2 = Oyster::Graphics::API::CreateModel(L"char_temporary.dan"); + m = Oyster::Graphics::API::CreateModel(L"crate_colonists.dan"); + //m->WorldMatrix.m[0][0] = 0.0002f; + //m->WorldMatrix.m[1][1] = 0.0002f; + //m->WorldMatrix.m[2][2] = 0.0002f; + 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); + m3 = Oyster::Graphics::API::CreateModel(L"char_orca.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); 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); @@ -220,14 +220,14 @@ float angle = 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,0),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; ma.m[0][0] = 0.2f; ma.m[1][1] = 0.2f; ma.m[2][2] = 0.2f; - m->WorldMatrix = m->WorldMatrix * ma; + //m->WorldMatrix = m->WorldMatrix * ma; Oyster::Graphics::API::Update(deltaTime); //m2->Animation.data.AnimationTime += deltaTime;// * 0.5f; return S_OK; @@ -242,7 +242,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; @@ -250,7 +250,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; From fe6742f9e2fb37f4edf10d1d3f5ffc7cfdb6ef9f Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Fri, 14 Feb 2014 14:31:01 +0100 Subject: [PATCH 12/22] Tweaks and a new state: NetLoadState --- Code/Game/DanBiasGame/DanBiasGame.vcxproj | 2 ++ Code/Game/DanBiasGame/DanBiasGame_Impl.cpp | 13 ++++++-- .../GameClientState/Buttons/TextField.h | 27 ++++++++------- .../GameClientState/GameClientState.h | 3 +- .../DanBiasGame/GameClientState/GameState.cpp | 2 +- .../GameClientState/LanMenuState.cpp | 33 ++++++++++++++----- .../GameClientState/LobbyState.cpp | 2 +- 7 files changed, 54 insertions(+), 28 deletions(-) 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 8691436d..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 @@ -182,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: @@ -194,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/TextField.h b/Code/Game/DanBiasGame/GameClientState/Buttons/TextField.h index 3cfc7380..af9c4346 100644 --- a/Code/Game/DanBiasGame/GameClientState/Buttons/TextField.h +++ b/Code/Game/DanBiasGame/GameClientState/Buttons/TextField.h @@ -78,36 +78,35 @@ namespace DanBias { namespace Client { ::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::Float3 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->fontHeight, 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::Float3 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->fontHeight, 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; } } } 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 edcb5289..1bc77921 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -42,7 +42,7 @@ bool GameState::Init(NetworkClient* nwClient) LoadGame(); //tell server ready - nwClient->Send(GameLogic::Protocol_General_Status(GameLogic::Protocol_General_Status::States_ready)); + nwClient->Send( GameLogic::Protocol_General_Status(GameLogic::Protocol_General_Status::States_ready) ); return true; } diff --git a/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp b/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp index 936d7c3c..f5699ce5 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; - - 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->AppendText( L"127.0.0.1" ); - this->privData->connectIP->SetFontHeight( 0.1f ); - this->privData->connectIP->SetLineSpacing( 0.0f ); + 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 ); @@ -135,4 +139,15 @@ void OnButtonInteract_Connect( Oyster::Event::ButtonEvent& e ) 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/LobbyState.cpp b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp index 8643c777..96ac9ca5 100644 --- a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp @@ -102,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; From c1d63a147762be10e765201a101a0b0d757ecd2d Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Fri, 14 Feb 2014 14:32:17 +0100 Subject: [PATCH 13/22] new state: NetLoadState --- .../GameClientState/NetLoadState.cpp | 58 +++++++++++++++++++ .../GameClientState/NetLoadState.h | 29 ++++++++++ 2 files changed, 87 insertions(+) create mode 100644 Code/Game/DanBiasGame/GameClientState/NetLoadState.cpp create mode 100644 Code/Game/DanBiasGame/GameClientState/NetLoadState.h diff --git a/Code/Game/DanBiasGame/GameClientState/NetLoadState.cpp b/Code/Game/DanBiasGame/GameClientState/NetLoadState.cpp new file mode 100644 index 00000000..4c1f711c --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/NetLoadState.cpp @@ -0,0 +1,58 @@ +#include "NetLoadState.h" +#include "NetworkClient.h" + +using namespace ::DanBias::Client; +using namespace ::Oyster; +using namespace ::Oyster::Network; + +struct NetLoadState::MyData +{ + MyData() {} + + GameClientState::ClientState nextState; + NetworkClient *nwClient; +}; + +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; + + + + 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; +} \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/NetLoadState.h b/Code/Game/DanBiasGame/GameClientState/NetLoadState.h new file mode 100644 index 00000000..f147bfe8 --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/NetLoadState.h @@ -0,0 +1,29 @@ +#ifndef DANBIAS_CLIENT_NETLOADSTATE_H +#define DANBIAS_CLIENT_NETLOADSTATE_H + +#include "GameClientState.h" +#include "NetworkClient.h" + +namespace DanBias +{ + namespace Client + { + class NetLoadState : public GameClientState + { + private: + struct MyData; + ::Utility::DynamicMemory::UniquePointer privData; + public: + NetLoadState( ); + virtual ~NetLoadState( ); + + bool Init( Oyster::Network::NetworkClient* nwClient ); + ClientState Update( float deltaTime, InputClass* KeyInput ); + + bool Render(); + bool Release(); + void ChangeState( ClientState next ); + }; + } +} +#endif // ! DANBIAS_CLIENT_LOGINSTATE_H \ No newline at end of file From bfb9864be99e3de6b09eca4af806cec8d19fbd84 Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Fri, 14 Feb 2014 15:07:55 +0100 Subject: [PATCH 14/22] GL - handle if the model dose not exist --- .../DanBiasGame/GameClientState/C_Object.cpp | 19 ++++- .../DanBiasGame/GameClientState/C_Object.h | 5 +- .../GameClientState/C_obj/C_DynamicObj.cpp | 4 +- .../GameClientState/C_obj/C_DynamicObj.h | 2 +- .../GameClientState/C_obj/C_Player.cpp | 11 ++- .../GameClientState/C_obj/C_Player.h | 3 +- .../GameClientState/C_obj/C_StaticObj.cpp | 4 +- .../GameClientState/C_obj/C_StaticObj.h | 2 +- .../GameClientState/C_obj/C_UIobject.cpp | 4 +- .../GameClientState/C_obj/C_UIobject.h | 2 +- .../DanBiasGame/GameClientState/GameState.cpp | 81 +++++++++++-------- Code/Misc/DynamicArray.h | 2 +- 12 files changed, 89 insertions(+), 50 deletions(-) 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 f926a08a..ae9dc3a5 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_Object.h +++ b/Code/Game/DanBiasGame/GameClientState/C_Object.h @@ -29,8 +29,9 @@ private: protected: Oyster::Graphics::Model::Model *model; public: - - virtual void Init(ModelInitData modelInit); + C_Object(); + virtual ~C_Object(); + virtual bool Init(ModelInitData modelInit); void setWorld(Oyster::Math::Float4x4 world); Oyster::Math::Float4x4 getWorld() const; 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 a75785a6..b6420f53 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.cpp @@ -13,9 +13,12 @@ C_Player::~C_Player(void) } -void C_Player::Init(ModelInitData modelInit) +bool C_Player::Init(ModelInitData modelInit) { - C_Object::Init(modelInit); - Oyster::Graphics::API::PlayAnimation(model, L"movement"); - //Oyster::Graphics::API::Update(0.002f); + 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 9d7c3de0..3ef96702 100644 --- a/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.h +++ b/Code/Game/DanBiasGame/GameClientState/C_obj/C_Player.h @@ -11,7 +11,8 @@ private: public: C_Player(void); virtual ~C_Player(void); - void Init(ModelInitData modelInit); + 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/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index c4da14bb..c86d599d 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -195,7 +195,12 @@ bool GameState::LoadModels(std::string mapFile) modelData.id = modelId++; this->staticObjects.Push(new C_StaticObj()); - this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData); + if(!this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData)) + { + // the model don't exist + this->staticObjects.Remove(this->staticObjects.Size() -1 ); + modelId--; + } } break; case GameLogic::ObjectType::ObjectType_Dynamic: @@ -209,7 +214,12 @@ bool GameState::LoadModels(std::string mapFile) modelData.id = modelId++; this->dynamicObjects.Push(new C_DynamicObj()); - this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); + if(!this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData)) + { + // the model don't exist + this->dynamicObjects.Remove(this->dynamicObjects.Size() -1 ); + modelId--; + } } break; case GameLogic::ObjectType::ObjectType_Light: @@ -241,40 +251,44 @@ bool GameState::LoadModels(std::string mapFile) modelData.rotation = first; modelData.scale = Oyster::Math::Float3(1,1,1); modelData.modelPath = L"char_still_sizeref.dan"; - modelData.id = myId; + modelData.id = modelId; this->staticObjects.Push(new C_StaticObj()); - this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData); + if(!this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData)) + { + // the model don't exist + this->staticObjects.Remove(this->staticObjects.Size() -1 ); + modelId--; + } + //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; - 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; + //this->staticObjects.Push(new C_StaticObj()); + //this->staticObjects[this->staticObjects.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; - 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); - 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; - 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); + //this->staticObjects.Push(new C_StaticObj()); + //this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData); return true; @@ -302,13 +316,16 @@ void GameState::InitiatePlayer(int id, std::wstring modelName, Oyster::Math::Flo 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.modelPath = modelName; + modelData.modelPath = L"crate_generic.dan"; // modelName; modelData.id = myId; obj = new C_Player(); this->dynamicObjects.Push(obj); - this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); - + if(!this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData)) + { + // the model don't exist + this->dynamicObjects.Remove(this->dynamicObjects.Size() -1 ); + } 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]); diff --git a/Code/Misc/DynamicArray.h b/Code/Misc/DynamicArray.h index 8b4c98da..9d7bbc30 100644 --- a/Code/Misc/DynamicArray.h +++ b/Code/Misc/DynamicArray.h @@ -170,7 +170,7 @@ namespace Utility template void DynamicArray::Remove(unsigned int index) { - assert(index > (unsigned int) this->size); + assert(index < (unsigned int) this->size); T* temp = new T[this->capacity - 1]; From 655f48017c7beaf610fe65ff98af36d84d2fcffb Mon Sep 17 00:00:00 2001 From: lanariel Date: Fri, 14 Feb 2014 15:11:12 +0100 Subject: [PATCH 15/22] Anim Fix --- Code/OysterGraphics/Render/Resources.cpp | 4 ++-- .../Shader/Passes/Gather/Header.hlsli | 2 -- Code/Tester/MainTest.cpp | 17 +---------------- 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/Code/OysterGraphics/Render/Resources.cpp b/Code/OysterGraphics/Render/Resources.cpp index 696ee6f1..0c5bf592 100644 --- a/Code/OysterGraphics/Render/Resources.cpp +++ b/Code/OysterGraphics/Render/Resources.cpp @@ -340,8 +340,8 @@ 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 }, - { "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,5,GetShader::Vertex(L"Gather"),Gather::Pass.IAStage.Layout); diff --git a/Code/OysterGraphics/Shader/Passes/Gather/Header.hlsli b/Code/OysterGraphics/Shader/Passes/Gather/Header.hlsli index 8747e46d..7584fcd3 100644 --- a/Code/OysterGraphics/Shader/Passes/Gather/Header.hlsli +++ b/Code/OysterGraphics/Shader/Passes/Gather/Header.hlsli @@ -13,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/Tester/MainTest.cpp b/Code/Tester/MainTest.cpp index d30529a8..c3d19f29 100644 --- a/Code/Tester/MainTest.cpp +++ b/Code/Tester/MainTest.cpp @@ -171,14 +171,10 @@ HRESULT InitDirect3D() } m = Oyster::Graphics::API::CreateModel(L"crate_colonists.dan"); - //m->WorldMatrix.m[0][0] = 0.0002f; - //m->WorldMatrix.m[1][1] = 0.0002f; - //m->WorldMatrix.m[2][2] = 0.0002f; 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_orca.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); + //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"); @@ -219,17 +215,10 @@ HRESULT InitDirect3D() float angle = 0; HRESULT Update(float deltaTime) { - //angle += Oyster::Math::pi/16 * deltaTime; m->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0) * angle,Oyster::Math::Float3(0,0,0),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; - ma.m[0][0] = 0.2f; - ma.m[1][1] = 0.2f; - ma.m[2][2] = 0.2f; - //m->WorldMatrix = m->WorldMatrix * ma; Oyster::Graphics::API::Update(deltaTime); - //m2->Animation.data.AnimationTime += deltaTime;// * 0.5f; return S_OK; } @@ -290,14 +279,10 @@ 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; From 3051621f30fe8730b8c2ccd21af25fa136405d10 Mon Sep 17 00:00:00 2001 From: Sam Mario Svensson Date: Fri, 14 Feb 2014 15:18:38 +0100 Subject: [PATCH 16/22] GL- levelLoader can now load a correct spawnpoint --- .../DanBiasGame/GameClientState/GameState.cpp | 7 +++++ .../LevelLoader/LevelParser.cpp | 30 ++++++++++++++----- .../LevelLoader/ObjectDefines.h | 11 ++++++- .../GameLogic/LevelLoader/LevelParser.cpp | 29 +++++++++++++----- .../GameLogic/LevelLoader/ObjectDefines.h | 7 ++++- 5 files changed, 67 insertions(+), 17 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index c86d599d..22194795 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -175,8 +175,15 @@ bool GameState::LoadModels(std::string mapFile) { GameLogic::ObjectTypeHeader* obj = objects.at(i); + switch (obj->typeID) { + + case GameLogic::ObjectType::ObjectType_SpawnPoint: + { + + break; + } case GameLogic::ObjectType::ObjectType_LevelMetaData: 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/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 *************************************/ From c85cecd05a51e2e0d68e3adf1e12e32790865f71 Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Fri, 14 Feb 2014 15:19:10 +0100 Subject: [PATCH 17/22] som more stuff created another version of Quaternion to Angular Axis conversion. --- .../GameClientState/LanMenuState.cpp | 6 ++-- .../GameClientState/LobbyState.cpp | 2 +- .../GameClientState/NetLoadState.cpp | 32 +++++++++++++++++-- .../GameClientState/NetLoadState.h | 9 ++++-- Code/OysterMath/LinearMath.h | 8 +++++ Code/OysterMath/OysterMath.cpp | 6 ++++ Code/OysterMath/OysterMath.h | 3 ++ 7 files changed, 57 insertions(+), 9 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp b/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp index f5699ce5..6a836a36 100644 --- a/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LanMenuState.cpp @@ -121,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; } @@ -135,7 +135,7 @@ 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; } diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp index 96ac9ca5..e3bfa68a 100644 --- a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp @@ -48,7 +48,7 @@ bool LobbyState::Init(NetworkClient* nwClient) // create buttons ButtonRectangle *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 diff --git a/Code/Game/DanBiasGame/GameClientState/NetLoadState.cpp b/Code/Game/DanBiasGame/GameClientState/NetLoadState.cpp index 4c1f711c..e3f419bf 100644 --- a/Code/Game/DanBiasGame/GameClientState/NetLoadState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/NetLoadState.cpp @@ -1,5 +1,6 @@ #include "NetLoadState.h" #include "NetworkClient.h" +#include "../Game/GameProtocols/ProtocolIdentificationID.h" using namespace ::DanBias::Client; using namespace ::Oyster; @@ -10,7 +11,7 @@ struct NetLoadState::MyData MyData() {} GameClientState::ClientState nextState; - NetworkClient *nwClient; + //NetworkClient *nwClient; needed? }; NetLoadState::NetLoadState(void) {} @@ -26,9 +27,12 @@ bool NetLoadState::Init( NetworkClient* nwClient ) this->privData = new MyData(); this->privData->nextState = GameClientState::ClientState_Same; - this->privData->nwClient = nwClient; + //this->privData->nwClient = nwClient; needed? + + // we may assume that nwClient is properly connected to the server + this->privData->nextState = GameClientState::ClientState_Main; return true; } @@ -55,4 +59,28 @@ bool NetLoadState::Release() void NetLoadState::ChangeState( ClientState next ) { this->privData->nextState = next; +} + +void NetLoadState::DataRecieved( NetEvent e ) +{ + CustomNetProtocol data = e.args.data.protocol; + short ID = data[0].value.netShort; // fetching the id data. + + //if( ProtocolIsGameplay(ID) ) + //{ + // switch(ID) + // { + // //case protocol_Gameplay_ObjectPickup: break; /** @todo TODO: implement */ + // default: break; + // } + //} + //else if( ProtocolIsGeneral(ID) ) + //{ + // switch( ID ) + // { + // case protocol_General_Status: break; /** @todo TODO: implement */ + // case protocol_General_Text: break; /** @todo TODO: implement */ + // default: break; + // } + //} } \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/NetLoadState.h b/Code/Game/DanBiasGame/GameClientState/NetLoadState.h index f147bfe8..e2688a4e 100644 --- a/Code/Game/DanBiasGame/GameClientState/NetLoadState.h +++ b/Code/Game/DanBiasGame/GameClientState/NetLoadState.h @@ -10,9 +10,6 @@ namespace DanBias { class NetLoadState : public GameClientState { - private: - struct MyData; - ::Utility::DynamicMemory::UniquePointer privData; public: NetLoadState( ); virtual ~NetLoadState( ); @@ -23,6 +20,12 @@ namespace DanBias 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; }; } } diff --git a/Code/OysterMath/LinearMath.h b/Code/OysterMath/LinearMath.h index a6d48eb2..e0c7bf9f 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 ) + { + ScalarType angle = ScalarType(2) * (ScalarType)::std::acos( rotation.real ), + multiplier = angle / (ScalarType)::std::sqrt( 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..8db4e175 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 ); diff --git a/Code/OysterMath/OysterMath.h b/Code/OysterMath/OysterMath.h index 23ba55ff..8de2759a 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 ); From 911700676c8cbaea47334a568f17040359a5d036 Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Fri, 14 Feb 2014 15:24:19 +0100 Subject: [PATCH 18/22] human error fix --- Code/OysterMath/LinearMath.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/OysterMath/LinearMath.h b/Code/OysterMath/LinearMath.h index e0c7bf9f..23fe0511 100644 --- a/Code/OysterMath/LinearMath.h +++ b/Code/OysterMath/LinearMath.h @@ -377,7 +377,7 @@ namespace LinearAlgebra3D inline ::LinearAlgebra::Vector3 AngularAxis( const ::LinearAlgebra::Quaternion &rotation ) { ScalarType angle = ScalarType(2) * (ScalarType)::std::acos( rotation.real ), - multiplier = angle / (ScalarType)::std::sqrt( rotation.real ); + multiplier = angle / (ScalarType)::std::sqrt( ScalarType(1) - rotation.real * rotation.real ); return multiplier * rotation.imaginary; } From 9096e548a1da729bdedba462fdd4e87b71105d53 Mon Sep 17 00:00:00 2001 From: lanariel Date: Fri, 14 Feb 2014 15:31:38 +0100 Subject: [PATCH 19/22] Text Culling Fix --- Code/OysterGraphics/Render/GuiRenderer.cpp | 2 +- .../Shader/Passes/Post/PostPass.hlsl | 6 ------ Code/Tester/MainTest.cpp | 17 ++++++++++++++++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Code/OysterGraphics/Render/GuiRenderer.cpp b/Code/OysterGraphics/Render/GuiRenderer.cpp index 86f6fe0e..8eda0bf5 100644 --- a/Code/OysterGraphics/Render/GuiRenderer.cpp +++ b/Code/OysterGraphics/Render/GuiRenderer.cpp @@ -92,7 +92,7 @@ namespace Oyster tmpInst.coff=(1.0f/TEXT_NR_LETTERS); tmpInst.offset=text[i]-32; tmpInst.pos=i*(FontSize * 0.7f * TEXT_SPACING); - if(tmpInst.pos > size.x) + if(tmpInst.pos > size.x*2) { text = text.substr(0,i-1); break; diff --git a/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl b/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl index ba835e18..26c9e941 100644 --- a/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl +++ b/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl @@ -21,12 +21,6 @@ float4 SuperSample(float4 Glow, uint3 DTid) index = index / Output.Length; Glow = Ambient.SampleLevel(S1, index,1); Glow = Glow * Glow.w*10; - //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; return Glow; } diff --git a/Code/Tester/MainTest.cpp b/Code/Tester/MainTest.cpp index c3d19f29..e854e1f9 100644 --- a/Code/Tester/MainTest.cpp +++ b/Code/Tester/MainTest.cpp @@ -213,9 +213,10 @@ HRESULT InitDirect3D() return S_OK; } float angle = 0; +float z=0; HRESULT Update(float deltaTime) { - m->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,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::Graphics::API::Update(deltaTime); @@ -285,6 +286,20 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam case 0x58: 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; From 73e9629832f282af3608a6c118386a0e1bc2d4b9 Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Fri, 14 Feb 2014 15:33:17 +0100 Subject: [PATCH 20/22] Removed incorrect Quaternion to AngAxis conversion use Float3 AngularAxis( const Quaternion &rotation ) in ::Oyster::Math3D instead --- .../DanBiasGame/GameClientState/GameState.cpp | 4 +- Code/OysterMath/LinearMath.h | 2 +- Code/OysterMath/OysterMath.cpp | 46 ------------------- Code/OysterMath/OysterMath.h | 6 --- 4 files changed, 3 insertions(+), 55 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index 1bc77921..66ca6c12 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -420,7 +420,7 @@ void GameState::DataRecieved( NetEventmyId == decoded.object_ID ) - camera.SetAngular( QuaternionToAngularAxis(rotation).xyz ); + camera.SetAngular( AngularAxis(rotation) ); int i = FindObject( this->dynamicObjects, decoded.object_ID ); if( i > -1 ) @@ -437,7 +437,7 @@ void GameState::DataRecieved( NetEventmyId == decoded.object_ID ) { camera.SetPosition( position ); - camera.SetAngular( QuaternionToAngularAxis(rotation).xyz ); + camera.SetAngular( AngularAxis(rotation) ); } int i = FindObject( this->dynamicObjects, decoded.object_ID ); diff --git a/Code/OysterMath/LinearMath.h b/Code/OysterMath/LinearMath.h index 23fe0511..25b65331 100644 --- a/Code/OysterMath/LinearMath.h +++ b/Code/OysterMath/LinearMath.h @@ -375,7 +375,7 @@ namespace LinearAlgebra3D 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; diff --git a/Code/OysterMath/OysterMath.cpp b/Code/OysterMath/OysterMath.cpp index 8db4e175..deac2d0b 100644 --- a/Code/OysterMath/OysterMath.cpp +++ b/Code/OysterMath/OysterMath.cpp @@ -102,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 8de2759a..da23e16d 100644 --- a/Code/OysterMath/OysterMath.h +++ b/Code/OysterMath/OysterMath.h @@ -152,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() ); From 26fb7a56649f479cce8de32820bc3155c9e7f506 Mon Sep 17 00:00:00 2001 From: Sam Mario Svensson Date: Fri, 14 Feb 2014 15:36:19 +0100 Subject: [PATCH 21/22] GL- Compile fel med spawnpoint fixat --- Code/Game/GameLogic/Level.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 1b1692d9..6b9081d7 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -108,11 +108,11 @@ Object* Level::createGameObj(ObjectHeader* obj, ICustomBody* rigidBody) gameObj = new Portal(rigidBody, (ObjectSpecialType)obj->specialTypeID, objID++, destination); } break; - case ObjectSpecialType_SpawnPoint: - { + //case ObjectSpecialType_SpawnPoint: + //{ // save - } + //} break; case ObjectSpecialType_Player: { From 2dde8547b7481df1279e784944786aaa4b66a5f9 Mon Sep 17 00:00:00 2001 From: Dander7BD Date: Fri, 14 Feb 2014 17:12:38 +0100 Subject: [PATCH 22/22] Server poking --- .../GameClientState/LobbyAdminState.cpp | 16 +++--- .../GameClientState/LobbyState.cpp | 16 +++--- .../GameClientState/NetLoadState.cpp | 50 +++++++++---------- .../GameClientState/NetLoadState.h | 2 + Code/Game/GameProtocols/LobbyProtocols.h | 34 ++++++++++--- .../GameProtocols/ProtocolIdentificationID.h | 7 +-- Code/Game/GameServer/GameLobby.h | 2 +- .../GameLobby_ProtocolParser.cpp | 6 +-- Code/Game/aDanBiasGameLauncher/Launcher.cpp | 2 +- 9 files changed, 77 insertions(+), 58 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.cpp b/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.cpp index 9416f01e..c157226e 100644 --- a/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.cpp @@ -120,14 +120,14 @@ void LobbyAdminState::DataRecieved( NetEventprivData = new MyData(); this->privData->nextState = GameClientState::ClientState_Same; - //this->privData->nwClient = nwClient; needed? + this->privData->nwClient = nwClient; + this->privData->loading = false; // we may assume that nwClient is properly connected to the server - - - this->privData->nextState = GameClientState::ClientState_Main; + // signals querry to server for loading instructions + nwClient->Send( Protocol_QuerryGameType() ); return true; } @@ -63,24 +65,20 @@ void NetLoadState::ChangeState( ClientState next ) void NetLoadState::DataRecieved( NetEvent e ) { - CustomNetProtocol data = e.args.data.protocol; - short ID = data[0].value.netShort; // fetching the id data. + // fetching the id data. + short ID = e.args.data.protocol[0].value.netShort; - //if( ProtocolIsGameplay(ID) ) - //{ - // switch(ID) - // { - // //case protocol_Gameplay_ObjectPickup: break; /** @todo TODO: implement */ - // default: break; - // } - //} - //else if( ProtocolIsGeneral(ID) ) - //{ - // switch( ID ) - // { - // case protocol_General_Status: break; /** @todo TODO: implement */ - // case protocol_General_Text: break; /** @todo TODO: implement */ - // default: break; - // } - //} -} \ No newline at end of file + 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 index e2688a4e..ff2d1acc 100644 --- a/Code/Game/DanBiasGame/GameClientState/NetLoadState.h +++ b/Code/Game/DanBiasGame/GameClientState/NetLoadState.h @@ -26,6 +26,8 @@ namespace DanBias private: struct MyData; ::Utility::DynamicMemory::UniquePointer privData; + + void LoadGame( const ::std::string &fileName ); }; } } diff --git a/Code/Game/GameProtocols/LobbyProtocols.h b/Code/Game/GameProtocols/LobbyProtocols.h index b57245ba..8e94ff51 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 f9033d5b..c0e19104 100644 --- a/Code/Game/GameProtocols/ProtocolIdentificationID.h +++ b/Code/Game/GameProtocols/ProtocolIdentificationID.h @@ -27,13 +27,14 @@ /********* 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_QuerryGameType 207 #define protocol_LobbyMAX 299 diff --git a/Code/Game/GameServer/GameLobby.h b/Code/Game/GameServer/GameLobby.h index 94cb0e3c..812d1360 100644 --- a/Code/Game/GameServer/GameLobby.h +++ b/Code/Game/GameServer/GameLobby.h @@ -40,7 +40,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 93986650..07ae1f20 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();