From 528a591fabcbd7d1bfb40c7181cc4161251ac17f Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Tue, 11 Feb 2014 11:46:06 +0100 Subject: [PATCH 01/24] GL - almost rotating --- .../DanBiasGame/GameClientState/GameState.cpp | 4 ++-- Code/Game/GameLogic/Game_PlayerData.cpp | 2 +- Code/Game/GameLogic/Object.cpp | 8 ++----- Code/Game/GameLogic/Player.cpp | 21 ++++++++----------- 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index 5214875a..f3ce7b46 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -453,14 +453,14 @@ void GameState::readKeyInput(InputClass* KeyInput) } //send delta mouse movement - //if (KeyInput->IsMousePressed()) + if (KeyInput->IsMousePressed()) { camera->Yaw(-KeyInput->GetYaw()); camera->Pitch(KeyInput->GetPitch()); pitch = KeyInput->GetPitch(); camera->UpdateViewMatrix(); GameLogic::Protocol_PlayerLook playerLookDir; - Oyster::Math::Float4 look = camera->GetLook(); + Oyster::Math::Float4 look = camera->GetRight(); playerLookDir.lookDirX = look.x; playerLookDir.lookDirY = look.y; playerLookDir.lookDirZ = look.z; diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index 15de4399..c8cbc997 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -16,7 +16,7 @@ Game::PlayerData::PlayerData() //create rigid body 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,Level::LevelCollisionBefore, Player::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER); this->player->GetRigidBody()->SetCustomTag(this); diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp index b2b74838..535268b7 100644 --- a/Code/Game/GameLogic/Object.cpp +++ b/Code/Game/GameLogic/Object.cpp @@ -107,13 +107,9 @@ void Object::setAfterCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage Oyster::Math::Float3 Object::GetPosition() { - Oyster::Physics::ICustomBody::State state; - state = this->rigidBody->GetState(); - return state.centerPos; + return (Oyster::Math::Float3) this->rigidBody->GetState().centerPos; } Oyster::Math::Float4x4 Object::GetOrientation() { - Oyster::Physics::ICustomBody::State state; - state = this->rigidBody->GetState(); - return state.GetOrientation(); + return this->rigidBody->GetState().GetOrientation(); } \ No newline at end of file diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index acbb33a9..9e826ef5 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -22,7 +22,6 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type) { InitPlayer(); } - Player::Player(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) :DynamicObject(collisionFuncBefore,collisionFuncAfter,type) { @@ -60,21 +59,14 @@ Player::~Player(void) void Player::BeginFrame() { - weapon->Update(0.002f); + //weapon->Update(0.002f); Object::BeginFrame(); } void Player::EndFrame() { // snap to axis - Object::EndFrame(); - // rotate - - //Oyster::Math::Float3 up = currPhysicsState.GetOrientation().v[1]; - //Oyster::Math::Float3 deltaAxis = up * (-dx * 0.02) ; - - //currPhysicsState.AddRotation(deltaAxis); - + Object::EndFrame(); } void Player::Move(const PLAYER_MOVEMENT &movement) @@ -143,11 +135,12 @@ void Player::Respawn(Oyster::Math::Float3 spawnPoint) this->life = 100; this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE; this->lookDir = Oyster::Math::Float4(1,0,0); - //this->newPhysicsState.centerPos = spawnPoint; + this->rigidBody->SetPosition(spawnPoint); } void Player::Rotate(const Oyster::Math3D::Float4 lookDir) { + // right Oyster::Math::Float dx = lookDir.w; if(dx > 0.0f) { @@ -156,12 +149,16 @@ void Player::Rotate(const Oyster::Math3D::Float4 lookDir) this->lookDir = lookDir.xyz; this->dx = lookDir.w; + + + Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1]; + this->rigidBody->SetUpAndRight(up, lookDir.xyz); } void Player::Jump() { Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1]; - //newPhysicsState.ApplyLinearImpulse(up * MOVE_FORCE * this->gameInstance->GetFrameTime()); + //this->rigidBody->GetState().SetLinearVelocity(up *10); } bool Player::IsWalking() From f0df377bcd9c32fde54e87589eaf6ef48887d291 Mon Sep 17 00:00:00 2001 From: lanariel Date: Tue, 11 Feb 2014 13:29:19 +0100 Subject: [PATCH 02/24] Basic 2d Render + Anim Updates --- .../Definitions/GraphicalDefinition.h | 7 + Code/OysterGraphics/DllInterfaces/GFXAPI.cpp | 20 ++- Code/OysterGraphics/DllInterfaces/GFXAPI.h | 6 + Code/OysterGraphics/OldRender/TextBox.h | 30 +---- Code/OysterGraphics/OysterGraphics.vcxproj | 17 +++ .../OysterGraphics.vcxproj.filters | 3 + .../OysterGraphics/Render/DefaultRenderer.cpp | 17 --- Code/OysterGraphics/Render/DefaultRenderer.h | 3 - Code/OysterGraphics/Render/GuiRenderer.cpp | 121 ++++++++++++++---- Code/OysterGraphics/Render/GuiRenderer.h | 15 +-- Code/OysterGraphics/Render/Resources.cpp | 63 +++++++++ Code/OysterGraphics/Render/Resources.h | 8 +- .../Shader/Passes/2D/Text/2DTextGeometry.hlsl | 29 +++++ .../Shader/Passes/2D/Text/2DTextVertex.hlsl | 6 + .../Shader/Passes/2D/Text/Header.hlsli | 20 +++ Code/Tester/MainTest.cpp | 26 ++-- 16 files changed, 291 insertions(+), 100 deletions(-) create mode 100644 Code/OysterGraphics/Shader/Passes/2D/Text/2DTextGeometry.hlsl create mode 100644 Code/OysterGraphics/Shader/Passes/2D/Text/2DTextVertex.hlsl create mode 100644 Code/OysterGraphics/Shader/Passes/2D/Text/Header.hlsli diff --git a/Code/OysterGraphics/Definitions/GraphicalDefinition.h b/Code/OysterGraphics/Definitions/GraphicalDefinition.h index 7c0d76d7..0b30ee76 100644 --- a/Code/OysterGraphics/Definitions/GraphicalDefinition.h +++ b/Code/OysterGraphics/Definitions/GraphicalDefinition.h @@ -66,6 +66,13 @@ namespace Oyster int x; int y; }; + + struct Text2D + { + float pos; + int offset; + float coff; + }; } } } \ No newline at end of file diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp index 5a92f0de..a175aa58 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp @@ -29,11 +29,10 @@ namespace Oyster { return API::Fail; } + Render::Resources::Gui::Text::Font = (ID3D11ShaderResourceView*)API::CreateTexture(L"font_generic.png"); Render::Resources::Init(); Render::Preparations::Basic::SetViewPort(); - Render::DefaultRenderer::cube = API::CreateModel(L"box.dan"); - Render::DefaultRenderer::cube2 = API::CreateModel(L"box2.dan"); return API::Sucsess; } @@ -111,8 +110,7 @@ namespace Oyster void API::Clean() { - DeleteModel(Render::DefaultRenderer::cube); - DeleteModel(Render::DefaultRenderer::cube2); + DeleteTexture(Render::Resources::Gui::Text::Font); SAFE_DELETE(Core::viewPort); Core::loader.Clean(); Oyster::Graphics::Core::PipelineManager::Clean(); @@ -157,12 +155,12 @@ namespace Oyster void API::StartGuiRender() { - Render::Rendering::Gui::BeginRender(); + Render::Gui::Begin2DRender(); } void API::RenderGuiElement(API::Texture tex, Math::Float2 pos, Math::Float2 size) { - Render::Rendering::Gui::Render((ID3D11ShaderResourceView*)tex,pos,size); + Render::Gui::Render((ID3D11ShaderResourceView*)tex,pos,size); } API::Texture API::CreateTexture(std::wstring filename) @@ -187,5 +185,15 @@ namespace Oyster { deltaTime = dt; } + + void API::StartTextRender() + { + Render::Gui::Begin2DTextRender(); + } + + void API::RenderText(std::wstring text, Math::Float2 Pos, Math::Float2 Size) + { + Render::Gui::RenderText(text,Pos,Size); + } } } \ No newline at end of file diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.h b/Code/OysterGraphics/DllInterfaces/GFXAPI.h index 65f82460..6511fc4d 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.h +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.h @@ -59,6 +59,12 @@ namespace Oyster //! @brief Renders a single GUI element using the texture provided and the Pos in the center, %based system static void RenderGuiElement(Texture, Math::Float2 Pos, Math::Float2 Size); + //! @brief Configures Renderer to process 2D Text, data will be passed in to EndFrame() + static void StartTextRender(); + + //! @brief Renders a single GUI string using the texture provided and the Pos in the center, %based system + static void RenderText(std::wstring, Math::Float2 Pos, Math::Float2 Size); + //! @brief Performs light calculations, post effects and presents the scene static void EndFrame(); diff --git a/Code/OysterGraphics/OldRender/TextBox.h b/Code/OysterGraphics/OldRender/TextBox.h index 6b95dce7..40046210 100644 --- a/Code/OysterGraphics/OldRender/TextBox.h +++ b/Code/OysterGraphics/OldRender/TextBox.h @@ -10,31 +10,6 @@ struct Text2D int offset; float coff; }; -/*struct TextInstanceData -{ - Oyster::Buffer InstanceBuffer; - bool Visible; - int NumLetters; - Oyster::Math::Float4x4 World; -};*/ -/*struct TextData -{ - Oyster::Math::Float3 pos; - Oyster::Math::Float2 uv; -}; - -struct PerCharData -{ - float data; - Oyster::Math::Float3 charOffset; -}; -struct TextInstanceData -{ - Oyster::Buffer InstanceBuffer; - bool Visible; - int NumLetters; - Oyster::Math::Float4x4 World; -};*/ namespace Oyster { @@ -49,9 +24,6 @@ namespace Oyster static HRESULT CreateVertexBuffer(); static HRESULT CreateTextfield(int _id); public: - //static Oyster::Buffer TextBuffer; - //static int NumVertices; - //static std::vector TextInstances; static Buffer TextBuffer; static int NumLetters; static ID3D11ShaderResourceView* Texture; @@ -59,8 +31,10 @@ namespace Oyster static bool Init(); static bool UpdateTextField(std::string _str); static bool SetTexture(const char* _file); + //Updates a textbox with the certain id static void Update(std::string _str, float _scale); + //Removes all old instances and recreates it with the input data static HRESULT Reset(int _count, std::string* _str, Float3* _pos); static void Apply(int _id); diff --git a/Code/OysterGraphics/OysterGraphics.vcxproj b/Code/OysterGraphics/OysterGraphics.vcxproj index c19e073f..fc00bde5 100644 --- a/Code/OysterGraphics/OysterGraphics.vcxproj +++ b/Code/OysterGraphics/OysterGraphics.vcxproj @@ -231,6 +231,22 @@ Vertex Vertex + + Geometry + 4.0 + Geometry + 4.0 + Geometry + 4.0 + Geometry + 4.0 + + + Vertex + Vertex + Vertex + Vertex + Compute Compute @@ -319,6 +335,7 @@ + diff --git a/Code/OysterGraphics/OysterGraphics.vcxproj.filters b/Code/OysterGraphics/OysterGraphics.vcxproj.filters index 4fcaee03..d76a066f 100644 --- a/Code/OysterGraphics/OysterGraphics.vcxproj.filters +++ b/Code/OysterGraphics/OysterGraphics.vcxproj.filters @@ -107,6 +107,8 @@ + + @@ -117,5 +119,6 @@ + \ No newline at end of file diff --git a/Code/OysterGraphics/Render/DefaultRenderer.cpp b/Code/OysterGraphics/Render/DefaultRenderer.cpp index c3b91192..3573ad0a 100644 --- a/Code/OysterGraphics/Render/DefaultRenderer.cpp +++ b/Code/OysterGraphics/Render/DefaultRenderer.cpp @@ -13,8 +13,6 @@ namespace Oyster namespace Render { Definitions::Pointlight pl; - Model::Model* DefaultRenderer::cube = NULL; - Model::Model* DefaultRenderer::cube2 = NULL; void DefaultRenderer::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight Lights, int numLights) { @@ -67,17 +65,11 @@ namespace Oyster if(info->Animated && models[i].Animation.AnimationPlaying != NULL) { models[i].Animation.AnimationTime += deltaTime; - cube->WorldMatrix = Math::Matrix::identity; ////store inverse absolut transform Math::Matrix SkinTransform[100]; Math::Matrix BoneAnimated[100]; Math::Matrix BoneAbsAnimated[100]; - Math::Matrix Scale = Math::Matrix::identity; - Scale.m[0][0] = 1; - Scale.m[1][1] = 1; - Scale.m[2][2] = 2; - for(int b = 0; b BoneCount; ++b) @@ -86,10 +78,6 @@ namespace Oyster SkinTransform[b] = Bone.Absolute.GetInverse(); BoneAnimated[b] = Bone.Relative; BoneAbsAnimated[b] = Bone.Absolute; - - - cube2->WorldMatrix = Scale; - cube2->WorldMatrix.v[3] = info->bones[b].Absolute.v[3]; } int b = 0; Model::Animation A = *models[i].Animation.AnimationPlaying; @@ -127,11 +115,6 @@ namespace Oyster for(int b = 0; b < info->BoneCount; ++b) { BoneAbsAnimated[b] = BoneAbsAnimated[info->bones[b].Parent] * BoneAnimated[b]; - //SkinTransform[b] = BoneAbsAnimated[b]; - cube->WorldMatrix = Scale; - cube->WorldMatrix.v[3] = BoneAbsAnimated[b].v[3]; - cube->WorldMatrix = models[i].WorldMatrix * cube->WorldMatrix; - DefaultRenderer::RenderScene(cube,1,View,Projection); } //write data to am diff --git a/Code/OysterGraphics/Render/DefaultRenderer.h b/Code/OysterGraphics/Render/DefaultRenderer.h index 627998fa..b45f672f 100644 --- a/Code/OysterGraphics/Render/DefaultRenderer.h +++ b/Code/OysterGraphics/Render/DefaultRenderer.h @@ -16,9 +16,6 @@ namespace Oyster static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight Lights, int numLights); static void RenderScene(Model::Model* models, int count, Math::Matrix View, Math::Matrix Projection, float DeltaTime = 0); static void EndFrame(); - - static Model::Model* cube; - static Model::Model* cube2; }; } } diff --git a/Code/OysterGraphics/Render/GuiRenderer.cpp b/Code/OysterGraphics/Render/GuiRenderer.cpp index 62b724cd..0fbda1be 100644 --- a/Code/OysterGraphics/Render/GuiRenderer.cpp +++ b/Code/OysterGraphics/Render/GuiRenderer.cpp @@ -7,37 +7,104 @@ namespace Oyster namespace Graphics { namespace Render - { - namespace Rendering + { + const int TEXT_NR_LETTERS=95; + const float TEXT_SIZE=2.5; + + void Gui::Begin2DRender() { - void Gui::BeginRender() + Core::PipelineManager::SetRenderPass(Render::Resources::Gui::Pass); + } + + void Gui::Render(ID3D11ShaderResourceView* tex,Math::Float2 pos, Math::Float2 size) + { + Core::deviceContext->PSSetShaderResources(0,1,&tex); + + pos *= 2; + pos -= 1; + pos.y *= -1; + + Definitions::GuiData gd; + gd.Translation = Math::Matrix::identity; + gd.Translation.m41 = pos.x; + gd.Translation.m42 = pos.y; + gd.Translation.m11 = size.x; + gd.Translation.m22 = size.y; + + void* data = Render::Resources::Gui::Data.Map(); + memcpy(data,&gd,sizeof(Definitions::GuiData)); + Render::Resources::Gui::Data.Unmap(); + Core::deviceContext->Draw(1,0); + } + + void Gui::Begin2DTextRender() + { + Resources::Gui::Text::Vertex.Apply(); + Core::PipelineManager::SetRenderPass(Resources::Gui::Text::Pass); + } + + void Gui::RenderText(std::wstring text, Math::Float2 pos, Math::Float2 size) + { + //Pos.x -= instance.sizeX/2; + //Pos.x += size.x; + //Pos.y -= instance.sizeY/2; + //Pos.y += size.y; + //Matrix m; + //m = Math::Matrix::identity; + //float width = (1.0f/(instance.sizeX/2.0f)); + //float height = (1.0f/(instance.sizeY/2.0f)); + //m.m41=Pos.x * width; + //m.m42=-Pos.y * height; + //m.m43=Pos.z; + //m.m11=width*size.x; + //m.m22=height*size.y; + //void* dest = Resources::Buffers::CBufferGs.Map(); + //memcpy(dest,&m.GetTranspose(),64); + //Resources::Buffers::CBufferGs.Unmap(); + + //Oyster::Render::Textbox::Update(text, size.x); + //Oyster::Engine::PrepareForRendering::Begin2DTextRender(); + //Oyster::Core::DeviceContext->PSSetShaderResources(0,1,&(Oyster::Render::Textbox::Texture)); + ////Should be able to be outside of the for loop. Keeping it here for now though. + //Oyster::Core::DeviceContext->Draw(Oyster::Render::Textbox::NumLetters, 0); + + pos *= 2; + pos -= 1; + pos.y *= -1; + + Definitions::GuiData gd; + + gd.Translation = Math::Matrix::identity; + gd.Translation.m41 = (pos.x - (size.x/2 * text.length())); + gd.Translation.m42 = pos.y; + gd.Translation.m11 = size.x; + gd.Translation.m22 = size.y; + + + void* data = Render::Resources::Gui::Data.Map(); + memcpy(data,&gd,sizeof(Definitions::GuiData)); + Render::Resources::Gui::Data.Unmap(); + Definitions::Text2D tmpInst; + + void* dest = Resources::Gui::Text::Vertex.Map(); + Definitions::Text2D* dataView = reinterpret_cast(dest); + //tmpInst.charOffset=_pos; + for (unsigned int i=0; iPSSetShaderResources(0,1,&tex); - - pos *= 2; - pos -= 1; - pos.y *= -1; - - Definitions::GuiData gd; - - gd.Translation = Math::Matrix::identity; - gd.Translation.m41 = pos.x; - gd.Translation.m42 = pos.y; - gd.Translation.m11 = size.x; - gd.Translation.m22 = size.y; - - - void* data = Render::Resources::Gui::Data.Map(); - memcpy(data,&gd,sizeof(Definitions::GuiData)); - Render::Resources::Gui::Data.Unmap(); - - Core::deviceContext->Draw(1,0); - } + + Core::deviceContext->Draw(text.length(), 0); } } } diff --git a/Code/OysterGraphics/Render/GuiRenderer.h b/Code/OysterGraphics/Render/GuiRenderer.h index c722ae24..6d865950 100644 --- a/Code/OysterGraphics/Render/GuiRenderer.h +++ b/Code/OysterGraphics/Render/GuiRenderer.h @@ -8,15 +8,14 @@ namespace Oyster { namespace Render { - namespace Rendering + class Gui { - class Gui - { - public: - static void BeginRender(); - static void Render(ID3D11ShaderResourceView* tex, Math::Float2 pos, Math::Float2 size); - }; - } + public: + static void Begin2DRender(); + static void Render(ID3D11ShaderResourceView* tex, Math::Float2 pos, Math::Float2 size); + static void Begin2DTextRender(); + static void RenderText(std::wstring text, Math::Float2 pos, Math::Float2 size); + }; } } } \ No newline at end of file diff --git a/Code/OysterGraphics/Render/Resources.cpp b/Code/OysterGraphics/Render/Resources.cpp index f7b1144d..9f2adbb3 100644 --- a/Code/OysterGraphics/Render/Resources.cpp +++ b/Code/OysterGraphics/Render/Resources.cpp @@ -14,6 +14,9 @@ const std::wstring PathToCSO = L"..\\Content\\Shaders\\"; const int KernelSize = 10; const int SampleSpread = 16; + +const int MAX_LETTER_COUNT=60; + namespace Oyster { namespace Graphics @@ -34,6 +37,7 @@ namespace Oyster Shader::RenderPass Resources::Light::Pass; Shader::RenderPass Resources::Post::Pass; Shader::RenderPass Resources::Gui::Pass; + Shader::RenderPass Resources::Gui::Text::Pass; Shader::RenderPass Resources::Blur::VertPass; //Set this pass second when doing a "fullscreen" blur Shader::RenderPass Resources::Blur::HorPass; //Set this pass first when doing a "fullscreen" blur @@ -41,6 +45,7 @@ namespace Oyster Buffer Resources::Gather::AnimationData = Buffer(); Buffer Resources::Light::LightConstantsData = Buffer(); Buffer Resources::Gui::Data = Buffer(); + Buffer Resources::Gui::Text::Vertex = Buffer(); Buffer Resources::Post::Data = Buffer(); Buffer Resources::Light::PointLightsData = Buffer(); @@ -52,6 +57,9 @@ namespace Oyster ID3D11RasterizerState* Resources::RenderStates::rs = NULL; ID3D11SamplerState** Resources::RenderStates::ss = new ID3D11SamplerState*[1]; ID3D11DepthStencilState* Resources::RenderStates::dsState = NULL; + ID3D11BlendState* Resources::RenderStates::bs = NULL; + + ID3D11ShaderResourceView* Resources::Gui::Text::Font = NULL; Core::Init::State Resources::InitShaders() @@ -85,6 +93,11 @@ namespace Oyster Core::PipelineManager::Init(path + L"2DVertex" + end,ShaderType::Vertex, L"2D"); Core::PipelineManager::Init(path + L"2DGeometry" + end,ShaderType::Geometry, L"2D"); Core::PipelineManager::Init(path + L"2DPixel" + end,ShaderType::Pixel, L"2D"); +#ifdef _DEBUG + path = PathToHLSL+L"2D\\Text\\"; +#endif + Core::PipelineManager::Init(path + L"2DTextVertex" + end,ShaderType::Vertex, L"2DText"); + Core::PipelineManager::Init(path + L"2DTextGeometry" + end,ShaderType::Geometry, L"2DText"); return Core::Init::State::Success; } @@ -121,6 +134,12 @@ namespace Oyster desc.NumElements = MaxLightSize; desc.Type = Buffer::STRUCTURED_BUFFER; Light::PointLightsData.Init(desc); + + desc.Type = Buffer::BUFFER_TYPE::VERTEX_BUFFER; + desc.ElementSize = sizeof(Definitions::Text2D); + desc.NumElements = MAX_LETTER_COUNT; + Gui::Text::Vertex.Init(desc); + return Core::Init::Success; } @@ -178,6 +197,23 @@ namespace Oyster Core::device->CreateDepthStencilState(&ddesc,&RenderStates::dsState); + + D3D11_BLEND_DESC bdesc; + bdesc.AlphaToCoverageEnable = true; + bdesc.IndependentBlendEnable = false; + bdesc.RenderTarget[0].BlendEnable = true; + + bdesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA; + bdesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; + bdesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; + + bdesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; + bdesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ONE; + bdesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_MAX; + + bdesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; + + Core::device->CreateBlendState(&bdesc,&RenderStates::bs); return Core::Init::Success; } @@ -368,6 +404,28 @@ namespace Oyster //And the Ambient UAV is now the output texture Blur::VertPass.UAV.Compute.push_back(LBufferUAV[2]); + ////---------------- 2DText Pass Setup ---------------------------- + Gui::Text::Pass.Shaders.Vertex = GetShader::Vertex(L"2DText"); + Gui::Text::Pass.Shaders.Geometry = GetShader::Geometry(L"2DText"); + Gui::Text::Pass.Shaders.Pixel = GetShader::Pixel(L"2D"); + + Gui::Text::Pass.IAStage.Topology = D3D11_PRIMITIVE_TOPOLOGY_POINTLIST; + + D3D11_INPUT_ELEMENT_DESC Text2Ddesc[] = + { + {"Position",0, DXGI_FORMAT_R32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"Offset",0, DXGI_FORMAT_R32_SINT, 0, 4, D3D11_INPUT_PER_VERTEX_DATA, 0}, + {"CharOffset",0, DXGI_FORMAT_R32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0}, + }; + + Shader::CreateInputLayout(Text2Ddesc,3, GetShader::Vertex(L"2DText") ,Gui::Text::Pass.IAStage.Layout); + Gui::Text::Pass.CBuffers.Geometry.push_back(Gui::Data); + Gui::Text::Pass.SRV.Pixel.push_back(Gui::Text::Font); + Gui::Text::Pass.RTV.push_back(GBufferRTV[2]); + Gui::Text::Pass.RenderStates.SampleCount = 1; + Gui::Text::Pass.RenderStates.SampleState = RenderStates::ss; + Gui::Text::Pass.RenderStates.BlendState = RenderStates::bs; + return Core::Init::Success; } @@ -389,6 +447,7 @@ namespace Oyster Light::LightConstantsData.~Buffer(); Light::PointLightsData.~Buffer(); Gui::Data.~Buffer(); + Gui::Text::Vertex.~Buffer(); Post::Data.~Buffer(); SAFE_RELEASE(Light::PointLightView); SAFE_RELEASE(Light::SSAOKernel); @@ -425,6 +484,10 @@ namespace Oyster SAFE_DELETE_ARRAY(Gather::Pass.RenderStates.SampleState); SAFE_RELEASE(Gui::Pass.IAStage.Layout); + + SAFE_RELEASE(Gui::Text::Pass.RenderStates.BlendState); + + SAFE_RELEASE(Gui::Text::Pass.IAStage.Layout); } } } diff --git a/Code/OysterGraphics/Render/Resources.h b/Code/OysterGraphics/Render/Resources.h index 2d05aab6..cdc12efc 100644 --- a/Code/OysterGraphics/Render/Resources.h +++ b/Code/OysterGraphics/Render/Resources.h @@ -36,6 +36,7 @@ namespace Oyster static ID3D11RasterizerState* rs; static ID3D11SamplerState** ss; static ID3D11DepthStencilState* dsState; + static ID3D11BlendState* bs; }; struct Gather @@ -60,7 +61,12 @@ namespace Oyster { static Core::PipelineManager::RenderPass Pass; static Core::Buffer Data; - static Core::Buffer Vertex; + struct Text + { + static Core::PipelineManager::RenderPass Pass; + static Core::Buffer Vertex; + static ID3D11ShaderResourceView* Font; + }; }; struct Blur diff --git a/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextGeometry.hlsl b/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextGeometry.hlsl new file mode 100644 index 00000000..feefbed7 --- /dev/null +++ b/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextGeometry.hlsl @@ -0,0 +1,29 @@ +#include "Header.hlsli" + +[maxvertexcount(4)] +void main(point Text2DIn input[1],inout TriangleStream Quads) +{ + float startoff=input[0].off*input[0].coff; + float endoff=startoff+input[0].coff; + Pixel2DIn output; + + output.Pos = mul(float4(-1,-1,0,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.x += input[0].Pos; + output.Uv = float2(startoff,0); + Quads.Append(output); + + output.Pos = mul(float4(1,-1,0,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.x += input[0].Pos; + output.Uv = float2(endoff,0); + Quads.Append(output); +} \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextVertex.hlsl b/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextVertex.hlsl new file mode 100644 index 00000000..91497124 --- /dev/null +++ b/Code/OysterGraphics/Shader/Passes/2D/Text/2DTextVertex.hlsl @@ -0,0 +1,6 @@ +#include "Header.hlsli" + +Text2DIn main(Text2DIn input) +{ + return input; +} \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/Passes/2D/Text/Header.hlsli b/Code/OysterGraphics/Shader/Passes/2D/Text/Header.hlsli new file mode 100644 index 00000000..7b64fd79 --- /dev/null +++ b/Code/OysterGraphics/Shader/Passes/2D/Text/Header.hlsli @@ -0,0 +1,20 @@ +#include "../Header.hlsli" +cbuffer TextPerObject : register(c0) +{ + float4x4 gWorld; +}; + +Texture2D g_tex1 : register(t0); + +struct Text2DIn +{ + float Pos : Position; + int off : Offset; + float coff : CharOffset; +}; + +struct TEXT_VS_OUT +{ + float4 pos : SV_POSITION; + float2 texCoord : TEXCOORD; +}; \ No newline at end of file diff --git a/Code/Tester/MainTest.cpp b/Code/Tester/MainTest.cpp index a577f010..c857b320 100644 --- a/Code/Tester/MainTest.cpp +++ b/Code/Tester/MainTest.cpp @@ -158,19 +158,21 @@ HRESULT InitDirect3D() { HRESULT hr = S_OK;; - if(Oyster::Graphics::API::Init(g_hWnd,false,false, Oyster::Math::Float2( 1024, 768 )) == Oyster::Graphics::API::Fail) - { - return E_FAIL; - } + Oyster::Graphics::API::Option o = Oyster::Graphics::API::GetOption(); o.modelPath = L"..\\Content\\Models\\"; o.texturePath = L"..\\Content\\Textures\\"; Oyster::Graphics::API::SetOptions(o); + if(Oyster::Graphics::API::Init(g_hWnd,false,false, Oyster::Math::Float2( 1024, 768 )) == Oyster::Graphics::API::Fail) + { + return E_FAIL; + } + m = Oyster::Graphics::API::CreateModel(L"crate_colonists.dan"); - m2 = Oyster::Graphics::API::CreateModel(L"char_fake_bin.dan"); - m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(0,0,0),Oyster::Math::Float3::null); - Oyster::Graphics::API::PlayAnimation(m2, L"Bend",true); + m2 = Oyster::Graphics::API::CreateModel(L"char_temporary.dan"); + m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(4,0,0),Oyster::Math::Float3::null); + Oyster::Graphics::API::PlayAnimation(m2, L"movement",true); t = Oyster::Graphics::API::CreateTexture(L"structure_corp_mdg.png"); @@ -195,8 +197,8 @@ HRESULT InitDirect3D() float angle = 0; HRESULT Update(float deltaTime) { - angle += Oyster::Math::pi/16 * deltaTime; - m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0)*-angle,Oyster::Math::Float3(0,0,0),Oyster::Math::Float3::null); + //angle += Oyster::Math::pi/16 * deltaTime; + m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3(0,1,0) * angle,Oyster::Math::Float3(4,0,0),Oyster::Math::Float3::null); //Oyster::Math::Matrix ma = Oyster::Math::Matrix::identity; Oyster::Graphics::API::Update(deltaTime); //m2->Animation.data.AnimationTime += deltaTime;// * 0.5f; @@ -211,7 +213,9 @@ HRESULT Render(float deltaTime) Oyster::Graphics::API::RenderModel(m); Oyster::Graphics::API::RenderModel(m2); Oyster::Graphics::API::StartGuiRender(); - Oyster::Graphics::API::RenderGuiElement(t,Oyster::Math::Float2(0.5f,0.5f),Oyster::Math::Float2(0.2f,0.2f)); + Oyster::Graphics::API::RenderGuiElement(t,Oyster::Math::Float2(0.5f,0.5f),Oyster::Math::Float2(0.8f,0.2f)); + Oyster::Graphics::API::StartTextRender(); + Oyster::Graphics::API::RenderText(L"Lanariel Was Here",Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.05f,0.08f)); Oyster::Graphics::API::EndFrame(); return S_OK; @@ -254,10 +258,12 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam //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 d771a5181d24a999ee015fc002a338007e523a1f Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Tue, 11 Feb 2014 13:41:38 +0100 Subject: [PATCH 03/24] GL - rotation and gravity fixed --- .../DanBiasGame/GameClientState/GameState.cpp | 6 +-- Code/Game/GameLogic/Game_PlayerData.cpp | 2 +- Code/Game/GameLogic/Level.cpp | 32 +----------- Code/Game/GameLogic/Object.cpp | 2 +- Code/Game/GameLogic/Player.cpp | 19 ++++--- .../Implementation/GameSession_Gameplay.cpp | 49 ------------------- .../Implementation/GameSession_General.cpp | 4 +- 7 files changed, 17 insertions(+), 97 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index f3ce7b46..2d49da99 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -565,8 +565,6 @@ void GameState::Protocol( ObjPos* pos ) { if(dynamicObjects[i]->GetId() == pos->object_ID) { - - //dynamicObjects[i]->setPos(Float3(world[12], world[13], world[14])); dynamicObjects[i]->setWorld(world); @@ -592,10 +590,10 @@ void GameState::Protocol( ObjPos* pos ) //camera->setUp(up); //camera->setLook(objForward); - up *= 1; + up *= 2; objForward *= -2; Oyster::Math::Float3 cameraPos = pos + up + objForward; - //camera->SetPosition(cameraPos); + camera->SetPosition(cameraPos); //camera->UpdateViewMatrix(); } diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index c8cbc997..6b25c94f 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -16,7 +16,7 @@ Game::PlayerData::PlayerData() //create rigid body 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); + rigidBody->SetAngularFactor(0.0f); //create player with this rigid body this->player = new Player(rigidBody,Level::LevelCollisionBefore, Player::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER); this->player->GetRigidBody()->SetCustomTag(this); diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 06d461fa..e2e52854 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -112,36 +112,8 @@ void Level::InitiateLevel(std::string levelPath) } void Level::InitiateLevel(float radius) { - float heading = Utility::Value::Radian(180.0f); - float attitude = Utility::Value::Radian(0.0f); - float bank = Utility::Value::Radian(0); - - double c1 = cos(heading/2); - double s1 = sin(heading/2); - double c2 = cos(attitude/2); - double s2 = sin(attitude/2); - double c3 = cos(bank/2); - double s3 = sin(bank/2); - double c1c2 = c1*c2; - double s1s2 = s1*s2; - double w =c1c2*c3 - s1s2*s3; - double x =c1c2*s3 + s1s2*c3; - double y =s1*c2*c3 + c1*s2*s3; - double z =c1*s2*c3 - s1*c2*s3; - double angle = 2 * acos(w); - - double norm = x*x+y*y+z*z; - if (norm < 0.001) { // when all euler angles are zero angle =0 so - // we can set axis to anything to avoid divide by zero - x=1; - y=z=0; - } else { - norm = sqrt(norm); - x /= norm; - y /= norm; - z /= norm; - } - + API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0)); + API::Instance().SetGravity(50); int idCount = 100; // add level sphere ICustomBody* rigidBody = API::Instance().AddCollisionSphere(599.2f, Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f); diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp index 535268b7..6fbc8189 100644 --- a/Code/Game/GameLogic/Object.cpp +++ b/Code/Game/GameLogic/Object.cpp @@ -88,7 +88,7 @@ Oyster::Physics::ICustomBody* Object::GetRigidBody() void Object::BeginFrame() { - + } // update physic void Object::EndFrame() diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 9e826ef5..039cae63 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -6,7 +6,7 @@ using namespace GameLogic; using namespace Oyster::Physics; -const int MOVE_FORCE = 500; +const int MOVE_FORCE = 30; Player::Player() :DynamicObject() { @@ -61,6 +61,8 @@ void Player::BeginFrame() { //weapon->Update(0.002f); Object::BeginFrame(); + + } void Player::EndFrame() @@ -98,31 +100,26 @@ void Player::Move(const PLAYER_MOVEMENT &movement) void Player::MoveForward() { Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2]; - //Oyster::Math::Float3 forward = lookDir; - rigidBody->SetLinearVelocity( 10 * forward.GetNormalized() ); + rigidBody->SetLinearVelocity( MOVE_FORCE * forward.GetNormalized() ); } void Player::MoveBackwards() { Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2]; - //Oyster::Math::Float3 forward = lookDir; - rigidBody->SetLinearVelocity( 10 * -forward.GetNormalized() ); + rigidBody->SetLinearVelocity( MOVE_FORCE * -forward.GetNormalized() ); } void Player::MoveRight() { //Do cross product with forward vector and negative gravity vector Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2]; - - //Oyster::Math::Float3 forward = lookDir; Oyster::Math::Float3 r = (-this->rigidBody->GetState().centerPos.Normalize()).Cross(forward); - rigidBody->SetLinearVelocity(r * 10); + rigidBody->SetLinearVelocity(r * MOVE_FORCE); } void Player::MoveLeft() { //Do cross product with forward vector and negative gravity vector Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2]; - //Oyster::Math::Float3 forward = lookDir; Oyster::Math::Float3 r = (-this->rigidBody->GetState().centerPos.Normalize()).Cross(forward); - rigidBody->SetLinearVelocity(-r * 10); + rigidBody->SetLinearVelocity(-r * MOVE_FORCE); } void Player::UseWeapon(const WEAPON_FIRE &usage) @@ -153,6 +150,8 @@ void Player::Rotate(const Oyster::Math3D::Float4 lookDir) Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1]; this->rigidBody->SetUpAndRight(up, lookDir.xyz); + this->rigidBody->SetUpAndRight(this->rigidBody->GetState().centerPos.GetNormalized(), this->rigidBody->GetState().GetOrientation().v[0].xyz.GetNormalized()); + } void Player::Jump() diff --git a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp index b7d11e42..6cf5ec5c 100644 --- a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp @@ -97,59 +97,10 @@ namespace DanBias GameSession::gameSession->networkTimer.reset(); GameLogic::IObjectData* obj = movedObject; - if(movedObject->GetID() == testID) //TODO: TEST - { - float sec = (float)testTimer.getElapsedSeconds(); - sec = 0; - } int id = obj->GetID(); Protocol_ObjectPosition p(obj->GetOrientation(), id); - //if(id != 1) GameSession::gameSession->Send(p.GetProtocol()); - - - /* - if(dynamic_cast(obj)) - { - obj = ((GameLogic::ILevelData*)movedObject)->GetObjectAt(0); - if(obj) - { - if(obj->GetObjectType() == OBJECT_TYPE_WORLD) - { - int id = obj->GetID(); - Oyster::Math::Float4x4 world =obj->GetOrientation(); - - Protocol_ObjectPosition p(world, id); - gameSession->Send(p.GetProtocol()); - } - } - - obj =((GameLogic::ILevelData*)movedObject)->GetObjectAt(1); - if(obj) - { - if(obj->GetObjectType() == OBJECT_TYPE_BOX) - { - int id = obj->GetID(); - Oyster::Math::Float4x4 world = obj->GetOrientation(); - Protocol_ObjectPosition p(world, id); - gameSession->Send(p.GetProtocol()); - } - } - - obj =((GameLogic::ILevelData*)movedObject)->GetObjectAt(2); - if(obj) - { - if(obj->GetObjectType() == OBJECT_TYPE_BOX) - { - int id = obj->GetID(); - Oyster::Math::Float4x4 world = obj->GetOrientation(); - Protocol_ObjectPosition p(world, id); - GameSession::gameSession->Send(p.GetProtocol()); - } - } - } - */ } } diff --git a/Code/Game/GameServer/Implementation/GameSession_General.cpp b/Code/Game/GameServer/Implementation/GameSession_General.cpp index d6e6106c..941c4b6a 100644 --- a/Code/Game/GameServer/Implementation/GameSession_General.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_General.cpp @@ -136,7 +136,7 @@ namespace DanBias } else { - Protocol_LobbyCreateGame p(readyList[i]->GetPlayer()->GetID(), "char_white.dan", readyList[i]->GetPlayer()->GetOrientation()); + Protocol_LobbyCreateGame p(readyList[i]->GetPlayer()->GetID(), "char_temporary.dan", readyList[i]->GetPlayer()->GetOrientation()); readyList[i]->GetClient()->Send(p); } } @@ -156,7 +156,7 @@ namespace DanBias { if((this->clients[k] && readyList[i]) && readyList[i]->GetClient()->GetID() != this->clients[k]->GetClient()->GetID()) { - Protocol_ObjectCreate p(this->clients[k]->GetPlayer()->GetOrientation(), this->clients[k]->GetPlayer()->GetID(), "char_white.dan"); //The model name will be custom later.. + Protocol_ObjectCreate p(this->clients[k]->GetPlayer()->GetOrientation(), this->clients[k]->GetPlayer()->GetID(), "char_temporary.dan"); //The model name will be custom later.. readyList[i]->GetClient()->Send(p); } } From 89189f93d89100c88264b98e3276fa8d3e72c4c4 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Tue, 11 Feb 2014 14:03:14 +0100 Subject: [PATCH 04/24] asd --- Code/Game/GameLogic/Object.cpp | 36 +++++++++++++++++++++++++++++----- Code/Game/GameLogic/Object.h | 14 ++++++++++++- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp index 6fbc8189..6e198e45 100644 --- a/Code/Game/GameLogic/Object.cpp +++ b/Code/Game/GameLogic/Object.cpp @@ -105,11 +105,37 @@ void Object::setAfterCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter)); } -Oyster::Math::Float3 Object::GetPosition() -{ - return (Oyster::Math::Float3) this->rigidBody->GetState().centerPos; -} + Oyster::Math::Float4x4 Object::GetOrientation() { - return this->rigidBody->GetState().GetOrientation(); + Oyster::Physics::ICustomBody::State state; + state = this->rigidBody->GetState(); + return state.GetOrientation(); +} + + +Oyster::Math::Float3 Object::GetPosition() +{ + return this->position; +} +Oyster::Math::Float3 Object::GetRotation() +{ + return this->rotation; +} +Oyster::Math::Float3 Object::GetScaling() +{ + return this->scale; +} + +void Object::SetPosition(Oyster::Math::Float3 position) +{ + this->position = position; +} +void Object::SetRotation(Oyster::Math::Float3 rotation) +{ + this->rotation = rotation; +} +void Object::SetScaling(Oyster::Math::Float3 scale) +{ + this->scale = scale; } \ No newline at end of file diff --git a/Code/Game/GameLogic/Object.h b/Code/Game/GameLogic/Object.h index 1098cb56..6e4b9a81 100644 --- a/Code/Game/GameLogic/Object.h +++ b/Code/Game/GameLogic/Object.h @@ -29,10 +29,17 @@ namespace GameLogic OBJECT_TYPE GetObjectType() const; void setID(int id); int GetID() const; - Oyster::Math::Float3 GetPosition(); Oyster::Math::Float4x4 GetOrientation(); + Oyster::Math::Float3 GetPosition(); + Oyster::Math::Float3 GetRotation(); + Oyster::Math::Float3 GetScaling(); + + void SetPosition(Oyster::Math::Float3 position); + void SetRotation(Oyster::Math::Float3 rotation); + void SetScaling(Oyster::Math::Float3 scale); + Oyster::Physics::ICustomBody* GetRigidBody(); void ApplyLinearImpulse(Oyster::Math::Float3 force); @@ -55,6 +62,11 @@ namespace GameLogic static const Game* gameInstance; Oyster::Math::Float3 currLook; Oyster::Math::Float3 newLook; + + Oyster::Math::Float3 position; + Oyster::Math::Float3 rotation; + Oyster::Math::Float3 scale; + }; } From 696d6997f637d58dd30848cbc3b1a67cab0116ad Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Tue, 11 Feb 2014 14:13:35 +0100 Subject: [PATCH 05/24] GL - Button system done, only need to add 2d rendering to it. --- Code/Game/DanBiasGame/DanBiasGame.vcxproj | 3 + Code/Game/DanBiasGame/DanBiasGame_Impl.cpp | 3 + .../GameClientState/Buttons/ButtonCircle.h | 62 ++++++++++++++++++ .../GameClientState/Buttons/ButtonRectangle.h | 57 +++++++++++++++++ .../GameClientState/Buttons/EventButtonGUI.h | 64 +++++++++++++++++++ .../GameClientState/LoginState.cpp | 34 ++++++++++ .../DanBiasGame/GameClientState/LoginState.h | 4 ++ Code/Misc/EventHandler/EventButton.h | 8 +++ Code/Misc/EventHandler/EventButtonCircle.h | 64 ------------------- .../EventHandler/EventButtonCollection.cpp | 11 ++++ .../Misc/EventHandler/EventButtonCollection.h | 7 +- Code/Misc/EventHandler/EventButtonRectangle.h | 60 ----------------- Code/Misc/EventHandler/EventHandler.cpp | 13 ++-- Code/Misc/EventHandler/EventHandler.h | 6 +- Code/Misc/EventHandler/IEventButton.h | 10 ++- Code/Misc/Misc.vcxproj | 2 - Code/Misc/Misc.vcxproj.filters | 6 -- 17 files changed, 265 insertions(+), 149 deletions(-) create mode 100644 Code/Game/DanBiasGame/GameClientState/Buttons/ButtonCircle.h create mode 100644 Code/Game/DanBiasGame/GameClientState/Buttons/ButtonRectangle.h create mode 100644 Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h delete mode 100644 Code/Misc/EventHandler/EventButtonCircle.h delete mode 100644 Code/Misc/EventHandler/EventButtonRectangle.h diff --git a/Code/Game/DanBiasGame/DanBiasGame.vcxproj b/Code/Game/DanBiasGame/DanBiasGame.vcxproj index 83806118..2a02099a 100644 --- a/Code/Game/DanBiasGame/DanBiasGame.vcxproj +++ b/Code/Game/DanBiasGame/DanBiasGame.vcxproj @@ -215,6 +215,9 @@ + + + diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index ccb80d85..e987edc0 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -141,6 +141,9 @@ namespace DanBias HRESULT DanBiasGame::Update(float deltaTime) { + //Update menu buttons + EventHandler::Instance().Update(m_data->inputObj); + m_data->inputObj->Update(); if(m_data->serverOwner) diff --git a/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonCircle.h b/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonCircle.h new file mode 100644 index 00000000..f399382d --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonCircle.h @@ -0,0 +1,62 @@ +////////////////////////////////////// +// Created by Pontus Fransson 2014 // +////////////////////////////////////// + +#ifndef DANBIAS_CLIENT_BUTTON_CIRCLE_H +#define DANBIAS_CLIENT_BUTTON_CIRCLE_H + +#include "EventButtonGUI.h" + +namespace DanBias +{ + namespace Client + { + template + class ButtonCircle : public EventButtonGUI + { + public: + ButtonCircle() + : EventButtonGUI(), radius(0) + {} + ButtonCircle(std::wstring textureName, Owner owner, float xPos, float yPos, float radius, float textureHalfWidth, float textureHalfHeight) + : EventButtonGUI(textureName, owner, xPos, yPos, textureHalfWidth, textureHalfHeight), radius(radius) + {} + ButtonCircle(std::wstring textureName, EventFunc func, float xPos, float yPos, float radius, float textureHalfWidth, float textureHalfHeight) + : EventButtonGUI(textureName, func, xPos, yPos, textureHalfWidth, textureHalfHeight), radius(radius) + {} + ButtonCircle(std::wstring textureName, EventFunc func, Owner owner, float xPos, float yPos, float radius, float textureHalfWidth, float textureHalfHeight) + : EventButtonGUI(textureName, func, owner, xPos, yPos, textureHalfWidth, textureHalfHeight), radius(radius) + {} + ButtonCircle(std::wstring textureName, EventFunc func, Owner owner, void* userData, float xPos, float yPos, float radius, float textureHalfWidth, float textureHalfHeight) + : EventButtonGUI(textureName, func, owner, userData, xPos, yPos, textureHalfWidth, textureHalfHeight), radius(radius) + {} + ~ButtonCircle() + {} + + //Circle vs point collision + bool Collision(InputClass* inputObject) + { + //Should come from the InputClass + float xMouse = 2, yMouse = 2; + + float xDiff = xMouse - xPos; + float yDiff = yMouse - yPos; + + float length = (xDiff * xDiff) + (yDiff * yDiff); + + if(length <= radius*radius) + { + return true; + } + + return false; + } + + protected: + float radius; + + }; + } +} + +#endif \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonRectangle.h b/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonRectangle.h new file mode 100644 index 00000000..a77f5346 --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonRectangle.h @@ -0,0 +1,57 @@ +////////////////////////////////////// +// Created by Pontus Fransson 2014 // +////////////////////////////////////// + +#ifndef DANBIAS_CLIENT_BUTTON_RECTANGLE_H +#define DANBIAS_CLIENT_BUTTON_RECTANGLE_H + +#include "EventButtonGUI.h" + +namespace DanBias +{ + namespace Client + { + template + class ButtonRectangle : public EventButtonGUI + { + public: + ButtonRectangle() + : EventButtonGUI(), halfWidth(0), halfHeight(0) + {} + ButtonRectangle(std::wstring textureName, Owner owner, float xPos, float yPos, float halfWidth, float halfHeight) + : EventButtonGUI(textureName, owner, xPos, yPos, halfWidth, halfHeight) + {} + ButtonRectangle(std::wstring textureName, EventFunc func, float xPos, float yPos, float halfWidth, float halfHeight) + : EventButtonGUI(textureName, func, xPos, yPos, halfWidth, halfHeight) + {} + ButtonRectangle(std::wstring textureName, EventFunc func, Owner owner, float xPos, float yPos, float halfWidth, float halfHeight) + : EventButtonGUI(textureName, func, owner, xPos, yPos, halfWidth, halfHeight) + {} + ButtonRectangle(std::wstring textureName, EventFunc func, Owner owner, void* userData, float xPos, float yPos, float halfWidth, float halfHeight) + : EventButtonGUI(textureName, func, owner, userData, xPos, yPos, halfWidth, halfHeight) + {} + ~ButtonRectangle() + {} + + //Circle vs point collision + bool Collision(InputClass* inputObject) + { + //Should come from the InputClass + float xMouse = 1, yMouse = 0; + + if(xMouse >= xPos - halfWidth && xMouse <= xPos + halfWidth + && yMouse >= yPos - halfHeight && yMouse <= yPos + halfHeight) + { + return true; + } + + return false; + } + + protected: + + }; + } +} + +#endif \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h b/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h new file mode 100644 index 00000000..598d594d --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h @@ -0,0 +1,64 @@ +////////////////////////////////////// +// Created by Pontus Fransson 2014 // +////////////////////////////////////// + +#ifndef DANBIAS_CLIENT_EVENT_BUTTON_GUI_H +#define DANBIAS_CLIENT_EVENT_BUTTON_GUI_H + +#include "../Misc/EventHandler/EventButton.h" + +namespace DanBias +{ + namespace Client + { + template + class EventButtonGUI : public Oyster::Event::EventButton + { + public: + EventButtonGUI() + : EventButton(), xPos(0), yPos(0), halfWidth(0), halfHeight(0), texture(NULL) + {} + EventButtonGUI(std::wstring textureName, Owner owner, float xPos, float yPos, float halfWidth, float halfHeight) + : EventButton(owner), xPos(xPos), yPos(yPos), halfWidth(halfWidth), halfHeight(halfHeight) + { + CreateTexture(textureName); + } + EventButtonGUI(std::wstring textureName, EventFunc func, float xPos, float yPos, float halfWidth, float halfHeight) + : EventButton(func), xPos(xPos), yPos(yPos), halfWidth(halfWidth), halfHeight(halfHeight) + { + CreateTexture(textureName); + } + EventButtonGUI(std::wstring textureName, EventFunc func, Owner owner, float xPos, float yPos, float halfWidth, float halfHeight) + : EventButton(func, owner), xPos(xPos), yPos(yPos), halfWidth(halfWidth), halfHeight(halfHeight) + { + CreateTexture(textureName); + } + EventButtonGUI(std::wstring textureName, EventFunc func, Owner owner, void* userData, float xPos, float yPos, float halfWidth, float halfHeight) + : EventButton(func, owner, userData), xPos(xPos), yPos(yPos), halfWidth(halfWidth), halfHeight(halfHeight) + { + CreateTexture(textureName); + } + ~EventButtonGUI() + {} + + void CreateTexture(std::wstring textureName) + { + //Create texture + } + + virtual void Render() + { + //Render att xPos and yPos + //With halfWidth and halfHeight + } + + protected: + float xPos, yPos; + float halfWidth, halfHeight; + void* texture; + + }; + } +} + +#endif \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/LoginState.cpp b/Code/Game/DanBiasGame/GameClientState/LoginState.cpp index 7fed3b5a..0a655e1f 100644 --- a/Code/Game/DanBiasGame/GameClientState/LoginState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LoginState.cpp @@ -19,9 +19,43 @@ struct LoginState::myData // game client* }privData; +#include "Buttons\ButtonCircle.h" +#include "Buttons\ButtonRectangle.h" +#include "../Misc/EventHandler/EventHandler.h" +using namespace Oyster::Event; + +enum TestEnum +{ + Create, + Options, + Exit, +}; + LoginState::LoginState(void) { + EventButtonCollection* collection = new EventButtonCollection; + EventHandler::Instance().AddCollection(collection); + collection->AddButton(new ButtonRectangle(L"textureName.jpg", &LoginState::ButtonCallback, this, (void*)Options, 0.0f, 0.0f, 0.0f, 0.0f)); +} + +void LoginState::ButtonCallback(Oyster::Event::ButtonEvent& e) +{ + TestEnum type = TestEnum((int)e.userData); + + switch(type) + { + case Create: + if(e.state == ButtonState_Released) + { + //Change to create state or something similar + } + break; + case Options: + break; + case Exit: + break; + } } LoginState::~LoginState(void) diff --git a/Code/Game/DanBiasGame/GameClientState/LoginState.h b/Code/Game/DanBiasGame/GameClientState/LoginState.h index d426187d..280012a9 100644 --- a/Code/Game/DanBiasGame/GameClientState/LoginState.h +++ b/Code/Game/DanBiasGame/GameClientState/LoginState.h @@ -5,6 +5,8 @@ #include "OysterMath.h" #include "NetworkClient.h" #include +#include "../Misc/EventHandler/EventButton.h" + namespace DanBias { namespace Client @@ -24,6 +26,8 @@ namespace DanBias bool InitCamera(Oyster::Math::Float3 startPos); ClientState Update(float deltaTime, InputClass* KeyInput); + static void ButtonCallback(Oyster::Event::ButtonEvent& e); + bool Render(); bool Release(); void Protocol(ProtocolStruct* protocol)override; diff --git a/Code/Misc/EventHandler/EventButton.h b/Code/Misc/EventHandler/EventButton.h index 64215da2..636552cc 100644 --- a/Code/Misc/EventHandler/EventButton.h +++ b/Code/Misc/EventHandler/EventButton.h @@ -62,6 +62,7 @@ namespace Oyster void SendEvent(ButtonState state); //Set + void SetEnabled(bool enable); void SetUserData(void* data); void SetEventFunc(EventFunc func); void SetOwner(Owner owner); @@ -206,6 +207,13 @@ namespace Oyster } } + //Set if the button should be updated and collided with. + template + void EventButton::SetEnabled(bool enable) + { + this->privData.enabled = enable; + } + template void EventButton::SetUserData(void* data) { diff --git a/Code/Misc/EventHandler/EventButtonCircle.h b/Code/Misc/EventHandler/EventButtonCircle.h deleted file mode 100644 index 3a298acb..00000000 --- a/Code/Misc/EventHandler/EventButtonCircle.h +++ /dev/null @@ -1,64 +0,0 @@ -////////////////////////////////////// -// Created by Pontus Fransson 2014 // -////////////////////////////////////// - -#ifndef MISC_EVENT_BUTTON_CIRCLE_H -#define MISC_EVENT_BUTTON_CIRCLE_H - -#include "EventButton.h" -#include "../../Input/L_inputClass.h" - -namespace Oyster -{ - namespace Event - { - template - class EventButtonCircle : public EventButton - { - public: - EventButtonCircle() - : EventButton(), xPos(0), yPos(0), radius(0) - {} - EventButtonCircle(Owner owner, float xPos, float yPos, float radius) - : EventButton(owner), xPos(xPos), yPos(yPos), radius(radius) - {} - EventButtonCircle(void (*EventFunc)( Oyster::Event::ButtonEvent& e), float xPos, float yPos, float radius) - : EventButton(EventFunc), xPos(xPos), yPos(yPos), radius(radius) - {} - EventButtonCircle(void (*EventFunc)( Oyster::Event::ButtonEvent& e), Owner owner, float xPos, float yPos, float radius) - : EventButton(EventFunc, owner), xPos(xPos), yPos(yPos), radius(radius) - {} - EventButtonCircle(void (*EventFunc)( Oyster::Event::ButtonEvent& e), Owner owner, void* userData, float xPos, float yPos, float radius) - : EventButton(EventFunc, owner, userData), xPos(xPos), yPos(yPos), radius(radius) - {} - ~EventButtonCircle() - {} - - //Circle vs point collision - bool Collision(InputClass* inputObject) - { - //Should come from the InputClass - float xMouse = 2, yMouse = 2; - - float xDiff = xMouse - xPos; - float yDiff = yMouse - yPos; - - float length = (xDiff * xDiff) + (yDiff * yDiff); - - if(length <= radius*radius) - { - return true; - } - - return false; - } - - private: - float xPos, yPos; - float radius; - - }; - } -} - -#endif \ No newline at end of file diff --git a/Code/Misc/EventHandler/EventButtonCollection.cpp b/Code/Misc/EventHandler/EventButtonCollection.cpp index 6a77c520..4096bd44 100644 --- a/Code/Misc/EventHandler/EventButtonCollection.cpp +++ b/Code/Misc/EventHandler/EventButtonCollection.cpp @@ -34,6 +34,17 @@ void EventButtonCollection::Update(InputClass* inputObject) } } +void EventButtonCollection::Render() +{ + if(this->collectionState == EventCollectionState_Enabled) + { + for(int i = 0; i < (int)buttons.size(); i++) + { + buttons[i]->Render(); + } + } +} + EventCollectionState EventButtonCollection::GetState() const { return collectionState; diff --git a/Code/Misc/EventHandler/EventButtonCollection.h b/Code/Misc/EventHandler/EventButtonCollection.h index 0cc77b42..56bb3d27 100644 --- a/Code/Misc/EventHandler/EventButtonCollection.h +++ b/Code/Misc/EventHandler/EventButtonCollection.h @@ -27,6 +27,10 @@ namespace Oyster EventCollectionState_Unknown = -1, }; + /******************************** + This EventButtonCollection will handle the destruction of the buttons when they are added to the collection. + + ********************************/ class EventButtonCollection { public: @@ -34,6 +38,7 @@ namespace Oyster ~EventButtonCollection(); void Update(InputClass* inputObject); + void Render(); template void AddButton(EventButton* button) @@ -47,7 +52,7 @@ namespace Oyster //Clear all buttons and reset the state. void Clear(); - private: + protected: std::vector buttons; EventCollectionState collectionState; diff --git a/Code/Misc/EventHandler/EventButtonRectangle.h b/Code/Misc/EventHandler/EventButtonRectangle.h deleted file mode 100644 index fc917437..00000000 --- a/Code/Misc/EventHandler/EventButtonRectangle.h +++ /dev/null @@ -1,60 +0,0 @@ -////////////////////////////////////// -// Created by Pontus Fransson 2014 // -////////////////////////////////////// - -#ifndef MISC_EVENT_BUTTON_RECTANGLE_H -#define MISC_EVENT_BUTTON_RECTANGLE_H - -#include "EventButton.h" -#include "../../Input/L_inputClass.h" - -namespace Oyster -{ - namespace Event - { - template - class EventButtonRectangle : public EventButton - { - public: - EventButtonRectangle() - : EventButton(), xPos(0), yPos(0), halfWidth(0), halfHeight(0) - {} - EventButtonRectangle(Owner owner, float xPos, float yPos, float halfWidth, float halfHeight) - : EventButton(owner), xPos(xPos), yPos(yPos), halfWidth(halfWidth), halfHeight(halfHeight) - {} - EventButtonRectangle(void (*EventFunc)( Oyster::Event::ButtonEvent& e), float xPos, float yPos, float halfWidth, float halfHeight) - : EventButton(EventFunc), xPos(xPos), yPos(yPos), halfWidth(halfWidth), halfHeight(halfHeight) - {} - EventButtonRectangle(void (*EventFunc)( Oyster::Event::ButtonEvent& e), Owner owner, float xPos, float yPos, float halfWidth, float halfHeight) - : EventButton(EventFunc, owner), xPos(xPos), yPos(yPos), halfWidth(halfWidth), halfHeight(halfHeight) - {} - EventButtonRectangle(void (*EventFunc)( Oyster::Event::ButtonEvent& e), Owner owner, void* userData, float xPos, float yPos, float halfWidth, float halfHeight) - : EventButton(EventFunc, owner, userData), xPos(xPos), yPos(yPos), halfWidth(halfWidth), halfHeight(halfHeight) - {} - ~EventButtonRectangle() - {} - - //Circle vs point collision - bool Collision(InputClass* inputObject) - { - //Should come from the InputClass - float xMouse = 1, yMouse = 0; - - if(xMouse >= xPos - halfWidth && xMouse <= xPos + halfWidth - && yMouse >= yPos - halfHeight && yMouse <= yPos + halfHeight) - { - return true; - } - - return false; - } - - private: - float xPos, yPos; - float halfWidth, halfHeight; - - }; - } -} - -#endif \ No newline at end of file diff --git a/Code/Misc/EventHandler/EventHandler.cpp b/Code/Misc/EventHandler/EventHandler.cpp index a7347075..7c7f7722 100644 --- a/Code/Misc/EventHandler/EventHandler.cpp +++ b/Code/Misc/EventHandler/EventHandler.cpp @@ -34,14 +34,15 @@ void EventHandler::Update(InputClass* inputObject) } } -void EventHandler::AddCollection(EventButtonCollection& collection) +void EventHandler::Render() { - collections.push_back(&collection); + for(int i = 0; i < (int)collections.size(); i++) + { + collections.at(i)->Render(); + } } -EventButtonCollection& EventHandler::CreateCollection() +void EventHandler::AddCollection(EventButtonCollection* collection) { - EventButtonCollection* temp = new EventButtonCollection; - collections.push_back(temp); - return *temp; + collections.push_back(collection); } \ No newline at end of file diff --git a/Code/Misc/EventHandler/EventHandler.h b/Code/Misc/EventHandler/EventHandler.h index 4ca1a9ab..c58d628d 100644 --- a/Code/Misc/EventHandler/EventHandler.h +++ b/Code/Misc/EventHandler/EventHandler.h @@ -9,8 +9,6 @@ #include "EventButtonCollection.h" #include "EventButton.h" -#include "EventButtonCircle.h" -#include "EventButtonRectangle.h" #include @@ -27,9 +25,9 @@ namespace Oyster static EventHandler& Instance(); void Update(InputClass* inputObject); + void Render(); - void AddCollection(EventButtonCollection& collection); - EventButtonCollection& CreateCollection(); + void AddCollection(EventButtonCollection* collection); private: std::vector collections; diff --git a/Code/Misc/EventHandler/IEventButton.h b/Code/Misc/EventHandler/IEventButton.h index 901a8265..13e6f21b 100644 --- a/Code/Misc/EventHandler/IEventButton.h +++ b/Code/Misc/EventHandler/IEventButton.h @@ -25,14 +25,12 @@ namespace Oyster public: virtual ~IEventButton(){} - virtual void Update(InputClass *input){} + virtual void Render() = 0; + virtual void Update(InputClass *input) = 0; - virtual void SendEvent(ButtonState state){} - - struct ButtonEvent; - virtual void SetEventFunc(void (*EventFunc)( ButtonEvent e )){} + virtual void SendEvent(ButtonState state) = 0; - virtual unsigned int GetID(){ return -1; } + virtual unsigned int GetID() = 0; }; } diff --git a/Code/Misc/Misc.vcxproj b/Code/Misc/Misc.vcxproj index 593de858..efb3cc48 100644 --- a/Code/Misc/Misc.vcxproj +++ b/Code/Misc/Misc.vcxproj @@ -167,9 +167,7 @@ - - diff --git a/Code/Misc/Misc.vcxproj.filters b/Code/Misc/Misc.vcxproj.filters index c50f2804..edcf0e99 100644 --- a/Code/Misc/Misc.vcxproj.filters +++ b/Code/Misc/Misc.vcxproj.filters @@ -134,11 +134,5 @@ Header Files - - Header Files - - - Header Files - \ No newline at end of file From 1725f05c4bd9662d8fcea27a578b2f84b952e58c Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Tue, 11 Feb 2014 15:06:46 +0100 Subject: [PATCH 06/24] GUI - GUI testing. --- .../GameClientState/Buttons/EventButtonGUI.h | 7 +++-- .../GameClientState/LoginState.cpp | 29 +++++++++++++------ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h b/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h index 598d594d..9519a586 100644 --- a/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h +++ b/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h @@ -48,8 +48,11 @@ namespace DanBias virtual void Render() { - //Render att xPos and yPos - //With halfWidth and halfHeight + if(EventButton::Enabled()) + { + //Render att xPos and yPos + //With halfWidth and halfHeight + } } protected: diff --git a/Code/Game/DanBiasGame/GameClientState/LoginState.cpp b/Code/Game/DanBiasGame/GameClientState/LoginState.cpp index 0a655e1f..05c766b9 100644 --- a/Code/Game/DanBiasGame/GameClientState/LoginState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LoginState.cpp @@ -8,6 +8,12 @@ using namespace DanBias::Client; +//Menu buttons +#include "Buttons/ButtonCircle.h" +#include "Buttons/ButtonRectangle.h" +#include "../Misc/EventHandler/EventHandler.h" +using namespace Oyster::Event; + struct LoginState::myData { myData(){} @@ -17,12 +23,12 @@ struct LoginState::myData int modelCount; // UI object // game client* + + //Menu button collection + EventButtonCollection* collection; + }privData; -#include "Buttons\ButtonCircle.h" -#include "Buttons\ButtonRectangle.h" -#include "../Misc/EventHandler/EventHandler.h" -using namespace Oyster::Event; enum TestEnum { @@ -33,10 +39,6 @@ enum TestEnum LoginState::LoginState(void) { - EventButtonCollection* collection = new EventButtonCollection; - EventHandler::Instance().AddCollection(collection); - - collection->AddButton(new ButtonRectangle(L"textureName.jpg", &LoginState::ButtonCallback, this, (void*)Options, 0.0f, 0.0f, 0.0f, 0.0f)); } void LoginState::ButtonCallback(Oyster::Event::ButtonEvent& e) @@ -68,8 +70,14 @@ bool LoginState::Init(Oyster::Network::NetworkClient* nwClient) privData = new myData(); this->nwClient = nwClient; // load models - LoadModels(L"UImodels.txt"); + //LoadModels(L"UImodels.txt"); InitCamera(Oyster::Math::Float3(0,0,5.4f)); + + //Create menu buttons + privData->collection = new EventButtonCollection; + EventHandler::Instance().AddCollection(privData->collection); + privData->collection->AddButton(new ButtonRectangle(L"textureName.jpg", &LoginState::ButtonCallback, this, (void*)Options, 0.0f, 0.0f, 0.0f, 0.0f)); + return true; } bool LoginState::LoadModels(std::wstring file) @@ -172,6 +180,9 @@ bool LoginState::Render() // render lights + //Render buttons + EventHandler::Instance().Render(); + Oyster::Graphics::API::EndFrame(); return true; } From 474744c72a5a25cb5ab44d30599c0239c7b67606 Mon Sep 17 00:00:00 2001 From: lanariel Date: Wed, 12 Feb 2014 08:24:24 +0100 Subject: [PATCH 07/24] Fixed wierd ambience, 2DText Render and Lighting --- Code/OysterGraphics/DllInterfaces/GFXAPI.cpp | 6 ++-- .../OysterGraphics/Render/DefaultRenderer.cpp | 17 +++++----- Code/OysterGraphics/Render/DefaultRenderer.h | 2 +- Code/OysterGraphics/Render/GuiRenderer.cpp | 34 +++++-------------- Code/OysterGraphics/Render/Resources.cpp | 4 +-- .../Shader/Passes/Post/PostPass.hlsl | 2 +- Code/Tester/MainTest.cpp | 33 +++++++++++++++--- 7 files changed, 54 insertions(+), 44 deletions(-) diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp index a175aa58..51ea20a2 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp @@ -50,11 +50,11 @@ namespace Oyster { if(Lights.size()) { - Render::DefaultRenderer::NewFrame(View, Projection, Lights[0], (int)Lights.size()); + Render::DefaultRenderer::NewFrame(View, Projection, &Lights[0], (int)Lights.size()); } else { - Render::DefaultRenderer::NewFrame(View, Projection, Definitions::Pointlight(), 0); + Render::DefaultRenderer::NewFrame(View, Projection, NULL, 0); } } @@ -178,7 +178,7 @@ namespace Oyster m->Animation.AnimationPlaying = &(*m->info->Animations.find(name)).second; m->Animation.AnimationTime=0; m->Animation.LoopAnimation = looping; - return m->Animation.AnimationPlaying->duration; + return (float)m->Animation.AnimationPlaying->duration; } void API::Update(float dt) diff --git a/Code/OysterGraphics/Render/DefaultRenderer.cpp b/Code/OysterGraphics/Render/DefaultRenderer.cpp index 3573ad0a..2ad8646b 100644 --- a/Code/OysterGraphics/Render/DefaultRenderer.cpp +++ b/Code/OysterGraphics/Render/DefaultRenderer.cpp @@ -14,11 +14,12 @@ namespace Oyster { Definitions::Pointlight pl; - void DefaultRenderer::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight Lights, int numLights) + void DefaultRenderer::NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight* Lights, int numLights) { Preparations::Basic::ClearBackBuffer(Oyster::Math::Float4(1,0,0,1)); Preparations::Basic::ClearRTV(Resources::GBufferRTV,Resources::GBufferSize,Math::Float4(0,0,0,0)); Core::PipelineManager::SetRenderPass(Graphics::Render::Resources::Gather::Pass); + Lights[1]; void* data; @@ -35,12 +36,12 @@ namespace Oyster Resources::Light::LightConstantsData.Unmap(); data = Resources::Light::PointLightsData.Map(); - memcpy(data, &Lights, sizeof(Definitions::Pointlight) * numLights); + memcpy(data, Lights, sizeof(Definitions::Pointlight) * numLights); Resources::Light::PointLightsData.Unmap(); Definitions::PostData pd; - pd.x = lc.Pixels.x; - pd.y = lc.Pixels.y; + pd.x = (int)lc.Pixels.x; + pd.y = (int)lc.Pixels.y; data = Resources::Post::Data.Map(); memcpy(data, &pd, sizeof(Definitions::PostData)); @@ -164,11 +165,11 @@ namespace Oyster Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1); - Core::PipelineManager::SetRenderPass(Resources::Blur::HorPass); - Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1); + //Core::PipelineManager::SetRenderPass(Resources::Blur::HorPass); + //Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1); - Core::PipelineManager::SetRenderPass(Resources::Blur::VertPass); - Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1); + //Core::PipelineManager::SetRenderPass(Resources::Blur::VertPass); + //Core::deviceContext->Dispatch((UINT)((Core::resolution.x + 15U) / 16U), (UINT)((Core::resolution.y + 15U) / 16U), 1); Core::PipelineManager::SetRenderPass(Resources::Post::Pass); diff --git a/Code/OysterGraphics/Render/DefaultRenderer.h b/Code/OysterGraphics/Render/DefaultRenderer.h index b45f672f..1a5cdcc0 100644 --- a/Code/OysterGraphics/Render/DefaultRenderer.h +++ b/Code/OysterGraphics/Render/DefaultRenderer.h @@ -13,7 +13,7 @@ namespace Oyster class DefaultRenderer { public: - static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight Lights, int numLights); + static void NewFrame(Oyster::Math::Float4x4 View, Oyster::Math::Float4x4 Projection, Definitions::Pointlight* Lights, int numLights); static void RenderScene(Model::Model* models, int count, Math::Matrix View, Math::Matrix Projection, float DeltaTime = 0); static void EndFrame(); }; diff --git a/Code/OysterGraphics/Render/GuiRenderer.cpp b/Code/OysterGraphics/Render/GuiRenderer.cpp index 0fbda1be..ee114898 100644 --- a/Code/OysterGraphics/Render/GuiRenderer.cpp +++ b/Code/OysterGraphics/Render/GuiRenderer.cpp @@ -9,7 +9,7 @@ namespace Oyster namespace Render { const int TEXT_NR_LETTERS=95; - const float TEXT_SIZE=2.5; + const float TEXT_SPACING=1.8f; void Gui::Begin2DRender() { @@ -45,37 +45,21 @@ namespace Oyster void Gui::RenderText(std::wstring text, Math::Float2 pos, Math::Float2 size) { - //Pos.x -= instance.sizeX/2; - //Pos.x += size.x; - //Pos.y -= instance.sizeY/2; - //Pos.y += size.y; - //Matrix m; - //m = Math::Matrix::identity; - //float width = (1.0f/(instance.sizeX/2.0f)); - //float height = (1.0f/(instance.sizeY/2.0f)); - //m.m41=Pos.x * width; - //m.m42=-Pos.y * height; - //m.m43=Pos.z; - //m.m11=width*size.x; - //m.m22=height*size.y; - //void* dest = Resources::Buffers::CBufferGs.Map(); - //memcpy(dest,&m.GetTranspose(),64); - //Resources::Buffers::CBufferGs.Unmap(); - - //Oyster::Render::Textbox::Update(text, size.x); - //Oyster::Engine::PrepareForRendering::Begin2DTextRender(); - //Oyster::Core::DeviceContext->PSSetShaderResources(0,1,&(Oyster::Render::Textbox::Texture)); - ////Should be able to be outside of the for loop. Keeping it here for now though. - //Oyster::Core::DeviceContext->Draw(Oyster::Render::Textbox::NumLetters, 0); + + size.x = size.x / (text.length() * TEXT_SPACING /2); + pos *= 2; pos -= 1; pos.y *= -1; + + pos.x = pos.x - (size.x * (text.length()-1) * TEXT_SPACING /2); + Definitions::GuiData gd; gd.Translation = Math::Matrix::identity; - gd.Translation.m41 = (pos.x - (size.x/2 * text.length())); + gd.Translation.m41 = pos.x; gd.Translation.m42 = pos.y; gd.Translation.m11 = size.x; gd.Translation.m22 = size.y; @@ -93,7 +77,7 @@ namespace Oyster { tmpInst.coff=(1.0f/TEXT_NR_LETTERS); tmpInst.offset=text[i]-32; - tmpInst.pos=i*(size.x*2); + tmpInst.pos=i*(size.x * TEXT_SPACING); //float tst=getCharID(_str[i]); //tmpInst.offset=tst; //tmpInst.charOffset.x=_pos.x-i*TEXT_SIZE; diff --git a/Code/OysterGraphics/Render/Resources.cpp b/Code/OysterGraphics/Render/Resources.cpp index 9f2adbb3..6ccc480b 100644 --- a/Code/OysterGraphics/Render/Resources.cpp +++ b/Code/OysterGraphics/Render/Resources.cpp @@ -163,8 +163,8 @@ namespace Oyster D3D11_SAMPLER_DESC sdesc; sdesc.Filter = D3D11_FILTER_ANISOTROPIC; - sdesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP; - sdesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP; + sdesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP; + sdesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP; sdesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP; sdesc.MipLODBias = 0; sdesc.MaxAnisotropy =4; diff --git a/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl b/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl index b219bd28..247efb42 100644 --- a/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl +++ b/Code/OysterGraphics/Shader/Passes/Post/PostPass.hlsl @@ -17,7 +17,7 @@ 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 GUI; - uint2 index = DTid.xy/2 + int2(Pixels.x/2,0); + uint2 index = DTid.xy/2 + uint2(Pixels.x/2,0); float3 PostLight = Amb.xyz * AmbFactor; PostLight = PostLight + Light.xyz; GUI = float4(Ambient[index]); diff --git a/Code/Tester/MainTest.cpp b/Code/Tester/MainTest.cpp index c857b320..cd614f42 100644 --- a/Code/Tester/MainTest.cpp +++ b/Code/Tester/MainTest.cpp @@ -21,6 +21,7 @@ Oyster::Graphics::Model::Model* m = NULL; Oyster::Graphics::Model::Model* m2 = NULL; Oyster::Graphics::Model::Model* m3 = NULL; Oyster::Graphics::API::Texture t = NULL; +Oyster::Graphics::API::Texture t2 = NULL; Oyster::Math::Float4x4 V; Oyster::Math::Float4x4 P; Oyster::Graphics::Definitions::Pointlight pl; @@ -170,11 +171,15 @@ HRESULT InitDirect3D() } m = Oyster::Graphics::API::CreateModel(L"crate_colonists.dan"); + m->WorldMatrix.m[0][0] = 50; + m->WorldMatrix.m[1][1] = 50; + m->WorldMatrix.m[2][2] = 0.00000005f; m2 = Oyster::Graphics::API::CreateModel(L"char_temporary.dan"); m2->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); t = Oyster::Graphics::API::CreateTexture(L"structure_corp_mdg.png"); + t2 = Oyster::Graphics::API::CreateTexture(L"whiteGui.png"); P = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/2,1280.0f/720.0f,.1f,10000); Oyster::Graphics::API::SetProjection(P); @@ -184,9 +189,23 @@ HRESULT InitDirect3D() - pl.Color = Oyster::Math::Float3(1,0,1); + pl.Color = Oyster::Math::Float3(1,0,0); pl.Bright = 1; - pl.Pos = Oyster::Math::Float3(0,-20.0f,0.4f); + pl.Pos = Oyster::Math::Float3(-20,0,0); + pl.Radius = 90; + + Oyster::Graphics::API::AddLight(pl); + + pl.Color = Oyster::Math::Float3(0,1,0); + pl.Bright = 1; + pl.Pos = Oyster::Math::Float3(0,20,0); + pl.Radius = 90; + + Oyster::Graphics::API::AddLight(pl); + + pl.Color = Oyster::Math::Float3(0,0,1); + pl.Bright = 1; + pl.Pos = Oyster::Math::Float3(0,0,20); pl.Radius = 90; Oyster::Graphics::API::AddLight(pl); @@ -213,9 +232,15 @@ HRESULT Render(float deltaTime) Oyster::Graphics::API::RenderModel(m); Oyster::Graphics::API::RenderModel(m2); Oyster::Graphics::API::StartGuiRender(); - Oyster::Graphics::API::RenderGuiElement(t,Oyster::Math::Float2(0.5f,0.5f),Oyster::Math::Float2(0.8f,0.2f)); + Oyster::Graphics::API::RenderGuiElement(t,Oyster::Math::Float2(0.5f,0.5f),Oyster::Math::Float2(1,1)); + Oyster::Graphics::API::RenderGuiElement(t2,Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f)); Oyster::Graphics::API::StartTextRender(); - Oyster::Graphics::API::RenderText(L"Lanariel Was Here",Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.05f,0.08f)); + std::wstring fps; + float f = 1/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::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f)); Oyster::Graphics::API::EndFrame(); return S_OK; From ebf313ccd64999f2451728641c1dbf6b0f03ecc9 Mon Sep 17 00:00:00 2001 From: lanariel Date: Wed, 12 Feb 2014 08:35:21 +0100 Subject: [PATCH 08/24] 2D transparancy --- Code/OysterGraphics/Render/Resources.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Code/OysterGraphics/Render/Resources.cpp b/Code/OysterGraphics/Render/Resources.cpp index 6ccc480b..e0a0aa79 100644 --- a/Code/OysterGraphics/Render/Resources.cpp +++ b/Code/OysterGraphics/Render/Resources.cpp @@ -389,6 +389,7 @@ namespace Oyster Gui::Pass.RenderStates.SampleCount = 1; Gui::Pass.RenderStates.SampleState = RenderStates::ss; + Gui::Pass.RenderStates.BlendState = RenderStates::bs; ////---------------- Blur Pass Setup ---------------------------- Blur::HorPass.Shaders.Compute = GetShader::Compute(L"BlurHor"); From d0955b2f4ef31af65e07d82652f744a07bac6da1 Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Wed, 12 Feb 2014 09:08:38 +0100 Subject: [PATCH 09/24] GL - Button delete update. --- Code/Game/DanBiasGame/DanBiasGame.vcxproj | 2 +- Code/Game/DanBiasGame/DanBiasGame_Impl.cpp | 8 +- .../GameClientState/Buttons/ButtonCircle.h | 62 ---------------- .../GameClientState/Buttons/ButtonEllipse.h | 63 ++++++++++++++++ .../GameClientState/Buttons/ButtonRectangle.h | 43 +++++++---- .../GameClientState/Buttons/EventButtonGUI.h | 59 +++++++++++---- .../GameClientState/LoginState.cpp | 73 +++++++++++++++++-- Code/Misc/EventHandler/EventButton.h | 23 +++++- .../EventHandler/EventButtonCollection.cpp | 10 ++- Code/Misc/EventHandler/EventHandler.cpp | 23 ++++++ Code/Misc/EventHandler/EventHandler.h | 5 +- 11 files changed, 267 insertions(+), 104 deletions(-) delete mode 100644 Code/Game/DanBiasGame/GameClientState/Buttons/ButtonCircle.h create mode 100644 Code/Game/DanBiasGame/GameClientState/Buttons/ButtonEllipse.h diff --git a/Code/Game/DanBiasGame/DanBiasGame.vcxproj b/Code/Game/DanBiasGame/DanBiasGame.vcxproj index 2a02099a..5049b6e7 100644 --- a/Code/Game/DanBiasGame/DanBiasGame.vcxproj +++ b/Code/Game/DanBiasGame/DanBiasGame.vcxproj @@ -215,7 +215,7 @@ - + diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index 587a3df1..2a9bb5da 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -59,8 +59,8 @@ namespace DanBias { WindowShell::CreateConsoleWindow(); - //if(! m_data->window->CreateWin(WindowShell::WINDOW_INIT_DESC(L"Window", cPOINT(1600, 900), cPOINT()))) - if(! m_data->window->CreateWin(WindowShell::WINDOW_INIT_DESC())) + if(! m_data->window->CreateWin(WindowShell::WINDOW_INIT_DESC(L"Window", cPOINT(1024, 768), cPOINT()))) + //if(! m_data->window->CreateWin(WindowShell::WINDOW_INIT_DESC())) return DanBiasClientReturn_Error; if( FAILED( InitDirect3D() ) ) @@ -132,7 +132,7 @@ namespace DanBias HRESULT DanBiasGame::InitInput() { m_data->inputObj = new InputClass; - if(!m_data->inputObj->Initialize(m_data->window->GetHINSTANCE(), m_data->window->GetHWND(), m_data->window->GetHeight(), m_data->window->GetWidth())) + if(!m_data->inputObj->Initialize(m_data->window->GetHINSTANCE(), m_data->window->GetHWND(), m_data->window->GetWidth(), m_data->window->GetHeight())) { MessageBox(0, L"Could not initialize the input object.", L"Error", MB_OK); return E_FAIL; @@ -207,6 +207,8 @@ namespace DanBias delete m_data->inputObj; delete m_data; + EventHandler::Instance().Clean(); + Oyster::Graphics::API::Clean(); GameServerAPI::ServerStop(); diff --git a/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonCircle.h b/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonCircle.h deleted file mode 100644 index f399382d..00000000 --- a/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonCircle.h +++ /dev/null @@ -1,62 +0,0 @@ -////////////////////////////////////// -// Created by Pontus Fransson 2014 // -////////////////////////////////////// - -#ifndef DANBIAS_CLIENT_BUTTON_CIRCLE_H -#define DANBIAS_CLIENT_BUTTON_CIRCLE_H - -#include "EventButtonGUI.h" - -namespace DanBias -{ - namespace Client - { - template - class ButtonCircle : public EventButtonGUI - { - public: - ButtonCircle() - : EventButtonGUI(), radius(0) - {} - ButtonCircle(std::wstring textureName, Owner owner, float xPos, float yPos, float radius, float textureHalfWidth, float textureHalfHeight) - : EventButtonGUI(textureName, owner, xPos, yPos, textureHalfWidth, textureHalfHeight), radius(radius) - {} - ButtonCircle(std::wstring textureName, EventFunc func, float xPos, float yPos, float radius, float textureHalfWidth, float textureHalfHeight) - : EventButtonGUI(textureName, func, xPos, yPos, textureHalfWidth, textureHalfHeight), radius(radius) - {} - ButtonCircle(std::wstring textureName, EventFunc func, Owner owner, float xPos, float yPos, float radius, float textureHalfWidth, float textureHalfHeight) - : EventButtonGUI(textureName, func, owner, xPos, yPos, textureHalfWidth, textureHalfHeight), radius(radius) - {} - ButtonCircle(std::wstring textureName, EventFunc func, Owner owner, void* userData, float xPos, float yPos, float radius, float textureHalfWidth, float textureHalfHeight) - : EventButtonGUI(textureName, func, owner, userData, xPos, yPos, textureHalfWidth, textureHalfHeight), radius(radius) - {} - ~ButtonCircle() - {} - - //Circle vs point collision - bool Collision(InputClass* inputObject) - { - //Should come from the InputClass - float xMouse = 2, yMouse = 2; - - float xDiff = xMouse - xPos; - float yDiff = yMouse - yPos; - - float length = (xDiff * xDiff) + (yDiff * yDiff); - - if(length <= radius*radius) - { - return true; - } - - return false; - } - - protected: - float radius; - - }; - } -} - -#endif \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonEllipse.h b/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonEllipse.h new file mode 100644 index 00000000..e74d4233 --- /dev/null +++ b/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonEllipse.h @@ -0,0 +1,63 @@ +////////////////////////////////////// +// Created by Pontus Fransson 2014 // +////////////////////////////////////// + +#ifndef DANBIAS_CLIENT_BUTTON_CIRCLE_H +#define DANBIAS_CLIENT_BUTTON_CIRCLE_H + +#include "EventButtonGUI.h" + +//Only for testing because we don't have any other input +#include "../WindowManager/WindowShell.h" + +namespace DanBias +{ + namespace Client + { + template + class ButtonEllipse : public EventButtonGUI + { + public: + ButtonEllipse() + : EventButtonGUI(), radius(0) + {} + ButtonEllipse(std::wstring textureName, Owner owner, float xPos, float yPos, float textureWidth, float textureHeight) + : EventButtonGUI(textureName, owner, xPos, yPos, textureWidth, textureHeight) + {} + ButtonEllipse(std::wstring textureName, EventFunc func, float xPos, float yPos, float textureWidth, float textureHeight) + : EventButtonGUI(textureName, func, xPos, yPos, textureWidth, textureHeight) + {} + ButtonEllipse(std::wstring textureName, EventFunc func, Owner owner, float xPos, float yPos, float textureWidth, float textureHeight) + : EventButtonGUI(textureName, func, owner, xPos, yPos, textureWidth, textureHeight) + {} + ButtonEllipse(std::wstring textureName, EventFunc func, Owner owner, void* userData, float xPos, float yPos, float textureWidth, float textureHeight) + : EventButtonGUI(textureName, func, owner, userData, xPos, yPos, textureWidth, textureHeight) + {} + virtual ~ButtonEllipse() + {} + + //Circle vs point collision + bool Collision(InputClass* inputObject) + { + POINT p; + GetCursorPos(&p); + ScreenToClient(WindowShell::GetHWND(), &p); + RECT r; + GetClientRect(WindowShell::GetHWND(), &r); + + //Should come from the InputClass + float xMouse = (float)p.x / (float)r.right, yMouse = (float)p.y / (float)r.bottom; + + double normx = (xMouse - xPos) / width; + double normy = (yMouse - yPos) / height; + + return (normx * normx + normy * normy) < 0.25; + } + + protected: + + }; + } +} + +#endif \ No newline at end of file diff --git a/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonRectangle.h b/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonRectangle.h index a77f5346..1c725211 100644 --- a/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonRectangle.h +++ b/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonRectangle.h @@ -6,6 +6,9 @@ #define DANBIAS_CLIENT_BUTTON_RECTANGLE_H #include "EventButtonGUI.h" +#include +//Only for testing because we don't have any other input +#include "../WindowManager/WindowShell.h" namespace DanBias { @@ -16,31 +19,43 @@ namespace DanBias { public: ButtonRectangle() - : EventButtonGUI(), halfWidth(0), halfHeight(0) + : EventButtonGUI(), width(0), height(0) {} - ButtonRectangle(std::wstring textureName, Owner owner, float xPos, float yPos, float halfWidth, float halfHeight) - : EventButtonGUI(textureName, owner, xPos, yPos, halfWidth, halfHeight) + ButtonRectangle(std::wstring textureName, Owner owner, float xPos, float yPos, float width, float height) + : EventButtonGUI(textureName, owner, xPos, yPos, width, height) {} - ButtonRectangle(std::wstring textureName, EventFunc func, float xPos, float yPos, float halfWidth, float halfHeight) - : EventButtonGUI(textureName, func, xPos, yPos, halfWidth, halfHeight) + ButtonRectangle(std::wstring textureName, EventFunc func, float xPos, float yPos, float width, float height) + : EventButtonGUI(textureName, func, xPos, yPos, width, height) {} - ButtonRectangle(std::wstring textureName, EventFunc func, Owner owner, float xPos, float yPos, float halfWidth, float halfHeight) - : EventButtonGUI(textureName, func, owner, xPos, yPos, halfWidth, halfHeight) + ButtonRectangle(std::wstring textureName, EventFunc func, Owner owner, float xPos, float yPos, float width, float height) + : EventButtonGUI(textureName, func, owner, xPos, yPos, width, height) {} - ButtonRectangle(std::wstring textureName, EventFunc func, Owner owner, void* userData, float xPos, float yPos, float halfWidth, float halfHeight) - : EventButtonGUI(textureName, func, owner, userData, xPos, yPos, halfWidth, halfHeight) + ButtonRectangle(std::wstring textureName, EventFunc func, Owner owner, void* userData, float xPos, float yPos, float width, float height) + : EventButtonGUI(textureName, func, owner, userData, xPos, yPos, width, height) {} - ~ButtonRectangle() + virtual ~ButtonRectangle() {} //Circle vs point collision bool Collision(InputClass* inputObject) { - //Should come from the InputClass - float xMouse = 1, yMouse = 0; + POINT p; + RECT r; + GetCursorPos(&p); + ScreenToClient(WindowShell::GetHWND(), &p); + GetClientRect(WindowShell::GetHWND(), &r); - if(xMouse >= xPos - halfWidth && xMouse <= xPos + halfWidth - && yMouse >= yPos - halfHeight && yMouse <= yPos + halfHeight) + //Should come from the InputClass + float xMouse = (float)p.x / (float)r.right, yMouse = (float)p.y / (float)r.bottom; + + float widthTemp = xPos - width * 0.5f; + float widthTemp2 = xPos + width * 0.5f; + float heightTemp = yPos - height * 0.5f; + float heightTemp2 = yPos + height * 0.5f; + //std::cout << p.x << ' ' << p.y << ' ' << widthTemp << ' ' << heightTemp << std::endl; + + if(xMouse >= widthTemp && xMouse <= widthTemp2 && + yMouse >= heightTemp && yMouse <= heightTemp2) { return true; } diff --git a/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h b/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h index 9519a586..7e2de14f 100644 --- a/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h +++ b/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h @@ -6,6 +6,7 @@ #define DANBIAS_CLIENT_EVENT_BUTTON_GUI_H #include "../Misc/EventHandler/EventButton.h" +#include "../OysterGraphics/DllInterfaces/GFXAPI.h" namespace DanBias { @@ -16,49 +17,79 @@ namespace DanBias { public: EventButtonGUI() - : EventButton(), xPos(0), yPos(0), halfWidth(0), halfHeight(0), texture(NULL) + : EventButton(), xPos(0), yPos(0), width(0), height(0), texture(NULL) {} - EventButtonGUI(std::wstring textureName, Owner owner, float xPos, float yPos, float halfWidth, float halfHeight) - : EventButton(owner), xPos(xPos), yPos(yPos), halfWidth(halfWidth), halfHeight(halfHeight) + EventButtonGUI(std::wstring textureName, Owner owner, float xPos, float yPos, float width, float height) + : EventButton(owner), xPos(xPos), yPos(yPos), width(width), height(height), texture(NULL) { CreateTexture(textureName); } - EventButtonGUI(std::wstring textureName, EventFunc func, float xPos, float yPos, float halfWidth, float halfHeight) - : EventButton(func), xPos(xPos), yPos(yPos), halfWidth(halfWidth), halfHeight(halfHeight) + EventButtonGUI(std::wstring textureName, EventFunc func, float xPos, float yPos, float width, float height) + : EventButton(func), xPos(xPos), yPos(yPos), width(width), height(height), texture(NULL) { CreateTexture(textureName); } - EventButtonGUI(std::wstring textureName, EventFunc func, Owner owner, float xPos, float yPos, float halfWidth, float halfHeight) - : EventButton(func, owner), xPos(xPos), yPos(yPos), halfWidth(halfWidth), halfHeight(halfHeight) + EventButtonGUI(std::wstring textureName, EventFunc func, Owner owner, float xPos, float yPos, float width, float height) + : EventButton(func, owner), xPos(xPos), yPos(yPos), width(width), height(height), texture(NULL) { CreateTexture(textureName); } - EventButtonGUI(std::wstring textureName, EventFunc func, Owner owner, void* userData, float xPos, float yPos, float halfWidth, float halfHeight) - : EventButton(func, owner, userData), xPos(xPos), yPos(yPos), halfWidth(halfWidth), halfHeight(halfHeight) + EventButtonGUI(std::wstring textureName, EventFunc func, Owner owner, void* userData, float xPos, float yPos, float width, float height) + : EventButton(func, owner, userData), xPos(xPos), yPos(yPos), width(width), height(height), texture(NULL) { CreateTexture(textureName); } - ~EventButtonGUI() - {} + virtual ~EventButtonGUI() + { + Oyster::Graphics::API::DeleteTexture(texture); + Oyster::Graphics::API::DeleteTexture(texture2); + Oyster::Graphics::API::DeleteTexture(texture3); + texture = NULL; + texture2 = NULL; + texture3 = NULL; + } void CreateTexture(std::wstring textureName) { + std::wstring file = L".png"; + //Create texture + texture = Oyster::Graphics::API::CreateTexture(textureName + std::wstring(L"none") + file); + texture2 = Oyster::Graphics::API::CreateTexture(textureName + std::wstring(L"highlight") + file); + texture3 = Oyster::Graphics::API::CreateTexture(textureName + std::wstring(L"down") + file); } virtual void Render() { + if(EventButton::Enabled()) { //Render att xPos and yPos - //With halfWidth and halfHeight + //With width and height + + if(EventButton::GetState() == ButtonState_None) + { + Oyster::Graphics::API::RenderGuiElement(texture, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height)); + } + else if(EventButton::GetState() == ButtonState_Hover) + { + Oyster::Graphics::API::RenderGuiElement(texture2, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height)); + } + else + { + Oyster::Graphics::API::RenderGuiElement(texture3, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height)); + } + } } protected: float xPos, yPos; - float halfWidth, halfHeight; - void* texture; + float width, height; + Oyster::Graphics::API::Texture texture; + Oyster::Graphics::API::Texture texture2; + Oyster::Graphics::API::Texture texture3; + }; } diff --git a/Code/Game/DanBiasGame/GameClientState/LoginState.cpp b/Code/Game/DanBiasGame/GameClientState/LoginState.cpp index a2f5a197..4f148624 100644 --- a/Code/Game/DanBiasGame/GameClientState/LoginState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LoginState.cpp @@ -9,7 +9,7 @@ using namespace DanBias::Client; //Menu buttons -#include "Buttons/ButtonCircle.h" +#include "Buttons/ButtonEllipse.h" #include "Buttons/ButtonRectangle.h" #include "../Misc/EventHandler/EventHandler.h" using namespace Oyster::Event; @@ -27,6 +27,7 @@ struct LoginState::myData //Menu button collection EventButtonCollection* collection; + int testNumber; }privData; @@ -34,6 +35,8 @@ enum TestEnum { Create, Options, + Incr, + Decr, Exit, }; @@ -48,15 +51,46 @@ void LoginState::ButtonCallback(Oyster::Event::ButtonEvent& e) switch(type) { case Create: - if(e.state == ButtonState_Released) + /*if(e.state == ButtonState_None) + { + int a = 0; + std::cout << "None" << std::endl; + } + else if(e.state == ButtonState_Hover) + { + int a = 0; + std::cout << "Hover" << std::endl; + } + else if(e.state == ButtonState_Down) + { + int a = 0; + std::cout << "Down" << std::endl; + } + else if(e.state == ButtonState_Pressed) + { + int a = 0; + std::cout << "Pressed" << std::endl; + } + else if(e.state == ButtonState_Released) { //Change to create state or something similar - } + int a = 0; + std::cout << "Released" << std::endl; + }*/ break; case Options: break; case Exit: break; + + case Incr: + if(e.state == ButtonState_Released) + e.owner->privData->testNumber++; + break; + case Decr: + if(e.state == ButtonState_Released) + e.owner->privData->testNumber--; + break; } } @@ -68,7 +102,7 @@ LoginState::~LoginState(void) bool LoginState::Init(Oyster::Network::NetworkClient* nwClient) { privData = new myData(); - this->nwClient = nwClient; + this->nwClient = nwClient; // load models //LoadModels(L"UImodels.txt"); InitCamera(Oyster::Math::Float3(0,0,5.4f)); @@ -76,7 +110,23 @@ bool LoginState::Init(Oyster::Network::NetworkClient* nwClient) //Create menu buttons privData->collection = new EventButtonCollection; EventHandler::Instance().AddCollection(privData->collection); - privData->collection->AddButton(new ButtonRectangle(L"textureName.jpg", &LoginState::ButtonCallback, this, (void*)Options, 0.0f, 0.0f, 0.0f, 0.0f)); + privData->collection->AddButton(new ButtonEllipse(L"circle_", &LoginState::ButtonCallback, this, (void*)Create, 0.2f, 0.2f, 0.1f, 0.2f)); + privData->collection->AddButton(new ButtonEllipse(L"circle_", &LoginState::ButtonCallback, this, (void*)Create, 0.2f, 0.3f, 0.1f, 0.2f)); + privData->collection->AddButton(new ButtonEllipse(L"circle_", &LoginState::ButtonCallback, this, (void*)Create, 0.2f, 0.4f, 0.1f, 0.2f)); + privData->collection->AddButton(new ButtonEllipse(L"circle_", &LoginState::ButtonCallback, this, (void*)Create, 0.2f, 0.5f, 0.1f, 0.2f)); + + privData->collection->AddButton(new ButtonRectangle(L"button_", &LoginState::ButtonCallback, this, (void*)Create, 0.15f, 0.05f, 0.1f, 0.1f)); + privData->collection->AddButton(new ButtonRectangle(L"button_", &LoginState::ButtonCallback, this, (void*)Create, 0.25f, 0.05f, 0.1f, 0.1f)); + privData->collection->AddButton(new ButtonRectangle(L"button_", &LoginState::ButtonCallback, this, (void*)Create, 0.35f, 0.05f, 0.1f, 0.1f)); + privData->collection->AddButton(new ButtonRectangle(L"button_", &LoginState::ButtonCallback, this, (void*)Create, 0.45f, 0.05f, 0.1f, 0.1f)); + + privData->collection->AddButton(new ButtonRectangle(L"button_", &LoginState::ButtonCallback, this, (void*)Create, 0.5f, 0.5f, 0.3f, 0.3f)); + + //Incr/decr buttons + privData->collection->AddButton(new ButtonRectangle(L"button_", &LoginState::ButtonCallback, this, (void*)Incr, 0.85f, 0.2f, 0.1f, 0.1f)); + privData->collection->AddButton(new ButtonRectangle(L"button_", &LoginState::ButtonCallback, this, (void*)Decr, 0.55f, 0.2f, 0.1f, 0.1f)); + + privData->testNumber = 0; return true; } @@ -146,6 +196,7 @@ GameClientState::ClientState LoginState::Update(float deltaTime, InputClass* Key // failed to connect return ClientState_Same; } + privData->collection->SetState(EventCollectionState_Disabled); return ClientState_LobbyCreated; } // join game @@ -159,6 +210,7 @@ GameClientState::ClientState LoginState::Update(float deltaTime, InputClass* Key // failed to connect return ClientState_Same; } + privData->collection->SetState(EventCollectionState_Disabled); return ClientState_Lobby; } return ClientState_Same; @@ -181,8 +233,16 @@ bool LoginState::Render(float dt) // render lights //Render buttons + Oyster::Graphics::API::StartGuiRender(); EventHandler::Instance().Render(); + std::wstring number; + wchar_t temp[10]; + _itow_s(privData->testNumber, temp, 10); + number = temp; + Oyster::Graphics::API::StartTextRender(); + Oyster::Graphics::API::RenderText(number, Oyster::Math::Float2(0.7, 0.2), Oyster::Math::Float2(0.1, 0.1)); + Oyster::Graphics::API::EndFrame(); return true; } @@ -196,6 +256,9 @@ bool LoginState::Release() privData->object[i] = NULL; } + delete privData->collection; + //EventHandler::Instance().DeleteCollection(privData->collection); + delete privData; privData = NULL; return true; diff --git a/Code/Misc/EventHandler/EventButton.h b/Code/Misc/EventHandler/EventButton.h index 636552cc..6a220845 100644 --- a/Code/Misc/EventHandler/EventButton.h +++ b/Code/Misc/EventHandler/EventButton.h @@ -54,7 +54,7 @@ namespace Oyster EventButton(EventFunc func); EventButton(EventFunc func, Owner owner); EventButton(EventFunc func, Owner owner, void* userData); - ~EventButton(); + virtual ~EventButton(); void Update(InputClass *input); @@ -72,6 +72,7 @@ namespace Oyster unsigned int GetID(); //EventFunc GetFunctionPointer(); Owner GetOwner(); + ButtonState GetState(); bool operator ==(const EventButton& obj); @@ -139,7 +140,8 @@ namespace Oyster if(this->privData.enabled) { ButtonState currentState = ButtonState_None; - + static bool outside = false; + static bool clicked = false; if(Collision(input)) { if(input->IsMousePressed()) @@ -148,12 +150,19 @@ namespace Oyster switch(this->privData.previousState) { case ButtonState_None: + outside = true; currentState = ButtonState_Hover; break; case ButtonState_Hover: case ButtonState_Released: - currentState = ButtonState_Pressed; + if(outside == false) + { + clicked = true; + currentState = ButtonState_Pressed; + } + else + currentState = ButtonState_Hover; break; case ButtonState_Pressed: @@ -166,6 +175,7 @@ namespace Oyster } else { + outside = false; //Change state when the mouse button is NOT pressed switch(this->privData.previousState) { @@ -173,6 +183,7 @@ namespace Oyster case ButtonState_Hover: case ButtonState_Released: currentState = ButtonState_Hover; + clicked = false; break; case ButtonState_Pressed: @@ -256,6 +267,12 @@ namespace Oyster { return this->privData.owner; } + + template + ButtonState EventButton::GetState() + { + return this->privData.previousState; + } template bool EventButton::operator ==(const EventButton& obj) diff --git a/Code/Misc/EventHandler/EventButtonCollection.cpp b/Code/Misc/EventHandler/EventButtonCollection.cpp index 4096bd44..cc769b5c 100644 --- a/Code/Misc/EventHandler/EventButtonCollection.cpp +++ b/Code/Misc/EventHandler/EventButtonCollection.cpp @@ -3,7 +3,7 @@ ////////////////////////////////////// #include "EventButtonCollection.h" - +#include "EventHandler.h" #include "../../Input/L_inputClass.h" using namespace Oyster::Event; @@ -15,6 +15,14 @@ EventButtonCollection::EventButtonCollection() EventButtonCollection::~EventButtonCollection() { + for(int i = 0; i < EventHandler::Instance().collections.size(); i++) + { + if(EventHandler::Instance().collections.at(i) == this) + { + EventHandler::Instance().collections.erase(EventHandler::Instance().collections.begin() + i); + } + } + int size = buttons.size(); for(int i = 0; i < size; i++) { diff --git a/Code/Misc/EventHandler/EventHandler.cpp b/Code/Misc/EventHandler/EventHandler.cpp index 7c7f7722..139e0cac 100644 --- a/Code/Misc/EventHandler/EventHandler.cpp +++ b/Code/Misc/EventHandler/EventHandler.cpp @@ -26,6 +26,16 @@ EventHandler::~EventHandler() } } +void EventHandler::Clean() +{ + int size = collections.size(); + for(int i = 0; i < size; i++) + { + delete collections[i]; + } + collections.clear(); +} + void EventHandler::Update(InputClass* inputObject) { for(int i = 0; i < (int)collections.size(); i++) @@ -45,4 +55,17 @@ void EventHandler::Render() void EventHandler::AddCollection(EventButtonCollection* collection) { collections.push_back(collection); +} + +void EventHandler::DeleteCollection(EventButtonCollection* collection) +{ + for(int i = 0; i < collections.size(); i++) + { + if(collections.at(i) == collection) + { + delete collection; + collections.erase(collections.begin() + i); + break; + } + } } \ No newline at end of file diff --git a/Code/Misc/EventHandler/EventHandler.h b/Code/Misc/EventHandler/EventHandler.h index c58d628d..8459a77a 100644 --- a/Code/Misc/EventHandler/EventHandler.h +++ b/Code/Misc/EventHandler/EventHandler.h @@ -24,14 +24,17 @@ namespace Oyster static EventHandler& Instance(); + void Clean(); + void Update(InputClass* inputObject); void Render(); void AddCollection(EventButtonCollection* collection); + void DeleteCollection(EventButtonCollection* collection); private: std::vector collections; - + friend class EventButtonCollection; }; } } From d7c381cc85633c0edfd49c92e11802561e455710 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Wed, 12 Feb 2014 09:23:14 +0100 Subject: [PATCH 10/24] GL- fixed subscription --- Code/Game/GameLogic/AttatchmentMassDriver.cpp | 2 +- Code/Game/GameLogic/Object.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp index a2002566..b5458ff3 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -99,7 +99,7 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float Oyster::Math::Float3 look = owner->GetLookDir(); Oyster::Math::Float3 pos = owner->GetPosition(); - pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (20000 * dt); + pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (200 * dt); Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(look, up, pos); Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/8,1,1,50); diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp index 6e198e45..6770be75 100644 --- a/Code/Game/GameLogic/Object.cpp +++ b/Code/Game/GameLogic/Object.cpp @@ -47,7 +47,7 @@ Object::Object(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE Object::Object(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) { this->rigidBody = rigidBody; - + this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)collisionFuncAfter); this->type = type; this->objectID = GID(); } @@ -55,7 +55,7 @@ Object::Object(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefor Object::Object(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) { this->rigidBody = rigidBody; - + this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)collisionFuncAfter); this->type = type; this->objectID = GID(); } From f92bed35f5291420ddddb5db382cd848abcc1a86 Mon Sep 17 00:00:00 2001 From: lanariel Date: Wed, 12 Feb 2014 09:24:37 +0100 Subject: [PATCH 11/24] Colored Text and Tinted Gui elements --- Code/OysterGraphics/DllInterfaces/GFXAPI.cpp | 8 ++++---- Code/OysterGraphics/DllInterfaces/GFXAPI.h | 4 ++-- Code/OysterGraphics/Render/GuiRenderer.cpp | 14 ++++++++++++-- Code/OysterGraphics/Render/GuiRenderer.h | 4 ++-- Code/OysterGraphics/Render/Resources.cpp | 8 ++++++++ Code/OysterGraphics/Render/Resources.h | 1 + Code/OysterGraphics/Shader/Passes/2D/2DPixel.hlsl | 2 +- Code/OysterGraphics/Shader/Passes/2D/Header.hlsli | 7 ++++++- .../Shader/Passes/2D/Text/Header.hlsli | 2 +- Code/Tester/MainTest.cpp | 4 ++-- 10 files changed, 39 insertions(+), 15 deletions(-) diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp index 51ea20a2..b8d8bbae 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.cpp @@ -158,9 +158,9 @@ namespace Oyster Render::Gui::Begin2DRender(); } - void API::RenderGuiElement(API::Texture tex, Math::Float2 pos, Math::Float2 size) + void API::RenderGuiElement(API::Texture tex, Math::Float2 pos, Math::Float2 size, Math::Float3 color) { - Render::Gui::Render((ID3D11ShaderResourceView*)tex,pos,size); + Render::Gui::Render((ID3D11ShaderResourceView*)tex,pos,size,color); } API::Texture API::CreateTexture(std::wstring filename) @@ -191,9 +191,9 @@ namespace Oyster Render::Gui::Begin2DTextRender(); } - void API::RenderText(std::wstring text, Math::Float2 Pos, Math::Float2 Size) + void API::RenderText(std::wstring text, Math::Float2 Pos, Math::Float2 Size, Math::Float3 color) { - Render::Gui::RenderText(text,Pos,Size); + Render::Gui::RenderText(text,Pos,Size,color); } } } \ No newline at end of file diff --git a/Code/OysterGraphics/DllInterfaces/GFXAPI.h b/Code/OysterGraphics/DllInterfaces/GFXAPI.h index 6511fc4d..bdf70072 100644 --- a/Code/OysterGraphics/DllInterfaces/GFXAPI.h +++ b/Code/OysterGraphics/DllInterfaces/GFXAPI.h @@ -57,13 +57,13 @@ namespace Oyster static void StartGuiRender(); //! @brief Renders a single GUI element using the texture provided and the Pos in the center, %based system - static void RenderGuiElement(Texture, Math::Float2 Pos, Math::Float2 Size); + static void RenderGuiElement(Texture, Math::Float2 Pos, Math::Float2 Size, Math::Float3 Color = Math::Float3(1,1,1)); //! @brief Configures Renderer to process 2D Text, data will be passed in to EndFrame() static void StartTextRender(); //! @brief Renders a single GUI string using the texture provided and the Pos in the center, %based system - static void RenderText(std::wstring, Math::Float2 Pos, Math::Float2 Size); + static void RenderText(std::wstring, Math::Float2 Pos, Math::Float2 Size, Math::Float3 Color = Math::Float3(1,1,1)); //! @brief Performs light calculations, post effects and presents the scene static void EndFrame(); diff --git a/Code/OysterGraphics/Render/GuiRenderer.cpp b/Code/OysterGraphics/Render/GuiRenderer.cpp index ee114898..fbdfa37c 100644 --- a/Code/OysterGraphics/Render/GuiRenderer.cpp +++ b/Code/OysterGraphics/Render/GuiRenderer.cpp @@ -16,7 +16,7 @@ namespace Oyster Core::PipelineManager::SetRenderPass(Render::Resources::Gui::Pass); } - void Gui::Render(ID3D11ShaderResourceView* tex,Math::Float2 pos, Math::Float2 size) + void Gui::Render(ID3D11ShaderResourceView* tex,Math::Float2 pos, Math::Float2 size, Math::Float3 color) { Core::deviceContext->PSSetShaderResources(0,1,&tex); @@ -34,6 +34,12 @@ namespace Oyster void* data = Render::Resources::Gui::Data.Map(); memcpy(data,&gd,sizeof(Definitions::GuiData)); Render::Resources::Gui::Data.Unmap(); + + data = Render::Resources::Gui::Color.Map(); + memcpy(data,&color,sizeof(Math::Float3)); + Render::Resources::Gui::Color.Unmap(); + + Core::deviceContext->Draw(1,0); } @@ -43,7 +49,7 @@ namespace Oyster Core::PipelineManager::SetRenderPass(Resources::Gui::Text::Pass); } - void Gui::RenderText(std::wstring text, Math::Float2 pos, Math::Float2 size) + void Gui::RenderText(std::wstring text, Math::Float2 pos, Math::Float2 size, Math::Float3 color) { size.x = size.x / (text.length() * TEXT_SPACING /2); @@ -70,6 +76,10 @@ namespace Oyster Render::Resources::Gui::Data.Unmap(); Definitions::Text2D tmpInst; + data = Render::Resources::Gui::Color.Map(); + memcpy(data,&color,sizeof(Math::Float3)); + Render::Resources::Gui::Color.Unmap(); + void* dest = Resources::Gui::Text::Vertex.Map(); Definitions::Text2D* dataView = reinterpret_cast(dest); //tmpInst.charOffset=_pos; diff --git a/Code/OysterGraphics/Render/GuiRenderer.h b/Code/OysterGraphics/Render/GuiRenderer.h index 6d865950..f5513d2f 100644 --- a/Code/OysterGraphics/Render/GuiRenderer.h +++ b/Code/OysterGraphics/Render/GuiRenderer.h @@ -12,9 +12,9 @@ namespace Oyster { public: static void Begin2DRender(); - static void Render(ID3D11ShaderResourceView* tex, Math::Float2 pos, Math::Float2 size); + static void Render(ID3D11ShaderResourceView* tex, Math::Float2 pos, Math::Float2 size, Math::Float3 tint = Math::Float3(1,1,1)); static void Begin2DTextRender(); - static void RenderText(std::wstring text, Math::Float2 pos, Math::Float2 size); + static void RenderText(std::wstring text, Math::Float2 pos, Math::Float2 size, Math::Float3 tint = Math::Float3(1,1,1)); }; } } diff --git a/Code/OysterGraphics/Render/Resources.cpp b/Code/OysterGraphics/Render/Resources.cpp index e0a0aa79..73834071 100644 --- a/Code/OysterGraphics/Render/Resources.cpp +++ b/Code/OysterGraphics/Render/Resources.cpp @@ -45,6 +45,7 @@ namespace Oyster Buffer Resources::Gather::AnimationData = Buffer(); Buffer Resources::Light::LightConstantsData = Buffer(); Buffer Resources::Gui::Data = Buffer(); + Buffer Resources::Gui::Color = Buffer(); Buffer Resources::Gui::Text::Vertex = Buffer(); Buffer Resources::Post::Data = Buffer(); @@ -118,6 +119,10 @@ namespace Oyster desc.ElementSize = sizeof(Definitions::AnimationData); Gather::AnimationData.Init(desc); + desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_PS; + desc.ElementSize = sizeof(Math::Float3); + Gui::Color.Init(desc); + desc.Type = Buffer::BUFFER_TYPE::CONSTANT_BUFFER_GS; desc.NumElements = 1; desc.ElementSize = sizeof(Definitions::GuiData); @@ -378,6 +383,7 @@ namespace Oyster Gui::Pass.Shaders.Geometry = GetShader::Geometry(L"2D"); Gui::Pass.RTV.push_back(GBufferRTV[2]); Gui::Pass.CBuffers.Geometry.push_back(Gui::Data); + Gui::Pass.CBuffers.Pixel.push_back(Gui::Color); D3D11_INPUT_ELEMENT_DESC indesc2D[] = { @@ -421,6 +427,7 @@ namespace Oyster Shader::CreateInputLayout(Text2Ddesc,3, GetShader::Vertex(L"2DText") ,Gui::Text::Pass.IAStage.Layout); Gui::Text::Pass.CBuffers.Geometry.push_back(Gui::Data); + Gui::Text::Pass.CBuffers.Pixel.push_back(Gui::Color); Gui::Text::Pass.SRV.Pixel.push_back(Gui::Text::Font); Gui::Text::Pass.RTV.push_back(GBufferRTV[2]); Gui::Text::Pass.RenderStates.SampleCount = 1; @@ -448,6 +455,7 @@ namespace Oyster Light::LightConstantsData.~Buffer(); Light::PointLightsData.~Buffer(); Gui::Data.~Buffer(); + Gui::Color.~Buffer(); Gui::Text::Vertex.~Buffer(); Post::Data.~Buffer(); SAFE_RELEASE(Light::PointLightView); diff --git a/Code/OysterGraphics/Render/Resources.h b/Code/OysterGraphics/Render/Resources.h index cdc12efc..d43b5756 100644 --- a/Code/OysterGraphics/Render/Resources.h +++ b/Code/OysterGraphics/Render/Resources.h @@ -61,6 +61,7 @@ namespace Oyster { static Core::PipelineManager::RenderPass Pass; static Core::Buffer Data; + static Core::Buffer Color; struct Text { static Core::PipelineManager::RenderPass Pass; diff --git a/Code/OysterGraphics/Shader/Passes/2D/2DPixel.hlsl b/Code/OysterGraphics/Shader/Passes/2D/2DPixel.hlsl index a09111b9..c28fd642 100644 --- a/Code/OysterGraphics/Shader/Passes/2D/2DPixel.hlsl +++ b/Code/OysterGraphics/Shader/Passes/2D/2DPixel.hlsl @@ -2,5 +2,5 @@ float4 main(Pixel2DIn input) : SV_Target0 { - return Material.Sample(LinearSampler,input.Uv); + return Material.Sample(LinearSampler,input.Uv) * float4(Color,1); } \ No newline at end of file diff --git a/Code/OysterGraphics/Shader/Passes/2D/Header.hlsli b/Code/OysterGraphics/Shader/Passes/2D/Header.hlsli index 5a026d34..4b507644 100644 --- a/Code/OysterGraphics/Shader/Passes/2D/Header.hlsli +++ b/Code/OysterGraphics/Shader/Passes/2D/Header.hlsli @@ -3,11 +3,16 @@ struct Vertex2DIn float2 Pos : Position; }; -cbuffer EveryObject2D : register(c0) +cbuffer EveryObject2D : register(b0) { float4x4 Translation; }; +cbuffer ColorData : register(b0) +{ + float3 Color; +}; + struct Pixel2DIn { float4 Pos : SV_Position; diff --git a/Code/OysterGraphics/Shader/Passes/2D/Text/Header.hlsli b/Code/OysterGraphics/Shader/Passes/2D/Text/Header.hlsli index 7b64fd79..6d7ab899 100644 --- a/Code/OysterGraphics/Shader/Passes/2D/Text/Header.hlsli +++ b/Code/OysterGraphics/Shader/Passes/2D/Text/Header.hlsli @@ -1,5 +1,5 @@ #include "../Header.hlsli" -cbuffer TextPerObject : register(c0) +cbuffer TextPerObject : register(b0) { float4x4 gWorld; }; diff --git a/Code/Tester/MainTest.cpp b/Code/Tester/MainTest.cpp index cd614f42..f545e42d 100644 --- a/Code/Tester/MainTest.cpp +++ b/Code/Tester/MainTest.cpp @@ -233,14 +233,14 @@ HRESULT Render(float deltaTime) Oyster::Graphics::API::RenderModel(m2); Oyster::Graphics::API::StartGuiRender(); Oyster::Graphics::API::RenderGuiElement(t,Oyster::Math::Float2(0.5f,0.5f),Oyster::Math::Float2(1,1)); - Oyster::Graphics::API::RenderGuiElement(t2,Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f)); + //Oyster::Graphics::API::RenderGuiElement(t2,Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float3(1,0,0)); Oyster::Graphics::API::StartTextRender(); std::wstring fps; float f = 1/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::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f)); + Oyster::Graphics::API::RenderText(fps,Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float3(0,1,0)); Oyster::Graphics::API::EndFrame(); return S_OK; From bdc5b5e736b2e1fc149b37de32c51b9665e351aa Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Wed, 12 Feb 2014 09:32:13 +0100 Subject: [PATCH 12/24] GL - fixed graphics, collision with house, locked to 30 fps on client, jump added --- Code/Game/DanBiasGame/DanBiasGame_Impl.cpp | 8 +++--- .../DanBiasGame/GameClientState/GameState.cpp | 25 +++++++++---------- Code/Game/GameLogic/Level.cpp | 24 +++++++++--------- Code/Game/GameLogic/Player.cpp | 4 +-- 4 files changed, 30 insertions(+), 31 deletions(-) diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp index 587a3df1..bf557473 100644 --- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp +++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp @@ -93,12 +93,12 @@ namespace DanBias m_data->recieverObj->Update(); capFrame += dt; - //if(capFrame > 0.03) + if(capFrame > 0.03) { - Oyster::Graphics::API::Update(dt); - if(Update(dt) != S_OK) + Oyster::Graphics::API::Update(capFrame); + if(Update(capFrame) != S_OK) return DanBiasClientReturn_Error; - if(Render(dt) != S_OK) + if(Render(capFrame) != S_OK) return DanBiasClientReturn_Error; capFrame = 0; } diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index cfc07fc9..e7d41cb3 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -50,11 +50,11 @@ bool GameState::Init(Oyster::Network::NetworkClient* nwClient) GameState::gameStateState GameState::LoadGame() { Oyster::Graphics::Definitions::Pointlight plight; - plight.Pos = Float3(315, 0 ,5); + plight.Pos = Float3(615, 0 ,5); plight.Color = Float3(0.9f,0.7f,0.2f); - plight.Radius = 10; + plight.Radius = 100; plight.Bright = 0.5f; - //Oyster::Graphics::API::AddLight(plight); + Oyster::Graphics::API::AddLight(plight); plight.Pos = Float3(10,800,5); plight.Color = Float3(0.9f,0.7f,0.3f); plight.Radius = 300; @@ -122,9 +122,8 @@ bool GameState::LoadModels() this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); } - /* // add crystal model - modelData.position = Oyster::Math::Float3(10, 301, 0); + modelData.position = Oyster::Math::Float3(10, 601, 0); modelData.modelPath = L"crystalformation_b.dan"; modelData.id = id++; // load models @@ -132,19 +131,19 @@ bool GameState::LoadModels() this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); // add house model - modelData.position = Oyster::Math::Float3(-50, 290, 0); + modelData.position = Oyster::Math::Float3(-50, 590, 0); //Oyster::Math3D::Float4x4 rot = Oyster::Math3D::RotationMatrix(Oyster::Math::Float3(0 ,Utility::Value::Radian(90.0f), 0)); modelData.visible = true; modelData.modelPath = L"building_corporation.dan"; modelData.id = id++; // load models - this->dynamicObjects.Push(new C_DynamicObj()); - this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); + this->staticObjects.Push(new C_StaticObj()); + this->staticObjects[this->staticObjects.Size() -1 ]->Init(modelData); // add player model - modelData.position = Oyster::Math::Float3(0, 320, 0); + modelData.position = Oyster::Math::Float3(0, 602, 0); modelData.modelPath = L"char_still_sizeref.dan"; modelData.id = id++; // load models @@ -152,7 +151,7 @@ bool GameState::LoadModels() this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); // add player model 2 - modelData.position = Oyster::Math::Float3(50, 320, 0); + modelData.position = Oyster::Math::Float3(50, 602, 0); modelData.modelPath = L"char_still_sizeref.dan"; modelData.id = id++; // load models @@ -160,7 +159,7 @@ bool GameState::LoadModels() this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); // add jumppad - modelData.position = Oyster::Math::Float3(4, 300.3, 0); + modelData.position = Oyster::Math::Float3(4, 600.3, 0); modelData.modelPath = L"jumppad_round.dan"; modelData.id = id++; // load models @@ -174,7 +173,7 @@ bool GameState::LoadModels() modelData.id = id++; // load models this->dynamicObjects.Push(new C_DynamicObj()); - this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData);*/ + this->dynamicObjects[this->dynamicObjects.Size() -1 ]->Init(modelData); return true; } bool GameState::LoadModels(std::string mapFile) @@ -374,7 +373,7 @@ bool GameState::Render(float dt) std::wstring fps; float f = 1/dt; fps = std::to_wstring(f); - Oyster::Graphics::API::RenderText(fps,Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.05f,0.08f)); + Oyster::Graphics::API::RenderText(fps,Oyster::Math::Float2(0.5f,0.1f),Oyster::Math::Float2(0.2f,0.05f)); Oyster::Graphics::API::EndFrame(); return true; diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index e2e52854..619b491e 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -113,7 +113,7 @@ void Level::InitiateLevel(std::string levelPath) void Level::InitiateLevel(float radius) { API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0)); - API::Instance().SetGravity(50); + API::Instance().SetGravity(100); int idCount = 100; // add level sphere ICustomBody* rigidBody = API::Instance().AddCollisionSphere(599.2f, Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f); @@ -165,20 +165,20 @@ void Level::InitiateLevel(float radius) - //// add crystal + // 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); - //ICustomBody* rigidBody_Crystal = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(10, 605, 0), 5); - - //this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); - //rigidBody_Crystal->SetCustomTag(this->dynamicObjects[nrOfBoxex]); - - // + this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); + rigidBody_Crystal->SetCustomTag(this->dynamicObjects[nrOfBoxex]); + this->dynamicObjects[nrOfBoxex]->objectID = idCount++; + - //// add house - //ICustomBody* rigidBody_House =API::Instance().AddCollisionBox(Oyster::Math::Float3(0.5f, 0.5f, 0.5f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(10, 905, 0), 0); - //this->staticObjects.Push(new StaticObject(rigidBody_House,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_GENERIC)); - //rigidBody_House->SetCustomTag(this->staticObjects[0]); + // 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::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_GENERIC)); + rigidBody_House->SetCustomTag(this->staticObjects[0]); + this->staticObjects[0]->objectID = idCount++; } void Level::AddPlayerToTeam(Player *player, int teamID) diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 039cae63..238d5e68 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -156,8 +156,8 @@ void Player::Rotate(const Oyster::Math3D::Float4 lookDir) void Player::Jump() { - Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1]; - //this->rigidBody->GetState().SetLinearVelocity(up *10); + Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1].GetNormalized(); + this->rigidBody->ApplyImpulse(up *2000); } bool Player::IsWalking() From e6316f323989a66a2e9a91ab9b1ede523be3bba5 Mon Sep 17 00:00:00 2001 From: lanariel Date: Wed, 12 Feb 2014 09:32:15 +0100 Subject: [PATCH 13/24] removed some old stuff, respect animation looping state --- Code/OysterGraphics/ClassDiagram.cd | 2 - .../OysterGraphics.vcxproj.filters.orig | 88 ------- .../OysterGraphics.vcxproj.orig | 214 ------------------ .../OysterGraphics/Render/DefaultRenderer.cpp | 2 +- Code/Tester/MainTest.cpp | 2 +- 5 files changed, 2 insertions(+), 306 deletions(-) delete mode 100644 Code/OysterGraphics/ClassDiagram.cd delete mode 100644 Code/OysterGraphics/OysterGraphics.vcxproj.filters.orig delete mode 100644 Code/OysterGraphics/OysterGraphics.vcxproj.orig diff --git a/Code/OysterGraphics/ClassDiagram.cd b/Code/OysterGraphics/ClassDiagram.cd deleted file mode 100644 index 7b894197..00000000 --- a/Code/OysterGraphics/ClassDiagram.cd +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/Code/OysterGraphics/OysterGraphics.vcxproj.filters.orig b/Code/OysterGraphics/OysterGraphics.vcxproj.filters.orig deleted file mode 100644 index 94814340..00000000 --- a/Code/OysterGraphics/OysterGraphics.vcxproj.filters.orig +++ /dev/null @@ -1,88 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - -<<<<<<< HEAD - -======= - ->>>>>>> f08e9491ed00b00aedba0eabf1caed33830fc0e2 - Source Files - - - Source Files - -<<<<<<< HEAD - -======= - - Source Files - - ->>>>>>> f08e9491ed00b00aedba0eabf1caed33830fc0e2 - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - - - - - - \ No newline at end of file diff --git a/Code/OysterGraphics/OysterGraphics.vcxproj.orig b/Code/OysterGraphics/OysterGraphics.vcxproj.orig deleted file mode 100644 index 8a0e9221..00000000 --- a/Code/OysterGraphics/OysterGraphics.vcxproj.orig +++ /dev/null @@ -1,214 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {0EC83E64-230E-48EF-B08C-6AC9651B4F82} - OysterGraphics - - - - StaticLibrary - true - v110 - MultiByte - - - StaticLibrary - true - v110 - MultiByte - - - StaticLibrary - false - v110 - true - MultiByte - - - StaticLibrary - false - v110 - true - MultiByte - - - - - - - - - - - - - - - - - - - $(SolutionDir)..\External\Lib\$(ProjectName)\ - $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ - $(ProjectName)_$(PlatformShortName)D - - - $(SolutionDir)..\External\Lib\$(ProjectName)\ - $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ - $(ProjectName)_$(PlatformShortName) - - - $(SolutionDir)..\External\Lib\$(ProjectName)\ - $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ - $(ProjectName)_$(PlatformShortName)D - - - $(SolutionDir)..\External\Lib\$(ProjectName)\ - $(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\ - $(ProjectName)_$(PlatformShortName) - - - - Level3 - Disabled - true - $(SolutionDir)OysterMath;$(SolutionDir)Misc;%(AdditionalIncludeDirectories) - - - true - - - true - - - - - Level3 - Disabled - true - ..\OysterPhysic3D\Collision;..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories) - - - true - - - - - Level3 - MaxSpeed - true - true - true - ..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories) - - - true - true - true - - - - - Level3 - MaxSpeed - true - true - true - ..\OysterPhysics3D;..\OysterMath;..\Misc;%(AdditionalIncludeDirectories) - - - true - true - true - - - - - - - -<<<<<<< HEAD - - - -======= - - - - ->>>>>>> f08e9491ed00b00aedba0eabf1caed33830fc0e2 - - - - - -<<<<<<< HEAD -======= - - ->>>>>>> f08e9491ed00b00aedba0eabf1caed33830fc0e2 - - - - - - - - - - {2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee} - - - {f10cbc03-9809-4cba-95d8-327c287b18ee} - - - - - Vertex - Vertex - Vertex - Vertex - - - Pixel - Pixel - Pixel - Pixel - true - 5.0 - main - - - Vertex - Vertex - Vertex - Vertex - true - 5.0 - main - - - - - - - - \ No newline at end of file diff --git a/Code/OysterGraphics/Render/DefaultRenderer.cpp b/Code/OysterGraphics/Render/DefaultRenderer.cpp index 2ad8646b..a92c54d6 100644 --- a/Code/OysterGraphics/Render/DefaultRenderer.cpp +++ b/Code/OysterGraphics/Render/DefaultRenderer.cpp @@ -82,7 +82,7 @@ namespace Oyster } int b = 0; Model::Animation A = *models[i].Animation.AnimationPlaying; - while(models[i].Animation.AnimationTime>A.duration) + while(models[i].Animation.AnimationTime>A.duration && models[i].Animation.LoopAnimation) models[i].Animation.AnimationTime -= (float)A.duration; float position = models[i].Animation.AnimationTime; diff --git a/Code/Tester/MainTest.cpp b/Code/Tester/MainTest.cpp index f545e42d..4462f060 100644 --- a/Code/Tester/MainTest.cpp +++ b/Code/Tester/MainTest.cpp @@ -176,7 +176,7 @@ HRESULT InitDirect3D() m->WorldMatrix.m[2][2] = 0.00000005f; m2 = Oyster::Graphics::API::CreateModel(L"char_temporary.dan"); m2->WorldMatrix = Oyster::Math3D::OrientationMatrix(Oyster::Math::Float3::null,Oyster::Math::Float3(4,0,0),Oyster::Math::Float3::null); - Oyster::Graphics::API::PlayAnimation(m2, L"movement",true); + Oyster::Graphics::API::PlayAnimation(m2, L"movement",false); t = Oyster::Graphics::API::CreateTexture(L"structure_corp_mdg.png"); t2 = Oyster::Graphics::API::CreateTexture(L"whiteGui.png"); From 0bae7b9c6b93aef579256034d87e8d1a5c34a578 Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Wed, 12 Feb 2014 09:49:57 +0100 Subject: [PATCH 14/24] Misc - Fixed a few errors that can occur --- .../DanBiasGame/GameClientState/LoginState.cpp | 1 - Code/Misc/EventHandler/EventButtonCollection.cpp | 11 +++++++++-- Code/Misc/EventHandler/EventButtonCollection.h | 15 ++++++++++----- Code/Misc/EventHandler/EventHandler.cpp | 9 +++++++++ Code/Misc/EventHandler/EventHandler.h | 10 ++++++++++ 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/LoginState.cpp b/Code/Game/DanBiasGame/GameClientState/LoginState.cpp index 4f148624..d94d8ed5 100644 --- a/Code/Game/DanBiasGame/GameClientState/LoginState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LoginState.cpp @@ -257,7 +257,6 @@ bool LoginState::Release() } delete privData->collection; - //EventHandler::Instance().DeleteCollection(privData->collection); delete privData; privData = NULL; diff --git a/Code/Misc/EventHandler/EventButtonCollection.cpp b/Code/Misc/EventHandler/EventButtonCollection.cpp index cc769b5c..2bd5f09a 100644 --- a/Code/Misc/EventHandler/EventButtonCollection.cpp +++ b/Code/Misc/EventHandler/EventButtonCollection.cpp @@ -8,8 +8,8 @@ using namespace Oyster::Event; -EventButtonCollection::EventButtonCollection() - : collectionState(EventCollectionState_Enabled) +EventButtonCollection::EventButtonCollection(EventCollectionState state) + : collectionState(state) { } @@ -65,6 +65,13 @@ void EventButtonCollection::SetState(const EventCollectionState state) void EventButtonCollection::Clear() { + int size = buttons.size(); + for(int i = 0; i < size; i++) + { + delete buttons[i]; + buttons[i] = NULL; + } buttons.clear(); + collectionState = EventCollectionState_Enabled; } \ No newline at end of file diff --git a/Code/Misc/EventHandler/EventButtonCollection.h b/Code/Misc/EventHandler/EventButtonCollection.h index 56bb3d27..5bcd044a 100644 --- a/Code/Misc/EventHandler/EventButtonCollection.h +++ b/Code/Misc/EventHandler/EventButtonCollection.h @@ -28,20 +28,20 @@ namespace Oyster }; /******************************** - This EventButtonCollection will handle the destruction of the buttons when they are added to the collection. - + This EventButtonCollection will handle the destruction of the buttons when they are added to the collection ********************************/ class EventButtonCollection { public: - EventButtonCollection(); + EventButtonCollection(EventCollectionState state = EventCollectionState_Enabled); ~EventButtonCollection(); void Update(InputClass* inputObject); void Render(); - template - void AddButton(EventButton* button) + /*Add a button to the collection when a button is added to the collection you are not allowed to delete it. + */ + template void AddButton(EventButton* button) { buttons.push_back(button); } @@ -52,6 +52,11 @@ namespace Oyster //Clear all buttons and reset the state. void Clear(); + private: + //Can't copy + EventButtonCollection(const EventButtonCollection& obj); + EventButtonCollection& operator =(const EventButtonCollection& obj); + protected: std::vector buttons; EventCollectionState collectionState; diff --git a/Code/Misc/EventHandler/EventHandler.cpp b/Code/Misc/EventHandler/EventHandler.cpp index 139e0cac..4b623714 100644 --- a/Code/Misc/EventHandler/EventHandler.cpp +++ b/Code/Misc/EventHandler/EventHandler.cpp @@ -23,6 +23,7 @@ EventHandler::~EventHandler() for(int i = 0; i < size; i++) { delete collections[i]; + collections[i] = NULL; } } @@ -32,6 +33,7 @@ void EventHandler::Clean() for(int i = 0; i < size; i++) { delete collections[i]; + collections[i] = NULL; } collections.clear(); } @@ -54,6 +56,12 @@ void EventHandler::Render() void EventHandler::AddCollection(EventButtonCollection* collection) { + for(int i = 0; i < collections.size(); i++) + { + //Do not add the collection if it's already in the list. + if(collections.at(i) == collection) + return; + } collections.push_back(collection); } @@ -64,6 +72,7 @@ void EventHandler::DeleteCollection(EventButtonCollection* collection) if(collections.at(i) == collection) { delete collection; + collection = NULL; collections.erase(collections.begin() + i); break; } diff --git a/Code/Misc/EventHandler/EventHandler.h b/Code/Misc/EventHandler/EventHandler.h index 8459a77a..71a35ecd 100644 --- a/Code/Misc/EventHandler/EventHandler.h +++ b/Code/Misc/EventHandler/EventHandler.h @@ -29,11 +29,21 @@ namespace Oyster void Update(InputClass* inputObject); void Render(); + /*Add a collection to the EventHandler will only add collections not already present in the list. + + */ void AddCollection(EventButtonCollection* collection); void DeleteCollection(EventButtonCollection* collection); + private: + //Can't copy this class. + EventHandler(const EventHandler& obj); + EventHandler& operator =(const EventHandler& obj); + private: std::vector collections; + + //EventButtonCollection is a firend so it can delete it self. friend class EventButtonCollection; }; } From 8e07475434c4c35c59b8da6a3e74167091277549 Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Wed, 12 Feb 2014 10:02:52 +0100 Subject: [PATCH 15/24] GL - Buttons is now using one texture per button type. Fixed button state when spamming the button. --- .../GameClientState/Buttons/EventButtonGUI.h | 19 +++----------- .../GameClientState/LoginState.cpp | 25 +++++++++---------- Code/Misc/EventHandler/EventButton.h | 7 +++--- 3 files changed, 20 insertions(+), 31 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h b/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h index 7e2de14f..73bccc49 100644 --- a/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h +++ b/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h @@ -42,26 +42,17 @@ namespace DanBias virtual ~EventButtonGUI() { Oyster::Graphics::API::DeleteTexture(texture); - Oyster::Graphics::API::DeleteTexture(texture2); - Oyster::Graphics::API::DeleteTexture(texture3); texture = NULL; - texture2 = NULL; - texture3 = NULL; } void CreateTexture(std::wstring textureName) { - std::wstring file = L".png"; - //Create texture - texture = Oyster::Graphics::API::CreateTexture(textureName + std::wstring(L"none") + file); - texture2 = Oyster::Graphics::API::CreateTexture(textureName + std::wstring(L"highlight") + file); - texture3 = Oyster::Graphics::API::CreateTexture(textureName + std::wstring(L"down") + file); + texture = Oyster::Graphics::API::CreateTexture(textureName); } virtual void Render() { - if(EventButton::Enabled()) { //Render att xPos and yPos @@ -69,15 +60,15 @@ namespace DanBias if(EventButton::GetState() == ButtonState_None) { - Oyster::Graphics::API::RenderGuiElement(texture, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height)); + Oyster::Graphics::API::RenderGuiElement(texture, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height), Oyster::Math::Float3(1, 1, 1)); } else if(EventButton::GetState() == ButtonState_Hover) { - Oyster::Graphics::API::RenderGuiElement(texture2, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height)); + Oyster::Graphics::API::RenderGuiElement(texture, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height), Oyster::Math::Float3(0, 1, 0)); } else { - Oyster::Graphics::API::RenderGuiElement(texture3, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height)); + Oyster::Graphics::API::RenderGuiElement(texture, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height), Oyster::Math::Float3(1, 0, 0)); } } @@ -87,8 +78,6 @@ namespace DanBias float xPos, yPos; float width, height; Oyster::Graphics::API::Texture texture; - Oyster::Graphics::API::Texture texture2; - Oyster::Graphics::API::Texture texture3; }; diff --git a/Code/Game/DanBiasGame/GameClientState/LoginState.cpp b/Code/Game/DanBiasGame/GameClientState/LoginState.cpp index d94d8ed5..7424b7b2 100644 --- a/Code/Game/DanBiasGame/GameClientState/LoginState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LoginState.cpp @@ -110,21 +110,21 @@ bool LoginState::Init(Oyster::Network::NetworkClient* nwClient) //Create menu buttons privData->collection = new EventButtonCollection; EventHandler::Instance().AddCollection(privData->collection); - privData->collection->AddButton(new ButtonEllipse(L"circle_", &LoginState::ButtonCallback, this, (void*)Create, 0.2f, 0.2f, 0.1f, 0.2f)); - privData->collection->AddButton(new ButtonEllipse(L"circle_", &LoginState::ButtonCallback, this, (void*)Create, 0.2f, 0.3f, 0.1f, 0.2f)); - privData->collection->AddButton(new ButtonEllipse(L"circle_", &LoginState::ButtonCallback, this, (void*)Create, 0.2f, 0.4f, 0.1f, 0.2f)); - privData->collection->AddButton(new ButtonEllipse(L"circle_", &LoginState::ButtonCallback, this, (void*)Create, 0.2f, 0.5f, 0.1f, 0.2f)); + privData->collection->AddButton(new ButtonEllipse(L"circle.png", &LoginState::ButtonCallback, this, (void*)Create, 0.2f, 0.2f, 0.1f, 0.2f)); + privData->collection->AddButton(new ButtonEllipse(L"circle.png", &LoginState::ButtonCallback, this, (void*)Create, 0.2f, 0.3f, 0.1f, 0.2f)); + privData->collection->AddButton(new ButtonEllipse(L"circle.png", &LoginState::ButtonCallback, this, (void*)Create, 0.2f, 0.4f, 0.1f, 0.2f)); + privData->collection->AddButton(new ButtonEllipse(L"circle.png", &LoginState::ButtonCallback, this, (void*)Create, 0.2f, 0.5f, 0.1f, 0.2f)); - privData->collection->AddButton(new ButtonRectangle(L"button_", &LoginState::ButtonCallback, this, (void*)Create, 0.15f, 0.05f, 0.1f, 0.1f)); - privData->collection->AddButton(new ButtonRectangle(L"button_", &LoginState::ButtonCallback, this, (void*)Create, 0.25f, 0.05f, 0.1f, 0.1f)); - privData->collection->AddButton(new ButtonRectangle(L"button_", &LoginState::ButtonCallback, this, (void*)Create, 0.35f, 0.05f, 0.1f, 0.1f)); - privData->collection->AddButton(new ButtonRectangle(L"button_", &LoginState::ButtonCallback, this, (void*)Create, 0.45f, 0.05f, 0.1f, 0.1f)); + privData->collection->AddButton(new ButtonRectangle(L"button.png", &LoginState::ButtonCallback, this, (void*)Create, 0.15f, 0.05f, 0.1f, 0.1f)); + privData->collection->AddButton(new ButtonRectangle(L"button.png", &LoginState::ButtonCallback, this, (void*)Create, 0.25f, 0.05f, 0.1f, 0.1f)); + privData->collection->AddButton(new ButtonRectangle(L"button.png", &LoginState::ButtonCallback, this, (void*)Create, 0.35f, 0.05f, 0.1f, 0.1f)); + privData->collection->AddButton(new ButtonRectangle(L"button.png", &LoginState::ButtonCallback, this, (void*)Create, 0.45f, 0.05f, 0.1f, 0.1f)); - privData->collection->AddButton(new ButtonRectangle(L"button_", &LoginState::ButtonCallback, this, (void*)Create, 0.5f, 0.5f, 0.3f, 0.3f)); + privData->collection->AddButton(new ButtonRectangle(L"button.png", &LoginState::ButtonCallback, this, (void*)Create, 0.5f, 0.5f, 0.3f, 0.3f)); //Incr/decr buttons - privData->collection->AddButton(new ButtonRectangle(L"button_", &LoginState::ButtonCallback, this, (void*)Incr, 0.85f, 0.2f, 0.1f, 0.1f)); - privData->collection->AddButton(new ButtonRectangle(L"button_", &LoginState::ButtonCallback, this, (void*)Decr, 0.55f, 0.2f, 0.1f, 0.1f)); + privData->collection->AddButton(new ButtonRectangle(L"button.png", &LoginState::ButtonCallback, this, (void*)Incr, 0.85f, 0.2f, 0.1f, 0.1f)); + privData->collection->AddButton(new ButtonRectangle(L"button.png", &LoginState::ButtonCallback, this, (void*)Decr, 0.55f, 0.2f, 0.1f, 0.1f)); privData->testNumber = 0; @@ -217,7 +217,6 @@ GameClientState::ClientState LoginState::Update(float deltaTime, InputClass* Key } bool LoginState::Render(float dt) { - Oyster::Graphics::API::SetView(privData->view); Oyster::Graphics::API::SetProjection( privData->proj); @@ -241,7 +240,7 @@ bool LoginState::Render(float dt) _itow_s(privData->testNumber, temp, 10); number = temp; Oyster::Graphics::API::StartTextRender(); - Oyster::Graphics::API::RenderText(number, Oyster::Math::Float2(0.7, 0.2), Oyster::Math::Float2(0.1, 0.1)); + Oyster::Graphics::API::RenderText(number, Oyster::Math::Float2(0.7, 0.2), Oyster::Math::Float2(0.1, 0.1), Oyster::Math::Float3(1, 0, 0)); Oyster::Graphics::API::EndFrame(); return true; diff --git a/Code/Misc/EventHandler/EventButton.h b/Code/Misc/EventHandler/EventButton.h index 6a220845..6e99fcc7 100644 --- a/Code/Misc/EventHandler/EventButton.h +++ b/Code/Misc/EventHandler/EventButton.h @@ -155,15 +155,16 @@ namespace Oyster break; case ButtonState_Hover: - case ButtonState_Released: if(outside == false) { clicked = true; currentState = ButtonState_Pressed; } - else - currentState = ButtonState_Hover; break; + case ButtonState_Released: + currentState = ButtonState_Hover; + break; + case ButtonState_Pressed: case ButtonState_Down: From 7394f68769c97449e576c7e099e96935f5d5c359 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Wed, 12 Feb 2014 10:57:43 +0100 Subject: [PATCH 16/24] GL - fixed what some asshole did in weapon --- Code/Game/GameLogic/Weapon.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Code/Game/GameLogic/Weapon.cpp b/Code/Game/GameLogic/Weapon.cpp index e52fe8df..66de8e33 100644 --- a/Code/Game/GameLogic/Weapon.cpp +++ b/Code/Game/GameLogic/Weapon.cpp @@ -18,17 +18,9 @@ Weapon::Weapon() Weapon::Weapon(int MaxNrOfSockets,Player *owner) { - if(MaxNrOfSockets > 1) return; - - attatchmentSockets.Resize(MaxNrOfSockets); attatchmentSockets[0] = new AttatchmentSocket(); - for (int i = 0; i < MaxNrOfSockets; i++) - { - this->attatchmentSockets[i] = 0; - } - weaponState = WEAPON_STATE_IDLE; currentNrOfAttatchments = 0; selectedAttatchment = 0; From 3a80a711439acd736fb893f78921ae5eb8a15d73 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Wed, 12 Feb 2014 11:32:30 +0100 Subject: [PATCH 17/24] GL - working on weapon --- Code/Game/GameLogic/AttatchmentMassDriver.cpp | 16 ++++++++-------- Code/Game/GameLogic/CollisionManager.cpp | 9 +++++---- Code/OysterPhysics3D/Cone.cpp | 9 +++++++-- Code/OysterPhysics3D/Cone.h | 9 +++++++++ 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp index 2b66bcde..bd52029d 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -95,22 +95,22 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float heldObject = NULL; return; } - Oyster::Math::Float3 up = owner->GetOrientation().v[1]; - Oyster::Math::Float3 look = owner->GetLookDir(); - Oyster::Math::Float3 pos = owner->GetPosition(); + + Oyster::Math::Float radius = 2; + Oyster::Math::Float3 look = owner->GetLookDir().GetNormalized(); + Oyster::Math::Float lenght = 5; + Oyster::Math::Float3 pos = owner->GetRigidBody()->GetState().centerPos; pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (200 * dt); - Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(look, up, pos); - Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/8,1,1,50); - Oyster::Collision3D::Frustrum hitFrustum = Oyster::Collision3D::Frustrum(Oyster::Math3D::ViewProjectionMatrix(aim,hitSpace)); + Oyster::Collision3D::Cone *hitCone = new Oyster::Collision3D::Cone(look*5,pos,radius); + - Oyster::Collision3D::Cone *hitCone; forcePushData args; args.pushForce = pushForce; - //Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,&args,ForcePushAction); + Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction); } /******************************************************** diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index 9c6f6aca..9f71f249 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -123,19 +123,20 @@ using namespace GameLogic; void AttatchmentMassDriver::ForcePushAction(Oyster::Physics::ICustomBody *obj, void *args) { - Oyster::Physics::ICustomBody::State state; + if(obj->GetState().mass == 0) return; + Object *realObj = (Object*)obj->GetCustomTag(); if(realObj->GetObjectType() == OBJECT_TYPE_PLAYER || realObj->GetObjectType() == OBJECT_TYPE_WORLD) return; - state = obj->GetState(); - //state.ApplyLinearImpulse(((forcePushData*)(args))->pushForce); - obj->SetState(state); + obj->ApplyImpulse(((forcePushData*)(args))->pushForce); } void AttatchmentMassDriver::AttemptPickUp(Oyster::Physics::ICustomBody *obj, void* args) { + if(obj->GetState().mass == 0) return; + AttatchmentMassDriver *weapon = ((AttatchmentMassDriver*)args); if(weapon->hasObject) diff --git a/Code/OysterPhysics3D/Cone.cpp b/Code/OysterPhysics3D/Cone.cpp index a336f820..61d7faf3 100644 --- a/Code/OysterPhysics3D/Cone.cpp +++ b/Code/OysterPhysics3D/Cone.cpp @@ -15,14 +15,14 @@ Cone::Cone( ) : ICollideable(Type_cone) this->height = Oyster::Math::Float3(0,0,0); } -Cone::Cone( const ::Oyster::Math::Float3 &height, const Oyster::Math::Float3 &position, const ::Oyster::Math::Float &radius ) +Cone::Cone( const ::Oyster::Math::Float3 &height, const Oyster::Math::Float3 &position, const ::Oyster::Math::Float &radius ) : ICollideable(Type_cone) { this->radius = radius; this->height = height; this->position = position; } -Cone::Cone( const ::Oyster::Math::Float4 &height, const Oyster::Math::Float4 &position, const ::Oyster::Math::Float &radius ) +Cone::Cone( const ::Oyster::Math::Float4 &height, const Oyster::Math::Float4 &position, const ::Oyster::Math::Float &radius ) : ICollideable(Type_cone) { this->radius = radius; this->height = (Oyster::Math::Float3)height; @@ -42,3 +42,8 @@ Cone & Cone::operator = ( const Cone &cone ) return *this; } +::Utility::DynamicMemory::UniquePointer Cone::Clone( ) const +{ + return ::Utility::DynamicMemory::UniquePointer( new Cone(*this) ); +} + diff --git a/Code/OysterPhysics3D/Cone.h b/Code/OysterPhysics3D/Cone.h index 0c12201a..3bae3df3 100644 --- a/Code/OysterPhysics3D/Cone.h +++ b/Code/OysterPhysics3D/Cone.h @@ -25,6 +25,15 @@ namespace Oyster Cone & operator = ( const Cone &Cone ); + virtual ::Utility::DynamicMemory::UniquePointer Clone( ) const; + + bool Intersects( const ICollideable &target ) const{return false;}; + bool Intersects( const ICollideable &target, ::Oyster::Math::Float4 &worldPointOfContact ) const{return false;}; + bool Contains( const ICollideable &target ) const{return false;}; + + ::Oyster::Math::Float TimeOfContact( const ICollideable &deuterStart, const ICollideable &deuterEnd ) const{return 0;}; + + Oyster::Math::Float3 height; Oyster::Math::Float3 position; Oyster::Math::Float radius; From f2a444507cb8b5da6854dd25a3f52c5f4699e4d2 Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Wed, 12 Feb 2014 11:35:48 +0100 Subject: [PATCH 18/24] GL - FIxed Button state flickering, added flag resizeToScreenAspectRatio. --- .../GameClientState/Buttons/ButtonEllipse.h | 18 +++++------ .../GameClientState/Buttons/ButtonRectangle.h | 16 +++++----- .../GameClientState/Buttons/EventButtonGUI.h | 26 +++++++++++----- .../GameClientState/LoginState.cpp | 31 ++++++++++--------- Code/Misc/EventHandler/EventButton.h | 4 +++ 5 files changed, 56 insertions(+), 39 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonEllipse.h b/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonEllipse.h index e74d4233..291bf07d 100644 --- a/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonEllipse.h +++ b/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonEllipse.h @@ -21,17 +21,17 @@ namespace DanBias ButtonEllipse() : EventButtonGUI(), radius(0) {} - ButtonEllipse(std::wstring textureName, Owner owner, float xPos, float yPos, float textureWidth, float textureHeight) - : EventButtonGUI(textureName, owner, xPos, yPos, textureWidth, textureHeight) + ButtonEllipse(std::wstring textureName, Owner owner, float xPos, float yPos, float textureWidth, float textureHeight, bool resizeToScreenAspectRatio = true) + : EventButtonGUI(textureName, owner, xPos, yPos, textureWidth, textureHeight, resizeToScreenAspectRatio) {} - ButtonEllipse(std::wstring textureName, EventFunc func, float xPos, float yPos, float textureWidth, float textureHeight) - : EventButtonGUI(textureName, func, xPos, yPos, textureWidth, textureHeight) + ButtonEllipse(std::wstring textureName, EventFunc func, float xPos, float yPos, float textureWidth, float textureHeight, bool resizeToScreenAspectRatio = true) + : EventButtonGUI(textureName, func, xPos, yPos, textureWidth, textureHeight, resizeToScreenAspectRatio) {} - ButtonEllipse(std::wstring textureName, EventFunc func, Owner owner, float xPos, float yPos, float textureWidth, float textureHeight) - : EventButtonGUI(textureName, func, owner, xPos, yPos, textureWidth, textureHeight) + ButtonEllipse(std::wstring textureName, EventFunc func, Owner owner, float xPos, float yPos, float textureWidth, float textureHeight, bool resizeToScreenAspectRatio = true) + : EventButtonGUI(textureName, func, owner, xPos, yPos, textureWidth, textureHeight, resizeToScreenAspectRatio) {} - ButtonEllipse(std::wstring textureName, EventFunc func, Owner owner, void* userData, float xPos, float yPos, float textureWidth, float textureHeight) - : EventButtonGUI(textureName, func, owner, userData, xPos, yPos, textureWidth, textureHeight) + ButtonEllipse(std::wstring textureName, EventFunc func, Owner owner, void* userData, float xPos, float yPos, float textureWidth, float textureHeight, bool resizeToScreenAspectRatio = true) + : EventButtonGUI(textureName, func, owner, userData, xPos, yPos, textureWidth, textureHeight, resizeToScreenAspectRatio) {} virtual ~ButtonEllipse() {} @@ -40,9 +40,9 @@ namespace DanBias bool Collision(InputClass* inputObject) { POINT p; + RECT r; GetCursorPos(&p); ScreenToClient(WindowShell::GetHWND(), &p); - RECT r; GetClientRect(WindowShell::GetHWND(), &r); //Should come from the InputClass diff --git a/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonRectangle.h b/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonRectangle.h index 1c725211..a1aac005 100644 --- a/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonRectangle.h +++ b/Code/Game/DanBiasGame/GameClientState/Buttons/ButtonRectangle.h @@ -21,17 +21,17 @@ namespace DanBias ButtonRectangle() : EventButtonGUI(), width(0), height(0) {} - ButtonRectangle(std::wstring textureName, Owner owner, float xPos, float yPos, float width, float height) - : EventButtonGUI(textureName, owner, xPos, yPos, width, height) + ButtonRectangle(std::wstring textureName, Owner owner, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true) + : EventButtonGUI(textureName, owner, xPos, yPos, width, height, resizeToScreenAspectRatio) {} - ButtonRectangle(std::wstring textureName, EventFunc func, float xPos, float yPos, float width, float height) - : EventButtonGUI(textureName, func, xPos, yPos, width, height) + ButtonRectangle(std::wstring textureName, EventFunc func, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true) + : EventButtonGUI(textureName, func, xPos, yPos, width, height, resizeToScreenAspectRatio) {} - ButtonRectangle(std::wstring textureName, EventFunc func, Owner owner, float xPos, float yPos, float width, float height) - : EventButtonGUI(textureName, func, owner, xPos, yPos, width, height) + ButtonRectangle(std::wstring textureName, EventFunc func, Owner owner, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true) + : EventButtonGUI(textureName, func, owner, xPos, yPos, width, height, resizeToScreenAspectRatio) {} - ButtonRectangle(std::wstring textureName, EventFunc func, Owner owner, void* userData, float xPos, float yPos, float width, float height) - : EventButtonGUI(textureName, func, owner, userData, xPos, yPos, width, height) + ButtonRectangle(std::wstring textureName, EventFunc func, Owner owner, void* userData, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true) + : EventButtonGUI(textureName, func, owner, userData, xPos, yPos, width, height, resizeToScreenAspectRatio) {} virtual ~ButtonRectangle() {} diff --git a/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h b/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h index 73bccc49..e71dd0fa 100644 --- a/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h +++ b/Code/Game/DanBiasGame/GameClientState/Buttons/EventButtonGUI.h @@ -19,25 +19,29 @@ namespace DanBias EventButtonGUI() : EventButton(), xPos(0), yPos(0), width(0), height(0), texture(NULL) {} - EventButtonGUI(std::wstring textureName, Owner owner, float xPos, float yPos, float width, float height) + EventButtonGUI(std::wstring textureName, Owner owner, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true) : EventButton(owner), xPos(xPos), yPos(yPos), width(width), height(height), texture(NULL) { CreateTexture(textureName); + if(resizeToScreenAspectRatio) ResizeWithAspectRatio(); } - EventButtonGUI(std::wstring textureName, EventFunc func, float xPos, float yPos, float width, float height) + EventButtonGUI(std::wstring textureName, EventFunc func, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true) : EventButton(func), xPos(xPos), yPos(yPos), width(width), height(height), texture(NULL) { CreateTexture(textureName); + if(resizeToScreenAspectRatio) ResizeWithAspectRatio(); } - EventButtonGUI(std::wstring textureName, EventFunc func, Owner owner, float xPos, float yPos, float width, float height) + EventButtonGUI(std::wstring textureName, EventFunc func, Owner owner, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true) : EventButton(func, owner), xPos(xPos), yPos(yPos), width(width), height(height), texture(NULL) { CreateTexture(textureName); + if(resizeToScreenAspectRatio) ResizeWithAspectRatio(); } - EventButtonGUI(std::wstring textureName, EventFunc func, Owner owner, void* userData, float xPos, float yPos, float width, float height) + EventButtonGUI(std::wstring textureName, EventFunc func, Owner owner, void* userData, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true) : EventButton(func, owner, userData), xPos(xPos), yPos(yPos), width(width), height(height), texture(NULL) { CreateTexture(textureName); + if(resizeToScreenAspectRatio) ResizeWithAspectRatio(); } virtual ~EventButtonGUI() { @@ -60,26 +64,32 @@ namespace DanBias if(EventButton::GetState() == ButtonState_None) { - Oyster::Graphics::API::RenderGuiElement(texture, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height), Oyster::Math::Float3(1, 1, 1)); + Oyster::Graphics::API::RenderGuiElement(texture, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height), Oyster::Math::Float3(1.0f, 1.0f, 1.0f)); } else if(EventButton::GetState() == ButtonState_Hover) { - Oyster::Graphics::API::RenderGuiElement(texture, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height), Oyster::Math::Float3(0, 1, 0)); + Oyster::Graphics::API::RenderGuiElement(texture, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height), Oyster::Math::Float3(0.0f, 1.0f, 0.0f)); } else { - Oyster::Graphics::API::RenderGuiElement(texture, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height), Oyster::Math::Float3(1, 0, 0)); + Oyster::Graphics::API::RenderGuiElement(texture, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height), Oyster::Math::Float3(1.0f, 0.0f, 0.0f)); } } } + void ResizeWithAspectRatio() + { + RECT r; + GetClientRect(WindowShell::GetHWND(), &r); + height *= (float)r.right/(float)r.bottom; + } + protected: float xPos, yPos; float width, height; Oyster::Graphics::API::Texture texture; - }; } } diff --git a/Code/Game/DanBiasGame/GameClientState/LoginState.cpp b/Code/Game/DanBiasGame/GameClientState/LoginState.cpp index 7424b7b2..b4dcdc45 100644 --- a/Code/Game/DanBiasGame/GameClientState/LoginState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/LoginState.cpp @@ -26,7 +26,7 @@ struct LoginState::myData //Menu button collection EventButtonCollection* collection; - + bool createGame; int testNumber; }privData; @@ -51,7 +51,7 @@ void LoginState::ButtonCallback(Oyster::Event::ButtonEvent& e) switch(type) { case Create: - /*if(e.state == ButtonState_None) + if(e.state == ButtonState_None) { int a = 0; std::cout << "None" << std::endl; @@ -76,7 +76,8 @@ void LoginState::ButtonCallback(Oyster::Event::ButtonEvent& e) //Change to create state or something similar int a = 0; std::cout << "Released" << std::endl; - }*/ + e.owner->privData->createGame = true; + } break; case Options: break; @@ -110,22 +111,23 @@ bool LoginState::Init(Oyster::Network::NetworkClient* nwClient) //Create menu buttons privData->collection = new EventButtonCollection; EventHandler::Instance().AddCollection(privData->collection); - privData->collection->AddButton(new ButtonEllipse(L"circle.png", &LoginState::ButtonCallback, this, (void*)Create, 0.2f, 0.2f, 0.1f, 0.2f)); - privData->collection->AddButton(new ButtonEllipse(L"circle.png", &LoginState::ButtonCallback, this, (void*)Create, 0.2f, 0.3f, 0.1f, 0.2f)); - privData->collection->AddButton(new ButtonEllipse(L"circle.png", &LoginState::ButtonCallback, this, (void*)Create, 0.2f, 0.4f, 0.1f, 0.2f)); - privData->collection->AddButton(new ButtonEllipse(L"circle.png", &LoginState::ButtonCallback, this, (void*)Create, 0.2f, 0.5f, 0.1f, 0.2f)); + privData->collection->AddButton(new ButtonEllipse(L"circle.png", &LoginState::ButtonCallback, this, (void*)Options, 0.2f, 0.2f, 0.1f, 0.1f)); + privData->collection->AddButton(new ButtonEllipse(L"circle.png", &LoginState::ButtonCallback, this, (void*)Options, 0.2f, 0.3f, 0.1f, 0.1f)); + privData->collection->AddButton(new ButtonEllipse(L"circle.png", &LoginState::ButtonCallback, this, (void*)Options, 0.2f, 0.4f, 0.1f, 0.1f)); + privData->collection->AddButton(new ButtonEllipse(L"circle.png", &LoginState::ButtonCallback, this, (void*)Options, 0.2f, 0.5f, 0.1f, 0.1f)); - privData->collection->AddButton(new ButtonRectangle(L"button.png", &LoginState::ButtonCallback, this, (void*)Create, 0.15f, 0.05f, 0.1f, 0.1f)); - privData->collection->AddButton(new ButtonRectangle(L"button.png", &LoginState::ButtonCallback, this, (void*)Create, 0.25f, 0.05f, 0.1f, 0.1f)); - privData->collection->AddButton(new ButtonRectangle(L"button.png", &LoginState::ButtonCallback, this, (void*)Create, 0.35f, 0.05f, 0.1f, 0.1f)); - privData->collection->AddButton(new ButtonRectangle(L"button.png", &LoginState::ButtonCallback, this, (void*)Create, 0.45f, 0.05f, 0.1f, 0.1f)); + privData->collection->AddButton(new ButtonRectangle(L"button.png", &LoginState::ButtonCallback, this, (void*)Options, 0.15f, 0.05f, 0.1f, 0.1f)); + privData->collection->AddButton(new ButtonRectangle(L"button.png", &LoginState::ButtonCallback, this, (void*)Options, 0.25f, 0.05f, 0.1f, 0.1f)); + privData->collection->AddButton(new ButtonRectangle(L"button.png", &LoginState::ButtonCallback, this, (void*)Options, 0.35f, 0.05f, 0.1f, 0.1f)); + privData->collection->AddButton(new ButtonRectangle(L"button.png", &LoginState::ButtonCallback, this, (void*)Options, 0.45f, 0.05f, 0.1f, 0.1f)); privData->collection->AddButton(new ButtonRectangle(L"button.png", &LoginState::ButtonCallback, this, (void*)Create, 0.5f, 0.5f, 0.3f, 0.3f)); //Incr/decr buttons privData->collection->AddButton(new ButtonRectangle(L"button.png", &LoginState::ButtonCallback, this, (void*)Incr, 0.85f, 0.2f, 0.1f, 0.1f)); privData->collection->AddButton(new ButtonRectangle(L"button.png", &LoginState::ButtonCallback, this, (void*)Decr, 0.55f, 0.2f, 0.1f, 0.1f)); - + + privData->createGame = false; privData->testNumber = 0; return true; @@ -182,7 +184,7 @@ GameClientState::ClientState LoginState::Update(float deltaTime, InputClass* Key // check data from server // create game - if( KeyInput->IsKeyPressed(DIK_C)) + if( KeyInput->IsKeyPressed(DIK_C) || privData->createGame) { DanBias::GameServerAPI::ServerInitDesc desc; @@ -239,8 +241,9 @@ bool LoginState::Render(float dt) wchar_t temp[10]; _itow_s(privData->testNumber, temp, 10); number = temp; + Oyster::Graphics::API::StartTextRender(); - Oyster::Graphics::API::RenderText(number, Oyster::Math::Float2(0.7, 0.2), Oyster::Math::Float2(0.1, 0.1), Oyster::Math::Float3(1, 0, 0)); + Oyster::Graphics::API::RenderText(number, Oyster::Math::Float2(0.7f, 0.2f), Oyster::Math::Float2(0.1f, 0.1f*(1008.0f/730.0f)), Oyster::Math::Float3(1.0f, 0.0f, 0.0f)); Oyster::Graphics::API::EndFrame(); return true; diff --git a/Code/Misc/EventHandler/EventButton.h b/Code/Misc/EventHandler/EventButton.h index 6e99fcc7..b891889d 100644 --- a/Code/Misc/EventHandler/EventButton.h +++ b/Code/Misc/EventHandler/EventButton.h @@ -160,6 +160,10 @@ namespace Oyster clicked = true; currentState = ButtonState_Pressed; } + else + { + currentState = ButtonState_Hover; + } break; case ButtonState_Released: currentState = ButtonState_Hover; From fa16f71a26f5a5b7c3fc97ebf889bc1ceb7db691 Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Wed, 12 Feb 2014 11:36:08 +0100 Subject: [PATCH 19/24] GL - forgot to commit files --- .../DanBiasGame/GameClientState/GameState.h | 1 + Code/Game/GameLogic/CollisionManager.cpp | 1 + Code/Game/GameLogic/Game_PlayerData.cpp | 2 +- Code/Game/GameLogic/Level.cpp | 2 +- Code/Game/GameLogic/Player.cpp | 49 ++++++++++--------- Code/Game/GameLogic/Player.h | 4 +- Code/Game/GameProtocols/ObjectProtocols.h | 10 ++-- 7 files changed, 38 insertions(+), 31 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.h b/Code/Game/DanBiasGame/GameClientState/GameState.h index 5935398d..74226008 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.h +++ b/Code/Game/DanBiasGame/GameClientState/GameState.h @@ -33,6 +33,7 @@ private: int myId; float pitch; + float timer; struct myData; myData* privData; Utility::DynamicMemory::DynamicArray> staticObjects; diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index 9c6f6aca..3c556d5f 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -38,6 +38,7 @@ using namespace GameLogic; break; case OBJECT_TYPE::OBJECT_TYPE_WORLD: PlayerVObject(*player,*realObj, kineticEnergyLoss); + player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING; break; } diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index 39ce44cb..908dd42f 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -6,7 +6,7 @@ using namespace GameLogic; Game::PlayerData::PlayerData() { //set some stats that are appropriate to a player - Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(0,628,-25); + Oyster::Math::Float3 centerPosition = Oyster::Math::Float3(0,603,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; diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index 619b491e..e7b10eac 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -113,7 +113,7 @@ void Level::InitiateLevel(std::string levelPath) void Level::InitiateLevel(float radius) { API::Instance().SetGravityPoint(Oyster::Math3D::Float3(0,0,0)); - API::Instance().SetGravity(100); + API::Instance().SetGravity(200); int idCount = 100; // add level sphere ICustomBody* rigidBody = API::Instance().AddCollisionSphere(599.2f, Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f); diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 238d5e68..61ee108f 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -45,7 +45,8 @@ void Player::InitPlayer() this->life = 100; this->teamID = -1; this->playerState = PLAYER_STATE_IDLE; - lookDir = Oyster::Math::Float4(0,0,-1,0); + this->lookDir = Oyster::Math::Float3(0,0,-1); + this->moveDir = Oyster::Math::Float3(0,0,0); } Player::~Player(void) @@ -61,8 +62,6 @@ void Player::BeginFrame() { //weapon->Update(0.002f); Object::BeginFrame(); - - } void Player::EndFrame() @@ -99,27 +98,37 @@ void Player::Move(const PLAYER_MOVEMENT &movement) void Player::MoveForward() { - Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2]; - rigidBody->SetLinearVelocity( MOVE_FORCE * forward.GetNormalized() ); + Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized(); + moveDir = forward; + moveDir.Normalize(); + rigidBody->SetLinearVelocity( MOVE_FORCE * moveDir ); } void Player::MoveBackwards() { - Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2]; - rigidBody->SetLinearVelocity( MOVE_FORCE * -forward.GetNormalized() ); + Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized(); + moveDir = -forward; + moveDir.Normalize(); + rigidBody->SetLinearVelocity( MOVE_FORCE * moveDir ); } void Player::MoveRight() { //Do cross product with forward vector and negative gravity vector - Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2]; - Oyster::Math::Float3 r = (-this->rigidBody->GetState().centerPos.Normalize()).Cross(forward); - rigidBody->SetLinearVelocity(r * MOVE_FORCE); + Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized(); + Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos.Normalize(); + Oyster::Math::Float3 r = (up).Cross(forward).Normalize(); + moveDir = -r; + moveDir.Normalize(); + rigidBody->SetLinearVelocity( MOVE_FORCE * moveDir ); } void Player::MoveLeft() { //Do cross product with forward vector and negative gravity vector - Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2]; - Oyster::Math::Float3 r = (-this->rigidBody->GetState().centerPos.Normalize()).Cross(forward); - rigidBody->SetLinearVelocity(-r * MOVE_FORCE); + Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized(); + Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos.Normalize(); + Oyster::Math::Float3 r = (up).Cross(forward).Normalize(); + moveDir = r; + moveDir.Normalize(); + rigidBody->SetLinearVelocity( MOVE_FORCE * moveDir ); } void Player::UseWeapon(const WEAPON_FIRE &usage) @@ -137,27 +146,19 @@ void Player::Respawn(Oyster::Math::Float3 spawnPoint) void Player::Rotate(const Oyster::Math3D::Float4 lookDir) { - // right - Oyster::Math::Float dx = lookDir.w; - if(dx > 0.0f) - { - int i =0 ; - } - + // this is the camera right vector this->lookDir = lookDir.xyz; - this->dx = lookDir.w; - Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1]; this->rigidBody->SetUpAndRight(up, lookDir.xyz); this->rigidBody->SetUpAndRight(this->rigidBody->GetState().centerPos.GetNormalized(), this->rigidBody->GetState().GetOrientation().v[0].xyz.GetNormalized()); - } void Player::Jump() { Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1].GetNormalized(); - this->rigidBody->ApplyImpulse(up *2000); + this->rigidBody->ApplyImpulse(up *1500); + this->playerState == PLAYER_STATE::PLAYER_STATE_JUMPING; } bool Player::IsWalking() diff --git a/Code/Game/GameLogic/Player.h b/Code/Game/GameLogic/Player.h index b7791a42..623b0988 100644 --- a/Code/Game/GameLogic/Player.h +++ b/Code/Game/GameLogic/Player.h @@ -85,8 +85,8 @@ namespace GameLogic int teamID; Weapon *weapon; PLAYER_STATE playerState; - Oyster::Math::Float3 lookDir; //Duplicate in Object.h? - Oyster::Math::Float dx; //dx of what? + Oyster::Math::Float3 moveDir; + Oyster::Math::Float3 lookDir; bool hasTakenDamage; float invincibleCooldown; diff --git a/Code/Game/GameProtocols/ObjectProtocols.h b/Code/Game/GameProtocols/ObjectProtocols.h index 753d61e3..6dd32d62 100644 --- a/Code/Game/GameProtocols/ObjectProtocols.h +++ b/Code/Game/GameProtocols/ObjectProtocols.h @@ -292,7 +292,7 @@ namespace GameLogic { short object_ID; float position[3]; - float rotation[3]; + float rotation[4]; Protocol_ObjectPositionRotation() { @@ -307,10 +307,11 @@ namespace GameLogic this->protocol[5].type = Oyster::Network::NetAttributeType_Float; this->protocol[6].type = Oyster::Network::NetAttributeType_Float; this->protocol[7].type = Oyster::Network::NetAttributeType_Float; + this->protocol[8].type = Oyster::Network::NetAttributeType_Float; this->object_ID = 0; memset(&this->position[0], 0, sizeof(float) * 3); - memset(&this->rotation[0], 0, sizeof(float) * 3); + memset(&this->rotation[0], 0, sizeof(float) * 4); } Protocol_ObjectPositionRotation(Oyster::Network::CustomNetProtocol& p) { @@ -323,6 +324,7 @@ namespace GameLogic this->rotation[0] = p[5].value.netFloat; this->rotation[1] = p[6].value.netFloat; this->rotation[2] = p[7].value.netFloat; + this->rotation[3] = p[8].value.netFloat; } Protocol_ObjectPositionRotation(float p[3], float r[3], int id) { @@ -337,10 +339,11 @@ namespace GameLogic this->protocol[5].type = Oyster::Network::NetAttributeType_Float; this->protocol[6].type = Oyster::Network::NetAttributeType_Float; this->protocol[7].type = Oyster::Network::NetAttributeType_Float; + this->protocol[8].type = Oyster::Network::NetAttributeType_Float; object_ID = id; memcpy(&this->position[0], &p[0], sizeof(float) * 3); - memcpy(&this->rotation[0], &r[0], sizeof(float) * 3); + memcpy(&this->rotation[0], &r[0], sizeof(float) * 4); } Oyster::Network::CustomNetProtocol GetProtocol() override { @@ -351,6 +354,7 @@ namespace GameLogic this->protocol[5].value = this->rotation[0]; this->protocol[6].value = this->rotation[1]; this->protocol[7].value = this->rotation[2]; + this->protocol[8].value = this->rotation[3]; return protocol; } From cc4e3f947cdbd3561e1286d3dc6c8bb479eee9eb Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Wed, 12 Feb 2014 12:16:16 +0100 Subject: [PATCH 20/24] GL - playermovement fixed, can walk in diagonal directions --- Code/Game/GameLogic/Player.cpp | 66 ++++++++++++++++++++++------------ Code/Game/GameLogic/Player.h | 4 +++ 2 files changed, 48 insertions(+), 22 deletions(-) diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 61ee108f..31a436bf 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -7,6 +7,7 @@ using namespace GameLogic; using namespace Oyster::Physics; const int MOVE_FORCE = 30; +const float KEY_TIMER = 0.04f; Player::Player() :DynamicObject() { @@ -47,6 +48,10 @@ void Player::InitPlayer() 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; } Player::~Player(void) @@ -62,6 +67,41 @@ void Player::BeginFrame() { //weapon->Update(0.002f); Object::BeginFrame(); + Oyster::Math::Float3 forward(0,0,0); + Oyster::Math::Float3 back(0,0,0); + Oyster::Math::Float3 right(0,0,0); + Oyster::Math::Float3 left(0,0,0); + Oyster::Math::Float3 moveDirection(0,0,0); + if (key_forward > 0.001) + { + key_forward -= gameInstance->GetFrameTime(); + forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized(); + } + if (key_backward > 0.001) + { + key_backward -= gameInstance->GetFrameTime(); + back = -this->rigidBody->GetState().GetOrientation().v[2].GetNormalized(); + } + if (key_strafeRight > 0.001) + { + + key_strafeRight -= gameInstance->GetFrameTime(); + Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized(); + Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos.Normalize(); + right = -((up).Cross(forward).Normalize()); + right.Normalize(); + } + if (key_strafeLeft > 0.001) + { + key_strafeLeft -= gameInstance->GetFrameTime(); + Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized(); + Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos.Normalize(); + left = (up).Cross(forward).Normalize(); + left.Normalize(); + } + moveDirection = forward + back + left + right; + //moveDirection.Normalize(); + rigidBody->SetLinearVelocity( MOVE_FORCE * moveDirection ); } void Player::EndFrame() @@ -98,37 +138,19 @@ void Player::Move(const PLAYER_MOVEMENT &movement) void Player::MoveForward() { - Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized(); - moveDir = forward; - moveDir.Normalize(); - rigidBody->SetLinearVelocity( MOVE_FORCE * moveDir ); + key_forward = KEY_TIMER; } void Player::MoveBackwards() { - Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized(); - moveDir = -forward; - moveDir.Normalize(); - rigidBody->SetLinearVelocity( MOVE_FORCE * moveDir ); + key_backward = KEY_TIMER; } void Player::MoveRight() { - //Do cross product with forward vector and negative gravity vector - Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized(); - Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos.Normalize(); - Oyster::Math::Float3 r = (up).Cross(forward).Normalize(); - moveDir = -r; - moveDir.Normalize(); - rigidBody->SetLinearVelocity( MOVE_FORCE * moveDir ); + key_strafeRight = KEY_TIMER; } void Player::MoveLeft() { - //Do cross product with forward vector and negative gravity vector - Oyster::Math::Float3 forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized(); - Oyster::Math::Float3 up = this->rigidBody->GetState().centerPos.Normalize(); - Oyster::Math::Float3 r = (up).Cross(forward).Normalize(); - moveDir = r; - moveDir.Normalize(); - rigidBody->SetLinearVelocity( MOVE_FORCE * moveDir ); + key_strafeLeft = KEY_TIMER; } void Player::UseWeapon(const WEAPON_FIRE &usage) diff --git a/Code/Game/GameLogic/Player.h b/Code/Game/GameLogic/Player.h index 623b0988..bb00c23b 100644 --- a/Code/Game/GameLogic/Player.h +++ b/Code/Game/GameLogic/Player.h @@ -87,6 +87,10 @@ namespace GameLogic PLAYER_STATE playerState; Oyster::Math::Float3 moveDir; Oyster::Math::Float3 lookDir; + float key_forward; + float key_backward; + float key_strafeRight; + float key_strafeLeft; bool hasTakenDamage; float invincibleCooldown; From 15cc7cb85e769e44d0c8bea226f302c3b007cf4e Mon Sep 17 00:00:00 2001 From: Robin Engman Date: Wed, 12 Feb 2014 12:38:52 +0100 Subject: [PATCH 21/24] Fixed collision for object not in world --- .../Implementation/PhysicsAPI_Impl.cpp | 4 +- .../Implementation/PhysicsAPI_Impl.h | 2 +- Code/OysterPhysics3D/Cone.cpp | 38 +++++++++++-------- Code/OysterPhysics3D/Cone.h | 15 ++++---- 4 files changed, 33 insertions(+), 26 deletions(-) diff --git a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp index 820688a5..3b4fc74d 100644 --- a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp +++ b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.cpp @@ -297,10 +297,10 @@ void API_Impl::ApplyEffect(Oyster::Collision3D::ICollideable* collideable, void* case ICollideable::Type::Type_cone: cone = dynamic_cast(collideable); // Add collision shape - shape = new btConeShape(cone->radius, cone->height.GetLength()); + shape = new btConeShapeZ(cone->radius, cone->length); // Add motion state - state = new btDefaultMotionState(btTransform(btQuaternion(btVector3(cone->height.x, cone->height.y, cone->height.z).normalized(), 0.0f),btVector3(cone->position.x, cone->position.y, cone->position.z))); + state = new btDefaultMotionState(btTransform(btQuaternion(cone->quaternion.x, cone->quaternion.y, cone->quaternion.z, cone->quaternion.w),btVector3(cone->center.x, cone->center.y, cone->center.z))); // Add rigid body rigidBodyCI = btRigidBody::btRigidBodyConstructionInfo (0, state, shape); diff --git a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.h b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.h index c2e3d5ea..422e82ef 100644 --- a/Code/GamePhysics/Implementation/PhysicsAPI_Impl.h +++ b/Code/GamePhysics/Implementation/PhysicsAPI_Impl.h @@ -39,7 +39,7 @@ namespace Oyster } else { - assert(colObj1->m_collisionObject == &body && "Body does not match either collision object"); + //assert(colObj1->m_collisionObject == &body && "Body does not match either collision object"); pt = cp.m_localPointB; this->func((ICustomBody*)(colObj0->getCollisionObject()->getUserPointer()), this->args); } diff --git a/Code/OysterPhysics3D/Cone.cpp b/Code/OysterPhysics3D/Cone.cpp index 61d7faf3..ccc190d6 100644 --- a/Code/OysterPhysics3D/Cone.cpp +++ b/Code/OysterPhysics3D/Cone.cpp @@ -11,22 +11,36 @@ using namespace ::Oyster::Math3D; Cone::Cone( ) : ICollideable(Type_cone) { + this->center = Float3(0, 0, 0); + this->quaternion = Float4(0, 0, 0, 1); this->radius = 1; - this->height = Oyster::Math::Float3(0,0,0); + this->length = 0; } -Cone::Cone( const ::Oyster::Math::Float3 &height, const Oyster::Math::Float3 &position, const ::Oyster::Math::Float &radius ) : ICollideable(Type_cone) +Cone & Cone::operator = ( const Cone &Cone ) { - this->radius = radius; - this->height = height; - this->position = position; + this->center = Cone.center; + this->quaternion = Cone.quaternion; + this->radius = Cone.radius; + this->length = Cone.length; + + return *this; } -Cone::Cone( const ::Oyster::Math::Float4 &height, const Oyster::Math::Float4 &position, const ::Oyster::Math::Float &radius ) : ICollideable(Type_cone) +Cone::Cone( const ::Oyster::Math::Float &height, const Oyster::Math::Float3 &position, const Oyster::Math::Float4 &quaternion, const ::Oyster::Math::Float &radius ) : ICollideable(Type_cone) { + this->center = position; + this->quaternion = quaternion; this->radius = radius; - this->height = (Oyster::Math::Float3)height; - this->position = (Oyster::Math::Float3)position; + this->length = height; +} + +Cone::Cone( const ::Oyster::Math::Float &height, const Oyster::Math::Float4 &position, const Oyster::Math::Float4 &quaternion, const ::Oyster::Math::Float &radius ) : ICollideable(Type_cone) +{ + this->center = position; + this->quaternion = quaternion; + this->radius = radius; + this->length = height; } Cone::~Cone( ) @@ -34,14 +48,6 @@ Cone::~Cone( ) } -Cone & Cone::operator = ( const Cone &cone ) -{ - this->radius = cone.radius; - this->height = cone.height; - this->position = cone.position; - return *this; -} - ::Utility::DynamicMemory::UniquePointer Cone::Clone( ) const { return ::Utility::DynamicMemory::UniquePointer( new Cone(*this) ); diff --git a/Code/OysterPhysics3D/Cone.h b/Code/OysterPhysics3D/Cone.h index 3bae3df3..64ff98b9 100644 --- a/Code/OysterPhysics3D/Cone.h +++ b/Code/OysterPhysics3D/Cone.h @@ -18,9 +18,15 @@ namespace Oyster { public: + union + { + struct{ ::Oyster::Math::Float3 center; ::Oyster::Math::Float4 quaternion; ::Oyster::Math::Float radius; ::Oyster::Math::Float length; }; + char byte[sizeof(::Oyster::Math::Float3) + sizeof(::Oyster::Math::Float4) + sizeof(::Oyster::Math::Float) + sizeof(::Oyster::Math::Float)]; + }; + Cone(); - Cone( const ::Oyster::Math::Float3 &height, const Oyster::Math::Float3 &position, const ::Oyster::Math::Float &radius ); - Cone( const ::Oyster::Math::Float4 &height, const Oyster::Math::Float4 &position, const ::Oyster::Math::Float &radius ); + Cone( const ::Oyster::Math::Float &height, const Oyster::Math::Float3 &position, const Oyster::Math::Float4 &quaternion, const ::Oyster::Math::Float &radius ); + Cone( const ::Oyster::Math::Float &height, const Oyster::Math::Float4 &position, const Oyster::Math::Float4 &quaternion, const ::Oyster::Math::Float &radius ); virtual ~Cone( ); Cone & operator = ( const Cone &Cone ); @@ -32,11 +38,6 @@ namespace Oyster bool Contains( const ICollideable &target ) const{return false;}; ::Oyster::Math::Float TimeOfContact( const ICollideable &deuterStart, const ICollideable &deuterEnd ) const{return 0;}; - - - Oyster::Math::Float3 height; - Oyster::Math::Float3 position; - Oyster::Math::Float radius; }; } From e8536cc5d4d97ba45dadf587ebe0d872e2206660 Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Wed, 12 Feb 2014 13:11:35 +0100 Subject: [PATCH 22/24] GL - removed before collision event, sending look and right dir to server --- .../DanBiasGame/GameClientState/GameState.cpp | 13 ++-- Code/Game/GameLogic/CollisionManager.cpp | 17 +---- Code/Game/GameLogic/DynamicObject.cpp | 12 ++-- Code/Game/GameLogic/DynamicObject.h | 6 +- Code/Game/GameLogic/Game.h | 2 +- Code/Game/GameLogic/GameAPI.h | 2 +- Code/Game/GameLogic/Game_PlayerData.cpp | 11 +-- Code/Game/GameLogic/JumpPad.cpp | 4 +- Code/Game/GameLogic/JumpPad.h | 1 - Code/Game/GameLogic/Level.cpp | 12 ++-- Code/Game/GameLogic/Level.h | 1 - Code/Game/GameLogic/Object.cpp | 10 +-- Code/Game/GameLogic/Object.h | 7 +- Code/Game/GameLogic/Player.cpp | 23 ++++--- Code/Game/GameLogic/Player.h | 10 +-- Code/Game/GameLogic/StaticObject.cpp | 12 ++-- Code/Game/GameLogic/StaticObject.h | 6 +- Code/Game/GameProtocols/ObjectProtocols.h | 2 +- Code/Game/GameProtocols/PlayerProtocols.h | 68 ++++++++++++------- .../Implementation/GameSession_Gameplay.cpp | 10 ++- 20 files changed, 110 insertions(+), 119 deletions(-) diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index 5c620021..8eff1be2 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -449,15 +449,12 @@ void GameState::readKeyInput(InputClass* KeyInput) camera->Yaw(-KeyInput->GetYaw()); camera->Pitch(KeyInput->GetPitch()); pitch = KeyInput->GetPitch(); - camera->UpdateViewMatrix(); - GameLogic::Protocol_PlayerLook playerLookDir; - Oyster::Math::Float4 look = camera->GetRight(); - playerLookDir.lookDirX = look.x; - playerLookDir.lookDirY = look.y; - playerLookDir.lookDirZ = look.z; - playerLookDir.deltaX = -KeyInput->GetYaw(); + camera->UpdateViewMatrix(); + Oyster::Math::Float3 look = camera->GetLook(); + Oyster::Math::Float3 right = camera->GetRight(); + GameLogic::Protocol_PlayerLook playerLook(look, right); - privData->nwClient->Send(playerLookDir); + privData->nwClient->Send(playerLook); } // shoot diff --git a/Code/Game/GameLogic/CollisionManager.cpp b/Code/Game/GameLogic/CollisionManager.cpp index 27949cc9..0ef2a204 100644 --- a/Code/Game/GameLogic/CollisionManager.cpp +++ b/Code/Game/GameLogic/CollisionManager.cpp @@ -38,7 +38,7 @@ using namespace GameLogic; break; case OBJECT_TYPE::OBJECT_TYPE_WORLD: PlayerVObject(*player,*realObj, kineticEnergyLoss); - player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING; + //player->playerState = PLAYER_STATE::PLAYER_STATE_WALKING; break; } @@ -89,28 +89,15 @@ using namespace GameLogic; } } - Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj) - { - return Physics::ICustomBody::SubscriptMessage_none; - } + Oyster::Physics::ICustomBody::SubscriptMessage Object::DefaultCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss) { return Physics::ICustomBody::SubscriptMessage_none; } - Oyster::Physics::ICustomBody::SubscriptMessage Player::PlayerCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj) - { - return Physics::ICustomBody::SubscriptMessage_player_collision_response; - } Oyster::Physics::ICustomBody::SubscriptMessage Player::PlayerCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss) { return Physics::ICustomBody::SubscriptMessage_none; } - //Oyster::Physics::ICustomBody::SubscriptMessage - Oyster::Physics::ICustomBody::SubscriptMessage Level::LevelCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj) - { - return Physics::ICustomBody::SubscriptMessage_ignore_collision_response; - } - Oyster::Physics::ICustomBody::SubscriptMessage CollisionManager::IgnoreCollision(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody *obj) { return Physics::ICustomBody::SubscriptMessage_ignore_collision_response; diff --git a/Code/Game/GameLogic/DynamicObject.cpp b/Code/Game/GameLogic/DynamicObject.cpp index 437dca2c..05a4138d 100644 --- a/Code/Game/GameLogic/DynamicObject.cpp +++ b/Code/Game/GameLogic/DynamicObject.cpp @@ -20,18 +20,18 @@ DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYP } -DynamicObject::DynamicObject(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) - :Object(collisionFuncBefore,collisionFuncAfter,type) +DynamicObject::DynamicObject( void* collisionFuncAfter, OBJECT_TYPE type) + :Object(collisionFuncAfter,type) { } -DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) - :Object(rigidBody, collisionFuncBefore, collisionFuncAfter, type) +DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, OBJECT_TYPE type) + :Object(rigidBody, collisionFuncAfter, type) { } -DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) - :Object(rigidBody, collisionFuncBefore, collisionFuncAfter, type) +DynamicObject::DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) + :Object(rigidBody, collisionFuncAfter, type) { } diff --git a/Code/Game/GameLogic/DynamicObject.h b/Code/Game/GameLogic/DynamicObject.h index 3fcdae39..815875b3 100644 --- a/Code/Game/GameLogic/DynamicObject.h +++ b/Code/Game/GameLogic/DynamicObject.h @@ -16,9 +16,9 @@ namespace GameLogic DynamicObject(); DynamicObject(OBJECT_TYPE type); DynamicObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type); - DynamicObject(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); - DynamicObject(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); - DynamicObject(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type); + DynamicObject( void* collisionFuncAfter, OBJECT_TYPE type); + DynamicObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, OBJECT_TYPE type); + DynamicObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type); ~DynamicObject(void); diff --git a/Code/Game/GameLogic/Game.h b/Code/Game/GameLogic/Game.h index 601b0f0c..d88ddd7b 100644 --- a/Code/Game/GameLogic/Game.h +++ b/Code/Game/GameLogic/Game.h @@ -41,7 +41,7 @@ namespace GameLogic Oyster::Math::Float4x4 GetOrientation() override; int GetID() const override; OBJECT_TYPE GetObjectType() const override; - void Rotate(const Oyster::Math3D::Float4 lookDir) override; + void Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right) override; Player *player; }; diff --git a/Code/Game/GameLogic/GameAPI.h b/Code/Game/GameLogic/GameAPI.h index d51cf4a6..79656878 100644 --- a/Code/Game/GameLogic/GameAPI.h +++ b/Code/Game/GameLogic/GameAPI.h @@ -83,7 +83,7 @@ namespace GameLogic * @param x: The relative x axis * @param y: The relative y axis **/ - virtual void Rotate(const Oyster::Math3D::Float4 lookDir) = 0; + virtual void Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right) = 0; /******************************************************** * Uses the chosen players weapon based on input diff --git a/Code/Game/GameLogic/Game_PlayerData.cpp b/Code/Game/GameLogic/Game_PlayerData.cpp index 908dd42f..56df13c4 100644 --- a/Code/Game/GameLogic/Game_PlayerData.cpp +++ b/Code/Game/GameLogic/Game_PlayerData.cpp @@ -18,13 +18,8 @@ Game::PlayerData::PlayerData() 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,Level::LevelCollisionBefore, Player::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER); + this->player = new Player(rigidBody, Player::PlayerCollision, OBJECT_TYPE::OBJECT_TYPE_PLAYER); this->player->GetRigidBody()->SetCustomTag(this); - - //Oyster::Physics::ICustomBody::State state; - //this->player->GetRigidBody()->GetState(state); - ////state.SetRotation(Oyster::Math::Float3(0, Oyster::Math::pi, 0)); - //this->player->GetRigidBody()->SetState(state); player->EndFrame(); } Game::PlayerData::PlayerData(int playerID,int teamID) @@ -77,7 +72,7 @@ OBJECT_TYPE Game::PlayerData::GetObjectType() const { return this->player->GetObjectType(); } -void Game::PlayerData::Rotate(const Oyster::Math3D::Float4 lookDir) +void Game::PlayerData::Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right) { - this->player->Rotate(lookDir); + this->player->Rotate(lookDir, right); } \ No newline at end of file diff --git a/Code/Game/GameLogic/JumpPad.cpp b/Code/Game/GameLogic/JumpPad.cpp index c60e248c..15b80dc8 100644 --- a/Code/Game/GameLogic/JumpPad.cpp +++ b/Code/Game/GameLogic/JumpPad.cpp @@ -8,8 +8,8 @@ JumpPad::JumpPad(void) { } -JumpPad::JumpPad(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type, Oyster::Math::Float3 pushForce) - :StaticObject(rigidBody, collisionFuncBefore, collisionFuncAfter, type) +JumpPad::JumpPad(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type, Oyster::Math::Float3 pushForce) + :StaticObject(rigidBody, collisionFuncAfter, type) { } diff --git a/Code/Game/GameLogic/JumpPad.h b/Code/Game/GameLogic/JumpPad.h index b9fe2253..8d645a00 100644 --- a/Code/Game/GameLogic/JumpPad.h +++ b/Code/Game/GameLogic/JumpPad.h @@ -9,7 +9,6 @@ namespace GameLogic JumpPad(void); JumpPad(Oyster::Physics::ICustomBody *rigidBody - ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter) ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss) ,OBJECT_TYPE type, Oyster::Math::Float3 pushForce); diff --git a/Code/Game/GameLogic/Level.cpp b/Code/Game/GameLogic/Level.cpp index e7b10eac..04324fcc 100644 --- a/Code/Game/GameLogic/Level.cpp +++ b/Code/Game/GameLogic/Level.cpp @@ -82,7 +82,7 @@ void Level::InitiateLevel(std::string levelPath) // add rigidbody to the logical obj // Object::DefaultCollisionBefore, Object::DefaultCollisionAfter for now, gamelogic will take care of this // set object_type to objID - this->staticObjects.Push(new StaticObject(rigidBody,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); + this->staticObjects.Push(new StaticObject(rigidBody, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); this->staticObjects[staticObjCount]->objectID = modelCount++; rigidBody->SetCustomTag(this->staticObjects[staticObjCount]); @@ -97,7 +97,7 @@ void Level::InitiateLevel(std::string levelPath) rigidBody_Dynamic = 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_Dynamic,Object::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); + this->dynamicObjects.Push(new DynamicObject(rigidBody_Dynamic, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); this->dynamicObjects[dynamicObjCount]->objectID = modelCount++; rigidBody_Dynamic->SetCustomTag(this->dynamicObjects[dynamicObjCount]); } @@ -117,7 +117,7 @@ void Level::InitiateLevel(float radius) int idCount = 100; // add level sphere ICustomBody* rigidBody = API::Instance().AddCollisionSphere(599.2f, Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f); - levelObj = new StaticObject(rigidBody, LevelCollisionBefore, LevelCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_WORLD); + levelObj = new StaticObject(rigidBody, LevelCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_WORLD); this->levelObj->objectID = idCount++; rigidBody->SetCustomTag(levelObj); @@ -130,7 +130,7 @@ 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::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); + this->dynamicObjects.Push(new DynamicObject(rigidBody_TestBox, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); this->dynamicObjects[i]->objectID = idCount++; rigidBody_TestBox->SetCustomTag(this->dynamicObjects[i]); } @@ -168,7 +168,7 @@ 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::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); + this->dynamicObjects.Push(new DynamicObject(rigidBody_Crystal, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_BOX)); rigidBody_Crystal->SetCustomTag(this->dynamicObjects[nrOfBoxex]); this->dynamicObjects[nrOfBoxex]->objectID = idCount++; @@ -176,7 +176,7 @@ void Level::InitiateLevel(float radius) // 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::DefaultCollisionBefore, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_GENERIC)); + this->staticObjects.Push(new StaticObject(rigidBody_House, Object::DefaultCollisionAfter, OBJECT_TYPE::OBJECT_TYPE_GENERIC)); rigidBody_House->SetCustomTag(this->staticObjects[0]); this->staticObjects[0]->objectID = idCount++; } diff --git a/Code/Game/GameLogic/Level.h b/Code/Game/GameLogic/Level.h index 581d1ee0..15f4a832 100644 --- a/Code/Game/GameLogic/Level.h +++ b/Code/Game/GameLogic/Level.h @@ -60,7 +60,6 @@ namespace GameLogic * @param rigidBodyLevel: physics object of the level * @param obj: physics object for the object that collided with the level ********************************************************/ - static Oyster::Physics::ICustomBody::SubscriptMessage LevelCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj); static Oyster::Physics::ICustomBody::SubscriptMessage LevelCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss); int getNrOfDynamicObj(); diff --git a/Code/Game/GameLogic/Object.cpp b/Code/Game/GameLogic/Object.cpp index 78141e5f..631ae1b7 100644 --- a/Code/Game/GameLogic/Object.cpp +++ b/Code/Game/GameLogic/Object.cpp @@ -36,7 +36,7 @@ Object::Object(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type) this->objectID = GID(); } -Object::Object(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) +Object::Object( void* collisionFuncAfter, OBJECT_TYPE type) { this->rigidBody = API::Instance().AddCollisionBox(Oyster::Math::Float3(0.0f, 0.0f, 0.0f), Oyster::Math::Float4(0, 0, 0, 1), Oyster::Math::Float3(0, 0, 0), 0, 0.5f, 0.8f, 0.6f); @@ -44,18 +44,18 @@ Object::Object(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE this->objectID = GID(); } -Object::Object(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) +Object::Object(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, OBJECT_TYPE type) { this->rigidBody = rigidBody; - + this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter)); this->type = type; this->objectID = GID(); } -Object::Object(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) +Object::Object(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) { this->rigidBody = rigidBody; - + this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_AfterCollisionResponse)(collisionFuncAfter)); this->type = type; this->objectID = GID(); } diff --git a/Code/Game/GameLogic/Object.h b/Code/Game/GameLogic/Object.h index 293ba85d..677aef13 100644 --- a/Code/Game/GameLogic/Object.h +++ b/Code/Game/GameLogic/Object.h @@ -20,9 +20,9 @@ namespace GameLogic Object(); Object(OBJECT_TYPE type); Object(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type); - Object(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); - Object(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); - Object(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type); + Object(void* collisionFuncAfter, OBJECT_TYPE type); + Object(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, OBJECT_TYPE type); + Object(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type); ~Object(void); OBJECT_TYPE GetObjectType() const override; @@ -43,7 +43,6 @@ namespace GameLogic void setBeforeCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter)); void setAfterCollisonFunc(Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss)); - static Oyster::Physics::ICustomBody::SubscriptMessage DefaultCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj); static Oyster::Physics::ICustomBody::SubscriptMessage DefaultCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss); public: //HACK: This should be private when level is dynamic diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 31a436bf..f6267876 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -7,7 +7,7 @@ using namespace GameLogic; using namespace Oyster::Physics; const int MOVE_FORCE = 30; -const float KEY_TIMER = 0.04f; +const float KEY_TIMER = 0.03f; Player::Player() :DynamicObject() { @@ -23,18 +23,18 @@ Player::Player(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type) { InitPlayer(); } -Player::Player(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) - :DynamicObject(collisionFuncBefore,collisionFuncAfter,type) +Player::Player( void* collisionFuncAfter, OBJECT_TYPE type) + :DynamicObject(collisionFuncAfter,type) { InitPlayer(); } -Player::Player(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) - :DynamicObject(rigidBody, collisionFuncBefore, collisionFuncAfter, type) +Player::Player(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, OBJECT_TYPE type) + :DynamicObject(rigidBody, collisionFuncAfter, type) { InitPlayer(); } -Player::Player(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) - :DynamicObject(rigidBody, collisionFuncBefore, collisionFuncAfter, type) +Player::Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) + :DynamicObject(rigidBody, collisionFuncAfter, type) { InitPlayer(); } @@ -74,7 +74,7 @@ void Player::BeginFrame() Oyster::Math::Float3 moveDirection(0,0,0); if (key_forward > 0.001) { - key_forward -= gameInstance->GetFrameTime(); + key_forward -= gameInstance->GetFrameTime(); // fixed timer forward = this->rigidBody->GetState().GetOrientation().v[2].GetNormalized(); } if (key_backward > 0.001) @@ -160,19 +160,20 @@ void Player::UseWeapon(const WEAPON_FIRE &usage) void Player::Respawn(Oyster::Math::Float3 spawnPoint) { + key_jump = this->life = 100; this->playerState = PLAYER_STATE::PLAYER_STATE_IDLE; this->lookDir = Oyster::Math::Float4(1,0,0); this->rigidBody->SetPosition(spawnPoint); } -void Player::Rotate(const Oyster::Math3D::Float4 lookDir) +void Player::Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right) { // this is the camera right vector - this->lookDir = lookDir.xyz; + this->lookDir = lookDir; Oyster::Math::Float3 up = this->rigidBody->GetState().GetOrientation().v[1]; - this->rigidBody->SetUpAndRight(up, lookDir.xyz); + this->rigidBody->SetUpAndRight(up, right); this->rigidBody->SetUpAndRight(this->rigidBody->GetState().centerPos.GetNormalized(), this->rigidBody->GetState().GetOrientation().v[0].xyz.GetNormalized()); } diff --git a/Code/Game/GameLogic/Player.h b/Code/Game/GameLogic/Player.h index bb00c23b..d2adb4be 100644 --- a/Code/Game/GameLogic/Player.h +++ b/Code/Game/GameLogic/Player.h @@ -18,9 +18,9 @@ namespace GameLogic Player(void); Player(OBJECT_TYPE type); Player(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type); - Player(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); - Player(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); - Player(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type); + Player( void* collisionFuncAfter, OBJECT_TYPE type); + Player(Oyster::Physics::ICustomBody *rigidBody, void* collisionFuncAfter, OBJECT_TYPE type); + Player(Oyster::Physics::ICustomBody *rigidBody, Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type); ~Player(void); void InitPlayer(); @@ -48,7 +48,7 @@ namespace GameLogic void Respawn(Oyster::Math::Float3 spawnPoint); - void Rotate(const Oyster::Math3D::Float4 lookDir); + void Rotate(const Oyster::Math3D::Float3 lookDir, const Oyster::Math3D::Float3 right); /******************************************************** * Collision function for player, this is to be sent to physics through the subscribe function with the rigidbody @@ -73,7 +73,6 @@ namespace GameLogic void BeginFrame(); void EndFrame(); - static Oyster::Physics::ICustomBody::SubscriptMessage PlayerCollisionBefore(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj); static Oyster::Physics::ICustomBody::SubscriptMessage PlayerCollisionAfter(Oyster::Physics::ICustomBody *rigidBodyLevel, Oyster::Physics::ICustomBody *obj, Oyster::Math::Float kineticEnergyLoss); @@ -91,6 +90,7 @@ namespace GameLogic float key_backward; float key_strafeRight; float key_strafeLeft; + float key_jump; bool hasTakenDamage; float invincibleCooldown; diff --git a/Code/Game/GameLogic/StaticObject.cpp b/Code/Game/GameLogic/StaticObject.cpp index 65cc0577..12725595 100644 --- a/Code/Game/GameLogic/StaticObject.cpp +++ b/Code/Game/GameLogic/StaticObject.cpp @@ -22,18 +22,18 @@ StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE //this->rigidBody->SetSubscription((Oyster::Physics::ICustomBody::EventAction_BeforeCollisionResponse)(CollisionManager::IgnoreCollision)); } -StaticObject::StaticObject(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) - :Object(collisionFuncBefore,collisionFuncAfter,type) +StaticObject::StaticObject( void* collisionFuncAfter, OBJECT_TYPE type) + :Object(collisionFuncAfter,type) { } -StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type) - :Object(rigidBody, collisionFuncBefore, collisionFuncAfter, type) +StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, OBJECT_TYPE type) + :Object(rigidBody, collisionFuncAfter, type) { } -StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) - :Object(rigidBody, collisionFuncBefore, collisionFuncAfter, type) +StaticObject::StaticObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type) + :Object(rigidBody, collisionFuncAfter, type) { } diff --git a/Code/Game/GameLogic/StaticObject.h b/Code/Game/GameLogic/StaticObject.h index c51f93a1..585594e6 100644 --- a/Code/Game/GameLogic/StaticObject.h +++ b/Code/Game/GameLogic/StaticObject.h @@ -18,9 +18,9 @@ namespace GameLogic StaticObject(); StaticObject(OBJECT_TYPE type); StaticObject(Oyster::Physics::ICustomBody *rigidBody, OBJECT_TYPE type); - StaticObject(void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); - StaticObject(Oyster::Physics::ICustomBody *rigidBody ,void* collisionFuncBefore, void* collisionFuncAfter, OBJECT_TYPE type); - StaticObject(Oyster::Physics::ICustomBody *rigidBody ,Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncBefore)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter), Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type); + StaticObject( void* collisionFuncAfter, OBJECT_TYPE type); + StaticObject(Oyster::Physics::ICustomBody *rigidBody , void* collisionFuncAfter, OBJECT_TYPE type); + StaticObject(Oyster::Physics::ICustomBody *rigidBody , Oyster::Physics::ICustomBody::SubscriptMessage (*collisionFuncAfter)(Oyster::Physics::ICustomBody *proto,Oyster::Physics::ICustomBody *deuter,Oyster::Math::Float kineticEnergyLoss), OBJECT_TYPE type); ~StaticObject(void); diff --git a/Code/Game/GameProtocols/ObjectProtocols.h b/Code/Game/GameProtocols/ObjectProtocols.h index 6dd32d62..f265141d 100644 --- a/Code/Game/GameProtocols/ObjectProtocols.h +++ b/Code/Game/GameProtocols/ObjectProtocols.h @@ -326,7 +326,7 @@ namespace GameLogic this->rotation[2] = p[7].value.netFloat; this->rotation[3] = p[8].value.netFloat; } - Protocol_ObjectPositionRotation(float p[3], float r[3], int id) + Protocol_ObjectPositionRotation(float p[3], float r[4], int id) { this->protocol[0].value = protocol_Gameplay_ObjectPositionRotation; this->protocol[0].type = Oyster::Network::NetAttributeType_Short; diff --git a/Code/Game/GameProtocols/PlayerProtocols.h b/Code/Game/GameProtocols/PlayerProtocols.h index a3c3501e..b7d79d6c 100644 --- a/Code/Game/GameProtocols/PlayerProtocols.h +++ b/Code/Game/GameProtocols/PlayerProtocols.h @@ -76,12 +76,37 @@ namespace GameLogic struct Protocol_PlayerLook :public Oyster::Network::CustomProtocolObject { - float lookDirX; - float lookDirY; - float lookDirZ; - float deltaX; + // can be swapped to a quaternion later + float lookDir[3]; + float right[3]; Protocol_PlayerLook() + { + this->protocol[0].value = protocol_Gameplay_PlayerLookDir; + this->protocol[0].type = Oyster::Network::NetAttributeType_Short; + // LookDir + this->protocol[1].type = Oyster::Network::NetAttributeType_Float; + this->protocol[2].type = Oyster::Network::NetAttributeType_Float; + this->protocol[3].type = Oyster::Network::NetAttributeType_Float; + // Right + this->protocol[4].type = Oyster::Network::NetAttributeType_Float; + this->protocol[5].type = Oyster::Network::NetAttributeType_Float; + this->protocol[6].type = Oyster::Network::NetAttributeType_Float; + + memset(&this->lookDir[0], 0, sizeof(float) * 3); + memset(&this->right[0], 0, sizeof(float) * 3); + } + Protocol_PlayerLook(Oyster::Network::CustomNetProtocol& p) + { + this->lookDir[0] = p[1].value.netFloat; + this->lookDir[1] = p[2].value.netFloat; + this->lookDir[2] = p[3].value.netFloat; + + this->right[0] = p[4].value.netFloat; + this->right[1] = p[5].value.netFloat; + this->right[2] = p[6].value.netFloat; + } + Protocol_PlayerLook(float l[3], float r[3]) { this->protocol[0].value = protocol_Gameplay_PlayerLookDir; this->protocol[0].type = Oyster::Network::NetAttributeType_Short; @@ -89,32 +114,23 @@ namespace GameLogic this->protocol[1].type = Oyster::Network::NetAttributeType_Float; this->protocol[2].type = Oyster::Network::NetAttributeType_Float; this->protocol[3].type = Oyster::Network::NetAttributeType_Float; - this->protocol[4].type = Oyster::Network::NetAttributeType_Float; - - } - Protocol_PlayerLook(Oyster::Network::CustomNetProtocol& p) - { - lookDirX = p[1].value.netFloat; - lookDirY = p[2].value.netFloat; - lookDirZ = p[3].value.netFloat; - deltaX = p[4].value.netFloat; - } - const Protocol_PlayerLook& operator=(Oyster::Network::CustomNetProtocol& val) - { - lookDirX = val[1].value.netFloat; - lookDirY = val[2].value.netFloat; - lookDirZ = val[3].value.netFloat; - deltaX = val[4].value.netFloat; - return *this; + this->protocol[4].type = Oyster::Network::NetAttributeType_Float; + this->protocol[5].type = Oyster::Network::NetAttributeType_Float; + this->protocol[6].type = Oyster::Network::NetAttributeType_Float; + + memcpy(&this->lookDir[0], &l[0], sizeof(float) * 3); + memcpy(&this->right[0], &r[0], sizeof(float) * 3); } + Oyster::Network::CustomNetProtocol GetProtocol() override { - this->protocol[1].value = lookDirX; - this->protocol[2].value = lookDirY; - this->protocol[3].value = lookDirZ; - this->protocol[4].value = deltaX; - + this->protocol[1].value = this->lookDir[0]; + this->protocol[2].value = this->lookDir[1]; + this->protocol[3].value = this->lookDir[2]; + this->protocol[4].value = this->right[0]; + this->protocol[5].value = this->right[1]; + this->protocol[6].value = this->right[2]; return protocol; } diff --git a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp index 9fed11f2..66893573 100644 --- a/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp +++ b/Code/Game/GameServer/Implementation/GameSession_Gameplay.cpp @@ -186,12 +186,10 @@ namespace DanBias } void GameSession::Gameplay_PlayerLookDir ( Protocol_PlayerLook& p, DanBias::GameClient* c ) { - Oyster::Math3D::Float4 lookDir; - lookDir.x = p.lookDirX; - lookDir.y = p.lookDirY; - lookDir.z = p.lookDirZ; - lookDir.w = p.deltaX; - c->GetPlayer()->Rotate(lookDir); + Oyster::Math3D::Float3 lookDir = p.lookDir; + Oyster::Math3D::Float3 right = p.right; + + c->GetPlayer()->Rotate(lookDir, right); } void GameSession::Gameplay_PlayerChangeWeapon ( Protocol_PlayerChangeWeapon& p, DanBias::GameClient* c ) { From b34df93e492adccfd238969bfd47cff6ba248f16 Mon Sep 17 00:00:00 2001 From: Erik Persson Date: Wed, 12 Feb 2014 13:12:51 +0100 Subject: [PATCH 23/24] GL - Massdriver updates --- Code/Game/GameLogic/AttatchmentMassDriver.cpp | 27 ++++++++++--------- Code/Game/GameLogic/AttatchmentSocket.cpp | 6 ++--- Code/Game/GameLogic/Player.cpp | 2 ++ 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/Code/Game/GameLogic/AttatchmentMassDriver.cpp b/Code/Game/GameLogic/AttatchmentMassDriver.cpp index bd52029d..bb7a30f8 100644 --- a/Code/Game/GameLogic/AttatchmentMassDriver.cpp +++ b/Code/Game/GameLogic/AttatchmentMassDriver.cpp @@ -66,7 +66,7 @@ void AttatchmentMassDriver::Update(float dt) Oyster::Physics::ICustomBody::State ownerState = owner->GetRigidBody()->GetState(); Oyster::Math::Float3 up = -ownerState.GetOrientation().v[2]; up *= -0.3; - Oyster::Math::Float3 pos = ownerPos + up + (owner->GetLookDir().GetNormalized()*5); + Oyster::Math::Float3 pos = ownerPos + up + (owner->GetLookDir().GetNormalized()*10); state.centerPos = pos; @@ -96,14 +96,14 @@ void AttatchmentMassDriver::ForcePush(const GameLogic::WEAPON_FIRE &usage, float return; } - Oyster::Math::Float radius = 2; + Oyster::Math::Float radius = 4; Oyster::Math::Float3 look = owner->GetLookDir().GetNormalized(); - Oyster::Math::Float lenght = 5; + Oyster::Math::Float lenght = 10; Oyster::Math::Float3 pos = owner->GetRigidBody()->GetState().centerPos; - pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (200 * dt); + pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (100); - Oyster::Collision3D::Cone *hitCone = new Oyster::Collision3D::Cone(look*5,pos,radius); + Oyster::Collision3D::Cone *hitCone = new Oyster::Collision3D::Cone(lenght,pos,(Oyster::Math::Float4)owner->GetRigidBody()->GetState().quaternion,radius); @@ -129,7 +129,7 @@ void AttatchmentMassDriver::ForceZip(const WEAPON_FIRE &usage, float dt) void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt) { - //if(hasObject) return; //this test checks if the weapon already has something picked up, if so then it cant use this function + if(hasObject) return; //this test checks if the weapon already has something picked up, if so then it cant use this function PickUpObject(usage,dt); //first test if there is a nearby object to pickup @@ -137,21 +137,24 @@ void AttatchmentMassDriver::ForcePull(const WEAPON_FIRE &usage, float dt) //if no object has been picked up then suck objects towards you - Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (100 * dt); - Oyster::Math::Float4x4 aim = Oyster::Math3D::ViewMatrix_LookAtDirection(owner->GetLookDir(), owner->GetRigidBody()->GetState().GetOrientation().v[2].xyz, owner->GetPosition()); + Oyster::Math::Float radius = 4; + Oyster::Math::Float3 look = owner->GetLookDir().GetNormalized(); + Oyster::Math::Float lenght = 10; + Oyster::Math::Float3 pos = owner->GetRigidBody()->GetState().centerPos; - Oyster::Math::Float4x4 hitSpace = Oyster::Math3D::ProjectionMatrix_Perspective(Oyster::Math::pi/4,1,1,20); - Oyster::Collision3D::Frustrum hitFrustum = Oyster::Collision3D::Frustrum(Oyster::Math3D::ViewProjectionMatrix(aim,hitSpace)); + Oyster::Math::Float4 pushForce = Oyster::Math::Float4(this->owner->GetLookDir()) * (100); + + Oyster::Collision3D::Cone *hitCone = new Oyster::Collision3D::Cone(lenght,pos,(Oyster::Math::Float4)owner->GetRigidBody()->GetState().quaternion,radius); forcePushData args; args.pushForce = -pushForce; - //Oyster::Physics::API::Instance().ApplyEffect(hitFrustum,&args,ForcePushAction); + Oyster::Physics::API::Instance().ApplyEffect(hitCone,&args,ForcePushAction); } void AttatchmentMassDriver::PickUpObject(const WEAPON_FIRE &usage, float dt) { Oyster::Math::Float3 pos = owner->GetPosition() + owner->GetLookDir().GetNormalized()*5; - Oyster::Collision3D::Sphere *hitSphere = new Oyster::Collision3D::Sphere(pos,20); + Oyster::Collision3D::Sphere *hitSphere = new Oyster::Collision3D::Sphere(pos,10); Oyster::Physics::API::Instance().ApplyEffect(hitSphere,this,AttemptPickUp); diff --git a/Code/Game/GameLogic/AttatchmentSocket.cpp b/Code/Game/GameLogic/AttatchmentSocket.cpp index 7a8076b1..453387fe 100644 --- a/Code/Game/GameLogic/AttatchmentSocket.cpp +++ b/Code/Game/GameLogic/AttatchmentSocket.cpp @@ -14,10 +14,10 @@ AttatchmentSocket::AttatchmentSocket(void) AttatchmentSocket::~AttatchmentSocket(void) { - if(this->attatchment) - delete this->attatchment; + //if(this->attatchment) + //delete this->attatchment; - this->attatchment = 0; + //this->attatchment = 0; } IAttatchment* AttatchmentSocket::GetAttatchment() diff --git a/Code/Game/GameLogic/Player.cpp b/Code/Game/GameLogic/Player.cpp index 31a436bf..05e07000 100644 --- a/Code/Game/GameLogic/Player.cpp +++ b/Code/Game/GameLogic/Player.cpp @@ -102,6 +102,8 @@ void Player::BeginFrame() moveDirection = forward + back + left + right; //moveDirection.Normalize(); rigidBody->SetLinearVelocity( MOVE_FORCE * moveDirection ); + + weapon->Update(0.01f); } void Player::EndFrame() From 14077c6d4ed6d7c470809e1084fb5270e2be4fa6 Mon Sep 17 00:00:00 2001 From: lindaandersson Date: Wed, 12 Feb 2014 13:17:27 +0100 Subject: [PATCH 24/24] GL - moved camera for testing --- Code/DanBias.sln | 20 ------------------- .../DanBiasGame/GameClientState/GameState.cpp | 4 ++-- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/Code/DanBias.sln b/Code/DanBias.sln index c01d5969..f2bf5f98 100644 --- a/Code/DanBias.sln +++ b/Code/DanBias.sln @@ -70,8 +70,6 @@ Global {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|Win32.Deploy.0 = Debug|Win32 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|x64.ActiveCfg = Release|x64 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|x64.Build.0 = Release|x64 - {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|x64.ActiveCfg = Debug|x64 - {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.Debug|x64.Build.0 = Debug|x64 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.MinSizeRel|Mixed Platforms.ActiveCfg = Release|Win32 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.MinSizeRel|Mixed Platforms.Build.0 = Release|Win32 {0EC83E64-230E-48EF-B08C-6AC9651B4F82}.MinSizeRel|Win32.ActiveCfg = Release|Win32 @@ -97,8 +95,6 @@ Global {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|Win32.Deploy.0 = Debug|Win32 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|x64.ActiveCfg = Release|x64 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|x64.Build.0 = Release|x64 - {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|x64.ActiveCfg = Debug|x64 - {F10CBC03-9809-4CBA-95D8-327C287B18EE}.Debug|x64.Build.0 = Debug|x64 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.MinSizeRel|Mixed Platforms.ActiveCfg = Release|Win32 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.MinSizeRel|Mixed Platforms.Build.0 = Release|Win32 {F10CBC03-9809-4CBA-95D8-327C287B18EE}.MinSizeRel|Win32.ActiveCfg = Release|Win32 @@ -124,13 +120,6 @@ Global {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Win32.Deploy.0 = Debug|Win32 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|x64.ActiveCfg = Release|x64 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|x64.Build.0 = Release|x64 - {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Mixed Platforms.Build.0 = Debug|x64 - {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Win32.ActiveCfg = Debug|Win32 - {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Win32.Build.0 = Debug|Win32 - {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|Win32.Deploy.0 = Debug|Win32 - {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|x64.ActiveCfg = Debug|x64 - {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.Debug|x64.Build.0 = Debug|x64 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.MinSizeRel|Mixed Platforms.ActiveCfg = Release|Win32 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.MinSizeRel|Mixed Platforms.Build.0 = Release|Win32 {2EC4DDED-8F75-4C86-A10B-E1E8EB29F3EE}.MinSizeRel|Win32.ActiveCfg = Release|Win32 @@ -187,8 +176,6 @@ Global {6A066806-F43F-4B31-A4E3-57179674F460}.RelWithDebInfo|x64.ActiveCfg = Release|x64 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Mixed Platforms.ActiveCfg = Release|x64 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Mixed Platforms.Build.0 = Release|x64 - {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Mixed Platforms.Build.0 = Debug|x64 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Win32.ActiveCfg = Debug|Win32 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|Win32.Build.0 = Debug|Win32 {C5AA09D0-6594-4CD3-BD92-1D380C7B3B50}.Debug|x64.ActiveCfg = Release|x64 @@ -211,8 +198,6 @@ Global {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|Win32.Build.0 = Debug|Win32 {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|x64.ActiveCfg = Release|Win32 {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|x64.Build.0 = Release|Win32 - {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|x64.ActiveCfg = Debug|x64 - {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Debug|x64.Build.0 = Debug|x64 {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.MinSizeRel|Mixed Platforms.ActiveCfg = Debug|Win32 {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.MinSizeRel|Win32.ActiveCfg = Debug|Win32 {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.MinSizeRel|x64.ActiveCfg = Debug|Win32 @@ -225,11 +210,6 @@ Global {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.RelWithDebInfo|Mixed Platforms.ActiveCfg = Release|Win32 {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.RelWithDebInfo|Win32.ActiveCfg = Release|Win32 {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.RelWithDebInfo|x64.ActiveCfg = Release|Win32 - {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|x64.ActiveCfg = Release|x64 - {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.Release|x64.Build.0 = Release|x64 - {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.RelWithDebInfo|Mixed Platforms.ActiveCfg = Release|Win32 - {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.RelWithDebInfo|Win32.ActiveCfg = Release|Win32 - {1B3BEA4C-CF75-438A-9693-60FB8444BBF3}.RelWithDebInfo|x64.ActiveCfg = Release|x64 {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {666FEA52-975F-41CD-B224-B19AF3C0ABBA}.Debug|Win32.ActiveCfg = Debug|Win32 diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp index 8eff1be2..4c2899e1 100644 --- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp +++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp @@ -563,8 +563,8 @@ void GameState::Protocol( ObjPos* pos ) Float3 pos = dynamicObjects[i]->getPos(); Float3 up = dynamicObjects[i]->getWorld().v[1]; Float3 objForward = dynamicObjects[i]->getWorld().v[2]; - up *= 2; - objForward *= -2; + up *= 3; + objForward *= -4; Oyster::Math::Float3 cameraPos = pos + up + objForward; camera->SetPosition(cameraPos); }