From 7987d4b27cabe927d75da234a0e201ec502b66ac Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Fri, 29 Jan 2016 12:06:14 +0100 Subject: [PATCH 1/9] Added AssaultDash and all its logic, including a doubletapkey. Doubletapkey could be made more generic. --- include/Game/Systems/PlayerMovementSystem.h | 16 +++++++ src/Game/Systems/PlayerMovementSystem.cpp | 52 +++++++++++++++++++-- 2 files changed, 64 insertions(+), 4 deletions(-) diff --git a/include/Game/Systems/PlayerMovementSystem.h b/include/Game/Systems/PlayerMovementSystem.h index f39740ec..554d174e 100644 --- a/include/Game/Systems/PlayerMovementSystem.h +++ b/include/Game/Systems/PlayerMovementSystem.h @@ -20,4 +20,20 @@ private: EventRelay m_EPlayerSpawned; bool OnPlayerSpawned(Events::PlayerSpawned& e); + + double m_AssaultDashDoubleTapDeltaTime = 0.0f; + double m_AssaultDashCoolDownTimer = 0.0f; + double m_AssaultDashCoolDownMaxTimer = 3.0f; + ImGuiKey m_AssaultDashDoubleTapLastKey = ImGuiKey_Escape; + const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f; + enum class AssaultDashDirection { + Left, + Right, + None + }; + AssaultDashDirection m_AssaultDashTapDirection = AssaultDashDirection::None; + bool m_AssaultDashDoubleTapped = false; + bool m_PlayerIsDashing = false; + + void assaultDashCheck(glm::vec3 controllerMovement, double dt, bool isJumping); }; \ No newline at end of file diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 6eab02c5..fe28ff8e 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -1,6 +1,6 @@ #include "Systems/PlayerMovementSystem.h" -PlayerMovementSystem::PlayerMovementSystem(World* world, EventBroker* eventBroker) +PlayerMovementSystem::PlayerMovementSystem(World* world, EventBroker* eventBroker) : System(world, eventBroker) , PureSystem("Player") { @@ -41,7 +41,9 @@ void PlayerMovementSystem::Update(double dt) if (player.HasComponent("Physics")) { ComponentWrapper cPhysics = player["Physics"]; - + //Assault Dash Check - + //TODO: check if playerclass is assault! + assaultDashCheck(controller->Movement(), dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f); glm::vec3 wishDirection = controller->Movement() * glm::inverse(glm::quat(ori)); float wishSpeed; if (controller->Crouching()) { @@ -71,12 +73,15 @@ void PlayerMovementSystem::Update(double dt) static float surfaceFriction = 5.f; ImGui::InputFloat("surfaceFriction", &surfaceFriction); float accelerationSpeed = actualAccel * (float)dt * wishSpeed * surfaceFriction; - accelerationSpeed = glm::min(accelerationSpeed, addSpeed); + //if doubleTapped do Assault Dash - but only boost maximum 50.0f + float doubleTapDashBoost = m_AssaultDashDoubleTapped ? 20.0f : 1.0f; + accelerationSpeed = glm::min(doubleTapDashBoost*glm::min(accelerationSpeed, addSpeed), 50.0f); velocity += accelerationSpeed * wishDirection; ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity)); } - if (controller->Jumping() && !controller->Crouching() && velocity.y == 0.f) { + //you cant jump and dash at the same time - since there is no friction in the air and we would thus dash much further in the air + if (!m_PlayerIsDashing && controller->Jumping() && !controller->Crouching() && velocity.y == 0.f) { velocity.y += 4.f; } @@ -95,6 +100,7 @@ void PlayerMovementSystem::Update(double dt) ComponentWrapper cAnimation = playerModel["Animation"]; float movementLength = glm::length(groundVelocity); + //TODO: add assault dash animation here if (glm::length(controller->Movement()) > 0.f) { if (controller->Crouching()) { cAnimation["Name"] = "Crouch Walk"; @@ -158,3 +164,41 @@ bool PlayerMovementSystem::OnPlayerSpawned(Events::PlayerSpawned& e) return true; } +void PlayerMovementSystem::assaultDashCheck(glm::vec3 controllerMovement, double dt, bool isJumping) { + m_AssaultDashDoubleTapDeltaTime += dt; + m_AssaultDashCoolDownTimer -= dt; + //cooldown = m_AssaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work) + if (m_AssaultDashCoolDownTimer > (m_AssaultDashCoolDownMaxTimer - 0.25f)) { + m_PlayerIsDashing = true; + } else { + m_PlayerIsDashing = false; + } + //reset the DoubleTapped state in case we recently doubleTapped + if (m_AssaultDashDoubleTapped) { + m_AssaultDashDoubleTapped = false; + } + //Assault Dash logic: tap left or right twice within 0.5sec to activate the doubletap-dash + if (controllerMovement.x > 0 && controllerMovement.y == 0.f && controllerMovement.z == 0.f) { + if (m_AssaultDashDoubleTapLastKey != ImGuiKey_RightArrow && m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer + && m_AssaultDashTapDirection == AssaultDashDirection::Right && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) { + m_AssaultDashDoubleTapped = true; + m_AssaultDashDoubleTapDeltaTime = 0.f; + m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; + } + m_AssaultDashDoubleTapLastKey = ImGuiKey_RightArrow; + m_AssaultDashDoubleTapDeltaTime = 0.f; + m_AssaultDashTapDirection = AssaultDashDirection::Right; + } else if (controllerMovement.x < 0 && controllerMovement.y == 0.f && controllerMovement.z == 0.f) { + if (m_AssaultDashDoubleTapLastKey != ImGuiKey_LeftArrow && m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer + && m_AssaultDashTapDirection == AssaultDashDirection::Left && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) { + m_AssaultDashDoubleTapped = true; + m_AssaultDashDoubleTapDeltaTime = 0.f; + m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; + } + m_AssaultDashDoubleTapLastKey = ImGuiKey_LeftArrow; + m_AssaultDashDoubleTapDeltaTime = 0.f; + m_AssaultDashTapDirection = AssaultDashDirection::Left; + } else { + m_AssaultDashDoubleTapLastKey = ImGuiKey_Escape; + } +} From 9d3171540df1d0acd04174a564459ab13b4ae4b6 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Wed, 3 Feb 2016 11:54:14 +0100 Subject: [PATCH 2/9] AssaultDashCheck is now in FirstPersonInputController instead. TODO: config option, shift button, forward/backward dash --- .../Engine/Input/FirstPersonInputController.h | 62 +++++++++++++++++++ include/Game/Systems/PlayerMovementSystem.h | 15 ----- src/Game/Systems/PlayerMovementSystem.cpp | 44 +------------ 3 files changed, 65 insertions(+), 56 deletions(-) diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index d4c9071c..1efe4b75 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -25,6 +25,10 @@ public: virtual bool OnCommand(const Events::InputCommand& e) override; virtual void Reset(); + void AssaultDashCheck(double dt, bool isJumping); + virtual bool AssaultDashDoubleTapped() const { return m_AssaultDashDoubleTapped; } + virtual bool PlayerIsDashing() const { return m_PlayerIsDashing; } + protected: const int m_PlayerID; bool m_MouseLocked = false; @@ -33,6 +37,23 @@ protected: bool m_Jumping = false; bool m_DoubleJumping = false; bool m_Crouching = false; + //assault dash enum + enum class AssaultDashDirection { + Left, + Right, + Forward, + Backward, + None + }; + //assault dash membervariables + double m_AssaultDashDoubleTapDeltaTime = 0.0f; + double m_AssaultDashCoolDownTimer = 0.0f; + double m_AssaultDashCoolDownMaxTimer = 3.0f; + AssaultDashDirection m_AssaultDashDoubleTapLastKey = AssaultDashDirection::None; + const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f; + AssaultDashDirection m_AssaultDashTapDirection = AssaultDashDirection::None; + bool m_AssaultDashDoubleTapped = false; + bool m_PlayerIsDashing = false; EventRelay m_ELockMouse; bool OnLockMouse(const Events::LockMouse& e); @@ -129,4 +150,45 @@ bool FirstPersonInputController::OnLockMouse(const Events::LockMou return true; } +template +void FirstPersonInputController::AssaultDashCheck(double dt, bool isJumping) { + auto controllerMovement = Movement(); + m_AssaultDashDoubleTapDeltaTime += dt; + m_AssaultDashCoolDownTimer -= dt; + //cooldown = m_AssaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work) + if (m_AssaultDashCoolDownTimer > (m_AssaultDashCoolDownMaxTimer - 0.25f)) { + m_PlayerIsDashing = true; + } else { + m_PlayerIsDashing = false; + } + //reset the DoubleTapped state in case we recently doubleTapped + if (m_AssaultDashDoubleTapped) { + m_AssaultDashDoubleTapped = false; + } + //Assault Dash logic: tap left or right twice within 0.5sec to activate the doubletap-dash + if (controllerMovement.x > 0 && controllerMovement.y == 0.f && controllerMovement.z == 0.f) { + if (m_AssaultDashDoubleTapLastKey != AssaultDashDirection::Right && m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer + && m_AssaultDashTapDirection == AssaultDashDirection::Right && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) { + m_AssaultDashDoubleTapped = true; + m_AssaultDashDoubleTapDeltaTime = 0.f; + m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; + } + m_AssaultDashDoubleTapLastKey = AssaultDashDirection::Right; + m_AssaultDashDoubleTapDeltaTime = 0.f; + m_AssaultDashTapDirection = AssaultDashDirection::Right; + } else if (controllerMovement.x < 0 && controllerMovement.y == 0.f && controllerMovement.z == 0.f) { + if (m_AssaultDashDoubleTapLastKey != AssaultDashDirection::Left && m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer + && m_AssaultDashTapDirection == AssaultDashDirection::Left && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) { + m_AssaultDashDoubleTapped = true; + m_AssaultDashDoubleTapDeltaTime = 0.f; + m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; + } + m_AssaultDashDoubleTapLastKey = AssaultDashDirection::Left; + m_AssaultDashDoubleTapDeltaTime = 0.f; + m_AssaultDashTapDirection = AssaultDashDirection::Left; + } else { + m_AssaultDashDoubleTapLastKey = AssaultDashDirection::None; + } +} + #endif \ No newline at end of file diff --git a/include/Game/Systems/PlayerMovementSystem.h b/include/Game/Systems/PlayerMovementSystem.h index 554d174e..34862e90 100644 --- a/include/Game/Systems/PlayerMovementSystem.h +++ b/include/Game/Systems/PlayerMovementSystem.h @@ -21,19 +21,4 @@ private: EventRelay m_EPlayerSpawned; bool OnPlayerSpawned(Events::PlayerSpawned& e); - double m_AssaultDashDoubleTapDeltaTime = 0.0f; - double m_AssaultDashCoolDownTimer = 0.0f; - double m_AssaultDashCoolDownMaxTimer = 3.0f; - ImGuiKey m_AssaultDashDoubleTapLastKey = ImGuiKey_Escape; - const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f; - enum class AssaultDashDirection { - Left, - Right, - None - }; - AssaultDashDirection m_AssaultDashTapDirection = AssaultDashDirection::None; - bool m_AssaultDashDoubleTapped = false; - bool m_PlayerIsDashing = false; - - void assaultDashCheck(glm::vec3 controllerMovement, double dt, bool isJumping); }; \ No newline at end of file diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index c3eb1c84..70bbafb0 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -43,7 +43,7 @@ void PlayerMovementSystem::Update(double dt) ComponentWrapper cPhysics = player["Physics"]; //Assault Dash Check - //TODO: check if playerclass is assault! - assaultDashCheck(controller->Movement(), dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f); + controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f); glm::vec3 wishDirection = controller->Movement() * glm::inverse(glm::quat(ori)); float wishSpeed; if (controller->Crouching()) { @@ -74,14 +74,14 @@ void PlayerMovementSystem::Update(double dt) ImGui::InputFloat("surfaceFriction", &surfaceFriction); float accelerationSpeed = actualAccel * (float)dt * wishSpeed * surfaceFriction; //if doubleTapped do Assault Dash - but only boost maximum 50.0f - float doubleTapDashBoost = m_AssaultDashDoubleTapped ? 20.0f : 1.0f; + float doubleTapDashBoost = controller->AssaultDashDoubleTapped() ? 20.0f : 1.0f; accelerationSpeed = glm::min(doubleTapDashBoost*glm::min(accelerationSpeed, addSpeed), 50.0f); velocity += accelerationSpeed * wishDirection; ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity)); } //you cant jump and dash at the same time - since there is no friction in the air and we would thus dash much further in the air - if (!m_PlayerIsDashing && controller->Jumping() && !controller->Crouching() && (velocity.y == 0.f || !controller->DoubleJumping())) { + if (!controller->PlayerIsDashing() && controller->Jumping() && !controller->Crouching() && (velocity.y == 0.f || !controller->DoubleJumping())) { if (velocity.y == 0.f) { controller->SetDoubleJumping(false); } @@ -170,41 +170,3 @@ bool PlayerMovementSystem::OnPlayerSpawned(Events::PlayerSpawned& e) return true; } -void PlayerMovementSystem::assaultDashCheck(glm::vec3 controllerMovement, double dt, bool isJumping) { - m_AssaultDashDoubleTapDeltaTime += dt; - m_AssaultDashCoolDownTimer -= dt; - //cooldown = m_AssaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work) - if (m_AssaultDashCoolDownTimer > (m_AssaultDashCoolDownMaxTimer - 0.25f)) { - m_PlayerIsDashing = true; - } else { - m_PlayerIsDashing = false; - } - //reset the DoubleTapped state in case we recently doubleTapped - if (m_AssaultDashDoubleTapped) { - m_AssaultDashDoubleTapped = false; - } - //Assault Dash logic: tap left or right twice within 0.5sec to activate the doubletap-dash - if (controllerMovement.x > 0 && controllerMovement.y == 0.f && controllerMovement.z == 0.f) { - if (m_AssaultDashDoubleTapLastKey != ImGuiKey_RightArrow && m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer - && m_AssaultDashTapDirection == AssaultDashDirection::Right && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) { - m_AssaultDashDoubleTapped = true; - m_AssaultDashDoubleTapDeltaTime = 0.f; - m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; - } - m_AssaultDashDoubleTapLastKey = ImGuiKey_RightArrow; - m_AssaultDashDoubleTapDeltaTime = 0.f; - m_AssaultDashTapDirection = AssaultDashDirection::Right; - } else if (controllerMovement.x < 0 && controllerMovement.y == 0.f && controllerMovement.z == 0.f) { - if (m_AssaultDashDoubleTapLastKey != ImGuiKey_LeftArrow && m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer - && m_AssaultDashTapDirection == AssaultDashDirection::Left && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) { - m_AssaultDashDoubleTapped = true; - m_AssaultDashDoubleTapDeltaTime = 0.f; - m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; - } - m_AssaultDashDoubleTapLastKey = ImGuiKey_LeftArrow; - m_AssaultDashDoubleTapDeltaTime = 0.f; - m_AssaultDashTapDirection = AssaultDashDirection::Left; - } else { - m_AssaultDashDoubleTapLastKey = ImGuiKey_Escape; - } -} From bd2da7bc9f88f8e9f27bfbeaa2c1cff210e0cdb4 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 3 Feb 2016 16:30:00 +0100 Subject: [PATCH 3/9] Revert "Revert "Merge pull request #75 from teamfisk/NormalSpecularMapping"" This reverts commit b56824786ce1c01f429b9f2309423bb1021a929e. --- assets | 2 +- .../Rendering/DrawColorCorrectionPass.h | 4 +- include/Engine/Rendering/RenderQueue.h | 4 + include/Engine/Rendering/Util/GLError.h | 2 +- resources/Schema/Components.xsd | 1 + resources/Schema/Components/SceneLight.xml | 7 + resources/Schema/Components/SceneLight.xsd | 25 + resources/Schema/Entities/AssetPedistal.xml | 51 + resources/Schema/Entities/EditorTestWorld.xml | 196 ++- .../Schema/Entities/EditorWidgetTranslate.xml | 9 - resources/Schema/Entities/Player.xml | 17 +- .../Schema/Entities/QualityAssurance.xml | 1558 +++++++++++++++++ resources/Schema/Entities/RayBlue.xml | 3 +- resources/Schema/Entities/RayRed.xml | 3 +- resources/Schema/Entities/SoundEmitter.xml | 24 + .../Entities/SpawnPointClusterWithModels.xml | 68 + .../Entities/SpawnerWithPlayerModel.xml | 16 + resources/Schema/Types/Entity.xsd | 1 + .../Shaders/DrawColorCorrection.frag.glsl | 4 +- resources/Shaders/ExplosionEffect.geom.glsl | 28 +- resources/Shaders/ForwardPlus.frag.glsl | 15 +- resources/Shaders/ForwardPlus.vert.glsl | 4 +- src/Engine/Editor/EditorRenderSystem.cpp | 8 +- .../Rendering/DrawColorCorrectionPass.cpp | 10 +- src/Engine/Rendering/DrawFinalPass.cpp | 86 +- src/Engine/Rendering/FrameBuffer.cpp | 7 - src/Engine/Rendering/PickingPass.cpp | 8 +- src/Engine/Rendering/RenderSystem.cpp | 9 +- src/Engine/Rendering/Renderer.cpp | 4 +- 29 files changed, 2029 insertions(+), 145 deletions(-) create mode 100644 resources/Schema/Components/SceneLight.xml create mode 100644 resources/Schema/Components/SceneLight.xsd create mode 100644 resources/Schema/Entities/AssetPedistal.xml create mode 100644 resources/Schema/Entities/QualityAssurance.xml create mode 100644 resources/Schema/Entities/SoundEmitter.xml create mode 100644 resources/Schema/Entities/SpawnPointClusterWithModels.xml create mode 100644 resources/Schema/Entities/SpawnerWithPlayerModel.xml diff --git a/assets b/assets index 091ad5c0..c4898d82 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 091ad5c01bf7b6ef5501fc907fc610576a4a45ea +Subproject commit c4898d8281b5584d89b1caf14dab8e5fac120321 diff --git a/include/Engine/Rendering/DrawColorCorrectionPass.h b/include/Engine/Rendering/DrawColorCorrectionPass.h index e9a7e281..fcde73d7 100644 --- a/include/Engine/Rendering/DrawColorCorrectionPass.h +++ b/include/Engine/Rendering/DrawColorCorrectionPass.h @@ -7,6 +7,7 @@ #include "ShaderProgram.h" //#include "Util/UnorderedMapVec2.h" #include "Texture.h" +#include "imgui/imgui.h" class DrawColorCorrectionPass { @@ -16,14 +17,13 @@ public: void InitializeFrameBuffers(); void InitializeShaderPrograms(); - void Draw(GLuint sceneTexture, GLuint bloomTexture); + void Draw(GLuint sceneTexture, GLuint bloomTexture, GLfloat gamma, GLfloat exposure); private: const IRenderer* m_Renderer; ShaderProgram* m_ColorCorrectionProgram; Model* m_ScreenQuad; - GLfloat m_Exposure; }; #endif \ No newline at end of file diff --git a/include/Engine/Rendering/RenderQueue.h b/include/Engine/Rendering/RenderQueue.h index 57371146..af9d928e 100644 --- a/include/Engine/Rendering/RenderQueue.h +++ b/include/Engine/Rendering/RenderQueue.h @@ -26,6 +26,7 @@ struct RenderScene std::list> DirectionalLightJobs; Rectangle Viewport; bool ClearDepth = false; + glm::vec4 AmbientColor; void Clear() { @@ -40,6 +41,9 @@ struct RenderScene struct RenderFrame { public: + //TODO: Getters + GLfloat Gamma = 2.2f; + GLfloat Exposure = 1.f; void Add(RenderScene &scene) { diff --git a/include/Engine/Rendering/Util/GLError.h b/include/Engine/Rendering/Util/GLError.h index 754623d1..2b244e1c 100644 --- a/include/Engine/Rendering/Util/GLError.h +++ b/include/Engine/Rendering/Util/GLError.h @@ -9,7 +9,7 @@ inline bool _GLERROR(const char* info, const char* file, const char* func, unsig GLenum error = glGetError(); if (error != GL_NO_ERROR) { - _LOG(LOG_LEVEL_ERROR, file, func, line, "GL Error: %s, %i, %s", info, error, gluErrorString(error)); + _LOG(LOG_LEVEL_ERROR, file, func, line, "GL Error: %s\nError code: %i, %s\n", info, error, gluErrorString(error)); return true; } diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index ab46b0ea..bb1fd770 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -11,6 +11,7 @@ + diff --git a/resources/Schema/Components/SceneLight.xml b/resources/Schema/Components/SceneLight.xml new file mode 100644 index 00000000..80b6b9f4 --- /dev/null +++ b/resources/Schema/Components/SceneLight.xml @@ -0,0 +1,7 @@ + + + + true + 2.2 + 1 + \ No newline at end of file diff --git a/resources/Schema/Components/SceneLight.xsd b/resources/Schema/Components/SceneLight.xsd new file mode 100644 index 00000000..9f8a9705 --- /dev/null +++ b/resources/Schema/Components/SceneLight.xsd @@ -0,0 +1,25 @@ + + + + + + Some settings for the scene lighting + + + + + Color of the ambient light + + + Wether the ambient light should be applied or not + + + Gamma correction for the scene + + + The exposure of the camera + + + + + \ No newline at end of file diff --git a/resources/Schema/Entities/AssetPedistal.xml b/resources/Schema/Entities/AssetPedistal.xml new file mode 100644 index 00000000..728a3028 --- /dev/null +++ b/resources/Schema/Entities/AssetPedistal.xml @@ -0,0 +1,51 @@ + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/AssaultWeaponBlue.mesh + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/EditorTestWorld.xml b/resources/Schema/Entities/EditorTestWorld.xml index 9565e2d4..4727c777 100755 --- a/resources/Schema/Entities/EditorTestWorld.xml +++ b/resources/Schema/Entities/EditorTestWorld.xml @@ -2,7 +2,9 @@ - + + + @@ -18,7 +20,7 @@ - + @@ -38,18 +40,27 @@ Models/DirectionalLightWidget.mesh - 1.0499999523162842 + 1 - + + + true + + + 5.0498686575577523 + 5 + + 3 + Models/Assault.mesh @@ -62,11 +73,26 @@ - Models/SecondaryWeapon.mesh + Models/AssaultWeaponRed.mesh + true - - + + + + + + + + + + Models/DefenderGunRed.mesh + true + false + + + + @@ -85,7 +111,7 @@ Run - + 1 @@ -101,7 +127,7 @@ Walk - + 1 @@ -147,70 +173,6 @@ - - - - Models/NormalMapSphere.mesh - - - - - - - - - - - Models/SpecularMapSphere.mesh - - - - - - - - - - 1 - - - - - - - - - - - Models/Core/UnitSphere.mesh - - - - 3 - 1.1399998664855957 - - - - - - - - - - - - - - - - Models/IncandescenceMapSphere.mesh - - - - - - - @@ -227,7 +189,7 @@ - + @@ -284,8 +246,94 @@ + + + + 1 + + + + + + + + + + + Models/NormalMapSphere.mesh + + + + + + + + + + + Models/SpecularMapSphere.mesh + + + + + + + + + + 1 + + + + + + + + + + + Models/Core/UnitSphere.mesh + + + + 3 + 1.1399998664855957 + + + + + + + + + + + + + + + + Models/IncandescenceMapSphere.mesh + + + + + + + + + + + + + 1.3999999761581421 + + + + + diff --git a/resources/Schema/Entities/EditorWidgetTranslate.xml b/resources/Schema/Entities/EditorWidgetTranslate.xml index d4ed5e76..c6dba4d9 100644 --- a/resources/Schema/Entities/EditorWidgetTranslate.xml +++ b/resources/Schema/Entities/EditorWidgetTranslate.xml @@ -84,15 +84,6 @@ - - - - - - - - - diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index e81ec5aa..d365c0ee 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -2,12 +2,12 @@ - + @@ -20,7 +20,7 @@ - + @@ -101,12 +101,19 @@ + + true + + 3.7999999523162842 + + true + - Models/AssaultWeapon.mesh + Models/AssaultWeaponRed.mesh - + @@ -141,7 +148,7 @@ Hold Pos - + 1 diff --git a/resources/Schema/Entities/QualityAssurance.xml b/resources/Schema/Entities/QualityAssurance.xml new file mode 100644 index 00000000..e057cf38 --- /dev/null +++ b/resources/Schema/Entities/QualityAssurance.xml @@ -0,0 +1,1558 @@ + + + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + + + + + + + + + + 90 + + + + + + + + + + + + 1 + + + + + + + + + + + Audio/crosscounter.wav + true + + + + + + + + + + SoundEmitter + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + Sound Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + 0.80000001192092896 + + + Models/DirectionalLightWidget.mesh + + + 1 + + + + + + + + + + + + + + + + + + + + + Run + + 1 + + + models/AssaultAnimated.mesh + + + + + + + + + + + Walk + + 1 + + + models/AssaultAnimated.mesh + + + + + + + + + Animation test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Run + + 1 + + + Models/AssaultAnimated.mesh + + + + + + + + + + + + + + + + + + + + + + + + models/NormSpecIncdMapSphere.mesh + + + + + + + + + 1 + + + + + + + + + + + Models/Core/UnitSphere.mesh + + + + 3 + 1.1399998664855957 + + + + + + + + + + + + Models/Core/UnitSphere.mesh + + + + 5.0100002288818359 + 0.69999998807907104 + + + + + + + + + + + + Models/Core/UnitSphere.mesh + + + + 4 + 0.80000001192092896 + + + + + + + + + + + + + + 1 + + + + + + + + + + + Models/NormalMapSphere.mesh + + + + + + + + + + + Models/SpecularMapSphere.mesh + + + + + + + + + + 1 + + + + + + + + + + + Models/Core/UnitSphere.mesh + + + + 3 + 1.1399998664855957 + + + + + + + + + + + + + + + + Models/IncandescenceMapSphere.mesh + + + + + + + + + + + + + TextureMap's Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + 1.3999999761581421 + + + + + + + + + + + + + + + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + + + Spawn Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + true + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + Models/Core/UnitRaptor.mesh + + true + + + + + + + + + + + Models/Assault.mesh + + true + + + + + + + + + + + + Models/Core/UnitCube.mesh + + true + + + + + + + + + + + + + Transparency Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/AssaultWeaponBlue.mesh + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/AssaultWeaponRed.mesh + + + + + + + + + + + + + + + + Asset Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/SecondaryWeapon.mesh + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/AssualtSoft.mesh + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/DefenderGunBlue.mesh + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/DefenderGunRed.mesh + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/Assualt.mesh + + + + + + + + + + + + + + + + + + + + + + + + CapturePoint Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + Models/CapturePoint.mesh + + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + true + + + + + + + + + + + + + + + + + + Red team home point + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Models/CapturePoint.mesh + + + + + + + + + + + 1 + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + RedMiddle Point + Fonts/DroidSans.ttf + + + + + + + + + + + + + + + Models/CapturePoint.mesh + + + + + + + + + 2 + + + Models/Core/UnitCube.mesh + true + + + + + + + + + + + + + + Middle Point + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Models/CapturePoint.mesh + + + + + + + + + + + -12.033302729641917 + 3 + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + BlueMiddle Point + Fonts/DroidSans.ttf + + + + + + + + + + + + + + + Models/CapturePoint.mesh + + + + + + + + + + + + + + 4 + + + Models/Core/UnitCube.mesh + + true + + + + + + + + + + + + + + + + + + Blue team home point + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Test/ObstacleCourse.mesh + + + + + + + + + + + Collision Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + true + + 0.75008034908941568 + 3.7999999523162842 + + true + + + Models/AssaultWeaponBlue.mesh + true + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + + + 1.1999860997035228 + + + Models/Assault.mesh + true + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Walk + + 1 + + + true + + + 0.68343188336345406 + + true + + + Models/AssaultAnimated.mesh + true + + + + + + + + + + + + + + + ExplosionEffect Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + Remember to pick random entities. + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/RayBlue.xml b/resources/Schema/Entities/RayBlue.xml index 3b985a7e..4a0bb9d4 100644 --- a/resources/Schema/Entities/RayBlue.xml +++ b/resources/Schema/Entities/RayBlue.xml @@ -7,7 +7,8 @@ Models/CylinderBullet.mesh - + + true diff --git a/resources/Schema/Entities/RayRed.xml b/resources/Schema/Entities/RayRed.xml index df563476..e69df489 100644 --- a/resources/Schema/Entities/RayRed.xml +++ b/resources/Schema/Entities/RayRed.xml @@ -7,7 +7,8 @@ Models/CylinderBullet.mesh - + + true diff --git a/resources/Schema/Entities/SoundEmitter.xml b/resources/Schema/Entities/SoundEmitter.xml new file mode 100644 index 00000000..39b4c750 --- /dev/null +++ b/resources/Schema/Entities/SoundEmitter.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + SoundEmitter + Fonts/DroidSans.ttf,64 + + + + + + + + + + diff --git a/resources/Schema/Entities/SpawnPointClusterWithModels.xml b/resources/Schema/Entities/SpawnPointClusterWithModels.xml new file mode 100644 index 00000000..9c42d0e4 --- /dev/null +++ b/resources/Schema/Entities/SpawnPointClusterWithModels.xml @@ -0,0 +1,68 @@ + + + + + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + + + Models/Assault.mesh + + + + + + + + + + diff --git a/resources/Schema/Entities/SpawnerWithPlayerModel.xml b/resources/Schema/Entities/SpawnerWithPlayerModel.xml new file mode 100644 index 00000000..1274eefa --- /dev/null +++ b/resources/Schema/Entities/SpawnerWithPlayerModel.xml @@ -0,0 +1,16 @@ + + + + + + + Models/Assault.mesh + + + + + + + + + diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index 99b90caa..028af9e6 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -31,6 +31,7 @@ + diff --git a/resources/Shaders/DrawColorCorrection.frag.glsl b/resources/Shaders/DrawColorCorrection.frag.glsl index 8d13992a..91ace0c7 100644 --- a/resources/Shaders/DrawColorCorrection.frag.glsl +++ b/resources/Shaders/DrawColorCorrection.frag.glsl @@ -3,6 +3,7 @@ layout (binding = 0) uniform sampler2D SceneTexture; layout (binding = 1) uniform sampler2D BloomTexture; uniform float Exposure; +uniform float Gamma; in VertexData{ vec2 TextureCoordinate; @@ -12,7 +13,6 @@ out vec4 fragmentColor; void main() { - const float gamma = 2.2; vec4 hdrColor = texture(SceneTexture, Input.TextureCoordinate); vec4 bloomColor = texture(BloomTexture, Input.TextureCoordinate); hdrColor += bloomColor; @@ -21,7 +21,7 @@ void main() vec3 result = vec3(1.0) - exp(-hdrColor.rgb * Exposure); //gamme correction - result = pow(result, vec3(1.0 / gamma)); + result = pow(result, vec3(1.0 / Gamma)); fragmentColor = vec4(result, 1.0); //fragmentColor = hdrColor; diff --git a/resources/Shaders/ExplosionEffect.geom.glsl b/resources/Shaders/ExplosionEffect.geom.glsl index cb91b545..44b44aa6 100644 --- a/resources/Shaders/ExplosionEffect.geom.glsl +++ b/resources/Shaders/ExplosionEffect.geom.glsl @@ -17,15 +17,21 @@ uniform bool ExponentialAccelaration; in VertexData{ vec3 Position; vec3 Normal; + vec3 Tangent; + vec3 BiTangent; vec2 TextureCoordinate; vec4 ExplosionColor; + float ExplosionPercentageElapsed; }Input[]; out VertexData{ vec3 Position; vec3 Normal; + vec3 Tangent; + vec3 BiTangent; vec2 TextureCoordinate; vec4 ExplosionColor; + float ExplosionPercentageElapsed; }Output; layout(triangles) in; @@ -114,12 +120,17 @@ void main() { // calculate the max distance (s) the triangle will move float s = (randomVelocity.x * ExplosionDuration) + (0.5 * a * pow(ExplosionDuration, 2)); + float te = (length(triangleCenter2ExplosionRadius) / s); - Output.ExplosionColor = EndColor * (length(triangleCenter2ExplosionRadius) / s); + Output.ExplosionColor = EndColor; + Output.ExplosionPercentageElapsed = te; + } else { - Output.ExplosionColor = EndColor * timePercetage; + Output.ExplosionColor = EndColor; + Output.ExplosionPercentageElapsed = timePercetage; + } // for every vertex on the triangle... @@ -132,6 +143,8 @@ void main() Output.Normal = Input[i].Normal; Output.Position = Input[i].Position; Output.TextureCoordinate = Input[i].TextureCoordinate; + Output.Tangent = Input[i].Tangent; + Output.BiTangent = Input[i].BiTangent; // convert to model space for the gravity to always be in -y vec4 ExplodedPositionInModelSpace = M * vec4(ExplodedPosition, 1.0); @@ -154,11 +167,14 @@ void main() // if explosion color should be affected by distance instead of time... if (ColorByDistance == true) { - Output.ExplosionColor = vec4(0.0); + Output.ExplosionColor = EndColor; + Output.ExplosionPercentageElapsed = 0.0; } else { - Output.ExplosionColor = EndColor * timePercetage; + Output.ExplosionColor = EndColor; + Output.ExplosionPercentageElapsed = timePercetage; + } // for every vertex on the triangle... @@ -168,7 +184,9 @@ void main() Output.Normal = Input[i].Normal; Output.Position = Input[i].Position; Output.TextureCoordinate = Input[i].TextureCoordinate; - + Output.Tangent = Input[i].Tangent; + Output.BiTangent = Input[i].BiTangent; + // no change in position, pass through vertex gl_Position = gl_in[i].gl_Position; EmitVertex(); diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index de672dd1..c09e0438 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -7,13 +7,13 @@ uniform vec4 Color; uniform vec4 DiffuseColor; uniform vec2 ScreenDimensions; uniform vec4 FillColor; +uniform vec4 AmbientColor; uniform float FillPercentage; layout (binding = 0) uniform sampler2D DiffuseTexture; layout (binding = 1) uniform sampler2D NormalMapTexture; layout (binding = 2) uniform sampler2D SpecularMapTexture; layout (binding = 3) uniform sampler2D GlowMapTexture; - #define TILE_SIZE 16 struct LightSource { @@ -55,13 +55,12 @@ in VertexData{ vec3 BiTangent; vec2 TextureCoordinate; vec4 ExplosionColor; + float ExplosionPercentageElapsed; }Input; out vec4 sceneColor; out vec4 bloomColor; -vec4 scene_ambient = vec4(0.3,0.3,0.3,1); - struct LightResult { vec4 Diffuse; vec4 Specular; @@ -120,6 +119,7 @@ void main() vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate); vec4 position = V * M * vec4(Input.Position, 1.0); vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, NormalMapTexture); + normal = normalize(normal); //vec4 normal = normalize(V * vec4(Input.Normal, 0.0)); vec4 viewVec = normalize(-position); @@ -128,7 +128,7 @@ void main() tilePos.y = int(gl_FragCoord.y/TILE_SIZE); LightResult totalLighting; - totalLighting.Diffuse = scene_ambient; + totalLighting.Diffuse = vec4(AmbientColor.rgb, 1.0); int currentTile = int(floor(gl_FragCoord.x/TILE_SIZE) + (floor(gl_FragCoord.y/TILE_SIZE) * int(ScreenDimensions.x/TILE_SIZE))); int start = int(LightGrids.Data[currentTile].Start); @@ -150,8 +150,9 @@ void main() totalLighting.Specular += light_result.Specular; } - - vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; + vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); + color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); + //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; float pos = ((P * vec4(Input.Position, 1)).y + 1.0)/2.0; @@ -160,7 +161,7 @@ void main() color_result += FillColor; } sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1)); - color_result += glowTexel; + color_result += glowTexel*3; bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), 1.0); diff --git a/resources/Shaders/ForwardPlus.vert.glsl b/resources/Shaders/ForwardPlus.vert.glsl index 1a7cca12..3b3e931c 100644 --- a/resources/Shaders/ForwardPlus.vert.glsl +++ b/resources/Shaders/ForwardPlus.vert.glsl @@ -20,6 +20,7 @@ out VertexData{ vec3 BiTangent; vec2 TextureCoordinate; vec4 ExplosionColor; + float ExplosionPercentageElapsed; }Output; void main() @@ -41,5 +42,6 @@ void main() Output.Normal = vec3(M * vec4(Normal, 0.0)); Output.Tangent = vec3(M * vec4(Tangent, 0.0)); Output.BiTangent = vec3(M * vec4(BiTangent, 0.0)); - Output.ExplosionColor = vec4(0.0); + Output.ExplosionColor = vec4(1.0); + Output.ExplosionPercentageElapsed = 0.0; } \ No newline at end of file diff --git a/src/Engine/Editor/EditorRenderSystem.cpp b/src/Engine/Editor/EditorRenderSystem.cpp index 67b09a21..4d65e9d3 100644 --- a/src/Engine/Editor/EditorRenderSystem.cpp +++ b/src/Engine/Editor/EditorRenderSystem.cpp @@ -23,6 +23,12 @@ void EditorRenderSystem::Update(double dt) scene.Camera = m_EditorCamera; scene.Viewport = Rectangle(1920, 1080); + auto cSceneLight = m_World->GetComponents("SceneLight"); + if (cSceneLight != nullptr) { + //these are hardcoded since they want special light treatment and a component just for widgets is stupid. + scene.AmbientColor = glm::vec4(0.8, 0.8, 0.8, 1.0); + } + auto models = m_World->GetComponents("Model"); if (models != nullptr) { for (auto& cModel : *models) { @@ -49,7 +55,7 @@ void EditorRenderSystem::Update(double dt) glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, entity.World); for (auto matGroup : model->MaterialGroups()) { std::shared_ptr modelJob = std::make_shared(model, scene.Camera, modelMatrix, matGroup, cModel, entity.World, glm::vec4(0), 0.f); - if(cModel["Transparent"]) { + if (cModel["Transparent"]) { scene.TransparentObjects.push_back(modelJob); } else { scene.OpaqueObjects.push_back(modelJob); diff --git a/src/Engine/Rendering/DrawColorCorrectionPass.cpp b/src/Engine/Rendering/DrawColorCorrectionPass.cpp index ba9efe3e..45401bce 100644 --- a/src/Engine/Rendering/DrawColorCorrectionPass.cpp +++ b/src/Engine/Rendering/DrawColorCorrectionPass.cpp @@ -5,7 +5,8 @@ DrawColorCorrectionPass::DrawColorCorrectionPass(IRenderer* renderer) m_Renderer = renderer; m_ScreenQuad = ResourceManager::Load("Models/Core/ScreenQuad.mesh"); - m_Exposure = 0.4; //TODO: Renderer: Fixa så att denna går att ändra på genom komponent eller setting. + + //m_Exposure = 0.4; //TODO: Renderer: Fixa så att denna går att ändra på genom komponent eller setting. InitializeShaderPrograms(); } @@ -19,15 +20,16 @@ void DrawColorCorrectionPass::InitializeShaderPrograms() m_ColorCorrectionProgram->Link(); } -void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture) +void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLfloat gamma, GLfloat exposure) { //glBindFramebuffer(GL_FRAMEBUFFER, 0); GLERROR("DrawScreenQuadPass::Draw: Pre"); DrawScreenQuadPassState state = DrawScreenQuadPassState(); m_ColorCorrectionProgram->Bind(); - glClear(GL_COLOR_BUFFER_BIT); - glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Exposure"), m_Exposure); + //glClear(GL_COLOR_BUFFER_BIT); + glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Exposure"), exposure); + glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Gamma"), gamma); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, sceneTexture); diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index aa9da9a1..8247797e 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -44,6 +44,7 @@ void DrawFinalPass::InitializeShaderPrograms() m_ForwardPlusProgram->BindFragDataLocation(0, "sceneColor"); m_ForwardPlusProgram->BindFragDataLocation(1, "bloomColor"); m_ForwardPlusProgram->Link(); + GLERROR("Creating forward+ program"); m_ExplosionEffectProgram = ResourceManager::Load("#ExplosionEffectProgram"); m_ExplosionEffectProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/ForwardPlus.vert.glsl"))); @@ -53,11 +54,12 @@ void DrawFinalPass::InitializeShaderPrograms() m_ExplosionEffectProgram->BindFragDataLocation(0, "sceneColor"); m_ExplosionEffectProgram->BindFragDataLocation(1, "bloomColor"); m_ExplosionEffectProgram->Link(); + GLERROR("Creating explosion program"); } void DrawFinalPass::Draw(RenderScene& scene) { - GLERROR("DrawFinalPass::Draw: Pre"); + GLERROR("Pre"); DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle()); if (scene.ClearDepth) { @@ -65,12 +67,12 @@ void DrawFinalPass::Draw(RenderScene& scene) } DrawModelRenderQueues(scene.OpaqueObjects, scene); - GLERROR("DrawFinalPass::Draw: OpaqueObjects"); + GLERROR("OpaqueObjects"); DrawModelRenderQueues(scene.TransparentObjects, scene); - GLERROR("DrawFinalPass::Draw: TransparentObjects"); + GLERROR("TransparentObjects"); - GLERROR("DrawFinalPass::Draw: END"); delete state; + GLERROR("END"); } @@ -111,7 +113,9 @@ void DrawFinalPass::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm: void DrawFinalPass::DrawModelRenderQueues(std::list>& job, RenderScene& scene) { GLuint forwardHandle = m_ForwardPlusProgram->GetHandle(); + GLERROR("forwardHandle"); GLuint explosionHandle = m_ExplosionEffectProgram->GetHandle(); + GLERROR("explosionHandle"); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO()); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO()); @@ -122,10 +126,21 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& auto explosionEffectJob = std::dynamic_pointer_cast(job); if(explosionEffectJob) { //Bind program + if(GLERROR("Prebind")) { + continue; + } m_ExplosionEffectProgram->Bind(); + if(GLERROR("BindProgram")) { + continue; + } + + glDisable(GL_CULL_FACE); //Bind uniforms BindExplosionUniforms(explosionHandle, explosionEffectJob, scene); + if(GLERROR("BindExplosionUniforms")) { + continue; + } if (explosionEffectJob->Model->m_RawModel->m_Skeleton != nullptr) { @@ -134,13 +149,23 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } } + if(GLERROR("Animation")) { + continue; + } //bind textures BindExplosionTextures(explosionEffectJob); + if(GLERROR("BindExplosionTextures")) { + continue; + } //draw glBindVertexArray(explosionEffectJob->Model->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, explosionEffectJob->Model->ElementBuffer); glDrawElements(GL_TRIANGLES, explosionEffectJob->EndIndex - explosionEffectJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(explosionEffectJob->StartIndex*sizeof(unsigned int))); + glEnable(GL_CULL_FACE); + if(GLERROR("explosion effect end")) { + continue; + } } else { auto modelJob = std::dynamic_pointer_cast(job); @@ -167,7 +192,9 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& glBindVertexArray(modelJob->Model->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer); glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex*sizeof(unsigned int))); - GLERROR("DrawFinalPass::Model: END"); + if(GLERROR("models end")) { + continue; + } } } } @@ -176,36 +203,46 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) { + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix)); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix())); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); + glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix)); - glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color)); glUniform3fv(glGetUniformLocation(shaderHandle, "ExplosionOrigin"), 1, glm::value_ptr(job->ExplosionOrigin)); glUniform1f(glGetUniformLocation(shaderHandle, "TimeSinceDeath"), job->TimeSinceDeath); glUniform1f(glGetUniformLocation(shaderHandle, "ExplosionDuration"), job->ExplosionDuration); glUniform4fv(glGetUniformLocation(shaderHandle, "EndColor"), 1, glm::value_ptr(job->EndColor)); glUniform1i(glGetUniformLocation(shaderHandle, "Randomness"), job->Randomness); + glUniform1fv(glGetUniformLocation(shaderHandle, "RandomNumbers"), 50, job->RandomNumbers.data()); glUniform1f(glGetUniformLocation(shaderHandle, "RandomnessScalar"), job->RandomnessScalar); glUniform2fv(glGetUniformLocation(shaderHandle, "Velocity"), 1, glm::value_ptr(job->Velocity)); glUniform1i(glGetUniformLocation(shaderHandle, "ColorByDistance"), job->ColorByDistance); glUniform1i(glGetUniformLocation(shaderHandle, "ExponentialAccelaration"), job->ExponentialAccelaration); - glUniform4fv(glGetUniformLocation(shaderHandle, "DiffuseColor"), 1, glm::value_ptr(job->DiffuseColor)); - glUniform1fv(glGetUniformLocation(shaderHandle, "RandomNumbers"), 50, job->RandomNumbers.data()); -} -void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) -{ - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix())); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); - glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height); - - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix)); glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color)); glUniform4fv(glGetUniformLocation(shaderHandle, "DiffuseColor"), 1, glm::value_ptr(job->DiffuseColor)); glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(job->FillColor)); glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), job->FillPercentage); + glUniform4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor)); + GLERROR("END"); +} + +void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) +{ + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix)); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix())); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); + + glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height); + + glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color)); + glUniform4fv(glGetUniformLocation(shaderHandle, "DiffuseColor"), 1, glm::value_ptr(job->DiffuseColor)); + glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(job->FillColor)); + glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), job->FillPercentage); + glUniform4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor)); + + GLERROR("END"); } @@ -217,7 +254,22 @@ void DrawFinalPass::BindExplosionTextures(std::shared_ptr& j } else { glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); } + glActiveTexture(GL_TEXTURE1); + if (job->NormalTexture != nullptr) { + glBindTexture(GL_TEXTURE_2D, job->NormalTexture->m_Texture); + } else { + glBindTexture(GL_TEXTURE_2D, m_NeutralNormalTexture->m_Texture); + } + + glActiveTexture(GL_TEXTURE2); + if (job->SpecularTexture != nullptr) { + glBindTexture(GL_TEXTURE_2D, job->SpecularTexture->m_Texture); + } else { + glBindTexture(GL_TEXTURE_2D, m_GreyTexture->m_Texture); + } + + glActiveTexture(GL_TEXTURE3); if (job->IncandescenceTexture != nullptr) { glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture->m_Texture); } else { diff --git a/src/Engine/Rendering/FrameBuffer.cpp b/src/Engine/Rendering/FrameBuffer.cpp index b7e908cc..9677f50e 100644 --- a/src/Engine/Rendering/FrameBuffer.cpp +++ b/src/Engine/Rendering/FrameBuffer.cpp @@ -54,13 +54,6 @@ void FrameBuffer::Generate() case GL_RENDERBUFFER: glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle); GLERROR("FrameBuffer generate: glFramebufferRenderbuffer"); - if ( (*it)->m_Attachment != GL_COLOR_ATTACHMENT0 || - (*it)->m_Attachment != GL_COLOR_ATTACHMENT1 || - (*it)->m_Attachment != GL_DEPTH_ATTACHMENT || - (*it)->m_Attachment != GL_STENCIL_ATTACHMENT) //TODO: Viktor: Fixa detta - { - LOG_ERROR("RenderBuffer Attachment not valid."); - } break; } diff --git a/src/Engine/Rendering/PickingPass.cpp b/src/Engine/Rendering/PickingPass.cpp index 792539f8..abc79f2e 100644 --- a/src/Engine/Rendering/PickingPass.cpp +++ b/src/Engine/Rendering/PickingPass.cpp @@ -75,9 +75,9 @@ void PickingPass::Draw(RenderScene& scene) m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]); if (m_ColorCounter[0] > 255) { m_ColorCounter[0] = 0; - m_ColorCounter[1] += 5; + m_ColorCounter[1] += 1; } else { - m_ColorCounter[0] += 50; + m_ColorCounter[0] += 1; } } @@ -121,9 +121,9 @@ void PickingPass::Draw(RenderScene& scene) m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]); if (m_ColorCounter[0] > 255) { m_ColorCounter[0] = 0; - m_ColorCounter[1] += 5; + m_ColorCounter[1] += 1; } else { - m_ColorCounter[0] += 50; + m_ColorCounter[0] += 1; } } diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index a0912a45..eaecf99e 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -240,10 +240,17 @@ void RenderSystem::Update(double dt) m_Camera->SetOrientation(Transform::AbsoluteOrientation(m_CurrentCamera)); } - RenderScene scene; scene.Camera = m_Camera; scene.Viewport = Rectangle(1280, 720); + + auto cSceneLight = m_World->GetComponents("SceneLight"); + if (cSceneLight != nullptr && cSceneLight->begin() != cSceneLight->end()) { + m_RenderFrame->Gamma = (double)(*cSceneLight->begin())["Gamma"]; + m_RenderFrame->Exposure = (double)(*cSceneLight->begin())["Exposure"]; + scene.AmbientColor = (glm::vec4)(*cSceneLight->begin())["AmbientColor"]; + } + fillModels(scene.OpaqueObjects, scene.TransparentObjects); fillPointLights(scene.PointLightJobs, m_World); fillDirectionalLights(scene.DirectionalLightJobs, m_World); diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index bec86b4a..a63e02a0 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -119,8 +119,8 @@ void Renderer::Draw(RenderFrame& frame) } m_DrawBloomPass->Draw(m_DrawFinalPass->BloomTexture()); - if(m_DebugTextureToDraw == 0) { - m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture()); + if (m_DebugTextureToDraw == 0) { + m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture(), frame.Gamma, frame.Exposure); } if (m_DebugTextureToDraw == 1) { m_DrawScreenQuadPass->Draw(m_DrawFinalPass->SceneTexture()); From 7b5a2a538815c632da5713ba3a68c5861d2f97df Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Wed, 3 Feb 2016 17:30:46 +0100 Subject: [PATCH 4/9] Dashing now works great both with shift and doubletap. Added Dash Component. Changed default Player.xml to have a Dash Component. Disabled Sprint. You can now disable DoubleTapToDash in Input.Ini. Added command "SpecialAbility". --- .../Editor/EditorCameraInputController.h | 7 +- .../Engine/Input/FirstPersonInputController.h | 98 ++++++++++++++----- resources/Schema/Components.xsd | 1 + resources/Schema/Components/Dash.xml | 4 + resources/Schema/Components/Dash.xsd | 18 ++++ resources/Schema/Entities/Player.xml | 1 + src/Game/Systems/PlayerMovementSystem.cpp | 13 ++- 7 files changed, 108 insertions(+), 34 deletions(-) create mode 100644 resources/Schema/Components/Dash.xml create mode 100644 resources/Schema/Components/Dash.xsd diff --git a/include/Engine/Editor/EditorCameraInputController.h b/include/Engine/Editor/EditorCameraInputController.h index 4c139e01..6c5e8b14 100644 --- a/include/Engine/Editor/EditorCameraInputController.h +++ b/include/Engine/Editor/EditorCameraInputController.h @@ -55,11 +55,12 @@ public: } } - if (e.Command == "Sprint") { + //this is just temp here, the sprint ability. it will have a component check later + if (e.Command == "SpecialAbility") { if (e.Value > 0) { - m_SpeedMultiplier *= 2.f; + //m_SpeedMultiplier *= 2.f; } else { - m_SpeedMultiplier /= 2.f; + //m_SpeedMultiplier /= 2.f; } } diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index 1efe4b75..4e964d19 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -4,6 +4,7 @@ #include "../GLM.h" #include "../Core/InputController.h" #include "../Core/ELockMouse.h" +#include "InputHandler.h" template class FirstPersonInputController : public InputController @@ -48,12 +49,18 @@ protected: //assault dash membervariables double m_AssaultDashDoubleTapDeltaTime = 0.0f; double m_AssaultDashCoolDownTimer = 0.0f; - double m_AssaultDashCoolDownMaxTimer = 3.0f; + double m_AssaultDashCoolDownMaxTimer = 2.0f; AssaultDashDirection m_AssaultDashDoubleTapLastKey = AssaultDashDirection::None; const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f; - AssaultDashDirection m_AssaultDashTapDirection = AssaultDashDirection::None; + std::string m_AssaultDashTapDirection = ""; bool m_AssaultDashDoubleTapped = false; bool m_PlayerIsDashing = false; + bool m_ShiftDashing = true; + bool m_ValidDoubleTap = false; + + //specialabilitys + bool m_MovementKeyDown = false; + bool m_SpecialAbilityKeyDown = false; EventRelay m_ELockMouse; bool OnLockMouse(const Events::LockMouse& e); @@ -125,6 +132,22 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm } } + if (e.Command == "Forward" || e.Command == "Right") { + //if value = 0 then you have just released this key + if (e.Value > 0 || e.Value < 0) { + m_MovementKeyDown = true; + //if you pressed the same key within m_AssaultDashDoubleTapSensitivityTimer then you have doubletapped it + if (m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer && m_AssaultDashTapDirection == e.Command) { + m_ValidDoubleTap = true; + } + } else { + m_MovementKeyDown = false; + //you have just released the key, store what key it was and reset the doubletap-sensitivity-timer + m_AssaultDashTapDirection = e.Command; + m_AssaultDashDoubleTapDeltaTime = 0.f; + } + } + if (e.Command == "Jump") { m_Jumping = e.Value > 0; } @@ -133,6 +156,19 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm m_Crouching = e.Value > 0; } + if (e.Command == "SpecialAbility") { + if (e.Value > 0) { + m_SpecialAbilityKeyDown = true; + } else { + m_SpecialAbilityKeyDown = false; + } + } + if (m_SpecialAbilityKeyDown && m_MovementKeyDown) { + m_ShiftDashing = true; + } else { + m_ShiftDashing = false; + } + return true; } @@ -152,7 +188,6 @@ bool FirstPersonInputController::OnLockMouse(const Events::LockMou template void FirstPersonInputController::AssaultDashCheck(double dt, bool isJumping) { - auto controllerMovement = Movement(); m_AssaultDashDoubleTapDeltaTime += dt; m_AssaultDashCoolDownTimer -= dt; //cooldown = m_AssaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work) @@ -161,34 +196,43 @@ void FirstPersonInputController::AssaultDashCheck(double dt, bool } else { m_PlayerIsDashing = false; } - //reset the DoubleTapped state in case we recently doubleTapped + + //dashing with shift + if (m_ShiftDashing && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) { + //player is dashing with shift + //the wanted-direction is set in playermovement already so we dont need to check what direction we want to dash in! + m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; + m_AssaultDashDoubleTapped = true; + m_AssaultDashDoubleTapDeltaTime = 0.f; + //moving to the side has priority + return; + } + + //dashing with doubletap - check if doubletap to dash enabled + if (ResourceManager::Load("Input.ini")->Get("Keyboard.DoubleTapToDash", false)) { + return; + } + + //reset the DoubleTapped state in case we recently doubleTapped (doubletap will only happen during 1 frame) if (m_AssaultDashDoubleTapped) { m_AssaultDashDoubleTapped = false; } - //Assault Dash logic: tap left or right twice within 0.5sec to activate the doubletap-dash - if (controllerMovement.x > 0 && controllerMovement.y == 0.f && controllerMovement.z == 0.f) { - if (m_AssaultDashDoubleTapLastKey != AssaultDashDirection::Right && m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer - && m_AssaultDashTapDirection == AssaultDashDirection::Right && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) { - m_AssaultDashDoubleTapped = true; - m_AssaultDashDoubleTapDeltaTime = 0.f; - m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; - } - m_AssaultDashDoubleTapLastKey = AssaultDashDirection::Right; - m_AssaultDashDoubleTapDeltaTime = 0.f; - m_AssaultDashTapDirection = AssaultDashDirection::Right; - } else if (controllerMovement.x < 0 && controllerMovement.y == 0.f && controllerMovement.z == 0.f) { - if (m_AssaultDashDoubleTapLastKey != AssaultDashDirection::Left && m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer - && m_AssaultDashTapDirection == AssaultDashDirection::Left && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) { - m_AssaultDashDoubleTapped = true; - m_AssaultDashDoubleTapDeltaTime = 0.f; - m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; - } - m_AssaultDashDoubleTapLastKey = AssaultDashDirection::Left; - m_AssaultDashDoubleTapDeltaTime = 0.f; - m_AssaultDashTapDirection = AssaultDashDirection::Left; - } else { - m_AssaultDashDoubleTapLastKey = AssaultDashDirection::None; + + //check if we have received a valid doubletap + if (!m_ValidDoubleTap) { + return; } + m_ValidDoubleTap = false; + + if (!(m_AssaultDashCoolDownTimer <= 0.0f && !isJumping)) { + //if we cant dash at the moment, then just reset the tap-sensitivity-timer + m_AssaultDashDoubleTapDeltaTime = 0.f; + return; + } + //ok, we have a valid tap, lets do it + m_AssaultDashDoubleTapped = true; + m_AssaultDashDoubleTapDeltaTime = 0.f; + m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; } #endif \ No newline at end of file diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index bb1fd770..17278f14 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -30,4 +30,5 @@ + \ No newline at end of file diff --git a/resources/Schema/Components/Dash.xml b/resources/Schema/Components/Dash.xml new file mode 100644 index 00000000..084f9620 --- /dev/null +++ b/resources/Schema/Components/Dash.xml @@ -0,0 +1,4 @@ + + + true + \ No newline at end of file diff --git a/resources/Schema/Components/Dash.xsd b/resources/Schema/Components/Dash.xsd new file mode 100644 index 00000000..68b64b0c --- /dev/null +++ b/resources/Schema/Components/Dash.xsd @@ -0,0 +1,18 @@ + + + + + + + + A dash component for one of the classes + + + + + Yada + + + + + \ No newline at end of file diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index d365c0ee..3029e9f7 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -6,6 +6,7 @@ + diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 70bbafb0..4fe3da2d 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -43,8 +43,14 @@ void PlayerMovementSystem::Update(double dt) ComponentWrapper cPhysics = player["Physics"]; //Assault Dash Check - //TODO: check if playerclass is assault! - controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f); + if (player.HasComponent("Dash")) { + controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f); + } glm::vec3 wishDirection = controller->Movement() * glm::inverse(glm::quat(ori)); + //this makes sure you can only dash in the 4 directions: forw,backw,left,right + if (controller->AssaultDashDoubleTapped() && controller->Movement().z != 0 && controller->Movement().x != 0) { + wishDirection = glm::vec3(controller->Movement().x, 0, 0)* glm::inverse(glm::quat(ori)); + } float wishSpeed; if (controller->Crouching()) { wishSpeed = playerCrouchSpeed; @@ -74,7 +80,7 @@ void PlayerMovementSystem::Update(double dt) ImGui::InputFloat("surfaceFriction", &surfaceFriction); float accelerationSpeed = actualAccel * (float)dt * wishSpeed * surfaceFriction; //if doubleTapped do Assault Dash - but only boost maximum 50.0f - float doubleTapDashBoost = controller->AssaultDashDoubleTapped() ? 20.0f : 1.0f; + float doubleTapDashBoost = controller->AssaultDashDoubleTapped() ? 40.0f : 1.0f; accelerationSpeed = glm::min(doubleTapDashBoost*glm::min(accelerationSpeed, addSpeed), 50.0f); velocity += accelerationSpeed * wishDirection; ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity)); @@ -84,8 +90,7 @@ void PlayerMovementSystem::Update(double dt) if (!controller->PlayerIsDashing() && controller->Jumping() && !controller->Crouching() && (velocity.y == 0.f || !controller->DoubleJumping())) { if (velocity.y == 0.f) { controller->SetDoubleJumping(false); - } - else { + } else { controller->SetDoubleJumping(true); } velocity.y += 4.f; From 1bd4aa91ff70275f1a3cd38e66c184841617f985 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Wed, 3 Feb 2016 17:45:37 +0100 Subject: [PATCH 5/9] Oops! Readded "Sprint" command. Removed some unnecessary variables in FirstPersonInputController. Fixed bug where you couldnt dash right away as the game started. --- .../Engine/Editor/EditorCameraInputController.h | 7 +++---- .../Engine/Input/FirstPersonInputController.h | 17 ++++------------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/include/Engine/Editor/EditorCameraInputController.h b/include/Engine/Editor/EditorCameraInputController.h index 6c5e8b14..4c139e01 100644 --- a/include/Engine/Editor/EditorCameraInputController.h +++ b/include/Engine/Editor/EditorCameraInputController.h @@ -55,12 +55,11 @@ public: } } - //this is just temp here, the sprint ability. it will have a component check later - if (e.Command == "SpecialAbility") { + if (e.Command == "Sprint") { if (e.Value > 0) { - //m_SpeedMultiplier *= 2.f; + m_SpeedMultiplier *= 2.f; } else { - //m_SpeedMultiplier /= 2.f; + m_SpeedMultiplier /= 2.f; } } diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index 4e964d19..de4f1226 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -38,24 +38,15 @@ protected: bool m_Jumping = false; bool m_DoubleJumping = false; bool m_Crouching = false; - //assault dash enum - enum class AssaultDashDirection { - Left, - Right, - Forward, - Backward, - None - }; //assault dash membervariables - double m_AssaultDashDoubleTapDeltaTime = 0.0f; - double m_AssaultDashCoolDownTimer = 0.0f; - double m_AssaultDashCoolDownMaxTimer = 2.0f; - AssaultDashDirection m_AssaultDashDoubleTapLastKey = AssaultDashDirection::None; + double m_AssaultDashDoubleTapDeltaTime = 0.0; + double m_AssaultDashCoolDownTimer = 0.0; + double m_AssaultDashCoolDownMaxTimer = 2.0; const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f; std::string m_AssaultDashTapDirection = ""; bool m_AssaultDashDoubleTapped = false; bool m_PlayerIsDashing = false; - bool m_ShiftDashing = true; + bool m_ShiftDashing = false; bool m_ValidDoubleTap = false; //specialabilitys From 03a16b46b568ee8079c615559b1a3e2d311855cf Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Thu, 4 Feb 2016 10:28:28 +0100 Subject: [PATCH 6/9] Dash component now has the dash-maxCoolDownVariable in it. --- .../Engine/Input/FirstPersonInputController.h | 17 +++++++++-------- resources/Schema/Components/Dash.xml | 2 +- resources/Schema/Components/Dash.xsd | 4 ++-- src/Game/Systems/PlayerMovementSystem.cpp | 5 ++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index de4f1226..fa9af852 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -26,7 +26,7 @@ public: virtual bool OnCommand(const Events::InputCommand& e) override; virtual void Reset(); - void AssaultDashCheck(double dt, bool isJumping); + void AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer); virtual bool AssaultDashDoubleTapped() const { return m_AssaultDashDoubleTapped; } virtual bool PlayerIsDashing() const { return m_PlayerIsDashing; } @@ -38,10 +38,11 @@ protected: bool m_Jumping = false; bool m_DoubleJumping = false; bool m_Crouching = false; - //assault dash membervariables + //assault dash membervariables - needed to calculate the doubletap- and dashlogic double m_AssaultDashDoubleTapDeltaTime = 0.0; double m_AssaultDashCoolDownTimer = 0.0; - double m_AssaultDashCoolDownMaxTimer = 2.0; + //i will let m_AssaultDashDoubleTapSensitivityTimer stay hardcoded, its not really a gamevariable (more an inputvariable), + //and its very unlikely that someone wants to change that value const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f; std::string m_AssaultDashTapDirection = ""; bool m_AssaultDashDoubleTapped = false; @@ -178,11 +179,11 @@ bool FirstPersonInputController::OnLockMouse(const Events::LockMou } template -void FirstPersonInputController::AssaultDashCheck(double dt, bool isJumping) { +void FirstPersonInputController::AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer) { m_AssaultDashDoubleTapDeltaTime += dt; m_AssaultDashCoolDownTimer -= dt; - //cooldown = m_AssaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work) - if (m_AssaultDashCoolDownTimer > (m_AssaultDashCoolDownMaxTimer - 0.25f)) { + //cooldown = assaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work) + if (m_AssaultDashCoolDownTimer > (assaultDashCoolDownMaxTimer - 0.25f)) { m_PlayerIsDashing = true; } else { m_PlayerIsDashing = false; @@ -192,7 +193,7 @@ void FirstPersonInputController::AssaultDashCheck(double dt, bool if (m_ShiftDashing && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) { //player is dashing with shift //the wanted-direction is set in playermovement already so we dont need to check what direction we want to dash in! - m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; + m_AssaultDashCoolDownTimer = assaultDashCoolDownMaxTimer; m_AssaultDashDoubleTapped = true; m_AssaultDashDoubleTapDeltaTime = 0.f; //moving to the side has priority @@ -223,7 +224,7 @@ void FirstPersonInputController::AssaultDashCheck(double dt, bool //ok, we have a valid tap, lets do it m_AssaultDashDoubleTapped = true; m_AssaultDashDoubleTapDeltaTime = 0.f; - m_AssaultDashCoolDownTimer = m_AssaultDashCoolDownMaxTimer; + m_AssaultDashCoolDownTimer = assaultDashCoolDownMaxTimer; } #endif \ No newline at end of file diff --git a/resources/Schema/Components/Dash.xml b/resources/Schema/Components/Dash.xml index 084f9620..fbd255a6 100644 --- a/resources/Schema/Components/Dash.xml +++ b/resources/Schema/Components/Dash.xml @@ -1,4 +1,4 @@ - true + 2.0 \ No newline at end of file diff --git a/resources/Schema/Components/Dash.xsd b/resources/Schema/Components/Dash.xsd index 68b64b0c..ca6fc366 100644 --- a/resources/Schema/Components/Dash.xsd +++ b/resources/Schema/Components/Dash.xsd @@ -9,8 +9,8 @@ - - Yada + + This is the cooldown on dash diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 4fe3da2d..c65a961e 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -41,10 +41,9 @@ void PlayerMovementSystem::Update(double dt) if (player.HasComponent("Physics")) { ComponentWrapper cPhysics = player["Physics"]; - //Assault Dash Check - - //TODO: check if playerclass is assault! + //Assault Dash Check if (player.HasComponent("Dash")) { - controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f); + controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f, player["Dash"]["CoolDownMaxTimer"]); } glm::vec3 wishDirection = controller->Movement() * glm::inverse(glm::quat(ori)); //this makes sure you can only dash in the 4 directions: forw,backw,left,right From 035c79564b2e129e16cefef4c6d527bb9cf75b98 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Thu, 4 Feb 2016 11:41:21 +0100 Subject: [PATCH 7/9] Changed Dash name to DashAbility. Fixed dash bug where you could do two different keys to dash. --- include/Engine/Input/FirstPersonInputController.h | 11 ++++++++--- resources/Schema/Components.xsd | 2 +- .../Schema/Components/{Dash.xml => DashAbility.xml} | 2 +- .../Schema/Components/{Dash.xsd => DashAbility.xsd} | 2 +- resources/Schema/Entities/Player.xml | 4 +++- src/Game/Systems/PlayerMovementSystem.cpp | 4 ++-- 6 files changed, 16 insertions(+), 9 deletions(-) rename resources/Schema/Components/{Dash.xml => DashAbility.xml} (78%) rename resources/Schema/Components/{Dash.xsd => DashAbility.xsd} (94%) diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index fa9af852..2bbd768d 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -45,6 +45,7 @@ protected: //and its very unlikely that someone wants to change that value const float m_AssaultDashDoubleTapSensitivityTimer = 0.25f; std::string m_AssaultDashTapDirection = ""; + std::string m_CurrentDirectionVector = ""; bool m_AssaultDashDoubleTapped = false; bool m_PlayerIsDashing = false; bool m_ShiftDashing = false; @@ -125,17 +126,21 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm } if (e.Command == "Forward" || e.Command == "Right") { + if (e.Value != 0) { + m_CurrentDirectionVector = e.Command == "Right" ? (e.Value > 0 ? "Right" : "Left") : (e.Value > 0 ? "Forward" : "Backward"); + } //if value = 0 then you have just released this key - if (e.Value > 0 || e.Value < 0) { + if (e.Value != 0) { m_MovementKeyDown = true; //if you pressed the same key within m_AssaultDashDoubleTapSensitivityTimer then you have doubletapped it - if (m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer && m_AssaultDashTapDirection == e.Command) { + if (m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer && m_AssaultDashTapDirection == m_CurrentDirectionVector) { m_ValidDoubleTap = true; } } else { + //== 0 m_MovementKeyDown = false; //you have just released the key, store what key it was and reset the doubletap-sensitivity-timer - m_AssaultDashTapDirection = e.Command; + m_AssaultDashTapDirection = m_CurrentDirectionVector; m_AssaultDashDoubleTapDeltaTime = 0.f; } } diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index 17278f14..265a3cc5 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -30,5 +30,5 @@ - + \ No newline at end of file diff --git a/resources/Schema/Components/Dash.xml b/resources/Schema/Components/DashAbility.xml similarity index 78% rename from resources/Schema/Components/Dash.xml rename to resources/Schema/Components/DashAbility.xml index fbd255a6..25b9e19a 100644 --- a/resources/Schema/Components/Dash.xml +++ b/resources/Schema/Components/DashAbility.xml @@ -1,4 +1,4 @@ - + 2.0 \ No newline at end of file diff --git a/resources/Schema/Components/Dash.xsd b/resources/Schema/Components/DashAbility.xsd similarity index 94% rename from resources/Schema/Components/Dash.xsd rename to resources/Schema/Components/DashAbility.xsd index ca6fc366..4273cc71 100644 --- a/resources/Schema/Components/Dash.xsd +++ b/resources/Schema/Components/DashAbility.xsd @@ -3,7 +3,7 @@ - + A dash component for one of the classes diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 3029e9f7..fe24adcc 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -6,7 +6,9 @@ - + + 2.0 + diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index c65a961e..3224f579 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -42,8 +42,8 @@ void PlayerMovementSystem::Update(double dt) if (player.HasComponent("Physics")) { ComponentWrapper cPhysics = player["Physics"]; //Assault Dash Check - if (player.HasComponent("Dash")) { - controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f, player["Dash"]["CoolDownMaxTimer"]); + if (player.HasComponent("DashAbility")) { + controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f, player["DashAbility"]["CoolDownMaxTimer"]); } glm::vec3 wishDirection = controller->Movement() * glm::inverse(glm::quat(ori)); //this makes sure you can only dash in the 4 directions: forw,backw,left,right From c87e4d4fd6f05d8e257da9588836d0252c59a5e4 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 4 Feb 2016 11:53:11 +0100 Subject: [PATCH 8/9] Added mutex to resource manager cache reading to avoid a potential race condition. We hope this is the actual bug we saw. --- include/Engine/Core/ResourceManager.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/include/Engine/Core/ResourceManager.h b/include/Engine/Core/ResourceManager.h index 10529819..b994b5cf 100644 --- a/include/Engine/Core/ResourceManager.h +++ b/include/Engine/Core/ResourceManager.h @@ -200,13 +200,16 @@ static T* ResourceManager::Load(const std::string& resourceName, Resource* paren } //If resource has already been cached and completely loaded. - it = m_ResourceCache.find(cacheKey); - if (it != m_ResourceCache.end()) { - if (it->second != nullptr) { - return static_cast(it->second); - } else { - //Don't return null on failure, exception instead. - throw Resource::FailedLoadingException(); + { + boost::lock_guard guard(m_Mutex); + it = m_ResourceCache.find(cacheKey); + if (it != m_ResourceCache.end()) { + if (it->second != nullptr) { + return static_cast(it->second); + } else { + //Don't return null on failure, exception instead. + throw Resource::FailedLoadingException(); + } } } From 6990e473b3c2d481cee2cd4b5a784051eb386603 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 4 Feb 2016 11:53:35 +0100 Subject: [PATCH 9/9] Adding a clear here makes AMD drivers NOT crash for some reason. We're fixing the symptom but not the underlying cause. --- src/Engine/Rendering/DrawColorCorrectionPass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Engine/Rendering/DrawColorCorrectionPass.cpp b/src/Engine/Rendering/DrawColorCorrectionPass.cpp index 45401bce..95de26e2 100644 --- a/src/Engine/Rendering/DrawColorCorrectionPass.cpp +++ b/src/Engine/Rendering/DrawColorCorrectionPass.cpp @@ -27,7 +27,7 @@ void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLf DrawScreenQuadPassState state = DrawScreenQuadPassState(); m_ColorCorrectionProgram->Bind(); - //glClear(GL_COLOR_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT); glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Exposure"), exposure); glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Gamma"), gamma);