From 047e71a4e15001ca028b6f7ce60ae4da4d26b57d Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Thu, 4 Feb 2016 16:18:54 +0100 Subject: [PATCH 001/252] Added BoostAssault,BoostDefender components. Added their effects in HealthSystem,PlayerMovementSystem --- resources/Schema/Components.xsd | 2 + resources/Schema/Components/BoostAssault.xml | 16 ++ resources/Schema/Components/BoostAssault.xsd | 18 ++ resources/Schema/Components/BoostDefender.xml | 16 ++ resources/Schema/Components/BoostDefender.xsd | 18 ++ .../Schema/Entities/BoostAssaultTest.xml | 243 ++++++++++++++++++ src/Game/Systems/HealthSystem.cpp | 3 + src/Game/Systems/PlayerMovementSystem.cpp | 9 +- 8 files changed, 322 insertions(+), 3 deletions(-) create mode 100644 resources/Schema/Components/BoostAssault.xml create mode 100644 resources/Schema/Components/BoostAssault.xsd create mode 100644 resources/Schema/Components/BoostDefender.xml create mode 100644 resources/Schema/Components/BoostDefender.xsd create mode 100644 resources/Schema/Entities/BoostAssaultTest.xml diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index ab46b0ea..36060753 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -29,4 +29,6 @@ + + \ No newline at end of file diff --git a/resources/Schema/Components/BoostAssault.xml b/resources/Schema/Components/BoostAssault.xml new file mode 100644 index 00000000..099d3b0c --- /dev/null +++ b/resources/Schema/Components/BoostAssault.xml @@ -0,0 +1,16 @@ + + + + + + 5 + + + 5 + + + + + + + diff --git a/resources/Schema/Components/BoostAssault.xsd b/resources/Schema/Components/BoostAssault.xsd new file mode 100644 index 00000000..f7d348b7 --- /dev/null +++ b/resources/Schema/Components/BoostAssault.xsd @@ -0,0 +1,18 @@ + + + + + + + + This is the assault's class boost component + + + + + This is the strength of the boost effect + + + + + diff --git a/resources/Schema/Components/BoostDefender.xml b/resources/Schema/Components/BoostDefender.xml new file mode 100644 index 00000000..489d30cd --- /dev/null +++ b/resources/Schema/Components/BoostDefender.xml @@ -0,0 +1,16 @@ + + + + + + 10 + + + 5 + + + + + + + diff --git a/resources/Schema/Components/BoostDefender.xsd b/resources/Schema/Components/BoostDefender.xsd new file mode 100644 index 00000000..167b41dd --- /dev/null +++ b/resources/Schema/Components/BoostDefender.xsd @@ -0,0 +1,18 @@ + + + + + + + + This is the defender's class boost component + + + + + This is the strength of the boost effect + + + + + diff --git a/resources/Schema/Entities/BoostAssaultTest.xml b/resources/Schema/Entities/BoostAssaultTest.xml new file mode 100644 index 00000000..97fd3f4d --- /dev/null +++ b/resources/Schema/Entities/BoostAssaultTest.xml @@ -0,0 +1,243 @@ + + + + + + + + + + + + Models\MapVersion1.mesh + + + + + + + + + 2 + + + Models/DirectionalLightWidget.mesh + false + + + + + + + + + + + + + 8 + 2.7999999523162842 + + + + + + + + + + + 8 + 2.7999999523162842 + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + false + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + false + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Game/Systems/HealthSystem.cpp b/src/Game/Systems/HealthSystem.cpp index 9e118070..3f64d7b9 100644 --- a/src/Game/Systems/HealthSystem.cpp +++ b/src/Game/Systems/HealthSystem.cpp @@ -49,6 +49,9 @@ bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e) { ComponentWrapper cHealth = e.Player["Health"]; double& health = cHealth["Health"]; + if (e.Player.HasComponent("BoostDefender")) { + e.Damage -= (double)e.Player["BoostDefender"]["StrengthOfEffect"]; + } health -= e.Damage; if (health <= 0.0) { diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 72900d7a..bb50942d 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") { @@ -72,6 +72,10 @@ void PlayerMovementSystem::Update(double dt) ImGui::InputFloat("surfaceFriction", &surfaceFriction); float accelerationSpeed = actualAccel * (float)dt * wishSpeed * surfaceFriction; accelerationSpeed = glm::min(accelerationSpeed, addSpeed); + //if player has Boost from an Assault class, accelerate the player faster + if (player.HasComponent("BoostAssault")) { + accelerationSpeed *= (double) player["BoostAssault"]["StrengthOfEffect"]; + } velocity += accelerationSpeed * wishDirection; ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity)); } @@ -79,8 +83,7 @@ void PlayerMovementSystem::Update(double dt) if (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 7f1016476b80878d0374da7e79d948a787fa636c Mon Sep 17 00:00:00 2001 From: Ayumiwii Date: Fri, 5 Feb 2016 15:08:56 +0100 Subject: [PATCH 002/252] Shadows WIP - create 2D texture (depthmap) --- .../Engine/Rendering/DirectionalLightJob.h | 5 +- include/Engine/Rendering/Renderer.h | 2 + include/Engine/Rendering/ShadowPass.cpp | 124 ++ include/Engine/Rendering/ShadowPass.h | 50 + include/Engine/Rendering/ShadowPassState.h | 15 + resources/Schema/Entities/OliviaTestWorld.xml | 1558 +++++++++++++++++ resources/Shaders/Shadow.frag.glsl | 18 + resources/Shaders/Shadow.vert.glsl | 17 + src/Engine/Rendering/FrameBuffer.cpp | 2 +- src/Engine/Rendering/Renderer.cpp | 9 +- src/Engine/Rendering/ShadowPassState.cpp | 16 + 11 files changed, 1812 insertions(+), 4 deletions(-) create mode 100644 include/Engine/Rendering/ShadowPass.cpp create mode 100644 include/Engine/Rendering/ShadowPass.h create mode 100644 include/Engine/Rendering/ShadowPassState.h create mode 100644 resources/Schema/Entities/OliviaTestWorld.xml create mode 100644 resources/Shaders/Shadow.frag.glsl create mode 100644 resources/Shaders/Shadow.vert.glsl create mode 100644 src/Engine/Rendering/ShadowPassState.cpp diff --git a/include/Engine/Rendering/DirectionalLightJob.h b/include/Engine/Rendering/DirectionalLightJob.h index 5f104ca5..0fcfaf84 100644 --- a/include/Engine/Rendering/DirectionalLightJob.h +++ b/include/Engine/Rendering/DirectionalLightJob.h @@ -15,13 +15,14 @@ struct DirectionalLightJob : RenderJob DirectionalLightJob(ComponentWrapper transformComponent, ComponentWrapper directionalLightComponent, World* m_World) : RenderJob() { - - Direction = glm::vec4(0,0,-1,0) * glm::inverse(Transform::AbsoluteOrientation(m_World, transformComponent.EntityID)); + Orientation = Transform::AbsoluteOrientation(m_World, transformComponent.EntityID); + Direction = glm::vec4(0,0,-1,0) * glm::inverse(Orientation); //Direction = glm::vec4((glm::vec3)directionalLightComponent["Direction"], 0.f); Color = (glm::vec4)directionalLightComponent["Color"]; Intensity = (double)directionalLightComponent["Intensity"]; }; + glm::quat Orientation; glm::vec4 Direction; glm::vec4 Color; float Intensity; diff --git a/include/Engine/Rendering/Renderer.h b/include/Engine/Rendering/Renderer.h index 33a61edf..74338e40 100644 --- a/include/Engine/Rendering/Renderer.h +++ b/include/Engine/Rendering/Renderer.h @@ -22,6 +22,7 @@ #include "../Core/Transform.h" #include "imgui/imgui.h" #include "TextPass.h" +#include "ShadowPass.h" class Renderer : public IRenderer { @@ -57,6 +58,7 @@ private: DrawScreenQuadPass* m_DrawScreenQuadPass; DrawBloomPass* m_DrawBloomPass; DrawColorCorrectionPass* m_DrawColorCorrectionPass; + ShadowPass* m_ShadowPass; //----------------------Functions----------------------// void InitializeWindow(); diff --git a/include/Engine/Rendering/ShadowPass.cpp b/include/Engine/Rendering/ShadowPass.cpp new file mode 100644 index 00000000..94844d1f --- /dev/null +++ b/include/Engine/Rendering/ShadowPass.cpp @@ -0,0 +1,124 @@ +#include "ShadowPass.h" + +ShadowPass::ShadowPass(IRenderer * renderer) +{ + m_Renderer = renderer; + + //InitializeTextures(); + InitializeFrameBuffers(); + InitializeShaderPrograms(); +} + +ShadowPass::~ShadowPass() +{ + +} + + +void ShadowPass::InitializeFrameBuffers() +{ + +// glGenRenderbuffers(1, &m_DepthFBO); +// glBindRenderbuffer(GL_RENDERBUFFER, m_DepthFBO); +// glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); + + // Depth texture + glGenTextures(1, &m_DepthMap); + glBindTexture(GL_TEXTURE_2D, m_DepthMap); + //glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1024, 1024, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1024, 1024, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); + //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, 1024, 1024, 0, GL_RGB, GL_FLOAT, 0); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + m_DepthBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthMap, GL_DEPTH_ATTACHMENT))); + //m_DepthBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthMap, GL_COLOR_ATTACHMENT0))); + m_DepthBuffer.Generate(); + + GLERROR("depthMap failed"); + +} + +void ShadowPass::InitializeShaderPrograms() +{ + m_ShadowProgram = ResourceManager::Load("#ShadowProgram"); + m_ShadowProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/Shadow.vert.glsl"))); + m_ShadowProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/Shadow.frag.glsl"))); + m_ShadowProgram->Compile(); + m_ShadowProgram->BindFragDataLocation(0, "ShadowMap"); + m_ShadowProgram->Link(); +} + +void ShadowPass::ClearBuffer() +{ + m_DepthBuffer.Bind(); + glClearColor(0.f, 0.f, 0.f, 0.f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + m_DepthBuffer.Unbind(); +} + +void ShadowPass::Draw(RenderScene & scene) +{ + ShadowPassState* state = new ShadowPassState(m_DepthBuffer.GetHandle()); + + GLuint shaderHandle = m_ShadowProgram->GetHandle(); + glDrawBuffer(GL_NONE); + glReadBuffer(GL_NONE); + m_ShadowProgram->Bind(); + + //if (scene.ClearDepth) { + // glClear(GL_COLOR_BUFFER_BIT); + //} + + for (auto &job : scene.DirectionalLightJobs) { + auto directionalLightJob = std::dynamic_pointer_cast(job); + + if(directionalLightJob) { + + GLfloat near_plane = 1.0f, far_plane = 200.5f; + glm::mat4 lightProjection = glm::ortho(-10.0f, 10.0f, -10.0f, 10.0f, near_plane, far_plane); + + // broken? + //glm::mat4 lightView = glm::lookAt(-glm::normalize(glm::vec3(directionalLightJob->Direction)), glm::vec3(0,0,0), glm::vec3(0,1,0)); + glm::mat4 lightView = glm::lookAt(glm::vec3(50.f, 50.f, 50.f), glm::vec3(0.f, 0.f, 0.f), glm::vec3(0.f, 1.f, 0.f)); + //glm::mat4 lightSpaceMatrix = lightProjection * lightView; + + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix())); + + GLERROR("ShadowLight ERROR"); + + for (auto &objectJob : scene.OpaqueObjects) { + auto modelJob = std::dynamic_pointer_cast(objectJob); + + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); + + 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("Shadow Draw ERROR"); + + } + + } + + m_DepthBuffer.Unbind(); + + delete state; + + + } + + + + + //m_ShadowProgram->Unbind(); + + + + + +} diff --git a/include/Engine/Rendering/ShadowPass.h b/include/Engine/Rendering/ShadowPass.h new file mode 100644 index 00000000..c578339e --- /dev/null +++ b/include/Engine/Rendering/ShadowPass.h @@ -0,0 +1,50 @@ +#ifndef ShadowPass_h_ +#define ShadowPass_h_ + +#include "IRenderer.h" +#include "FrameBuffer.h" +#include "ShaderProgram.h" +#include "../Core/EventBroker.h" +#include "../Core/World.h" +#include "ShadowPassState.h" + +//#include "ShadowPassState.h" // not created yet + + + +class ShadowPass +{ +public: + + ShadowPass(IRenderer* renderer); + ~ShadowPass(); + + void InitializeFrameBuffers(); + void InitializeShaderPrograms(); + void ClearBuffer(); + void Draw(RenderScene& scene); + + + + GLuint DepthMap() const { return m_DepthMap; } + + +private: + + + + EventBroker* m_EventBroker; + + const IRenderer* m_Renderer; + + GLuint m_DepthMap; + + FrameBuffer m_DepthBuffer; + + ShaderProgram* m_ShadowProgram; + + GLuint m_DepthFBO; + +}; + +#endif \ No newline at end of file diff --git a/include/Engine/Rendering/ShadowPassState.h b/include/Engine/Rendering/ShadowPassState.h new file mode 100644 index 00000000..ec08a77c --- /dev/null +++ b/include/Engine/Rendering/ShadowPassState.h @@ -0,0 +1,15 @@ +#ifndef ShadowPassState_h_ +#define ShadowPassState_h_ + +#include "Rendering/RenderState.h" + +class ShadowPassState : public RenderState +{ +public: + ShadowPassState(GLuint frameBuffer); + ~ShadowPassState(); + +private: +}; + +#endif \ No newline at end of file diff --git a/resources/Schema/Entities/OliviaTestWorld.xml b/resources/Schema/Entities/OliviaTestWorld.xml new file mode 100644 index 00000000..23c2b283 --- /dev/null +++ b/resources/Schema/Entities/OliviaTestWorld.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/AssaultBlueWeapon.mesh + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Models/AssaultRedWeapon.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 + + 2.3331127968986038 + 3.7999999523162842 + + true + + + Models/AssaultWeaponBlue.mesh + true + + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + + + 0.28322599621543532 + + + Models/Assault.mesh + true + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + + + + + + + + + + + + + + + + + + + 0.5 + + + + + + + + + + + Walk + + 1 + + + true + + + 1.8831113377486872 + + true + + + Models/AssaultAnimated.mesh + true + + + + + + + + + + + + + + + ExplosionEffect Test + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + Remember to pick random entities. + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + diff --git a/resources/Shaders/Shadow.frag.glsl b/resources/Shaders/Shadow.frag.glsl new file mode 100644 index 00000000..04cc05df --- /dev/null +++ b/resources/Shaders/Shadow.frag.glsl @@ -0,0 +1,18 @@ +#version 430 + + + +in VertexData{ + vec3 Position; +}Input; + +//layout(location = 0 ) out vec4 ShadowMap; +layout(location = 0 ) out float ShadowMap; + +void main() +{ + //ShadowMap = vec4(vec3(gl_FragCoord.z), 1.0); + //ShadowMap = gl_FragCoord.z; +} + + diff --git a/resources/Shaders/Shadow.vert.glsl b/resources/Shaders/Shadow.vert.glsl new file mode 100644 index 00000000..cc1ee0a9 --- /dev/null +++ b/resources/Shaders/Shadow.vert.glsl @@ -0,0 +1,17 @@ +#version 430 + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; + +layout(location = 0) in vec3 Position; + +out VertexData{ + vec3 Position; +}Output; + +void main() +{ + Output.Position = Position; + gl_Position = P * V * M * vec4(Position, 1.0); +} \ No newline at end of file diff --git a/src/Engine/Rendering/FrameBuffer.cpp b/src/Engine/Rendering/FrameBuffer.cpp index 9677f50e..4f83122e 100644 --- a/src/Engine/Rendering/FrameBuffer.cpp +++ b/src/Engine/Rendering/FrameBuffer.cpp @@ -58,7 +58,7 @@ void FrameBuffer::Generate() } - if ((*it)->m_Attachment != GL_DEPTH_ATTACHMENT) { + if ((*it)->m_ResourceType == GL_TEXTURE_2D) { attachments.push_back((*it)->m_Attachment); } } diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index a63e02a0..147fed65 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -93,7 +93,7 @@ void Renderer::Update(double dt) void Renderer::Draw(RenderFrame& frame) { - ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0Gaussian\0Picking"); + ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0Gaussian\0Picking\0Shadow"); //clear buffer 0 glClearColor(0.f, 0.f, 0.f, 0.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -102,11 +102,13 @@ void Renderer::Draw(RenderFrame& frame) m_PickingPass->ClearPicking(); m_DrawFinalPass->ClearBuffer(); m_DrawBloomPass->ClearBuffer(); + m_ShadowPass->ClearBuffer(); for (auto scene : frame.RenderScenes){ SortRenderJobsByDepth(*scene); m_PickingPass->Draw(*scene); + m_ShadowPass->Draw(*scene); m_LightCullingPass->GenerateNewFrustum(*scene); m_LightCullingPass->FillLightList(*scene); m_LightCullingPass->CullLights(*scene); @@ -133,6 +135,10 @@ void Renderer::Draw(RenderFrame& frame) } if (m_DebugTextureToDraw == 4) { m_DrawScreenQuadPass->Draw(m_PickingPass->PickingTexture()); + } + if (m_DebugTextureToDraw == 5) { + m_DrawScreenQuadPass->Draw(m_ShadowPass->DepthMap()); + // m_DrawScreenQuadPass->Draw(); } m_ImGuiRenderPass->Draw(); @@ -177,4 +183,5 @@ void Renderer::InitializeRenderPasses() m_DrawScreenQuadPass = new DrawScreenQuadPass(this); m_DrawBloomPass = new DrawBloomPass(this); m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this); + m_ShadowPass = new ShadowPass(this); } diff --git a/src/Engine/Rendering/ShadowPassState.cpp b/src/Engine/Rendering/ShadowPassState.cpp new file mode 100644 index 00000000..caa09b9f --- /dev/null +++ b/src/Engine/Rendering/ShadowPassState.cpp @@ -0,0 +1,16 @@ +#include "Rendering/ShadowPassState.h" + +ShadowPassState::ShadowPassState(GLuint frameBuffer) +{ + GLERROR("---2"); + BindFramebuffer(frameBuffer); + GLERROR("---3"); + Enable(GL_DEPTH_TEST); + Enable(GL_CULL_FACE); + Disable(GL_BLEND); +} + +ShadowPassState::~ShadowPassState() +{ + +} \ No newline at end of file From c912cd7a428492c0b659a88a1611a3adb8c1490e Mon Sep 17 00:00:00 2001 From: Ayumiwii Date: Fri, 5 Feb 2016 15:12:17 +0100 Subject: [PATCH 003/252] Shadows wip --- include/Engine/Rendering/ShadowPass.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/Engine/Rendering/ShadowPass.cpp b/include/Engine/Rendering/ShadowPass.cpp index 94844d1f..2fe14238 100644 --- a/include/Engine/Rendering/ShadowPass.cpp +++ b/include/Engine/Rendering/ShadowPass.cpp @@ -62,10 +62,10 @@ void ShadowPass::ClearBuffer() void ShadowPass::Draw(RenderScene & scene) { ShadowPassState* state = new ShadowPassState(m_DepthBuffer.GetHandle()); - - GLuint shaderHandle = m_ShadowProgram->GetHandle(); glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE); + + GLuint shaderHandle = m_ShadowProgram->GetHandle(); m_ShadowProgram->Bind(); //if (scene.ClearDepth) { From 0e51ae7dc91e6cb8a85d369a550cff6ba811166d Mon Sep 17 00:00:00 2001 From: Ayumiwii Date: Fri, 5 Feb 2016 15:31:20 +0100 Subject: [PATCH 004/252] shadow wip --- assets | 2 +- include/Engine/Rendering/ShadowPass.cpp | 2 -- resources/Shaders/Shadow.frag.glsl | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/assets b/assets index c4898d82..091ad5c0 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit c4898d8281b5584d89b1caf14dab8e5fac120321 +Subproject commit 091ad5c01bf7b6ef5501fc907fc610576a4a45ea diff --git a/include/Engine/Rendering/ShadowPass.cpp b/include/Engine/Rendering/ShadowPass.cpp index 2fe14238..33549d03 100644 --- a/include/Engine/Rendering/ShadowPass.cpp +++ b/include/Engine/Rendering/ShadowPass.cpp @@ -62,8 +62,6 @@ void ShadowPass::ClearBuffer() void ShadowPass::Draw(RenderScene & scene) { ShadowPassState* state = new ShadowPassState(m_DepthBuffer.GetHandle()); - glDrawBuffer(GL_NONE); - glReadBuffer(GL_NONE); GLuint shaderHandle = m_ShadowProgram->GetHandle(); m_ShadowProgram->Bind(); diff --git a/resources/Shaders/Shadow.frag.glsl b/resources/Shaders/Shadow.frag.glsl index 04cc05df..b2f7115b 100644 --- a/resources/Shaders/Shadow.frag.glsl +++ b/resources/Shaders/Shadow.frag.glsl @@ -12,7 +12,7 @@ layout(location = 0 ) out float ShadowMap; void main() { //ShadowMap = vec4(vec3(gl_FragCoord.z), 1.0); - //ShadowMap = gl_FragCoord.z; + ShadowMap = (glgl_FragCoord.x, glgl_FragCoord.y, glgl_FragCoord.z); } From bbf6058c17d904873710c41e53bd1b6c1a2c49fb Mon Sep 17 00:00:00 2001 From: Ayumiwii Date: Fri, 5 Feb 2016 16:13:46 +0100 Subject: [PATCH 005/252] Shadow WIP - fixed file placing of ShadowPass.cpp --- resources/Shaders/Shadow.frag.glsl | 2 +- .../Engine/Rendering/ShadowPass.cpp | 23 +++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) rename {include => src}/Engine/Rendering/ShadowPass.cpp (78%) diff --git a/resources/Shaders/Shadow.frag.glsl b/resources/Shaders/Shadow.frag.glsl index b2f7115b..983cc828 100644 --- a/resources/Shaders/Shadow.frag.glsl +++ b/resources/Shaders/Shadow.frag.glsl @@ -12,7 +12,7 @@ layout(location = 0 ) out float ShadowMap; void main() { //ShadowMap = vec4(vec3(gl_FragCoord.z), 1.0); - ShadowMap = (glgl_FragCoord.x, glgl_FragCoord.y, glgl_FragCoord.z); + ShadowMap = (gl_FragCoord.z); } diff --git a/include/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp similarity index 78% rename from include/Engine/Rendering/ShadowPass.cpp rename to src/Engine/Rendering/ShadowPass.cpp index 33549d03..56fcbe7a 100644 --- a/include/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -1,4 +1,4 @@ -#include "ShadowPass.h" +#include "Rendering/ShadowPass.h" ShadowPass::ShadowPass(IRenderer * renderer) { @@ -26,15 +26,15 @@ void ShadowPass::InitializeFrameBuffers() glGenTextures(1, &m_DepthMap); glBindTexture(GL_TEXTURE_2D, m_DepthMap); //glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1024, 1024, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1024, 1024, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); - //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, 1024, 1024, 0, GL_RGB, GL_FLOAT, 0); + //glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1024, 1024, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, 1024, 1024, 0, GL_RGB, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - m_DepthBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthMap, GL_DEPTH_ATTACHMENT))); - //m_DepthBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthMap, GL_COLOR_ATTACHMENT0))); + //m_DepthBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthMap, GL_DEPTH_ATTACHMENT))); + m_DepthBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthMap, GL_COLOR_ATTACHMENT0))); m_DepthBuffer.Generate(); GLERROR("depthMap failed"); @@ -75,16 +75,19 @@ void ShadowPass::Draw(RenderScene & scene) if(directionalLightJob) { - GLfloat near_plane = 1.0f, far_plane = 200.5f; + GLfloat near_plane = 1.0f, far_plane = 75.5f; glm::mat4 lightProjection = glm::ortho(-10.0f, 10.0f, -10.0f, 10.0f, near_plane, far_plane); // broken? - //glm::mat4 lightView = glm::lookAt(-glm::normalize(glm::vec3(directionalLightJob->Direction)), glm::vec3(0,0,0), glm::vec3(0,1,0)); - glm::mat4 lightView = glm::lookAt(glm::vec3(50.f, 50.f, 50.f), glm::vec3(0.f, 0.f, 0.f), glm::vec3(0.f, 1.f, 0.f)); + glm::mat4 lightView = glm::lookAt(-glm::normalize(glm::vec3(directionalLightJob->Direction)) * (float)50.0 , glm::vec3(0,0,0), glm::vec3(0,1,0)); + //glm::mat4 lightView = glm::lookAt(glm::vec3(10.f, 10.f, 50.f), glm::vec3(0.f, 0.f, 0.f), glm::vec3(0.f, 1.f, 0.f)); //glm::mat4 lightSpaceMatrix = lightProjection * lightView; - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix())); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(lightProjection)); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(lightView)); + + /* glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));*/ GLERROR("ShadowLight ERROR"); From 6542d1b44445458651cb9f96dbc9b1458eca29c9 Mon Sep 17 00:00:00 2001 From: Ayumiwii Date: Fri, 5 Feb 2016 17:29:53 +0100 Subject: [PATCH 006/252] Shadow WIP - DepthTexture working --- include/Engine/Rendering/ShadowPass.h | 9 +++++++++ resources/Shaders/Shadow.frag.glsl | 8 ++++---- resources/Shaders/Shadow.vert.glsl | 8 ++++---- src/Engine/Rendering/ShadowPass.cpp | 16 ++++++++-------- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/include/Engine/Rendering/ShadowPass.h b/include/Engine/Rendering/ShadowPass.h index c578339e..6a00dacd 100644 --- a/include/Engine/Rendering/ShadowPass.h +++ b/include/Engine/Rendering/ShadowPass.h @@ -7,6 +7,7 @@ #include "../Core/EventBroker.h" #include "../Core/World.h" #include "ShadowPassState.h" +#include "imgui/imgui.h" //#include "ShadowPassState.h" // not created yet @@ -45,6 +46,14 @@ private: GLuint m_DepthFBO; + GLfloat m_NearPlane = -40.f; + GLfloat m_FarPlane = 80.f; + //GLfloat m_Left = -10.f; + //GLfloat m_Right = 10.f; + //GLfloat m_Bottom = -10.f; + //GLfloat m_Top = 10.f; + GLfloat m_LRBT[4] = { -40.f, 100.f, -50.f, 50.f }; + }; #endif \ No newline at end of file diff --git a/resources/Shaders/Shadow.frag.glsl b/resources/Shaders/Shadow.frag.glsl index 983cc828..798d1cda 100644 --- a/resources/Shaders/Shadow.frag.glsl +++ b/resources/Shaders/Shadow.frag.glsl @@ -2,9 +2,9 @@ -in VertexData{ - vec3 Position; -}Input; +//in VertexData{ +// vec3 Position; +//}Input; //layout(location = 0 ) out vec4 ShadowMap; layout(location = 0 ) out float ShadowMap; @@ -12,7 +12,7 @@ layout(location = 0 ) out float ShadowMap; void main() { //ShadowMap = vec4(vec3(gl_FragCoord.z), 1.0); - ShadowMap = (gl_FragCoord.z); + //ShadowMap = (gl_FragCoord.z); } diff --git a/resources/Shaders/Shadow.vert.glsl b/resources/Shaders/Shadow.vert.glsl index cc1ee0a9..16c0b26e 100644 --- a/resources/Shaders/Shadow.vert.glsl +++ b/resources/Shaders/Shadow.vert.glsl @@ -6,12 +6,12 @@ uniform mat4 P; layout(location = 0) in vec3 Position; -out VertexData{ - vec3 Position; -}Output; +//out VertexData{ +// vec3 Position; +//}Output; void main() { - Output.Position = Position; +// Output.Position = Position; gl_Position = P * V * M * vec4(Position, 1.0); } \ No newline at end of file diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index 56fcbe7a..84c0de87 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -26,15 +26,15 @@ void ShadowPass::InitializeFrameBuffers() glGenTextures(1, &m_DepthMap); glBindTexture(GL_TEXTURE_2D, m_DepthMap); //glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1024, 1024, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); - //glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1024, 1024, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, 1024, 1024, 0, GL_RGB, GL_FLOAT, 0); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1024, 1024, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); + //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, 1024, 1024, 0, GL_RGB, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - //m_DepthBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthMap, GL_DEPTH_ATTACHMENT))); - m_DepthBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthMap, GL_COLOR_ATTACHMENT0))); + m_DepthBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthMap, GL_DEPTH_ATTACHMENT))); + //m_DepthBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthMap, GL_COLOR_ATTACHMENT0))); m_DepthBuffer.Generate(); GLERROR("depthMap failed"); @@ -70,16 +70,16 @@ void ShadowPass::Draw(RenderScene & scene) // glClear(GL_COLOR_BUFFER_BIT); //} + ImGui::DragFloat4("ShadowMapCam", m_LRBT, 1.f, -1000.f, 1000.f); + for (auto &job : scene.DirectionalLightJobs) { auto directionalLightJob = std::dynamic_pointer_cast(job); if(directionalLightJob) { - - GLfloat near_plane = 1.0f, far_plane = 75.5f; - glm::mat4 lightProjection = glm::ortho(-10.0f, 10.0f, -10.0f, 10.0f, near_plane, far_plane); + glm::mat4 lightProjection = glm::ortho(m_LRBT[0], m_LRBT[1], m_LRBT[2], m_LRBT[3], m_NearPlane, m_FarPlane); // broken? - glm::mat4 lightView = glm::lookAt(-glm::normalize(glm::vec3(directionalLightJob->Direction)) * (float)50.0 , glm::vec3(0,0,0), glm::vec3(0,1,0)); + glm::mat4 lightView = glm::lookAt(-glm::normalize(glm::vec3(directionalLightJob->Direction)) * (float)20.0 , glm::vec3(0,0,0), glm::vec3(0,1,0)); //glm::mat4 lightView = glm::lookAt(glm::vec3(10.f, 10.f, 50.f), glm::vec3(0.f, 0.f, 0.f), glm::vec3(0.f, 1.f, 0.f)); //glm::mat4 lightSpaceMatrix = lightProjection * lightView; From cb7f06573fbea083af3c666f4185a5cadabc14a3 Mon Sep 17 00:00:00 2001 From: Ayumiwii Date: Tue, 9 Feb 2016 14:08:57 +0100 Subject: [PATCH 007/252] Shadows stage 2 WIP --- include/Engine/Rendering/DrawFinalPass.h | 4 +- include/Engine/Rendering/ShadowPass.h | 19 ++++--- resources/Shaders/ExplosionEffect.geom.glsl | 4 ++ resources/Shaders/ForwardPlus.frag.glsl | 63 ++++++++++++++++++++- resources/Shaders/ForwardPlus.vert.glsl | 22 ++++++- src/Engine/Rendering/DrawFinalPass.cpp | 20 ++++++- src/Engine/Rendering/FrameBuffer.cpp | 1 - src/Engine/Rendering/Renderer.cpp | 5 +- src/Engine/Rendering/ShadowPass.cpp | 19 +++---- 9 files changed, 128 insertions(+), 29 deletions(-) diff --git a/include/Engine/Rendering/DrawFinalPass.h b/include/Engine/Rendering/DrawFinalPass.h index 74f505fe..ba65d6e7 100644 --- a/include/Engine/Rendering/DrawFinalPass.h +++ b/include/Engine/Rendering/DrawFinalPass.h @@ -8,11 +8,12 @@ #include "ShaderProgram.h" #include "Util/UnorderedMapVec2.h" #include "Texture.h" +#include "ShadowPass.h" class DrawFinalPass { public: - DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass); + DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, ShadowPass* shadowPass); ~DrawFinalPass() { } void InitializeTextures(); void InitializeFrameBuffers(); @@ -50,6 +51,7 @@ private: const IRenderer* m_Renderer; const LightCullingPass* m_LightCullingPass; + const ShadowPass* m_ShadowPass; ShaderProgram* m_ForwardPlusProgram; ShaderProgram* m_ExplosionEffectProgram; diff --git a/include/Engine/Rendering/ShadowPass.h b/include/Engine/Rendering/ShadowPass.h index 6a00dacd..a8f41502 100644 --- a/include/Engine/Rendering/ShadowPass.h +++ b/include/Engine/Rendering/ShadowPass.h @@ -11,7 +11,8 @@ //#include "ShadowPassState.h" // not created yet - +enum NearFar { Near = 0, Far = 1 }; +enum LRBT { Left = 0, Right = 1, Bottom = 2, Top = 3 }; class ShadowPass { @@ -28,7 +29,11 @@ public: GLuint DepthMap() const { return m_DepthMap; } - + glm::mat4 lightSpaceMatrix() const { return m_LightSpaceMatrix; } + glm::mat4 lightP() const { return m_LightProjection; } + glm::mat4 lightV() const { return m_LightView; } + //glm::mat4 lightV() const { return m_LightProjection; } //swapped m_P -> m_V + //glm::mat4 lightP() const { return m_LightView; } // swapped m_V -> m_P private: @@ -46,14 +51,12 @@ private: GLuint m_DepthFBO; - GLfloat m_NearPlane = -40.f; - GLfloat m_FarPlane = 80.f; - //GLfloat m_Left = -10.f; - //GLfloat m_Right = 10.f; - //GLfloat m_Bottom = -10.f; - //GLfloat m_Top = 10.f; + GLfloat m_NearFarPlane[2] = { -40.f, 30.f }; GLfloat m_LRBT[4] = { -40.f, 100.f, -50.f, 50.f }; + glm::mat4 m_LightProjection; + glm::mat4 m_LightView; + glm::mat4 m_LightSpaceMatrix; }; #endif \ No newline at end of file diff --git a/resources/Shaders/ExplosionEffect.geom.glsl b/resources/Shaders/ExplosionEffect.geom.glsl index 44b44aa6..3471e4f2 100644 --- a/resources/Shaders/ExplosionEffect.geom.glsl +++ b/resources/Shaders/ExplosionEffect.geom.glsl @@ -22,6 +22,7 @@ in VertexData{ vec2 TextureCoordinate; vec4 ExplosionColor; float ExplosionPercentageElapsed; + vec4 PositionLightSpace; }Input[]; out VertexData{ @@ -32,6 +33,7 @@ out VertexData{ vec2 TextureCoordinate; vec4 ExplosionColor; float ExplosionPercentageElapsed; + vec4 PositionLightSpace; }Output; layout(triangles) in; @@ -145,6 +147,7 @@ void main() Output.TextureCoordinate = Input[i].TextureCoordinate; Output.Tangent = Input[i].Tangent; Output.BiTangent = Input[i].BiTangent; + Output.PositionLightSpace = Input[i].PositionLightSpace; // convert to model space for the gravity to always be in -y vec4 ExplodedPositionInModelSpace = M * vec4(ExplodedPosition, 1.0); @@ -186,6 +189,7 @@ void main() Output.TextureCoordinate = Input[i].TextureCoordinate; Output.Tangent = Input[i].Tangent; Output.BiTangent = Input[i].BiTangent; + Output.PositionLightSpace = Input[i].PositionLightSpace; // no change in position, pass through vertex gl_Position = gl_in[i].gl_Position; diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index c09e0438..d54de713 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -13,6 +13,7 @@ layout (binding = 0) uniform sampler2D DiffuseTexture; layout (binding = 1) uniform sampler2D NormalMapTexture; layout (binding = 2) uniform sampler2D SpecularMapTexture; layout (binding = 3) uniform sampler2D GlowMapTexture; +layout (binding = 4) uniform sampler2D DepthMap; #define TILE_SIZE 16 @@ -56,6 +57,7 @@ in VertexData{ vec2 TextureCoordinate; vec4 ExplosionColor; float ExplosionPercentageElapsed; + vec4 PositionLightSpace; }Input; out vec4 sceneColor; @@ -112,6 +114,45 @@ vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textu return vec4(TBN * normalize(NormalMap), 0.0); } +//float CalcShadowValue(vec4 positionLightSpace, vec4 normal, vec4 lightDir, sampler2D depthTexture) +//{ +// // perform perspective divide +// //vec3 projCoords = positionLightSpace.xyz / positionLightSpace.w; +// // Transform to [0,1] range +// //projCoords = projCoords * 0.5 + 0.5; +// // Get closest depth value from light's perspective (using [0,1] range fragPosLight as coords) +// float closestDepth = texture(depthTexture, positionLightSpace.xy).r; +// // Get depth of current fragment from light's perspective +// float currentDepth = positionLightSpace.z; +// // Check whether current frag pos is in shadow +// float shadow = currentDepth > closestDepth ? 1.0 : 0.0; +// +// return shadow; +// +//} + +float CalcShadowValue(vec4 positionLightSpace, vec4 normal, vec4 lightDir, sampler2D depthTexture) +{ + + //float bias = max(0.05 * (1.0 - dot(normal, -lightDir)), 0.005); + // perform perspective divide + vec3 projCoords = positionLightSpace.xyz / positionLightSpace.w; + // Transform to [0,1] range + projCoords = projCoords * 0.5 + 0.5; + // Get closest depth value from light's perspective (using [0,1] range fragPosLight as coords) + //float lightDepth = texture(depthTexture, positionLightSpace.xy).r; + float closestDepth = texture(depthTexture, projCoords.xy).r; + // Get depth of current fragment from light's perspective + //float currentDepth = positionLightSpace.z; + float currentDepth = projCoords.z; + // Check whether current frag pos is in shadow + float shadow = currentDepth /*- bias*/ > closestDepth ? 1.0 : 0.0; + // float shadow = currentDepth > closestDepth ? 1.0 : 0.0; + + return shadow; + +} + void main() { vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate); @@ -134,24 +175,42 @@ void main() int start = int(LightGrids.Data[currentTile].Start); int amount = int(LightGrids.Data[currentTile].Amount); + float shadowFactor = 1.0; + for(int i = start; i < start + amount; i++) { int l = int(LightIndex[i]); LightSource light = LightSources.List[l]; - + LightResult light_result; //These if statements should be removed. if(light.Type == 1) { // point light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, position, normal, light.Falloff); } else if (light.Type == 2) { //Directional light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal); + shadowFactor = CalcShadowValue(Input.PositionLightSpace, normal, light.Direction, DepthMap); } + totalLighting.Diffuse += light_result.Diffuse; - totalLighting.Specular += light_result.Specular; + totalLighting.Specular += light_result.Specular; } + totalLighting.Diffuse += (1.0 - shadowFactor); + totalLighting.Specular += (1.0 - shadowFactor); + //LightResult getInformation; + vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); + + //color_result = (totalLighting.Diffuse + (1.0 - shadowFactor) * (getInformation.Diffuse + (getInformation.Specular * specularTexel))) * color_result; + + + + + + + + //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; diff --git a/resources/Shaders/ForwardPlus.vert.glsl b/resources/Shaders/ForwardPlus.vert.glsl index 3b3e931c..21f3f370 100644 --- a/resources/Shaders/ForwardPlus.vert.glsl +++ b/resources/Shaders/ForwardPlus.vert.glsl @@ -3,6 +3,9 @@ uniform mat4 M; uniform mat4 V; uniform mat4 P; +uniform mat4 lightSpaceMatrix; // Shadow map PV +uniform mat4 LightV; +uniform mat4 LightP; uniform mat4 Bones[100]; layout(location = 0) in vec3 Position; @@ -21,8 +24,17 @@ out VertexData{ vec2 TextureCoordinate; vec4 ExplosionColor; float ExplosionPercentageElapsed; + vec4 PositionLightSpace; }Output; +// N +mat4 biasMatrix = mat4( +vec4(0.5, 0.0, 0.0, 0.0), +vec4(0.0, 0.5, 0.0, 0.0), +vec4(0.0, 0.0, 0.5, 0.0), +vec4(0.5, 0.5, 0.5, 1.0) +); + void main() { @@ -34,9 +46,12 @@ void main() + BoneWeights[2] * Bones[int(BoneIndices[2])] + BoneWeights[3] * Bones[int(BoneIndices[3])]; } - - gl_Position = P*V*M*boneTransform * vec4(Position, 1.0); + //vec4 lightPos = biasMatrix * LightP * LightV * M * vec4(Position, 1.0); // N + + gl_Position = P*V*M*boneTransform * vec4(Position, 1.0); + //gl_Position = lightPos; // N + Output.Position = (boneTransform * vec4(Position, 1.0)).xyz; Output.TextureCoordinate = TextureCoords; Output.Normal = vec3(M * vec4(Normal, 0.0)); @@ -44,4 +59,7 @@ void main() Output.BiTangent = vec3(M * vec4(BiTangent, 0.0)); Output.ExplosionColor = vec4(1.0); Output.ExplosionPercentageElapsed = 0.0; + + //Output.PositionLightSpace = lightPos; // N + Output.PositionLightSpace = lightSpaceMatrix * (M * vec4(Position, 1.0)); } \ No newline at end of file diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 8247797e..3e74cd1a 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -1,9 +1,10 @@ #include "Rendering/DrawFinalPass.h" -DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass) +DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, ShadowPass* shadowPass) { m_Renderer = renderer; m_LightCullingPass = lightCullingPass; + m_ShadowPass = shadowPass; InitializeTextures(); InitializeShaderPrograms(); InitializeFrameBuffers(); @@ -242,6 +243,16 @@ void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptrFillPercentage); glUniform4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor)); + //Shadow + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "lightSpaceMatrix"), 1, GL_FALSE, glm::value_ptr(m_ShadowPass->lightSpaceMatrix())); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightP"), 1, GL_FALSE, glm::value_ptr(m_ShadowPass->lightP())); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightV"), 1, GL_FALSE, glm::value_ptr(m_ShadowPass->lightV())); + //GLfloat m_NearFarPlane[2] = { -40.f, 30.f }; + //GLfloat m_LRBT[4] = { -40.f, 100.f, -50.f, 50.f }; + //glm::mat4 m_LightProjection = glm::ortho(m_LRBT[Left], m_LRBT[Right], m_LRBT[Bottom], m_LRBT[Top], m_NearFarPlane[Near], m_NearFarPlane[Far]); + //glm::mat4 m_LightView = glm::lookAt(glm::vec3(-20.0f, 20.0f, -20.0f), glm::vec3(0.0f), glm::vec3(1.0)); + //glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightP"), 1, GL_FALSE, glm::value_ptr(m_LightProjection)); + //glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightV"), 1, GL_FALSE, glm::value_ptr(m_LightView)); GLERROR("END"); } @@ -306,5 +317,12 @@ void DrawFinalPass::BindModelTextures(std::shared_ptr& job) } else { glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture); } + + glActiveTexture(GL_TEXTURE4); + if (m_ShadowPass->DepthMap() != NULL) { + glBindTexture(GL_TEXTURE_2D, m_ShadowPass->DepthMap()); + } else { + glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); + } } diff --git a/src/Engine/Rendering/FrameBuffer.cpp b/src/Engine/Rendering/FrameBuffer.cpp index 4f83122e..44ffb20e 100644 --- a/src/Engine/Rendering/FrameBuffer.cpp +++ b/src/Engine/Rendering/FrameBuffer.cpp @@ -49,7 +49,6 @@ void FrameBuffer::Generate() case GL_TEXTURE_2D: glFramebufferTexture2D(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle, 0); GLERROR("FrameBuffer generate: glFramebufferTexture2D"); - break; case GL_RENDERBUFFER: glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle); diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index 147fed65..f8e1cd6b 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -138,7 +138,6 @@ void Renderer::Draw(RenderFrame& frame) } if (m_DebugTextureToDraw == 5) { m_DrawScreenQuadPass->Draw(m_ShadowPass->DepthMap()); - // m_DrawScreenQuadPass->Draw(); } m_ImGuiRenderPass->Draw(); @@ -179,9 +178,9 @@ void Renderer::InitializeRenderPasses() { m_PickingPass = new PickingPass(this, m_EventBroker); m_LightCullingPass = new LightCullingPass(this); - m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass); + m_ShadowPass = new ShadowPass(this); + m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_ShadowPass); m_DrawScreenQuadPass = new DrawScreenQuadPass(this); m_DrawBloomPass = new DrawBloomPass(this); m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this); - m_ShadowPass = new ShadowPass(this); } diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index 84c0de87..9855917c 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -71,23 +71,20 @@ void ShadowPass::Draw(RenderScene & scene) //} ImGui::DragFloat4("ShadowMapCam", m_LRBT, 1.f, -1000.f, 1000.f); + ImGui::DragFloat2("ShadowMapNearFar", m_NearFarPlane, 1.f, -1000.f, 1000.f); for (auto &job : scene.DirectionalLightJobs) { auto directionalLightJob = std::dynamic_pointer_cast(job); if(directionalLightJob) { - glm::mat4 lightProjection = glm::ortho(m_LRBT[0], m_LRBT[1], m_LRBT[2], m_LRBT[3], m_NearPlane, m_FarPlane); + //m_LightProjection = glm::ortho(m_LRBT[Left], m_LRBT[Right], m_LRBT[Bottom], m_LRBT[Top], m_NearFarPlane[Near], m_NearFarPlane[Far]); + m_LightProjection = glm::ortho(m_LRBT[Left], m_LRBT[Right], m_LRBT[Bottom], m_LRBT[Top], m_NearFarPlane[Near], m_NearFarPlane[Far]); + m_LightView = glm::lookAt(-glm::normalize(glm::vec3(directionalLightJob->Direction)), glm::vec3(0.f,0.f,0.f), glm::vec3(0.f,1.f,0.f)); + //m_LightView = glm::lookAt(glm::vec3(-20.0f, 20.0f, -20.0f), glm::vec3(0.0f), glm::vec3(1.0)); + m_LightSpaceMatrix = m_LightProjection * m_LightView; - // broken? - glm::mat4 lightView = glm::lookAt(-glm::normalize(glm::vec3(directionalLightJob->Direction)) * (float)20.0 , glm::vec3(0,0,0), glm::vec3(0,1,0)); - //glm::mat4 lightView = glm::lookAt(glm::vec3(10.f, 10.f, 50.f), glm::vec3(0.f, 0.f, 0.f), glm::vec3(0.f, 1.f, 0.f)); - //glm::mat4 lightSpaceMatrix = lightProjection * lightView; - - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(lightProjection)); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(lightView)); - - /* glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));*/ + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection)); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView)); GLERROR("ShadowLight ERROR"); From 847c539373ba58548bf010a96e60ac66a56b44dc Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Tue, 9 Feb 2016 14:44:12 +0100 Subject: [PATCH 008/252] Fix viewport --- resources/Shaders/ForwardPlus.frag.glsl | 21 ++------------------- resources/Shaders/ForwardPlus.vert.glsl | 4 ++-- src/Engine/Rendering/ShadowPass.cpp | 5 ++--- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index d54de713..56809878 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -114,27 +114,10 @@ vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textu return vec4(TBN * normalize(NormalMap), 0.0); } -//float CalcShadowValue(vec4 positionLightSpace, vec4 normal, vec4 lightDir, sampler2D depthTexture) -//{ -// // perform perspective divide -// //vec3 projCoords = positionLightSpace.xyz / positionLightSpace.w; -// // Transform to [0,1] range -// //projCoords = projCoords * 0.5 + 0.5; -// // Get closest depth value from light's perspective (using [0,1] range fragPosLight as coords) -// float closestDepth = texture(depthTexture, positionLightSpace.xy).r; -// // Get depth of current fragment from light's perspective -// float currentDepth = positionLightSpace.z; -// // Check whether current frag pos is in shadow -// float shadow = currentDepth > closestDepth ? 1.0 : 0.0; -// -// return shadow; -// -//} - float CalcShadowValue(vec4 positionLightSpace, vec4 normal, vec4 lightDir, sampler2D depthTexture) { - //float bias = max(0.05 * (1.0 - dot(normal, -lightDir)), 0.005); + float bias = max(0.05 * (1.0 - dot(normal, -lightDir)), 0.005); // perform perspective divide vec3 projCoords = positionLightSpace.xyz / positionLightSpace.w; // Transform to [0,1] range @@ -188,7 +171,7 @@ void main() light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, position, normal, light.Falloff); } else if (light.Type == 2) { //Directional light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal); - shadowFactor = CalcShadowValue(Input.PositionLightSpace, normal, light.Direction, DepthMap); + shadowFactor = CalcShadowValue(Input.PositionLightSpace, vec4(Input.Normal, 0.0), light.Direction, DepthMap); } totalLighting.Diffuse += light_result.Diffuse; diff --git a/resources/Shaders/ForwardPlus.vert.glsl b/resources/Shaders/ForwardPlus.vert.glsl index 21f3f370..bde356e9 100644 --- a/resources/Shaders/ForwardPlus.vert.glsl +++ b/resources/Shaders/ForwardPlus.vert.glsl @@ -47,7 +47,7 @@ void main() + BoneWeights[3] * Bones[int(BoneIndices[3])]; } - //vec4 lightPos = biasMatrix * LightP * LightV * M * vec4(Position, 1.0); // N + //vec4 lightPos = LightP * LightV * M * vec4(Position, 1.0); // N gl_Position = P*V*M*boneTransform * vec4(Position, 1.0); //gl_Position = lightPos; // N @@ -61,5 +61,5 @@ void main() Output.ExplosionPercentageElapsed = 0.0; //Output.PositionLightSpace = lightPos; // N - Output.PositionLightSpace = lightSpaceMatrix * (M * vec4(Position, 1.0)); + Output.PositionLightSpace = lightSpaceMatrix * M * vec4(Position, 1.0); } \ No newline at end of file diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index 9855917c..3ae83773 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -25,9 +25,8 @@ void ShadowPass::InitializeFrameBuffers() // Depth texture glGenTextures(1, &m_DepthMap); glBindTexture(GL_TEXTURE_2D, m_DepthMap); - //glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1024, 1024, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1024, 1024, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); - //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, 1024, 1024, 0, GL_RGB, GL_FLOAT, 0); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); + //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height, 0, GL_RGB, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); From ecd823cb9f59843a2d67be0711a18f3daef4d166 Mon Sep 17 00:00:00 2001 From: Ayumiwii Date: Tue, 9 Feb 2016 16:15:11 +0100 Subject: [PATCH 009/252] Shadow WIP stage 2 - Soft shadow --- include/Engine/Rendering/ShadowPass.h | 8 ++++++-- resources/Shaders/ForwardPlus.frag.glsl | 22 +++++++++++++++++++++- src/Engine/Rendering/ShadowPass.cpp | 13 +++++++------ 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/include/Engine/Rendering/ShadowPass.h b/include/Engine/Rendering/ShadowPass.h index a8f41502..301af9a5 100644 --- a/include/Engine/Rendering/ShadowPass.h +++ b/include/Engine/Rendering/ShadowPass.h @@ -32,8 +32,8 @@ public: glm::mat4 lightSpaceMatrix() const { return m_LightSpaceMatrix; } glm::mat4 lightP() const { return m_LightProjection; } glm::mat4 lightV() const { return m_LightView; } - //glm::mat4 lightV() const { return m_LightProjection; } //swapped m_P -> m_V - //glm::mat4 lightP() const { return m_LightView; } // swapped m_V -> m_P + + void setResolution(GLuint width, GLuint height) { resolutionSizeWidth = width; resolutionSizeHeigth = height; } private: @@ -57,6 +57,10 @@ private: glm::mat4 m_LightProjection; glm::mat4 m_LightView; glm::mat4 m_LightSpaceMatrix; + + GLuint resolutionSizeWidth = 2048; + GLuint resolutionSizeHeigth = 2048; + }; #endif \ No newline at end of file diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 56809878..cf3b3ed0 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -114,6 +114,13 @@ vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textu return vec4(TBN * normalize(NormalMap), 0.0); } +vec2 poissonDisk[4] = vec2[]( + vec2( -0.94201624, -0.39906216 ), + vec2( 0.94558609, -0.76890725 ), + vec2( -0.094184101, -0.92938870 ), + vec2( 0.34495938, 0.29387760 ) + ); + float CalcShadowValue(vec4 positionLightSpace, vec4 normal, vec4 lightDir, sampler2D depthTexture) { @@ -129,8 +136,21 @@ float CalcShadowValue(vec4 positionLightSpace, vec4 normal, vec4 lightDir, sampl //float currentDepth = positionLightSpace.z; float currentDepth = projCoords.z; // Check whether current frag pos is in shadow - float shadow = currentDepth /*- bias*/ > closestDepth ? 1.0 : 0.0; + //float shadow = currentDepth - bias > closestDepth ? 1.0 : 0.0; // float shadow = currentDepth > closestDepth ? 1.0 : 0.0; + + float shadow = 0.0; + //soft shadow - using percentage-closer filtering (PCF) is to simply sample the surrounding texels of the depth map and average the results: + vec2 texelSize = 1.0 / textureSize(depthTexture, 0); + for(int x = -1; x <= 1; ++x) + { + for(int y = -1; y <= 1; ++y) + { + float pcfDepth = texture(depthTexture, projCoords.xy + vec2(x, y) * texelSize).r; + shadow += currentDepth - bias > pcfDepth ? 1.0 : 0.0; + } + } + shadow /= 9.0; return shadow; diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index 3ae83773..c6bb4313 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -25,7 +25,7 @@ void ShadowPass::InitializeFrameBuffers() // Depth texture glGenTextures(1, &m_DepthMap); glBindTexture(GL_TEXTURE_2D, m_DepthMap); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, resolutionSizeWidth, resolutionSizeHeigth, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height, 0, GL_RGB, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -65,9 +65,9 @@ void ShadowPass::Draw(RenderScene & scene) GLuint shaderHandle = m_ShadowProgram->GetHandle(); m_ShadowProgram->Bind(); - //if (scene.ClearDepth) { - // glClear(GL_COLOR_BUFFER_BIT); - //} + glViewport(0, 0, resolutionSizeWidth, resolutionSizeHeigth); + glCullFace(GL_FRONT); + ImGui::DragFloat4("ShadowMapCam", m_LRBT, 1.f, -1000.f, 1000.f); ImGui::DragFloat2("ShadowMapNearFar", m_NearFarPlane, 1.f, -1000.f, 1000.f); @@ -111,8 +111,9 @@ void ShadowPass::Draw(RenderScene & scene) - - //m_ShadowProgram->Unbind(); + glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); + glCullFace(GL_BACK); + m_ShadowProgram->Unbind(); From 6af167675d102f02a40df9291371b51768707d86 Mon Sep 17 00:00:00 2001 From: Ayumiwii Date: Wed, 10 Feb 2016 11:48:44 +0100 Subject: [PATCH 010/252] Shadow WIP stage 2 - fix cel-shading --- include/Engine/Rendering/ShadowPass.h | 9 ++-- resources/Shaders/ForwardPlus.frag.glsl | 32 +++++++------ src/Engine/Rendering/ShadowPass.cpp | 61 +++++++++++++------------ 3 files changed, 57 insertions(+), 45 deletions(-) diff --git a/include/Engine/Rendering/ShadowPass.h b/include/Engine/Rendering/ShadowPass.h index 301af9a5..e26045db 100644 --- a/include/Engine/Rendering/ShadowPass.h +++ b/include/Engine/Rendering/ShadowPass.h @@ -51,16 +51,17 @@ private: GLuint m_DepthFBO; - GLfloat m_NearFarPlane[2] = { -40.f, 30.f }; - GLfloat m_LRBT[4] = { -40.f, 100.f, -50.f, 50.f }; + GLfloat m_NearFarPlane[2] = { -84.f, 28.f }; + GLfloat m_LRBT[4] = { -77.f, 75.f, -89.f, 89.f }; glm::mat4 m_LightProjection; glm::mat4 m_LightView; glm::mat4 m_LightSpaceMatrix; - GLuint resolutionSizeWidth = 2048; - GLuint resolutionSizeHeigth = 2048; + GLuint resolutionSizeWidth = 2048 * 4; + GLuint resolutionSizeHeigth = 2048 * 4; + bool m_ShadowOn = true; }; #endif \ No newline at end of file diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index cf3b3ed0..a82555c8 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -124,7 +124,8 @@ vec2 poissonDisk[4] = vec2[]( float CalcShadowValue(vec4 positionLightSpace, vec4 normal, vec4 lightDir, sampler2D depthTexture) { - float bias = max(0.05 * (1.0 - dot(normal, -lightDir)), 0.005); + float bias = 0.005; + //float bias = max(0.05 * (1.0 - dot(normal, -lightDir)), 0.005); // perform perspective divide vec3 projCoords = positionLightSpace.xyz / positionLightSpace.w; // Transform to [0,1] range @@ -136,21 +137,26 @@ float CalcShadowValue(vec4 positionLightSpace, vec4 normal, vec4 lightDir, sampl //float currentDepth = positionLightSpace.z; float currentDepth = projCoords.z; // Check whether current frag pos is in shadow - //float shadow = currentDepth - bias > closestDepth ? 1.0 : 0.0; - // float shadow = currentDepth > closestDepth ? 1.0 : 0.0; + float shadow = currentDepth - bias > closestDepth ? 1.0 : 0.0; + //float shadow = currentDepth > closestDepth ? 1.0 : 0.0; - float shadow = 0.0; - //soft shadow - using percentage-closer filtering (PCF) is to simply sample the surrounding texels of the depth map and average the results: - vec2 texelSize = 1.0 / textureSize(depthTexture, 0); - for(int x = -1; x <= 1; ++x) + //float shadow = 0.0; + ////soft shadow - using percentage-closer filtering (PCF) is to simply sample the surrounding texels of the depth map and average the results: + //vec2 texelSize = 1.0 / textureSize(depthTexture, 0); + //for(int x = -1; x <= 1; ++x) + //{ + // for(int y = -1; y <= 1; ++y) + // { + // float pcfDepth = texture(depthTexture, projCoords.xy + vec2(x, y) * texelSize).r; + // shadow += currentDepth - bias > pcfDepth ? 1.0 : 0.0; + // } + //} + //shadow /= 9.0; + // + if(projCoords.z > 0.9) { - for(int y = -1; y <= 1; ++y) - { - float pcfDepth = texture(depthTexture, projCoords.xy + vec2(x, y) * texelSize).r; - shadow += currentDepth - bias > pcfDepth ? 1.0 : 0.0; - } + shadow = 1.0; } - shadow /= 9.0; return shadow; diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index c6bb4313..61e37da3 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -25,13 +25,14 @@ void ShadowPass::InitializeFrameBuffers() // Depth texture glGenTextures(1, &m_DepthMap); glBindTexture(GL_TEXTURE_2D, m_DepthMap); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, resolutionSizeWidth, resolutionSizeHeigth, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, resolutionSizeWidth, resolutionSizeHeigth, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height, 0, GL_RGB, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + m_DepthBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthMap, GL_DEPTH_ATTACHMENT))); //m_DepthBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthMap, GL_COLOR_ATTACHMENT0))); m_DepthBuffer.Generate(); @@ -66,47 +67,51 @@ void ShadowPass::Draw(RenderScene & scene) m_ShadowProgram->Bind(); glViewport(0, 0, resolutionSizeWidth, resolutionSizeHeigth); - glCullFace(GL_FRONT); - + glCullFace(GL_BACK); + //state->Disable(GL_CULL_FACE); ImGui::DragFloat4("ShadowMapCam", m_LRBT, 1.f, -1000.f, 1000.f); ImGui::DragFloat2("ShadowMapNearFar", m_NearFarPlane, 1.f, -1000.f, 1000.f); + ImGui::Checkbox("EnableShadow", &m_ShadowOn); - for (auto &job : scene.DirectionalLightJobs) { - auto directionalLightJob = std::dynamic_pointer_cast(job); + if (m_ShadowOn == true) + { + for (auto &job : scene.DirectionalLightJobs) { + auto directionalLightJob = std::dynamic_pointer_cast(job); - if(directionalLightJob) { - //m_LightProjection = glm::ortho(m_LRBT[Left], m_LRBT[Right], m_LRBT[Bottom], m_LRBT[Top], m_NearFarPlane[Near], m_NearFarPlane[Far]); - m_LightProjection = glm::ortho(m_LRBT[Left], m_LRBT[Right], m_LRBT[Bottom], m_LRBT[Top], m_NearFarPlane[Near], m_NearFarPlane[Far]); - m_LightView = glm::lookAt(-glm::normalize(glm::vec3(directionalLightJob->Direction)), glm::vec3(0.f,0.f,0.f), glm::vec3(0.f,1.f,0.f)); - //m_LightView = glm::lookAt(glm::vec3(-20.0f, 20.0f, -20.0f), glm::vec3(0.0f), glm::vec3(1.0)); - m_LightSpaceMatrix = m_LightProjection * m_LightView; + if(directionalLightJob) { + //m_LightProjection = glm::ortho(m_LRBT[Left], m_LRBT[Right], m_LRBT[Bottom], m_LRBT[Top], m_NearFarPlane[Near], m_NearFarPlane[Far]); + m_LightProjection = glm::ortho(m_LRBT[Left], m_LRBT[Right], m_LRBT[Bottom], m_LRBT[Top], m_NearFarPlane[Near], m_NearFarPlane[Far]); + m_LightView = glm::lookAt(-glm::normalize(glm::vec3(directionalLightJob->Direction)), glm::vec3(0.f,0.f,0.f), glm::vec3(0.f,1.f,0.f)); + //m_LightView = glm::lookAt(glm::vec3(-20.0f, 20.0f, -20.0f), glm::vec3(0.0f), glm::vec3(1.0)); + m_LightSpaceMatrix = m_LightProjection * m_LightView; - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection)); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView)); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection)); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView)); - GLERROR("ShadowLight ERROR"); + GLERROR("ShadowLight ERROR"); - for (auto &objectJob : scene.OpaqueObjects) { - auto modelJob = std::dynamic_pointer_cast(objectJob); + for (auto &objectJob : scene.OpaqueObjects) { + auto modelJob = std::dynamic_pointer_cast(objectJob); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); - 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))); + 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("Shadow Draw ERROR"); + GLERROR("Shadow Draw ERROR"); - } + } + } + + m_DepthBuffer.Unbind(); + + delete state; + + } - - m_DepthBuffer.Unbind(); - - delete state; - - } From 69db32337ddb04557e8e60187782076249a5d253 Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Wed, 10 Feb 2016 15:16:58 +0100 Subject: [PATCH 011/252] Shado wip --- include/Engine/Rendering/ShadowPass.h | 2 +- resources/Schema/Entities/GameMap.xml | 7 +++ resources/Shaders/ForwardPlus.frag.glsl | 63 +++++++++++-------------- src/Engine/Rendering/ShadowPass.cpp | 14 ++++-- 4 files changed, 44 insertions(+), 42 deletions(-) diff --git a/include/Engine/Rendering/ShadowPass.h b/include/Engine/Rendering/ShadowPass.h index e26045db..5acc376e 100644 --- a/include/Engine/Rendering/ShadowPass.h +++ b/include/Engine/Rendering/ShadowPass.h @@ -51,7 +51,7 @@ private: GLuint m_DepthFBO; - GLfloat m_NearFarPlane[2] = { -84.f, 28.f }; + GLfloat m_NearFarPlane[2] = { -34.f, 27.f }; GLfloat m_LRBT[4] = { -77.f, 75.f, -89.f, 89.f }; glm::mat4 m_LightProjection; diff --git a/resources/Schema/Entities/GameMap.xml b/resources/Schema/Entities/GameMap.xml index 97fd3f4d..7b62b5d8 100644 --- a/resources/Schema/Entities/GameMap.xml +++ b/resources/Schema/Entities/GameMap.xml @@ -238,6 +238,13 @@ + + + + + + + diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index a82555c8..170a9d5a 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -13,7 +13,7 @@ layout (binding = 0) uniform sampler2D DiffuseTexture; layout (binding = 1) uniform sampler2D NormalMapTexture; layout (binding = 2) uniform sampler2D SpecularMapTexture; layout (binding = 3) uniform sampler2D GlowMapTexture; -layout (binding = 4) uniform sampler2D DepthMap; +layout (binding = 4) uniform sampler2DShadow DepthMap; #define TILE_SIZE 16 @@ -114,49 +114,39 @@ vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textu return vec4(TBN * normalize(NormalMap), 0.0); } -vec2 poissonDisk[4] = vec2[]( - vec2( -0.94201624, -0.39906216 ), - vec2( 0.94558609, -0.76890725 ), - vec2( -0.094184101, -0.92938870 ), - vec2( 0.34495938, 0.29387760 ) - ); - -float CalcShadowValue(vec4 positionLightSpace, vec4 normal, vec4 lightDir, sampler2D depthTexture) +float CalcShadowValue(vec4 positionLightSpace, vec3 normal, vec3 lightDir, sampler2DShadow depthTexture) { float bias = 0.005; - //float bias = max(0.05 * (1.0 - dot(normal, -lightDir)), 0.005); - // perform perspective divide + //float bias = max(0.05 * (1.0 - dot(normal, lightDir)), 0.005); + //float bias = 0.005 * tan(acos(clamp(dot(normal, lightDir), 0,1))); bias = clamp(bias, 0,0.01); + vec3 projCoords = positionLightSpace.xyz / positionLightSpace.w; - // Transform to [0,1] range projCoords = projCoords * 0.5 + 0.5; - // Get closest depth value from light's perspective (using [0,1] range fragPosLight as coords) - //float lightDepth = texture(depthTexture, positionLightSpace.xy).r; - float closestDepth = texture(depthTexture, projCoords.xy).r; - // Get depth of current fragment from light's perspective - //float currentDepth = positionLightSpace.z; - float currentDepth = projCoords.z; - // Check whether current frag pos is in shadow - float shadow = currentDepth - bias > closestDepth ? 1.0 : 0.0; - //float shadow = currentDepth > closestDepth ? 1.0 : 0.0; - + //float shadowMapDepth = texture(depthTexture, projCoords.xy).r; + float shadowMapDepth = 1.0 - texture(depthTexture, projCoords); + float geometryDepth = projCoords.z; + //float shadow = geometryDepth - bias > shadowMapDepth ? 1.0 : 0.0; + //float shadow = geometryDepth - bias > shadowMapDepth ? 0.0 : 1.0; + float shadow = shadowMapDepth; + //float shadow = 0.0; - ////soft shadow - using percentage-closer filtering (PCF) is to simply sample the surrounding texels of the depth map and average the results: + //vec2 texelSize = 1.0 / textureSize(depthTexture, 0); - //for(int x = -1; x <= 1; ++x) + //for(int x = -1; x <= 1; x++) //{ - // for(int y = -1; y <= 1; ++y) + // for(int y = -1; y <= 1; y++) // { - // float pcfDepth = texture(depthTexture, projCoords.xy + vec2(x, y) * texelSize).r; - // shadow += currentDepth - bias > pcfDepth ? 1.0 : 0.0; + // float pcfDepth = texture(depthTexture, projCoords.xy + vec2(x, y) * texelSize).r; + // shadow += geometryDepth - bias > pcfDepth ? 1.0 : 0.0; // } //} //shadow /= 9.0; - // - if(projCoords.z > 0.9) - { - shadow = 1.0; - } + + //if(projCoords.z > 1.0) + //{ + // shadow = 0.0; + //} return shadow; @@ -184,7 +174,7 @@ void main() int start = int(LightGrids.Data[currentTile].Start); int amount = int(LightGrids.Data[currentTile].Amount); - float shadowFactor = 1.0; + float shadowFactor = 0.0; for(int i = start; i < start + amount; i++) { @@ -197,15 +187,16 @@ void main() light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, position, normal, light.Falloff); } else if (light.Type == 2) { //Directional light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal); - shadowFactor = CalcShadowValue(Input.PositionLightSpace, vec4(Input.Normal, 0.0), light.Direction, DepthMap); + shadowFactor = CalcShadowValue(Input.PositionLightSpace, Input.Normal, vec3(light.Direction), DepthMap); } totalLighting.Diffuse += light_result.Diffuse; totalLighting.Specular += light_result.Specular; } - totalLighting.Diffuse += (1.0 - shadowFactor); - totalLighting.Specular += (1.0 - shadowFactor); + totalLighting.Diffuse *= (1.0 + vec4(AmbientColor.rgb, 1.0)) - vec4(vec3(shadowFactor), 0.0); + totalLighting.Specular *= (1.0 + vec4(AmbientColor.rgb, 1.0)) - vec4(vec3(shadowFactor), 0.0); + //LightResult getInformation; vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index 61e37da3..5ffd553f 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -25,12 +25,15 @@ void ShadowPass::InitializeFrameBuffers() // Depth texture glGenTextures(1, &m_DepthMap); glBindTexture(GL_TEXTURE_2D, m_DepthMap); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, resolutionSizeWidth, resolutionSizeHeigth, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, resolutionSizeWidth, resolutionSizeHeigth, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height, 0, GL_RGB, GL_FLOAT, 0); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); + glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY); m_DepthBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthMap, GL_DEPTH_ATTACHMENT))); @@ -67,7 +70,8 @@ void ShadowPass::Draw(RenderScene & scene) m_ShadowProgram->Bind(); glViewport(0, 0, resolutionSizeWidth, resolutionSizeHeigth); - glCullFace(GL_BACK); + + //glCullFace(GL_FRONT); //state->Disable(GL_CULL_FACE); ImGui::DragFloat4("ShadowMapCam", m_LRBT, 1.f, -1000.f, 1000.f); @@ -117,7 +121,7 @@ void ShadowPass::Draw(RenderScene & scene) glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); - glCullFace(GL_BACK); + //glCullFace(GL_BACK); m_ShadowProgram->Unbind(); From cb77c1ff974fcb1f031f9fc3a6d1e12714533917 Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Wed, 10 Feb 2016 16:16:41 +0100 Subject: [PATCH 012/252] Working pcf, not optimized --- include/Engine/Rendering/ShadowPass.h | 4 ++-- resources/Shaders/ForwardPlus.frag.glsl | 9 ++++----- src/Engine/Rendering/ShadowPass.cpp | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/include/Engine/Rendering/ShadowPass.h b/include/Engine/Rendering/ShadowPass.h index 5acc376e..7c93fcd8 100644 --- a/include/Engine/Rendering/ShadowPass.h +++ b/include/Engine/Rendering/ShadowPass.h @@ -58,8 +58,8 @@ private: glm::mat4 m_LightView; glm::mat4 m_LightSpaceMatrix; - GLuint resolutionSizeWidth = 2048 * 4; - GLuint resolutionSizeHeigth = 2048 * 4; + GLuint resolutionSizeWidth = 2048 * 2; + GLuint resolutionSizeHeigth = 2048 * 2; bool m_ShadowOn = true; }; diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 170a9d5a..ce71be28 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -121,16 +121,15 @@ float CalcShadowValue(vec4 positionLightSpace, vec3 normal, vec3 lightDir, sampl //float bias = max(0.05 * (1.0 - dot(normal, lightDir)), 0.005); //float bias = 0.005 * tan(acos(clamp(dot(normal, lightDir), 0,1))); bias = clamp(bias, 0,0.01); - vec3 projCoords = positionLightSpace.xyz / positionLightSpace.w; + vec3 projCoords = vec3(positionLightSpace.xy, positionLightSpace.z + bias) / positionLightSpace.w; projCoords = projCoords * 0.5 + 0.5; //float shadowMapDepth = texture(depthTexture, projCoords.xy).r; - float shadowMapDepth = 1.0 - texture(depthTexture, projCoords); + float shadowMapDepth = texture(depthTexture, projCoords); float geometryDepth = projCoords.z; //float shadow = geometryDepth - bias > shadowMapDepth ? 1.0 : 0.0; - //float shadow = geometryDepth - bias > shadowMapDepth ? 0.0 : 1.0; - float shadow = shadowMapDepth; + //float shadow = 1.0 - bias > shadowMapDepth ? 0.0 : 1.0; - //float shadow = 0.0; + float shadow = 1.0 - shadowMapDepth; //vec2 texelSize = 1.0 / textureSize(depthTexture, 0); //for(int x = -1; x <= 1; x++) diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index 5ffd553f..fbf25219 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -33,7 +33,7 @@ void ShadowPass::InitializeFrameBuffers() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); - glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY); + //glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY); m_DepthBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthMap, GL_DEPTH_ATTACHMENT))); @@ -71,7 +71,7 @@ void ShadowPass::Draw(RenderScene & scene) glViewport(0, 0, resolutionSizeWidth, resolutionSizeHeigth); - //glCullFace(GL_FRONT); + glCullFace(GL_FRONT); //state->Disable(GL_CULL_FACE); ImGui::DragFloat4("ShadowMapCam", m_LRBT, 1.f, -1000.f, 1000.f); @@ -121,7 +121,7 @@ void ShadowPass::Draw(RenderScene & scene) glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); - //glCullFace(GL_BACK); + glCullFace(GL_BACK); m_ShadowProgram->Unbind(); From 36043010af52d4d346f6cd4423d0ac32513af655 Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Wed, 10 Feb 2016 20:51:33 +0100 Subject: [PATCH 013/252] wip for shadows they work, but will be shit until we get cascaded. --- include/Engine/Rendering/ShadowPass.h | 4 +-- resources/Shaders/ForwardPlus.frag.glsl | 45 ++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/include/Engine/Rendering/ShadowPass.h b/include/Engine/Rendering/ShadowPass.h index 7c93fcd8..c5bf038e 100644 --- a/include/Engine/Rendering/ShadowPass.h +++ b/include/Engine/Rendering/ShadowPass.h @@ -58,8 +58,8 @@ private: glm::mat4 m_LightView; glm::mat4 m_LightSpaceMatrix; - GLuint resolutionSizeWidth = 2048 * 2; - GLuint resolutionSizeHeigth = 2048 * 2; + GLuint resolutionSizeWidth = 1024 * 8; + GLuint resolutionSizeHeigth = 1024 * 8; bool m_ShadowOn = true; }; diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index ce71be28..1157a019 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -114,18 +114,53 @@ vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textu return vec4(TBN * normalize(NormalMap), 0.0); } +vec2 poissonDisk[16] = vec2[]( + vec2( -0.94201624, -0.39906216 ), + vec2( 0.94558609, -0.76890725 ), + vec2( -0.094184101, -0.92938870 ), + vec2( 0.34495938, 0.29387760 ), + vec2( -0.91588581, 0.45771432 ), + vec2( -0.81544232, -0.87912464 ), + vec2( -0.38277543, 0.27676845 ), + vec2( 0.97484398, 0.75648379 ), + vec2( 0.44323325, -0.97511554 ), + vec2( 0.53742981, -0.47373420 ), + vec2( -0.26496911, -0.41893023 ), + vec2( 0.79197514, 0.19090188 ), + vec2( -0.24188840, 0.99706507 ), + vec2( -0.81409955, 0.91437590 ), + vec2( 0.19984126, 0.78641367 ), + vec2( 0.14383161, -0.14100790 ) +); + +float random(vec3 seed, int i) +{ + vec4 seed4 = vec4(seed, i); + float dot_product = dot(seed4, vec4(12.9898, 78.233, 45.164, 94.673)); + return fract(sin(dot_product) * 43758.5453); +} + float CalcShadowValue(vec4 positionLightSpace, vec3 normal, vec3 lightDir, sampler2DShadow depthTexture) { float bias = 0.005; //float bias = max(0.05 * (1.0 - dot(normal, lightDir)), 0.005); - //float bias = 0.005 * tan(acos(clamp(dot(normal, lightDir), 0,1))); bias = clamp(bias, 0,0.01); + //float bias = 0.005 * tan(acos(clamp(dot(normal, -lightDir), 0.0, 1.0))); vec3 projCoords = vec3(positionLightSpace.xy, positionLightSpace.z + bias) / positionLightSpace.w; projCoords = projCoords * 0.5 + 0.5; //float shadowMapDepth = texture(depthTexture, projCoords.xy).r; - float shadowMapDepth = texture(depthTexture, projCoords); - float geometryDepth = projCoords.z; + float shadowMapDepth; + //for (int i = 0; i < 4; i++) + //{ + // int index = i; + // //int index = int(16.0 * random(gl_FragCoord.xyy, i)) % 16; + // shadowMapDepth += 0.25 * texture(depthTexture, projCoords + vec3(poissonDisk[index], 0.0) / 700.0); + //} + + shadowMapDepth = texture(depthTexture, projCoords); + + //float geometryDepth = projCoords.z; //float shadow = geometryDepth - bias > shadowMapDepth ? 1.0 : 0.0; //float shadow = 1.0 - bias > shadowMapDepth ? 0.0 : 1.0; @@ -193,8 +228,8 @@ void main() totalLighting.Specular += light_result.Specular; } - totalLighting.Diffuse *= (1.0 + vec4(AmbientColor.rgb, 1.0)) - vec4(vec3(shadowFactor), 0.0); - totalLighting.Specular *= (1.0 + vec4(AmbientColor.rgb, 1.0)) - vec4(vec3(shadowFactor), 0.0); + totalLighting.Diffuse *= (1.5 + vec4(AmbientColor.rgb, 1.0)) - vec4(vec3(shadowFactor), 0.0); + totalLighting.Specular *= (1.5 + vec4(AmbientColor.rgb, 1.0)) - vec4(vec3(shadowFactor), 0.0); //LightResult getInformation; From 17da9a8036ca6d23512aabcadb4c18106f5bb69e Mon Sep 17 00:00:00 2001 From: Teejoon Date: Tue, 16 Feb 2016 15:56:58 +0100 Subject: [PATCH 014/252] WIP --- include/Engine/Rendering/ModelJob.h | 2 +- include/Engine/Rendering/SpriteJob.h | 8 +- resources/Schema/Components.xsd | 1 + resources/Schema/Components/Indicator.xml | 3 + resources/Schema/Components/Indicator.xsd | 11 + resources/Schema/Entities/JohansTestMap.xml | 5379 +++++++++++++++++ resources/Schema/Entities/TestPlayerIndicator | 590 ++ .../Schema/Entities/TestPlayerIndicator.xml | 590 ++ src/Engine/Rendering/RenderSystem.cpp | 35 +- 9 files changed, 6612 insertions(+), 7 deletions(-) create mode 100644 resources/Schema/Components/Indicator.xml create mode 100644 resources/Schema/Components/Indicator.xsd create mode 100644 resources/Schema/Entities/JohansTestMap.xml create mode 100644 resources/Schema/Entities/TestPlayerIndicator create mode 100644 resources/Schema/Entities/TestPlayerIndicator.xml diff --git a/include/Engine/Rendering/ModelJob.h b/include/Engine/Rendering/ModelJob.h index ba801f60..41b0b8dd 100644 --- a/include/Engine/Rendering/ModelJob.h +++ b/include/Engine/Rendering/ModelJob.h @@ -183,7 +183,7 @@ struct ModelJob : RenderJob void CalculateHash() override { - Hash = TextureID + ModelID << 10 + ShaderID << 20; + Hash = ShaderID << 20 + ModelID << 10 + TextureID; } }; diff --git a/include/Engine/Rendering/SpriteJob.h b/include/Engine/Rendering/SpriteJob.h index 3bb43a1c..07636a97 100644 --- a/include/Engine/Rendering/SpriteJob.h +++ b/include/Engine/Rendering/SpriteJob.h @@ -17,7 +17,7 @@ struct SpriteJob : RenderJob { - SpriteJob(ComponentWrapper cSprite, Camera* camera, glm::mat4 matrix, World* world, glm::vec4 fillColor, float fillPercentage, bool depthSorted) + SpriteJob(ComponentWrapper cSprite, Camera* camera, glm::mat4 matrix, World* world, glm::vec4 fillColor, float fillPercentage, bool depthSorted, bool isIndicator) : RenderJob() { Model = ResourceManager::Load<::Model>("Models/Core/UnitQuad.mesh"); @@ -30,7 +30,7 @@ struct SpriteJob : RenderJob StartIndex = matProp.material->StartIndex; EndIndex = matProp.material->EndIndex; - Matrix = matrix; + Matrix = matrix; Color = cSprite["Color"]; Entity = cSprite.EntityID; Position = Transform::AbsolutePosition(world, cSprite.EntityID); @@ -40,7 +40,7 @@ struct SpriteJob : RenderJob Depth = viewpos.z; } World = world; - + IsIndicator = isIndicator; FillColor = fillColor; FillPercentage = fillPercentage; }; @@ -61,6 +61,8 @@ struct SpriteJob : RenderJob unsigned int EndIndex = 0; World* World; + bool IsIndicator = false; + glm::vec4 FillColor = glm::vec4(0); float FillPercentage = 0.0; diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index 61e49ae3..8a5f51f3 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -42,4 +42,5 @@ + \ No newline at end of file diff --git a/resources/Schema/Components/Indicator.xml b/resources/Schema/Components/Indicator.xml new file mode 100644 index 00000000..cd4e3f46 --- /dev/null +++ b/resources/Schema/Components/Indicator.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/resources/Schema/Components/Indicator.xsd b/resources/Schema/Components/Indicator.xsd new file mode 100644 index 00000000..54a6bfe5 --- /dev/null +++ b/resources/Schema/Components/Indicator.xsd @@ -0,0 +1,11 @@ + + + + + + + + Billbord and makes a Model or Sprite too always appare on players screen + + + \ No newline at end of file diff --git a/resources/Schema/Entities/JohansTestMap.xml b/resources/Schema/Entities/JohansTestMap.xml new file mode 100644 index 00000000..06e97bdc --- /dev/null +++ b/resources/Schema/Entities/JohansTestMap.xml @@ -0,0 +1,5379 @@ + + + + + + + + + + + + + + + + + + Models/Props/Ground.mesh + + + + + + + + + Models/Props/Highground1.mesh + + + + + + + + + + Models/Props/Highground2.mesh + + + + + + + + + + Models/Props/Highground1.mesh + + + + + + + + + + + + Models/Props/Highground2.mesh + + + + + + + + + + + + Models/Props/Highground3.mesh + + + + + + + + + + Models/Props/Highground4.mesh + + + + + + + + + + Models/Props/Highground5.mesh + + + + + + + + + + + Models/Props/Highground6.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallTop.mesh + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall1.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall2.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallSmall3.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall4.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar3Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar3Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall4.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall4.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall4.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall4.mesh + + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/WoodenBridge.mesh + + + + + + + + + + + + + + Models/Props/Bridges/WoodenBridge.mesh + + + + + + + + + + + + + + Models/Props/Bridges/WoodenBridge.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + + Models/Props/Bridges/WoodenBridge.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + + Models/Props/Flora/TreeLog.mesh + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointBlue.mesh + + + + + + + + + + + + + 4 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + + + + + + Textures/Test/aM4ME4GR.png + false + + + + + + + + + + + + Textures/Test/SmallDiff.png + false + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 3 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 2 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 1.5498908015879351 + 1 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointRed.mesh + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + + + + + + Textures/Test/aM4ME4GR.png + false + + + + + + + + + + Textures/Test/SmallDiff.png + false + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + 10 + + + + + + + + + + 10 + + + + + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + 1 + + + + + + + + + + + + + + Schema/Entities/PlayerRed.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 0.10000000149011612 + + + + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 0.10000000149011612 + + + + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 0.10000000149011612 + + + + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 0.10000000149011612 + + + + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 0.10000000149011612 + + + + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 0.10000000149011612 + + + + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 0.10000000149011612 + + + + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 0.10000000149011612 + + + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/TestPlayerIndicator b/resources/Schema/Entities/TestPlayerIndicator new file mode 100644 index 00000000..504fa0db --- /dev/null +++ b/resources/Schema/Entities/TestPlayerIndicator @@ -0,0 +1,590 @@ + + + + + + + + + + 600 + + + + + + + + + 5 + + + + + + + + + + + + + + + + + + + + + + + + Models/Widgets/Camera.mesh + false + + + + + + + + + + + + + + + + + + + Textures/Weapons/Crosshair/SmallThickHoleDot.png + false + + + + + + + + + + + + Schema/Entities/HitMarker.xml + + + + + + + + + + + + + + 1 + + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + 1 + + + + Textures/HealthHUD3.png + + + + + + + + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 2 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 3 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 4 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 1 + + + 0.10332605343919568 + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + Idle + 1.0214894690177836 + 1 + + + Models/Characters/Assault/FirstPerson.mesh + + true + + + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + true + + + + + + + + + + + Schema/Entities/RayBlue.xml + + + + + + + + + + + Schema/Entities/ReloadEffectView.xml + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + + + 32 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + 360 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + + + + Models/Widgets/Camera.mesh + false + + + + + + + + + + + + Idle + 0.33673680560517383 + 1 + + + AimRifle + + + + + Models/Characters/Assault/AssaultAnimations.mesh + + + + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + + + Schema/Entities/RayBlue.xml + + + + + + + + + + + Schema/Entities/ReloadEffectWorld.xml + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + false + + + + + + + + + + + + Models/Core/UnitCube.mesh + + false + + + + + + + + + + + Insert name here + Fonts/DroidSans.ttf,100 + + + + + + + + + + + + + + Textures/Test/aM4ME4GR.png + + + + + + + + + + diff --git a/resources/Schema/Entities/TestPlayerIndicator.xml b/resources/Schema/Entities/TestPlayerIndicator.xml new file mode 100644 index 00000000..56390bcb --- /dev/null +++ b/resources/Schema/Entities/TestPlayerIndicator.xml @@ -0,0 +1,590 @@ + + + + + + + + + + 600 + + + + + + + + + 5 + + + + + + + + + + + + + + + + + + + + + + + + Models/Widgets/Camera.mesh + false + + + + + + + + + + + + + + + + + + + Textures/Weapons/Crosshair/SmallThickHoleDot.png + false + + + + + + + + + + + + Schema/Entities/HitMarker.xml + + + + + + + + + + + + + + 1 + + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + 1 + + + + Textures/HealthHUD3.png + + + + + + + + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 2 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 3 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 4 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 1 + + + 0.10332605343919568 + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + Idle + 0.71065405191594166 + 1 + + + Models/Characters/Assault/FirstPerson.mesh + + true + + + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + true + + + + + + + + + + + Schema/Entities/RayBlue.xml + + + + + + + + + + + Schema/Entities/ReloadEffectView.xml + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + + + 32 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + 360 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + + + + Models/Widgets/Camera.mesh + false + + + + + + + + + + + + Idle + 1.0759003871452997 + 1 + + + AimRifle + + + + + Models/Characters/Assault/AssaultAnimations.mesh + + + + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + + + Schema/Entities/RayBlue.xml + + + + + + + + + + + Schema/Entities/ReloadEffectWorld.xml + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + false + + + + + + + + + + + + Models/Core/UnitCube.mesh + + false + + + + + + + + + + + Insert name here + Fonts/DroidSans.ttf,100 + + + + + + + + + + + + + + Textures/Test/aM4ME4GR.png + + + + + + + + + + diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index 665c4027..cd604b8c 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -67,11 +67,16 @@ void RenderSystem::fillSprites(std::list>& jobs, Worl fillColor = (glm::vec4)fillComponent["Color"]; } - glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, world); - //modelMatrix *= m_Camera->BillboardMatrix(); + glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, world); + bool isIndicator = false; + if (world->HasComponent(entity.ID, "Indicator") || entity.FirstParentWithComponent("Indicator").Valid()) + { + isIndicator = true; + modelMatrix = modelMatrix * m_Camera->BillboardMatrix(); + } - std::shared_ptr spriteJob = std::shared_ptr(new SpriteJob(cSprite, m_Camera, modelMatrix, world, fillColor, fillPercentage, depthSorted)); + std::shared_ptr spriteJob = std::shared_ptr(new SpriteJob(cSprite, m_Camera, modelMatrix, world, fillColor, fillPercentage, depthSorted, isIndicator)); jobs.push_back(spriteJob); } @@ -94,6 +99,30 @@ bool RenderSystem::isEntityVisible(EntityWrapper& entity) return false; } + // If a sprite is an Indicator, it's not local on player and object is in the same team, then dispaly it + if ( + (entity.HasComponent("Indicator")) + && (entity != m_LocalPlayer || !entity.IsChildOf(m_LocalPlayer)) + && (entity.HasComponent("Team") || entity.FirstParentWithComponent("Team").Valid()) + && entity.HasComponent("Sprite") + && m_LocalPlayer.World != nullptr + ) { + EntityWrapper entityTeam; + if (!entity.HasComponent("Team")) { + entityTeam = entity.FirstParentWithComponent("Team"); + } + else { + entityTeam = entity; + } + ComponentWrapper& entityTeamComponent = entityTeam["Team"]; + ComponentWrapper& localComponent = m_LocalPlayer["Team"]; + int entityTeamInt = entityTeamComponent["Team"]; + int localComponentInt = localComponent["Team"]; + int SpectatorInt = localComponent["Team"].Enum("Spectator"); + if (entityTeamInt != localComponentInt && localComponentInt != SpectatorInt) { + return false; + } + } return true; } From e7118ce8e5eecefffd7f70587ed48a0a98561706 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Wed, 17 Feb 2016 10:52:50 +0100 Subject: [PATCH 015/252] WIP --- include/Engine/Rendering/Skeleton.h | 5 +- resources/Schema/Entities/AnimationTests2.xml | 64 ++++++++++++------ src/Engine/Rendering/Skeleton.cpp | 66 +++++++++++-------- 3 files changed, 84 insertions(+), 51 deletions(-) diff --git a/include/Engine/Rendering/Skeleton.h b/include/Engine/Rendering/Skeleton.h index 28a5ef6a..3a7231d6 100644 --- a/include/Engine/Rendering/Skeleton.h +++ b/include/Engine/Rendering/Skeleton.h @@ -108,6 +108,8 @@ public: void AccumulateBoneTransforms(bool noRootMotion, std::vector animations, std::map& frameBones, const Bone* bone, glm::mat4 parentMatrix); void AccumulateBoneTransforms(bool noRootMotion, std::vector animations, AnimationOffset animationOffset, std::map& frameBones, const Bone* bone, glm::mat4 parentMatrix); + glm::mat4 AdditiveBlend(JointFrameTransform addTransform, JointFrameTransform transform); + void PrintSkeleton(); void PrintSkeleton(const Bone* parent, int depthCount); std::map Animations; @@ -118,8 +120,7 @@ public: int GetKeyframe(const Animation& animation, double time); private: - - glm::mat4 GetOffsetTransform(const Bone* bone, AnimationOffset animationOffset); + JointFrameTransform GetOffsetTransform(const Bone* bone, AnimationOffset animationOffset); std::map m_BonesByName; diff --git a/resources/Schema/Entities/AnimationTests2.xml b/resources/Schema/Entities/AnimationTests2.xml index 413c7e67..7ce357f4 100644 --- a/resources/Schema/Entities/AnimationTests2.xml +++ b/resources/Schema/Entities/AnimationTests2.xml @@ -29,25 +29,19 @@ - Run - 0.5 - 0.60188997954429357 - -1 + AimRifle + 0.94417153407339605 1 - 0.5 - 0.96957233017255007 + + 0.032904333143131348 0.093923612201312068 1 - - AimRifle - - Models/Characters/Assault/AssaultAnimations.mesh - + @@ -61,8 +55,8 @@ Models/Weapons/Red/AssaultWeaponRed.mesh - - + + @@ -108,23 +102,52 @@ - ShootFastRifle - 0.056234247235838808 + Idle + 0.17120540274882234 1 - 1 - Idl + 0.10000000149011612 + StrafeRigh 0.5 - 1.8308673495784191 - StrafeRigh + 0.518960175468406 0.5 0.32167823998061529 1 + + AimRifle + Models/Characters/Assault/AssaultAnimations.mesh + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Red/AssaultWeaponRed.mesh + + + + + + + + + + + AimRifle + + + Models/Characters/Assault/AssaultAnimations.mesh + + + + + @@ -135,7 +158,8 @@ Models/Weapons/Red/AssaultWeaponRed.mesh - + + diff --git a/src/Engine/Rendering/Skeleton.cpp b/src/Engine/Rendering/Skeleton.cpp index e390d694..bd994a08 100644 --- a/src/Engine/Rendering/Skeleton.cpp +++ b/src/Engine/Rendering/Skeleton.cpp @@ -274,26 +274,18 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vectorParent) { - if (offset != glm::mat4(1)) { - boneMatrix = parentMatrix * offset;// *((glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix)); - } else { - boneMatrix = parentMatrix *((glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix)); - - } + boneMatrix = parentMatrix * (glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix); boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix; } else { - boneMatrix = offset * glm::inverse(bone->OffsetMatrix); + boneMatrix = glm::inverse(bone->OffsetMatrix); boneMatrices[bone->ID] = parentMatrix; } } else { - glm::vec3 finalPosInterp; - glm::quat finalRotInterp; - glm::vec3 finalScaleInterp; + JointFrameTransform jointFinalTransform; + float totalWeight = 0; for (JointFrameTransform jointTransform : JointTransforms) { @@ -303,26 +295,23 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vectorID] = boneMatrix * bone->OffsetMatrix; } @@ -331,7 +320,20 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vector animations, AnimationOffset animationOffset, glm::mat4 childMatrix) { glm::mat4 boneMatrix; - + /* std::vector JointTransforms; for (const AnimationData animationData : animations) { @@ -569,9 +577,9 @@ glm::mat4 Skeleton::GetBoneTransform(bool noRootMotion, const Bone* bone, std::v if (bone->Parent != nullptr) { return GetBoneTransform(noRootMotion, bone->Parent, animations, animationOffset, boneMatrix); - } else { + } else {*/ return boneMatrix; - } + // } } From db8bc612bd61c1de7f7543fca13ff2abc8f7b4ec Mon Sep 17 00:00:00 2001 From: viktorljung Date: Wed, 17 Feb 2016 14:55:02 +0100 Subject: [PATCH 016/252] AdditiveBlend now working, needs cleanup --- include/Engine/Rendering/Skeleton.h | 8 +- resources/Schema/Entities/AnimationTests2.xml | 64 ++------- src/Engine/Rendering/Skeleton.cpp | 122 ++++++++++-------- 3 files changed, 79 insertions(+), 115 deletions(-) diff --git a/include/Engine/Rendering/Skeleton.h b/include/Engine/Rendering/Skeleton.h index 3a7231d6..3f9331ca 100644 --- a/include/Engine/Rendering/Skeleton.h +++ b/include/Engine/Rendering/Skeleton.h @@ -76,9 +76,9 @@ public: }; struct JointFrameTransform { - glm::vec3 PositionInterp = glm::vec3(0); - glm::quat RotationInterp = glm::quat(); - glm::vec3 ScaleInterp = glm::vec3(0); + glm::vec3 Position = glm::vec3(0); + glm::quat Rotation = glm::quat(); + glm::vec3 Scale = glm::vec3(0); float Weight; }; @@ -108,7 +108,7 @@ public: void AccumulateBoneTransforms(bool noRootMotion, std::vector animations, std::map& frameBones, const Bone* bone, glm::mat4 parentMatrix); void AccumulateBoneTransforms(bool noRootMotion, std::vector animations, AnimationOffset animationOffset, std::map& frameBones, const Bone* bone, glm::mat4 parentMatrix); - glm::mat4 AdditiveBlend(JointFrameTransform addTransform, JointFrameTransform transform); + glm::mat4 AdditiveBlend(glm::mat4 differencePose, glm::mat4 targetPose); void PrintSkeleton(); void PrintSkeleton(const Bone* parent, int depthCount); diff --git a/resources/Schema/Entities/AnimationTests2.xml b/resources/Schema/Entities/AnimationTests2.xml index 7ce357f4..c36c5c02 100644 --- a/resources/Schema/Entities/AnimationTests2.xml +++ b/resources/Schema/Entities/AnimationTests2.xml @@ -29,10 +29,10 @@ - AimRifle - 0.94417153407339605 + Idle + 1.1429797894322036 + 1 1 - 0.032904333143131348 0.093923612201312068 1 @@ -44,24 +44,7 @@ - - - - - R_Arm_Weapon_Joint - - - - Models/Weapons/Red/AssaultWeaponRed.mesh - - - - - - - - - + @@ -103,43 +86,32 @@ Idle - 0.17120540274882234 + 1.1429797894322036 1 0.10000000149011612 StrafeRigh 0.5 - 0.518960175468406 + 0.67154243305829331 0.5 0.32167823998061529 1 AimRifle + Models/Characters/Assault/AssaultAnimations.mesh - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Red/AssaultWeaponRed.mesh - - - - - - + AimRifle + 0.5 Models/Characters/Assault/AssaultAnimations.mesh @@ -148,23 +120,7 @@ - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Red/AssaultWeaponRed.mesh - - - - - - - - - + diff --git a/src/Engine/Rendering/Skeleton.cpp b/src/Engine/Rendering/Skeleton.cpp index bd994a08..0e9483d6 100644 --- a/src/Engine/Rendering/Skeleton.cpp +++ b/src/Engine/Rendering/Skeleton.cpp @@ -127,23 +127,23 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vectorID] = parentMatrix; } } else if (JointTransforms.size() == 1) { - boneMatrix = parentMatrix *(glm::translate(JointTransforms.at(0).PositionInterp) * glm::toMat4(JointTransforms.at(0).RotationInterp) * glm::scale(JointTransforms.at(0).ScaleInterp)); + boneMatrix = parentMatrix *(glm::translate(JointTransforms.at(0).Position) * glm::toMat4(JointTransforms.at(0).Rotation) * glm::scale(JointTransforms.at(0).Scale)); boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix; } else { @@ -178,14 +178,14 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vectorID] = boneMatrix * bone->OffsetMatrix; @@ -321,16 +335,10 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vectorOffsetMatrix) * childMatrix; } } else if (JointTransforms.size() == 1) { - boneMatrix = (glm::translate(JointTransforms.at(0).PositionInterp) * glm::toMat4(JointTransforms.at(0).RotationInterp) * glm::scale(JointTransforms.at(0).ScaleInterp)) * childMatrix; + boneMatrix = (glm::translate(JointTransforms.at(0).Position) * glm::toMat4(JointTransforms.at(0).Rotation) * glm::scale(JointTransforms.at(0).Scale)) * childMatrix; } else { glm::vec3 finalPosInterp; @@ -676,14 +684,14 @@ glm::mat4 Skeleton::GetBoneTransform(bool noRootMotion, const Bone* bone, std::v for (JointFrameTransform jointTransform : JointTransforms) { if (jointTransform.Weight == 1.0f) { - finalPosInterp = jointTransform.PositionInterp; - finalRotInterp = jointTransform.RotationInterp; - finalScaleInterp = jointTransform.ScaleInterp; + finalPosInterp = jointTransform.Position; + finalRotInterp = jointTransform.Rotation; + finalScaleInterp = jointTransform.Scale; break; } else { - finalPosInterp += jointTransform.PositionInterp * (jointTransform.Weight/totalWeight); - finalRotInterp *= glm::slerp(glm::quat(), jointTransform.RotationInterp, (jointTransform.Weight/totalWeight)); - finalScaleInterp += jointTransform.ScaleInterp * (jointTransform.Weight/totalWeight); + finalPosInterp += jointTransform.Position * (jointTransform.Weight/totalWeight); + finalRotInterp *= glm::slerp(glm::quat(), jointTransform.Rotation, (jointTransform.Weight/totalWeight)); + finalScaleInterp += jointTransform.Scale * (jointTransform.Weight/totalWeight); } } From debb1881bf70ee2de8d5bd91a4ad564cd1d9fd47 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Wed, 17 Feb 2016 15:48:45 +0100 Subject: [PATCH 017/252] BoneAttachment working --- include/Engine/Rendering/Skeleton.h | 2 +- resources/Schema/Entities/BlueRifle | 19 ++++++ src/Engine/Rendering/Skeleton.cpp | 101 +++++++++++++--------------- 3 files changed, 68 insertions(+), 54 deletions(-) create mode 100644 resources/Schema/Entities/BlueRifle diff --git a/include/Engine/Rendering/Skeleton.h b/include/Engine/Rendering/Skeleton.h index 3f9331ca..93f62a37 100644 --- a/include/Engine/Rendering/Skeleton.h +++ b/include/Engine/Rendering/Skeleton.h @@ -108,7 +108,7 @@ public: void AccumulateBoneTransforms(bool noRootMotion, std::vector animations, std::map& frameBones, const Bone* bone, glm::mat4 parentMatrix); void AccumulateBoneTransforms(bool noRootMotion, std::vector animations, AnimationOffset animationOffset, std::map& frameBones, const Bone* bone, glm::mat4 parentMatrix); - glm::mat4 AdditiveBlend(glm::mat4 differencePose, glm::mat4 targetPose); + glm::mat4 AdditiveBlend(const Bone* bone, AnimationOffset animationOffset, glm::mat4 targetPose); void PrintSkeleton(); void PrintSkeleton(const Bone* parent, int depthCount); diff --git a/resources/Schema/Entities/BlueRifle b/resources/Schema/Entities/BlueRifle new file mode 100644 index 00000000..194c7739 --- /dev/null +++ b/resources/Schema/Entities/BlueRifle @@ -0,0 +1,19 @@ + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + + diff --git a/src/Engine/Rendering/Skeleton.cpp b/src/Engine/Rendering/Skeleton.cpp index 0e9483d6..4e961a36 100644 --- a/src/Engine/Rendering/Skeleton.cpp +++ b/src/Engine/Rendering/Skeleton.cpp @@ -276,7 +276,11 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vectorParent) { - boneMatrix = parentMatrix * (glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix); + + glm::mat4 jointPose = (glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix); + glm::mat4 boneTransform = AdditiveBlend(bone, animationOffset, jointPose); + + boneMatrix = parentMatrix * boneTransform; boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix; } else { boneMatrix = glm::inverse(bone->OffsetMatrix); @@ -308,22 +312,8 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vectorID] = boneMatrix * bone->OffsetMatrix; @@ -335,10 +325,19 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vector animations, AnimationOffset animationOffset, glm::mat4 childMatrix) { glm::mat4 boneMatrix; - /* + std::vector JointTransforms; for (const AnimationData animationData : animations) { @@ -511,23 +509,23 @@ glm::mat4 Skeleton::GetBoneTransform(bool noRootMotion, const Bone* bone, std::v Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties; Animation::Keyframe::BoneProperty nextBoneProperty = nextFrame.BoneProperties; - jointTransform.PositionInterp = currentBoneProperty.Position * (1.f - progress) + nextBoneProperty.Position * progress; - jointTransform.RotationInterp = glm::slerp(currentBoneProperty.Rotation, nextBoneProperty.Rotation, progress); - jointTransform.ScaleInterp = currentBoneProperty.Scale * (1.f - progress) + nextBoneProperty.Scale * progress; + jointTransform.Position = currentBoneProperty.Position * (1.f - progress) + nextBoneProperty.Position * progress; + jointTransform.Rotation = glm::slerp(currentBoneProperty.Rotation, nextBoneProperty.Rotation, progress); + jointTransform.Scale = currentBoneProperty.Scale * (1.f - progress) + nextBoneProperty.Scale * progress; // Flag for no root motion if (bone == RootBone && noRootMotion) { - jointTransform.PositionInterp.x = 0; - jointTransform.PositionInterp.z = 0; + jointTransform.Position.x = 0; + jointTransform.Position.z = 0; } JointTransforms.push_back(jointTransform); } else { // 1 keyframes for the current bone currentFrame = boneKeyFrames.at(0); - jointTransform.PositionInterp = currentFrame.BoneProperties.Position; - jointTransform.RotationInterp = currentFrame.BoneProperties.Rotation; - jointTransform.ScaleInterp = currentFrame.BoneProperties.Scale; + jointTransform.Position = currentFrame.BoneProperties.Position; + jointTransform.Rotation = currentFrame.BoneProperties.Rotation; + jointTransform.Scale = currentFrame.BoneProperties.Scale; JointTransforms.push_back(jointTransform); } @@ -538,23 +536,20 @@ glm::mat4 Skeleton::GetBoneTransform(bool noRootMotion, const Bone* bone, std::v } - glm::mat4 offset = GetOffsetTransform(bone, animationOffset); - if (JointTransforms.size() == 0) { if (bone->Parent) { - if (offset != glm::mat4(1)) { - boneMatrix = offset * childMatrix;// *((glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix)); - } else { - boneMatrix = ((glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix)) * childMatrix; - } + + glm::mat4 jointPose = (glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix); + glm::mat4 boneTransform = AdditiveBlend(bone, animationOffset, jointPose); + + boneMatrix = boneTransform * childMatrix; } else { - boneMatrix = offset * glm::inverse(bone->OffsetMatrix); + boneMatrix = glm::inverse(bone->OffsetMatrix) * childMatrix; } } else { - glm::vec3 finalPosInterp; - glm::quat finalRotInterp; - glm::vec3 finalScaleInterp; + JointFrameTransform jointFinalTransform; + float totalWeight = 0; for (JointFrameTransform jointTransform : JointTransforms) { @@ -564,30 +559,30 @@ glm::mat4 Skeleton::GetBoneTransform(bool noRootMotion, const Bone* bone, std::v for (JointFrameTransform jointTransform : JointTransforms) { if (jointTransform.Weight == 1.0f) { - finalPosInterp = jointTransform.PositionInterp; - finalRotInterp = jointTransform.RotationInterp; - finalScaleInterp = jointTransform.ScaleInterp; + jointFinalTransform.Position = jointTransform.Position; + jointFinalTransform.Rotation = jointTransform.Rotation; + jointFinalTransform.Scale = jointTransform.Scale; break; } else { - finalPosInterp += jointTransform.PositionInterp * (jointTransform.Weight/totalWeight); - finalRotInterp *= glm::slerp(glm::quat(), jointTransform.RotationInterp, (jointTransform.Weight/totalWeight)); - finalScaleInterp += jointTransform.ScaleInterp * (jointTransform.Weight/totalWeight); + jointFinalTransform.Position += jointTransform.Position * (jointTransform.Weight/totalWeight); + jointFinalTransform.Rotation *= glm::slerp(glm::quat(), jointTransform.Rotation, (jointTransform.Weight/totalWeight)); + jointFinalTransform.Scale += jointTransform.Scale * (jointTransform.Weight/totalWeight); } } - if (offset != glm::mat4(1)) { - boneMatrix = ((glm::translate(finalPosInterp) * glm::toMat4(finalRotInterp) * glm::scale(finalScaleInterp)) + offset) * childMatrix; - } else { - boneMatrix = (glm::translate(finalPosInterp) * glm::toMat4(finalRotInterp) * glm::scale(finalScaleInterp)) * childMatrix; - } + + glm::mat4 jointPose = (glm::translate(jointFinalTransform.Position) * glm::toMat4(jointFinalTransform.Rotation) * glm::scale(jointFinalTransform.Scale)); + glm::mat4 boneTransform = AdditiveBlend(bone, animationOffset, jointPose); + + boneMatrix = boneTransform * childMatrix; } if (bone->Parent != nullptr) { return GetBoneTransform(noRootMotion, bone->Parent, animations, animationOffset, boneMatrix); - } else {*/ + } else { return boneMatrix; - // } + } } From 1c9a1a99044b3825bdbcd3aeb73028873bb6ef25 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Wed, 17 Feb 2016 16:04:44 +0100 Subject: [PATCH 018/252] playerMovementSpeed,playerCrouchSpeed in the player component now also gets AssaultBoosted. --- resources/Schema/Entities/NewMap.xml | 20 ++++++++++---------- src/Game/Systems/HealthSystem.cpp | 4 ++-- src/Game/Systems/PlayerMovementSystem.cpp | 8 +++++++- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/resources/Schema/Entities/NewMap.xml b/resources/Schema/Entities/NewMap.xml index 00dc476f..8fb8d9f4 100644 --- a/resources/Schema/Entities/NewMap.xml +++ b/resources/Schema/Entities/NewMap.xml @@ -5019,7 +5019,7 @@ - + @@ -5089,7 +5089,7 @@ - + @@ -5165,7 +5165,7 @@ - + @@ -5184,7 +5184,7 @@ - + @@ -5203,7 +5203,7 @@ - + @@ -5222,7 +5222,7 @@ - + @@ -5241,7 +5241,7 @@ - + @@ -5260,7 +5260,7 @@ - + @@ -5279,7 +5279,7 @@ - + @@ -5298,7 +5298,7 @@ - + diff --git a/src/Game/Systems/HealthSystem.cpp b/src/Game/Systems/HealthSystem.cpp index 201e4760..b4ea210c 100644 --- a/src/Game/Systems/HealthSystem.cpp +++ b/src/Game/Systems/HealthSystem.cpp @@ -30,8 +30,8 @@ bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e) ComponentWrapper cHealth = e.Victim["Health"]; double& health = cHealth["Health"]; - if (e.Player.HasComponent("BoostDefender")) { - e.Damage -= (double)e.Player["BoostDefender"]["StrengthOfEffect"]; + if (e.Victim.HasComponent("BoostDefender")) { + e.Damage -= (double)e.Victim["BoostDefender"]["StrengthOfEffect"]; } health -= e.Damage; diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 64216e58..e754252d 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -53,6 +53,11 @@ void PlayerMovementSystem::updateMovementControllers(double dt) float playerMovementSpeed = player["Player"]["MovementSpeed"]; float playerCrouchSpeed = player["Player"]["CrouchSpeed"]; glm::vec3& wishDirection = player["Player"]["CurrentWishDirection"]; + if (player.HasComponent("BoostAssault")) { + playerMovementSpeed *= (double)player["BoostAssault"]["StrengthOfEffect"]; + playerCrouchSpeed *= (double)player["BoostAssault"]["StrengthOfEffect"]; + } + if (player.HasComponent("Physics")) { ComponentWrapper cPhysics = player["Physics"]; @@ -104,9 +109,10 @@ void PlayerMovementSystem::updateMovementControllers(double dt) //if doubleTapped do Assault Dash - but only boost maximum 50.0f float doubleTapDashBoost = controller->AssaultDashDoubleTapped() ? 40.0f : 1.0f; accelerationSpeed = glm::min(doubleTapDashBoost*glm::min(accelerationSpeed, addSpeed), 50.0f); + accelerationSpeed = doubleTapDashBoost*glm::min(accelerationSpeed, addSpeed); //if player has Boost from an Assault class, accelerate the player faster if (player.HasComponent("BoostAssault")) { - accelerationSpeed *= (double) player["BoostAssault"]["StrengthOfEffect"]; + accelerationSpeed *= (double)player["BoostAssault"]["StrengthOfEffect"]; } velocity += accelerationSpeed * wishDirection; ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity)); From 56bc1fee3ddf5767bc5af135652fe519894f9df0 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Wed, 17 Feb 2016 16:43:38 +0100 Subject: [PATCH 019/252] Added LifeTimeOfEffect in BoostAssault,BoostDefender components. --- resources/Schema/Components/BoostAssault.xml | 15 ++------------- resources/Schema/Components/BoostAssault.xsd | 3 +++ resources/Schema/Components/BoostDefender.xml | 15 ++------------- resources/Schema/Components/BoostDefender.xsd | 3 +++ src/Game/Systems/PlayerMovementSystem.cpp | 1 - 5 files changed, 10 insertions(+), 27 deletions(-) diff --git a/resources/Schema/Components/BoostAssault.xml b/resources/Schema/Components/BoostAssault.xml index 099d3b0c..20ec953c 100644 --- a/resources/Schema/Components/BoostAssault.xml +++ b/resources/Schema/Components/BoostAssault.xml @@ -1,16 +1,5 @@ - - - - 5 - - - 5 - - - - - - + 2 + 5 diff --git a/resources/Schema/Components/BoostAssault.xsd b/resources/Schema/Components/BoostAssault.xsd index f7d348b7..b965b1fa 100644 --- a/resources/Schema/Components/BoostAssault.xsd +++ b/resources/Schema/Components/BoostAssault.xsd @@ -12,6 +12,9 @@ This is the strength of the boost effect + + How long the effect lasts + diff --git a/resources/Schema/Components/BoostDefender.xml b/resources/Schema/Components/BoostDefender.xml index 489d30cd..c1810544 100644 --- a/resources/Schema/Components/BoostDefender.xml +++ b/resources/Schema/Components/BoostDefender.xml @@ -1,16 +1,5 @@ - - - - 10 - - - 5 - - - - - - + 10 + 5 diff --git a/resources/Schema/Components/BoostDefender.xsd b/resources/Schema/Components/BoostDefender.xsd index 167b41dd..ed59f89c 100644 --- a/resources/Schema/Components/BoostDefender.xsd +++ b/resources/Schema/Components/BoostDefender.xsd @@ -12,6 +12,9 @@ This is the strength of the boost effect + + How long the effect lasts + diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index e754252d..a0289f3d 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -109,7 +109,6 @@ void PlayerMovementSystem::updateMovementControllers(double dt) //if doubleTapped do Assault Dash - but only boost maximum 50.0f float doubleTapDashBoost = controller->AssaultDashDoubleTapped() ? 40.0f : 1.0f; accelerationSpeed = glm::min(doubleTapDashBoost*glm::min(accelerationSpeed, addSpeed), 50.0f); - accelerationSpeed = doubleTapDashBoost*glm::min(accelerationSpeed, addSpeed); //if player has Boost from an Assault class, accelerate the player faster if (player.HasComponent("BoostAssault")) { accelerationSpeed *= (double)player["BoostAssault"]["StrengthOfEffect"]; From 4fd0108443e04cfe04d918f445cd3763fd8f54d6 Mon Sep 17 00:00:00 2001 From: Teejoon Date: Wed, 17 Feb 2016 16:50:24 +0100 Subject: [PATCH 020/252] Working billbording --- resources/Schema/Components/Indicator.xml | 4 + resources/Schema/Components/Indicator.xsd | 14 +- resources/Schema/Entities/JohansTestMap.xml | 90 +-- resources/Schema/Entities/Player.xml | 30 +- resources/Schema/Entities/PlayerRed.xml | 29 +- resources/Schema/Entities/TestPlayerIndicator | 590 ------------------ .../Schema/Entities/TestPlayerIndicator.xml | 590 ------------------ src/Engine/Rendering/RenderSystem.cpp | 53 +- 8 files changed, 121 insertions(+), 1279 deletions(-) delete mode 100644 resources/Schema/Entities/TestPlayerIndicator delete mode 100644 resources/Schema/Entities/TestPlayerIndicator.xml diff --git a/resources/Schema/Components/Indicator.xml b/resources/Schema/Components/Indicator.xml index cd4e3f46..3aab2d1b 100644 --- a/resources/Schema/Components/Indicator.xml +++ b/resources/Schema/Components/Indicator.xml @@ -1,3 +1,7 @@ + 10 + 10 + 1 + 1 \ No newline at end of file diff --git a/resources/Schema/Components/Indicator.xsd b/resources/Schema/Components/Indicator.xsd index 54a6bfe5..69e47821 100644 --- a/resources/Schema/Components/Indicator.xsd +++ b/resources/Schema/Components/Indicator.xsd @@ -5,7 +5,19 @@ - Billbord and makes a Model or Sprite too always appare on players screen + Billbord a Sprite around global Y axis + + + + After this distance between the camera and the sprite, the sprite will not get any smaller on the screen + + + Smaller distance between the camera and the sprite, the sprite will not get any bigger on the screen + + + + + \ No newline at end of file diff --git a/resources/Schema/Entities/JohansTestMap.xml b/resources/Schema/Entities/JohansTestMap.xml index 06e97bdc..c60ea350 100644 --- a/resources/Schema/Entities/JohansTestMap.xml +++ b/resources/Schema/Entities/JohansTestMap.xml @@ -4783,41 +4783,7 @@ - - - - - - - - - - - - - Textures/Test/aM4ME4GR.png - false - - - - - - - - - - - - Textures/Test/SmallDiff.png - false - - - - - - - - + @@ -4952,41 +4918,7 @@ - - - - - - - - - - - - - Textures/Test/aM4ME4GR.png - false - - - - - - - - - - Textures/Test/SmallDiff.png - false - - - - - - - - - - + @@ -5149,7 +5081,7 @@ - Schema/Entities/Player.xml + Schema/Entities/TestPlayerIndicator.xml @@ -5233,7 +5165,7 @@ - + @@ -5252,7 +5184,7 @@ - + @@ -5271,7 +5203,7 @@ - + @@ -5290,7 +5222,7 @@ - + @@ -5309,7 +5241,7 @@ - + @@ -5328,7 +5260,7 @@ - + @@ -5347,7 +5279,7 @@ - + @@ -5366,7 +5298,7 @@ - + diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index be6009ba..64ebbf54 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -349,7 +349,7 @@ Idle - 1.6050530664521858 + 0.30516549779527224 1 @@ -370,8 +370,8 @@ true - - + + @@ -477,7 +477,7 @@ Idle - 1.620305457513453 + 1.9204144556290004 1 @@ -501,8 +501,8 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - + + @@ -572,6 +572,24 @@ + + + + 30 + + + Textures/Icons/Arrow.png + false + + + + + + + + + + diff --git a/resources/Schema/Entities/PlayerRed.xml b/resources/Schema/Entities/PlayerRed.xml index d9839e9f..a6c6d077 100644 --- a/resources/Schema/Entities/PlayerRed.xml +++ b/resources/Schema/Entities/PlayerRed.xml @@ -349,7 +349,7 @@ Idle - 1.6050530664521858 + 0.73262309029003347 1 @@ -370,8 +370,8 @@ true - - + + @@ -477,7 +477,7 @@ Idle - 1.620305457513453 + 0.031207590802594609 1 @@ -501,8 +501,8 @@ Models/Weapons/Red/AssaultWeaponRed.mesh - - + + @@ -572,6 +572,23 @@ + + + + 30 + + + Textures/Icons/Arrow.png + + + + + + + + + + diff --git a/resources/Schema/Entities/TestPlayerIndicator b/resources/Schema/Entities/TestPlayerIndicator deleted file mode 100644 index 504fa0db..00000000 --- a/resources/Schema/Entities/TestPlayerIndicator +++ /dev/null @@ -1,590 +0,0 @@ - - - - - - - - - - 600 - - - - - - - - - 5 - - - - - - - - - - - - - - - - - - - - - - - - Models/Widgets/Camera.mesh - false - - - - - - - - - - - - - - - - - - - Textures/Weapons/Crosshair/SmallThickHoleDot.png - false - - - - - - - - - - - - Schema/Entities/HitMarker.xml - - - - - - - - - - - - - - 1 - - - - - 100/100 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - 1 - - - - Textures/HealthHUD3.png - - - - - - - - - - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - 2 - - - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - 3 - - - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - 4 - - - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - 1 - - - 0.10332605343919568 - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - - - - - - - - - - - - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - - - - Idle - 1.0214894690177836 - 1 - - - Models/Characters/Assault/FirstPerson.mesh - - true - - - - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - true - - - - - - - - - - - Schema/Entities/RayBlue.xml - - - - - - - - - - - Schema/Entities/ReloadEffectView.xml - - - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - - - - - 32 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - 360 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - - - - - - - - - - Models/Widgets/Camera.mesh - false - - - - - - - - - - - - Idle - 0.33673680560517383 - 1 - - - AimRifle - - - - - Models/Characters/Assault/AssaultAnimations.mesh - - - - - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - - - - - - - - - - - Schema/Entities/RayBlue.xml - - - - - - - - - - - Schema/Entities/ReloadEffectWorld.xml - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - false - - - - - - - - - - - - Models/Core/UnitCube.mesh - - false - - - - - - - - - - - Insert name here - Fonts/DroidSans.ttf,100 - - - - - - - - - - - - - - Textures/Test/aM4ME4GR.png - - - - - - - - - - diff --git a/resources/Schema/Entities/TestPlayerIndicator.xml b/resources/Schema/Entities/TestPlayerIndicator.xml deleted file mode 100644 index 56390bcb..00000000 --- a/resources/Schema/Entities/TestPlayerIndicator.xml +++ /dev/null @@ -1,590 +0,0 @@ - - - - - - - - - - 600 - - - - - - - - - 5 - - - - - - - - - - - - - - - - - - - - - - - - Models/Widgets/Camera.mesh - false - - - - - - - - - - - - - - - - - - - Textures/Weapons/Crosshair/SmallThickHoleDot.png - false - - - - - - - - - - - - Schema/Entities/HitMarker.xml - - - - - - - - - - - - - - 1 - - - - - 100/100 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - 1 - - - - Textures/HealthHUD3.png - - - - - - - - - - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - 2 - - - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - 3 - - - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - 4 - - - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - 1 - - - 0.10332605343919568 - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - - - - - - - - - - - - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - - - - Idle - 0.71065405191594166 - 1 - - - Models/Characters/Assault/FirstPerson.mesh - - true - - - - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - true - - - - - - - - - - - Schema/Entities/RayBlue.xml - - - - - - - - - - - Schema/Entities/ReloadEffectView.xml - - - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - - - - - 32 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - 360 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - - - - - - - - - - Models/Widgets/Camera.mesh - false - - - - - - - - - - - - Idle - 1.0759003871452997 - 1 - - - AimRifle - - - - - Models/Characters/Assault/AssaultAnimations.mesh - - - - - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - - - - - - - - - - - Schema/Entities/RayBlue.xml - - - - - - - - - - - Schema/Entities/ReloadEffectWorld.xml - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - false - - - - - - - - - - - - Models/Core/UnitCube.mesh - - false - - - - - - - - - - - Insert name here - Fonts/DroidSans.ttf,100 - - - - - - - - - - - - - - Textures/Test/aM4ME4GR.png - - - - - - - - - - diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index cd604b8c..c05b3681 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -67,13 +67,53 @@ void RenderSystem::fillSprites(std::list>& jobs, Worl fillColor = (glm::vec4)fillComponent["Color"]; } - glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, world); - + glm::mat4 modelMatrix = glm::mat4(1); + bool isIndicator = false; if (world->HasComponent(entity.ID, "Indicator") || entity.FirstParentWithComponent("Indicator").Valid()) { isIndicator = true; - modelMatrix = modelMatrix * m_Camera->BillboardMatrix(); + glm::vec3 pos = Transform::AbsolutePosition(entity); + + + // Code for shcneking if sprite is inside or outside of screen + //glm::vec4 projectedPos = m_Camera->ProjectionMatrix() * m_Camera->ViewMatrix() * glm::vec4(pos, 1.0f); + //projectedPos /= projectedPos.w; + //// Check if inside of outside of screen. + //if (projectedPos.x < -1.0f || projectedPos.x > 1.0f || projectedPos.y < -1.0f || projectedPos.y > 1.0f) { + // // is outside of screen + //} else { + // // is inside of screen + //} + + + glm::vec3 zAxis = glm::vec3(0.0f, 1.0f, 0.0f); + glm::vec3 normal = pos - m_Camera->Position(); + normal.y = 0; + normal = glm::normalize(normal); + glm::vec3 right = glm::cross(normal, zAxis); + glm::vec3 up = glm::cross(right, normal); + + modelMatrix[0][0] = right.x; + modelMatrix[0][1] = right.y; + modelMatrix[0][2] = right.z; + + modelMatrix[1][0] = zAxis.x; + modelMatrix[1][1] = zAxis.y; + modelMatrix[1][2] = zAxis.z; + + modelMatrix[2][0] = normal.x; + modelMatrix[2][1] = normal.y; + modelMatrix[2][2] = normal.z; + + modelMatrix[3][0] = pos.x; + modelMatrix[3][1] = pos.y; + modelMatrix[3][2] = pos.z; + + modelMatrix = modelMatrix * glm::scale(Transform::AbsoluteScale(entity)); + + } else { + modelMatrix = Transform::ModelMatrix(entity.ID, world); } std::shared_ptr spriteJob = std::shared_ptr(new SpriteJob(cSprite, m_Camera, modelMatrix, world, fillColor, fillPercentage, depthSorted, isIndicator)); @@ -101,8 +141,8 @@ bool RenderSystem::isEntityVisible(EntityWrapper& entity) // If a sprite is an Indicator, it's not local on player and object is in the same team, then dispaly it if ( - (entity.HasComponent("Indicator")) - && (entity != m_LocalPlayer || !entity.IsChildOf(m_LocalPlayer)) + entity.HasComponent("Indicator") + && !entity.IsChildOf(m_LocalPlayer) && (entity.HasComponent("Team") || entity.FirstParentWithComponent("Team").Valid()) && entity.HasComponent("Sprite") && m_LocalPlayer.World != nullptr @@ -110,8 +150,7 @@ bool RenderSystem::isEntityVisible(EntityWrapper& entity) EntityWrapper entityTeam; if (!entity.HasComponent("Team")) { entityTeam = entity.FirstParentWithComponent("Team"); - } - else { + } else { entityTeam = entity; } ComponentWrapper& entityTeamComponent = entityTeam["Team"]; From 5e3af7ac5d6eb1ca0883ff5bf891bdb9b0688aee Mon Sep 17 00:00:00 2001 From: Teejoon Date: Wed, 17 Feb 2016 17:58:01 +0100 Subject: [PATCH 021/252] Player Indicator now working OK. Scaling depending on how far away you are makes the Indicator to hide players head behind it. Shields are making indicators to disappear. --- resources/Schema/Components/Indicator.xml | 5 +-- resources/Schema/Components/Indicator.xsd | 7 ----- resources/Schema/Entities/Player.xml | 16 +++++----- resources/Schema/Entities/PlayerRed.xml | 16 +++++----- src/Engine/Rendering/RenderSystem.cpp | 38 ++++++++++++++++++++--- 5 files changed, 51 insertions(+), 31 deletions(-) diff --git a/resources/Schema/Components/Indicator.xml b/resources/Schema/Components/Indicator.xml index 3aab2d1b..1dfc0077 100644 --- a/resources/Schema/Components/Indicator.xml +++ b/resources/Schema/Components/Indicator.xml @@ -1,7 +1,4 @@ - 10 - 10 - 1 - 1 + 10 \ No newline at end of file diff --git a/resources/Schema/Components/Indicator.xsd b/resources/Schema/Components/Indicator.xsd index 69e47821..5015b13c 100644 --- a/resources/Schema/Components/Indicator.xsd +++ b/resources/Schema/Components/Indicator.xsd @@ -9,14 +9,7 @@ - - After this distance between the camera and the sprite, the sprite will not get any smaller on the screen - - - Smaller distance between the camera and the sprite, the sprite will not get any bigger on the screen - - diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 64ebbf54..dfc8855c 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -349,7 +349,7 @@ Idle - 0.30516549779527224 + 1.9902125899398158 1 @@ -370,8 +370,8 @@ true - - + + @@ -477,7 +477,7 @@ Idle - 1.9204144556290004 + 1.7887947062665859 1 @@ -501,8 +501,8 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - + + @@ -575,7 +575,7 @@ - 30 + 80 Textures/Icons/Arrow.png @@ -585,7 +585,7 @@ - + diff --git a/resources/Schema/Entities/PlayerRed.xml b/resources/Schema/Entities/PlayerRed.xml index a6c6d077..fc8dea66 100644 --- a/resources/Schema/Entities/PlayerRed.xml +++ b/resources/Schema/Entities/PlayerRed.xml @@ -349,7 +349,7 @@ Idle - 0.73262309029003347 + 1.5972608217572741 1 @@ -370,8 +370,8 @@ true - - + + @@ -477,7 +477,7 @@ Idle - 0.031207590802594609 + 1.0291785284465931 1 @@ -501,8 +501,8 @@ Models/Weapons/Red/AssaultWeaponRed.mesh - - + + @@ -575,7 +575,7 @@ - 30 + 80 Textures/Icons/Arrow.png @@ -584,7 +584,7 @@ - + diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index c05b3681..a0534fed 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -67,16 +67,26 @@ void RenderSystem::fillSprites(std::list>& jobs, Worl fillColor = (glm::vec4)fillComponent["Color"]; } - glm::mat4 modelMatrix = glm::mat4(1); + glm::mat4 modelMatrix; bool isIndicator = false; if (world->HasComponent(entity.ID, "Indicator") || entity.FirstParentWithComponent("Indicator").Valid()) { + EntityWrapper EntityWithIndicator; + if (world->HasComponent(entity.ID, "Indicator")) { + EntityWithIndicator = entity; + } + else { + EntityWithIndicator = entity.FirstParentWithComponent("Indicator"); + } + auto indicator = EntityWithIndicator["Indicator"]; + + float minScale = (float)(double)indicator["MinScale"]; isIndicator = true; glm::vec3 pos = Transform::AbsolutePosition(entity); - // Code for shcneking if sprite is inside or outside of screen + // Code for check if sprite is inside or outside of screen //glm::vec4 projectedPos = m_Camera->ProjectionMatrix() * m_Camera->ViewMatrix() * glm::vec4(pos, 1.0f); //projectedPos /= projectedPos.w; //// Check if inside of outside of screen. @@ -89,6 +99,13 @@ void RenderSystem::fillSprites(std::list>& jobs, Worl glm::vec3 zAxis = glm::vec3(0.0f, 1.0f, 0.0f); glm::vec3 normal = pos - m_Camera->Position(); + + //float distance = glm::length(normal); + //if (distance < minDistance) { + // pos = pos - glm::normalize(normal) * (distance - minDistance); + //} else if (distance > maxDistance) { + // pos = pos - glm::normalize(normal) * (distance - maxDistance); + //} normal.y = 0; normal = glm::normalize(normal); glm::vec3 right = glm::cross(normal, zAxis); @@ -97,21 +114,34 @@ void RenderSystem::fillSprites(std::list>& jobs, Worl modelMatrix[0][0] = right.x; modelMatrix[0][1] = right.y; modelMatrix[0][2] = right.z; + modelMatrix[0][3] = 0.0f; modelMatrix[1][0] = zAxis.x; modelMatrix[1][1] = zAxis.y; modelMatrix[1][2] = zAxis.z; + modelMatrix[1][3] = 0.0f; modelMatrix[2][0] = normal.x; modelMatrix[2][1] = normal.y; modelMatrix[2][2] = normal.z; + modelMatrix[2][3] = 0.0f; modelMatrix[3][0] = pos.x; modelMatrix[3][1] = pos.y; modelMatrix[3][2] = pos.z; + modelMatrix[3][3] = 1.0f; - modelMatrix = modelMatrix * glm::scale(Transform::AbsoluteScale(entity)); - + glm::mat4 tranformationMatrix = modelMatrix * glm::scale(Transform::AbsoluteScale(entity)); + glm::vec4 tmp = tranformationMatrix * glm::vec4(glm::vec3(0.5, 0.5, 0), 1.0f); + glm::vec2 projectedTopRight = m_Camera->WorldToScreen(glm::vec3(tmp), m_Renderer->GetViewportSize()); + tmp = tranformationMatrix * glm::vec4(glm::vec3(-0.5, -0.5, 0), 1.0f); + glm::vec2 projectedBottomLeft = m_Camera->WorldToScreen(glm::vec3(tmp), m_Renderer->GetViewportSize()); + + float diag = glm::length(projectedBottomLeft - projectedTopRight); + if (diag < minScale) { + tranformationMatrix = tranformationMatrix * glm::scale(glm::vec3(minScale / diag, minScale / diag, minScale / diag)); + } + modelMatrix = tranformationMatrix; } else { modelMatrix = Transform::ModelMatrix(entity.ID, world); } From c4d3c515e4f77d1120b05c833f384cea7724e699 Mon Sep 17 00:00:00 2001 From: Teejoon Date: Wed, 17 Feb 2016 18:04:49 +0100 Subject: [PATCH 022/252] Marge with Master --- resources/Schema/Entities/JohansTestMap.xml | 5311 ------------------- resources/Schema/Entities/Player.xml | 2 +- resources/Schema/Entities/PlayerRed.xml | 2 +- 3 files changed, 2 insertions(+), 5313 deletions(-) delete mode 100644 resources/Schema/Entities/JohansTestMap.xml diff --git a/resources/Schema/Entities/JohansTestMap.xml b/resources/Schema/Entities/JohansTestMap.xml deleted file mode 100644 index c60ea350..00000000 --- a/resources/Schema/Entities/JohansTestMap.xml +++ /dev/null @@ -1,5311 +0,0 @@ - - - - - - - - - - - - - - - - - - Models/Props/Ground.mesh - - - - - - - - - Models/Props/Highground1.mesh - - - - - - - - - - Models/Props/Highground2.mesh - - - - - - - - - - Models/Props/Highground1.mesh - - - - - - - - - - - - Models/Props/Highground2.mesh - - - - - - - - - - - - Models/Props/Highground3.mesh - - - - - - - - - - Models/Props/Highground4.mesh - - - - - - - - - - Models/Props/Highground5.mesh - - - - - - - - - - - Models/Props/Highground6.mesh - - - - - - - - - - Models/Props/Walls/SciFiWallTop.mesh - - - - - - - - - Models/Props/Walls/SciFiWallBig.mesh - - - - - - - - - - Models/Props/Walls/SciFiWallMedium.mesh - - - - - - - - - - Models/Props/Walls/SciFiWallSmall1.mesh - - - - - - - - - - Models/Props/Walls/SciFiWallSmall2.mesh - - - - - - - - - - Models/Props/Walls/SciFiWallBig.mesh - - - - - - - - - - - - Models/Props/Walls/SciFiWallMedium.mesh - - - - - - - - - - - - Models/Props/Walls/SciFiWallSmall3.mesh - - - - - - - - - - Models/Props/Walls/SciFiWallSmall4.mesh - - - - - - - - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar1Blue.mesh - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar1Red.mesh - - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Red.mesh - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar3Blue.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar1Blue.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar1Red.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar3Red.mesh - - - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Red.mesh - - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Red.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Red.mesh - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Red.mesh - - - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Red.mesh - - - - - - - - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall4.mesh - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall4.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall4.mesh - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - Models/Props/Flora/SpecialRoot.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - Models/Props/Walls/SmallWall4.mesh - - - - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - - - - - - - - Models/Props/Bridges/WoodenBridge.mesh - - - - - - - - - - - - - - Models/Props/Bridges/WoodenBridge.mesh - - - - - - - - - - - - - - Models/Props/Bridges/WoodenBridge.mesh - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridge1Red.mesh - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridge1Blue.mesh - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - - - - - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridge1Blue.mesh - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridge1Blue.mesh - - - - - - - - - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridge1Red.mesh - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridge1Red.mesh - - - - - - - - - - - - - Models/Props/Bridges/WoodenBridge.mesh - - - - - - - - - - - - - - - - - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - Models/Core/UnitPlane.mesh - - true - - - - - - - - - - - - - Models/Core/UnitPlane.mesh - - true - - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - - - Models/Props/Flora/TreeLog.mesh - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - - Models/Props/Flora/SpecialRoot.mesh - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - - Models/Props/Flora/SpecialRoot.mesh - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - - Models/Props/Flora/SpecialRoot.mesh - - - - - - - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - - - - - - - - - - Models/Props/CapturePoint/CapturePointBlue.mesh - - - - - - - - - - - - - 4 - - - Models/Core/UnitCylinder.mesh - - true - - - - - - - - - - - - - - - - - - - - - Models/Props/CapturePoint/CapturePointNeutral.mesh - - - - - - - - - - 3 - - - Models/Core/UnitCylinder.mesh - - true - - - - - - - - - - - - - - - - - Models/Props/CapturePoint/CapturePointNeutral.mesh - - - - - - - - - - 2 - - - Models/Core/UnitCylinder.mesh - - true - - - - - - - - - - - - - - - - - Models/Props/CapturePoint/CapturePointNeutral.mesh - - - - - - - - - - 1.5498908015879351 - 1 - - - Models/Core/UnitCylinder.mesh - - true - - - - - - - - - - - - - - - - - Models/Props/CapturePoint/CapturePointRed.mesh - - - - - - - - - - - - - - - Models/Core/UnitCylinder.mesh - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - - - - - - - 10 - - - - - - - - - - 10 - - - - - - - - - - - - - 10 - - - - - - - - - - - 10 - - - - - - - - - - - 10 - - - - - - - - - - - 1 - - - - - - - - - - - - - - Schema/Entities/PlayerRed.xml - - - - - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - - - Schema/Entities/TestPlayerIndicator.xml - - - - - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - - - - - - - - Models/Props/PickUps/HealthPickUp.mesh - - - 0.10000000149011612 - - - - - - - - - - - - - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - 0.10000000149011612 - - - - - - - - - - - - - - - - Models/Props/PickUps/HealthPickUp.mesh - - - 0.10000000149011612 - - - - - - - - - - - - - - - - Models/Props/PickUps/HealthPickUp.mesh - - - 0.10000000149011612 - - - - - - - - - - - - - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - 0.10000000149011612 - - - - - - - - - - - - - - - - Models/Props/PickUps/HealthPickUp.mesh - - - 0.10000000149011612 - - - - - - - - - - - - - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - 0.10000000149011612 - - - - - - - - - - - - - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - 0.10000000149011612 - - - - - - - - - - - - - - - - diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index dfc8855c..4fd70af1 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -575,7 +575,7 @@ - 80 + 60 Textures/Icons/Arrow.png diff --git a/resources/Schema/Entities/PlayerRed.xml b/resources/Schema/Entities/PlayerRed.xml index fc8dea66..c9ac246d 100644 --- a/resources/Schema/Entities/PlayerRed.xml +++ b/resources/Schema/Entities/PlayerRed.xml @@ -575,7 +575,7 @@ - 80 + 60 Textures/Icons/Arrow.png From c3ed429377210709d4ab2664dc26ce6ff7343e5d Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Wed, 17 Feb 2016 18:11:36 +0100 Subject: [PATCH 023/252] Added BoostSystem, Added BoostAssault entity XML --- include/Game/Systems/BoostSystem.h | 25 + resources/Schema/Entities/BoostAssault.xml | 14 + .../Schema/Entities/BoostAssaultTest.xml | 5370 ++++++++++++++++- src/Game/Game.cpp | 2 + src/Game/Systems/BoostSystem.cpp | 60 + .../Systems/Weapon/AssaultWeaponBehaviour.cpp | 10 +- 6 files changed, 5326 insertions(+), 155 deletions(-) create mode 100644 include/Game/Systems/BoostSystem.h create mode 100644 resources/Schema/Entities/BoostAssault.xml create mode 100644 src/Game/Systems/BoostSystem.cpp diff --git a/include/Game/Systems/BoostSystem.h b/include/Game/Systems/BoostSystem.h new file mode 100644 index 00000000..8d87f065 --- /dev/null +++ b/include/Game/Systems/BoostSystem.h @@ -0,0 +1,25 @@ +#ifndef BoostSystem_h__ +#define BoostSystem_h__ + +#include "Core/System.h" +#include "Core/Transform.h" +#include "Core/ResourceManager.h" +#include "Core/EntityFileParser.h" +#include "Core/EPlayerDamage.h" +#include "Common.h" +#include + +#include "Rendering/Util/CommonFunctions.h" + +class BoostSystem : public System +{ +public: + BoostSystem(SystemParams params); + +private: + EventRelay m_EPlayerDamage; + bool OnPlayerDamage(Events::PlayerDamage& e); + + std::string determineClass(EntityWrapper player); +}; +#endif \ No newline at end of file diff --git a/resources/Schema/Entities/BoostAssault.xml b/resources/Schema/Entities/BoostAssault.xml new file mode 100644 index 00000000..727e5363 --- /dev/null +++ b/resources/Schema/Entities/BoostAssault.xml @@ -0,0 +1,14 @@ + + + + + + + 55 + + + + + + + diff --git a/resources/Schema/Entities/BoostAssaultTest.xml b/resources/Schema/Entities/BoostAssaultTest.xml index 97fd3f4d..89dcd0d7 100644 --- a/resources/Schema/Entities/BoostAssaultTest.xml +++ b/resources/Schema/Entities/BoostAssaultTest.xml @@ -6,130 +6,5080 @@ - + - - Models\MapVersion1.mesh - - + + + + + + Models/Props/Ground.mesh + + + + + + + + + Models/Props/Highground1.mesh + + + + + + + + + + Models/Props/Highground2.mesh + + + + + + + + + + Models/Props/Highground1.mesh + + + + + + + + + + + + Models/Props/Highground2.mesh + + + + + + + + + + + + Models/Props/Highground3.mesh + + + + + + + + + + Models/Props/Highground4.mesh + + + + + + + + + + Models/Props/Highground5.mesh + + + + + + + + + + + Models/Props/Highground6.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallTop.mesh + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall1.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall2.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallSmall3.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall4.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar3Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar3Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall4.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall4.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall4.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall4.mesh + + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/WoodenBridge.mesh + + + + + + + + + + + + + + Models/Props/Bridges/WoodenBridge.mesh + + + + + + + + + + + + + + Models/Props/Bridges/WoodenBridge.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + + Models/Props/Bridges/WoodenBridge.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + + Models/Props/Flora/TreeLog.mesh + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + - + - - 2 - - - Models/DirectionalLightWidget.mesh - false - - - - - - + - + + + + + + Models/Props/CapturePoint/CapturePointBlue.mesh + + + + + + + + + + + + + 4 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 3 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 2 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 1.5498908015879351 + 1 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointRed.mesh + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + - + - - 8 - 2.7999999523162842 - - - - + - + + + + + 1 + + + + + + + + + 10 + + + + + + + + + + 10 + + + + + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + 1 + + + + + + + + - - - - 8 - 2.7999999523162842 - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - + + + + + Schema/Entities/PlayerRed.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + - - Models/Core/UnitCube.mesh - false - Schema/Entities/Player.xml @@ -139,100 +5089,218 @@ - + - + - + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + - + + + Models/Characters/Assault/AssaultTPose.mesh + false + - + - + + + + Models/Characters/Assault/AssaultTPose.mesh + false + - + - + + + + Models/Characters/Assault/AssaultTPose.mesh + false + - - - - - - - - - + - + - - - Models/Core/UnitCube.mesh - false - - - Schema/Entities/Player.xml - - - - - - - - - + - - + + + Models/Props/PickUps/HealthPickUp.mesh + + + 0.10000000149011612 + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 0.10000000149011612 + + - + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 0.10000000149011612 + + - + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 0.10000000149011612 + + - + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 0.10000000149011612 + + + + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 0.10000000149011612 + + + + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 0.10000000149011612 + + + + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 0.10000000149011612 + + + + + + + + diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 49b1a963..2cc5d715 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -26,6 +26,7 @@ #include "Network/MultiplayerSnapshotFilter.h" #include "Game/Systems/AmmunitionHUDSystem.h" #include "Game/Systems/KillFeedSystem.h" +#include "Game/Systems/BoostSystem.h" Game::Game(int argc, char* argv[]) @@ -132,6 +133,7 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); + m_SystemPipeline->AddSystem(updateOrderLevel); // Populate Octree with collidables ++updateOrderLevel; m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeCollision, "Collidable"); diff --git a/src/Game/Systems/BoostSystem.cpp b/src/Game/Systems/BoostSystem.cpp new file mode 100644 index 00000000..bdd36d6a --- /dev/null +++ b/src/Game/Systems/BoostSystem.cpp @@ -0,0 +1,60 @@ +#include "Systems/BoostSystem.h" + +BoostSystem::BoostSystem(SystemParams params) + : System(params) +{ + EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &BoostSystem::OnPlayerDamage); +} + +bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e) +{ + if (e.Victim.ID == e.Inflictor.ID) { + return false; + } + if (!e.Victim.Valid() && e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) { + return false; + } + + if (!e.Inflictor.Valid() || !e.Victim.Valid()) { + return false; + } + + auto teamInflictor = m_World->GetComponent(e.Inflictor.ID, "Team"); + auto teamVictim = m_World->GetComponent(e.Victim.ID, "Team"); + if ((int)teamInflictor["Team"] != (int)teamVictim["Team"]) { + return false; + } + + //friendly fire + + auto className = determineClass(e.Inflictor); + if (className == "") { + return false; + } + //"Schema/Entities/BoostAssault.xml" + std::string classXML = "Schema/Entities/" + className + ".xml"; + + //class + + //load & set the BoostAssault Component + auto entityFile = ResourceManager::Load(classXML); + EntityFileParser parser(entityFile); + EntityID boostAssaultEntity = parser.MergeEntities(m_World); + m_World->SetParent(boostAssaultEntity, e.Victim.ID); + + return true; +} + +std::string BoostSystem::determineClass(EntityWrapper player) +{ + if (m_World->HasComponent(player.ID, "DashAbility")) { + return "BoostAssault"; + } + if (m_World->HasComponent(player.ID, "DefenderShield")) { + return "BoostDefender"; + } + if (m_World->HasComponent(player.ID, "SniperSprint")) { + return "BoostSniper"; + } + return ""; +} diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp index 84d3ccd4..4a56ec8c 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -384,10 +384,12 @@ bool AssaultWeaponBehaviour::shoot(double damage) return false; } - // Check for friendly fire - if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)m_Player["Team"]["Team"]) { - return false; - } + + // Do Not Check for friendly fire + //// Check for friendly fire + //if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)m_Player["Team"]["Team"]) { + // return false; + //} // Deal damage! Events::PlayerDamage ePlayerDamage; From 178402e9646b11e3b0a61e189ba082161a228ac1 Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Thu, 18 Feb 2016 10:08:29 +0100 Subject: [PATCH 024/252] cascade shadow wip --- include/Engine/Rendering/ShadowPass.h | 20 +++++- resources/Shaders/ForwardPlus.frag.glsl | 6 +- src/Engine/Editor/EditorRenderSystem.cpp | 2 +- src/Engine/Rendering/RenderSystem.cpp | 2 +- src/Engine/Rendering/ShadowPass.cpp | 91 ++++++++++++++++++++++-- 5 files changed, 108 insertions(+), 13 deletions(-) diff --git a/include/Engine/Rendering/ShadowPass.h b/include/Engine/Rendering/ShadowPass.h index c5bf038e..685432c8 100644 --- a/include/Engine/Rendering/ShadowPass.h +++ b/include/Engine/Rendering/ShadowPass.h @@ -9,11 +9,18 @@ #include "ShadowPassState.h" #include "imgui/imgui.h" +#define MAX_SPLITS 5 + //#include "ShadowPassState.h" // not created yet enum NearFar { Near = 0, Far = 1 }; enum LRBT { Left = 0, Right = 1, Bottom = 2, Top = 3 }; +struct ShadowCamera{ + Camera* camera; + std::array frustumCorners; +}; + class ShadowPass { public: @@ -37,7 +44,10 @@ public: private: - + void CalculateFrustum(RenderScene & scene, std::shared_ptr directionalLightJob); + glm::vec3 LightDirectionToPoint(glm::vec4 direction); + std::array UpdateFrustumPoints(Camera* cam, glm::vec3 center, glm::vec3 view_dir); + void UpdateSplitDist(std::array shadow_cams, float far_distance, float near_distance); EventBroker* m_EventBroker; @@ -52,7 +62,8 @@ private: GLuint m_DepthFBO; GLfloat m_NearFarPlane[2] = { -34.f, 27.f }; - GLfloat m_LRBT[4] = { -77.f, 75.f, -89.f, 89.f }; + //GLfloat m_LRBT[4] = { -77.f, 75.f, -89.f, 89.f }; + GLfloat m_LRBT[4] = { -10.f, 10.f, -10.f, 10.f }; glm::mat4 m_LightProjection; glm::mat4 m_LightView; @@ -62,6 +73,11 @@ private: GLuint resolutionSizeHeigth = 1024 * 8; bool m_ShadowOn = true; + + int m_CurrentNrOfSplits = 3; + float m_SplitWeight = 0.75f; + + std::array shadCams; }; #endif \ No newline at end of file diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 1157a019..205f1c5d 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -228,8 +228,10 @@ void main() totalLighting.Specular += light_result.Specular; } - totalLighting.Diffuse *= (1.5 + vec4(AmbientColor.rgb, 1.0)) - vec4(vec3(shadowFactor), 0.0); - totalLighting.Specular *= (1.5 + vec4(AmbientColor.rgb, 1.0)) - vec4(vec3(shadowFactor), 0.0); + //totalLighting.Diffuse *= (1.5 + vec4(AmbientColor.rgb, 1.0)) - vec4(vec3(shadowFactor), 0.0); + //totalLighting.Specular *= (1.5 + vec4(AmbientColor.rgb, 1.0)) - vec4(vec3(shadowFactor), 0.0); + totalLighting.Diffuse *= (1.0 + vec4(AmbientColor.rgb, 1.0)) + vec4(vec3(shadowFactor, shadowFactor, 0.0), 0.0); + totalLighting.Specular *= (1.0 + vec4(AmbientColor.rgb, 1.0)) + vec4(vec3(shadowFactor, shadowFactor, 0.0), 0.0); //LightResult getInformation; diff --git a/src/Engine/Editor/EditorRenderSystem.cpp b/src/Engine/Editor/EditorRenderSystem.cpp index 4d65e9d3..1a521b88 100644 --- a/src/Engine/Editor/EditorRenderSystem.cpp +++ b/src/Engine/Editor/EditorRenderSystem.cpp @@ -7,7 +7,7 @@ EditorRenderSystem::EditorRenderSystem(World* m_World, EventBroker* eventBroker, { EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &EditorRenderSystem::OnSetCamera); auto resolution = Rectangle::Rectangle(1280, 720); - m_EditorCamera = new Camera((float)resolution.Width / resolution.Height, glm::radians(45.f), 0.01f, 5000.f); + m_EditorCamera = new Camera((float)resolution.Width / resolution.Height, glm::radians(45.f), 0.01f, 500.f); } void EditorRenderSystem::Update(double dt) diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index eaecf99e..03613842 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -10,7 +10,7 @@ RenderSystem::RenderSystem(World* world, EventBroker* eventBroker, const IRender EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &RenderSystem::OnInputCommand); EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &RenderSystem::OnPlayerSpawned); - m_Camera = new Camera((float)m_Renderer->Resolution().Width / m_Renderer->Resolution().Height, glm::radians(45.f), 0.01f, 5000.f); + m_Camera = new Camera((float)m_Renderer->Resolution().Width / m_Renderer->Resolution().Height, glm::radians(45.f), 0.01f, 300.f); } RenderSystem::~RenderSystem() diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index fbf25219..ca7b59f0 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -14,6 +14,86 @@ ShadowPass::~ShadowPass() } +// Compute the 8 corner points of the current view frustum +std::array ShadowPass::UpdateFrustumPoints(Camera* cam, glm::vec3 center, glm::vec3 view_dir) +{ + glm::vec3 up = glm::vec3(0.f, 1.f, 0.f); + glm::vec3 right = glm::normalize(glm::cross(view_dir, up)); + + glm::vec3 farCenter = center + view_dir * cam->FarClip(); + glm::vec3 nearCenter = center + view_dir * cam->NearClip(); + + up = glm::normalize(glm::cross(right, view_dir)); + + float near_height = tan(cam->FOV() / 2.0f) * cam->NearClip(); + float near_width = near_height * cam->AspectRatio(); + float far_height = tan(cam->FOV() / 2.0f) * cam->FarClip(); + float far_width = far_height * cam->AspectRatio(); + + std::array frustumPoints; + frustumPoints[0] = nearCenter - up*near_height - right*near_width; + frustumPoints[1] = nearCenter + up*near_height - right*near_width; + frustumPoints[2] = nearCenter + up*near_height + right*near_width; + frustumPoints[3] = nearCenter - up*near_height + right*near_width; + + frustumPoints[4] = farCenter - up*far_height - right*far_width; + frustumPoints[5] = farCenter + up*far_height - right*far_width; + frustumPoints[6] = farCenter + up*far_height + right*far_width; + frustumPoints[7] = farCenter - up*far_height + right*far_width; + + return frustumPoints; +} + +// UpdateSplitDist computes the near and far distances for every frustum slice +// in camera eye space - that is, at what distance does a slice start and end +void ShadowPass::UpdateSplitDist(std::array shadow_cams, float far_distance, float near_distance) +{ + float lambda = m_SplitWeight; + float ratio = far_distance / near_distance; + + shadow_cams[0].camera->SetNearClip(near_distance); + + for (int i = 1; i < m_CurrentNrOfSplits; i++) { + float si = i / static_cast(m_CurrentNrOfSplits); + + shadow_cams[i].camera->SetNearClip(lambda * (near_distance * powf(ratio, si)) + (1 - lambda) * (near_distance + (far_distance - near_distance) * si)); + shadow_cams[i - 1].camera->SetFarClip(shadow_cams[i].camera->NearClip() * 1.005f); + } + + shadow_cams[m_CurrentNrOfSplits - 1].camera->SetFarClip(far_distance); +} + +float applyCropMatrix() +{ + +} + +// GLM wants a point for glm::lookAt, brute out a point that is on the light direction's tangent. +glm::vec3 ShadowPass::LightDirectionToPoint(glm::vec4 direction) +{ + return -glm::normalize(glm::vec3(direction)); +} + +void ShadowPass::CalculateFrustum(RenderScene & scene, std::shared_ptr directionalLightJob) +{ + //m_LightView = glm::lookAt(LightDirectionToPoint(directionalLightJob->Direction), glm::vec3(0.f, 0.f, 0.f), glm::vec3(0.f, 1.f, 0.f)); + + m_LightProjection = glm::ortho(m_LRBT[Left], m_LRBT[Right], m_LRBT[Bottom], m_LRBT[Top], m_NearFarPlane[Near], m_NearFarPlane[Far]); + + glm::vec3 LightPoint = LightDirectionToPoint(directionalLightJob->Direction); + + float CameraDistance = scene.Camera->FarClip() - scene.Camera->NearClip(); + float CameraPercentiles[3] = { 0.f, CameraDistance * 0.2f, CameraDistance * 0.65f }; + + + glm::vec3 point = scene.Camera->Position() + (scene.Camera->Forward() * 30.f); + + m_LightView = glm::lookAt(LightPoint + point, point, glm::vec3(0.f, 1.f, 0.f)); + + m_LightSpaceMatrix = m_LightProjection * m_LightView; + + //scene.Camera-> +} void ShadowPass::InitializeFrameBuffers() { @@ -29,9 +109,10 @@ void ShadowPass::InitializeFrameBuffers() //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height, 0, GL_RGB, GL_FLOAT, 0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, glm::vec4(1.f).data); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); //glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY); @@ -84,11 +165,7 @@ void ShadowPass::Draw(RenderScene & scene) auto directionalLightJob = std::dynamic_pointer_cast(job); if(directionalLightJob) { - //m_LightProjection = glm::ortho(m_LRBT[Left], m_LRBT[Right], m_LRBT[Bottom], m_LRBT[Top], m_NearFarPlane[Near], m_NearFarPlane[Far]); - m_LightProjection = glm::ortho(m_LRBT[Left], m_LRBT[Right], m_LRBT[Bottom], m_LRBT[Top], m_NearFarPlane[Near], m_NearFarPlane[Far]); - m_LightView = glm::lookAt(-glm::normalize(glm::vec3(directionalLightJob->Direction)), glm::vec3(0.f,0.f,0.f), glm::vec3(0.f,1.f,0.f)); - //m_LightView = glm::lookAt(glm::vec3(-20.0f, 20.0f, -20.0f), glm::vec3(0.0f), glm::vec3(1.0)); - m_LightSpaceMatrix = m_LightProjection * m_LightView; + CalculateFrustum(scene, directionalLightJob); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection)); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView)); From 7f489b3569996ff5c6c369bce6ffb387dd900107 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Thu, 18 Feb 2016 10:40:09 +0100 Subject: [PATCH 025/252] Added Assault,Defender,Sniper Components,Entities. Added ShieldAbility,Sprintability-Component (not implemented). Changed BoostSystem to use a childed Boost to the player. All friendly fire is 0 damage. --- include/Game/Systems/BoostSystem.h | 2 +- resources/Schema/Components.xsd | 3 +++ resources/Schema/Components/BoostAssault.xml | 1 - resources/Schema/Components/BoostAssault.xsd | 3 --- resources/Schema/Components/BoostDefender.xml | 1 - resources/Schema/Components/BoostDefender.xsd | 3 --- resources/Schema/Components/BoostSniper.xml | 4 ++++ resources/Schema/Components/BoostSniper.xsd | 18 +++++++++++++++ resources/Schema/Components/ShieldAbility.xml | 4 ++++ resources/Schema/Components/ShieldAbility.xsd | 18 +++++++++++++++ resources/Schema/Components/SprintAbility.xml | 4 ++++ resources/Schema/Components/SprintAbility.xsd | 18 +++++++++++++++ resources/Schema/Entities/BoostAssault.xml | 2 +- resources/Schema/Entities/BoostDefender.xml | 14 +++++++++++ resources/Schema/Entities/BoostSniper.xml | 14 +++++++++++ src/Game/Systems/BoostSystem.cpp | 23 +++++++++++-------- src/Game/Systems/HealthSystem.cpp | 5 ++-- src/Game/Systems/PlayerMovementSystem.cpp | 11 +++++---- .../Systems/Weapon/AssaultWeaponBehaviour.cpp | 9 ++++---- 19 files changed, 125 insertions(+), 32 deletions(-) create mode 100644 resources/Schema/Components/BoostSniper.xml create mode 100644 resources/Schema/Components/BoostSniper.xsd create mode 100644 resources/Schema/Components/ShieldAbility.xml create mode 100644 resources/Schema/Components/ShieldAbility.xsd create mode 100644 resources/Schema/Components/SprintAbility.xml create mode 100644 resources/Schema/Components/SprintAbility.xsd create mode 100644 resources/Schema/Entities/BoostDefender.xml create mode 100644 resources/Schema/Entities/BoostSniper.xml diff --git a/include/Game/Systems/BoostSystem.h b/include/Game/Systems/BoostSystem.h index 8d87f065..5e9c47da 100644 --- a/include/Game/Systems/BoostSystem.h +++ b/include/Game/Systems/BoostSystem.h @@ -20,6 +20,6 @@ private: EventRelay m_EPlayerDamage; bool OnPlayerDamage(Events::PlayerDamage& e); - std::string determineClass(EntityWrapper player); + std::string DetermineClass(EntityWrapper player); }; #endif \ No newline at end of file diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index f5c65719..c9d8a70e 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -35,9 +35,12 @@ + + + diff --git a/resources/Schema/Components/BoostAssault.xml b/resources/Schema/Components/BoostAssault.xml index 20ec953c..c76fe21e 100644 --- a/resources/Schema/Components/BoostAssault.xml +++ b/resources/Schema/Components/BoostAssault.xml @@ -1,5 +1,4 @@ 2 - 5 diff --git a/resources/Schema/Components/BoostAssault.xsd b/resources/Schema/Components/BoostAssault.xsd index b965b1fa..f7d348b7 100644 --- a/resources/Schema/Components/BoostAssault.xsd +++ b/resources/Schema/Components/BoostAssault.xsd @@ -12,9 +12,6 @@ This is the strength of the boost effect - - How long the effect lasts - diff --git a/resources/Schema/Components/BoostDefender.xml b/resources/Schema/Components/BoostDefender.xml index c1810544..fad0d2b7 100644 --- a/resources/Schema/Components/BoostDefender.xml +++ b/resources/Schema/Components/BoostDefender.xml @@ -1,5 +1,4 @@ 10 - 5 diff --git a/resources/Schema/Components/BoostDefender.xsd b/resources/Schema/Components/BoostDefender.xsd index ed59f89c..167b41dd 100644 --- a/resources/Schema/Components/BoostDefender.xsd +++ b/resources/Schema/Components/BoostDefender.xsd @@ -12,9 +12,6 @@ This is the strength of the boost effect - - How long the effect lasts - diff --git a/resources/Schema/Components/BoostSniper.xml b/resources/Schema/Components/BoostSniper.xml new file mode 100644 index 00000000..844b7c59 --- /dev/null +++ b/resources/Schema/Components/BoostSniper.xml @@ -0,0 +1,4 @@ + + + 10 + diff --git a/resources/Schema/Components/BoostSniper.xsd b/resources/Schema/Components/BoostSniper.xsd new file mode 100644 index 00000000..89778482 --- /dev/null +++ b/resources/Schema/Components/BoostSniper.xsd @@ -0,0 +1,18 @@ + + + + + + + + This is the defender's class boost component + + + + + This is the strength of the boost effect + + + + + diff --git a/resources/Schema/Components/ShieldAbility.xml b/resources/Schema/Components/ShieldAbility.xml new file mode 100644 index 00000000..49fcf0c0 --- /dev/null +++ b/resources/Schema/Components/ShieldAbility.xml @@ -0,0 +1,4 @@ + + + 2.0 + \ No newline at end of file diff --git a/resources/Schema/Components/ShieldAbility.xsd b/resources/Schema/Components/ShieldAbility.xsd new file mode 100644 index 00000000..49c0bae3 --- /dev/null +++ b/resources/Schema/Components/ShieldAbility.xsd @@ -0,0 +1,18 @@ + + + + + + + + A dash component for one of the classes + + + + + This is the cooldown on dash + + + + + \ No newline at end of file diff --git a/resources/Schema/Components/SprintAbility.xml b/resources/Schema/Components/SprintAbility.xml new file mode 100644 index 00000000..2aac99d6 --- /dev/null +++ b/resources/Schema/Components/SprintAbility.xml @@ -0,0 +1,4 @@ + + + 2.0 + \ No newline at end of file diff --git a/resources/Schema/Components/SprintAbility.xsd b/resources/Schema/Components/SprintAbility.xsd new file mode 100644 index 00000000..d8dc5383 --- /dev/null +++ b/resources/Schema/Components/SprintAbility.xsd @@ -0,0 +1,18 @@ + + + + + + + + A dash component for one of the classes + + + + + This is the cooldown on dash + + + + + \ No newline at end of file diff --git a/resources/Schema/Entities/BoostAssault.xml b/resources/Schema/Entities/BoostAssault.xml index 727e5363..9c8e54fd 100644 --- a/resources/Schema/Entities/BoostAssault.xml +++ b/resources/Schema/Entities/BoostAssault.xml @@ -4,7 +4,7 @@ - 55 + 10 diff --git a/resources/Schema/Entities/BoostDefender.xml b/resources/Schema/Entities/BoostDefender.xml new file mode 100644 index 00000000..f22b404e --- /dev/null +++ b/resources/Schema/Entities/BoostDefender.xml @@ -0,0 +1,14 @@ + + + + + + + 10 + + + + + + + diff --git a/resources/Schema/Entities/BoostSniper.xml b/resources/Schema/Entities/BoostSniper.xml new file mode 100644 index 00000000..a82a7a5d --- /dev/null +++ b/resources/Schema/Entities/BoostSniper.xml @@ -0,0 +1,14 @@ + + + + + + + 10 + + + + + + + diff --git a/src/Game/Systems/BoostSystem.cpp b/src/Game/Systems/BoostSystem.cpp index bdd36d6a..fdd5b6dc 100644 --- a/src/Game/Systems/BoostSystem.cpp +++ b/src/Game/Systems/BoostSystem.cpp @@ -25,35 +25,38 @@ bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e) return false; } - //friendly fire - - auto className = determineClass(e.Inflictor); + auto className = DetermineClass(e.Inflictor); if (className == "") { return false; } - //"Schema/Entities/BoostAssault.xml" + //"Schema/Entities/Boost-.xml" std::string classXML = "Schema/Entities/" + className + ".xml"; - //class - + //check if player already has the component + auto playerBoostAssaultEntity = e.Victim.FirstChildByName(className); + if (playerBoostAssaultEntity.Valid()) { + m_World->DeleteEntity(playerBoostAssaultEntity.ID); + } //load & set the BoostAssault Component auto entityFile = ResourceManager::Load(classXML); EntityFileParser parser(entityFile); EntityID boostAssaultEntity = parser.MergeEntities(m_World); + m_World->SetName(boostAssaultEntity, className); m_World->SetParent(boostAssaultEntity, e.Victim.ID); return true; } -std::string BoostSystem::determineClass(EntityWrapper player) +std::string BoostSystem::DetermineClass(EntityWrapper inflictorPlayer) { - if (m_World->HasComponent(player.ID, "DashAbility")) { + //determine the class based on what component the inflictor-player has + if (m_World->HasComponent(inflictorPlayer.ID, "DashAbility")) { return "BoostAssault"; } - if (m_World->HasComponent(player.ID, "DefenderShield")) { + if (m_World->HasComponent(inflictorPlayer.ID, "ShieldAbility")) { return "BoostDefender"; } - if (m_World->HasComponent(player.ID, "SniperSprint")) { + if (m_World->HasComponent(inflictorPlayer.ID, "SprintAbility")) { return "BoostSniper"; } return ""; diff --git a/src/Game/Systems/HealthSystem.cpp b/src/Game/Systems/HealthSystem.cpp index b4ea210c..82836d2c 100644 --- a/src/Game/Systems/HealthSystem.cpp +++ b/src/Game/Systems/HealthSystem.cpp @@ -30,8 +30,9 @@ bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e) ComponentWrapper cHealth = e.Victim["Health"]; double& health = cHealth["Health"]; - if (e.Victim.HasComponent("BoostDefender")) { - e.Damage -= (double)e.Victim["BoostDefender"]["StrengthOfEffect"]; + auto playerBoostDefenderEntity = e.Victim.FirstChildByName("BoostDefender"); + if (playerBoostDefenderEntity.Valid()) { + e.Damage -= (double)playerBoostDefenderEntity["BoostDefender"]["StrengthOfEffect"]; } health -= e.Damage; diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index a0289f3d..cb28c7e6 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -53,9 +53,10 @@ void PlayerMovementSystem::updateMovementControllers(double dt) float playerMovementSpeed = player["Player"]["MovementSpeed"]; float playerCrouchSpeed = player["Player"]["CrouchSpeed"]; glm::vec3& wishDirection = player["Player"]["CurrentWishDirection"]; - if (player.HasComponent("BoostAssault")) { - playerMovementSpeed *= (double)player["BoostAssault"]["StrengthOfEffect"]; - playerCrouchSpeed *= (double)player["BoostAssault"]["StrengthOfEffect"]; + auto playerBoostAssaultEntity = player.FirstChildByName("BoostAssault"); + if (playerBoostAssaultEntity.Valid()) { + playerMovementSpeed *= (double)playerBoostAssaultEntity["BoostAssault"]["StrengthOfEffect"]; + playerCrouchSpeed *= (double)playerBoostAssaultEntity["BoostAssault"]["StrengthOfEffect"]; } @@ -110,8 +111,8 @@ void PlayerMovementSystem::updateMovementControllers(double dt) float doubleTapDashBoost = controller->AssaultDashDoubleTapped() ? 40.0f : 1.0f; accelerationSpeed = glm::min(doubleTapDashBoost*glm::min(accelerationSpeed, addSpeed), 50.0f); //if player has Boost from an Assault class, accelerate the player faster - if (player.HasComponent("BoostAssault")) { - accelerationSpeed *= (double)player["BoostAssault"]["StrengthOfEffect"]; + if (playerBoostAssaultEntity.Valid()) { + accelerationSpeed *= (double)playerBoostAssaultEntity["BoostAssault"]["StrengthOfEffect"]; } velocity += accelerationSpeed * wishDirection; ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity)); diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp index 4a56ec8c..0b981169 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -385,11 +385,10 @@ bool AssaultWeaponBehaviour::shoot(double damage) } - // Do Not Check for friendly fire - //// Check for friendly fire - //if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)m_Player["Team"]["Team"]) { - // return false; - //} + // BoostUpdate: If friendly fire - reduce damage to 0 + if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)m_Player["Team"]["Team"]) { + damage = 0; + } // Deal damage! Events::PlayerDamage ePlayerDamage; From 8c92b7ceb6c389456260f9b6e0767149d10d8a71 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Thu, 18 Feb 2016 13:40:17 +0100 Subject: [PATCH 026/252] Small cleanup. Clarified a few comments --- include/Game/Systems/BoostSystem.h | 4 ---- src/Game/Systems/BoostSystem.cpp | 14 +++++++------- src/Game/Systems/HealthSystem.cpp | 1 + 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/include/Game/Systems/BoostSystem.h b/include/Game/Systems/BoostSystem.h index 5e9c47da..f82707ab 100644 --- a/include/Game/Systems/BoostSystem.h +++ b/include/Game/Systems/BoostSystem.h @@ -2,14 +2,10 @@ #define BoostSystem_h__ #include "Core/System.h" -#include "Core/Transform.h" #include "Core/ResourceManager.h" #include "Core/EntityFileParser.h" #include "Core/EPlayerDamage.h" #include "Common.h" -#include - -#include "Rendering/Util/CommonFunctions.h" class BoostSystem : public System { diff --git a/src/Game/Systems/BoostSystem.cpp b/src/Game/Systems/BoostSystem.cpp index fdd5b6dc..9e4d6968 100644 --- a/src/Game/Systems/BoostSystem.cpp +++ b/src/Game/Systems/BoostSystem.cpp @@ -14,30 +14,30 @@ bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e) if (!e.Victim.Valid() && e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) { return false; } - if (!e.Inflictor.Valid() || !e.Victim.Valid()) { return false; } - auto teamInflictor = m_World->GetComponent(e.Inflictor.ID, "Team"); - auto teamVictim = m_World->GetComponent(e.Victim.ID, "Team"); - if ((int)teamInflictor["Team"] != (int)teamVictim["Team"]) { + //if its not friendly fire, return + if ((int)m_World->GetComponent(e.Inflictor.ID, "Team")["Team"] != (int)m_World->GetComponent(e.Victim.ID, "Team")["Team"]) { return false; } + //determine the inflictors class auto className = DetermineClass(e.Inflictor); if (className == "") { return false; } - //"Schema/Entities/Boost-.xml" + + //get the XML file, example: "Schema/Entities/BoostclassName.xml" std::string classXML = "Schema/Entities/" + className + ".xml"; - //check if player already has the component + //check if player already has a child with the component, if so delete that child auto playerBoostAssaultEntity = e.Victim.FirstChildByName(className); if (playerBoostAssaultEntity.Valid()) { m_World->DeleteEntity(playerBoostAssaultEntity.ID); } - //load & set the BoostAssault Component + //load boost XML file, set it entity parented with the victim player auto entityFile = ResourceManager::Load(classXML); EntityFileParser parser(entityFile); EntityID boostAssaultEntity = parser.MergeEntities(m_World); diff --git a/src/Game/Systems/HealthSystem.cpp b/src/Game/Systems/HealthSystem.cpp index 82836d2c..6e1e276f 100644 --- a/src/Game/Systems/HealthSystem.cpp +++ b/src/Game/Systems/HealthSystem.cpp @@ -30,6 +30,7 @@ bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e) ComponentWrapper cHealth = e.Victim["Health"]; double& health = cHealth["Health"]; + //if player has the boost from a defender, subtract the damage taken by StrengthOfEffect amount auto playerBoostDefenderEntity = e.Victim.FirstChildByName("BoostDefender"); if (playerBoostDefenderEntity.Valid()) { e.Damage -= (double)playerBoostDefenderEntity["BoostDefender"]["StrengthOfEffect"]; From b2304a95f8e9146feb666629e605039973071a48 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Thu, 18 Feb 2016 13:49:22 +0100 Subject: [PATCH 027/252] Fixed some XML documentation --- resources/Schema/Components/BoostSniper.xsd | 2 +- resources/Schema/Components/ShieldAbility.xsd | 4 ++-- resources/Schema/Components/SprintAbility.xsd | 4 ++-- src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/resources/Schema/Components/BoostSniper.xsd b/resources/Schema/Components/BoostSniper.xsd index 89778482..2d62a9da 100644 --- a/resources/Schema/Components/BoostSniper.xsd +++ b/resources/Schema/Components/BoostSniper.xsd @@ -5,7 +5,7 @@ - This is the defender's class boost component + This is the sniper's class boost component diff --git a/resources/Schema/Components/ShieldAbility.xsd b/resources/Schema/Components/ShieldAbility.xsd index 49c0bae3..5cf2145c 100644 --- a/resources/Schema/Components/ShieldAbility.xsd +++ b/resources/Schema/Components/ShieldAbility.xsd @@ -5,12 +5,12 @@ - A dash component for one of the classes + A shield component for one of the classes - This is the cooldown on dash + This is the cooldown on shield diff --git a/resources/Schema/Components/SprintAbility.xsd b/resources/Schema/Components/SprintAbility.xsd index d8dc5383..4207dee2 100644 --- a/resources/Schema/Components/SprintAbility.xsd +++ b/resources/Schema/Components/SprintAbility.xsd @@ -5,12 +5,12 @@ - A dash component for one of the classes + A sprint component for one of the classes - This is the cooldown on dash + This is the cooldown on sprint diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp index 0b981169..7ea6f4f1 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -385,7 +385,7 @@ bool AssaultWeaponBehaviour::shoot(double damage) } - // BoostUpdate: If friendly fire - reduce damage to 0 + // If friendly fire - reduce damage to 0 (needed to make Boosts, Ammosharing work) if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)m_Player["Team"]["Team"]) { damage = 0; } From b81bb9eeead495e600517d9ec5b54d806512a398 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Thu, 18 Feb 2016 15:17:19 +0100 Subject: [PATCH 028/252] Changed SprintAbility to take StrengthOfEffect. PlayerMovementSystem: if Sniper is sprinting he will now move faster. --- include/Engine/Input/FirstPersonInputController.h | 9 +++++++++ resources/Schema/Components/SprintAbility.xml | 2 +- resources/Schema/Components/SprintAbility.xsd | 4 ++-- src/Game/Systems/PlayerMovementSystem.cpp | 12 +++++++++++- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index 7dc24a2c..21833864 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -28,6 +28,7 @@ public: virtual void Reset(); void AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer); + bool SniperSprintingCheck(); virtual bool AssaultDashDoubleTapped() const { return m_AssaultDashDoubleTapped; } virtual bool PlayerIsDashing() const { return m_PlayerIsDashing; } @@ -241,4 +242,12 @@ void FirstPersonInputController::AssaultDashCheck(double dt, bool m_EventBroker->Publish(e); } +template +bool FirstPersonInputController::SniperSprintingCheck() { + if (m_SpecialAbilityKeyDown) { + return true; + } else { + return false; + } +} #endif \ No newline at end of file diff --git a/resources/Schema/Components/SprintAbility.xml b/resources/Schema/Components/SprintAbility.xml index 2aac99d6..5cc59a3a 100644 --- a/resources/Schema/Components/SprintAbility.xml +++ b/resources/Schema/Components/SprintAbility.xml @@ -1,4 +1,4 @@ - 2.0 + 2.0 \ No newline at end of file diff --git a/resources/Schema/Components/SprintAbility.xsd b/resources/Schema/Components/SprintAbility.xsd index 4207dee2..9eabb450 100644 --- a/resources/Schema/Components/SprintAbility.xsd +++ b/resources/Schema/Components/SprintAbility.xsd @@ -9,8 +9,8 @@ - - This is the cooldown on sprint + + This is the strength of the sprint effect diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index cb28c7e6..ee2f9ca3 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -58,7 +58,14 @@ void PlayerMovementSystem::updateMovementControllers(double dt) playerMovementSpeed *= (double)playerBoostAssaultEntity["BoostAssault"]["StrengthOfEffect"]; playerCrouchSpeed *= (double)playerBoostAssaultEntity["BoostAssault"]["StrengthOfEffect"]; } - + bool sniperSprinting = false; + if (player.HasComponent("SprintAbility")) { + if (controller->SniperSprintingCheck()) { + playerMovementSpeed *= (double)player["SprintAbility"]["StrengthOfEffect"]; + playerCrouchSpeed *= (double)player["SprintAbility"]["StrengthOfEffect"]; + sniperSprinting = true; + } + } if (player.HasComponent("Physics")) { ComponentWrapper cPhysics = player["Physics"]; @@ -114,6 +121,9 @@ void PlayerMovementSystem::updateMovementControllers(double dt) if (playerBoostAssaultEntity.Valid()) { accelerationSpeed *= (double)playerBoostAssaultEntity["BoostAssault"]["StrengthOfEffect"]; } + if (sniperSprinting) { + accelerationSpeed *= (double)player["SprintAbility"]["StrengthOfEffect"]; + } velocity += accelerationSpeed * wishDirection; ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity)); } From 3c9c95cff4d132ef43e23886b3455c4f0745bb95 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Thu, 18 Feb 2016 16:34:18 +0100 Subject: [PATCH 029/252] Animation blending improved and Animation Override added --- assets | 2 +- include/Engine/Rendering/ModelJob.h | 9 + include/Engine/Rendering/Skeleton.h | 22 +- resources/Schema/Components/Animation.xml | 6 + resources/Schema/Components/Animation.xsd | 21 ++ resources/Schema/Entities/AnimationTests2.xml | 85 ++++- src/Engine/Rendering/AnimationSystem.cpp | 10 +- src/Engine/Rendering/Renderer.cpp | 1 + src/Engine/Rendering/Skeleton.cpp | 323 ++++++++---------- 9 files changed, 279 insertions(+), 200 deletions(-) diff --git a/assets b/assets index 4d36fdce..1e7adc74 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 4d36fdced7007a594a56b7371bb26861876889aa +Subproject commit 1e7adc749e02144615a20a82c847d3c8df46ee3d diff --git a/include/Engine/Rendering/ModelJob.h b/include/Engine/Rendering/ModelJob.h index ba801f60..773e002e 100644 --- a/include/Engine/Rendering/ModelJob.h +++ b/include/Engine/Rendering/ModelJob.h @@ -133,7 +133,16 @@ struct ModelJob : RenderJob } animationData.time = (double)animationComponent["Time" + std::to_string(i)]; animationData.weight = (double)animationComponent["Weight" + std::to_string(i)]; + + if((int)animationComponent["BlendType" + std::to_string(i)].Enum("Additive") == (int)animationComponent["BlendType" + std::to_string(i)]) { + animationData.blendType = Skeleton::BlendType::Additive; + } else if ((int)animationComponent["BlendType" + std::to_string(i)].Enum("Blend") == (int)animationComponent["BlendType" + std::to_string(i)]) { + animationData.blendType = Skeleton::BlendType::Blend; + } else if ((int)animationComponent["BlendType" + std::to_string(i)].Enum("Override") == (int)animationComponent["BlendType" + std::to_string(i)]) { + animationData.blendType = Skeleton::BlendType::Override; + } + animationData.level = (int)animationComponent["Level" + std::to_string(i)]; Animations.push_back(animationData); } } diff --git a/include/Engine/Rendering/Skeleton.h b/include/Engine/Rendering/Skeleton.h index 93f62a37..f064cc3c 100644 --- a/include/Engine/Rendering/Skeleton.h +++ b/include/Engine/Rendering/Skeleton.h @@ -68,18 +68,26 @@ public: std::map> JointAnimations; }; + enum class BlendType + { + Additive, + Blend, + Override, + }; struct AnimationData { const Animation* animation; + BlendType blendType; float time; + int level; float weight; }; - struct JointFrameTransform { - glm::vec3 Position = glm::vec3(0); - glm::quat Rotation = glm::quat(); - glm::vec3 Scale = glm::vec3(0); - float Weight; + struct JointFramePose { + BlendType Type; + int Level = 0; + glm::mat4 Pose = glm::mat4(0); + float Weight = 0.0f; }; struct AnimationOffset { @@ -119,8 +127,10 @@ public: glm::mat4 GetBoneTransform(bool noRootMotion, const Bone* bone, std::vector animations, glm::mat4 childMatrix); int GetKeyframe(const Animation& animation, double time); + private: - JointFrameTransform GetOffsetTransform(const Bone* bone, AnimationOffset animationOffset); + glm::mat4 GetOffsetTransform(const Bone* bone, AnimationOffset animationOffset); + glm::mat4 GetBonePose(const Bone* bone, const Animation* animation, double time, bool noRootMotion); std::map m_BonesByName; diff --git a/resources/Schema/Components/Animation.xml b/resources/Schema/Components/Animation.xml index ae42009d..6f49edb4 100644 --- a/resources/Schema/Components/Animation.xml +++ b/resources/Schema/Components/Animation.xml @@ -1,16 +1,22 @@ + + 0 1.0 0 0 true + + 0 1.0 0 0 true + + 0 1.0 0 0 diff --git a/resources/Schema/Components/Animation.xsd b/resources/Schema/Components/Animation.xsd index f39aac18..e765f8e8 100644 --- a/resources/Schema/Components/Animation.xsd +++ b/resources/Schema/Components/Animation.xsd @@ -3,20 +3,41 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/AnimationTests2.xml b/resources/Schema/Entities/AnimationTests2.xml index c36c5c02..8cc3f812 100644 --- a/resources/Schema/Entities/AnimationTests2.xml +++ b/resources/Schema/Entities/AnimationTests2.xml @@ -29,11 +29,14 @@ - Idle - 1.1429797894322036 + Run 1 + StrafeRight + 0.5 + 0.98334510030765165 + 0.5 + 0.97153983043137671 1 - 0.032904333143131348 0.093923612201312068 1 @@ -44,7 +47,20 @@ - + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + @@ -75,6 +91,7 @@ Models/Core/UnitPlane.mesh + @@ -85,42 +102,80 @@ - Idle - 1.1429797894322036 + Run 1 - 0.10000000149011612 - StrafeRigh + StrafeRight + 0.5 + 0.98334510030765165 0.5 - 0.67154243305829331 - 0.5 - 0.32167823998061529 + 0.89665639003541542 + 1 + ShootFastRifle + + + + 0.099759525382621339 1 AimRifle - + Models/Characters/Assault/AssaultAnimations.mesh - + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + + AimRifle - 0.5 + 0.5 + Ru + 0.57926159055711501 Models/Characters/Assault/AssaultAnimations.mesh + true - + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Red/AssaultWeaponRed.mesh + true + + + + + + diff --git a/src/Engine/Rendering/AnimationSystem.cpp b/src/Engine/Rendering/AnimationSystem.cpp index 02d72409..e70c4f36 100644 --- a/src/Engine/Rendering/AnimationSystem.cpp +++ b/src/Engine/Rendering/AnimationSystem.cpp @@ -54,13 +54,19 @@ void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& a e.Entity = entity; e.Name = (std::string)animationComponent["AnimationName" + std::to_string(i)]; m_EventBroker->Publish(e); - nextTime -= animation->Duration; + + while(nextTime > animation->Duration) { + nextTime -= animation->Duration; + } } else if (nextTime < 0) { Events::AnimationComplete e; e.Entity = entity; e.Name = (std::string)animationComponent["AnimationName" + std::to_string(i)]; m_EventBroker->Publish(e); - nextTime += animation->Duration; + + while (nextTime < 0) { + nextTime += animation->Duration; + } } } diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index 173ddb2b..85741be4 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -124,6 +124,7 @@ void Renderer::Draw(RenderFrame& frame) } m_DrawBloomPass->Draw(m_DrawFinalPass->BloomTexture()); + if (m_DebugTextureToDraw == 0) { m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture(), m_DrawFinalPass->SceneTextureLowRes(), m_DrawFinalPass->BloomTextureLowRes(), frame.Gamma, frame.Exposure); } diff --git a/src/Engine/Rendering/Skeleton.cpp b/src/Engine/Rendering/Skeleton.cpp index 4e961a36..94656848 100644 --- a/src/Engine/Rendering/Skeleton.cpp +++ b/src/Engine/Rendering/Skeleton.cpp @@ -66,7 +66,7 @@ std::vector Skeleton::GetFrameBones(std::vector animat if (animations.size() <= 0 || animationOffset.animation == nullptr) { std::vector finalMatrices; for (auto& b : Bones) { - finalMatrices.push_back(glm::mat4(1));//b.second->OffsetMatrix); + finalMatrices.push_back(glm::mat4(1)); } return finalMatrices; } @@ -85,14 +85,15 @@ std::vector Skeleton::GetFrameBones(std::vector animat void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vector animations, std::map& boneMatrices, const Bone* bone, glm::mat4 parentMatrix) { glm::mat4 boneMatrix; - std::vector JointTransforms; + + std::vector JointPoses; for (const AnimationData animationData : animations) { const Animation* animation = animationData.animation; const float time = animationData.time; - JointFrameTransform jointTransform; - jointTransform.Weight = animationData.weight;; + JointFramePose jointPose; + jointPose.Weight = animationData.weight;; if (animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) { std::vector boneKeyFrames = animation->JointAnimations.at(bone->ID); @@ -121,31 +122,28 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vector 1.0f || progress < 0.0f) { - LOG_INFO("Progress: %f", progress); progress = glm::clamp(progress, 0.0f, 1.0f); } Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties; Animation::Keyframe::BoneProperty nextBoneProperty = nextFrame.BoneProperties; - jointTransform.Position = currentBoneProperty.Position * (1.f - progress) + nextBoneProperty.Position * progress; - jointTransform.Rotation = glm::slerp(currentBoneProperty.Rotation, nextBoneProperty.Rotation, progress); - jointTransform.Scale = currentBoneProperty.Scale * (1.f - progress) + nextBoneProperty.Scale * progress; + glm::vec3 position = currentBoneProperty.Position * (1.f - progress) + nextBoneProperty.Position * progress; + glm::quat rotation = glm::slerp(currentBoneProperty.Rotation, nextBoneProperty.Rotation, progress); + glm::vec3 scale = currentBoneProperty.Scale * (1.f - progress) + nextBoneProperty.Scale * progress; // Flag for no root motion if (bone == RootBone && noRootMotion) { - jointTransform.Position.x = 0; - jointTransform.Position.z = 0; + position.x = 0; + position.z = 0; } - JointTransforms.push_back(jointTransform); + jointPose.Pose = (glm::translate(position) * glm::toMat4(rotation) * glm::scale(scale)); + JointPoses.push_back(jointPose); } else { // 1 keyframes for the current bone currentFrame = boneKeyFrames.at(0); - jointTransform.Position = currentFrame.BoneProperties.Position; - jointTransform.Rotation = currentFrame.BoneProperties.Rotation; - jointTransform.Scale = currentFrame.BoneProperties.Scale; - JointTransforms.push_back(jointTransform); - + jointPose.Pose = (glm::translate(currentFrame.BoneProperties.Position) * glm::toMat4(currentFrame.BoneProperties.Rotation) * glm::scale(currentFrame.BoneProperties.Scale)); + JointPoses.push_back(jointPose); } } else { // 0 keyframes for the current bone @@ -153,49 +151,41 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vectorParent) { - boneMatrix = parentMatrix * glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix; + + glm::mat4 jointPose = (glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix); + + boneMatrix = parentMatrix * jointPose; boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix; } else { boneMatrix = glm::inverse(bone->OffsetMatrix); boneMatrices[bone->ID] = parentMatrix; } - } else if (JointTransforms.size() == 1) { - boneMatrix = parentMatrix *(glm::translate(JointTransforms.at(0).Position) * glm::toMat4(JointTransforms.at(0).Rotation) * glm::scale(JointTransforms.at(0).Scale)); - boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix; } else { - glm::vec3 finalPosInterp; - glm::quat finalRotInterp; - glm::vec3 finalScaleInterp; float totalWeight = 0; - for (JointFrameTransform jointTransform : JointTransforms) { - totalWeight += jointTransform.Weight; + for (JointFramePose jointFramePose : JointPoses) { + totalWeight += jointFramePose.Weight; } + glm::mat4 finalBlend = glm::mat4(0); - for (JointFrameTransform jointTransform : JointTransforms) { - if (jointTransform.Weight == 1.0f) { - finalPosInterp = jointTransform.Position; - finalRotInterp = jointTransform.Rotation; - finalScaleInterp = jointTransform.Scale; - break; + for (JointFramePose jointFramePose : JointPoses) { + if (jointFramePose.Weight == 1.0f) { + finalBlend = jointFramePose.Pose; } else { - finalPosInterp += jointTransform.Position * (jointTransform.Weight/totalWeight); - finalRotInterp *= glm::slerp(glm::quat(), jointTransform.Rotation, (jointTransform.Weight/totalWeight)); - finalScaleInterp += jointTransform.Scale * (jointTransform.Weight/totalWeight); + finalBlend += jointFramePose.Pose * (jointFramePose.Weight / totalWeight); } - } - boneMatrix = parentMatrix *(glm::translate(finalPosInterp) * glm::toMat4(finalRotInterp) * glm::scale(finalScaleInterp)); + + boneMatrix = parentMatrix * finalBlend; boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix; } - - for (auto &child : bone->Children) { AccumulateBoneTransforms(noRootMotion, animations, boneMatrices, child, boneMatrix); } @@ -204,83 +194,25 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vector animations, AnimationOffset animationOffset, std::map& boneMatrices, const Bone* bone, glm::mat4 parentMatrix) { glm::mat4 boneMatrix; - - std::vector JointTransforms; + std::vector JointPoses; for (const AnimationData animationData : animations) { - const Animation* animation = animationData.animation; - const float time = animationData.time; - - JointFrameTransform jointTransform; - jointTransform.Weight = animationData.weight;; - - if (animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) { - std::vector boneKeyFrames = animation->JointAnimations.at(bone->ID); - - Animation::Keyframe currentFrame; - Animation::Keyframe nextFrame; - - if (boneKeyFrames.size() > 1) { // 2+ keyframes for the current bone - for (int index = boneKeyFrames.size()-1; index >= 0; index--) { // find the bone keyframes that surrounds the current frame - if (time >= boneKeyFrames.at(index).Time) { - currentFrame = boneKeyFrames.at(index); - nextFrame = boneKeyFrames.at((index + 1) % boneKeyFrames.size()); - break; - } - } - - float progress; - - if (nextFrame.Index == 0) { - nextFrame = currentFrame; - progress = (time - currentFrame.Time) / (animation->Duration - currentFrame.Time); - } else { - progress = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time); - - } - - - if (progress > 1.0f || progress < 0.0f) { - LOG_INFO("Progress: %f", progress); - progress = glm::clamp(progress, 0.0f, 1.0f); - } - Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties; - Animation::Keyframe::BoneProperty nextBoneProperty = nextFrame.BoneProperties; - - jointTransform.Position = currentBoneProperty.Position * (1.f - progress) + nextBoneProperty.Position * progress; - jointTransform.Rotation = glm::slerp(currentBoneProperty.Rotation, nextBoneProperty.Rotation, progress); - jointTransform.Scale = currentBoneProperty.Scale * (1.f - progress) + nextBoneProperty.Scale * progress; - - // Flag for no root motion - if (bone == RootBone && noRootMotion) { - jointTransform.Position.x = 0; - jointTransform.Position.z = 0; - } - - JointTransforms.push_back(jointTransform); - - } else { // 1 keyframes for the current bone - currentFrame = boneKeyFrames.at(0); - jointTransform.Position = currentFrame.BoneProperties.Position; - jointTransform.Rotation = currentFrame.BoneProperties.Rotation; - jointTransform.Scale = currentFrame.BoneProperties.Scale; - JointTransforms.push_back(jointTransform); - - } - } else { // 0 keyframes for the current bone - - } - + if (animationData.animation->JointAnimations.find(bone->ID) != animationData.animation->JointAnimations.end()) { // Does the bone have any keyframes in this animation? + JointFramePose jointPose; + jointPose.Weight = animationData.weight; + jointPose.Type = animationData.blendType; + jointPose.Level = animationData.level; + jointPose.Pose = GetBonePose(bone, animationData.animation, animationData.time, noRootMotion); + JointPoses.push_back(jointPose); + } } - if (JointTransforms.size() == 0) { + if (JointPoses.size() == 0) { // No keyframes for the current bone if (bone->Parent) { - glm::mat4 jointPose = (glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix); glm::mat4 boneTransform = AdditiveBlend(bone, animationOffset, jointPose); - - boneMatrix = parentMatrix * boneTransform; + boneMatrix = parentMatrix * boneTransform; boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix; } else { boneMatrix = glm::inverse(bone->OffsetMatrix); @@ -288,33 +220,31 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vector maxLevel ? jointPose.Level : maxLevel; } - for (JointFrameTransform jointTransform : JointTransforms) { - if (jointTransform.Weight == 1.0f) { - jointFinalTransform.Position = jointTransform.Position; - jointFinalTransform.Rotation = jointTransform.Rotation; - jointFinalTransform.Scale = jointTransform.Scale; - break; - } else { - jointFinalTransform.Position += jointTransform.Position * (jointTransform.Weight/totalWeight); - jointFinalTransform.Rotation *= glm::slerp(glm::quat(), jointTransform.Rotation, (jointTransform.Weight/totalWeight)); - jointFinalTransform.Scale += jointTransform.Scale * (jointTransform.Weight/totalWeight); + for (JointFramePose jointPose : JointPoses) { + if (jointPose.Type == BlendType::Override) { + finalOverride += jointPose.Pose * jointPose.Weight; //Blend Overrides then apply to final blend + } else if(jointPose.Type == BlendType::Blend) { + finalBlend += jointPose.Pose * jointPose.Weight; + } else if (jointPose.Type == BlendType::Additive) { + //Soon } - } + if(finalOverride != glm::mat4(0)) { + finalBlend = finalOverride; + } - glm::mat4 jointPose = (glm::translate(jointFinalTransform.Position) * glm::toMat4(jointFinalTransform.Rotation) * glm::scale(jointFinalTransform.Scale)); - glm::mat4 boneTransform = AdditiveBlend(bone, animationOffset, jointPose); - + glm::mat4 boneTransform = AdditiveBlend(bone, animationOffset, finalBlend); boneMatrix = parentMatrix * boneTransform; boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix; } @@ -329,18 +259,14 @@ glm::mat4 Skeleton::AdditiveBlend(const Bone* bone, AnimationOffset animationOff { AnimationOffset refOffset = animationOffset; refOffset.time = 0.5f; // reference pose is at 0.5s for now - JointFrameTransform refOffsetTransform = GetOffsetTransform(bone, refOffset); - JointFrameTransform srcOffsetTransform = GetOffsetTransform(bone, animationOffset); - - glm::mat4 srcPose = (glm::translate(srcOffsetTransform.Position) * glm::toMat4(srcOffsetTransform.Rotation) * glm::scale(srcOffsetTransform.Scale)); - glm::mat4 refPose = (glm::translate(refOffsetTransform.Position) * glm::toMat4(refOffsetTransform.Rotation) * glm::scale(refOffsetTransform.Scale)); - + glm::mat4 refPose = GetOffsetTransform(bone, refOffset); + glm::mat4 srcPose = GetOffsetTransform(bone, animationOffset); glm::mat4 differencePose = srcPose * glm::inverse(refPose); glm::mat4 finalPose = differencePose * targetPose; return finalPose; } -Skeleton::JointFrameTransform Skeleton::GetOffsetTransform(const Bone* bone, AnimationOffset animationOffset) +glm::mat4 Skeleton::GetOffsetTransform(const Bone* bone, AnimationOffset animationOffset) { const Animation* animation = animationOffset.animation; float time = animationOffset.time; @@ -371,7 +297,6 @@ Skeleton::JointFrameTransform Skeleton::GetOffsetTransform(const Bone* bone, Ani progress = (time - currentFrame.Time) / (animation->Duration - currentFrame.Time); } else { progress = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time); - } progress = glm::clamp(progress, 0.0f, 1.0f); @@ -392,13 +317,70 @@ Skeleton::JointFrameTransform Skeleton::GetOffsetTransform(const Bone* bone, Ani } } + return (glm::translate(position) * glm::toMat4(rotation) * glm::scale(scale));; +} - JointFrameTransform jointTransform; - jointTransform.Position = position; - jointTransform.Rotation = rotation; - jointTransform.Scale = scale; - return jointTransform; +glm::mat4 Skeleton::GetBonePose(const Bone* bone, const Animation* animation, double time, bool noRootMotion) +{ + glm::mat4 boneMatrix; + + std::vector JointPoses; + + + if (animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) { + std::vector boneKeyFrames = animation->JointAnimations.at(bone->ID); + + Animation::Keyframe currentFrame; + Animation::Keyframe nextFrame; + + if (boneKeyFrames.size() > 1) { // 2+ keyframes for the current bone + for (int index = boneKeyFrames.size()-1; index >= 0; index--) { // find the bone keyframes that surrounds the current frame + if (time >= boneKeyFrames.at(index).Time) { + currentFrame = boneKeyFrames.at(index); + nextFrame = boneKeyFrames.at((index + 1) % boneKeyFrames.size()); + break; + } + } + + float progress; + + if (nextFrame.Index == 0) { + nextFrame = currentFrame; + progress = (time - currentFrame.Time) / (animation->Duration - currentFrame.Time); + } else { + progress = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time); + + } + + + if (progress > 1.0f || progress < 0.0f) { + progress = glm::clamp(progress, 0.0f, 1.0f); + } + Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties; + Animation::Keyframe::BoneProperty nextBoneProperty = nextFrame.BoneProperties; + + glm::vec3 position = currentBoneProperty.Position * (1.f - progress) + nextBoneProperty.Position * progress; + glm::quat rotation = glm::slerp(currentBoneProperty.Rotation, nextBoneProperty.Rotation, progress); + glm::vec3 scale = currentBoneProperty.Scale * (1.f - progress) + nextBoneProperty.Scale * progress; + + // Flag for no root motion + if (bone == RootBone && noRootMotion) { + position.x = 0; + position.z = 0; + } + + boneMatrix = (glm::translate(position) * glm::toMat4(rotation) * glm::scale(scale)); + + } else { // 1 keyframes for the current bone + currentFrame = boneKeyFrames.at(0); + boneMatrix = (glm::translate(currentFrame.BoneProperties.Position) * glm::toMat4(currentFrame.BoneProperties.Rotation) * glm::scale(currentFrame.BoneProperties.Scale)); + } + } //else { // 0 keyframes for the current bone + + // } + + return boneMatrix; } glm::mat4 Skeleton::GetBoneTransform(const Bone* bone, const Animation* animation, float time, glm::mat4 childMatrix) @@ -467,14 +449,14 @@ glm::mat4 Skeleton::GetBoneTransform(bool noRootMotion, const Bone* bone, std::v { glm::mat4 boneMatrix; - std::vector JointTransforms; + std::vector JointPoses; for (const AnimationData animationData : animations) { const Animation* animation = animationData.animation; const float time = animationData.time; - JointFrameTransform jointTransform; - jointTransform.Weight = animationData.weight;; + JointFramePose jointPose; + jointPose.Weight = animationData.weight;; if (animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) { std::vector boneKeyFrames = animation->JointAnimations.at(bone->ID); @@ -503,31 +485,28 @@ glm::mat4 Skeleton::GetBoneTransform(bool noRootMotion, const Bone* bone, std::v if (progress > 1.0f || progress < 0.0f) { - LOG_INFO("Progress: %f", progress); progress = glm::clamp(progress, 0.0f, 1.0f); } Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties; Animation::Keyframe::BoneProperty nextBoneProperty = nextFrame.BoneProperties; - jointTransform.Position = currentBoneProperty.Position * (1.f - progress) + nextBoneProperty.Position * progress; - jointTransform.Rotation = glm::slerp(currentBoneProperty.Rotation, nextBoneProperty.Rotation, progress); - jointTransform.Scale = currentBoneProperty.Scale * (1.f - progress) + nextBoneProperty.Scale * progress; + glm::vec3 position = currentBoneProperty.Position * (1.f - progress) + nextBoneProperty.Position * progress; + glm::quat rotation = glm::slerp(currentBoneProperty.Rotation, nextBoneProperty.Rotation, progress); + glm::vec3 scale = currentBoneProperty.Scale * (1.f - progress) + nextBoneProperty.Scale * progress; // Flag for no root motion if (bone == RootBone && noRootMotion) { - jointTransform.Position.x = 0; - jointTransform.Position.z = 0; + position.x = 0; + position.z = 0; } - JointTransforms.push_back(jointTransform); + jointPose.Pose = (glm::translate(position) * glm::toMat4(rotation) * glm::scale(scale)); + JointPoses.push_back(jointPose); } else { // 1 keyframes for the current bone currentFrame = boneKeyFrames.at(0); - jointTransform.Position = currentFrame.BoneProperties.Position; - jointTransform.Rotation = currentFrame.BoneProperties.Rotation; - jointTransform.Scale = currentFrame.BoneProperties.Scale; - JointTransforms.push_back(jointTransform); - + jointPose.Pose = (glm::translate(currentFrame.BoneProperties.Position) * glm::toMat4(currentFrame.BoneProperties.Rotation) * glm::scale(currentFrame.BoneProperties.Scale)); + JointPoses.push_back(jointPose); } } else { // 0 keyframes for the current bone @@ -536,7 +515,7 @@ glm::mat4 Skeleton::GetBoneTransform(bool noRootMotion, const Bone* bone, std::v } - if (JointTransforms.size() == 0) { + if (JointPoses.size() == 0) { if (bone->Parent) { glm::mat4 jointPose = (glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix); @@ -548,33 +527,24 @@ glm::mat4 Skeleton::GetBoneTransform(bool noRootMotion, const Bone* bone, std::v } } else { - JointFrameTransform jointFinalTransform; - float totalWeight = 0; - for (JointFrameTransform jointTransform : JointTransforms) { - totalWeight += jointTransform.Weight; + for (JointFramePose jointFramePose : JointPoses) { + totalWeight += jointFramePose.Weight; } + glm::mat4 finalBlend = glm::mat4(0); - for (JointFrameTransform jointTransform : JointTransforms) { - if (jointTransform.Weight == 1.0f) { - jointFinalTransform.Position = jointTransform.Position; - jointFinalTransform.Rotation = jointTransform.Rotation; - jointFinalTransform.Scale = jointTransform.Scale; - break; + for (JointFramePose jointFramePose : JointPoses) { + if (jointFramePose.Weight == 1.0f) { + finalBlend = jointFramePose.Pose; } else { - jointFinalTransform.Position += jointTransform.Position * (jointTransform.Weight/totalWeight); - jointFinalTransform.Rotation *= glm::slerp(glm::quat(), jointTransform.Rotation, (jointTransform.Weight/totalWeight)); - jointFinalTransform.Scale += jointTransform.Scale * (jointTransform.Weight/totalWeight); + finalBlend += jointFramePose.Pose * (jointFramePose.Weight / totalWeight); } - } - glm::mat4 jointPose = (glm::translate(jointFinalTransform.Position) * glm::toMat4(jointFinalTransform.Rotation) * glm::scale(jointFinalTransform.Scale)); - glm::mat4 boneTransform = AdditiveBlend(bone, animationOffset, jointPose); - + glm::mat4 boneTransform = AdditiveBlend(bone, animationOffset, finalBlend); boneMatrix = boneTransform * childMatrix; } @@ -589,7 +559,7 @@ glm::mat4 Skeleton::GetBoneTransform(bool noRootMotion, const Bone* bone, std::v glm::mat4 Skeleton::GetBoneTransform(bool noRootMotion, const Bone* bone, std::vector animations, glm::mat4 childMatrix) { glm::mat4 boneMatrix; - std::vector JointTransforms; + /* std::vector JointTransforms; for (const AnimationData animationData : animations) { const Animation* animation = animationData.animation; @@ -625,7 +595,6 @@ glm::mat4 Skeleton::GetBoneTransform(bool noRootMotion, const Bone* bone, std::v if (progress > 1.0f || progress < 0.0f) { - LOG_INFO("Progress: %f", progress); progress = glm::clamp(progress, 0.0f, 1.0f); } Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties; @@ -688,18 +657,20 @@ glm::mat4 Skeleton::GetBoneTransform(bool noRootMotion, const Bone* bone, std::v finalRotInterp *= glm::slerp(glm::quat(), jointTransform.Rotation, (jointTransform.Weight/totalWeight)); finalScaleInterp += jointTransform.Scale * (jointTransform.Weight/totalWeight); } + } boneMatrix = (glm::translate(finalPosInterp) * glm::toMat4(finalRotInterp) * glm::scale(finalScaleInterp)) * childMatrix; } - if (bone->Parent != nullptr) { return GetBoneTransform(noRootMotion, bone->Parent, animations, boneMatrix); } else { return boneMatrix; - } + }*/ + +return boneMatrix; } int Skeleton::GetBoneID(std::string name) From bf376f54b627973f7950ae968336ce43273fc34b Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Thu, 18 Feb 2016 20:48:39 +0100 Subject: [PATCH 030/252] WIP I think this is now finding the different segments of the cascade --- include/Engine/Rendering/ShadowPass.h | 21 +- resources/Shaders/ForwardPlus.frag.glsl | 4 +- src/Engine/Editor/EditorSystem.cpp | 4 +- src/Engine/Rendering/ShadowPass.cpp | 311 ++++++++++++++++-------- 4 files changed, 230 insertions(+), 110 deletions(-) diff --git a/include/Engine/Rendering/ShadowPass.h b/include/Engine/Rendering/ShadowPass.h index 685432c8..306ae8e0 100644 --- a/include/Engine/Rendering/ShadowPass.h +++ b/include/Engine/Rendering/ShadowPass.h @@ -33,9 +33,7 @@ public: void ClearBuffer(); void Draw(RenderScene& scene); - - - GLuint DepthMap() const { return m_DepthMap; } + GLuint DepthMap() const { return m_DepthMap[m_ShadowLevel]; } glm::mat4 lightSpaceMatrix() const { return m_LightSpaceMatrix; } glm::mat4 lightP() const { return m_LightProjection; } glm::mat4 lightV() const { return m_LightView; } @@ -44,18 +42,20 @@ public: private: - void CalculateFrustum(RenderScene & scene, std::shared_ptr directionalLightJob); + glm::mat4 CalculateFrustum(RenderScene & scene, std::shared_ptr directionalLightJob, glm::mat4& p, glm::mat4& v, ShadowCamera shad_cam); glm::vec3 LightDirectionToPoint(glm::vec4 direction); std::array UpdateFrustumPoints(Camera* cam, glm::vec3 center, glm::vec3 view_dir); void UpdateSplitDist(std::array shadow_cams, float far_distance, float near_distance); + void InitializeLightCameras(); + glm::mat4 ApplyCropMatrix(ShadowCamera& shadow_cam, glm::mat4 m, glm::mat4 v); + glm::mat4 FindNewFrustum(ShadowCamera shadow_cam); EventBroker* m_EventBroker; const IRenderer* m_Renderer; - GLuint m_DepthMap; - - FrameBuffer m_DepthBuffer; + std::array m_DepthMap; + std::array m_DepthBuffer; ShaderProgram* m_ShadowProgram; @@ -69,15 +69,16 @@ private: glm::mat4 m_LightView; glm::mat4 m_LightSpaceMatrix; - GLuint resolutionSizeWidth = 1024 * 8; - GLuint resolutionSizeHeigth = 1024 * 8; + GLuint resolutionSizeWidth = 1024 * 2; + GLuint resolutionSizeHeigth = 1024 * 2; bool m_ShadowOn = true; + int m_ShadowLevel = 0; int m_CurrentNrOfSplits = 3; float m_SplitWeight = 0.75f; - std::array shadCams; + std::array m_shadCams; }; #endif \ No newline at end of file diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 205f1c5d..1f3ba711 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -143,9 +143,9 @@ float random(vec3 seed, int i) float CalcShadowValue(vec4 positionLightSpace, vec3 normal, vec3 lightDir, sampler2DShadow depthTexture) { - float bias = 0.005; + //float bias = 0.005; //float bias = max(0.05 * (1.0 - dot(normal, lightDir)), 0.005); - //float bias = 0.005 * tan(acos(clamp(dot(normal, -lightDir), 0.0, 1.0))); + float bias = 0.005 * tan(acos(clamp(dot(normal, -lightDir), 0.0, 1.0))); vec3 projCoords = vec3(positionLightSpace.xy, positionLightSpace.z + bias) / positionLightSpace.w; projCoords = projCoords * 0.5 + 0.5; diff --git a/src/Engine/Editor/EditorSystem.cpp b/src/Engine/Editor/EditorSystem.cpp index ccbc1b48..96b48874 100644 --- a/src/Engine/Editor/EditorSystem.cpp +++ b/src/Engine/Editor/EditorSystem.cpp @@ -17,7 +17,9 @@ EditorSystem::EditorSystem(World* world, EventBroker* eventBroker, IRenderer* re m_EditorCamera = importEntity(EntityWrapper(m_EditorWorld, EntityID_Invalid), "Schema/Entities/Empty.xml"); m_ActualCamera = m_EditorCamera; m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Transform"); - m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Camera"); + auto cCamera = m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Camera"); + (double&)cCamera["FarClip"] = 30.0; + m_EditorCameraInputController = new EditorCameraInputController(m_EventBroker, -1); m_EditorGUI = new EditorGUI(m_World, m_EventBroker); diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index ca7b59f0..7be01b5b 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -11,7 +11,7 @@ ShadowPass::ShadowPass(IRenderer * renderer) ShadowPass::~ShadowPass() { - + // m_shadCams } // Compute the 8 corner points of the current view frustum @@ -25,28 +25,28 @@ std::array ShadowPass::UpdateFrustumPoints(Camera* cam, glm::vec3 up = glm::normalize(glm::cross(right, view_dir)); - float near_height = tan(cam->FOV() / 2.0f) * cam->NearClip(); + float near_height = tan(cam->FOV() / 2.f) * cam->NearClip(); float near_width = near_height * cam->AspectRatio(); - float far_height = tan(cam->FOV() / 2.0f) * cam->FarClip(); + float far_height = tan(cam->FOV() / 2.f) * cam->FarClip(); float far_width = far_height * cam->AspectRatio(); std::array frustumPoints; - frustumPoints[0] = nearCenter - up*near_height - right*near_width; - frustumPoints[1] = nearCenter + up*near_height - right*near_width; - frustumPoints[2] = nearCenter + up*near_height + right*near_width; - frustumPoints[3] = nearCenter - up*near_height + right*near_width; - - frustumPoints[4] = farCenter - up*far_height - right*far_width; - frustumPoints[5] = farCenter + up*far_height - right*far_width; - frustumPoints[6] = farCenter + up*far_height + right*far_width; - frustumPoints[7] = farCenter - up*far_height + right*far_width; + frustumPoints[0] = nearCenter - up * near_height - right * near_width; + frustumPoints[1] = nearCenter + up * near_height - right * near_width; + frustumPoints[2] = nearCenter + up * near_height + right * near_width; + frustumPoints[3] = nearCenter - up * near_height + right * near_width; + + frustumPoints[4] = farCenter - up * far_height - right * far_width; + frustumPoints[5] = farCenter + up * far_height - right * far_width; + frustumPoints[6] = farCenter + up * far_height + right * far_width; + frustumPoints[7] = farCenter - up * far_height + right * far_width; return frustumPoints; } // UpdateSplitDist computes the near and far distances for every frustum slice // in camera eye space - that is, at what distance does a slice start and end -void ShadowPass::UpdateSplitDist(std::array shadow_cams, float far_distance, float near_distance) +void ShadowPass::UpdateSplitDist(std::array shadow_cams, float near_distance, float far_distance) { float lambda = m_SplitWeight; float ratio = far_distance / near_distance; @@ -63,66 +63,165 @@ void ShadowPass::UpdateSplitDist(std::array shadow_cam shadow_cams[m_CurrentNrOfSplits - 1].camera->SetFarClip(far_distance); } -float applyCropMatrix() +glm::mat4 ShadowPass::FindNewFrustum(ShadowCamera shadow_cam) { + float maxX = -1000.0f; + float maxY = -1000.0f; + float maxZ; + float minX = 1000.0f; + float minY = 1000.0f; + float minZ; + glm::vec4 transf = glm::vec4(shadow_cam.frustumCorners[0], 1.f); + + //if (transf.x > maxX) maxX = transf.x; + //if (transf.x < minX) minX = transf.x; + //if (transf.y > maxY) maxY = transf.y; + //if (transf.y < minY) minY = transf.y; + + for (int i = 0; i < 8; i++) + { + transf = glm::vec4(shadow_cam.frustumCorners[i], 1.f); + + transf.x /= transf.w; + transf.y /= transf.w; + + if (transf.x > maxX) maxX = transf.x; + if (transf.x < minX) minX = transf.x; + if (transf.y > maxY) maxY = transf.y; + if (transf.y < minY) minY = transf.y; + } + + glm::mat4 p = glm::ortho(minX, maxX, minY, maxY, m_NearFarPlane[Near], m_NearFarPlane[Far]); + + return p; } -// GLM wants a point for glm::lookAt, brute out a point that is on the light direction's tangent. -glm::vec3 ShadowPass::LightDirectionToPoint(glm::vec4 direction) +glm::mat4 ShadowPass::ApplyCropMatrix(ShadowCamera& shadow_cam, glm::mat4 m, glm::mat4 v) { - return -glm::normalize(glm::vec3(direction)); + glm::mat4 shad_modelview; + glm::mat4 shad_proj; + glm::mat4 shad_crop; + glm::mat4 shad_mvp; + float maxX = -1000.0f; + float maxY = -1000.0f; + float maxZ; + float minX = 1000.0f; + float minY = 1000.0f; + float minZ; + + glm::mat4 nv_mvp; + glm::vec4 transf; + + shad_modelview = m * v; + nv_mvp = shad_modelview; + + transf = nv_mvp * glm::vec4(shadow_cam.frustumCorners[0], 1.f); + minZ = transf.z; + maxZ = transf.z; + + for (int i = 1; i < 8; i++) { + transf = nv_mvp * glm::vec4(shadow_cam.frustumCorners[i], 1.f); + if (transf.z > maxZ) { + maxZ = transf.z; + } + if (transf.z < minZ) { + minZ = transf.z; + } + } + + // make sure all relevant shadow casters are included here + + shad_proj = glm::ortho(-1.f, 1.f, -1.f, 1.f, m_NearFarPlane[0], m_NearFarPlane[1]); + + //return shad_proj; + + shad_mvp = shad_proj * shad_modelview; + + nv_mvp = shad_mvp; + + for (int i = 0; i < 8; i++) + { + transf = nv_mvp * glm::vec4(shadow_cam.frustumCorners[i], 1.0f); + + transf.x /= transf.w; + transf.y /= transf.w; + + if (transf.x > maxX) maxX = transf.x; + if (transf.x < minX) minX = transf.x; + if (transf.y > maxY) maxY = transf.y; + if (transf.y < minY) minY = transf.y; + } + + float scaleX = 2.0f / (maxX - minX); + float scaleY = 2.0f / (maxY - minY); + float offsetX = -0.5f*(maxX + minX)*scaleX; + float offsetY = -0.5f*(maxY + minY)*scaleY; + + nv_mvp = glm::mat4(); + nv_mvp[0][0] = scaleX; + nv_mvp[1][1] = scaleY; + nv_mvp[0][3] = offsetX; + nv_mvp[1][3] = offsetY; + glm::transpose(nv_mvp); + + shad_crop = nv_mvp; + shad_crop *= shad_proj; + + //return nv_mvp; + //return shad_crop; + return glm::mat4(); } -void ShadowPass::CalculateFrustum(RenderScene & scene, std::shared_ptr directionalLightJob) +void MakeShadowMap(glm::mat4 m, glm::mat4 v, glm::mat4 p, glm::vec3 light_dir) { - //m_LightView = glm::lookAt(LightDirectionToPoint(directionalLightJob->Direction), glm::vec3(0.f, 0.f, 0.f), glm::vec3(0.f, 1.f, 0.f)); + //float shad_modelview[16]; - m_LightProjection = glm::ortho(m_LRBT[Left], m_LRBT[Right], m_LRBT[Bottom], m_LRBT[Top], m_NearFarPlane[Near], m_NearFarPlane[Far]); - - glm::vec3 LightPoint = LightDirectionToPoint(directionalLightJob->Direction); + glDisable(GL_TEXTURE_2D); - float CameraDistance = scene.Camera->FarClip() - scene.Camera->NearClip(); - float CameraPercentiles[3] = { 0.f, CameraDistance * 0.2f, CameraDistance * 0.65f }; + glm::mat4 viewMatrix = glm::lookAt(glm::vec3(0.f), light_dir, glm::vec3(-1.f, 0.f, 0.f)); - - glm::vec3 point = scene.Camera->Position() + (scene.Camera->Forward() * 30.f); - - m_LightView = glm::lookAt(LightPoint + point, point, glm::vec3(0.f, 1.f, 0.f)); - m_LightSpaceMatrix = m_LightProjection * m_LightView; - //scene.Camera-> + + + + + + + glEnable(GL_TEXTURE_2D); +} + +glm::mat4 ShadowPass::CalculateFrustum(RenderScene & scene, std::shared_ptr directionalLightJob, glm::mat4& p, glm::mat4& v, ShadowCamera shad_cam) +{ + p = glm::ortho(m_LRBT[Left], m_LRBT[Right], m_LRBT[Bottom], m_LRBT[Top], m_NearFarPlane[Near], m_NearFarPlane[Far]); + v = glm::lookAt(glm::vec3(0.f) + shad_cam.camera->Position(), glm::vec3(directionalLightJob->Direction) + shad_cam.camera->Position(), glm::vec3(-1.f, 0.f, 0.f)); + + return p * v; } void ShadowPass::InitializeFrameBuffers() { - -// glGenRenderbuffers(1, &m_DepthFBO); -// glBindRenderbuffer(GL_RENDERBUFFER, m_DepthFBO); -// glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); - // Depth texture - glGenTextures(1, &m_DepthMap); - glBindTexture(GL_TEXTURE_2D, m_DepthMap); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, resolutionSizeWidth, resolutionSizeHeigth, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); - //glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height, 0, GL_RGB, GL_FLOAT, 0); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); - glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, glm::vec4(1.f).data); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); - //glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY); + glGenTextures(m_CurrentNrOfSplits, m_DepthMap.data()); + for (int i = 0; i < m_CurrentNrOfSplits; i++) { + glBindTexture(GL_TEXTURE_2D, m_DepthMap[i]); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, resolutionSizeWidth / (1 + i), resolutionSizeHeigth + (1 + i), 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); + glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, glm::vec4(1.f).data); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); + //glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY); - m_DepthBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthMap, GL_DEPTH_ATTACHMENT))); - //m_DepthBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthMap, GL_COLOR_ATTACHMENT0))); - m_DepthBuffer.Generate(); + m_DepthBuffer[i].AddResource(std::shared_ptr(new Texture2D(&m_DepthMap[i], GL_DEPTH_ATTACHMENT))); + m_DepthBuffer[i].Generate(); + } GLERROR("depthMap failed"); - } void ShadowPass::InitializeShaderPrograms() @@ -135,74 +234,92 @@ void ShadowPass::InitializeShaderPrograms() m_ShadowProgram->Link(); } +void ShadowPass::InitializeLightCameras() +{ + //for (int i = 0; i < MAX_SPLITS; i++) { + // m_shadCams[i].camera = new Camera(1.f, ); + // Camera. + //} +} + void ShadowPass::ClearBuffer() { - m_DepthBuffer.Bind(); - glClearColor(0.f, 0.f, 0.f, 0.f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - m_DepthBuffer.Unbind(); + for (int i = 0; i < m_CurrentNrOfSplits; i++) { + m_DepthBuffer[i].Bind(); + glClearColor(0.f, 0.f, 0.f, 0.f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + m_DepthBuffer[i].Unbind(); + } } void ShadowPass::Draw(RenderScene & scene) { - ShadowPassState* state = new ShadowPassState(m_DepthBuffer.GetHandle()); + ImGui::DragFloat4("ShadowMapCam", m_LRBT, 1.f, -1000.f, 1000.f); + ImGui::DragFloat2("ShadowMapNearFar", m_NearFarPlane, 1.f, -1000.f, 1000.f); + ImGui::Checkbox("EnableShadow", &m_ShadowOn); + ImGui::DragInt("ShadowLevel", &m_ShadowLevel, 0.05f, 0, m_CurrentNrOfSplits - 1); - GLuint shaderHandle = m_ShadowProgram->GetHandle(); - m_ShadowProgram->Bind(); + for (int i = 0; i < m_CurrentNrOfSplits; i++) { + m_shadCams[i].camera = new Camera(*scene.Camera); + //m_shadCams[i].frustumCorners = tempPoints; + } - glViewport(0, 0, resolutionSizeWidth, resolutionSizeHeigth); + UpdateSplitDist(m_shadCams, scene.Camera->NearClip(), scene.Camera->FarClip()); + + for (int i = 0; i < m_CurrentNrOfSplits; i++) { + m_shadCams[i].frustumCorners = UpdateFrustumPoints(m_shadCams[i].camera, m_shadCams[i].camera->Position(), m_shadCams[i].camera->Forward()); - glCullFace(GL_FRONT); - //state->Disable(GL_CULL_FACE); + ShadowPassState* state = new ShadowPassState(m_DepthBuffer[i].GetHandle()); - ImGui::DragFloat4("ShadowMapCam", m_LRBT, 1.f, -1000.f, 1000.f); - ImGui::DragFloat2("ShadowMapNearFar", m_NearFarPlane, 1.f, -1000.f, 1000.f); - ImGui::Checkbox("EnableShadow", &m_ShadowOn); + GLuint shaderHandle = m_ShadowProgram->GetHandle(); + m_ShadowProgram->Bind(); - if (m_ShadowOn == true) - { - for (auto &job : scene.DirectionalLightJobs) { - auto directionalLightJob = std::dynamic_pointer_cast(job); - - if(directionalLightJob) { - CalculateFrustum(scene, directionalLightJob); + glViewport(0, 0, resolutionSizeWidth / (1 + i), resolutionSizeHeigth); + glDisable(GL_TEXTURE_2D); + glCullFace(GL_FRONT); + //state->Disable(GL_CULL_FACE); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection)); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView)); + //m_LightProjection = FindNewFrustum(m_shadCams[0], m_LightProjection, m_LightProjection); - GLERROR("ShadowLight ERROR"); + if (m_ShadowOn == true) + { + for (auto &job : scene.DirectionalLightJobs) { + auto directionalLightJob = std::dynamic_pointer_cast(job); - for (auto &objectJob : scene.OpaqueObjects) { - auto modelJob = std::dynamic_pointer_cast(objectJob); - - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); + if (directionalLightJob) { + m_LightSpaceMatrix = CalculateFrustum(scene, directionalLightJob, m_LightProjection, m_LightView, m_shadCams[i]); + m_LightProjection = FindNewFrustum(m_shadCams[i]); - 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))); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection)); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView)); - GLERROR("Shadow Draw ERROR"); + GLERROR("ShadowLight ERROR"); - } - - } + for (auto &objectJob : scene.OpaqueObjects) { + auto modelJob = std::dynamic_pointer_cast(objectJob); - m_DepthBuffer.Unbind(); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); - delete state; - - - } - } - - - - glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); - glCullFace(GL_BACK); - m_ShadowProgram->Unbind(); + //glm::mat4 proj_mat = ApplyCropMatrix(m_shadCams[0], modelJob->Matrix, m_LightView); + //glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(proj_mat)); + 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("Shadow Draw ERROR"); + } + } + m_DepthBuffer[i].Unbind(); + delete state; + } + } + glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); + glEnable(GL_TEXTURE_2D); + glCullFace(GL_BACK); + m_ShadowProgram->Unbind(); + } } From f2ab02d860bf33e58460129dbd3054313afbb55b Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Thu, 18 Feb 2016 22:38:50 +0100 Subject: [PATCH 031/252] More WIP Switching between levels seem to work, but I borked all matrices --- include/Engine/Rendering/ShadowPass.h | 29 ++--- resources/Shaders/ForwardPlus.vert.glsl | 3 +- src/Engine/Editor/EditorSystem.cpp | 2 +- src/Engine/Rendering/DrawFinalPass.cpp | 1 - src/Engine/Rendering/ShadowPass.cpp | 136 ++++-------------------- 5 files changed, 29 insertions(+), 142 deletions(-) diff --git a/include/Engine/Rendering/ShadowPass.h b/include/Engine/Rendering/ShadowPass.h index 306ae8e0..7df1bbe9 100644 --- a/include/Engine/Rendering/ShadowPass.h +++ b/include/Engine/Rendering/ShadowPass.h @@ -11,8 +11,6 @@ #define MAX_SPLITS 5 -//#include "ShadowPassState.h" // not created yet - enum NearFar { Near = 0, Far = 1 }; enum LRBT { Left = 0, Right = 1, Bottom = 2, Top = 3 }; @@ -34,41 +32,30 @@ public: void Draw(RenderScene& scene); GLuint DepthMap() const { return m_DepthMap[m_ShadowLevel]; } - glm::mat4 lightSpaceMatrix() const { return m_LightSpaceMatrix; } - glm::mat4 lightP() const { return m_LightProjection; } - glm::mat4 lightV() const { return m_LightView; } - - void setResolution(GLuint width, GLuint height) { resolutionSizeWidth = width; resolutionSizeHeigth = height; } - + glm::mat4 lightP() const { return m_LightProjection[m_ShadowLevel]; } + glm::mat4 lightV() const { return m_LightView[m_ShadowLevel]; } private: glm::mat4 CalculateFrustum(RenderScene & scene, std::shared_ptr directionalLightJob, glm::mat4& p, glm::mat4& v, ShadowCamera shad_cam); - glm::vec3 LightDirectionToPoint(glm::vec4 direction); std::array UpdateFrustumPoints(Camera* cam, glm::vec3 center, glm::vec3 view_dir); void UpdateSplitDist(std::array shadow_cams, float far_distance, float near_distance); - void InitializeLightCameras(); - glm::mat4 ApplyCropMatrix(ShadowCamera& shadow_cam, glm::mat4 m, glm::mat4 v); glm::mat4 FindNewFrustum(ShadowCamera shadow_cam); EventBroker* m_EventBroker; - - const IRenderer* m_Renderer; + const IRenderer* m_Renderer; std::array m_DepthMap; std::array m_DepthBuffer; - ShaderProgram* m_ShadowProgram; + std::array m_LightProjection; + std::array m_LightView; - GLuint m_DepthFBO; + ShaderProgram* m_ShadowProgram; + GLuint m_DepthFBO; GLfloat m_NearFarPlane[2] = { -34.f, 27.f }; - //GLfloat m_LRBT[4] = { -77.f, 75.f, -89.f, 89.f }; GLfloat m_LRBT[4] = { -10.f, 10.f, -10.f, 10.f }; - glm::mat4 m_LightProjection; - glm::mat4 m_LightView; - glm::mat4 m_LightSpaceMatrix; - GLuint resolutionSizeWidth = 1024 * 2; GLuint resolutionSizeHeigth = 1024 * 2; @@ -76,7 +63,7 @@ private: int m_ShadowLevel = 0; int m_CurrentNrOfSplits = 3; - float m_SplitWeight = 0.75f; + float m_SplitWeight = 0.5f; std::array m_shadCams; }; diff --git a/resources/Shaders/ForwardPlus.vert.glsl b/resources/Shaders/ForwardPlus.vert.glsl index bde356e9..be7fa273 100644 --- a/resources/Shaders/ForwardPlus.vert.glsl +++ b/resources/Shaders/ForwardPlus.vert.glsl @@ -3,7 +3,6 @@ uniform mat4 M; uniform mat4 V; uniform mat4 P; -uniform mat4 lightSpaceMatrix; // Shadow map PV uniform mat4 LightV; uniform mat4 LightP; uniform mat4 Bones[100]; @@ -61,5 +60,5 @@ void main() Output.ExplosionPercentageElapsed = 0.0; //Output.PositionLightSpace = lightPos; // N - Output.PositionLightSpace = lightSpaceMatrix * M * vec4(Position, 1.0); + Output.PositionLightSpace = LightP * LightV * M * vec4(Position, 1.0); } \ No newline at end of file diff --git a/src/Engine/Editor/EditorSystem.cpp b/src/Engine/Editor/EditorSystem.cpp index 96b48874..a13bac0b 100644 --- a/src/Engine/Editor/EditorSystem.cpp +++ b/src/Engine/Editor/EditorSystem.cpp @@ -18,7 +18,7 @@ EditorSystem::EditorSystem(World* world, EventBroker* eventBroker, IRenderer* re m_ActualCamera = m_EditorCamera; m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Transform"); auto cCamera = m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Camera"); - (double&)cCamera["FarClip"] = 30.0; + (double&)cCamera["FarClip"] = 60.0; m_EditorCameraInputController = new EditorCameraInputController(m_EventBroker, -1); diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 3e74cd1a..776bb1b3 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -244,7 +244,6 @@ void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptrlightSpaceMatrix())); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightP"), 1, GL_FALSE, glm::value_ptr(m_ShadowPass->lightP())); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightV"), 1, GL_FALSE, glm::value_ptr(m_ShadowPass->lightV())); //GLfloat m_NearFarPlane[2] = { -40.f, 30.f }; diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index 7be01b5b..ce9ac0c4 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -4,7 +4,6 @@ ShadowPass::ShadowPass(IRenderer * renderer) { m_Renderer = renderer; - //InitializeTextures(); InitializeFrameBuffers(); InitializeShaderPrograms(); } @@ -63,6 +62,7 @@ void ShadowPass::UpdateSplitDist(std::array shadow_cam shadow_cams[m_CurrentNrOfSplits - 1].camera->SetFarClip(far_distance); } +// Create a new light frustum based on the 8 corner points of a view frustum segment glm::mat4 ShadowPass::FindNewFrustum(ShadowCamera shadow_cam) { float maxX = -1000.0f; @@ -72,126 +72,35 @@ glm::mat4 ShadowPass::FindNewFrustum(ShadowCamera shadow_cam) float minY = 1000.0f; float minZ; - glm::vec4 transf = glm::vec4(shadow_cam.frustumCorners[0], 1.f); - - //if (transf.x > maxX) maxX = transf.x; - //if (transf.x < minX) minX = transf.x; - //if (transf.y > maxY) maxY = transf.y; - //if (transf.y < minY) minY = transf.y; + glm::vec4 transf; for (int i = 0; i < 8; i++) { transf = glm::vec4(shadow_cam.frustumCorners[i], 1.f); - transf.x /= transf.w; - transf.y /= transf.w; - if (transf.x > maxX) maxX = transf.x; if (transf.x < minX) minX = transf.x; if (transf.y > maxY) maxY = transf.y; if (transf.y < minY) minY = transf.y; } + //float scaleX = 2.0f / (maxX - minX); + //float scaleY = 2.0f / (maxY - minY); + //float offsetX = -0.5f * (maxX + minX) * scaleX; + //float offsetY = -0.5f * (maxY + minY) * scaleY; + // + //glm::mat4 nv_mvp = glm::mat4(); + //nv_mvp[0][0] = scaleX; + //nv_mvp[1][1] = scaleY; + //nv_mvp[0][3] = offsetX; + //nv_mvp[1][3] = offsetY; + //glm::transpose(nv_mvp); + glm::mat4 p = glm::ortho(minX, maxX, minY, maxY, m_NearFarPlane[Near], m_NearFarPlane[Far]); return p; } -glm::mat4 ShadowPass::ApplyCropMatrix(ShadowCamera& shadow_cam, glm::mat4 m, glm::mat4 v) -{ - glm::mat4 shad_modelview; - glm::mat4 shad_proj; - glm::mat4 shad_crop; - glm::mat4 shad_mvp; - float maxX = -1000.0f; - float maxY = -1000.0f; - float maxZ; - float minX = 1000.0f; - float minY = 1000.0f; - float minZ; - - glm::mat4 nv_mvp; - glm::vec4 transf; - - shad_modelview = m * v; - nv_mvp = shad_modelview; - - transf = nv_mvp * glm::vec4(shadow_cam.frustumCorners[0], 1.f); - minZ = transf.z; - maxZ = transf.z; - - for (int i = 1; i < 8; i++) { - transf = nv_mvp * glm::vec4(shadow_cam.frustumCorners[i], 1.f); - if (transf.z > maxZ) { - maxZ = transf.z; - } - if (transf.z < minZ) { - minZ = transf.z; - } - } - - // make sure all relevant shadow casters are included here - - shad_proj = glm::ortho(-1.f, 1.f, -1.f, 1.f, m_NearFarPlane[0], m_NearFarPlane[1]); - - //return shad_proj; - - shad_mvp = shad_proj * shad_modelview; - - nv_mvp = shad_mvp; - - for (int i = 0; i < 8; i++) - { - transf = nv_mvp * glm::vec4(shadow_cam.frustumCorners[i], 1.0f); - - transf.x /= transf.w; - transf.y /= transf.w; - - if (transf.x > maxX) maxX = transf.x; - if (transf.x < minX) minX = transf.x; - if (transf.y > maxY) maxY = transf.y; - if (transf.y < minY) minY = transf.y; - } - - float scaleX = 2.0f / (maxX - minX); - float scaleY = 2.0f / (maxY - minY); - float offsetX = -0.5f*(maxX + minX)*scaleX; - float offsetY = -0.5f*(maxY + minY)*scaleY; - - nv_mvp = glm::mat4(); - nv_mvp[0][0] = scaleX; - nv_mvp[1][1] = scaleY; - nv_mvp[0][3] = offsetX; - nv_mvp[1][3] = offsetY; - glm::transpose(nv_mvp); - - shad_crop = nv_mvp; - shad_crop *= shad_proj; - - //return nv_mvp; - //return shad_crop; - return glm::mat4(); -} - -void MakeShadowMap(glm::mat4 m, glm::mat4 v, glm::mat4 p, glm::vec3 light_dir) -{ - //float shad_modelview[16]; - - glDisable(GL_TEXTURE_2D); - - glm::mat4 viewMatrix = glm::lookAt(glm::vec3(0.f), light_dir, glm::vec3(-1.f, 0.f, 0.f)); - - - - - - - - - - glEnable(GL_TEXTURE_2D); -} - glm::mat4 ShadowPass::CalculateFrustum(RenderScene & scene, std::shared_ptr directionalLightJob, glm::mat4& p, glm::mat4& v, ShadowCamera shad_cam) { p = glm::ortho(m_LRBT[Left], m_LRBT[Right], m_LRBT[Bottom], m_LRBT[Top], m_NearFarPlane[Near], m_NearFarPlane[Far]); @@ -234,14 +143,6 @@ void ShadowPass::InitializeShaderPrograms() m_ShadowProgram->Link(); } -void ShadowPass::InitializeLightCameras() -{ - //for (int i = 0; i < MAX_SPLITS; i++) { - // m_shadCams[i].camera = new Camera(1.f, ); - // Camera. - //} -} - void ShadowPass::ClearBuffer() { for (int i = 0; i < m_CurrentNrOfSplits; i++) { @@ -287,11 +188,11 @@ void ShadowPass::Draw(RenderScene & scene) auto directionalLightJob = std::dynamic_pointer_cast(job); if (directionalLightJob) { - m_LightSpaceMatrix = CalculateFrustum(scene, directionalLightJob, m_LightProjection, m_LightView, m_shadCams[i]); - m_LightProjection = FindNewFrustum(m_shadCams[i]); + CalculateFrustum(scene, directionalLightJob, m_LightProjection[i], m_LightView[i], m_shadCams[i]); + m_LightProjection[i] = FindNewFrustum(m_shadCams[i]); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection)); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView)); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection[i])); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView[i])); GLERROR("ShadowLight ERROR"); @@ -321,5 +222,6 @@ void ShadowPass::Draw(RenderScene & scene) glCullFace(GL_BACK); m_ShadowProgram->Unbind(); + } } From 73a4336206df535b13f2087048bc6d7f4ff8491d Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Thu, 18 Feb 2016 23:33:10 +0100 Subject: [PATCH 032/252] Try some stuff --- include/Engine/Rendering/ShadowPass.h | 2 +- src/Engine/Rendering/ShadowPass.cpp | 20 ++++++++------------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/include/Engine/Rendering/ShadowPass.h b/include/Engine/Rendering/ShadowPass.h index 7df1bbe9..2022a5ab 100644 --- a/include/Engine/Rendering/ShadowPass.h +++ b/include/Engine/Rendering/ShadowPass.h @@ -36,7 +36,7 @@ public: glm::mat4 lightV() const { return m_LightView[m_ShadowLevel]; } private: - glm::mat4 CalculateFrustum(RenderScene & scene, std::shared_ptr directionalLightJob, glm::mat4& p, glm::mat4& v, ShadowCamera shad_cam); + glm::mat4 CalculateFrustum(RenderScene & scene, std::shared_ptr directionalLightJob, ShadowCamera shad_cam); std::array UpdateFrustumPoints(Camera* cam, glm::vec3 center, glm::vec3 view_dir); void UpdateSplitDist(std::array shadow_cams, float far_distance, float near_distance); glm::mat4 FindNewFrustum(ShadowCamera shadow_cam); diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index ce9ac0c4..412a1fc7 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -19,8 +19,10 @@ std::array ShadowPass::UpdateFrustumPoints(Camera* cam, glm::vec3 glm::vec3 up = glm::vec3(0.f, 1.f, 0.f); glm::vec3 right = glm::normalize(glm::cross(view_dir, up)); - glm::vec3 farCenter = center + view_dir * cam->FarClip(); - glm::vec3 nearCenter = center + view_dir * cam->NearClip(); + //glm::vec3 farCenter = center + view_dir * cam->FarClip(); + //glm::vec3 nearCenter = center + view_dir * cam->NearClip(); + glm::vec3 farCenter = view_dir * cam->FarClip(); + glm::vec3 nearCenter = view_dir * cam->NearClip(); up = glm::normalize(glm::cross(right, view_dir)); @@ -101,12 +103,11 @@ glm::mat4 ShadowPass::FindNewFrustum(ShadowCamera shadow_cam) return p; } -glm::mat4 ShadowPass::CalculateFrustum(RenderScene & scene, std::shared_ptr directionalLightJob, glm::mat4& p, glm::mat4& v, ShadowCamera shad_cam) +glm::mat4 ShadowPass::CalculateFrustum(RenderScene & scene, std::shared_ptr directionalLightJob, ShadowCamera shad_cam) { - p = glm::ortho(m_LRBT[Left], m_LRBT[Right], m_LRBT[Bottom], m_LRBT[Top], m_NearFarPlane[Near], m_NearFarPlane[Far]); - v = glm::lookAt(glm::vec3(0.f) + shad_cam.camera->Position(), glm::vec3(directionalLightJob->Direction) + shad_cam.camera->Position(), glm::vec3(-1.f, 0.f, 0.f)); + glm::vec3 middle = shad_cam.camera->Position() + (shad_cam.camera->Forward() * shad_cam.camera->FarClip() * 0.5f); - return p * v; + return glm::lookAt(glm::vec3(0.f) + middle, glm::vec3(directionalLightJob->Direction) + middle, glm::vec3(-1.f, 0.f, 0.f)); } void ShadowPass::InitializeFrameBuffers() @@ -180,15 +181,13 @@ void ShadowPass::Draw(RenderScene & scene) glCullFace(GL_FRONT); //state->Disable(GL_CULL_FACE); - //m_LightProjection = FindNewFrustum(m_shadCams[0], m_LightProjection, m_LightProjection); - if (m_ShadowOn == true) { for (auto &job : scene.DirectionalLightJobs) { auto directionalLightJob = std::dynamic_pointer_cast(job); if (directionalLightJob) { - CalculateFrustum(scene, directionalLightJob, m_LightProjection[i], m_LightView[i], m_shadCams[i]); + m_LightView[i] = CalculateFrustum(scene, directionalLightJob, m_shadCams[i]); m_LightProjection[i] = FindNewFrustum(m_shadCams[i]); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection[i])); @@ -201,9 +200,6 @@ void ShadowPass::Draw(RenderScene & scene) glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); - //glm::mat4 proj_mat = ApplyCropMatrix(m_shadCams[0], modelJob->Matrix, m_LightView); - //glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(proj_mat)); - 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))); From 949ee76f553cea745d575349d83fc2e3a39be950 Mon Sep 17 00:00:00 2001 From: Tleety Date: Fri, 19 Feb 2016 13:52:16 +0100 Subject: [PATCH 033/252] Fallow and name fix --- resources/Shaders/ForwardPlus.frag.glsl | 2 +- src/Engine/Rendering/DrawBloomPass.cpp | 2 +- src/Engine/Rendering/Renderer.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index d757ff36..8e248aad 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -73,7 +73,7 @@ struct LightResult { }; float CalcAttenuation(float radius, float dist, float falloff) { - return 1.0 - smoothstep(radius * 0.3, radius, dist); + return 1.0 - smoothstep(radius * falloff, radius, dist); } vec4 CalcSpecular(vec4 lightColor, vec4 viewVec, vec4 lightVec, vec4 normal) { diff --git a/src/Engine/Rendering/DrawBloomPass.cpp b/src/Engine/Rendering/DrawBloomPass.cpp index 23080a52..1855a653 100644 --- a/src/Engine/Rendering/DrawBloomPass.cpp +++ b/src/Engine/Rendering/DrawBloomPass.cpp @@ -122,7 +122,7 @@ void DrawBloomPass::Draw(GLuint texture) } -void DrawBloomPass::OnWindowRezise() +void DrawBloomPass::OnWindowResize() { GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); m_GaussianFrameBuffer_vert.Generate(); diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index d0c06ea0..b8665fce 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -29,7 +29,7 @@ void Renderer::glfwFrameBufferCallback(GLFWwindow* window, int width, int height currentRenderer->m_DrawFinalPass->OnWindowResize(); currentRenderer->m_LightCullingPass->OnWindowResize(); currentRenderer->m_PickingPass->OnWindowResize(); - currentRenderer->m_DrawBloomPass->OnWindowRezise(); + currentRenderer->m_DrawBloomPass->OnWindowResize(); } void Renderer::InitializeWindow() From 97fcdb342d5fcd51758b3eea3c3ae99debfd2604 Mon Sep 17 00:00:00 2001 From: Tleety Date: Fri, 19 Feb 2016 14:23:40 +0100 Subject: [PATCH 034/252] Bloom should now show behind transparent objects. --- resources/Shaders/ForwardPlus.frag.glsl | 2 +- src/Engine/Rendering/DrawFinalPass.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 8e248aad..2db0295c 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -169,7 +169,7 @@ void main() sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1)); color_result += glowTexel*GlowIntensity; - bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), 1.0); + bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), clamp(color_result.a, 0, 1)); //Tiled Debug Code /* diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index d46f9591..1b99955a 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -191,8 +191,10 @@ void DrawFinalPass::Draw(RenderScene& scene) state->StencilMask(0x00); DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene); GLERROR("OpaqueObjects"); + state->BlendFunc(GL_ONE, GL_ONE); DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene); GLERROR("TransparentObjects"); + state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); DrawSprites(scene.Jobs.SpriteJob, scene); GLERROR("SpriteJobs"); From abd36c81f8d6182a75c118bed855d935e9ec968b Mon Sep 17 00:00:00 2001 From: viktorljung Date: Mon, 22 Feb 2016 15:58:38 +0100 Subject: [PATCH 035/252] Added BlendTree that stores and blends multiple animations --- include/Engine/Rendering/BlendTree.h | 75 +++++ include/Engine/Rendering/ModelJob.h | 39 +-- include/Engine/Rendering/Skeleton.h | 17 +- resources/Schema/Components.xsd | 3 + resources/Schema/Components/Animation.xml | 26 +- resources/Schema/Components/Animation.xsd | 43 +-- resources/Schema/Components/Blend.xml | 6 + resources/Schema/Components/Blend.xsd | 14 + resources/Schema/Components/BlendAdditive.xml | 5 + resources/Schema/Components/BlendAdditive.xsd | 13 + resources/Schema/Components/BlendOverride.xml | 6 + resources/Schema/Components/BlendOverride.xsd | 14 + resources/Schema/Entities/AnimationTests2.xml | 156 ++++----- resources/Schema/Types/Entity.xsd | 3 + src/Engine/Rendering/AnimationSystem.cpp | 33 +- src/Engine/Rendering/BlendTree.cpp | 255 ++++++++++++++ src/Engine/Rendering/BoneAttachmentSystem.cpp | 13 +- src/Engine/Rendering/DrawFinalPass.cpp | 40 ++- src/Engine/Rendering/PickingPass.cpp | 20 +- src/Engine/Rendering/Skeleton.cpp | 313 ++++++------------ 20 files changed, 641 insertions(+), 453 deletions(-) create mode 100644 include/Engine/Rendering/BlendTree.h create mode 100644 resources/Schema/Components/Blend.xml create mode 100644 resources/Schema/Components/Blend.xsd create mode 100644 resources/Schema/Components/BlendAdditive.xml create mode 100644 resources/Schema/Components/BlendAdditive.xsd create mode 100644 resources/Schema/Components/BlendOverride.xml create mode 100644 resources/Schema/Components/BlendOverride.xsd create mode 100644 src/Engine/Rendering/BlendTree.cpp diff --git a/include/Engine/Rendering/BlendTree.h b/include/Engine/Rendering/BlendTree.h new file mode 100644 index 00000000..431cb8b2 --- /dev/null +++ b/include/Engine/Rendering/BlendTree.h @@ -0,0 +1,75 @@ +#ifndef BlendTree_h__ +#define BlendTree_h__ + +#include "Common.h" +#include "../GLM.h" +#include "Skeleton.h" +#include "../Core/EntityWrapper.h" +#include "../Core/World.h" +#include + +class BlendTree +{ +public: + enum class NodeType + { + Additive, + Blend, + Override, + Animation, + }; + + + struct Node + { + std::string Name; + Node* Parent = nullptr; + Node* Child[2] = { nullptr, nullptr }; + NodeType Type; + std::vector Pose; + float Weight = 0.f; + + Node* Next() { + Node* next = this; + + if (next->Child[1] == nullptr) { + // Node has no right child + next = this; + while (next->Parent != nullptr && next == next->Parent->Child[1]) { + next = next->Parent; + } + next = next->Parent; + } else { + // Find the leftmost node in the right subtree + next = next->Child[1]; + while (next->Child[0] != nullptr) { + next = next->Child[0]; + } + } + + return next; + + } + }; + + + + + + BlendTree(EntityWrapper ModelEntity, Skeleton* skeleton); + ~BlendTree(); + + std::vector GetBoneTransforms(Skeleton* skeleton); + + void PrintTree(); + +private: + Node* m_Root = nullptr; + + void FillTree(Node* parentNode, EntityWrapper parentEntity, Skeleton* skeleton); + BlendTree::Node* FillTreeByName(Node* parentNode, std::string name, EntityWrapper parentEntity, Skeleton* skeleton); + + void Blend(Skeleton* skeleton, std::vector& pose); +}; + +#endif diff --git a/include/Engine/Rendering/ModelJob.h b/include/Engine/Rendering/ModelJob.h index 773e002e..212a3888 100644 --- a/include/Engine/Rendering/ModelJob.h +++ b/include/Engine/Rendering/ModelJob.h @@ -15,6 +15,7 @@ #include "../Core/Transform.h" #include "Skeleton.h" #include "ShaderProgram.h" +#include "BlendTree.h" struct ModelJob : RenderJob { @@ -122,41 +123,11 @@ struct ModelJob : RenderJob Skeleton = Model->m_RawModel->m_Skeleton; if (Skeleton != nullptr) { - if (world->HasComponent(Entity, "Animation")) { - auto animationComponent = world->GetComponent(Entity, "Animation"); - - for (int i = 1; i <= 3; i++) { - ::Skeleton::AnimationData animationData; - animationData.animation = model->m_RawModel->m_Skeleton->GetAnimation(animationComponent["AnimationName" + std::to_string(i)]); - if (animationData.animation == nullptr) { - continue; - } - animationData.time = (double)animationComponent["Time" + std::to_string(i)]; - animationData.weight = (double)animationComponent["Weight" + std::to_string(i)]; - - if((int)animationComponent["BlendType" + std::to_string(i)].Enum("Additive") == (int)animationComponent["BlendType" + std::to_string(i)]) { - animationData.blendType = Skeleton::BlendType::Additive; - } else if ((int)animationComponent["BlendType" + std::to_string(i)].Enum("Blend") == (int)animationComponent["BlendType" + std::to_string(i)]) { - animationData.blendType = Skeleton::BlendType::Blend; - } else if ((int)animationComponent["BlendType" + std::to_string(i)].Enum("Override") == (int)animationComponent["BlendType" + std::to_string(i)]) { - animationData.blendType = Skeleton::BlendType::Override; - } - - animationData.level = (int)animationComponent["Level" + std::to_string(i)]; - Animations.push_back(animationData); - } - } - - if (world->HasComponent(Entity, "AnimationOffset")) { - auto animationOffsetComponent = world->GetComponent(Entity, "AnimationOffset"); - AnimationOffset.animation = model->m_RawModel->m_Skeleton->GetAnimation(animationOffsetComponent["AnimationName"]); - AnimationOffset.time = (double)animationOffsetComponent["Time"]; - } else { - AnimationOffset.animation = nullptr; - } + + EntityWrapper entityWrapper = EntityWrapper(world, modelComponent.EntityID); + BlendTree = new ::BlendTree(entityWrapper, Skeleton); } } - }; unsigned int TextureID; @@ -178,7 +149,7 @@ struct ModelJob : RenderJob std::vector<::Skeleton::AnimationData> Animations; ::Skeleton::AnimationOffset AnimationOffset; - + ::BlendTree* BlendTree = nullptr; glm::vec4 DiffuseColor; glm::vec4 SpecularColor; diff --git a/include/Engine/Rendering/Skeleton.h b/include/Engine/Rendering/Skeleton.h index f064cc3c..58021416 100644 --- a/include/Engine/Rendering/Skeleton.h +++ b/include/Engine/Rendering/Skeleton.h @@ -74,6 +74,7 @@ public: Blend, Override, }; + struct AnimationData { const Animation* animation; @@ -108,26 +109,24 @@ public: int GetBoneID(std::string name); - std::vector GetFrameBones(std::vector animations, AnimationOffset animationOffset, bool noRootMotion = false); - std::vector GetFrameBones(std::vector animations, bool noRootMotion = false); + std::vector GetFrameBones(); + + std::vector GetFrameBones(const Animation* animation, double time, bool additive, bool noRootMotion = false); + void AccumulateBoneTransforms(bool noRootMotion, const Animation* animation, double time, std::map& boneMatrices, bool additive, const Bone* bone, glm::mat4 parentMatrix); const Animation* GetAnimation(std::string name); - - void AccumulateBoneTransforms(bool noRootMotion, std::vector animations, std::map& frameBones, const Bone* bone, glm::mat4 parentMatrix); - void AccumulateBoneTransforms(bool noRootMotion, std::vector animations, AnimationOffset animationOffset, std::map& frameBones, const Bone* bone, glm::mat4 parentMatrix); - glm::mat4 AdditiveBlend(const Bone* bone, AnimationOffset animationOffset, glm::mat4 targetPose); - void PrintSkeleton(); - void PrintSkeleton(const Bone* parent, int depthCount); std::map Animations; glm::mat4 GetBoneTransform(const Bone* bone, const Animation* animation, float time, glm::mat4 childMatrix); glm::mat4 GetBoneTransform(bool noRootMotion, const Bone* bone, std::vector animations, AnimationOffset animationOffset, glm::mat4 childMatrix); glm::mat4 GetBoneTransform(bool noRootMotion, const Bone* bone, std::vector animations, glm::mat4 childMatrix); - int GetKeyframe(const Animation& animation, double time); + std::vector BlendPoses(std::vector pose1, std::vector pose2, float weight); + std::vector OverridePose(std::vector overridePose, std::vector targetPose); + private: glm::mat4 GetOffsetTransform(const Bone* bone, AnimationOffset animationOffset); glm::mat4 GetBonePose(const Bone* bone, const Animation* animation, double time, bool noRootMotion); diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index f950e8c8..d81c3852 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -39,4 +39,7 @@ + + + \ No newline at end of file diff --git a/resources/Schema/Components/Animation.xml b/resources/Schema/Components/Animation.xml index 6f49edb4..45ee8428 100644 --- a/resources/Schema/Components/Animation.xml +++ b/resources/Schema/Components/Animation.xml @@ -1,24 +1,8 @@ - - - 0 - 1.0 - 0 - 0 - true - - - 0 - 1.0 - 0 - 0 - true - - - 0 - 1.0 - 0 - 0 - true + + + 0 + true + false \ No newline at end of file diff --git a/resources/Schema/Components/Animation.xsd b/resources/Schema/Components/Animation.xsd index e765f8e8..5e82c333 100644 --- a/resources/Schema/Components/Animation.xsd +++ b/resources/Schema/Components/Animation.xsd @@ -2,48 +2,15 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + - \ No newline at end of file diff --git a/resources/Schema/Components/Blend.xml b/resources/Schema/Components/Blend.xml new file mode 100644 index 00000000..f949a102 --- /dev/null +++ b/resources/Schema/Components/Blend.xml @@ -0,0 +1,6 @@ + + + + + 0.5 + \ No newline at end of file diff --git a/resources/Schema/Components/Blend.xsd b/resources/Schema/Components/Blend.xsd new file mode 100644 index 00000000..95fc8f49 --- /dev/null +++ b/resources/Schema/Components/Blend.xsd @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/Schema/Components/BlendAdditive.xml b/resources/Schema/Components/BlendAdditive.xml new file mode 100644 index 00000000..758917f9 --- /dev/null +++ b/resources/Schema/Components/BlendAdditive.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/resources/Schema/Components/BlendAdditive.xsd b/resources/Schema/Components/BlendAdditive.xsd new file mode 100644 index 00000000..ab931d52 --- /dev/null +++ b/resources/Schema/Components/BlendAdditive.xsd @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/Schema/Components/BlendOverride.xml b/resources/Schema/Components/BlendOverride.xml new file mode 100644 index 00000000..a9f2095a --- /dev/null +++ b/resources/Schema/Components/BlendOverride.xml @@ -0,0 +1,6 @@ + + + + + 1.0 + \ No newline at end of file diff --git a/resources/Schema/Components/BlendOverride.xsd b/resources/Schema/Components/BlendOverride.xsd new file mode 100644 index 00000000..27fc01ed --- /dev/null +++ b/resources/Schema/Components/BlendOverride.xsd @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/Schema/Entities/AnimationTests2.xml b/resources/Schema/Entities/AnimationTests2.xml index 8cc3f812..ace71800 100644 --- a/resources/Schema/Entities/AnimationTests2.xml +++ b/resources/Schema/Entities/AnimationTests2.xml @@ -26,42 +26,6 @@ - - - - Run - 1 - StrafeRight - 0.5 - 0.98334510030765165 - 0.5 - 0.97153983043137671 - 1 - 0.093923612201312068 - 1 - - - Models/Characters/Assault/AssaultAnimations.mesh - - - - - - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - - - - - - - @@ -99,35 +63,19 @@ - + - - Run - 1 - StrafeRight - 0.5 - 0.98334510030765165 - 0.5 - 0.89665639003541542 - 1 - ShootFastRifle - - - - 0.099759525382621339 - 1 - - - AimRifle - - + + BlendOverride + AimAdditive + Models/Characters/Assault/AssaultAnimations.mesh - + R_Arm_Weapon_Joint @@ -136,45 +84,79 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - - - - - - - AimRifle - 0.5 - Ru - 0.57926159055711501 - - - Models/Characters/Assault/AssaultAnimations.mesh - true - - - - - - - + - - R_Arm_Weapon_Joint - - - Models/Weapons/Red/AssaultWeaponRed.mesh - true - + + AimRifle + + 0.5 + true + + + + + ShootRifleAnimation + BlendWalkRun + + + + + + + + RunAnimtaion + WalkAnimation + 1 + + + + + + + + Run + + 1 + + + + + + + + + Walk + + 1 + + + + + + + + + + + ShootFastRifle + + 1 + + + + + + + diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index ffe3421a..19eded09 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -43,6 +43,9 @@ + + + diff --git a/src/Engine/Rendering/AnimationSystem.cpp b/src/Engine/Rendering/AnimationSystem.cpp index e70c4f36..1b260b08 100644 --- a/src/Engine/Rendering/AnimationSystem.cpp +++ b/src/Engine/Rendering/AnimationSystem.cpp @@ -2,57 +2,56 @@ void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& animationComponent, double dt) { - if(!entity.HasComponent("Model")) { - return; - } + + EntityWrapper parent = entity.FirstParentWithComponent("Model"); Model* model; try { - model = ResourceManager::Load<::Model, true>(entity["Model"]["Resource"]); + model = ResourceManager::Load<::Model, true>(parent["Model"]["Resource"]); } catch (const std::exception&) { return; } - + Skeleton* skeleton = model->m_RawModel->m_Skeleton; - if(skeleton == nullptr) { + if (skeleton == nullptr) { return; } - for (int i = 1; i <= 3; i++) { - const Skeleton::Animation* animation = skeleton->GetAnimation(animationComponent["AnimationName" + std::to_string(i)]); + for (int i = 1; i <= 1; i++) { + const Skeleton::Animation* animation = skeleton->GetAnimation(animationComponent["AnimationName"]); if (animation == nullptr) { continue;; } - double animationSpeed = (double)animationComponent["Speed" + std::to_string(i)]; + double animationSpeed = (double)animationComponent["Speed"]; if (animationSpeed != 0.0) { - double nextTime = (double)animationComponent["Time" + std::to_string(i)] + animationSpeed * dt; + double nextTime = (double)animationComponent["Time"] + animationSpeed * dt; - if (!(bool)animationComponent["Loop" + std::to_string(i)]) { + if (!(bool)animationComponent["Loop"]) { if (nextTime > animation->Duration) { nextTime = animation->Duration; Events::AnimationComplete e; e.Entity = entity; - e.Name = (std::string)animationComponent["AnimationName" + std::to_string(i)]; + e.Name = (std::string)animationComponent["AnimationName"]; m_EventBroker->Publish(e); } else if (nextTime < 0) { Events::AnimationComplete e; e.Entity = entity; - e.Name = (std::string)animationComponent["AnimationName" + std::to_string(i)]; + e.Name = (std::string)animationComponent["AnimationName"]; m_EventBroker->Publish(e); nextTime = 0; } - (double&)animationComponent["Speed" + std::to_string(i)] = 0.0; + (double&)animationComponent["Speed"] = 0.0; } else { if (nextTime > animation->Duration) { Events::AnimationComplete e; e.Entity = entity; - e.Name = (std::string)animationComponent["AnimationName" + std::to_string(i)]; + e.Name = (std::string)animationComponent["AnimationName"]; m_EventBroker->Publish(e); while(nextTime > animation->Duration) { @@ -61,7 +60,7 @@ void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& a } else if (nextTime < 0) { Events::AnimationComplete e; e.Entity = entity; - e.Name = (std::string)animationComponent["AnimationName" + std::to_string(i)]; + e.Name = (std::string)animationComponent["AnimationName"]; m_EventBroker->Publish(e); while (nextTime < 0) { @@ -70,7 +69,7 @@ void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& a } } - (double&)animationComponent["Time" + std::to_string(i)] = nextTime; + (double&)animationComponent["Time"] = nextTime; } } } diff --git a/src/Engine/Rendering/BlendTree.cpp b/src/Engine/Rendering/BlendTree.cpp new file mode 100644 index 00000000..43d1d5fd --- /dev/null +++ b/src/Engine/Rendering/BlendTree.cpp @@ -0,0 +1,255 @@ +#include "Rendering/BlendTree.h" + +BlendTree::BlendTree(EntityWrapper ModelEntity, Skeleton* skeleton) +{ + auto itPair = ModelEntity.World->GetChildren(ModelEntity.ID); + if (itPair.first == itPair.second) { + return; + } + + + if (ModelEntity.HasComponent("Animation")) { + const Skeleton::Animation* animation = skeleton->GetAnimation(ModelEntity["Animation"]["AnimationName"]); + if (animation == nullptr) { + return; + } + + m_Root = new Node(); + m_Root->Name = ModelEntity.Name(); + m_Root->Pose = skeleton->GetFrameBones(animation, (double)ModelEntity["Animation"]["Time"], (bool)ModelEntity["Animation"]["Additive"]); + m_Root->Parent = nullptr; + m_Root->Type = NodeType::Animation; + + } else if (ModelEntity.HasComponent("Blend")) { + m_Root = new Node(); + m_Root->Name = ModelEntity.Name(); + m_Root->Parent = nullptr; + m_Root->Type = NodeType::Blend; + m_Root->Weight = (double)ModelEntity["Blend"]["Weight"]; + m_Root->Child[0] = FillTreeByName(m_Root, (std::string)ModelEntity["Blend"]["Pose1"], ModelEntity, skeleton); + m_Root->Child[1] = FillTreeByName(m_Root, (std::string)ModelEntity["Blend"]["Pose2"], ModelEntity, skeleton); + + } else if (ModelEntity.HasComponent("BlendOverride")) { + m_Root = new Node(); + m_Root->Name = ModelEntity.Name(); + m_Root->Parent = nullptr; + m_Root->Type = NodeType::Override; + m_Root->Child[0] = FillTreeByName(m_Root, (std::string)ModelEntity["BlendOverride"]["Master"], ModelEntity, skeleton); + m_Root->Child[1] = FillTreeByName(m_Root, (std::string)ModelEntity["BlendOverride"]["Slave"], ModelEntity, skeleton); + + } else if (ModelEntity.HasComponent("BlendAdditive")) { + m_Root = new Node(); + m_Root->Name = ModelEntity.Name(); + m_Root->Parent = nullptr; + m_Root->Type = NodeType::Additive; + m_Root->Child[0] = FillTreeByName(m_Root, (std::string)ModelEntity["BlendAdditive"]["Adder"], ModelEntity, skeleton); + m_Root->Child[1] = FillTreeByName(m_Root, (std::string)ModelEntity["BlendAdditive"]["Receiver"], ModelEntity, skeleton); + } + + + + // PrintTree(); +} + +BlendTree::~BlendTree() +{ + +} + +void BlendTree::PrintTree() +{ + Node* currentNode = m_Root; + LOG_INFO("\n\n"); + + while(currentNode->Child[0] != nullptr) { + currentNode = currentNode->Child[0]; + } + + while (currentNode != nullptr) + { + LOG_INFO("%s", currentNode->Name.c_str()); + currentNode = currentNode->Next(); + } + + +} + + + +void BlendTree::FillTree(Node* parentNode, EntityWrapper parentEntity, Skeleton* skeleton) +{ + auto itPair = parentEntity.World->GetChildren(parentEntity.ID); + if (itPair.first == itPair.second) { + return; // no children + } + + unsigned int childIndex = 0; + for (auto it = itPair.first; it != itPair.second; ++it) { + + EntityWrapper childEntity = EntityWrapper(parentEntity.World, it->second); + + if(!childEntity.Valid()) { + continue; + } + + if (childEntity.HasComponent("Animation")) { + const Skeleton::Animation* animation = skeleton->GetAnimation(childEntity["Animation"]["AnimationName"]); + if(animation == nullptr) { + continue; + } + + Node* node = new Node(); + node->Name = childEntity.Name(); + node->Pose = skeleton->GetFrameBones(animation, (double)childEntity["Animation"]["Time"], (bool)childEntity["Animation"]["Additive"]); + node->Parent = parentNode; + node->Type = NodeType::Animation; + parentNode->Child[childIndex] = node; + childIndex++; + FillTree(node, childEntity, skeleton); + + } else if (childEntity.HasComponent("Blend")) { + Node* node = new Node(); + node->Name = childEntity.Name(); + node->Parent = parentNode; + node->Type = NodeType::Blend; + node->Weight = (double)childEntity["Blend"]["Weight"]; + parentNode->Child[childIndex] = node; + childIndex++; + FillTree(node, childEntity, skeleton); + + } else if (childEntity.HasComponent("BlendOverride")) { + Node* node = new Node(); + node->Name = childEntity.Name(); + node->Parent = parentNode; + node->Type = NodeType::Override; + parentNode->Child[childIndex] = node; + childIndex++; + FillTree(node, childEntity, skeleton); + + } else if (childEntity.HasComponent("BlendAdditive")) { + Node* node = new Node(); + node->Name = childEntity.Name(); + node->Parent = parentNode; + node->Type = NodeType::Additive; + parentNode->Child[childIndex] = node; + childIndex++; + FillTree(node, childEntity, skeleton); + } + } +} + + +BlendTree::Node* BlendTree::FillTreeByName(Node* parentNode, std::string name, EntityWrapper parentEntity, Skeleton* skeleton) +{ + EntityWrapper childEntity = parentEntity.FirstChildByName(name); + + if (!childEntity.Valid()) { + return nullptr; + } + + if (childEntity.HasComponent("Animation")) { + const Skeleton::Animation* animation = skeleton->GetAnimation(childEntity["Animation"]["AnimationName"]); + if (animation == nullptr) { + return nullptr; + } + + Node* node = new Node(); + node->Name = childEntity.Name(); + node->Pose = skeleton->GetFrameBones(animation, (double)childEntity["Animation"]["Time"], (bool)childEntity["Animation"]["Additive"]); + node->Parent = parentNode; + node->Type = NodeType::Animation; + return node; + + } else if (childEntity.HasComponent("Blend")) { + Node* node = new Node(); + node->Name = childEntity.Name(); + node->Parent = parentNode; + node->Type = NodeType::Blend; + node->Weight = (double)childEntity["Blend"]["Weight"]; + node->Child[0] = FillTreeByName(node, (std::string)childEntity["Blend"]["Pose1"], childEntity, skeleton); + node->Child[1] = FillTreeByName(node, (std::string)childEntity["Blend"]["Pose2"], childEntity, skeleton); + return node; + } else if (childEntity.HasComponent("BlendOverride")) { + Node* node = new Node(); + node->Name = childEntity.Name(); + node->Parent = parentNode; + node->Type = NodeType::Override; + node->Child[0] = FillTreeByName(node, (std::string)childEntity["BlendOverride"]["Master"], childEntity, skeleton); + node->Child[1] = FillTreeByName(node, (std::string)childEntity["BlendOverride"]["Slave"], childEntity, skeleton); + return node; + } else if (childEntity.HasComponent("BlendAdditive")) { + Node* node = new Node(); + node->Name = childEntity.Name(); + node->Parent = parentNode; + node->Type = NodeType::Additive; + node->Child[0] = FillTreeByName(node, (std::string)childEntity["BlendAdditive"]["Adder"], childEntity, skeleton); + node->Child[1] = FillTreeByName(node, (std::string)childEntity["BlendAdditive"]["Receiver"], childEntity, skeleton); + return node; + } + + return nullptr; +} + +void BlendTree::Blend(Skeleton* skeleton, std::vector& pose) +{ + Node* currentNode; + Node* start = m_Root; + while (start->Child[0] != nullptr) { + start = start->Child[0]; + } + + currentNode = start; + LOG_INFO("\n\n"); + while (m_Root->Pose.size() == 0) { + if(currentNode->Pose.size() == 0) { + if(currentNode->Child[0]->Pose.size() != 0 && currentNode->Child[1]->Pose.size() != 0) { + + switch (currentNode->Type) { + case BlendTree::NodeType::Additive: + currentNode->Pose = skeleton->BlendPoses(currentNode->Child[0]->Pose, currentNode->Child[1]->Pose, currentNode->Weight); + break; + case BlendTree::NodeType::Blend: + currentNode->Pose = skeleton->BlendPoses(currentNode->Child[0]->Pose, currentNode->Child[1]->Pose, currentNode->Weight); + break; + case BlendTree::NodeType::Override: + currentNode->Pose = skeleton->OverridePose(currentNode->Child[0]->Pose, currentNode->Child[1]->Pose); + break; + case BlendTree::NodeType::Animation: + // do nothing + break; + } + + + LOG_INFO("Blending %s and %s", currentNode->Child[0]->Name.c_str(), currentNode->Child[1]->Name.c_str()); + } + } + + + + currentNode = currentNode->Next(); + + if (currentNode == nullptr) { + currentNode = start; + } + + } + + pose = m_Root->Pose; +} + +std::vector BlendTree::GetBoneTransforms(Skeleton* skeleton) +{ + if (skeleton == nullptr || m_Root == nullptr) { + std::vector pose; + for (auto& b : skeleton->Bones) { + pose.push_back(glm::mat4(1)); + } + return pose; + } + + std::vector pose; + Blend(skeleton, pose); + + return pose; +} + diff --git a/src/Engine/Rendering/BoneAttachmentSystem.cpp b/src/Engine/Rendering/BoneAttachmentSystem.cpp index 3effaf2c..a4d381d1 100644 --- a/src/Engine/Rendering/BoneAttachmentSystem.cpp +++ b/src/Engine/Rendering/BoneAttachmentSystem.cpp @@ -40,15 +40,10 @@ void BoneAttachmentSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapp glm::mat4 boneTransform; if (parent.HasComponent("Animation")) { - for (int i = 1; i <= 3; i++) { - ::Skeleton::AnimationData animationData; - animationData.animation = model->m_RawModel->m_Skeleton->GetAnimation(parent["Animation"]["AnimationName" + std::to_string(i)]); - if (animationData.animation == nullptr) { - continue; - } - animationData.time = (double)parent["Animation"]["Time" + std::to_string(i)]; - animationData.weight = (double)parent["Animation"]["Weight" + std::to_string(i)]; - + ::Skeleton::AnimationData animationData; + animationData.animation = model->m_RawModel->m_Skeleton->GetAnimation(parent["Animation"]["AnimationName"]); + if (animationData.animation != nullptr) { + animationData.time = (double)parent["Animation"]["Time"]; Animations.push_back(animationData); } } diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 11db71f0..43722a61 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -338,11 +338,12 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& //bind textures BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob); std::vector frameBones; - if (explosionEffectJob->AnimationOffset.animation != nullptr) { + /*if (explosionEffectJob->AnimationOffset.animation != nullptr) { frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); } else { frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); - } + }*/ + frameBones = explosionEffectJob->Skeleton->GetFrameBones(); glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } else { m_ExplosionEffectProgram->Bind(); @@ -365,11 +366,12 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& BindExplosionTextures(explosionSplatMapSkinnedHandle, explosionEffectJob); GLERROR("asdasd"); std::vector frameBones; - if (explosionEffectJob->AnimationOffset.animation != nullptr) { + /*if (explosionEffectJob->AnimationOffset.animation != nullptr) { frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); } else { frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); - } + }*/ + frameBones = explosionEffectJob->Skeleton->GetFrameBones(); glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } else { @@ -410,11 +412,12 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& //bind textures BindModelTextures(forwardSkinnedHandle, modelJob); std::vector frameBones; - if (modelJob->AnimationOffset.animation != nullptr) { + /* if (modelJob->AnimationOffset.animation != nullptr) { frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); } else { frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); - } + }*/ + frameBones = modelJob->BlendTree->GetBoneTransforms(modelJob->Skeleton); glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } else { @@ -438,11 +441,12 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& BindModelTextures(forwardSplatMapSkinnedHandle, modelJob); GLERROR("asdasd"); std::vector frameBones; - if (modelJob->AnimationOffset.animation != nullptr) { + /* if (modelJob->AnimationOffset.animation != nullptr) { frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); } else { frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); - } + }*/ + frameBones = modelJob->BlendTree->GetBoneTransforms(modelJob->Skeleton); glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } else { @@ -486,11 +490,12 @@ void DrawFinalPass::DrawShieldToStencilBuffer(std::listViewMatrix())); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); std::vector frameBones; - if (modelJob->AnimationOffset.animation != nullptr) { + /*if (modelJob->AnimationOffset.animation != nullptr) { frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); } else { frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); - } + }*/ + frameBones = modelJob->Skeleton->GetFrameBones(); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } else { m_ShieldToStencilProgram->Bind(); @@ -544,11 +549,12 @@ void DrawFinalPass::DrawShieldedModelRenderQueue(std::list frameBones; - if (explosionEffectJob->AnimationOffset.animation != nullptr) { + /* if (explosionEffectJob->AnimationOffset.animation != nullptr) { frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); } else { frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); - } + }*/ + frameBones = explosionEffectJob->Skeleton->GetFrameBones(); glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); if (GLERROR("Animation")) { @@ -583,11 +589,12 @@ void DrawFinalPass::DrawShieldedModelRenderQueue(std::list frameBones; - if (modelJob->AnimationOffset.animation != nullptr) { + /* if (modelJob->AnimationOffset.animation != nullptr) { frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); } else { frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); - } + }*/ + frameBones = modelJob->Skeleton->GetFrameBones(); glUniformMatrix4fv(glGetUniformLocation(forwardHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); @@ -619,11 +626,12 @@ void DrawFinalPass::DrawToDepthBuffer(std::list>& job glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); std::vector frameBones; - if (modelJob->AnimationOffset.animation != nullptr) { + /*if (modelJob->AnimationOffset.animation != nullptr) { frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); } else { frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); - } + }*/ + frameBones = modelJob->Skeleton->GetFrameBones(); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } else { diff --git a/src/Engine/Rendering/PickingPass.cpp b/src/Engine/Rendering/PickingPass.cpp index fa1b3ca3..479cb762 100644 --- a/src/Engine/Rendering/PickingPass.cpp +++ b/src/Engine/Rendering/PickingPass.cpp @@ -103,11 +103,12 @@ void PickingPass::Draw(RenderScene& scene) if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) { std::vector frameBones; - if (modelJob->AnimationOffset.animation != nullptr) { + /*if (modelJob->AnimationOffset.animation != nullptr) { frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); } else { frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); - } + }*/ + frameBones = modelJob->Skeleton->GetFrameBones(); glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } @@ -160,11 +161,12 @@ void PickingPass::Draw(RenderScene& scene) glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1]))); std::vector frameBones; - if (modelJob->AnimationOffset.animation != nullptr) { + /* if (modelJob->AnimationOffset.animation != nullptr) { frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); } else { frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); - } + }*/ + frameBones = modelJob->Skeleton->GetFrameBones(); glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } else { m_PickingProgram->Bind(); @@ -215,11 +217,12 @@ void PickingPass::Draw(RenderScene& scene) glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1]))); std::vector frameBones; - if (modelJob->AnimationOffset.animation != nullptr) { + /* if (modelJob->AnimationOffset.animation != nullptr) { frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); } else { frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); - } + }*/ + frameBones = modelJob->Skeleton->GetFrameBones(); glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } else { @@ -276,11 +279,12 @@ void PickingPass::Draw(RenderScene& scene) if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) { std::vector frameBones; - if (modelJob->AnimationOffset.animation != nullptr) { + /*if (modelJob->AnimationOffset.animation != nullptr) { frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); } else { frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); - } + }*/ + frameBones = modelJob->Skeleton->GetFrameBones(); glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } diff --git a/src/Engine/Rendering/Skeleton.cpp b/src/Engine/Rendering/Skeleton.cpp index 94656848..4745b36d 100644 --- a/src/Engine/Rendering/Skeleton.cpp +++ b/src/Engine/Rendering/Skeleton.cpp @@ -41,29 +41,17 @@ const Skeleton::Animation* Skeleton::GetAnimation(std::string name) } } -std::vector Skeleton::GetFrameBones(std::vector animations, bool noRootMotion /*= false*/) +std::vector Skeleton::GetFrameBones() { - if (animations.size() <= 0) { - std::vector finalMatrices; - for (auto& b : Bones) { - finalMatrices.push_back(glm::mat4(1));//b.second->OffsetMatrix); - } - return finalMatrices; - } - - std::map frameBones; - AccumulateBoneTransforms(true, animations, frameBones, RootBone, glm::mat4(1)); - std::vector finalMatrices; - for (auto &kv : frameBones) { - finalMatrices.push_back(kv.second); + for (auto& b : Bones) { + finalMatrices.push_back(glm::mat4(1)); } return finalMatrices; } - -std::vector Skeleton::GetFrameBones(std::vector animations, AnimationOffset animationOffset, bool noRootMotion /*= false*/) +std::vector Skeleton::GetFrameBones(const Animation* animation, const double time, bool additive, bool noRootMotion /*= false*/) { - if (animations.size() <= 0 || animationOffset.animation == nullptr) { + if (animation == nullptr) { std::vector finalMatrices; for (auto& b : Bones) { finalMatrices.push_back(glm::mat4(1)); @@ -71,9 +59,9 @@ std::vector Skeleton::GetFrameBones(std::vector animat return finalMatrices; } - + std::map frameBones; - AccumulateBoneTransforms(true, animations, animationOffset, frameBones, RootBone, glm::mat4(1)); + AccumulateBoneTransforms(true, animation, time, frameBones, additive, RootBone, glm::mat4(1)); std::vector finalMatrices; for (auto &kv : frameBones) { @@ -82,175 +70,74 @@ std::vector Skeleton::GetFrameBones(std::vector animat return finalMatrices; } -void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vector animations, std::map& boneMatrices, const Bone* bone, glm::mat4 parentMatrix) +void Skeleton::AccumulateBoneTransforms(bool noRootMotion, const Animation* animation, double time, std::map& boneMatrices, bool additive, const Bone* bone, glm::mat4 parentMatrix) { - glm::mat4 boneMatrix; - - std::vector JointPoses; - - for (const AnimationData animationData : animations) { - const Animation* animation = animationData.animation; - const float time = animationData.time; - - JointFramePose jointPose; - jointPose.Weight = animationData.weight;; - - if (animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) { - std::vector boneKeyFrames = animation->JointAnimations.at(bone->ID); - - Animation::Keyframe currentFrame; - Animation::Keyframe nextFrame; - - if (boneKeyFrames.size() > 1) { // 2+ keyframes for the current bone - for (int index = boneKeyFrames.size()-1; index >= 0; index--) { // find the bone keyframes that surrounds the current frame - if (time >= boneKeyFrames.at(index).Time) { - currentFrame = boneKeyFrames.at(index); - nextFrame = boneKeyFrames.at((index + 1) % boneKeyFrames.size()); - break; - } - } - - float progress; - - if (nextFrame.Index == 0) { - nextFrame = currentFrame; - progress = (time - currentFrame.Time) / (animation->Duration - currentFrame.Time); - } else { - progress = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time); - - } - - - if (progress > 1.0f || progress < 0.0f) { - progress = glm::clamp(progress, 0.0f, 1.0f); - } - Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties; - Animation::Keyframe::BoneProperty nextBoneProperty = nextFrame.BoneProperties; - - glm::vec3 position = currentBoneProperty.Position * (1.f - progress) + nextBoneProperty.Position * progress; - glm::quat rotation = glm::slerp(currentBoneProperty.Rotation, nextBoneProperty.Rotation, progress); - glm::vec3 scale = currentBoneProperty.Scale * (1.f - progress) + nextBoneProperty.Scale * progress; - - // Flag for no root motion - if (bone == RootBone && noRootMotion) { - position.x = 0; - position.z = 0; - } - - jointPose.Pose = (glm::translate(position) * glm::toMat4(rotation) * glm::scale(scale)); - JointPoses.push_back(jointPose); - - } else { // 1 keyframes for the current bone - currentFrame = boneKeyFrames.at(0); - jointPose.Pose = (glm::translate(currentFrame.BoneProperties.Position) * glm::toMat4(currentFrame.BoneProperties.Rotation) * glm::scale(currentFrame.BoneProperties.Scale)); - JointPoses.push_back(jointPose); - } - } else { // 0 keyframes for the current bone - - } - + if (additive) { + time += 1.0/60.0; // first frame is a reference frame } + glm::mat4 boneMatrix; - if (JointPoses.size() == 0) { - if (bone->Parent) { - glm::mat4 jointPose = (glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix); + if (animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) { + std::vector boneKeyFrames = animation->JointAnimations.at(bone->ID); - boneMatrix = parentMatrix * jointPose; - boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix; - } else { - boneMatrix = glm::inverse(bone->OffsetMatrix); - boneMatrices[bone->ID] = parentMatrix; - } - } else { + Animation::Keyframe currentFrame; + Animation::Keyframe nextFrame; - float totalWeight = 0; + if (boneKeyFrames.size() > 1) { // 2+ keyframes for the current bone + for (int index = boneKeyFrames.size()-1; index >= 0; index--) { // find the bone keyframes that surrounds the current frame + if (time >= boneKeyFrames.at(index).Time) { + currentFrame = boneKeyFrames.at(index); + nextFrame = boneKeyFrames.at((index + 1) % boneKeyFrames.size()); + break; + } + } - for (JointFramePose jointFramePose : JointPoses) { - totalWeight += jointFramePose.Weight; - } + float progress; - glm::mat4 finalBlend = glm::mat4(0); - - for (JointFramePose jointFramePose : JointPoses) { - if (jointFramePose.Weight == 1.0f) { - finalBlend = jointFramePose.Pose; + if (nextFrame.Index == 0) { + nextFrame = currentFrame; + progress = (time - currentFrame.Time) / (animation->Duration - currentFrame.Time); } else { - finalBlend += jointFramePose.Pose * (jointFramePose.Weight / totalWeight); + progress = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time); + } + + progress = glm::clamp(progress, 0.0f, 1.0f); + Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties; + Animation::Keyframe::BoneProperty nextBoneProperty = nextFrame.BoneProperties; + + glm::vec3 position = currentBoneProperty.Position * (1.f - progress) + nextBoneProperty.Position * progress; + glm::quat rotation = glm::slerp(currentBoneProperty.Rotation, nextBoneProperty.Rotation, progress); + glm::vec3 scale = currentBoneProperty.Scale * (1.f - progress) + nextBoneProperty.Scale * progress; + + // Flag for no root motion + if (bone == RootBone && noRootMotion) { + position.x = 0; + position.z = 0; + } + + boneMatrix = parentMatrix * (glm::translate(position) * glm::toMat4(rotation) * glm::scale(scale)); + boneMatrices[bone->ID] = boneMatrix *bone->OffsetMatrix; + + } else { // 1 keyframes for the current bone + currentFrame = boneKeyFrames.at(0); + boneMatrix = parentMatrix * (glm::translate(currentFrame.BoneProperties.Position) * glm::toMat4(currentFrame.BoneProperties.Rotation) * glm::scale(currentFrame.BoneProperties.Scale)); + boneMatrices[bone->ID] = boneMatrix *bone->OffsetMatrix; } - - - boneMatrix = parentMatrix * finalBlend; - boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix; - } - - for (auto &child : bone->Children) { - AccumulateBoneTransforms(noRootMotion, animations, boneMatrices, child, boneMatrix); - } -} - -void Skeleton::AccumulateBoneTransforms(bool noRootMotion, std::vector animations, AnimationOffset animationOffset, std::map& boneMatrices, const Bone* bone, glm::mat4 parentMatrix) -{ - glm::mat4 boneMatrix; - std::vector JointPoses; - - for (const AnimationData animationData : animations) { - if (animationData.animation->JointAnimations.find(bone->ID) != animationData.animation->JointAnimations.end()) { // Does the bone have any keyframes in this animation? - JointFramePose jointPose; - jointPose.Weight = animationData.weight; - jointPose.Type = animationData.blendType; - jointPose.Level = animationData.level; - jointPose.Pose = GetBonePose(bone, animationData.animation, animationData.time, noRootMotion); - JointPoses.push_back(jointPose); - } - } - - - if (JointPoses.size() == 0) { // No keyframes for the current bone + } else { // 0 keyframes for the current bone if (bone->Parent) { - glm::mat4 jointPose = (glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix); - glm::mat4 boneTransform = AdditiveBlend(bone, animationOffset, jointPose); - boneMatrix = parentMatrix * boneTransform; - boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix; + boneMatrix = parentMatrix * (glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix); + boneMatrices[bone->ID] = boneMatrix *bone->OffsetMatrix; } else { boneMatrix = glm::inverse(bone->OffsetMatrix); boneMatrices[bone->ID] = parentMatrix; } - } else { - - - glm::mat4 finalBlend = glm::mat4(0); - glm::mat4 finalOverride = glm::mat4(0); - - int maxLevel = 0; - for (JointFramePose jointPose : JointPoses) { - maxLevel = jointPose.Level > maxLevel ? jointPose.Level : maxLevel; - } - - - for (JointFramePose jointPose : JointPoses) { - if (jointPose.Type == BlendType::Override) { - finalOverride += jointPose.Pose * jointPose.Weight; //Blend Overrides then apply to final blend - } else if(jointPose.Type == BlendType::Blend) { - finalBlend += jointPose.Pose * jointPose.Weight; - } else if (jointPose.Type == BlendType::Additive) { - //Soon - } - } - - if(finalOverride != glm::mat4(0)) { - finalBlend = finalOverride; - } - - glm::mat4 boneTransform = AdditiveBlend(bone, animationOffset, finalBlend); - boneMatrix = parentMatrix * boneTransform; - boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix; } for (auto &child : bone->Children) { - AccumulateBoneTransforms(noRootMotion, animations, animationOffset, boneMatrices, child, boneMatrix); + AccumulateBoneTransforms(noRootMotion, animation, time, boneMatrices, additive, child, boneMatrix); } } @@ -444,7 +331,6 @@ glm::mat4 Skeleton::GetBoneTransform(const Bone* bone, const Animation* animatio } } - glm::mat4 Skeleton::GetBoneTransform(bool noRootMotion, const Bone* bone, std::vector animations, AnimationOffset animationOffset, glm::mat4 childMatrix) { glm::mat4 boneMatrix; @@ -555,7 +441,6 @@ glm::mat4 Skeleton::GetBoneTransform(bool noRootMotion, const Bone* bone, std::v } } - glm::mat4 Skeleton::GetBoneTransform(bool noRootMotion, const Bone* bone, std::vector animations, glm::mat4 childMatrix) { glm::mat4 boneMatrix; @@ -673,6 +558,50 @@ glm::mat4 Skeleton::GetBoneTransform(bool noRootMotion, const Bone* bone, std::v return boneMatrix; } + +std::vector Skeleton::BlendPoses(std::vector pose1, std::vector pose2, float weight) +{ + std::vector finalPose; + + if(pose1.size() != pose2.size()) { + LOG_ERROR("Number of bones does not match"); + return finalPose; + } + + for (int i = 0; i < pose1.size(); i++) { + glm::mat4 blendedPose = glm::mat4(0); + + blendedPose += pose1[i] * weight; + + blendedPose += pose2[i] * (1.f - weight); + + finalPose.push_back(blendedPose); + } + + return finalPose; +} + + +std::vector Skeleton::OverridePose(std::vector overridePose, std::vector targetPose) +{ + std::vector finalPose; + + if (overridePose.size() != targetPose.size()) { + LOG_ERROR("Number of bones does not match"); + return finalPose; + } + + for (int i = 0; i < overridePose.size(); i++) { + if(overridePose[i] != glm::mat4(1)) { + finalPose.push_back(overridePose[i]); + } else { + finalPose.push_back(targetPose[i]); + } + } + + return finalPose; +} + int Skeleton::GetBoneID(std::string name) { if (m_BonesByName.find(name) == m_BonesByName.end()) { @@ -681,47 +610,3 @@ int Skeleton::GetBoneID(std::string name) return m_BonesByName.at(name)->ID; } } - -void Skeleton::PrintSkeleton() -{ - if (LOG_LEVEL < LOG_LEVEL_DEBUG) { - return; - } - PrintSkeleton(RootBone, 0); -} - -void Skeleton::PrintSkeleton(const Bone* bone, int depthCount) -{ - std::stringstream ss; - ss << std::string(depthCount, ' '); - ss << bone->ID << ": " << bone->Name; - std::cout << ss.str() << std::endl; - - depthCount++; - - for (auto &child : bone->Children) { - PrintSkeleton(child, depthCount); - } -} - -int Skeleton::GetKeyframe(const Animation& animation, double time) -{ - -/* - if (time < 0) { - time = 0; - } - if (time >= animation.Duration) { - return animation..size() - 1; - } - - for (int keyframe = 0; keyframe < animation.Keyframes.size(); ++keyframe) { - if (animation.Keyframes[keyframe].Time > time) { - return (keyframe - 1) % animation.Keyframes.size(); - } - } -*/ - - - return 0; -} From 127edb4e604605610418ff4a6d33f06b6f9d0d8c Mon Sep 17 00:00:00 2001 From: viktorljung Date: Mon, 22 Feb 2016 17:47:30 +0100 Subject: [PATCH 036/252] Fixed some memory leaks --- include/Engine/Rendering/ModelJob.h | 4 ++-- resources/Schema/Entities/AnimationTests2.xml | 10 ++++++---- src/Engine/Rendering/BlendTree.cpp | 18 ++++++++++++++++++ src/Engine/Rendering/Skeleton.cpp | 4 +++- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/include/Engine/Rendering/ModelJob.h b/include/Engine/Rendering/ModelJob.h index 212a3888..c10d6389 100644 --- a/include/Engine/Rendering/ModelJob.h +++ b/include/Engine/Rendering/ModelJob.h @@ -125,7 +125,7 @@ struct ModelJob : RenderJob if (Skeleton != nullptr) { EntityWrapper entityWrapper = EntityWrapper(world, modelComponent.EntityID); - BlendTree = new ::BlendTree(entityWrapper, Skeleton); + BlendTree = std::shared_ptr<::BlendTree>(new ::BlendTree(entityWrapper, Skeleton)); } } }; @@ -149,7 +149,7 @@ struct ModelJob : RenderJob std::vector<::Skeleton::AnimationData> Animations; ::Skeleton::AnimationOffset AnimationOffset; - ::BlendTree* BlendTree = nullptr; + std::shared_ptr<::BlendTree> BlendTree = nullptr; glm::vec4 DiffuseColor; glm::vec4 SpecularColor; diff --git a/resources/Schema/Entities/AnimationTests2.xml b/resources/Schema/Entities/AnimationTests2.xml index ace71800..659ece9a 100644 --- a/resources/Schema/Entities/AnimationTests2.xml +++ b/resources/Schema/Entities/AnimationTests2.xml @@ -68,6 +68,7 @@ BlendOverride AimAdditive + 1 Models/Characters/Assault/AssaultAnimations.mesh @@ -93,7 +94,7 @@ AimRifle - + 0.5 true @@ -106,6 +107,7 @@ ShootRifleAnimation BlendWalkRun + 0 @@ -124,7 +126,7 @@ Run - + 1 @@ -135,7 +137,7 @@ Walk - + 1 @@ -148,7 +150,7 @@ ShootFastRifle - + 1 diff --git a/src/Engine/Rendering/BlendTree.cpp b/src/Engine/Rendering/BlendTree.cpp index 43d1d5fd..e5fb21a4 100644 --- a/src/Engine/Rendering/BlendTree.cpp +++ b/src/Engine/Rendering/BlendTree.cpp @@ -53,7 +53,25 @@ BlendTree::BlendTree(EntityWrapper ModelEntity, Skeleton* skeleton) BlendTree::~BlendTree() { + Node* currentNode = m_Root; + while (currentNode->Child[0] != nullptr) { + currentNode = currentNode->Child[0]; + } + + std::list m_NodesToRemove; + + while (currentNode != nullptr) { + currentNode = currentNode->Next(); + m_NodesToRemove.push_back(currentNode); + } + + for (auto it = m_NodesToRemove.begin(); it != m_NodesToRemove.end(); it++) { + if ((*it) != nullptr) { + delete (*it); + (*it) = nullptr; + } + } } void BlendTree::PrintTree() diff --git a/src/Engine/Rendering/Skeleton.cpp b/src/Engine/Rendering/Skeleton.cpp index 4745b36d..6a409d3c 100644 --- a/src/Engine/Rendering/Skeleton.cpp +++ b/src/Engine/Rendering/Skeleton.cpp @@ -591,12 +591,14 @@ std::vector Skeleton::OverridePose(std::vector overridePos return finalPose; } - for (int i = 0; i < overridePose.size(); i++) { + for (int i = 0; i < targetPose.size(); i++) { if(overridePose[i] != glm::mat4(1)) { finalPose.push_back(overridePose[i]); } else { finalPose.push_back(targetPose[i]); } + + //finalPose.push_back(overridePose[i]); } return finalPose; From fa4f007604745c8cdf9722d25b7486e4835e0007 Mon Sep 17 00:00:00 2001 From: Teejoon Date: Mon, 22 Feb 2016 18:35:00 +0100 Subject: [PATCH 037/252] Changed name from Indicator to SpriteIndicator. Can now be an indicator for a single team or every one --- resources/Schema/Components.xsd | 2 +- resources/Schema/Components/Indicator.xml | 4 - .../Schema/Components/SpriteIndicator.xml | 5 + .../{Indicator.xsd => SpriteIndicator.xsd} | 5 +- resources/Schema/Entities/Player.xml | 52 +++++++++-- resources/Schema/Entities/PlayerRed.xml | 59 ++++++++++-- src/Engine/Rendering/RenderSystem.cpp | 92 +++++++++---------- 7 files changed, 151 insertions(+), 68 deletions(-) delete mode 100644 resources/Schema/Components/Indicator.xml create mode 100644 resources/Schema/Components/SpriteIndicator.xml rename resources/Schema/Components/{Indicator.xsd => SpriteIndicator.xsd} (59%) diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index c97f2a06..42abed82 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -44,6 +44,6 @@ - + \ No newline at end of file diff --git a/resources/Schema/Components/Indicator.xml b/resources/Schema/Components/Indicator.xml deleted file mode 100644 index 1dfc0077..00000000 --- a/resources/Schema/Components/Indicator.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - 10 - \ No newline at end of file diff --git a/resources/Schema/Components/SpriteIndicator.xml b/resources/Schema/Components/SpriteIndicator.xml new file mode 100644 index 00000000..cbed22f0 --- /dev/null +++ b/resources/Schema/Components/SpriteIndicator.xml @@ -0,0 +1,5 @@ + + + 10 + false + \ No newline at end of file diff --git a/resources/Schema/Components/Indicator.xsd b/resources/Schema/Components/SpriteIndicator.xsd similarity index 59% rename from resources/Schema/Components/Indicator.xsd rename to resources/Schema/Components/SpriteIndicator.xsd index 5015b13c..bd8c1038 100644 --- a/resources/Schema/Components/Indicator.xsd +++ b/resources/Schema/Components/SpriteIndicator.xsd @@ -3,13 +3,16 @@ - + Billbord a Sprite around global Y axis + + Add a Team component to this Entity or Parent to make it visible only for that team + diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index d4485112..e68c0dd8 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -13,6 +13,7 @@ + @@ -60,6 +61,7 @@ Textures/Weapons/Crosshair/SmallThickHoleDot.png false + @@ -110,6 +112,7 @@ Textures/HealthHUD3.png + @@ -135,6 +138,7 @@ Textures/Core/UnitHexagon.png + @@ -152,6 +156,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -167,6 +172,7 @@ Textures/Core/UnitHexagon.png + @@ -185,6 +191,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -200,6 +207,7 @@ Textures/Core/UnitHexagon.png + @@ -217,6 +225,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -232,6 +241,7 @@ Textures/Core/UnitHexagon.png + @@ -249,6 +259,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -264,6 +275,7 @@ Textures/Core/UnitHexagon.png + @@ -279,6 +291,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -304,6 +317,7 @@ + Fonts/DroidSans.ttf,64 @@ -316,6 +330,7 @@ + Fonts/DroidSans.ttf,64 @@ -330,6 +345,7 @@ + Fonts/DroidSans.ttf,64 @@ -349,8 +365,10 @@ Idle - 1.8314163732853146 + 1.1964538350402378 1 + + Models/Characters/Assault/FirstPerson.mesh @@ -368,8 +386,8 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - + + @@ -406,6 +424,7 @@ Textures/Core/UnitHexagon.png + @@ -475,8 +494,10 @@ Idle - 0.16333512901638159 + 0.59503633283673452 1 + + AimRifle @@ -499,8 +520,8 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - + + @@ -570,6 +591,25 @@ + + + + Textures/Icons/Arrow.png + false + + + + + + 30 + true + + + + + + + diff --git a/resources/Schema/Entities/PlayerRed.xml b/resources/Schema/Entities/PlayerRed.xml index 4be8fc26..c45f9280 100644 --- a/resources/Schema/Entities/PlayerRed.xml +++ b/resources/Schema/Entities/PlayerRed.xml @@ -13,6 +13,7 @@ + @@ -60,6 +61,7 @@ Textures/Weapons/Crosshair/SmallThickHoleDot.png false + @@ -110,6 +112,7 @@ Textures/HealthHUD3.png + @@ -135,6 +138,7 @@ Textures/Core/UnitHexagon.png + @@ -152,6 +156,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -167,6 +172,7 @@ Textures/Core/UnitHexagon.png + @@ -185,6 +191,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -200,6 +207,7 @@ Textures/Core/UnitHexagon.png + @@ -217,6 +225,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -232,6 +241,7 @@ Textures/Core/UnitHexagon.png + @@ -249,6 +259,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -264,6 +275,7 @@ Textures/Core/UnitHexagon.png + @@ -279,6 +291,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -304,6 +317,7 @@ + Fonts/DroidSans.ttf,64 @@ -316,6 +330,7 @@ + Fonts/DroidSans.ttf,64 @@ -330,6 +345,7 @@ + Fonts/DroidSans.ttf,64 @@ -349,8 +365,10 @@ Idle - 0.018170670865885086 + 1.9065361003781902 1 + + Models/Characters/Assault/FirstPerson.mesh @@ -368,8 +386,8 @@ Models/Weapons/Red/AssaultWeaponRed.mesh - - + + @@ -406,6 +424,7 @@ Textures/Core/UnitHexagon.png + @@ -475,8 +494,10 @@ Idle - 0.11675631578762591 + 0.62178782386743592 1 + + AimRifle @@ -499,8 +520,8 @@ Models/Weapons/Red/AssaultWeaponRed.mesh - - + + @@ -570,6 +591,32 @@ + + + + + + + + + + + Textures/Icons/Arrow.png + false + + + + + + 30 + true + + + + + + + diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index a0534fed..7b0ea84f 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -52,40 +52,39 @@ void RenderSystem::fillSprites(std::list>& jobs, Worl continue; } - std::string diffuseResource = cSprite["DiffuseTexture"]; - std::string glowResource = cSprite["GlowMap"]; - bool depthSorted = cSprite["DepthSort"]; - if (diffuseResource.empty() && glowResource.empty()) { - continue; - } - - float fillPercentage = 0.f; - glm::vec4 fillColor = glm::vec4(0); - if (world->HasComponent(entity.ID, "Fill")) { - auto fillComponent = world->GetComponent(entity.ID, "Fill"); - fillPercentage = (float)(double)fillComponent["Percentage"]; - fillColor = (glm::vec4)fillComponent["Color"]; - } - glm::mat4 modelMatrix; - + + // See a sprite is an SpriteIndicator bool isIndicator = false; - if (world->HasComponent(entity.ID, "Indicator") || entity.FirstParentWithComponent("Indicator").Valid()) + if (world->HasComponent(entity.ID, "SpriteIndicator")) { - EntityWrapper EntityWithIndicator; - if (world->HasComponent(entity.ID, "Indicator")) { - EntityWithIndicator = entity; - } - else { - EntityWithIndicator = entity.FirstParentWithComponent("Indicator"); - } - auto indicator = EntityWithIndicator["Indicator"]; + auto indicator = entity["SpriteIndicator"]; float minScale = (float)(double)indicator["MinScale"]; + bool hasTeam = indicator["VisibleForSingleTeamOnly"]; isIndicator = true; glm::vec3 pos = Transform::AbsolutePosition(entity); + EntityWrapper entityTeam; + if (hasTeam && (entity.HasComponent("Team") || entity.FirstParentWithComponent("Team").Valid()) && m_LocalPlayer.World != nullptr) { + if (!entity.HasComponent("Team")) { + entityTeam = entity.FirstParentWithComponent("Team"); + } + else { + entityTeam = entity; + } + + ComponentWrapper& entityTeamComponent = entityTeam["Team"]; + ComponentWrapper& localComponent = m_LocalPlayer["Team"]; + int entityTeamInt = entityTeamComponent["Team"]; + int localComponentInt = localComponent["Team"]; + int SpectatorInt = localComponent["Team"].Enum("Spectator"); + if (entityTeamInt != localComponentInt && localComponentInt != SpectatorInt) { + continue; + } + } + // Code for check if sprite is inside or outside of screen //glm::vec4 projectedPos = m_Camera->ProjectionMatrix() * m_Camera->ViewMatrix() * glm::vec4(pos, 1.0f); //projectedPos /= projectedPos.w; @@ -142,10 +141,27 @@ void RenderSystem::fillSprites(std::list>& jobs, Worl tranformationMatrix = tranformationMatrix * glm::scale(glm::vec3(minScale / diag, minScale / diag, minScale / diag)); } modelMatrix = tranformationMatrix; - } else { + } + else { modelMatrix = Transform::ModelMatrix(entity.ID, world); } + + std::string diffuseResource = cSprite["DiffuseTexture"]; + std::string glowResource = cSprite["GlowMap"]; + bool depthSorted = cSprite["DepthSort"]; + if (diffuseResource.empty() && glowResource.empty()) { + continue; + } + + float fillPercentage = 0.f; + glm::vec4 fillColor = glm::vec4(0); + if (world->HasComponent(entity.ID, "Fill")) { + auto fillComponent = world->GetComponent(entity.ID, "Fill"); + fillPercentage = (float)(double)fillComponent["Percentage"]; + fillColor = (glm::vec4)fillComponent["Color"]; + } + std::shared_ptr spriteJob = std::shared_ptr(new SpriteJob(cSprite, m_Camera, modelMatrix, world, fillColor, fillPercentage, depthSorted, isIndicator)); jobs.push_back(spriteJob); @@ -168,30 +184,6 @@ bool RenderSystem::isEntityVisible(EntityWrapper& entity) ) { return false; } - - // If a sprite is an Indicator, it's not local on player and object is in the same team, then dispaly it - if ( - entity.HasComponent("Indicator") - && !entity.IsChildOf(m_LocalPlayer) - && (entity.HasComponent("Team") || entity.FirstParentWithComponent("Team").Valid()) - && entity.HasComponent("Sprite") - && m_LocalPlayer.World != nullptr - ) { - EntityWrapper entityTeam; - if (!entity.HasComponent("Team")) { - entityTeam = entity.FirstParentWithComponent("Team"); - } else { - entityTeam = entity; - } - ComponentWrapper& entityTeamComponent = entityTeam["Team"]; - ComponentWrapper& localComponent = m_LocalPlayer["Team"]; - int entityTeamInt = entityTeamComponent["Team"]; - int localComponentInt = localComponent["Team"]; - int SpectatorInt = localComponent["Team"].Enum("Spectator"); - if (entityTeamInt != localComponentInt && localComponentInt != SpectatorInt) { - return false; - } - } return true; } From fe3e0bac5bf86d54a374c3622b520d063e634a0b Mon Sep 17 00:00:00 2001 From: Teejoon Date: Mon, 22 Feb 2016 18:45:02 +0100 Subject: [PATCH 038/252] Changed SpritIndicator values on player --- resources/Schema/Entities/Player.xml | 15 ++++---- resources/Schema/Entities/PlayerRed.xml | 46 +++++++++++-------------- 2 files changed, 28 insertions(+), 33 deletions(-) diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index e68c0dd8..48adffac 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -365,7 +365,7 @@ Idle - 1.1964538350402378 + 0.97725610639912475 1 @@ -386,8 +386,8 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - + + @@ -494,7 +494,7 @@ Idle - 0.59503633283673452 + 0.87583812735846323 1 @@ -520,8 +520,8 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - + + @@ -601,11 +601,12 @@ - 30 + 50 true + diff --git a/resources/Schema/Entities/PlayerRed.xml b/resources/Schema/Entities/PlayerRed.xml index c45f9280..cd01632e 100644 --- a/resources/Schema/Entities/PlayerRed.xml +++ b/resources/Schema/Entities/PlayerRed.xml @@ -365,7 +365,7 @@ Idle - 1.9065361003781902 + 1.2667383999985162 1 @@ -386,8 +386,8 @@ Models/Weapons/Red/AssaultWeaponRed.mesh - - + + @@ -494,7 +494,7 @@ Idle - 0.62178782386743592 + 0.26532318661337229 1 @@ -520,8 +520,8 @@ Models/Weapons/Red/AssaultWeaponRed.mesh - - + + @@ -591,31 +591,25 @@ - + + + Textures/Icons/Arrow.png + false + + + + + + 50 + true + + - - - - - Textures/Icons/Arrow.png - false - - - - - - 30 - true - - - - - - + From 91b0ac5fbde7fc731be49eda31b1c668ca8d0c6e Mon Sep 17 00:00:00 2001 From: Tleety Date: Tue, 23 Feb 2016 16:00:43 +0100 Subject: [PATCH 039/252] Some groundwork for cubemaps. --- assets | 2 +- include/Engine/Rendering/CubeMapPass.h | 26 +++++++++++++++ include/Engine/Rendering/DrawFinalPass.h | 5 ++- include/Engine/Rendering/Renderer.h | 2 ++ include/Engine/Rendering/Texture.h | 1 + resources/Shaders/ForwardPlus.frag.glsl | 8 +++-- src/Engine/Rendering/CubeMapPass.cpp | 39 +++++++++++++++++++++++ src/Engine/Rendering/DrawBloomPass.cpp | 2 ++ src/Engine/Rendering/DrawFinalPass.cpp | 33 +++++++++++++++++-- src/Engine/Rendering/PickingPass.cpp | 3 ++ src/Engine/Rendering/PickingPassState.cpp | 5 +-- src/Engine/Rendering/Renderer.cpp | 12 ++++--- src/Engine/Rendering/Texture.cpp | 2 ++ 13 files changed, 126 insertions(+), 14 deletions(-) create mode 100644 include/Engine/Rendering/CubeMapPass.h create mode 100644 src/Engine/Rendering/CubeMapPass.cpp diff --git a/assets b/assets index 1e7adc74..ba8e04f1 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 1e7adc749e02144615a20a82c847d3c8df46ee3d +Subproject commit ba8e04f12be11034464b8446331286196953bb84 diff --git a/include/Engine/Rendering/CubeMapPass.h b/include/Engine/Rendering/CubeMapPass.h new file mode 100644 index 00000000..564329e2 --- /dev/null +++ b/include/Engine/Rendering/CubeMapPass.h @@ -0,0 +1,26 @@ +#ifndef CubeMapPass_h__ +#define CubeMapPass_h__ + +#include "IRenderer.h" +#include "ShaderProgram.h" + +class CubeMapPass +{ +public: + CubeMapPass(IRenderer* renderer); + ~CubeMapPass() { } + + void LoadTextures(); + void FillCubeMap(glm::vec3 originPosition); + void GenerateCubeMapTexture(); + + //GLuint CubeMapTexture() const { return m_CubeMapTexture; } + GLuint m_CubeMapTexture; + +private: + IRenderer* m_Renderer; + + std::vector m_CubeMapTestTextures; +}; + +#endif \ No newline at end of file diff --git a/include/Engine/Rendering/DrawFinalPass.h b/include/Engine/Rendering/DrawFinalPass.h index e3389471..1800c90e 100644 --- a/include/Engine/Rendering/DrawFinalPass.h +++ b/include/Engine/Rendering/DrawFinalPass.h @@ -4,6 +4,7 @@ #include "IRenderer.h" #include "DrawFinalPassState.h" #include "LightCullingPass.h" +#include "CubeMapPass.h" #include "FrameBuffer.h" #include "ShaderProgram.h" #include "Util/UnorderedMapVec2.h" @@ -13,7 +14,7 @@ class DrawFinalPass { public: - DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass); + DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass); ~DrawFinalPass() { } void InitializeTextures(); void InitializeFrameBuffers(); @@ -62,12 +63,14 @@ private: GLuint m_SceneTextureLowRes; GLuint m_DepthBuffer; GLuint m_DepthBufferLowRes; + GLuint m_CubeMapTexture; //maqke this component based i guess? GLuint m_ShieldPixelRate = 16; const IRenderer* m_Renderer; const LightCullingPass* m_LightCullingPass; + const CubeMapPass* m_CubeMapPass; ShaderProgram* m_ForwardPlusProgram; ShaderProgram* m_ExplosionEffectProgram; diff --git a/include/Engine/Rendering/Renderer.h b/include/Engine/Rendering/Renderer.h index aa87536b..720336aa 100644 --- a/include/Engine/Rendering/Renderer.h +++ b/include/Engine/Rendering/Renderer.h @@ -17,6 +17,7 @@ #include "DrawBloomPass.h" #include "DrawColorCorrectionPass.h" #include "SSAOPass.h" +#include "CubeMapPass.h" #include "../Core/EventBroker.h" #include "ImGuiRenderPass.h" #include "Camera.h" @@ -74,6 +75,7 @@ private: DrawBloomPass* m_DrawBloomPass; DrawColorCorrectionPass* m_DrawColorCorrectionPass; SSAOPass* m_SSAOPass; + CubeMapPass* m_CubeMapPass; //----------------------Functions----------------------// void InitializeWindow(); diff --git a/include/Engine/Rendering/Texture.h b/include/Engine/Rendering/Texture.h index 0fe650b3..d159e636 100644 --- a/include/Engine/Rendering/Texture.h +++ b/include/Engine/Rendering/Texture.h @@ -18,6 +18,7 @@ public: void Bind(GLenum textureUnit = GL_TEXTURE0); GLuint m_Texture = 0; + unsigned char* Data = nullptr; }; diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index f9b93091..78f2106f 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -22,6 +22,7 @@ layout (binding = 1) uniform sampler2D DiffuseTexture; layout (binding = 2) uniform sampler2D NormalMapTexture; layout (binding = 3) uniform sampler2D SpecularMapTexture; layout (binding = 4) uniform sampler2D GlowMapTexture; +layout (binding = 5) uniform samplerCube CubeMap; #define TILE_SIZE 16 @@ -132,7 +133,9 @@ void main() vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate * NormalUVRepeat, NormalMapTexture); normal = normalize(normal); //vec4 normal = normalize(V * vec4(Input.Normal, 0.0)); - vec4 viewVec = normalize(-position); + vec4 viewVec = normalize(-position); + vec3 R = reflect(-viewVec.xyz, normal.xyz); + vec4 reflectionColor = texture(CubeMap, R); vec2 tilePos; tilePos.x = int(gl_FragCoord.x/TILE_SIZE); @@ -171,7 +174,8 @@ void main() if(pos <= FillPercentage) { color_result += FillColor; } - sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1)); + //sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1)); + sceneColor = vec4(reflectionColor.xyz, 1); color_result += glowTexel*GlowIntensity; bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), clamp(color_result.a, 0, 1)); diff --git a/src/Engine/Rendering/CubeMapPass.cpp b/src/Engine/Rendering/CubeMapPass.cpp new file mode 100644 index 00000000..153d8eb8 --- /dev/null +++ b/src/Engine/Rendering/CubeMapPass.cpp @@ -0,0 +1,39 @@ +#include "Rendering/CubeMapPass.h" + +CubeMapPass::CubeMapPass(IRenderer* renderer) + :m_Renderer(renderer) +{ + LoadTextures(); + GenerateCubeMapTexture(); +} + +/* + +*/ + +void CubeMapPass::LoadTextures() +{ + for (int i = 0; i < 6; i++){ + std::string str; + str = "Textures/Test/CubeMap/CubeMapTest0" + std::to_string(i) + ".png"; + Texture* img = ResourceManager::Load(str); + m_CubeMapTestTextures.push_back(img); + } +} + +void CubeMapPass::GenerateCubeMapTexture() +{ + glGenTextures(1, &m_CubeMapTexture); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapTexture); + + for (int i = 0; i < 6; i++) { + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA32F, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_CubeMapTestTextures[i]->Data); + } + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + GLERROR("Generate Cubemap"); +} + diff --git a/src/Engine/Rendering/DrawBloomPass.cpp b/src/Engine/Rendering/DrawBloomPass.cpp index 6bfb58eb..e8ad4cd5 100644 --- a/src/Engine/Rendering/DrawBloomPass.cpp +++ b/src/Engine/Rendering/DrawBloomPass.cpp @@ -52,6 +52,7 @@ void DrawBloomPass::InitializeBuffers() void DrawBloomPass::ClearBuffer() { + GLERROR("PRE"); m_GaussianFrameBuffer_horiz.Bind(); glClearColor(0.f, 0.f, 0.f, 0.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -60,6 +61,7 @@ void DrawBloomPass::ClearBuffer() glClearColor(0.f, 0.f, 0.f, 0.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); m_GaussianFrameBuffer_vert.Unbind(); + GLERROR("END"); } void DrawBloomPass::Draw(GLuint texture) diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index c16caa24..e7982a3d 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -1,10 +1,11 @@ #include "Rendering/DrawFinalPass.h" -DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass) +DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass) + : m_Renderer(renderer) + , m_LightCullingPass(lightCullingPass) + , m_CubeMapPass(cubeMapPass) { //TODO: Make sure that uniforms are not sent into shader if not needed. - m_Renderer = renderer; - m_LightCullingPass = lightCullingPass; m_ShieldPixelRate = 8; InitializeTextures(); InitializeShaderPrograms(); @@ -261,20 +262,35 @@ void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture) void DrawFinalPass::ClearBuffer() { + GLERROR("PRE"); m_FinalPassFrameBufferLowRes.Bind(); + GLERROR("Bind LowRes"); + glViewport(0, 0, m_Renderer->GetViewportSize().Width/m_ShieldPixelRate, m_Renderer->GetViewportSize().Height/m_ShieldPixelRate); glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); + GLERROR("ViewPort,Scissor LowRes"); + glClearColor(0.f, 0.f, 0.f, 0.f); + GLERROR("1"); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + GLERROR("2"); + glDisable(GL_SCISSOR_TEST); + GLERROR("3"); + m_FinalPassFrameBufferLowRes.Unbind(); + GLERROR("prebind HighRes"); m_FinalPassFrameBuffer.Bind(); + GLERROR("Bind HighRes"); glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); + GLERROR("ViewPort,Scissor LowRes"); glClearColor(0.f, 0.f, 0.f, 0.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); m_FinalPassFrameBuffer.Unbind(); + GLERROR("END"); } @@ -358,12 +374,15 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& case RawModel::MaterialType::SingleTextures: { if (explosionEffectJob->Model->IsSkinned()) { + m_ExplosionEffectSkinnedProgram->Bind(); GLERROR("Bind ExplosionEffectSkinned program"); //bind uniforms BindExplosionUniforms(explosionSkinnedHandle, explosionEffectJob, scene); //bind textures BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); std::vector frameBones; if (explosionEffectJob->AnimationOffset.animation != nullptr) { frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); @@ -378,6 +397,8 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& BindExplosionUniforms(explosionHandle, explosionEffectJob, scene); //bind textures BindExplosionTextures(explosionHandle, explosionEffectJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); } break; } @@ -436,6 +457,8 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& BindModelUniforms(forwardSkinnedHandle, modelJob, scene); //bind textures BindModelTextures(forwardSkinnedHandle, modelJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); std::vector frameBones; if (modelJob->AnimationOffset.animation != nullptr) { frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); @@ -451,6 +474,8 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& BindModelUniforms(forwardHandle, modelJob, scene); //bind textures BindModelTextures(forwardHandle, modelJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); } break; } @@ -809,6 +834,8 @@ void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr& job) { + + switch (job->Type) { case RawModel::MaterialType::SingleTextures: case RawModel::MaterialType::Basic: diff --git a/src/Engine/Rendering/PickingPass.cpp b/src/Engine/Rendering/PickingPass.cpp index d1ed73dd..e0288348 100644 --- a/src/Engine/Rendering/PickingPass.cpp +++ b/src/Engine/Rendering/PickingPass.cpp @@ -64,6 +64,7 @@ void PickingPass::InitializeShaderPrograms() void PickingPass::Draw(RenderScene& scene) { + GLERROR("PRE"); PickingPassState* state = new PickingPassState(m_PickingBuffer.GetHandle()); //TODO: Render: Add code for more jobs than modeljobs. @@ -367,6 +368,7 @@ void PickingPass::Draw(RenderScene& scene) void PickingPass::ClearPicking() { + GLERROR("PRE"); m_PickingColorsToEntity.clear(); m_EntityColors.clear(); m_ColorCounter[0] = 0; @@ -376,6 +378,7 @@ void PickingPass::ClearPicking() glClearColor(0.f, 0.f, 0.f, 0.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); m_PickingBuffer.Unbind(); + GLERROR("END"); } diff --git a/src/Engine/Rendering/PickingPassState.cpp b/src/Engine/Rendering/PickingPassState.cpp index 0c4f4aca..f2d42bff 100644 --- a/src/Engine/Rendering/PickingPassState.cpp +++ b/src/Engine/Rendering/PickingPassState.cpp @@ -3,9 +3,9 @@ PickingPassState::PickingPassState(GLuint frameBuffer) { - GLERROR("---2"); + GLERROR("PRE"); BindFramebuffer(frameBuffer); - GLERROR("---3"); + GLERROR("Bind Framebuffer"); Enable(GL_DEPTH_TEST); Enable(GL_CULL_FACE); Disable(GL_BLEND); @@ -13,6 +13,7 @@ PickingPassState::PickingPassState(GLuint frameBuffer) glm::vec4 clearColor = glm::vec4(0.f); //ClearColor(clearColor); //Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + GLERROR("END"); } PickingPassState::~PickingPassState() diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index 0c668cad..8391599c 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -30,6 +30,7 @@ void Renderer::glfwFrameBufferCallback(GLFWwindow* window, int width, int height currentRenderer->m_LightCullingPass->OnWindowResize(); currentRenderer->m_PickingPass->OnWindowResize(); currentRenderer->m_DrawBloomPass->OnWindowResize(); + //TODO: CubeMapPass->OnWindowResize //If needed } void Renderer::InitializeWindow() @@ -88,9 +89,6 @@ void Renderer::InitializeShaders() //m_ExplosionEffectProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/ExplosionEffect.frag.glsl"))); //m_ExplosionEffectProgram->Compile(); //m_ExplosionEffectProgram->Link(); - - - } void Renderer::InputUpdate(double dt) @@ -108,6 +106,7 @@ void Renderer::Update(double dt) void Renderer::Draw(RenderFrame& frame) { + GLERROR("PRE"); ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking\0Ambient Occlusion"); ImGui::SliderFloat("SSAO sample radius", &m_SSAO_Radius, 0.01f, 5.0f); @@ -117,6 +116,7 @@ void Renderer::Draw(RenderFrame& frame) ImGui::SliderInt("SSAO Number of Samples", &m_SSAO_NumOfSamples, 2, 100); ImGui::SliderInt("SSAO Number of Turns", &m_SSAO_NumOfTurns, 0, 50); m_SSAOPass->Setting(m_SSAO_Radius, m_SSAO_Bias, m_SSAO_Contrast, m_SSAO_IntensityScale, m_SSAO_NumOfSamples, m_SSAO_NumOfTurns); + GLERROR("SSAO Settings"); //clear buffer 0 glClearColor(0.f, 0.f, 0.f, 0.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -127,6 +127,7 @@ void Renderer::Draw(RenderFrame& frame) m_DrawFinalPass->ClearBuffer(); m_DrawBloomPass->ClearBuffer(); PerformanceTimer::StopTimer("Renderer-ClearBuffers"); + GLERROR("ClearBuffers"); for (auto scene : frame.RenderScenes) { PerformanceTimer::StartTimer("Renderer-Depth"); m_PickingPass->Draw(*scene); @@ -239,9 +240,10 @@ void Renderer::InitializeRenderPasses() { m_PickingPass = new PickingPass(this, m_EventBroker); m_LightCullingPass = new LightCullingPass(this); - m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass); + m_CubeMapPass = new CubeMapPass(this); + m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass); m_DrawScreenQuadPass = new DrawScreenQuadPass(this); m_DrawBloomPass = new DrawBloomPass(this); m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this); - m_SSAOPass = new SSAOPass(this); + m_SSAOPass = new SSAOPass(this); } diff --git a/src/Engine/Rendering/Texture.cpp b/src/Engine/Rendering/Texture.cpp index 256246a9..03347044 100644 --- a/src/Engine/Rendering/Texture.cpp +++ b/src/Engine/Rendering/Texture.cpp @@ -18,6 +18,7 @@ Texture::Texture(std::string path) this->Width = img->Width; this->Height = img->Height; + this->Data = img->Data; GLint format; switch (img->Format) { @@ -28,6 +29,7 @@ Texture::Texture(std::string path) format = GL_RGBA; break; } + // Construct the OpenGL texture glGenTextures(1, &m_Texture); From 606a9bf94f25cf3c2bd4fa93b7a4c7a7c3ac4964 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Tue, 23 Feb 2016 17:06:41 +0100 Subject: [PATCH 040/252] BlendTree now working but has some memory leaks --- include/Engine/Rendering/BlendTree.h | 5 +- include/Engine/Rendering/Skeleton.h | 14 +- resources/Schema/Components/BlendOverride.xml | 1 - resources/Schema/Components/BlendOverride.xsd | 1 - resources/Schema/Entities/AnimationTests2.xml | 112 ++++++----- src/Engine/Rendering/BlendTree.cpp | 64 ++++--- src/Engine/Rendering/Skeleton.cpp | 181 ++++++++++++------ 7 files changed, 243 insertions(+), 135 deletions(-) diff --git a/include/Engine/Rendering/BlendTree.h b/include/Engine/Rendering/BlendTree.h index 431cb8b2..694776a1 100644 --- a/include/Engine/Rendering/BlendTree.h +++ b/include/Engine/Rendering/BlendTree.h @@ -26,7 +26,8 @@ public: Node* Parent = nullptr; Node* Child[2] = { nullptr, nullptr }; NodeType Type; - std::vector Pose; + std::map Pose; + //std::vector Pose; float Weight = 0.f; Node* Next() { @@ -69,7 +70,7 @@ private: void FillTree(Node* parentNode, EntityWrapper parentEntity, Skeleton* skeleton); BlendTree::Node* FillTreeByName(Node* parentNode, std::string name, EntityWrapper parentEntity, Skeleton* skeleton); - void Blend(Skeleton* skeleton, std::vector& pose); + void Blend(Skeleton* skeleton, std::map& pose); }; #endif diff --git a/include/Engine/Rendering/Skeleton.h b/include/Engine/Rendering/Skeleton.h index 58021416..e380b6f2 100644 --- a/include/Engine/Rendering/Skeleton.h +++ b/include/Engine/Rendering/Skeleton.h @@ -111,7 +111,7 @@ public: std::vector GetFrameBones(); - std::vector GetFrameBones(const Animation* animation, double time, bool additive, bool noRootMotion = false); + std::map GetFrameBones(const Animation* animation, double time, bool additive, bool noRootMotion = false); void AccumulateBoneTransforms(bool noRootMotion, const Animation* animation, double time, std::map& boneMatrices, bool additive, const Bone* bone, glm::mat4 parentMatrix); const Animation* GetAnimation(std::string name); @@ -124,11 +124,17 @@ public: glm::mat4 GetBoneTransform(bool noRootMotion, const Bone* bone, std::vector animations, glm::mat4 childMatrix); - std::vector BlendPoses(std::vector pose1, std::vector pose2, float weight); - std::vector OverridePose(std::vector overridePose, std::vector targetPose); + std::map BlendPoses(std::map pose1, std::map pose2, float weight); + std::map OverridePose(std::map overridePose, std::map targetPose); + std::map BlendPoseAdditive(std::map additivePose, std::map targetPose); + + std::vector GetFinalPose(std::map& boneMatrices); + void AccumulateFinalPose(std::map& boneMatrices, const Bone* bone, glm::mat4 parentMatrix); + + void AdditiveBoneTransforms(const Animation* animation, double time, std::map& boneMatrices, const Bone* bone); private: - glm::mat4 GetOffsetTransform(const Bone* bone, AnimationOffset animationOffset); + glm::mat4 GetAdditiveBonePose(const Bone* bone, const Animation* animation, double time); glm::mat4 GetBonePose(const Bone* bone, const Animation* animation, double time, bool noRootMotion); std::map m_BonesByName; diff --git a/resources/Schema/Components/BlendOverride.xml b/resources/Schema/Components/BlendOverride.xml index a9f2095a..c44a2d22 100644 --- a/resources/Schema/Components/BlendOverride.xml +++ b/resources/Schema/Components/BlendOverride.xml @@ -2,5 +2,4 @@ - 1.0 \ No newline at end of file diff --git a/resources/Schema/Components/BlendOverride.xsd b/resources/Schema/Components/BlendOverride.xsd index 27fc01ed..8cf6dbd6 100644 --- a/resources/Schema/Components/BlendOverride.xsd +++ b/resources/Schema/Components/BlendOverride.xsd @@ -7,7 +7,6 @@ - diff --git a/resources/Schema/Entities/AnimationTests2.xml b/resources/Schema/Entities/AnimationTests2.xml index 659ece9a..40761b13 100644 --- a/resources/Schema/Entities/AnimationTests2.xml +++ b/resources/Schema/Entities/AnimationTests2.xml @@ -65,11 +65,10 @@ - - BlendOverride - AimAdditive - 1 - + + AimAdditive + BlendOverride + Models/Characters/Assault/AssaultAnimations.mesh @@ -93,9 +92,8 @@ - AimRifle - - 0.5 + AimRifleA + true @@ -106,57 +104,79 @@ ShootRifleAnimation - BlendWalkRun - 0 + MovementBlend - - - - RunAnimtaion - WalkAnimation - 1 - - - - - - - - Run - - 1 - - - - - - - - - Walk - - 1 - - - - - - - - ShootFastRifle - + ShootFastRifleU + 1 + + + + BlendWalkRun + StrafeAnimation + 1 + + + + + + + + StrafeRightF + + 1 + + + + + + + + + RunAnimtaion + WalkAnimation + 0.43000054359436035 + + + + + + + + RunF + + 1 + + + + + + + + + WalkF + + 1 + + + + + + + + + diff --git a/src/Engine/Rendering/BlendTree.cpp b/src/Engine/Rendering/BlendTree.cpp index e5fb21a4..a5f10188 100644 --- a/src/Engine/Rendering/BlendTree.cpp +++ b/src/Engine/Rendering/BlendTree.cpp @@ -130,6 +130,7 @@ void BlendTree::FillTree(Node* parentNode, EntityWrapper parentEntity, Skeleton* node->Name = childEntity.Name(); node->Parent = parentNode; node->Type = NodeType::Blend; + (double&)childEntity["Blend"]["Weight"] = glm::clamp((float)(double)childEntity["Blend"]["Weight"], 0.f, 1.f); node->Weight = (double)childEntity["Blend"]["Weight"]; parentNode->Child[childIndex] = node; childIndex++; @@ -183,6 +184,7 @@ BlendTree::Node* BlendTree::FillTreeByName(Node* parentNode, std::string name, E node->Name = childEntity.Name(); node->Parent = parentNode; node->Type = NodeType::Blend; + (double&)childEntity["Blend"]["Weight"] = glm::clamp((float)(double)childEntity["Blend"]["Weight"], 0.f, 1.f); node->Weight = (double)childEntity["Blend"]["Weight"]; node->Child[0] = FillTreeByName(node, (std::string)childEntity["Blend"]["Pose1"], childEntity, skeleton); node->Child[1] = FillTreeByName(node, (std::string)childEntity["Blend"]["Pose2"], childEntity, skeleton); @@ -208,7 +210,7 @@ BlendTree::Node* BlendTree::FillTreeByName(Node* parentNode, std::string name, E return nullptr; } -void BlendTree::Blend(Skeleton* skeleton, std::vector& pose) +void BlendTree::Blend(Skeleton* skeleton, std::map& pose) { Node* currentNode; Node* start = m_Root; @@ -220,30 +222,37 @@ void BlendTree::Blend(Skeleton* skeleton, std::vector& pose) LOG_INFO("\n\n"); while (m_Root->Pose.size() == 0) { if(currentNode->Pose.size() == 0) { - if(currentNode->Child[0]->Pose.size() != 0 && currentNode->Child[1]->Pose.size() != 0) { + if (currentNode->Child[0] != nullptr && currentNode->Child[1] != nullptr) { + if (currentNode->Child[0]->Pose.size() != 0 && currentNode->Child[1]->Pose.size() != 0) { - switch (currentNode->Type) { - case BlendTree::NodeType::Additive: - currentNode->Pose = skeleton->BlendPoses(currentNode->Child[0]->Pose, currentNode->Child[1]->Pose, currentNode->Weight); - break; - case BlendTree::NodeType::Blend: - currentNode->Pose = skeleton->BlendPoses(currentNode->Child[0]->Pose, currentNode->Child[1]->Pose, currentNode->Weight); - break; - case BlendTree::NodeType::Override: - currentNode->Pose = skeleton->OverridePose(currentNode->Child[0]->Pose, currentNode->Child[1]->Pose); - break; - case BlendTree::NodeType::Animation: - // do nothing - break; + switch (currentNode->Type) { + case BlendTree::NodeType::Additive: + currentNode->Pose = skeleton->BlendPoseAdditive(currentNode->Child[0]->Pose, currentNode->Child[1]->Pose); + break; + case BlendTree::NodeType::Blend: + currentNode->Pose = skeleton->BlendPoses(currentNode->Child[0]->Pose, currentNode->Child[1]->Pose, currentNode->Weight); + break; + case BlendTree::NodeType::Override: + currentNode->Pose = skeleton->OverridePose(currentNode->Child[0]->Pose, currentNode->Child[1]->Pose); + break; + case BlendTree::NodeType::Animation: + // do nothing + break; + } + + LOG_INFO("Blending %s and %s", currentNode->Child[0]->Name.c_str(), currentNode->Child[1]->Name.c_str()); + } + } else if (currentNode->Child[0] != nullptr) { + if (currentNode->Child[0]->Pose.size() != 0) { + currentNode->Pose = currentNode->Child[0]->Pose; + } + } else if (currentNode->Child[1] != nullptr) { + if (currentNode->Child[1]->Pose.size() != 0) { + currentNode->Pose = currentNode->Child[1]->Pose; } - - - LOG_INFO("Blending %s and %s", currentNode->Child[0]->Name.c_str(), currentNode->Child[1]->Name.c_str()); } } - - currentNode = currentNode->Next(); if (currentNode == nullptr) { @@ -257,17 +266,20 @@ void BlendTree::Blend(Skeleton* skeleton, std::vector& pose) std::vector BlendTree::GetBoneTransforms(Skeleton* skeleton) { + std::vector finalPose; if (skeleton == nullptr || m_Root == nullptr) { - std::vector pose; - for (auto& b : skeleton->Bones) { - pose.push_back(glm::mat4(1)); + + for (int i = 0; i < skeleton->Bones.size(); i++) { + finalPose.push_back(glm::mat4(1)); } - return pose; + return finalPose; } - std::vector pose; + std::map pose; Blend(skeleton, pose); - return pose; + finalPose = skeleton->GetFinalPose(pose); + + return finalPose; } diff --git a/src/Engine/Rendering/Skeleton.cpp b/src/Engine/Rendering/Skeleton.cpp index 6a409d3c..e951b3c5 100644 --- a/src/Engine/Rendering/Skeleton.cpp +++ b/src/Engine/Rendering/Skeleton.cpp @@ -49,25 +49,26 @@ std::vector Skeleton::GetFrameBones() } return finalMatrices; } -std::vector Skeleton::GetFrameBones(const Animation* animation, const double time, bool additive, bool noRootMotion /*= false*/) +std::map Skeleton::GetFrameBones(const Animation* animation, const double time, bool additive, bool noRootMotion /*= false*/) { if (animation == nullptr) { - std::vector finalMatrices; + std::map finalMatrices; for (auto& b : Bones) { - finalMatrices.push_back(glm::mat4(1)); + finalMatrices[b.second->ID] = glm::mat4(1); } return finalMatrices; } std::map frameBones; - AccumulateBoneTransforms(true, animation, time, frameBones, additive, RootBone, glm::mat4(1)); - std::vector finalMatrices; - for (auto &kv : frameBones) { - finalMatrices.push_back(kv.second); + if(!additive) { + AccumulateBoneTransforms(true, animation, time, frameBones, additive, RootBone, glm::mat4(1)); + } else { + AdditiveBoneTransforms(animation, time, frameBones, RootBone); } - return finalMatrices; + + return frameBones; } void Skeleton::AccumulateBoneTransforms(bool noRootMotion, const Animation* animation, double time, std::map& boneMatrices, bool additive, const Bone* bone, glm::mat4 parentMatrix) @@ -77,7 +78,7 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, const Animation* anim } glm::mat4 boneMatrix; - + if (animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) { std::vector boneKeyFrames = animation->JointAnimations.at(bone->ID); @@ -118,21 +119,21 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, const Animation* anim position.z = 0; } - boneMatrix = parentMatrix * (glm::translate(position) * glm::toMat4(rotation) * glm::scale(scale)); - boneMatrices[bone->ID] = boneMatrix *bone->OffsetMatrix; + boneMatrix = (glm::translate(position) * glm::toMat4(rotation) * glm::scale(scale)); + boneMatrices[bone->ID] = boneMatrix;// *bone->OffsetMatrix; } else { // 1 keyframes for the current bone currentFrame = boneKeyFrames.at(0); - boneMatrix = parentMatrix * (glm::translate(currentFrame.BoneProperties.Position) * glm::toMat4(currentFrame.BoneProperties.Rotation) * glm::scale(currentFrame.BoneProperties.Scale)); - boneMatrices[bone->ID] = boneMatrix *bone->OffsetMatrix; + boneMatrix = (glm::translate(currentFrame.BoneProperties.Position) * glm::toMat4(currentFrame.BoneProperties.Rotation) * glm::scale(currentFrame.BoneProperties.Scale)); + boneMatrices[bone->ID] = boneMatrix;// *bone->OffsetMatrix; } } else { // 0 keyframes for the current bone if (bone->Parent) { - boneMatrix = parentMatrix * (glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix); - boneMatrices[bone->ID] = boneMatrix *bone->OffsetMatrix; + //boneMatrix = parentMatrix * (glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix); + //boneMatrices[bone->ID] = boneMatrix *bone->OffsetMatrix; } else { - boneMatrix = glm::inverse(bone->OffsetMatrix); - boneMatrices[bone->ID] = parentMatrix; + //boneMatrix = glm::inverse(bone->OffsetMatrix); + //boneMatrices[bone->ID] = parentMatrix; } } @@ -142,22 +143,36 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, const Animation* anim } -glm::mat4 Skeleton::AdditiveBlend(const Bone* bone, AnimationOffset animationOffset, glm::mat4 targetPose) +void Skeleton::AdditiveBoneTransforms(const Animation* animation, double time, std::map& boneMatrices, const Bone* bone) { - AnimationOffset refOffset = animationOffset; - refOffset.time = 0.5f; // reference pose is at 0.5s for now - glm::mat4 refPose = GetOffsetTransform(bone, refOffset); - glm::mat4 srcPose = GetOffsetTransform(bone, animationOffset); - glm::mat4 differencePose = srcPose * glm::inverse(refPose); - glm::mat4 finalPose = differencePose * targetPose; - return finalPose; + if (animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) { + glm::mat4 refPose = GetAdditiveBonePose(bone, animation, 0.0); + glm::mat4 srcPose = GetAdditiveBonePose(bone, animation, time); + glm::mat4 boneMatrix = srcPose * glm::inverse(refPose); + boneMatrices[bone->ID] = boneMatrix; + } + + for (auto &child : bone->Children) { + AdditiveBoneTransforms(animation, time, boneMatrices, child); + } } -glm::mat4 Skeleton::GetOffsetTransform(const Bone* bone, AnimationOffset animationOffset) -{ - const Animation* animation = animationOffset.animation; - float time = animationOffset.time; + +glm::mat4 Skeleton::AdditiveBlend(const Bone* bone, AnimationOffset animationOffset, glm::mat4 targetPose) +{ +/* + AnimationOffset refOffset = animationOffset; + refOffset.time = 0.5f; // reference pose is at 0.5s for now + glm::mat4 refPose = GetAdditiveBonePose(bone, refOffset); + glm::mat4 srcPose = GetAdditiveBonePose(bone, animationOffset); + glm::mat4 differencePose = srcPose * glm::inverse(refPose); + glm::mat4 finalPose = differencePose * targetPose;*/ + return glm::mat4(); +} + +glm::mat4 Skeleton::GetAdditiveBonePose(const Bone* bone, const Animation* animation, double time) +{ glm::vec3 position = glm::vec3(0); glm::quat rotation = glm::quat(); glm::vec3 scale = glm::vec3(1); @@ -559,51 +574,107 @@ return boneMatrix; } -std::vector Skeleton::BlendPoses(std::vector pose1, std::vector pose2, float weight) +std::map Skeleton::BlendPoses(std::map pose1, std::map pose2, float weight) { - std::vector finalPose; + std::map finalPose; - if(pose1.size() != pose2.size()) { - LOG_ERROR("Number of bones does not match"); - return finalPose; - } - - for (int i = 0; i < pose1.size(); i++) { + for (auto& b : Bones) { + int boneID = b.second->ID; glm::mat4 blendedPose = glm::mat4(0); - blendedPose += pose1[i] * weight; - - blendedPose += pose2[i] * (1.f - weight); - - finalPose.push_back(blendedPose); + if(pose1.find(boneID) != pose1.end() && pose2.find(boneID) != pose2.end()) { + blendedPose += pose1.at(boneID) * weight; + blendedPose += pose2.at(boneID) * (1.f - weight); + finalPose[boneID] = blendedPose; + } else if(pose1.find(boneID) != pose1.end()) { + finalPose[boneID] = pose1.at(boneID); + } else if (pose2.find(boneID) != pose2.end()) { + finalPose[boneID] = pose2.at(boneID); + } } return finalPose; } -std::vector Skeleton::OverridePose(std::vector overridePose, std::vector targetPose) +std::map Skeleton::OverridePose(std::map overridePose, std::map targetPose) { - std::vector finalPose; + std::map finalPose; - if (overridePose.size() != targetPose.size()) { - LOG_ERROR("Number of bones does not match"); - return finalPose; - } - - for (int i = 0; i < targetPose.size(); i++) { - if(overridePose[i] != glm::mat4(1)) { - finalPose.push_back(overridePose[i]); - } else { - finalPose.push_back(targetPose[i]); + for (auto& b : Bones) { + int boneID = b.second->ID; + if (overridePose.find(boneID) != overridePose.end()) { + finalPose[boneID] = overridePose.at(boneID); + } else if (targetPose.find(boneID) != targetPose.end()) { + finalPose[boneID] = targetPose.at(boneID); } + } + return finalPose; +} - //finalPose.push_back(overridePose[i]); + +std::map Skeleton::BlendPoseAdditive(std::map additivePose, std::map targetPose) +{ + std::map finalPose; + + for (auto& b : Bones) { + int boneID = b.second->ID; + glm::mat4 blendedPose = glm::mat4(1); + + if (additivePose.find(boneID) != additivePose.end() && targetPose.find(boneID) != targetPose.end()) { + blendedPose = additivePose.at(boneID) * targetPose.at(boneID); + finalPose[boneID] = blendedPose; + + } else if (additivePose.find(boneID) != additivePose.end()) { + finalPose[boneID] = additivePose.at(boneID); + } else if (targetPose.find(boneID) != targetPose.end()) { + finalPose[boneID] = targetPose.at(boneID); + } } return finalPose; } +std::vector Skeleton::GetFinalPose(std::map& boneMatrices) +{ + std::vector finalPose; + + AccumulateFinalPose(boneMatrices, RootBone, glm::mat4(1)); + + + for(auto& b : boneMatrices) { + finalPose.push_back(b.second); + } + + return finalPose; +} + +void Skeleton::AccumulateFinalPose(std::map& boneMatrices, const Bone* bone, glm::mat4 parentMatrix) +{ + + glm::mat4 boneMatrix; + + + if (boneMatrices.find(bone->ID) != boneMatrices.end()) { + + boneMatrix = parentMatrix * boneMatrices.at(bone->ID); + boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix; + + } else { + if (bone->Parent) { + boneMatrix = parentMatrix * (glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix); + boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix; + } else { + boneMatrix = glm::inverse(bone->OffsetMatrix); + boneMatrices[bone->ID] = parentMatrix; + } + } + + for (auto &child : bone->Children) { + AccumulateFinalPose(boneMatrices, child, boneMatrix); + } +} + int Skeleton::GetBoneID(std::string name) { if (m_BonesByName.find(name) == m_BonesByName.end()) { From 8d23c531afc08de9dd39584d84f8016e6498e2ef Mon Sep 17 00:00:00 2001 From: Tleety Date: Tue, 23 Feb 2016 17:17:50 +0100 Subject: [PATCH 041/252] Cubemaps kinda functioning, still somthing wierd with the vectors. --- assets | 2 +- resources/Shaders/ForwardPlus.frag.glsl | 9 ++++++--- src/Engine/Rendering/CubeMapPass.cpp | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/assets b/assets index ba8e04f1..89b40707 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit ba8e04f12be11034464b8446331286196953bb84 +Subproject commit 89b4070731584056402eac071845e9b1a0d156fb diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 78f2106f..1b4d8c1e 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -134,7 +134,8 @@ void main() normal = normalize(normal); //vec4 normal = normalize(V * vec4(Input.Normal, 0.0)); vec4 viewVec = normalize(-position); - vec3 R = reflect(-viewVec.xyz, normal.xyz); + vec3 R = reflect(viewVec.xyz, normal.xyz); + R = vec3(P * vec4(R, 1.0)); vec4 reflectionColor = texture(CubeMap, R); vec2 tilePos; @@ -166,6 +167,8 @@ void main() vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); + float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0; + color_result = color_result * clamp(1/specularTexel, 0, 1) + reflectionColor * clamp(specularTexel, 0, 1); //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; @@ -174,8 +177,8 @@ void main() if(pos <= FillPercentage) { color_result += FillColor; } - //sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1)); - sceneColor = vec4(reflectionColor.xyz, 1); + sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1)); + //sceneColor = vec4(reflectionColor.xyz, 1); color_result += glowTexel*GlowIntensity; bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), clamp(color_result.a, 0, 1)); diff --git a/src/Engine/Rendering/CubeMapPass.cpp b/src/Engine/Rendering/CubeMapPass.cpp index 153d8eb8..cdfc704e 100644 --- a/src/Engine/Rendering/CubeMapPass.cpp +++ b/src/Engine/Rendering/CubeMapPass.cpp @@ -27,7 +27,7 @@ void CubeMapPass::GenerateCubeMapTexture() glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapTexture); for (int i = 0; i < 6; i++) { - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA32F, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_CubeMapTestTextures[i]->Data); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA32F, 1024, 1024, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_CubeMapTestTextures[i]->Data); } glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); From e2831c5593604047cdca3eeb11e0046851176c72 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Tue, 23 Feb 2016 17:29:33 +0100 Subject: [PATCH 042/252] CapturePointSystem fix, DamageIndicatorSystem fix --- include/Game/Systems/DamageIndicatorSystem.h | 16 ++- src/Game/Systems/CapturePointSystem.cpp | 53 ++++---- src/Game/Systems/DamageIndicatorSystem.cpp | 133 ++++++++++++++----- src/Game/Systems/PlayerDeathSystem.cpp | 5 +- src/Tests/HealthSystemTest.h | 1 - 5 files changed, 144 insertions(+), 64 deletions(-) diff --git a/include/Game/Systems/DamageIndicatorSystem.h b/include/Game/Systems/DamageIndicatorSystem.h index 053b196b..49ae249c 100644 --- a/include/Game/Systems/DamageIndicatorSystem.h +++ b/include/Game/Systems/DamageIndicatorSystem.h @@ -15,10 +15,11 @@ #include "Rendering/Util/CommonFunctions.h" -class DamageIndicatorSystem : public System +class DamageIndicatorSystem : public ImpureSystem { public: DamageIndicatorSystem(SystemParams params); + virtual void Update(double dt) override; private: EventRelay m_EPlayerDamage; @@ -28,6 +29,19 @@ private: bool OnSetCamera(const Events::SetCamera& e); EntityID m_CurrentCamera = -1; + struct DamageIndicatorStruct { + EntityWrapper spriteEntity; + glm::vec3 enemyPosition; + DamageIndicatorStruct(EntityWrapper sprite, glm::vec3 pos) + : spriteEntity(sprite) + , enemyPosition(pos) {} + }; + std::vector updateDamageIndicatorVector; + float CalculateAngle(EntityWrapper player, glm::vec3 enemyPos); + //for tests + int m_TestVar = 0; + bool m_Testing = false; + glm::vec3 DamageIndicatorTest(EntityWrapper player); }; #endif diff --git a/src/Game/Systems/CapturePointSystem.cpp b/src/Game/Systems/CapturePointSystem.cpp index 5fdd74cd..e4df9740 100644 --- a/src/Game/Systems/CapturePointSystem.cpp +++ b/src/Game/Systems/CapturePointSystem.cpp @@ -1,32 +1,37 @@ #include "Systems/CapturePointSystem.h" #include -CapturePointSystem::CapturePointSystem(SystemParams params) +CapturePointSystem::CapturePointSystem(SystemParams params) : System(params) , PureSystem("CapturePoint") { //subscribe/listenTo playerdamage,healthpickup events (using the eventBroker) - if (IsClient) { - EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch); - EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave); - EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured); - } + EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch); + EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave); + EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured); + } //here all capturepoints will update their component //NOTE: needs to run each frame, since we're possibly modifying the captureTimer for the capturePoints by dt void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, ComponentWrapper& cCapturePoint, double dt) { - if (!IsClient) { - return; - } - + //if (!IsClient) { + // return; + //} if (m_WinnerWasFound) { return; } const int capturePointNumber = cCapturePoint["CapturePointNumber"]; const bool hasTeamComponent = capturePointEntity.HasComponent("Team"); + if (m_NumberOfCapturePoints != 0) { + if (!m_CapturePointNumberToEntityMap[0].HasComponent("CapturePoint")) { + //if map has changed, the capturepoints has changed, now have to redo them + m_NumberOfCapturePoints = 0; + m_CapturePointNumberToEntityMap.clear(); + } + } //if point doesnt have a teamComponent yet, add one. since: //what if capture point has no team -> we cant get/use the team enum from it... if (!hasTeamComponent) { @@ -71,8 +76,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp std::map nextPossibleCapturePoint; nextPossibleCapturePoint["Red"] = -1; nextPossibleCapturePoint["Blue"] = -1; - for (int i = 0; i < m_NumberOfCapturePoints; i++) - { + for (int i = 0; i < m_NumberOfCapturePoints; i++) { if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) { continue; } @@ -84,8 +88,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp nextPossibleCapturePoint["Blue"] = i + 1; } } - for (int i = m_NumberOfCapturePoints - 1; i >= 0; i--) - { + for (int i = m_NumberOfCapturePoints - 1; i >= 0; i--) { if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) { continue; } @@ -100,8 +103,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp //reset timers and reset the bool that triggers this if (m_ResetTimers) { - for (int i = 0; i < m_NumberOfCapturePoints; i++) - { + for (int i = 0; i < m_NumberOfCapturePoints; i++) { ComponentWrapper& capturePoint = m_CapturePointNumberToEntityMap[i]["CapturePoint"]; if ((int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Red"] && (int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Blue"]) { @@ -116,8 +118,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp } //check how many players are standing inside and are healthy - for (size_t i = m_ETriggerTouchVector.size(); i > 0; i--) - { + for (size_t i = m_ETriggerTouchVector.size(); i > 0; i--) { auto triggerTouched = m_ETriggerTouchVector[i - 1]; if (std::get<1>(triggerTouched) == capturePointEntity) { //some player has touched this - lets figure out: what team, health @@ -176,8 +177,8 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp cCapturePoint["CaptureTimer"] = (double)cCapturePoint["CaptureTimer"] + timerDeltaChange; } //if capturePoint is owned by the team, and the other team has been trying to take it, then increase/decrease the timer towards 0.0 - if ((ownedBy == currentTeam && currentTeam == redTeam && (double)cCapturePoint["CaptureTimer"] < 0.0) || - (ownedBy == currentTeam && currentTeam == blueTeam && (double)cCapturePoint["CaptureTimer"] > 0.0)) { + if ((ownedBy == currentTeam && currentTeam == redTeam && (double)cCapturePoint["CaptureTimer"] < captureTimeToTakeOver) || + (ownedBy == currentTeam && currentTeam == blueTeam && (double)cCapturePoint["CaptureTimer"] > -captureTimeToTakeOver)) { cCapturePoint["CaptureTimer"] = (double)cCapturePoint["CaptureTimer"] + timerDeltaChange; } //check if captureTimer > captureTimeToTakeOver and if so change owner and publish the eCaptured event @@ -195,17 +196,14 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp //check for possible winCondition = check if the homebase is owned by the other team bool checkForWinner = false; - if (capturePointNumber == m_RedTeamHomeCapturePoint && ownedBy != redTeam) - { + if (capturePointNumber == m_RedTeamHomeCapturePoint && ownedBy != redTeam) { checkForWinner = true; } - if (capturePointNumber == m_BlueTeamHomeCapturePoint && ownedBy != blueTeam) - { + if (capturePointNumber == m_BlueTeamHomeCapturePoint && ownedBy != blueTeam) { checkForWinner = true; } - if (checkForWinner && !m_WinnerWasFound) - { + if (checkForWinner && !m_WinnerWasFound) { //publish Win event Events::Win e; e.TeamThatWon = ownedBy; @@ -224,8 +222,7 @@ bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e) bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e) { - for (size_t i = 0; i < m_ETriggerTouchVector.size(); i++) - { + for (size_t i = 0; i < m_ETriggerTouchVector.size(); i++) { auto triggerTouched = m_ETriggerTouchVector[i]; if (std::get<0>(triggerTouched) == e.Entity && std::get<1>(triggerTouched) == e.Trigger) { m_ETriggerTouchVector.erase(m_ETriggerTouchVector.begin() + i); diff --git a/src/Game/Systems/DamageIndicatorSystem.cpp b/src/Game/Systems/DamageIndicatorSystem.cpp index 235eced0..65e1caf0 100644 --- a/src/Game/Systems/DamageIndicatorSystem.cpp +++ b/src/Game/Systems/DamageIndicatorSystem.cpp @@ -12,52 +12,42 @@ DamageIndicatorSystem::DamageIndicatorSystem(SystemParams params) auto entityFile = ResourceManager::Load("Schema/Entities/DamageIndicator.xml"); } +void DamageIndicatorSystem::Update(double dt) { + if (!IsServer) { + for (auto& iter = updateDamageIndicatorVector.begin(); iter != updateDamageIndicatorVector.end(); iter++) { + if (!iter->spriteEntity.Valid()) { + updateDamageIndicatorVector.erase(iter); + break; + } + auto angleBetweenVectors = CalculateAngle(LocalPlayer, iter->enemyPosition); + //simply set the rotation z-wise to the angleBetweenVectors + iter->spriteEntity["Transform"]["Orientation"] = glm::vec3(0, 0, angleBetweenVectors); + } + } +} + bool DamageIndicatorSystem::OnPlayerDamage(Events::PlayerDamage& e) { if (m_CurrentCamera == EntityID_Invalid) { return false; } - //if (e.Victim != LocalPlayer) { - // return false; - //} if (e.Victim.Valid() && e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) { return false; } if (!e.Inflictor.Valid() || !e.Victim.Valid()) { - return false; + return false; } - //grab players direction - auto playerOrientation = glm::quat((glm::vec3)e.Victim["Transform"]["Orientation"]); - - //get the position vectors, but ignore the y-height - auto enemyPosition = (glm::vec3)e.Inflictor["Transform"]["Position"]; - auto playerPosition = (glm::vec3)e.Victim["Transform"]["Position"]; - enemyPosition.y = 0.0f; - playerPosition.y = 0.0f; - - //calculate the enemy to player vector - auto enemyPlayerVector = glm::normalize(playerPosition - enemyPosition); - - //get angle from players current rotation, this angle is how much you rotate around the y-axis - auto playerAngle = glm::angle(playerOrientation); - auto playerRotationVector = glm::normalize(glm::rotateY(glm::vec3(0, 0, 1), playerAngle)); - - //dot product of players direction-vector and enemys-to-playervector will give the cos of the angle between the vectors - auto playerRotationDot = glm::dot(playerRotationVector, enemyPlayerVector); - //to get the angle between the vectors just do cos-inverse - auto angleBetweenVectors = glm::acos(playerRotationDot); - - //rotate the direction-vector 90 degrees to get the players side-vector - auto playerSideVector = glm::normalize(glm::rotateY(glm::vec3(0, 0, 1), playerAngle + 1.57f)); - //dot of sidevector positive = enemy is on the right side, dot sidevector negative = left side - auto playerSideVectorDot = glm::dot(playerSideVector, enemyPlayerVector); - if (playerSideVectorDot < 0) { - angleBetweenVectors = -angleBetweenVectors; + glm::vec3 inflictorPos = e.Inflictor["Transform"]["Position"]; + //if testing + if (m_Testing) { + inflictorPos = DamageIndicatorTest(e.Victim); } + float angleBetweenVectors = CalculateAngle(e.Victim, inflictorPos); + //load & set the "2d" sprite auto entityFile = ResourceManager::Load("Schema/Entities/DamageIndicator.xml"); EntityFileParser parser(entityFile); @@ -67,6 +57,10 @@ bool DamageIndicatorSystem::OnPlayerDamage(Events::PlayerDamage& e) //simply set the rotation z-wise to the angleBetweenVectors spriteWrapper["Transform"]["Orientation"] = glm::vec3(0, 0, angleBetweenVectors); + if (!IsServer) { + updateDamageIndicatorVector.emplace_back(spriteWrapper, inflictorPos); + } + return true; } @@ -74,3 +68,80 @@ bool DamageIndicatorSystem::OnSetCamera(const Events::SetCamera& e) { m_CurrentCamera = e.CameraEntity.ID; return true; } + +float DamageIndicatorSystem::CalculateAngle(EntityWrapper player, glm::vec3 enemyPos) { + //grab players direction + auto playerOrientation = glm::quat((glm::vec3)player["Transform"]["Orientation"]); + + //get the position vectors, but ignore the y-height + auto enemyPosition = enemyPos; + auto playerPosition = (glm::vec3)player["Transform"]["Position"]; + enemyPosition.y = 0.0f; + playerPosition.y = 0.0f; + + //calculate the enemy to player vector + auto enemyPlayerVector = glm::normalize(playerPosition - enemyPosition); + + //get the rotationvector relative to the z-axis + auto rotationVectorVec3 = glm::vec3(glm::toMat4(Transform::AbsoluteOrientation(player))*glm::vec4(0, 0, 1, 0)); + //rotate the direction-vector 90 degrees to get the players side-vector + auto playerSideVector = glm::vec3(glm::rotateY(rotationVectorVec3, 1.57f)); + + //dot product of players direction-vector and enemys-to-playervector will give the cos of the angle between the vectors + auto playerRotationDot = glm::dot(rotationVectorVec3, enemyPlayerVector); + //to get the angle between the vectors just do cos-inverse + auto angleBetweenVectors = glm::acos(playerRotationDot); + + //dot of sidevector positive = enemy is on the right side, dot sidevector negative = left side + auto playerSideVectorDot = glm::dot(playerSideVector, enemyPlayerVector); + if (playerSideVectorDot < 0) { + angleBetweenVectors = -angleBetweenVectors; + } + + return angleBetweenVectors; +} +glm::vec3 DamageIndicatorSystem::DamageIndicatorTest(EntityWrapper player) { + auto currentPos = (glm::vec3)player["Transform"]["Position"]; + + auto testVar = 1; + auto testVar2 = 1; + if (m_TestVar % 4 == 0) { + testVar = -1; + testVar2 = 1; + } + if (m_TestVar % 4 == 1) { + testVar = 1; + testVar2 = 1; + } + if (m_TestVar % 4 == 2) { + testVar *= -1; + testVar2 = -1; + } + if (m_TestVar % 4 == 3) { + testVar = 1; + testVar2 = -1; + } + m_TestVar++; + + auto inflictorPos = glm::vec3(currentPos.x + testVar*6.0f, currentPos.y, currentPos.z + testVar2*6.0f); + + //load the explosioneffect XML + auto deathEffect = ResourceManager::Load("Schema/Entities/PlayerDeathExplosionWithCamera.xml"); + EntityFileParser parser(deathEffect); + EntityID deathEffectID = parser.MergeEntities(m_World); + EntityWrapper deathEffectEW = EntityWrapper(m_World, deathEffectID); + + //components that we need from player + auto playerModel = player.FirstChildByName("PlayerModel"); + auto playerEntityModel = playerModel["Model"]; + auto playerEntityAnimation = playerModel["Animation"]; + + //copy the data from player to explosioneffectmodel + playerEntityModel.Copy(deathEffectEW["Model"]); + playerEntityAnimation.Copy(deathEffectEW["Animation"]); + + //copy the models position,orientation + deathEffectEW["Transform"]["Position"] = inflictorPos; + deathEffectEW["Transform"]["Orientation"] = (glm::vec3)player["Transform"]["Orientation"]; + return inflictorPos; +} diff --git a/src/Game/Systems/PlayerDeathSystem.cpp b/src/Game/Systems/PlayerDeathSystem.cpp index 40a98278..844d2ed1 100644 --- a/src/Game/Systems/PlayerDeathSystem.cpp +++ b/src/Game/Systems/PlayerDeathSystem.cpp @@ -33,9 +33,8 @@ void PlayerDeathSystem::createDeathEffect(EntityWrapper player) EntityWrapper deathEffectEW = EntityWrapper(m_World, deathEffectID); //components that we need from player - auto playerCamera = player.FirstChildByName("Camera"); auto playerModel = player.FirstChildByName("PlayerModel"); - if (!playerCamera.Valid() || !playerModel.Valid()) { + if (!playerModel.Valid()) { return; } if (!playerModel.HasComponent("Model") || !playerModel.HasComponent("Animation")) { @@ -44,7 +43,7 @@ void PlayerDeathSystem::createDeathEffect(EntityWrapper player) auto playerEntityModel = playerModel["Model"]; auto playerEntityAnimation = playerModel["Animation"]; - //copy the data from player to explisioneffectmodel + //copy the data from player to explosioneffectmodel playerEntityModel.Copy(deathEffectEW["Model"]); playerEntityAnimation.Copy(deathEffectEW["Animation"]); //freeze the animation diff --git a/src/Tests/HealthSystemTest.h b/src/Tests/HealthSystemTest.h index 685a06dd..275558d2 100644 --- a/src/Tests/HealthSystemTest.h +++ b/src/Tests/HealthSystemTest.h @@ -6,7 +6,6 @@ #include "Core/EventBroker.h" #include "Rendering/Renderer.h" #include "Core/InputManager.h" -#include "GUI/Frame.h" #include "Core/World.h" #include "Input/InputProxy.h" #include "Input/KeyboardInputHandler.h" From fa13c1d0654f38da20b608733e0294ca36fcaadf Mon Sep 17 00:00:00 2001 From: Jocke Date: Tue, 23 Feb 2016 18:24:46 +0100 Subject: [PATCH 043/252] Double jump is now working. --- include/Engine/Network/Client.h | 11 ++++--- include/Engine/Network/MessageType.h | 1 + include/Engine/Network/Server.h | 10 +++--- include/Game/Events/EDoubleJump.h | 2 +- include/Game/Systems/PlayerMovementSystem.h | 4 +++ src/Engine/Network/Client.cpp | 34 +++++++++++++++++++++ src/Engine/Network/Server.cpp | 15 +++++++-- src/Game/Systems/PlayerMovementSystem.cpp | 34 +++++++++++++++++---- 8 files changed, 93 insertions(+), 18 deletions(-) diff --git a/include/Engine/Network/Client.h b/include/Engine/Network/Client.h index 978c9b65..2b426cf4 100644 --- a/include/Engine/Network/Client.h +++ b/include/Engine/Network/Client.h @@ -21,6 +21,7 @@ #include "Core/ConfigFile.h" #include "Input/EInputCommand.h" #include "Core/EPlayerDamage.h" +#include "../Game/Events/EDoubleJump.h" #include "Network/EInterpolate.h" #include "Network/SnapshotFilter.h" #include "Core/EPlayerSpawned.h" @@ -34,7 +35,9 @@ public: void Connect(std::string address, int port); void Update() override; - +private: + UDPClient m_Unreliable; + TCPClient m_Reliable; std::vector m_PlayerSpawnEvents; void parseSpawnEvents(); // Save for children @@ -86,6 +89,7 @@ public: void parsePlayersSpawned(Packet& packet); void parseEntityDeletion(Packet& packet); void parseComponentDeletion(Packet& packet); + void parseDoubleJump(Packet& packet); void InterpolateFields(Packet & packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType); void parseSnapshot(Packet& packet); void identifyPacketLoss(); @@ -110,9 +114,8 @@ public: EventRelay m_EPlayerSpawned; bool OnPlayerSpawned(const Events::PlayerSpawned& e); void parsePlayerDamage(Packet& packet); -private: - UDPClient m_Unreliable; - TCPClient m_Reliable; + EventRelay m_EPDoubleJump; + bool OnDoubleJump(Events::DoubleJump & e); }; #endif diff --git a/include/Engine/Network/MessageType.h b/include/Engine/Network/MessageType.h index a72f054e..6322b098 100644 --- a/include/Engine/Network/MessageType.h +++ b/include/Engine/Network/MessageType.h @@ -19,6 +19,7 @@ enum class MessageType EntityDeleted, ComponentDeleted, PlayerTransform, + OnDoubleJump, Invalid }; diff --git a/include/Engine/Network/Server.h b/include/Engine/Network/Server.h index b37bffab..dad45120 100644 --- a/include/Engine/Network/Server.h +++ b/include/Engine/Network/Server.h @@ -17,6 +17,7 @@ #include "Core/EPlayerDamage.h" #include "Network/EPlayerDisconnected.h" #include "Core/EPlayerSpawned.h" +#include "../Game/Events/EDoubleJump.h" #include "Core/EEntityDeleted.h" #include "Core/EComponentDeleted.h" @@ -54,7 +55,7 @@ private: std::vector m_InputCommandsToBroadcast; //Timers std::clock_t m_StartPingTime; - + // Packet loss logic PacketID m_PacketID = 0; PacketID m_PreviousPacketID = 0; @@ -77,9 +78,10 @@ private: void parsePlayerTransform(Packet& packet); void parseOnInputCommand(Packet& packet); void parseClientPing(); - void parsePing(); - void parseUDPConnect(Packet & packet); - void parseTCPConnect(Packet & packet); + void parsePing(); + bool parseDoubleJump(Packet& packet); + void parseUDPConnect(Packet& packet); + void parseTCPConnect(Packet& packet); void parseDisconnect(); bool shouldSendToClient(EntityWrapper childEntity); diff --git a/include/Game/Events/EDoubleJump.h b/include/Game/Events/EDoubleJump.h index 767d5b39..f5cad1fd 100644 --- a/include/Game/Events/EDoubleJump.h +++ b/include/Game/Events/EDoubleJump.h @@ -8,7 +8,7 @@ namespace Events struct DoubleJump : public Event { - + EntityID entityID; }; } diff --git a/include/Game/Systems/PlayerMovementSystem.h b/include/Game/Systems/PlayerMovementSystem.h index 2bcae866..a4008777 100644 --- a/include/Game/Systems/PlayerMovementSystem.h +++ b/include/Game/Systems/PlayerMovementSystem.h @@ -34,9 +34,13 @@ private: glm::vec3 m_LastPosition = glm::vec3(); // The logic for making the sound play when player is moving void playerStep(double dt); + // Spawn a hexagon at origin of an Entity + void spawnHexagon(EntityWrapper target); EventRelay m_EPlayerSpawned; bool OnPlayerSpawned(Events::PlayerSpawned& e); + EventRelay m_EPDoubleJump; + bool PlayerMovementSystem::OnDoubleJump(Events::DoubleJump & e); void updateMovementControllers(double dt); void updateVelocity(double dt); diff --git a/src/Engine/Network/Client.cpp b/src/Engine/Network/Client.cpp index a2f52adb..ad72571c 100644 --- a/src/Engine/Network/Client.cpp +++ b/src/Engine/Network/Client.cpp @@ -30,6 +30,7 @@ void Client::Connect(std::string address, int port) EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Client::OnInputCommand); EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &Client::OnPlayerDamage); EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &Client::OnPlayerSpawned); + EVENT_SUBSCRIBE_MEMBER(m_EPDoubleJump, &Client::OnDoubleJump); auto config = ResourceManager::Load("Config.ini"); m_Address = address; if (address.empty()) { @@ -122,6 +123,9 @@ void Client::parseMessageType(Packet& packet) case MessageType::OnPlayerDamage: parsePlayerDamage(packet); break; + case MessageType::OnDoubleJump: + parseDoubleJump(packet); + break; default: break; } @@ -238,6 +242,20 @@ void Client::parseComponentDeletion(Packet & packet) } } +void Client::parseDoubleJump(Packet & packet) +{ + EntityID serverID = packet.ReadPrimitive(); + if (!serverClientMapsHasEntity(serverID)) { + return; + } + Events::DoubleJump e; + e.entityID = m_ServerIDToClientID.at(serverID); + // If player is local player to publish to prevent infinite feedback loop + if (e.entityID != m_LocalPlayer.ID) { + m_EventBroker->Publish(e); + } +} + void Client::updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID) { for (auto field : componentInfo.FieldsInOrder) { @@ -415,6 +433,11 @@ bool Client::OnPlayerDamage(const Events::PlayerDamage & e) if (e.Inflictor != m_LocalPlayer) { return false; } + // Could this happen? + //if (!clientServerMapsHasEntity(e.Inflictor.ID) + // || !clientServerMapsHasEntity(e.Victim.ID)) { + // return; + //} Packet packet(MessageType::OnPlayerDamage, m_SendPacketID); packet.WritePrimitive(m_ClientIDToServerID.at(e.Inflictor.ID)); @@ -450,6 +473,17 @@ void Client::parsePlayerDamage(Packet& packet) } } +bool Client::OnDoubleJump(Events::DoubleJump & e) +{ + if (!clientServerMapsHasEntity(e.entityID) || e.entityID != m_LocalPlayer.ID) { + return false; + } + Packet packet(MessageType::OnDoubleJump); + packet.WritePrimitive(m_ClientIDToServerID.at(e.entityID)); + m_Reliable.Send(packet); + return true; +} + void Client::sendLocalPlayerTransform() { if (!m_LocalPlayer.Valid()) { diff --git a/src/Engine/Network/Server.cpp b/src/Engine/Network/Server.cpp index aa66433b..1a063067 100644 --- a/src/Engine/Network/Server.cpp +++ b/src/Engine/Network/Server.cpp @@ -1,6 +1,6 @@ #include "Network/Server.h" -Server::Server(World* world, EventBroker* eventBroker, int port) +Server::Server(World* world, EventBroker* eventBroker, int port) : Network(world, eventBroker) { ConfigFile* config = ResourceManager::Load("Config.ini"); @@ -120,6 +120,9 @@ void Server::parseMessageType(Packet& packet) case MessageType::PlayerTransform: parsePlayerTransform(packet); break; + case MessageType::OnDoubleJump: + parseDoubleJump(packet); + break; default: break; } @@ -279,7 +282,7 @@ void Server::parseTCPConnect(Packet & packet) // Read packet ID m_PreviousPacketID = m_PacketID; // Set previous packet id m_PacketID = packet.ReadPrimitive(); //Read new packet id - + LOG_INFO("Parsing connections"); // Check if player is already connected // Ska vara till lagd i TCPServer receive @@ -426,7 +429,7 @@ bool Server::OnPlayerDamage(const Events::PlayerDamage& e) packet.WritePrimitive(e.Damage); reliableBroadcast(packet); - return false; + return true; } void Server::parseClientPing() @@ -453,6 +456,12 @@ void Server::parsePing() } } +bool Server::parseDoubleJump(Packet & packet) +{ + reliableBroadcast(packet); + return true; +} + void Server::parseOnInputCommand(Packet& packet) { PlayerID player = -1; diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 71fb16ee..ccd8c558 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -4,6 +4,7 @@ PlayerMovementSystem::PlayerMovementSystem(SystemParams params) : System(params) { EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &PlayerMovementSystem::OnPlayerSpawned); + EVENT_SUBSCRIBE_MEMBER(m_EPDoubleJump, &PlayerMovementSystem::OnDoubleJump); } PlayerMovementSystem::~PlayerMovementSystem() @@ -28,7 +29,6 @@ void PlayerMovementSystem::updateMovementControllers(double dt) if (!player.Valid()) { continue; } - // Aim pitch EntityWrapper cameraEntity = player.FirstChildByName("Camera"); if (cameraEntity.Valid()) { @@ -114,15 +114,14 @@ void PlayerMovementSystem::updateMovementControllers(double dt) if (isOnGround) { controller->SetDoubleJumping(false); } else { + // If IsServer and network is off this will not work if (IsClient) { //put a hexagon at the players feet - auto hexagonEffect = ResourceManager::Load("Schema/Entities/DoubleJumpHexagon.xml"); - EntityFileParser parser(hexagonEffect); - EntityID hexagonEffectID = parser.MergeEntities(m_World); - EntityWrapper hexagonEW = EntityWrapper(m_World, hexagonEffectID); - hexagonEW["Transform"]["Position"] = (glm::vec3)player["Transform"]["Position"]; + spawnHexagon(player); controller->SetDoubleJumping(true); + // Publish event for client to listen to Events::DoubleJump e; + e.entityID = player.ID; m_EventBroker->Publish(e); } } @@ -291,3 +290,26 @@ bool PlayerMovementSystem::OnPlayerSpawned(Events::PlayerSpawned& e) } return true; } + +bool PlayerMovementSystem::OnDoubleJump(Events::DoubleJump & e) +{ + // If entity does not exist, exit + if (!EntityWrapper(m_World, e.entityID).Valid()) { + return false; + } + // If entity IsLocalPlayer, exit + if (e.entityID == m_LocalPlayer.ID) { + return false; + } + spawnHexagon(EntityWrapper(m_World, e.entityID)); +} + +void PlayerMovementSystem::spawnHexagon(EntityWrapper target) +{ + //put a hexagon at the entitys... feet? + auto hexagonEffect = ResourceManager::Load("Schema/Entities/DoubleJumpHexagon.xml"); + EntityFileParser parser(hexagonEffect); + EntityID hexagonEffectID = parser.MergeEntities(m_World); + EntityWrapper hexagonEW = EntityWrapper(m_World, hexagonEffectID); + hexagonEW["Transform"]["Position"] = (glm::vec3)target["Transform"]["Position"]; +} \ No newline at end of file From 6465fe6ed68fd242d85a3411e46bf3a12cdbe6a2 Mon Sep 17 00:00:00 2001 From: Teejoon Date: Wed, 24 Feb 2016 13:22:41 +0100 Subject: [PATCH 044/252] Have fix the resizing errors --- include/Engine/Rendering/SSAOPass.h | 6 ++++-- src/Engine/Rendering/PickingPass.cpp | 18 +++--------------- src/Engine/Rendering/Renderer.cpp | 2 ++ src/Engine/Rendering/SSAOPass.cpp | 20 ++++++++++++-------- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/include/Engine/Rendering/SSAOPass.h b/include/Engine/Rendering/SSAOPass.h index f15e20d3..792d1d82 100644 --- a/include/Engine/Rendering/SSAOPass.h +++ b/include/Engine/Rendering/SSAOPass.h @@ -14,11 +14,14 @@ class SSAOPass { public: SSAOPass(IRenderer* rendere); - ~SSAOPass() { }; + ~SSAOPass() { + delete m_DrawBloomPass; + }; void Draw(GLuint depthBuffer, Camera* camera); void Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int NumOfTurns); void ClearBuffer(); + void OnWindowResize(); //Return the SSAO of the texture sent to Draw GLuint SSAOTexture() const { return m_DrawBloomPass->GaussianTexture(); } @@ -31,7 +34,6 @@ private: void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const; - void ComputeAO(GLuint depthBuffer, Camera* camera); //void blurHorizontal(GLuint depthBuffer); //void blurVertical(GLuint depthBuffer); diff --git a/src/Engine/Rendering/PickingPass.cpp b/src/Engine/Rendering/PickingPass.cpp index d1ed73dd..4b4cd193 100644 --- a/src/Engine/Rendering/PickingPass.cpp +++ b/src/Engine/Rendering/PickingPass.cpp @@ -21,23 +21,13 @@ void PickingPass::InitializeTextures() { GenerateTexture(&m_PickingTexture, GL_CLAMP_TO_BORDER, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RG8, GL_RG, GL_UNSIGNED_BYTE); + + GenerateTexture(&m_DepthBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST, + glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8); } void PickingPass::InitializeFrameBuffers() { - /* glGenRenderbuffers(1, &m_DepthBuffer); - glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);*/ - - glGenTextures(1, &m_DepthBuffer); - - glBindTexture(GL_TEXTURE_2D, m_DepthBuffer); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, (int)(m_Renderer->GetViewportSize().Width), (int)(m_Renderer->GetViewportSize().Height), 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, nullptr); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); - m_PickingBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthBuffer, GL_DEPTH_ATTACHMENT))); m_PickingBuffer.AddResource(std::shared_ptr(new Texture2D(&m_PickingTexture, GL_COLOR_ATTACHMENT0))); m_PickingBuffer.Generate(); @@ -382,8 +372,6 @@ void PickingPass::ClearPicking() void PickingPass::OnWindowResize() { InitializeTextures(); - glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); m_PickingBuffer.Generate(); } diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index 0c668cad..5b3348c3 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -30,6 +30,7 @@ void Renderer::glfwFrameBufferCallback(GLFWwindow* window, int width, int height currentRenderer->m_LightCullingPass->OnWindowResize(); currentRenderer->m_PickingPass->OnWindowResize(); currentRenderer->m_DrawBloomPass->OnWindowResize(); + currentRenderer->m_SSAOPass->OnWindowResize(); } void Renderer::InitializeWindow() @@ -126,6 +127,7 @@ void Renderer::Draw(RenderFrame& frame) m_PickingPass->ClearPicking(); m_DrawFinalPass->ClearBuffer(); m_DrawBloomPass->ClearBuffer(); + m_SSAOPass->ClearBuffer(); PerformanceTimer::StopTimer("Renderer-ClearBuffers"); for (auto scene : frame.RenderScenes) { PerformanceTimer::StartTimer("Renderer-Depth"); diff --git a/src/Engine/Rendering/SSAOPass.cpp b/src/Engine/Rendering/SSAOPass.cpp index 331e040f..d4cdcb19 100644 --- a/src/Engine/Rendering/SSAOPass.cpp +++ b/src/Engine/Rendering/SSAOPass.cpp @@ -6,6 +6,7 @@ SSAOPass::SSAOPass(IRenderer* renderer) m_ScreenQuad = ResourceManager::Load("Models/Core/ScreenQuad.mesh"); + InitializeTexture(); InitializeBuffer(); InitializeShaderProgram(); Setting(0.1f, 0.012f, 1.0f, 1.0f, 13, 7); @@ -28,16 +29,16 @@ void SSAOPass::InitializeShaderProgram() m_SSAOViewSpaceZProgram->Link(); } +void SSAOPass::InitializeTexture() { + GenerateTexture(&m_SSAOTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_R8, GL_RED, GL_FLOAT); + GenerateTexture(&m_SSAOViewSpaceZTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_R32F, GL_RED, GL_FLOAT); +} void SSAOPass::InitializeBuffer() { - GenerateTexture(&m_SSAOTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_R8, GL_RED, GL_FLOAT); - m_SSAOFramBuffer.AddResource(std::shared_ptr(new Texture2D(&m_SSAOTexture, GL_COLOR_ATTACHMENT0))); m_SSAOFramBuffer.Generate(); - GenerateTexture(&m_SSAOViewSpaceZTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_R32F, GL_RED, GL_FLOAT); - m_SSAOViewSpaceZFramBuffer.AddResource(std::shared_ptr(new Texture2D(&m_SSAOViewSpaceZTexture, GL_COLOR_ATTACHMENT0))); m_SSAOViewSpaceZFramBuffer.Generate(); } @@ -45,12 +46,12 @@ void SSAOPass::InitializeBuffer() void SSAOPass::ClearBuffer() { m_SSAOFramBuffer.Bind(); - glClearColor(0.f, 0.f, 0.f, 0.f); + glClearColor(1.f, 1.f, 1.f, 1.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); m_SSAOFramBuffer.Unbind(); m_SSAOViewSpaceZFramBuffer.Bind(); - glClearColor(0.f, 0.f, 0.f, 0.f); + glClearColor(1.f, 1.f, 1.f, 1.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); m_SSAOViewSpaceZFramBuffer.Unbind(); } @@ -136,6 +137,9 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera) m_DrawBloomPass->Draw(m_SSAOTexture); } -void ComputeAO(GLuint depthBuffer, Camera* camera) { - +void SSAOPass::OnWindowResize() { + m_DrawBloomPass->OnWindowResize(); + InitializeTexture(); + m_SSAOFramBuffer.Generate(); + m_SSAOViewSpaceZFramBuffer.Generate(); } \ No newline at end of file From 6f9ce8a0c16d1c65d05318e585857a3b02243468 Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 24 Feb 2016 13:57:54 +0100 Subject: [PATCH 045/252] WIP --- include/Engine/Rendering/CubeMapPass.h | 5 +++-- resources/Shaders/ForwardPlus.frag.glsl | 8 +++++--- resources/Shaders/ForwardPlus.vert.glsl | 8 ++++---- src/Engine/Rendering/CubeMapPass.cpp | 23 +++++++++++------------ src/Engine/Rendering/DrawFinalPass.cpp | 7 +++++++ 5 files changed, 30 insertions(+), 21 deletions(-) diff --git a/include/Engine/Rendering/CubeMapPass.h b/include/Engine/Rendering/CubeMapPass.h index 564329e2..0840e2c8 100644 --- a/include/Engine/Rendering/CubeMapPass.h +++ b/include/Engine/Rendering/CubeMapPass.h @@ -10,7 +10,7 @@ public: CubeMapPass(IRenderer* renderer); ~CubeMapPass() { } - void LoadTextures(); + void LoadTextures(std::string input); void FillCubeMap(glm::vec3 originPosition); void GenerateCubeMapTexture(); @@ -19,8 +19,9 @@ public: private: IRenderer* m_Renderer; + std::string m_PreviusCubeMapTexture; - std::vector m_CubeMapTestTextures; + std::vector m_CubeMapTextures; }; #endif \ No newline at end of file diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 1b4d8c1e..8b7a4824 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -12,6 +12,7 @@ uniform vec4 FillColor; uniform vec4 AmbientColor; uniform float FillPercentage; uniform float GlowIntensity = 10; +uniform vec3 CameraPosition; uniform vec2 DiffuseUVRepeat; uniform vec2 NormalUVRepeat; @@ -134,8 +135,9 @@ void main() normal = normalize(normal); //vec4 normal = normalize(V * vec4(Input.Normal, 0.0)); vec4 viewVec = normalize(-position); - vec3 R = reflect(viewVec.xyz, normal.xyz); - R = vec3(P * vec4(R, 1.0)); + vec3 I = normalize(vec3(M * vec4(Input.Position, 1.0)) - CameraPosition); + vec3 R = reflect(I, Input.Normal); + //R = vec3(P * vec4(R, 1.0)); vec4 reflectionColor = texture(CubeMap, R); vec2 tilePos; @@ -168,7 +170,7 @@ void main() vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0; - color_result = color_result * clamp(1/specularTexel, 0, 1) + reflectionColor * clamp(specularTexel, 0, 1); + //color_result = color_result * clamp(1/specularTexel, 0, 1) + reflectionColor * clamp(specularTexel, 0, 1); //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; diff --git a/resources/Shaders/ForwardPlus.vert.glsl b/resources/Shaders/ForwardPlus.vert.glsl index d475d825..32daf240 100644 --- a/resources/Shaders/ForwardPlus.vert.glsl +++ b/resources/Shaders/ForwardPlus.vert.glsl @@ -23,12 +23,12 @@ out VertexData{ void main() { gl_Position = P*V*M * vec4(Position, 1.0); - + mat4 TIM = transpose(inverse(M)); Output.Position = Position; Output.TextureCoordinate = TextureCoords; - 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.Normal = vec3(TIM) * Normal; + Output.Tangent = vec3(TIM) * Tangent; + Output.BiTangent = vec3(TIM) * BiTangent; Output.ExplosionColor = vec4(1.0); Output.ExplosionPercentageElapsed = 0.0; } \ No newline at end of file diff --git a/src/Engine/Rendering/CubeMapPass.cpp b/src/Engine/Rendering/CubeMapPass.cpp index cdfc704e..b64b77f1 100644 --- a/src/Engine/Rendering/CubeMapPass.cpp +++ b/src/Engine/Rendering/CubeMapPass.cpp @@ -3,21 +3,20 @@ CubeMapPass::CubeMapPass(IRenderer* renderer) :m_Renderer(renderer) { - LoadTextures(); + LoadTextures("Nevada"); GenerateCubeMapTexture(); } -/* - -*/ - -void CubeMapPass::LoadTextures() +void CubeMapPass::LoadTextures(std::string input) { - for (int i = 0; i < 6; i++){ - std::string str; - str = "Textures/Test/CubeMap/CubeMapTest0" + std::to_string(i) + ".png"; - Texture* img = ResourceManager::Load(str); - m_CubeMapTestTextures.push_back(img); + if (m_PreviusCubeMapTexture != input) { + m_CubeMapTextures.clear(); + for (int i = 0; i < 6; i++) { + std::string str; + str = "Textures/Test/CubeMap/" + input + "/CubeMapTest0" + std::to_string(i) + ".png"; + Texture* img = ResourceManager::Load(str); + m_CubeMapTextures.push_back(img); + } } } @@ -27,7 +26,7 @@ void CubeMapPass::GenerateCubeMapTexture() glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapTexture); for (int i = 0; i < 6; i++) { - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA32F, 1024, 1024, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_CubeMapTestTextures[i]->Data); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA32F, m_CubeMapTextures[0]->Width, m_CubeMapTextures[0]->Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_CubeMapTextures[i]->Data); } glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index e7982a3d..6cd2c1f1 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -383,6 +383,8 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob); glActiveTexture(GL_TEXTURE5); glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + std::vector frameBones; if (explosionEffectJob->AnimationOffset.animation != nullptr) { frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); @@ -399,6 +401,8 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& BindExplosionTextures(explosionHandle, explosionEffectJob); glActiveTexture(GL_TEXTURE5); glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + } break; } @@ -459,6 +463,8 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& BindModelTextures(forwardSkinnedHandle, modelJob); glActiveTexture(GL_TEXTURE5); glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + std::vector frameBones; if (modelJob->AnimationOffset.animation != nullptr) { frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); @@ -476,6 +482,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& BindModelTextures(forwardHandle, modelJob); glActiveTexture(GL_TEXTURE5); glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); } break; } From af68236e7186774ba25111523a5cbacb4860eaab Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Wed, 24 Feb 2016 13:58:05 +0100 Subject: [PATCH 046/252] now using a define INDICATOR_TEST to activate the DamageIndicatorSystem test. --- include/Game/Systems/DamageIndicatorSystem.h | 6 ++++-- src/Game/Systems/DamageIndicatorSystem.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/Game/Systems/DamageIndicatorSystem.h b/include/Game/Systems/DamageIndicatorSystem.h index 49ae249c..ae9ba195 100644 --- a/include/Game/Systems/DamageIndicatorSystem.h +++ b/include/Game/Systems/DamageIndicatorSystem.h @@ -14,6 +14,7 @@ #include #include "Rendering/Util/CommonFunctions.h" +//#define INDICATOR_TEST class DamageIndicatorSystem : public ImpureSystem { @@ -40,8 +41,9 @@ private: float CalculateAngle(EntityWrapper player, glm::vec3 enemyPos); //for tests - int m_TestVar = 0; - bool m_Testing = false; +#ifdef INDICATOR_TEST glm::vec3 DamageIndicatorTest(EntityWrapper player); + int m_TestVar = 0; +#endif }; #endif diff --git a/src/Game/Systems/DamageIndicatorSystem.cpp b/src/Game/Systems/DamageIndicatorSystem.cpp index 65e1caf0..92fbe607 100644 --- a/src/Game/Systems/DamageIndicatorSystem.cpp +++ b/src/Game/Systems/DamageIndicatorSystem.cpp @@ -42,9 +42,9 @@ bool DamageIndicatorSystem::OnPlayerDamage(Events::PlayerDamage& e) glm::vec3 inflictorPos = e.Inflictor["Transform"]["Position"]; //if testing - if (m_Testing) { +#ifdef INDICATOR_TEST inflictorPos = DamageIndicatorTest(e.Victim); - } +#endif float angleBetweenVectors = CalculateAngle(e.Victim, inflictorPos); @@ -100,6 +100,7 @@ float DamageIndicatorSystem::CalculateAngle(EntityWrapper player, glm::vec3 enem return angleBetweenVectors; } +#ifdef INDICATOR_TEST glm::vec3 DamageIndicatorSystem::DamageIndicatorTest(EntityWrapper player) { auto currentPos = (glm::vec3)player["Transform"]["Position"]; @@ -145,3 +146,4 @@ glm::vec3 DamageIndicatorSystem::DamageIndicatorTest(EntityWrapper player) { deathEffectEW["Transform"]["Orientation"] = (glm::vec3)player["Transform"]["Orientation"]; return inflictorPos; } +#endif \ No newline at end of file From 5af4f9d8e72795e4345cdc00623801d0c08bf51c Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Wed, 24 Feb 2016 14:06:41 +0100 Subject: [PATCH 047/252] Removed a comment originating from HUDDesynch branch --- src/Game/Systems/CapturePointSystem.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Game/Systems/CapturePointSystem.cpp b/src/Game/Systems/CapturePointSystem.cpp index e4df9740..b45f6ced 100644 --- a/src/Game/Systems/CapturePointSystem.cpp +++ b/src/Game/Systems/CapturePointSystem.cpp @@ -16,9 +16,6 @@ CapturePointSystem::CapturePointSystem(SystemParams params) //NOTE: needs to run each frame, since we're possibly modifying the captureTimer for the capturePoints by dt void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, ComponentWrapper& cCapturePoint, double dt) { - //if (!IsClient) { - // return; - //} if (m_WinnerWasFound) { return; } From 607e83134df77faae4a276189494a8cf5bd64ef7 Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 24 Feb 2016 14:16:49 +0100 Subject: [PATCH 048/252] Cubemaps working --- resources/Shaders/ForwardPlus.frag.glsl | 4 ++-- resources/Shaders/ForwardPlus.vert.glsl | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 8b7a4824..cddd6d6b 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -136,7 +136,7 @@ void main() //vec4 normal = normalize(V * vec4(Input.Normal, 0.0)); vec4 viewVec = normalize(-position); vec3 I = normalize(vec3(M * vec4(Input.Position, 1.0)) - CameraPosition); - vec3 R = reflect(I, Input.Normal); + vec3 R = reflect(-I, Input.Normal); //R = vec3(P * vec4(R, 1.0)); vec4 reflectionColor = texture(CubeMap, R); @@ -170,7 +170,7 @@ void main() vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0; - //color_result = color_result * clamp(1/specularTexel, 0, 1) + reflectionColor * clamp(specularTexel, 0, 1); + color_result = color_result * clamp(1/specularTexel, 0, 1) + reflectionColor * clamp(specularTexel, 0, 1); //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; diff --git a/resources/Shaders/ForwardPlus.vert.glsl b/resources/Shaders/ForwardPlus.vert.glsl index 32daf240..26686222 100644 --- a/resources/Shaders/ForwardPlus.vert.glsl +++ b/resources/Shaders/ForwardPlus.vert.glsl @@ -26,9 +26,9 @@ void main() mat4 TIM = transpose(inverse(M)); Output.Position = Position; Output.TextureCoordinate = TextureCoords; - Output.Normal = vec3(TIM) * Normal; - Output.Tangent = vec3(TIM) * Tangent; - Output.BiTangent = vec3(TIM) * BiTangent; + Output.Normal = vec3(TIM * vec4(Normal, 0.0)); + Output.Tangent = vec3(TIM * vec4(Tangent, 0.0)); + Output.BiTangent = vec3(TIM * vec4(BiTangent, 0.0)); Output.ExplosionColor = vec4(1.0); Output.ExplosionPercentageElapsed = 0.0; } \ No newline at end of file From f41e0b29be13badc2ba84aef79611a0734da8aee Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 24 Feb 2016 14:21:48 +0100 Subject: [PATCH 049/252] assets --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 89b40707..10a61165 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 89b4070731584056402eac071845e9b1a0d156fb +Subproject commit 10a611659ddaadfea6a560e707d395834855a979 From 7394436e7a0f811e8e536595bd6b791c3b28ca45 Mon Sep 17 00:00:00 2001 From: stiffly Date: Wed, 24 Feb 2016 14:23:54 +0100 Subject: [PATCH 050/252] Removed unnecessary comment. --- src/Game/Systems/CapturePointSystem.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Game/Systems/CapturePointSystem.cpp b/src/Game/Systems/CapturePointSystem.cpp index 598a1a8e..f5e37429 100644 --- a/src/Game/Systems/CapturePointSystem.cpp +++ b/src/Game/Systems/CapturePointSystem.cpp @@ -16,9 +16,6 @@ CapturePointSystem::CapturePointSystem(SystemParams params) //NOTE: needs to run each frame, since we're possibly modifying the captureTimer for the capturePoints by dt void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, ComponentWrapper& cCapturePoint, double dt) { - //if (!IsClient) { - // return; - //} if (m_WinnerWasFound) { return; } From feeff5b164a86f88346046b2d84ac45af15b867b Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 24 Feb 2016 14:47:47 +0100 Subject: [PATCH 051/252] Debug tool for different CubeMap changed cubemap influence. --- include/Engine/Rendering/CubeMapPass.h | 2 +- include/Engine/Rendering/Renderer.h | 1 + resources/Shaders/ForwardPlus.frag.glsl | 2 +- src/Engine/Rendering/CubeMapPass.cpp | 6 ++++-- src/Engine/Rendering/Renderer.cpp | 6 ++++++ 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/Engine/Rendering/CubeMapPass.h b/include/Engine/Rendering/CubeMapPass.h index 0840e2c8..3cda8cad 100644 --- a/include/Engine/Rendering/CubeMapPass.h +++ b/include/Engine/Rendering/CubeMapPass.h @@ -15,7 +15,7 @@ public: void GenerateCubeMapTexture(); //GLuint CubeMapTexture() const { return m_CubeMapTexture; } - GLuint m_CubeMapTexture; + GLuint m_CubeMapTexture = -1; private: IRenderer* m_Renderer; diff --git a/include/Engine/Rendering/Renderer.h b/include/Engine/Rendering/Renderer.h index 720336aa..f3a6bf31 100644 --- a/include/Engine/Rendering/Renderer.h +++ b/include/Engine/Rendering/Renderer.h @@ -59,6 +59,7 @@ private: Model* m_UnitSphere; int m_DebugTextureToDraw = 0; + int m_CubeMapTexture = 0; bool m_ResizeWindow = false; float m_SSAO_Radius = 1.0f; float m_SSAO_Bias = 0.05f; diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index cddd6d6b..6fbc9c27 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -170,7 +170,7 @@ void main() vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0; - color_result = color_result * clamp(1/specularTexel, 0, 1) + reflectionColor * clamp(specularTexel, 0, 1); + color_result = color_result * clamp(1/specularTexel, 0, 1)*2 + reflectionColor * clamp(specularTexel, 0, 1)/2; //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; diff --git a/src/Engine/Rendering/CubeMapPass.cpp b/src/Engine/Rendering/CubeMapPass.cpp index b64b77f1..75f5e1c9 100644 --- a/src/Engine/Rendering/CubeMapPass.cpp +++ b/src/Engine/Rendering/CubeMapPass.cpp @@ -4,7 +4,6 @@ CubeMapPass::CubeMapPass(IRenderer* renderer) :m_Renderer(renderer) { LoadTextures("Nevada"); - GenerateCubeMapTexture(); } void CubeMapPass::LoadTextures(std::string input) @@ -17,12 +16,15 @@ void CubeMapPass::LoadTextures(std::string input) Texture* img = ResourceManager::Load(str); m_CubeMapTextures.push_back(img); } + GenerateCubeMapTexture(); } } void CubeMapPass::GenerateCubeMapTexture() { - glGenTextures(1, &m_CubeMapTexture); + if (m_CubeMapTexture == -1) { + glGenTextures(1, &m_CubeMapTexture); + } glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapTexture); for (int i = 0; i < 6; i++) { diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index 8391599c..a3a53591 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -108,6 +108,12 @@ void Renderer::Draw(RenderFrame& frame) { GLERROR("PRE"); ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking\0Ambient Occlusion"); + ImGui::Combo("CubeMap", &m_CubeMapTexture, "Nevada(512)\0Sky(1024)"); + if(m_CubeMapTexture == 0) { + m_CubeMapPass->LoadTextures("Nevada"); + } else if (m_CubeMapTexture == 1) { + m_CubeMapPass->LoadTextures("Sky"); + } ImGui::SliderFloat("SSAO sample radius", &m_SSAO_Radius, 0.01f, 5.0f); ImGui::SliderFloat("SSAO bias", &m_SSAO_Bias, 0.0f, 0.1f); From ef87102d1f141810c2ebb3b2bc966f76d2849abc Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Wed, 24 Feb 2016 17:53:37 +0100 Subject: [PATCH 052/252] Ammo,HealthPickup now takes in account for possible parenting/childing of the pickup. Also saved the xml files with the new scaling --- include/Game/Systems/AmmoPickupSystem.h | 1 + include/Game/Systems/PickupSpawnSystem.h | 1 + resources/Schema/Entities/AmmoPickup.xml | 10 +++++----- resources/Schema/Entities/HealthPickup.xml | 10 +++++----- src/Game/Systems/AmmoPickupSystem.cpp | 5 +++-- src/Game/Systems/PickupSpawnSystem.cpp | 3 ++- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/include/Game/Systems/AmmoPickupSystem.h b/include/Game/Systems/AmmoPickupSystem.h index a54b8495..0fbd9e08 100644 --- a/include/Game/Systems/AmmoPickupSystem.h +++ b/include/Game/Systems/AmmoPickupSystem.h @@ -26,6 +26,7 @@ private: double AmmoGain; double RespawnTimer; double DecreaseThisRespawnTimer; + EntityID parentID; }; std::vector m_ETriggerTouchVector; }; diff --git a/include/Game/Systems/PickupSpawnSystem.h b/include/Game/Systems/PickupSpawnSystem.h index f912e8ff..66c5f630 100644 --- a/include/Game/Systems/PickupSpawnSystem.h +++ b/include/Game/Systems/PickupSpawnSystem.h @@ -27,6 +27,7 @@ private: double HealthGain; double RespawnTimer; double DecreaseThisRespawnTimer; + EntityID parentID; }; std::vector m_ETriggerTouchVector; }; diff --git a/resources/Schema/Entities/AmmoPickup.xml b/resources/Schema/Entities/AmmoPickup.xml index 1d1435f7..bebde467 100644 --- a/resources/Schema/Entities/AmmoPickup.xml +++ b/resources/Schema/Entities/AmmoPickup.xml @@ -2,18 +2,18 @@ - Models/Props/PickUps/AmmoPickUp.mesh - 0.1 - + 8 + - - + + + diff --git a/resources/Schema/Entities/HealthPickup.xml b/resources/Schema/Entities/HealthPickup.xml index c6fbc4f4..b4b83392 100644 --- a/resources/Schema/Entities/HealthPickup.xml +++ b/resources/Schema/Entities/HealthPickup.xml @@ -2,18 +2,18 @@ - Models/Props/PickUps/HealthPickUp.mesh - 0.1 - + 8 + - - + + + diff --git a/src/Game/Systems/AmmoPickupSystem.cpp b/src/Game/Systems/AmmoPickupSystem.cpp index f6778fe4..250fa494 100644 --- a/src/Game/Systems/AmmoPickupSystem.cpp +++ b/src/Game/Systems/AmmoPickupSystem.cpp @@ -29,6 +29,7 @@ void AmmoPickupSystem::Update(double dt) newAmmoPickupEntity["Transform"]["Position"] = ammoPickupPosition.Pos; newAmmoPickupEntity["AmmoPickup"]["AmmoGain"] = ammoPickupPosition.AmmoGain; newAmmoPickupEntity["AmmoPickup"]["RespawnTimer"] = ammoPickupPosition.RespawnTimer; + m_World->SetParent(newAmmoPickupEntity.ID, ammoPickupPosition.parentID); //erase the current element (AmmoPickupPosition) m_ETriggerTouchVector.erase(it); @@ -69,8 +70,8 @@ bool AmmoPickupSystem::OnTriggerTouch(Events::TriggerTouch& e) //copy position, ammogain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object) //we need to copy all values since each value can be different for each ammoPickup - m_ETriggerTouchVector.push_back({ (glm::vec3)e.Trigger["Transform"]["Position"] ,e.Trigger["AmmoPickup"]["AmmoGain"], - e.Trigger["AmmoPickup"]["RespawnTimer"],e.Trigger["AmmoPickup"]["RespawnTimer"] }); + m_ETriggerTouchVector.push_back({ e.Trigger["Transform"]["Position"], e.Trigger["AmmoPickup"]["AmmoGain"], + e.Trigger["AmmoPickup"]["RespawnTimer"], e.Trigger["AmmoPickup"]["RespawnTimer"], m_World->GetParent(e.Trigger.ID) }); //delete the ammopickup m_World->DeleteEntity(e.Trigger.ID); diff --git a/src/Game/Systems/PickupSpawnSystem.cpp b/src/Game/Systems/PickupSpawnSystem.cpp index 159f716b..abf59007 100644 --- a/src/Game/Systems/PickupSpawnSystem.cpp +++ b/src/Game/Systems/PickupSpawnSystem.cpp @@ -29,6 +29,7 @@ void PickupSpawnSystem::Update(double dt) newHealthPickupEntity["Transform"]["Position"] = healthPickupPosition.Pos; newHealthPickupEntity["HealthPickup"]["HealthGain"] = healthPickupPosition.HealthGain; newHealthPickupEntity["HealthPickup"]["RespawnTimer"] = healthPickupPosition.RespawnTimer; + m_World->SetParent(newHealthPickupEntity.ID, healthPickupPosition.parentID); //erase the current element (healthPickupPosition) m_ETriggerTouchVector.erase(it); @@ -58,7 +59,7 @@ bool PickupSpawnSystem::OnTriggerTouch(Events::TriggerTouch& e) //copy position, healthgain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object) //we need to copy all values since each value can be different for each healthPickup m_ETriggerTouchVector.push_back({ (glm::vec3)e.Trigger["Transform"]["Position"] ,e.Trigger["HealthPickup"]["HealthGain"], - e.Trigger["HealthPickup"]["RespawnTimer"],e.Trigger["HealthPickup"]["RespawnTimer"] }); + e.Trigger["HealthPickup"]["RespawnTimer"],e.Trigger["HealthPickup"]["RespawnTimer"], m_World->GetParent(e.Trigger.ID) }); //delete the healthpickup m_World->DeleteEntity(e.Trigger.ID); From c9c5e9841d23223f9af6c26073f427f9dafb2eca Mon Sep 17 00:00:00 2001 From: antc13 Date: Thu, 25 Feb 2016 10:55:14 +0100 Subject: [PATCH 053/252] New Map WIP, Map2 version 2 is with models on both sides. --- assets | 2 +- .../Schema/Entities/AmmoPickupWithModel.xml | 38 + .../Schema/Entities/HealthPickupWithModel.xml | 38 + resources/Schema/Entities/NewMap2.xml | 2913 +++++++++++ resources/Schema/Entities/NewMap2version2.xml | 4416 +++++++++++++++++ resources/Schema/Entities/RedSideModels.xml | 1522 ++++++ 6 files changed, 8928 insertions(+), 1 deletion(-) create mode 100644 resources/Schema/Entities/AmmoPickupWithModel.xml create mode 100644 resources/Schema/Entities/HealthPickupWithModel.xml create mode 100644 resources/Schema/Entities/NewMap2.xml create mode 100644 resources/Schema/Entities/NewMap2version2.xml create mode 100644 resources/Schema/Entities/RedSideModels.xml diff --git a/assets b/assets index 1e7adc74..0964372b 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 1e7adc749e02144615a20a82c847d3c8df46ee3d +Subproject commit 0964372b1dbb6c41a9d4b4a540ed55544b39f69d diff --git a/resources/Schema/Entities/AmmoPickupWithModel.xml b/resources/Schema/Entities/AmmoPickupWithModel.xml new file mode 100644 index 00000000..6c7ed50a --- /dev/null +++ b/resources/Schema/Entities/AmmoPickupWithModel.xml @@ -0,0 +1,38 @@ + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 8 + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/HealthPickupWithModel.xml b/resources/Schema/Entities/HealthPickupWithModel.xml new file mode 100644 index 00000000..8465e922 --- /dev/null +++ b/resources/Schema/Entities/HealthPickupWithModel.xml @@ -0,0 +1,38 @@ + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/NewMap2.xml b/resources/Schema/Entities/NewMap2.xml new file mode 100644 index 00000000..ad2ae770 --- /dev/null +++ b/resources/Schema/Entities/NewMap2.xml @@ -0,0 +1,2913 @@ + + + + + + + + + + + + + + + + + + Models/Props/GroundTest.mesh + + + + + + + + + Models/Props/Walls/SciFiWallTop.mesh + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + true + + + + + + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall1.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall2.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallSmall3.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall4.mesh + + + + + + + + + + + + Models/Props/HighgroundTest1.mesh + + + + + + + + + + Models/Props/HighgroundTest2.mesh + + + + + + + + + + + Models/Props/HighgroundTest3.mesh + + + + + + + + + + + Models/Props/HighgroundTest4.mesh + + + + + + + + + + + Models/Props/HighgroundTest5.mesh + + + + + + + + + + Models/Props/HighgroundTest6.mesh + + + + + + + + + + + Models/Props/HighgroundTest7.mesh + + + + + + + + + + + + + Models/Props/HighgroundTest8.mesh + + + + + + + + + + + + + Models/Props/HighgroundTest9.mesh + + + + + + + + + + + + + Models/Props/HighgroundTest10.mesh + + + + + + + + + + + + + Models/Props/HighgroundTest6.mesh + + + + + + + + + + + + + Models/Props/HighgroundTest1.mesh + + + + + + + + + + + + Models/Props/HighgroundTest2.mesh + + + + + + + + + + + + + Models/Props/HighgroundTest3.mesh + + + + + + + + + + + + + Models/Props/HighgroundTest4.mesh + + + + + + + + + + + + + Models/Props/HighgroundTest5.mesh + + + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar3Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar3Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 5 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + 4 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + + 3 + + + + + + + + + + + + 2 + 1 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointBlue.mesh + + + + + + + + + + + + + 4 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 3 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 2 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 1.5498908015879351 + 1 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointRed.mesh + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + 10 + + + + + + + + + + 10 + + + + + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + 1 + + + + + + + + + + + + + + Schema/Entities/PlayerRed.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + diff --git a/resources/Schema/Entities/NewMap2version2.xml b/resources/Schema/Entities/NewMap2version2.xml new file mode 100644 index 00000000..d1964a84 --- /dev/null +++ b/resources/Schema/Entities/NewMap2version2.xml @@ -0,0 +1,4416 @@ + + + + + + + + + + + + + + + + + + Models/Props/GroundTest.mesh + + + + + + + + + Models/Props/Walls/SciFiWallTop.mesh + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + true + + + + + + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall1.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall2.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallSmall3.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall4.mesh + + + + + + + + + + + + Models/Props/HighgroundTest1.mesh + + + + + + + + + + Models/Props/HighgroundTest2.mesh + + + + + + + + + + + Models/Props/HighgroundTest3.mesh + + + + + + + + + + + Models/Props/HighgroundTest4.mesh + + + + + + + + + + + Models/Props/HighgroundTest5.mesh + + + + + + + + + + Models/Props/HighgroundTest6.mesh + + + + + + + + + + + Models/Props/HighgroundTest7.mesh + + + + + + + + + + + + + Models/Props/HighgroundTest8.mesh + + + + + + + + + + + + + Models/Props/HighgroundTest9.mesh + + + + + + + + + + + + + Models/Props/HighgroundTest10.mesh + + + + + + + + + + + + + Models/Props/HighgroundTest6.mesh + + + + + + + + + + + + + Models/Props/HighgroundTest1.mesh + + + + + + + + + + + + Models/Props/HighgroundTest2.mesh + + + + + + + + + + + + + Models/Props/HighgroundTest3.mesh + + + + + + + + + + + + + Models/Props/HighgroundTest4.mesh + + + + + + + + + + + + + Models/Props/HighgroundTest5.mesh + + + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar3Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar3Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 5 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + 4 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + + 3 + + + + + + + + + + + + 2 + 1 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 5 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + 4 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + + 3 + + + + + + + + + + + + 2 + 1 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointBlue.mesh + + + + + + + + + + + + + 4 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 3 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 2 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 1.5498908015879351 + 1 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointRed.mesh + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + 10 + + + + + + + + + + 10 + + + + + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + 1 + + + + + + + + + + + + + + Schema/Entities/PlayerRed.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + diff --git a/resources/Schema/Entities/RedSideModels.xml b/resources/Schema/Entities/RedSideModels.xml new file mode 100644 index 00000000..afa478ec --- /dev/null +++ b/resources/Schema/Entities/RedSideModels.xml @@ -0,0 +1,1522 @@ + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 5 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + 4 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + + 3 + + + + + + + + + + + + 2 + 1 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + From c97d0d938138886e8d0fc4d41abd950b6bcf304f Mon Sep 17 00:00:00 2001 From: viktorljung Date: Thu, 25 Feb 2016 11:30:09 +0100 Subject: [PATCH 054/252] Fixed memory leaks and cleaned up Skeleton and BlendTree --- include/Engine/Rendering/BlendTree.h | 13 +- include/Engine/Rendering/ModelJob.h | 3 - include/Engine/Rendering/Skeleton.h | 59 +-- resources/Schema/Entities/AnimationTests2.xml | 372 +++++++++++++++++- resources/Schema/Entities/yeeee.xml | 122 ++++++ src/Engine/Rendering/BlendTree.cpp | 137 ++----- src/Engine/Rendering/BoneAttachmentSystem.cpp | 8 +- src/Engine/Rendering/DrawFinalPass.cpp | 56 +-- src/Engine/Rendering/PickingPass.cpp | 28 +- src/Engine/Rendering/Skeleton.cpp | 353 +++-------------- 10 files changed, 606 insertions(+), 545 deletions(-) create mode 100644 resources/Schema/Entities/yeeee.xml diff --git a/include/Engine/Rendering/BlendTree.h b/include/Engine/Rendering/BlendTree.h index 694776a1..8d192cfe 100644 --- a/include/Engine/Rendering/BlendTree.h +++ b/include/Engine/Rendering/BlendTree.h @@ -60,17 +60,22 @@ public: BlendTree(EntityWrapper ModelEntity, Skeleton* skeleton); ~BlendTree(); - std::vector GetBoneTransforms(Skeleton* skeleton); + + std::vector GetFinalPose() { return m_FinalPose; } + + void PrintTree(); private: + Skeleton* m_Skeleton = nullptr; Node* m_Root = nullptr; - void FillTree(Node* parentNode, EntityWrapper parentEntity, Skeleton* skeleton); - BlendTree::Node* FillTreeByName(Node* parentNode, std::string name, EntityWrapper parentEntity, Skeleton* skeleton); + std::vector m_FinalPose; + std::vector AccumulateFinalPose(); + BlendTree::Node* FillTreeByName(Node* parentNode, std::string name, EntityWrapper parentEntity); - void Blend(Skeleton* skeleton, std::map& pose); + void Blend(std::map& pose); }; #endif diff --git a/include/Engine/Rendering/ModelJob.h b/include/Engine/Rendering/ModelJob.h index c10d6389..4ea7a1f6 100644 --- a/include/Engine/Rendering/ModelJob.h +++ b/include/Engine/Rendering/ModelJob.h @@ -146,9 +146,6 @@ struct ModelJob : RenderJob glm::vec4 Color; const ::Model* Model = nullptr; ::Skeleton* Skeleton = nullptr; - std::vector<::Skeleton::AnimationData> Animations; - ::Skeleton::AnimationOffset AnimationOffset; - std::shared_ptr<::BlendTree> BlendTree = nullptr; glm::vec4 DiffuseColor; diff --git a/include/Engine/Rendering/Skeleton.h b/include/Engine/Rendering/Skeleton.h index e380b6f2..fa5a329d 100644 --- a/include/Engine/Rendering/Skeleton.h +++ b/include/Engine/Rendering/Skeleton.h @@ -68,34 +68,6 @@ public: std::map> JointAnimations; }; - enum class BlendType - { - Additive, - Blend, - Override, - }; - - struct AnimationData - { - const Animation* animation; - BlendType blendType; - float time; - int level; - float weight; - }; - - struct JointFramePose { - BlendType Type; - int Level = 0; - glm::mat4 Pose = glm::mat4(0); - float Weight = 0.0f; - }; - - struct AnimationOffset { - const Animation* animation; - float time; - }; - Skeleton() { } ~Skeleton(); @@ -106,36 +78,23 @@ public: // Attach a new bone to the skeleton // Returns: New bone index int CreateBone(int ID, int parentID, std::string name, glm::mat4 offsetMatrix); - int GetBoneID(std::string name); - - std::vector GetFrameBones(); + const Animation* GetAnimation(std::string name); std::map GetFrameBones(const Animation* animation, double time, bool additive, bool noRootMotion = false); - void AccumulateBoneTransforms(bool noRootMotion, const Animation* animation, double time, std::map& boneMatrices, bool additive, const Bone* bone, glm::mat4 parentMatrix); - - const Animation* GetAnimation(std::string name); - glm::mat4 AdditiveBlend(const Bone* bone, AnimationOffset animationOffset, glm::mat4 targetPose); - - std::map Animations; - glm::mat4 GetBoneTransform(const Bone* bone, const Animation* animation, float time, glm::mat4 childMatrix); - glm::mat4 GetBoneTransform(bool noRootMotion, const Bone* bone, std::vector animations, AnimationOffset animationOffset, glm::mat4 childMatrix); - glm::mat4 GetBoneTransform(bool noRootMotion, const Bone* bone, std::vector animations, glm::mat4 childMatrix); - - - std::map BlendPoses(std::map pose1, std::map pose2, float weight); - std::map OverridePose(std::map overridePose, std::map targetPose); - std::map BlendPoseAdditive(std::map additivePose, std::map targetPose); - + std::map BlendPoses(const std::map& pose1, const std::map& pose2, float weight); + std::map OverridePose(const std::map& overridePose, const std::map& targetPose); + std::map BlendPoseAdditive(const std::map& additivePose, const std::map& targetPose); std::vector GetFinalPose(std::map& boneMatrices); - void AccumulateFinalPose(std::map& boneMatrices, const Bone* bone, glm::mat4 parentMatrix); - - void AdditiveBoneTransforms(const Animation* animation, double time, std::map& boneMatrices, const Bone* bone); - + + std::map Animations; private: glm::mat4 GetAdditiveBonePose(const Bone* bone, const Animation* animation, double time); glm::mat4 GetBonePose(const Bone* bone, const Animation* animation, double time, bool noRootMotion); + void AccumulateFinalPose(std::map& boneMatrices, const Bone* bone, glm::mat4 parentMatrix); + void AdditiveBoneTransforms(const Animation* animation, double time, std::map& boneMatrices, const Bone* bone); + void AccumulateBoneTransforms(bool noRootMotion, const Animation* animation, double time, std::map& boneMatrices, const Bone* bone, glm::mat4 parentMatrix); std::map m_BonesByName; diff --git a/resources/Schema/Entities/AnimationTests2.xml b/resources/Schema/Entities/AnimationTests2.xml index 40761b13..4779bbaf 100644 --- a/resources/Schema/Entities/AnimationTests2.xml +++ b/resources/Schema/Entities/AnimationTests2.xml @@ -58,6 +58,7 @@ + @@ -113,7 +114,7 @@ ShootFastRifleU - + 1 @@ -134,7 +135,7 @@ StrafeRightF - + 1 @@ -155,7 +156,7 @@ RunF - + 1 @@ -166,7 +167,370 @@ WalkF - + + 1 + + + + + + + + + + + + + + + + + AimAdditive + BlendOverride + + + Models/Characters/Assault/AssaultAnimations.mesh + + + + + + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + + + AimRifleA + + true + + + + + + + + + ShootRifleAnimation + MovementBlend + + + + + + + + ShootFastRifleU + + 1 + + + + + + + + + BlendWalkRun + StrafeAnimation + 1 + + + + + + + + StrafeRightF + + 1 + + + + + + + + + RunAnimtaion + WalkAnimation + 0.43000054359436035 + + + + + + + + RunF + + 1 + + + + + + + + + WalkF + + 1 + + + + + + + + + + + + + + + + + AimAdditive + BlendOverride + + + Models/Characters/Assault/AssaultAnimations.mesh + + + + + + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + + + AimRifleA + + true + + + + + + + + + ShootRifleAnimation + MovementBlend + + + + + + + + ShootFastRifleU + + 1 + + + + + + + + + BlendWalkRun + StrafeAnimation + 1 + + + + + + + + StrafeRightF + + 1 + + + + + + + + + RunAnimtaion + WalkAnimation + 0.43000054359436035 + + + + + + + + RunF + + 1 + + + + + + + + + WalkF + + 1 + + + + + + + + + + + + + + + + + AimAdditive + BlendOverride + + + Models/Characters/Assault/AssaultAnimations.mesh + + + + + + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + + + AimRifleA + + true + + + + + + + + + ShootRifleAnimation + MovementBlend + + + + + + + + ShootFastRifleU + + 1 + + + + + + + + + BlendWalkRun + StrafeAnimation + 1 + + + + + + + + StrafeRightF + + 1 + + + + + + + + + RunAnimtaion + WalkAnimation + 0.43000054359436035 + + + + + + + + RunF + + 1 + + + + + + + + + WalkF + 1 diff --git a/resources/Schema/Entities/yeeee.xml b/resources/Schema/Entities/yeeee.xml new file mode 100644 index 00000000..d3853b8f --- /dev/null +++ b/resources/Schema/Entities/yeeee.xml @@ -0,0 +1,122 @@ + + + + + + AimAdditive + BlendOverride + + + Models/Characters/Assault/AssaultAnimations.mesh + + + + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + + + AimRifleA + + true + + + + + + + + + ShootRifleAnimation + MovementBlend + + + + + + + + ShootFastRifleU + + 1 + + + + + + + + + BlendWalkRun + StrafeAnimation + 1 + + + + + + + + StrafeRightF + + 1 + + + + + + + + + RunAnimtaion + WalkAnimation + 0.43000054359436035 + + + + + + + + RunF + + 1 + + + + + + + + + WalkF + + 1 + + + + + + + + + + + + + + diff --git a/src/Engine/Rendering/BlendTree.cpp b/src/Engine/Rendering/BlendTree.cpp index a5f10188..1d628a06 100644 --- a/src/Engine/Rendering/BlendTree.cpp +++ b/src/Engine/Rendering/BlendTree.cpp @@ -2,6 +2,10 @@ BlendTree::BlendTree(EntityWrapper ModelEntity, Skeleton* skeleton) { + + m_Skeleton = skeleton; + + auto itPair = ModelEntity.World->GetChildren(ModelEntity.ID); if (itPair.first == itPair.second) { return; @@ -16,7 +20,7 @@ BlendTree::BlendTree(EntityWrapper ModelEntity, Skeleton* skeleton) m_Root = new Node(); m_Root->Name = ModelEntity.Name(); - m_Root->Pose = skeleton->GetFrameBones(animation, (double)ModelEntity["Animation"]["Time"], (bool)ModelEntity["Animation"]["Additive"]); + m_Root->Pose = m_Skeleton->GetFrameBones(animation, (double)ModelEntity["Animation"]["Time"], (bool)ModelEntity["Animation"]["Additive"]); m_Root->Parent = nullptr; m_Root->Type = NodeType::Animation; @@ -26,26 +30,27 @@ BlendTree::BlendTree(EntityWrapper ModelEntity, Skeleton* skeleton) m_Root->Parent = nullptr; m_Root->Type = NodeType::Blend; m_Root->Weight = (double)ModelEntity["Blend"]["Weight"]; - m_Root->Child[0] = FillTreeByName(m_Root, (std::string)ModelEntity["Blend"]["Pose1"], ModelEntity, skeleton); - m_Root->Child[1] = FillTreeByName(m_Root, (std::string)ModelEntity["Blend"]["Pose2"], ModelEntity, skeleton); + m_Root->Child[0] = FillTreeByName(m_Root, (std::string)ModelEntity["Blend"]["Pose1"], ModelEntity); + m_Root->Child[1] = FillTreeByName(m_Root, (std::string)ModelEntity["Blend"]["Pose2"], ModelEntity); } else if (ModelEntity.HasComponent("BlendOverride")) { m_Root = new Node(); m_Root->Name = ModelEntity.Name(); m_Root->Parent = nullptr; m_Root->Type = NodeType::Override; - m_Root->Child[0] = FillTreeByName(m_Root, (std::string)ModelEntity["BlendOverride"]["Master"], ModelEntity, skeleton); - m_Root->Child[1] = FillTreeByName(m_Root, (std::string)ModelEntity["BlendOverride"]["Slave"], ModelEntity, skeleton); + m_Root->Child[0] = FillTreeByName(m_Root, (std::string)ModelEntity["BlendOverride"]["Master"], ModelEntity); + m_Root->Child[1] = FillTreeByName(m_Root, (std::string)ModelEntity["BlendOverride"]["Slave"], ModelEntity); } else if (ModelEntity.HasComponent("BlendAdditive")) { m_Root = new Node(); m_Root->Name = ModelEntity.Name(); m_Root->Parent = nullptr; m_Root->Type = NodeType::Additive; - m_Root->Child[0] = FillTreeByName(m_Root, (std::string)ModelEntity["BlendAdditive"]["Adder"], ModelEntity, skeleton); - m_Root->Child[1] = FillTreeByName(m_Root, (std::string)ModelEntity["BlendAdditive"]["Receiver"], ModelEntity, skeleton); + m_Root->Child[0] = FillTreeByName(m_Root, (std::string)ModelEntity["BlendAdditive"]["Adder"], ModelEntity); + m_Root->Child[1] = FillTreeByName(m_Root, (std::string)ModelEntity["BlendAdditive"]["Receiver"], ModelEntity); } + m_FinalPose = AccumulateFinalPose(); // PrintTree(); @@ -62,15 +67,12 @@ BlendTree::~BlendTree() std::list m_NodesToRemove; while (currentNode != nullptr) { - currentNode = currentNode->Next(); m_NodesToRemove.push_back(currentNode); + currentNode = currentNode->Next(); } for (auto it = m_NodesToRemove.begin(); it != m_NodesToRemove.end(); it++) { - if ((*it) != nullptr) { - delete (*it); - (*it) = nullptr; - } + delete (*it); } } @@ -89,92 +91,26 @@ void BlendTree::PrintTree() currentNode = currentNode->Next(); } - + } - - -void BlendTree::FillTree(Node* parentNode, EntityWrapper parentEntity, Skeleton* skeleton) +BlendTree::Node* BlendTree::FillTreeByName(Node* parentNode, std::string name, EntityWrapper parentEntity) { - auto itPair = parentEntity.World->GetChildren(parentEntity.ID); - if (itPair.first == itPair.second) { - return; // no children - } - - unsigned int childIndex = 0; - for (auto it = itPair.first; it != itPair.second; ++it) { - - EntityWrapper childEntity = EntityWrapper(parentEntity.World, it->second); - - if(!childEntity.Valid()) { - continue; - } - - if (childEntity.HasComponent("Animation")) { - const Skeleton::Animation* animation = skeleton->GetAnimation(childEntity["Animation"]["AnimationName"]); - if(animation == nullptr) { - continue; - } - - Node* node = new Node(); - node->Name = childEntity.Name(); - node->Pose = skeleton->GetFrameBones(animation, (double)childEntity["Animation"]["Time"], (bool)childEntity["Animation"]["Additive"]); - node->Parent = parentNode; - node->Type = NodeType::Animation; - parentNode->Child[childIndex] = node; - childIndex++; - FillTree(node, childEntity, skeleton); - - } else if (childEntity.HasComponent("Blend")) { - Node* node = new Node(); - node->Name = childEntity.Name(); - node->Parent = parentNode; - node->Type = NodeType::Blend; - (double&)childEntity["Blend"]["Weight"] = glm::clamp((float)(double)childEntity["Blend"]["Weight"], 0.f, 1.f); - node->Weight = (double)childEntity["Blend"]["Weight"]; - parentNode->Child[childIndex] = node; - childIndex++; - FillTree(node, childEntity, skeleton); - - } else if (childEntity.HasComponent("BlendOverride")) { - Node* node = new Node(); - node->Name = childEntity.Name(); - node->Parent = parentNode; - node->Type = NodeType::Override; - parentNode->Child[childIndex] = node; - childIndex++; - FillTree(node, childEntity, skeleton); - - } else if (childEntity.HasComponent("BlendAdditive")) { - Node* node = new Node(); - node->Name = childEntity.Name(); - node->Parent = parentNode; - node->Type = NodeType::Additive; - parentNode->Child[childIndex] = node; - childIndex++; - FillTree(node, childEntity, skeleton); - } - } -} - - -BlendTree::Node* BlendTree::FillTreeByName(Node* parentNode, std::string name, EntityWrapper parentEntity, Skeleton* skeleton) -{ - EntityWrapper childEntity = parentEntity.FirstChildByName(name); + EntityWrapper childEntity = parentEntity.FirstChildByName(name); // Make first level child by name if (!childEntity.Valid()) { return nullptr; } if (childEntity.HasComponent("Animation")) { - const Skeleton::Animation* animation = skeleton->GetAnimation(childEntity["Animation"]["AnimationName"]); + const Skeleton::Animation* animation = m_Skeleton->GetAnimation(childEntity["Animation"]["AnimationName"]); if (animation == nullptr) { return nullptr; } Node* node = new Node(); node->Name = childEntity.Name(); - node->Pose = skeleton->GetFrameBones(animation, (double)childEntity["Animation"]["Time"], (bool)childEntity["Animation"]["Additive"]); + node->Pose = m_Skeleton->GetFrameBones(animation, (double)childEntity["Animation"]["Time"], (bool)childEntity["Animation"]["Additive"]); node->Parent = parentNode; node->Type = NodeType::Animation; return node; @@ -186,31 +122,32 @@ BlendTree::Node* BlendTree::FillTreeByName(Node* parentNode, std::string name, E node->Type = NodeType::Blend; (double&)childEntity["Blend"]["Weight"] = glm::clamp((float)(double)childEntity["Blend"]["Weight"], 0.f, 1.f); node->Weight = (double)childEntity["Blend"]["Weight"]; - node->Child[0] = FillTreeByName(node, (std::string)childEntity["Blend"]["Pose1"], childEntity, skeleton); - node->Child[1] = FillTreeByName(node, (std::string)childEntity["Blend"]["Pose2"], childEntity, skeleton); + node->Child[0] = FillTreeByName(node, (std::string)childEntity["Blend"]["Pose1"], childEntity); + node->Child[1] = FillTreeByName(node, (std::string)childEntity["Blend"]["Pose2"], childEntity); return node; } else if (childEntity.HasComponent("BlendOverride")) { Node* node = new Node(); node->Name = childEntity.Name(); node->Parent = parentNode; node->Type = NodeType::Override; - node->Child[0] = FillTreeByName(node, (std::string)childEntity["BlendOverride"]["Master"], childEntity, skeleton); - node->Child[1] = FillTreeByName(node, (std::string)childEntity["BlendOverride"]["Slave"], childEntity, skeleton); + node->Child[0] = FillTreeByName(node, (std::string)childEntity["BlendOverride"]["Master"], childEntity); + node->Child[1] = FillTreeByName(node, (std::string)childEntity["BlendOverride"]["Slave"], childEntity); return node; } else if (childEntity.HasComponent("BlendAdditive")) { Node* node = new Node(); node->Name = childEntity.Name(); node->Parent = parentNode; node->Type = NodeType::Additive; - node->Child[0] = FillTreeByName(node, (std::string)childEntity["BlendAdditive"]["Adder"], childEntity, skeleton); - node->Child[1] = FillTreeByName(node, (std::string)childEntity["BlendAdditive"]["Receiver"], childEntity, skeleton); + node->Child[0] = FillTreeByName(node, (std::string)childEntity["BlendAdditive"]["Adder"], childEntity); + node->Child[1] = FillTreeByName(node, (std::string)childEntity["BlendAdditive"]["Receiver"], childEntity); return node; } + return nullptr; } -void BlendTree::Blend(Skeleton* skeleton, std::map& pose) +void BlendTree::Blend(std::map& pose) { Node* currentNode; Node* start = m_Root; @@ -219,7 +156,7 @@ void BlendTree::Blend(Skeleton* skeleton, std::map& pose) } currentNode = start; - LOG_INFO("\n\n"); + while (m_Root->Pose.size() == 0) { if(currentNode->Pose.size() == 0) { if (currentNode->Child[0] != nullptr && currentNode->Child[1] != nullptr) { @@ -227,20 +164,18 @@ void BlendTree::Blend(Skeleton* skeleton, std::map& pose) switch (currentNode->Type) { case BlendTree::NodeType::Additive: - currentNode->Pose = skeleton->BlendPoseAdditive(currentNode->Child[0]->Pose, currentNode->Child[1]->Pose); + currentNode->Pose = m_Skeleton->BlendPoseAdditive(currentNode->Child[0]->Pose, currentNode->Child[1]->Pose); break; case BlendTree::NodeType::Blend: - currentNode->Pose = skeleton->BlendPoses(currentNode->Child[0]->Pose, currentNode->Child[1]->Pose, currentNode->Weight); + currentNode->Pose = m_Skeleton->BlendPoses(currentNode->Child[0]->Pose, currentNode->Child[1]->Pose, currentNode->Weight); break; case BlendTree::NodeType::Override: - currentNode->Pose = skeleton->OverridePose(currentNode->Child[0]->Pose, currentNode->Child[1]->Pose); + currentNode->Pose = m_Skeleton->OverridePose(currentNode->Child[0]->Pose, currentNode->Child[1]->Pose); break; case BlendTree::NodeType::Animation: // do nothing break; } - - LOG_INFO("Blending %s and %s", currentNode->Child[0]->Name.c_str(), currentNode->Child[1]->Name.c_str()); } } else if (currentNode->Child[0] != nullptr) { if (currentNode->Child[0]->Pose.size() != 0) { @@ -264,21 +199,21 @@ void BlendTree::Blend(Skeleton* skeleton, std::map& pose) pose = m_Root->Pose; } -std::vector BlendTree::GetBoneTransforms(Skeleton* skeleton) +std::vector BlendTree::AccumulateFinalPose() { std::vector finalPose; - if (skeleton == nullptr || m_Root == nullptr) { + if (m_Skeleton == nullptr || m_Root == nullptr) { - for (int i = 0; i < skeleton->Bones.size(); i++) { + for (int i = 0; i < m_Skeleton->Bones.size(); i++) { finalPose.push_back(glm::mat4(1)); } return finalPose; } std::map pose; - Blend(skeleton, pose); + Blend(pose); - finalPose = skeleton->GetFinalPose(pose); + finalPose = m_Skeleton->GetFinalPose(pose); return finalPose; } diff --git a/src/Engine/Rendering/BoneAttachmentSystem.cpp b/src/Engine/Rendering/BoneAttachmentSystem.cpp index a4d381d1..0e259f4b 100644 --- a/src/Engine/Rendering/BoneAttachmentSystem.cpp +++ b/src/Engine/Rendering/BoneAttachmentSystem.cpp @@ -35,7 +35,7 @@ void BoneAttachmentSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapp return; } - std::vector<::Skeleton::AnimationData> Animations; + /* std::vector<::Skeleton::AnimationData> Animations; ::Skeleton::AnimationOffset AnimationOffset; glm::mat4 boneTransform; @@ -72,7 +72,7 @@ void BoneAttachmentSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapp glm::decompose(boneTransform, scale, rotation, translation, skew, perspective); glm::vec3 angles = glm::vec3(-glm::pitch(rotation), -glm::yaw(rotation), -glm::roll(rotation)); -/* +/ * angles.y = asin(-boneTransform[0][2]); if (cos(angles.y) != 0) { @@ -81,7 +81,7 @@ void BoneAttachmentSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapp } else { angles.x = atan2(-boneTransform[2][0], boneTransform[1][1]); angles.z = 0; - }*/ + }* / if ((bool)entity["BoneAttachment"]["InheritPosition"]) { (glm::vec3&)entity["Transform"]["Position"] = translation + (glm::vec3)entity["BoneAttachment"]["PositionOffset"]; @@ -91,5 +91,5 @@ void BoneAttachmentSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapp } if ((bool)entity["BoneAttachment"]["InheritScale"]) { (glm::vec3&)entity["Transform"]["Scale"] = scale * (glm::vec3)entity["BoneAttachment"]["ScaleOffset"]; - } + }*/ } diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 43722a61..b139f2ba 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -338,12 +338,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& //bind textures BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob); std::vector frameBones; - /*if (explosionEffectJob->AnimationOffset.animation != nullptr) { - frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); - } else { - frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); - }*/ - frameBones = explosionEffectJob->Skeleton->GetFrameBones(); + frameBones = explosionEffectJob->BlendTree->GetFinalPose(); glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } else { m_ExplosionEffectProgram->Bind(); @@ -366,12 +361,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& BindExplosionTextures(explosionSplatMapSkinnedHandle, explosionEffectJob); GLERROR("asdasd"); std::vector frameBones; - /*if (explosionEffectJob->AnimationOffset.animation != nullptr) { - frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); - } else { - frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); - }*/ - frameBones = explosionEffectJob->Skeleton->GetFrameBones(); + frameBones = explosionEffectJob->BlendTree->GetFinalPose(); glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } else { @@ -412,12 +402,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& //bind textures BindModelTextures(forwardSkinnedHandle, modelJob); std::vector frameBones; - /* if (modelJob->AnimationOffset.animation != nullptr) { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); - } else { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); - }*/ - frameBones = modelJob->BlendTree->GetBoneTransforms(modelJob->Skeleton); + frameBones = modelJob->BlendTree->GetFinalPose(); glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } else { @@ -441,12 +426,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& BindModelTextures(forwardSplatMapSkinnedHandle, modelJob); GLERROR("asdasd"); std::vector frameBones; - /* if (modelJob->AnimationOffset.animation != nullptr) { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); - } else { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); - }*/ - frameBones = modelJob->BlendTree->GetBoneTransforms(modelJob->Skeleton); + frameBones = modelJob->BlendTree->GetFinalPose(); glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } else { @@ -490,12 +470,7 @@ void DrawFinalPass::DrawShieldToStencilBuffer(std::listViewMatrix())); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); std::vector frameBones; - /*if (modelJob->AnimationOffset.animation != nullptr) { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); - } else { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); - }*/ - frameBones = modelJob->Skeleton->GetFrameBones(); + frameBones = modelJob->BlendTree->GetFinalPose(); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } else { m_ShieldToStencilProgram->Bind(); @@ -549,12 +524,7 @@ void DrawFinalPass::DrawShieldedModelRenderQueue(std::list frameBones; - /* if (explosionEffectJob->AnimationOffset.animation != nullptr) { - frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); - } else { - frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); - }*/ - frameBones = explosionEffectJob->Skeleton->GetFrameBones(); + frameBones = explosionEffectJob->BlendTree->GetFinalPose(); glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); if (GLERROR("Animation")) { @@ -589,12 +559,7 @@ void DrawFinalPass::DrawShieldedModelRenderQueue(std::list frameBones; - /* if (modelJob->AnimationOffset.animation != nullptr) { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); - } else { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); - }*/ - frameBones = modelJob->Skeleton->GetFrameBones(); + frameBones = modelJob->BlendTree->GetFinalPose(); glUniformMatrix4fv(glGetUniformLocation(forwardHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); @@ -626,12 +591,7 @@ void DrawFinalPass::DrawToDepthBuffer(std::list>& job glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); std::vector frameBones; - /*if (modelJob->AnimationOffset.animation != nullptr) { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); - } else { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); - }*/ - frameBones = modelJob->Skeleton->GetFrameBones(); + frameBones = modelJob->BlendTree->GetFinalPose(); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } else { diff --git a/src/Engine/Rendering/PickingPass.cpp b/src/Engine/Rendering/PickingPass.cpp index 479cb762..64483755 100644 --- a/src/Engine/Rendering/PickingPass.cpp +++ b/src/Engine/Rendering/PickingPass.cpp @@ -103,12 +103,7 @@ void PickingPass::Draw(RenderScene& scene) if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) { std::vector frameBones; - /*if (modelJob->AnimationOffset.animation != nullptr) { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); - } else { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); - }*/ - frameBones = modelJob->Skeleton->GetFrameBones(); + frameBones = modelJob->BlendTree->GetFinalPose(); glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } @@ -161,12 +156,7 @@ void PickingPass::Draw(RenderScene& scene) glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1]))); std::vector frameBones; - /* if (modelJob->AnimationOffset.animation != nullptr) { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); - } else { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); - }*/ - frameBones = modelJob->Skeleton->GetFrameBones(); + frameBones = modelJob->BlendTree->GetFinalPose(); glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } else { m_PickingProgram->Bind(); @@ -217,12 +207,7 @@ void PickingPass::Draw(RenderScene& scene) glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1]))); std::vector frameBones; - /* if (modelJob->AnimationOffset.animation != nullptr) { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); - } else { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); - }*/ - frameBones = modelJob->Skeleton->GetFrameBones(); + frameBones = modelJob->BlendTree->GetFinalPose(); glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } else { @@ -279,12 +264,7 @@ void PickingPass::Draw(RenderScene& scene) if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) { std::vector frameBones; - /*if (modelJob->AnimationOffset.animation != nullptr) { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); - } else { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); - }*/ - frameBones = modelJob->Skeleton->GetFrameBones(); + frameBones = modelJob->BlendTree->GetFinalPose(); glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } diff --git a/src/Engine/Rendering/Skeleton.cpp b/src/Engine/Rendering/Skeleton.cpp index e951b3c5..077e9d02 100644 --- a/src/Engine/Rendering/Skeleton.cpp +++ b/src/Engine/Rendering/Skeleton.cpp @@ -1,55 +1,6 @@ #include "Rendering/Skeleton.h" -int Skeleton::CreateBone(int ID, int parentID, std::string name, glm::mat4 offsetMatrix) -{ - if (m_BonesByName.find(name) != m_BonesByName.end()) { - return m_BonesByName.at(name)->ID; - } else { - Bone* bone; - - if (parentID == -1) { - bone = new Bone(ID, nullptr, name, offsetMatrix); - RootBone = bone; - } else { - Bone* parent = Bones[parentID]; - bone = new Bone(ID, parent, name, offsetMatrix); - parent->Children.push_back(bone); - } - - Bones[ID] = bone; - m_BonesByName[name] = bone; - return ID; - } -} - -Skeleton::~Skeleton() -{ - for (auto &kv : Bones) { - delete kv.second; - } -} - - - -const Skeleton::Animation* Skeleton::GetAnimation(std::string name) -{ - auto it = Animations.find(name); - if (it != Animations.end()) { - return const_cast(&it->second); - } else { - return nullptr; - } -} - -std::vector Skeleton::GetFrameBones() -{ - std::vector finalMatrices; - for (auto& b : Bones) { - finalMatrices.push_back(glm::mat4(1)); - } - return finalMatrices; -} -std::map Skeleton::GetFrameBones(const Animation* animation, const double time, bool additive, bool noRootMotion /*= false*/) +std::map Skeleton::GetFrameBones(const Animation* animation, double time, bool additive, bool noRootMotion /*= false*/) { if (animation == nullptr) { std::map finalMatrices; @@ -63,7 +14,7 @@ std::map Skeleton::GetFrameBones(const Animation* animation, con std::map frameBones; if(!additive) { - AccumulateBoneTransforms(true, animation, time, frameBones, additive, RootBone, glm::mat4(1)); + AccumulateBoneTransforms(true, animation, time, frameBones, RootBone, glm::mat4(1)); } else { AdditiveBoneTransforms(animation, time, frameBones, RootBone); } @@ -71,12 +22,8 @@ std::map Skeleton::GetFrameBones(const Animation* animation, con return frameBones; } -void Skeleton::AccumulateBoneTransforms(bool noRootMotion, const Animation* animation, double time, std::map& boneMatrices, bool additive, const Bone* bone, glm::mat4 parentMatrix) +void Skeleton::AccumulateBoneTransforms(bool noRootMotion, const Animation* animation, double time, std::map& boneMatrices, const Bone* bone, glm::mat4 parentMatrix) { - if (additive) { - time += 1.0/60.0; // first frame is a reference frame - } - glm::mat4 boneMatrix; @@ -138,7 +85,7 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, const Animation* anim } for (auto &child : bone->Children) { - AccumulateBoneTransforms(noRootMotion, animation, time, boneMatrices, additive, child, boneMatrix); + AccumulateBoneTransforms(noRootMotion, animation, time, boneMatrices, child, boneMatrix); } } @@ -157,20 +104,6 @@ void Skeleton::AdditiveBoneTransforms(const Animation* animation, double time, s } } - - -glm::mat4 Skeleton::AdditiveBlend(const Bone* bone, AnimationOffset animationOffset, glm::mat4 targetPose) -{ -/* - AnimationOffset refOffset = animationOffset; - refOffset.time = 0.5f; // reference pose is at 0.5s for now - glm::mat4 refPose = GetAdditiveBonePose(bone, refOffset); - glm::mat4 srcPose = GetAdditiveBonePose(bone, animationOffset); - glm::mat4 differencePose = srcPose * glm::inverse(refPose); - glm::mat4 finalPose = differencePose * targetPose;*/ - return glm::mat4(); -} - glm::mat4 Skeleton::GetAdditiveBonePose(const Bone* bone, const Animation* animation, double time) { glm::vec3 position = glm::vec3(0); @@ -227,9 +160,6 @@ glm::mat4 Skeleton::GetBonePose(const Bone* bone, const Animation* animation, do { glm::mat4 boneMatrix; - std::vector JointPoses; - - if (animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) { std::vector boneKeyFrames = animation->JointAnimations.at(bone->ID); @@ -346,235 +276,7 @@ glm::mat4 Skeleton::GetBoneTransform(const Bone* bone, const Animation* animatio } } -glm::mat4 Skeleton::GetBoneTransform(bool noRootMotion, const Bone* bone, std::vector animations, AnimationOffset animationOffset, glm::mat4 childMatrix) -{ - glm::mat4 boneMatrix; - - std::vector JointPoses; - - for (const AnimationData animationData : animations) { - const Animation* animation = animationData.animation; - const float time = animationData.time; - - JointFramePose jointPose; - jointPose.Weight = animationData.weight;; - - if (animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) { - std::vector boneKeyFrames = animation->JointAnimations.at(bone->ID); - - Animation::Keyframe currentFrame; - Animation::Keyframe nextFrame; - - if (boneKeyFrames.size() > 1) { // 2+ keyframes for the current bone - for (int index = boneKeyFrames.size()-1; index >= 0; index--) { // find the bone keyframes that surrounds the current frame - if (time >= boneKeyFrames.at(index).Time) { - currentFrame = boneKeyFrames.at(index); - nextFrame = boneKeyFrames.at((index + 1) % boneKeyFrames.size()); - break; - } - } - - float progress; - - if (nextFrame.Index == 0) { - nextFrame = currentFrame; - progress = (time - currentFrame.Time) / (animation->Duration - currentFrame.Time); - } else { - progress = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time); - - } - - - if (progress > 1.0f || progress < 0.0f) { - progress = glm::clamp(progress, 0.0f, 1.0f); - } - Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties; - Animation::Keyframe::BoneProperty nextBoneProperty = nextFrame.BoneProperties; - - glm::vec3 position = currentBoneProperty.Position * (1.f - progress) + nextBoneProperty.Position * progress; - glm::quat rotation = glm::slerp(currentBoneProperty.Rotation, nextBoneProperty.Rotation, progress); - glm::vec3 scale = currentBoneProperty.Scale * (1.f - progress) + nextBoneProperty.Scale * progress; - - // Flag for no root motion - if (bone == RootBone && noRootMotion) { - position.x = 0; - position.z = 0; - } - - jointPose.Pose = (glm::translate(position) * glm::toMat4(rotation) * glm::scale(scale)); - JointPoses.push_back(jointPose); - - } else { // 1 keyframes for the current bone - currentFrame = boneKeyFrames.at(0); - jointPose.Pose = (glm::translate(currentFrame.BoneProperties.Position) * glm::toMat4(currentFrame.BoneProperties.Rotation) * glm::scale(currentFrame.BoneProperties.Scale)); - JointPoses.push_back(jointPose); - } - } else { // 0 keyframes for the current bone - - } - - } - - - if (JointPoses.size() == 0) { - if (bone->Parent) { - - glm::mat4 jointPose = (glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix); - glm::mat4 boneTransform = AdditiveBlend(bone, animationOffset, jointPose); - - boneMatrix = boneTransform * childMatrix; - } else { - boneMatrix = glm::inverse(bone->OffsetMatrix) * childMatrix; - } - } else { - - float totalWeight = 0; - - for (JointFramePose jointFramePose : JointPoses) { - totalWeight += jointFramePose.Weight; - } - - glm::mat4 finalBlend = glm::mat4(0); - - for (JointFramePose jointFramePose : JointPoses) { - if (jointFramePose.Weight == 1.0f) { - finalBlend = jointFramePose.Pose; - } else { - finalBlend += jointFramePose.Pose * (jointFramePose.Weight / totalWeight); - } - } - - - glm::mat4 boneTransform = AdditiveBlend(bone, animationOffset, finalBlend); - boneMatrix = boneTransform * childMatrix; - } - - if (bone->Parent != nullptr) { - return GetBoneTransform(noRootMotion, bone->Parent, animations, animationOffset, boneMatrix); - } else { - return boneMatrix; - } -} - -glm::mat4 Skeleton::GetBoneTransform(bool noRootMotion, const Bone* bone, std::vector animations, glm::mat4 childMatrix) -{ - glm::mat4 boneMatrix; - /* std::vector JointTransforms; - - for (const AnimationData animationData : animations) { - const Animation* animation = animationData.animation; - const float time = animationData.time; - - JointFrameTransform jointTransform; - jointTransform.Weight = animationData.weight;; - - if (animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) { - std::vector boneKeyFrames = animation->JointAnimations.at(bone->ID); - - Animation::Keyframe currentFrame; - Animation::Keyframe nextFrame; - - if (boneKeyFrames.size() > 1) { // 2+ keyframes for the current bone - for (int index = boneKeyFrames.size()-1; index >= 0; index--) { // find the bone keyframes that surrounds the current frame - if (time >= boneKeyFrames.at(index).Time) { - currentFrame = boneKeyFrames.at(index); - nextFrame = boneKeyFrames.at((index + 1) % boneKeyFrames.size()); - break; - } - } - - float progress; - - if (nextFrame.Index == 0) { - nextFrame = currentFrame; - progress = (time - currentFrame.Time) / (animation->Duration - currentFrame.Time); - } else { - progress = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time); - - } - - - if (progress > 1.0f || progress < 0.0f) { - progress = glm::clamp(progress, 0.0f, 1.0f); - } - Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties; - Animation::Keyframe::BoneProperty nextBoneProperty = nextFrame.BoneProperties; - - jointTransform.Position = currentBoneProperty.Position * (1.f - progress) + nextBoneProperty.Position * progress; - jointTransform.Rotation = glm::slerp(currentBoneProperty.Rotation, nextBoneProperty.Rotation, progress); - jointTransform.Scale = currentBoneProperty.Scale * (1.f - progress) + nextBoneProperty.Scale * progress; - - // Flag for no root motion - if (bone == RootBone && noRootMotion) { - jointTransform.Position.x = 0; - jointTransform.Position.z = 0; - } - - JointTransforms.push_back(jointTransform); - - } else { // 1 keyframes for the current bone - currentFrame = boneKeyFrames.at(0); - jointTransform.Position = currentFrame.BoneProperties.Position; - jointTransform.Rotation = currentFrame.BoneProperties.Rotation; - jointTransform.Scale = currentFrame.BoneProperties.Scale; - JointTransforms.push_back(jointTransform); - - } - } else { // 0 keyframes for the current bone - - } - - } - - if (JointTransforms.size() <= 0) { - if (bone->Parent) { - boneMatrix = glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix * childMatrix; - } else { - boneMatrix = glm::inverse(bone->OffsetMatrix) * childMatrix; - } - } else if (JointTransforms.size() == 1) { - boneMatrix = (glm::translate(JointTransforms.at(0).Position) * glm::toMat4(JointTransforms.at(0).Rotation) * glm::scale(JointTransforms.at(0).Scale)) * childMatrix; - } else { - - glm::vec3 finalPosInterp; - glm::quat finalRotInterp; - glm::vec3 finalScaleInterp; - float totalWeight = 0; - - for (JointFrameTransform jointTransform : JointTransforms) { - totalWeight += jointTransform.Weight; - } - - - for (JointFrameTransform jointTransform : JointTransforms) { - if (jointTransform.Weight == 1.0f) { - finalPosInterp = jointTransform.Position; - finalRotInterp = jointTransform.Rotation; - finalScaleInterp = jointTransform.Scale; - break; - } else { - finalPosInterp += jointTransform.Position * (jointTransform.Weight/totalWeight); - finalRotInterp *= glm::slerp(glm::quat(), jointTransform.Rotation, (jointTransform.Weight/totalWeight)); - finalScaleInterp += jointTransform.Scale * (jointTransform.Weight/totalWeight); - } - - } - - boneMatrix = (glm::translate(finalPosInterp) * glm::toMat4(finalRotInterp) * glm::scale(finalScaleInterp)) * childMatrix; - } - - - if (bone->Parent != nullptr) { - return GetBoneTransform(noRootMotion, bone->Parent, animations, boneMatrix); - } else { - return boneMatrix; - }*/ - -return boneMatrix; -} - - -std::map Skeleton::BlendPoses(std::map pose1, std::map pose2, float weight) +std::map Skeleton::BlendPoses(const std::map& pose1, const std::map& pose2, float weight) { std::map finalPose; @@ -596,8 +298,7 @@ std::map Skeleton::BlendPoses(std::map pose1, st return finalPose; } - -std::map Skeleton::OverridePose(std::map overridePose, std::map targetPose) +std::map Skeleton::OverridePose(const std::map& overridePose, const std::map& targetPose) { std::map finalPose; @@ -612,8 +313,7 @@ std::map Skeleton::OverridePose(std::map overrid return finalPose; } - -std::map Skeleton::BlendPoseAdditive(std::map additivePose, std::map targetPose) +std::map Skeleton::BlendPoseAdditive(const std::map& additivePose, const std::map& targetPose) { std::map finalPose; @@ -683,3 +383,42 @@ int Skeleton::GetBoneID(std::string name) return m_BonesByName.at(name)->ID; } } + +int Skeleton::CreateBone(int ID, int parentID, std::string name, glm::mat4 offsetMatrix) +{ + if (m_BonesByName.find(name) != m_BonesByName.end()) { + return m_BonesByName.at(name)->ID; + } else { + Bone* bone; + + if (parentID == -1) { + bone = new Bone(ID, nullptr, name, offsetMatrix); + RootBone = bone; + } else { + Bone* parent = Bones[parentID]; + bone = new Bone(ID, parent, name, offsetMatrix); + parent->Children.push_back(bone); + } + + Bones[ID] = bone; + m_BonesByName[name] = bone; + return ID; + } +} + +Skeleton::~Skeleton() +{ + for (auto &kv : Bones) { + delete kv.second; + } +} + +const Skeleton::Animation* Skeleton::GetAnimation(std::string name) +{ + auto it = Animations.find(name); + if (it != Animations.end()) { + return const_cast(&it->second); + } else { + return nullptr; + } +} \ No newline at end of file From f10958c26808d770a4becbf825e4e127c97f9762 Mon Sep 17 00:00:00 2001 From: stiffly Date: Thu, 25 Feb 2016 11:50:29 +0100 Subject: [PATCH 055/252] Capturepoint logic is now purely done on the serverside. --- src/Game/Systems/CapturePointSystem.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Game/Systems/CapturePointSystem.cpp b/src/Game/Systems/CapturePointSystem.cpp index b45f6ced..c99a36a6 100644 --- a/src/Game/Systems/CapturePointSystem.cpp +++ b/src/Game/Systems/CapturePointSystem.cpp @@ -6,9 +6,11 @@ CapturePointSystem::CapturePointSystem(SystemParams params) , PureSystem("CapturePoint") { //subscribe/listenTo playerdamage,healthpickup events (using the eventBroker) - EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch); - EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave); - EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured); + if (!IsClient) { + EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch); + EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave); + EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured); + } } @@ -16,6 +18,9 @@ CapturePointSystem::CapturePointSystem(SystemParams params) //NOTE: needs to run each frame, since we're possibly modifying the captureTimer for the capturePoints by dt void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, ComponentWrapper& cCapturePoint, double dt) { + if (IsClient) { + return; + } if (m_WinnerWasFound) { return; } From 8ce6308649a93f69099e13c9f9dd6618f0300e8b Mon Sep 17 00:00:00 2001 From: stiffly Date: Thu, 25 Feb 2016 11:56:40 +0100 Subject: [PATCH 056/252] In snapshot: now sends player information and also CP information. Now it is no longer true that they will arrive in pre order. Appropriate actions were therefor implemented. --- include/Engine/Network/Client.h | 1 - src/Engine/Network/Client.cpp | 25 ++++------- src/Engine/Network/Server.cpp | 80 +++++++++++++++++---------------- 3 files changed, 50 insertions(+), 56 deletions(-) diff --git a/include/Engine/Network/Client.h b/include/Engine/Network/Client.h index d08b863a..7d23670a 100644 --- a/include/Engine/Network/Client.h +++ b/include/Engine/Network/Client.h @@ -103,7 +103,6 @@ public: void parseComponentDeletion(Packet& packet); void InterpolateFields(Packet & packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType); void parseSnapshot(Packet& packet); - void UpdateLocalCapturePointHUD(EntityWrapper capturePointHUD); void identifyPacketLoss(); void hasServerTimedOut(); EntityID createPlayer(); diff --git a/src/Engine/Network/Client.cpp b/src/Engine/Network/Client.cpp index 903cd929..5fb5c487 100644 --- a/src/Engine/Network/Client.cpp +++ b/src/Engine/Network/Client.cpp @@ -348,9 +348,7 @@ void Client::parseSnapshot(Packet& packet) EntityWrapper localEntity(m_World, localEntityID); // Update entity if (m_World->HasComponent(localEntityID, componentType)) { - if (localEntity.Name() == "CapturePointHUD") { - UpdateLocalCapturePointHUD(localEntity); - } + SharedComponentWrapper newComponent = createSharedComponent(packet, localEntityID, componentInfo); bool shouldApply = true; // Apply potential filter function @@ -361,6 +359,7 @@ void Client::parseSnapshot(Packet& packet) ComponentWrapper currentComponent = m_World->GetComponent(localEntityID, componentType); memcpy(currentComponent.Data, newComponent.Data, componentInfo.Stride); } + //if (localEntity != m_LocalPlayer && !localEntity.IsChildOf(m_LocalPlayer)) { // updateFields(packet, componentInfo, localEntityID); //} else { @@ -377,7 +376,11 @@ void Client::parseSnapshot(Packet& packet) if (serverParentID == EntityID_Invalid) { newLocalEntityID = m_World->CreateEntity(EntityID_Invalid); } else { - newLocalEntityID = m_World->CreateEntity(m_ServerIDToClientID.at(serverParentID)); + if (serverClientMapsHasEntity(serverParentID)) { + newLocalEntityID = m_World->CreateEntity(m_ServerIDToClientID.at(serverParentID)); + } else { + newLocalEntityID = m_World->CreateEntity(EntityID_Invalid); + } } m_World->SetName(newLocalEntityID, serverEntityName); insertIntoServerClientMaps(serverEntityID, newLocalEntityID); @@ -387,7 +390,7 @@ void Client::parseSnapshot(Packet& packet) } // Parent logic // This should be enough beacause we know that the entities arives in pre-order (there will always be a parent) - if (serverParentID != EntityID_Invalid) { + if (serverParentID != EntityID_Invalid && serverClientMapsHasEntity(serverParentID)) { EntityID localEntityID = m_ServerIDToClientID.at(serverEntityID); m_World->SetParent(localEntityID, m_ServerIDToClientID.at(serverParentID)); } @@ -395,18 +398,6 @@ void Client::parseSnapshot(Packet& packet) parseSpawnEvents(); } - -void Client::UpdateLocalCapturePointHUD(EntityWrapper capturePointHUD) -{ - //auto children = m_World->GetChildren(capturePointHUD.ID); - //for (auto it = children.first; it != children.second; it++) { - // it->first - //} - // - //EntityWrapper& localHUD = m_LocalPlayer.FirstChildByName("HUD").FirstChildByName("CapturePointHUD"); - //m_World->GetComponentPools() -} - void Client::disconnect() { m_IsConnected = false; diff --git a/src/Engine/Network/Server.cpp b/src/Engine/Network/Server.cpp index 8783a7b0..aa7d71d5 100644 --- a/src/Engine/Network/Server.cpp +++ b/src/Engine/Network/Server.cpp @@ -65,7 +65,7 @@ void Server::Update() PlayerDefinition localArea; localArea.Endpoint = boost::asio::ip::udp::endpoint(); m_ServerlistRequest.Receive(packet, localArea); - if(packet.GetMessageType() == MessageType::ServerlistRequest) { + if (packet.GetMessageType() == MessageType::ServerlistRequest) { packet.ReadPrimitive(); // Pop size packet.ReadPrimitive(); // Pop MsgType packet.ReadPrimitive(); // Pop packet ID @@ -76,7 +76,7 @@ void Server::Update() } // Check if players have disconnected - for (int i = 0; i < m_PlayersToDisconnect.size(); i++) { + for (int i = 0; i < m_PlayersToDisconnect.size(); i++) { disconnect(m_PlayersToDisconnect.at(i)); } m_PlayersToDisconnect.clear(); @@ -136,7 +136,7 @@ void Server::parseMessageType(Packet& packet) parseOnPlayerDamage(packet); break; case MessageType::PlayerTransform: - parsePlayerTransform(packet); + parsePlayerTransform(packet); break; default: break; @@ -191,43 +191,41 @@ void Server::addPlayersToPacket(Packet & packet, EntityID entityID) // HACK: Only sync players for now, since the map turned out to be TOO LARGE to send in one snapshot and Simon's computer shits itself // HACK: Also checked CapturePointHUD for now. (this would get out of sync); EntityWrapper childEntity(m_World, childEntityID); - if (!shouldSendToClient(childEntity)) { - continue; - } - - // Write EntityID and parentsID and Entity name - packet.WritePrimitive(childEntityID); - packet.WritePrimitive(entityID); - packet.WriteString(m_World->GetName(childEntityID)); - // Write components to child - int numberOfComponents = 0; - for (auto& i : worldComponentPools) { - if (i.second->KnowsEntity(childEntityID)) { - numberOfComponents++; + if (shouldSendToClient(childEntity)) { + // Write EntityID and parentsID and Entity name + packet.WritePrimitive(childEntityID); + packet.WritePrimitive(entityID); + packet.WriteString(m_World->GetName(childEntityID)); + // Write components to child + int numberOfComponents = 0; + for (auto& i : worldComponentPools) { + if (i.second->KnowsEntity(childEntityID)) { + numberOfComponents++; + } } - } - // Write how many components should be read - packet.WritePrimitive(numberOfComponents); - for (auto& i : worldComponentPools) { - // If the entity exist in the pool - if (i.second->KnowsEntity(childEntityID)) { - ComponentWrapper componentWrapper = i.second->GetByEntity(childEntityID); - // ComponentType - packet.WriteString(componentWrapper.Info.Name); - // Loop through fields - for (auto& componentField : componentWrapper.Info.FieldsInOrder) { - ComponentInfo::Field_t fieldInfo = componentWrapper.Info.Fields.at(componentField); - if (fieldInfo.Type == "string") { - std::string& value = componentWrapper[componentField]; - packet.WriteString(value); - } else { - packet.WriteData(componentWrapper.Data + fieldInfo.Offset, fieldInfo.Stride); + // Write how many components should be read + packet.WritePrimitive(numberOfComponents); + for (auto& i : worldComponentPools) { + // If the entity exist in the pool + if (i.second->KnowsEntity(childEntityID)) { + ComponentWrapper componentWrapper = i.second->GetByEntity(childEntityID); + // ComponentType + packet.WriteString(componentWrapper.Info.Name); + // Loop through fields + for (auto& componentField : componentWrapper.Info.FieldsInOrder) { + ComponentInfo::Field_t fieldInfo = componentWrapper.Info.Fields.at(componentField); + if (fieldInfo.Type == "string") { + std::string& value = componentWrapper[componentField]; + packet.WriteString(value); + } else { + packet.WriteData(componentWrapper.Data + fieldInfo.Offset, fieldInfo.Stride); + } } } } } // Go to to your children - addChildrenToPacket(packet, childEntityID); + addPlayersToPacket(packet, childEntityID); } } @@ -343,7 +341,7 @@ void Server::parseTCPConnect(Packet & packet) // Read packet ID m_PreviousPacketID = m_PacketID; // Set previous packet id m_PacketID = packet.ReadPrimitive(); //Read new packet id - + LOG_INFO("Parsing connections"); // Check if player is already connected // Ska vara till lagd i TCPServer receive @@ -455,8 +453,7 @@ bool Server::OnInputCommand(const Events::InputCommand & e) } isReadingData = !isReadingData; m_SaveDataTimer = std::clock(); - } - else if (e.Command == "KickPlayer" && e.Value > 0) { + } else if (e.Command == "KickPlayer" && e.Value > 0) { kick(0); } @@ -595,8 +592,15 @@ void Server::parsePlayerTransform(Packet& packet) bool Server::shouldSendToClient(EntityWrapper childEntity) { + auto children = m_World->GetChildren(childEntity.ID); + for (auto it = children.first; it != children.second; it++) { + EntityWrapper child(m_World, it->second); + if(child.HasComponent("CapturePoint")) { + return true; + } + } return childEntity.HasComponent("Player") || childEntity.FirstParentWithComponent("Player").Valid() - || childEntity.HasComponent("CapturePoint") || childEntity.FirstParentWithComponent("CapturePoint").Valid(); + || childEntity.HasComponent("CapturePoint"); } PlayerID Server::GetPlayerIDFromEndpoint() From cd315bbaa05bb022d36ae80bdacffd0eadd6b71d Mon Sep 17 00:00:00 2001 From: William Moberg Date: Thu, 25 Feb 2016 12:12:44 +0100 Subject: [PATCH 057/252] Added DoubleJump component and JumpSpeed in Player component so jumpheight can be adjusted for regular jump and double jump. --- resources/Schema/Components.xsd | 1 + resources/Schema/Components/DoubleJump.xml | 4 ++++ resources/Schema/Components/DoubleJump.xsd | 16 ++++++++++++++++ resources/Schema/Components/Player.xml | 1 + resources/Schema/Components/Player.xsd | 3 +++ resources/Schema/Entities/Player.xml | 1 + resources/Schema/Entities/PlayerRed.xml | 1 + src/Game/Systems/PlayerMovementSystem.cpp | 17 +++++++++++------ 8 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 resources/Schema/Components/DoubleJump.xml create mode 100644 resources/Schema/Components/DoubleJump.xsd diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index 42abed82..e2d07374 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -46,4 +46,5 @@ + \ No newline at end of file diff --git a/resources/Schema/Components/DoubleJump.xml b/resources/Schema/Components/DoubleJump.xml new file mode 100644 index 00000000..bb0d3bc7 --- /dev/null +++ b/resources/Schema/Components/DoubleJump.xml @@ -0,0 +1,4 @@ + + + 4.0 + \ No newline at end of file diff --git a/resources/Schema/Components/DoubleJump.xsd b/resources/Schema/Components/DoubleJump.xsd new file mode 100644 index 00000000..65ff0419 --- /dev/null +++ b/resources/Schema/Components/DoubleJump.xsd @@ -0,0 +1,16 @@ + + + + + + + Enables a Player to double jump. + + + + Vertical velocity set on double jump. + + + + + \ No newline at end of file diff --git a/resources/Schema/Components/Player.xml b/resources/Schema/Components/Player.xml index 00cff257..429aa5fb 100644 --- a/resources/Schema/Components/Player.xml +++ b/resources/Schema/Components/Player.xml @@ -2,5 +2,6 @@ 3 1.5 + 4.0 \ No newline at end of file diff --git a/resources/Schema/Components/Player.xsd b/resources/Schema/Components/Player.xsd index 1b33d222..b121fd06 100644 --- a/resources/Schema/Components/Player.xsd +++ b/resources/Schema/Components/Player.xsd @@ -11,6 +11,9 @@ + + Vertical velocity set when jumping. + diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 7a5d2eb4..569dbc77 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -11,6 +11,7 @@ + diff --git a/resources/Schema/Entities/PlayerRed.xml b/resources/Schema/Entities/PlayerRed.xml index cd01632e..3285a91f 100644 --- a/resources/Schema/Entities/PlayerRed.xml +++ b/resources/Schema/Entities/PlayerRed.xml @@ -11,6 +11,7 @@ + diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index a144dd18..916573a4 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -116,12 +116,18 @@ void PlayerMovementSystem::updateMovementControllers(double dt) 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 (!controller->PlayerIsDashing() && controller->Jumping() && !controller->Crouching() && (isOnGround || !controller->DoubleJumping())) { - (bool)cPhysics["IsOnGround"] = false; + if (isOnGround) { + controller->SetDoubleJumping(false); + } + //If player presses Jump and is not crouching. + if (controller->Jumping() && !controller->Crouching()) { if (isOnGround) { - controller->SetDoubleJumping(false); - } else { + (bool)cPhysics["IsOnGround"] = false; + velocity.y = player["Player"]["JumpSpeed"]; + } else if (player.HasComponent("DoubleJump") && !controller->DoubleJumping()) { + //Enter here if player can double jump and is doing so. + (bool)cPhysics["IsOnGround"] = false; + velocity.y = player["DoubleJump"]["DoubleJumpSpeed"]; if (IsClient) { //put a hexagon at the players feet auto hexagonEffect = ResourceManager::Load("Schema/Entities/DoubleJumpHexagon.xml"); @@ -134,7 +140,6 @@ void PlayerMovementSystem::updateMovementControllers(double dt) m_EventBroker->Publish(e); } } - velocity.y = 4.f; } if (player.HasComponent("AABB")) { From 508d8a6f008e3323da73c03035ab4c9b7df5e996 Mon Sep 17 00:00:00 2001 From: Jocke Date: Thu, 25 Feb 2016 14:24:38 +0100 Subject: [PATCH 058/252] Fixed memory leak in TCPServer::AcceptNewConnections caused by acceptor->async_accept(). Fixed some formating and comments. --- include/Engine/Network/TCPServer.h | 5 ++-- src/Engine/Network/Client.cpp | 24 +++++++++------- src/Engine/Network/Server.cpp | 4 +-- src/Engine/Network/TCPServer.cpp | 45 +++++++++++++----------------- 4 files changed, 37 insertions(+), 41 deletions(-) diff --git a/include/Engine/Network/TCPServer.h b/include/Engine/Network/TCPServer.h index 9cc7646a..61184470 100644 --- a/include/Engine/Network/TCPServer.h +++ b/include/Engine/Network/TCPServer.h @@ -22,10 +22,9 @@ private: std::unique_ptr acceptor; boost::shared_ptr lastReceivedSocket; - void handle_accept(boost::shared_ptr socket, - int& nextPlayerID, std::map& connectedPlayers, - const boost::system::error_code& error); int readBuffer(char* data, PlayerDefinition& playerDefinition); + PlayerID getPlayerIDFromEndpoint(const std::map& connectedPlayers, + boost::asio::ip::address address, unsigned short port); }; #endif \ No newline at end of file diff --git a/src/Engine/Network/Client.cpp b/src/Engine/Network/Client.cpp index ad72571c..c11f86f5 100644 --- a/src/Engine/Network/Client.cpp +++ b/src/Engine/Network/Client.cpp @@ -1,7 +1,7 @@ #include "Network/Client.h" using namespace boost::asio::ip; -Client::Client(World* world, EventBroker* eventBroker) +Client::Client(World* world, EventBroker* eventBroker) : Network(world, eventBroker) { // Asumes root node is EntityID_Invalid @@ -194,12 +194,12 @@ void Client::parseSpawnEvents() } e.Player = EntityWrapper(m_World, m_ServerIDToClientID.at(m_PlayerSpawnEvents.at(i).Player.ID)); //e.Spawner = EntityWrapper(m_World, m_ServerIDToClientID.at(m_PlayerSpawnEvents.at(i).Spawner.ID)); - e.PlayerID = -1; + e.PlayerID = -1; e.PlayerName = m_PlayerSpawnEvents.at(i).PlayerName; m_EventBroker->Publish(e); } m_PlayerSpawnEvents = tempSpawn; - // m_PlayerSpawnEvents.clear(); + // m_PlayerSpawnEvents.clear(); } void Client::parsePlayersSpawned(Packet& packet) @@ -243,14 +243,14 @@ void Client::parseComponentDeletion(Packet & packet) } void Client::parseDoubleJump(Packet & packet) -{ +{ EntityID serverID = packet.ReadPrimitive(); if (!serverClientMapsHasEntity(serverID)) { return; } Events::DoubleJump e; e.entityID = m_ServerIDToClientID.at(serverID); - // If player is local player to publish to prevent infinite feedback loop + // If player is local player do not publish to prevent infinite feedback loop if (e.entityID != m_LocalPlayer.ID) { m_EventBroker->Publish(e); } @@ -330,9 +330,10 @@ void Client::parseSnapshot(Packet& packet) if (serverClientMapsHasEntity(serverEntityID)) { EntityID localEntityID = m_ServerIDToClientID.at(serverEntityID); EntityWrapper localEntity(m_World, localEntityID); - + // Update entity if (m_World->HasComponent(localEntityID, componentType)) { + // TODO Fix memory leak here SharedComponentWrapper newComponent = createSharedComponent(packet, localEntityID, componentInfo); bool shouldApply = true; // Apply potential filter function @@ -343,6 +344,7 @@ void Client::parseSnapshot(Packet& packet) ComponentWrapper currentComponent = m_World->GetComponent(localEntityID, componentType); memcpy(currentComponent.Data, newComponent.Data, componentInfo.Stride); } + //if (localEntity != m_LocalPlayer && !localEntity.IsChildOf(m_LocalPlayer)) { // updateFields(packet, componentInfo, localEntityID); //} else { @@ -371,7 +373,9 @@ void Client::parseSnapshot(Packet& packet) // This should be enough beacause we know that the entities arives in pre-order (there will always be a parent) if (serverParentID != EntityID_Invalid) { EntityID localEntityID = m_ServerIDToClientID.at(serverEntityID); - m_World->SetParent(localEntityID, m_ServerIDToClientID.at(serverParentID)); + if (m_World->GetParent(localEntityID) != m_ServerIDToClientID.at(serverParentID)) { + m_World->SetParent(localEntityID, m_ServerIDToClientID.at(serverParentID)); + } } } parseSpawnEvents(); @@ -461,7 +465,7 @@ void Client::parsePlayerDamage(Packet& packet) Events::PlayerDamage e; PlayerID victimID = packet.ReadPrimitive(); PlayerID inflictorID = packet.ReadPrimitive(); - if(!serverClientMapsHasEntity(victimID) || !serverClientMapsHasEntity(inflictorID)){ + if (!serverClientMapsHasEntity(victimID) || !serverClientMapsHasEntity(inflictorID)) { return; } e.Inflictor = EntityWrapper(m_World, m_ServerIDToClientID.at(victimID)); @@ -501,7 +505,7 @@ void Client::sendLocalPlayerTransform() packet.WritePrimitive(orientation.x); packet.WritePrimitive(orientation.y); packet.WritePrimitive(orientation.z); - + bool hasAssaultWeapon = m_LocalPlayer.HasComponent("AssaultWeapon"); packet.WritePrimitive(hasAssaultWeapon); if (hasAssaultWeapon) { @@ -509,7 +513,7 @@ void Client::sendLocalPlayerTransform() packet.WritePrimitive((int)cAssaultWeapon["MagazineAmmo"]); packet.WritePrimitive((int)cAssaultWeapon["Ammo"]); } - + m_Unreliable.Send(packet); } diff --git a/src/Engine/Network/Server.cpp b/src/Engine/Network/Server.cpp index 1a063067..547e1641 100644 --- a/src/Engine/Network/Server.cpp +++ b/src/Engine/Network/Server.cpp @@ -28,9 +28,8 @@ Server::~Server() void Server::Update() { - PlayerDefinition pd; - m_Reliable.AcceptNewConnections(m_NextPlayerID, m_ConnectedPlayers); + for (auto& kv : m_ConnectedPlayers) { while (kv.second.TCPSocket->available()) { // Packet will get real data in receive @@ -46,6 +45,7 @@ void Server::Update() } } + PlayerDefinition pd; while (m_Unreliable.IsSocketAvailable()) { // Packet will get real data in receive Packet packet(MessageType::Invalid); diff --git a/src/Engine/Network/TCPServer.cpp b/src/Engine/Network/TCPServer.cpp index a449e684..6fdc28ce 100644 --- a/src/Engine/Network/TCPServer.cpp +++ b/src/Engine/Network/TCPServer.cpp @@ -4,22 +4,33 @@ using namespace boost::asio::ip; TCPServer::TCPServer() { acceptor = std::unique_ptr(new tcp::acceptor(m_IOService, tcp::endpoint(tcp::v4(), 27666))); + // Make the acceptor non-blocking so we wont get stuck in AcceptNewConnections(). + acceptor->non_blocking(true); } TCPServer::~TCPServer() -{ -} +{ } void TCPServer::AcceptNewConnections(int& nextPlayerID, std::map& connectedPlayers) { + boost::system::error_code error; boost::shared_ptr newSocket = boost::shared_ptr(new tcp::socket(m_IOService)); - m_IOService.poll(); - acceptor->async_accept(*newSocket, - boost::bind(&TCPServer::handle_accept, this, newSocket, boost::ref(nextPlayerID), boost::ref(connectedPlayers), - boost::asio::placeholders::error)); + acceptor->accept(*newSocket, error); + // If no error occured add new tcp connection + if (!error) { + // Add tcp socket to connections + boost::asio::ip::tcp::no_delay option(true); + newSocket->set_option(option); + PlayerDefinition pd; + pd.StopTime = std::clock(); + pd.TCPSocket = newSocket; + pd.TCPAddress = newSocket.get()->remote_endpoint().address(); + pd.TCPPort = newSocket.get()->remote_endpoint().port(); + connectedPlayers[nextPlayerID++] = pd; + } } -PlayerID GetPlayerIDFromEndpoint(const std::map& connectedPlayers, +PlayerID TCPServer::getPlayerIDFromEndpoint(const std::map& connectedPlayers, boost::asio::ip::address address, unsigned short port) { for (auto& kv : connectedPlayers) { @@ -31,24 +42,6 @@ PlayerID GetPlayerIDFromEndpoint(const std::map& con return -1; } -void TCPServer::handle_accept(boost::shared_ptr socket, - int& nextPlayerID, std::map& connectedPlayers, - const boost::system::error_code& error) -{ - if (!error && GetPlayerIDFromEndpoint(connectedPlayers, socket->remote_endpoint().address(), - socket->remote_endpoint().port()) == -1) { - // Add tcp socket to connections - boost::asio::ip::tcp::no_delay option(true); - socket->set_option(option); - PlayerDefinition pd; - pd.StopTime = std::clock(); - pd.TCPSocket = socket; - pd.TCPAddress = socket.get()->remote_endpoint().address(); - pd.TCPPort = socket.get()->remote_endpoint().port(); - connectedPlayers[nextPlayerID++] = pd; - } -} - void TCPServer::Send(Packet & packet, PlayerDefinition & playerDefinition) { try { @@ -73,7 +66,7 @@ void TCPServer::Send(Packet & packet) } void TCPServer::Disconnect() -{ +{ } From 059fe5c6c0b76e973d1f7c9f0db55b5d09a9f970 Mon Sep 17 00:00:00 2001 From: Jocke Date: Thu, 25 Feb 2016 16:04:27 +0100 Subject: [PATCH 059/252] Fixed typo m_EPDoubleJump to m_EDoubleJump. --- include/Engine/Network/Client.h | 2 +- include/Game/Systems/PlayerMovementSystem.h | 2 +- src/Engine/Network/Client.cpp | 2 +- src/Game/Systems/PlayerMovementSystem.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/Engine/Network/Client.h b/include/Engine/Network/Client.h index 10a78bfd..a983a685 100644 --- a/include/Engine/Network/Client.h +++ b/include/Engine/Network/Client.h @@ -131,7 +131,7 @@ private: EventRelay m_EPlayerSpawned; bool OnPlayerSpawned(const Events::PlayerSpawned& e); EventRelay< Client, Events::SearchForServers> m_ESearchForServers; - EventRelay m_EPDoubleJump; + EventRelay m_EDoubleJump; bool OnDoubleJump(Events::DoubleJump & e); bool OnSearchForServers(const Events::SearchForServers& e); UDPClient m_ServerlistRequest; diff --git a/include/Game/Systems/PlayerMovementSystem.h b/include/Game/Systems/PlayerMovementSystem.h index 43b0c4e3..92aa1915 100644 --- a/include/Game/Systems/PlayerMovementSystem.h +++ b/include/Game/Systems/PlayerMovementSystem.h @@ -39,7 +39,7 @@ private: EventRelay m_EPlayerSpawned; bool OnPlayerSpawned(Events::PlayerSpawned& e); - EventRelay m_EPDoubleJump; + EventRelay m_EDoubleJump; bool PlayerMovementSystem::OnDoubleJump(Events::DoubleJump & e); void updateMovementControllers(double dt); diff --git a/src/Engine/Network/Client.cpp b/src/Engine/Network/Client.cpp index dbd21d60..6ffce751 100644 --- a/src/Engine/Network/Client.cpp +++ b/src/Engine/Network/Client.cpp @@ -32,7 +32,7 @@ void Client::Connect(std::string address, int port) EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Client::OnInputCommand); EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &Client::OnPlayerDamage); EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &Client::OnPlayerSpawned); - EVENT_SUBSCRIBE_MEMBER(m_EPDoubleJump, &Client::OnDoubleJump); + EVENT_SUBSCRIBE_MEMBER(m_EDoubleJump, &Client::OnDoubleJump); EVENT_SUBSCRIBE_MEMBER(m_ESearchForServers, &Client::OnSearchForServers); auto config = ResourceManager::Load("Config.ini"); m_Address = address; diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index b69e8380..2e2502ec 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -4,7 +4,7 @@ PlayerMovementSystem::PlayerMovementSystem(SystemParams params) : System(params) { EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &PlayerMovementSystem::OnPlayerSpawned); - EVENT_SUBSCRIBE_MEMBER(m_EPDoubleJump, &PlayerMovementSystem::OnDoubleJump); + EVENT_SUBSCRIBE_MEMBER(m_EDoubleJump, &PlayerMovementSystem::OnDoubleJump); } PlayerMovementSystem::~PlayerMovementSystem() From 89d0d5753f8745b58ef561f5aa76e239550075fd Mon Sep 17 00:00:00 2001 From: William Moberg Date: Thu, 25 Feb 2016 16:16:24 +0100 Subject: [PATCH 060/252] Fix for player teleporting to (0,0,0). Saves player previous position in CollisionSystem instead of Physics component so it won't be saved when editing Players. --- include/Engine/Collision/CollisionSystem.h | 1 + resources/Schema/Components/Physics.xml | 1 - resources/Schema/Components/Physics.xsd | 1 - resources/Schema/Entities/Player.xml | 1 - resources/Schema/Entities/PlayerRed.xml | 1 - src/Engine/Collision/CollisionSystem.cpp | 88 +++++++++++----------- 6 files changed, 46 insertions(+), 47 deletions(-) diff --git a/include/Engine/Collision/CollisionSystem.h b/include/Engine/Collision/CollisionSystem.h index 9cd2fe63..19adea35 100644 --- a/include/Engine/Collision/CollisionSystem.h +++ b/include/Engine/Collision/CollisionSystem.h @@ -24,6 +24,7 @@ public: private: Octree* m_Octree; std::vector m_OctreeResult; + std::unordered_map m_PrevPositions; }; #endif \ No newline at end of file diff --git a/resources/Schema/Components/Physics.xml b/resources/Schema/Components/Physics.xml index 84b6aba3..6cb73c75 100644 --- a/resources/Schema/Components/Physics.xml +++ b/resources/Schema/Components/Physics.xml @@ -2,7 +2,6 @@ true - false 0.33 diff --git a/resources/Schema/Components/Physics.xsd b/resources/Schema/Components/Physics.xsd index 206e2a23..7fed1fb5 100644 --- a/resources/Schema/Components/Physics.xsd +++ b/resources/Schema/Components/Physics.xsd @@ -13,7 +13,6 @@ m/s^2 - The largest height of a "stair-step" that can be walked over diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 7a5d2eb4..4f012955 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -13,7 +13,6 @@ - diff --git a/resources/Schema/Entities/PlayerRed.xml b/resources/Schema/Entities/PlayerRed.xml index cd01632e..d56fa3c1 100644 --- a/resources/Schema/Entities/PlayerRed.xml +++ b/resources/Schema/Entities/PlayerRed.xml @@ -13,7 +13,6 @@ - diff --git a/src/Engine/Collision/CollisionSystem.cpp b/src/Engine/Collision/CollisionSystem.cpp index fcc3665f..9689bf13 100644 --- a/src/Engine/Collision/CollisionSystem.cpp +++ b/src/Engine/Collision/CollisionSystem.cpp @@ -16,51 +16,51 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c EntityAABB& boxA = *boundingBox; bool everHitTheGround = false; - glm::vec3 size = boxA.Size(); - float diameter = std::min(size.x, size.z); - glm::vec3 prevOrigin = (glm::vec3)cPhysics["PrevOrigin"]; - glm::vec3 toCurrentPos = boxA.Origin() - prevOrigin; - float rayLength = glm::length(toCurrentPos) + 0.5f*diameter; - //If the entity has moved farther than the size of its box, we need to handle it specially. - bool traceCollision = rayLength > diameter; - //hack solution: If prevOrigin is less than -9000 in all dimensions, - //then it means it is not set, i.e. this is the first collision check for the entity. - if (traceCollision && glm::any(glm::greaterThan((glm::vec3)cPhysics["PrevOrigin"], glm::vec3(-9000.f)))) { - Ray ray(prevOrigin, toCurrentPos); - m_OctreeResult.clear(); - m_Octree->ObjectsPossiblyHitByRay(ray, m_OctreeResult); - for (auto& boxB : m_OctreeResult) { - if (boxA.Entity == boxB.Entity) { - continue; - } - bool hit; - float dist; - if (boxB.Entity.HasComponent("Model")) { - RawModel* model; - std::string res = (std::string)boxB.Entity["Model"]["Resource"]; - try { - model = ResourceManager::Load(res); - } catch (const std::exception&) { + auto prevPosIt = m_PrevPositions.find(entity); + if (prevPosIt != m_PrevPositions.end()) { + glm::vec3 size = boxA.Size(); + float diameter = std::min(size.x, size.z); + glm::vec3 prevOrigin = prevPosIt->second; + glm::vec3 toCurrentPos = boxA.Origin() - prevOrigin; + float rayLength = glm::length(toCurrentPos) + 0.5f*diameter; + //If the entity has moved farther than the size of its box, we need to handle it specially. + if (rayLength > diameter) { + Ray ray(prevOrigin, toCurrentPos); + m_OctreeResult.clear(); + m_Octree->ObjectsPossiblyHitByRay(ray, m_OctreeResult); + for (auto& boxB : m_OctreeResult) { + if (boxA.Entity == boxB.Entity) { continue; } - float u, v; - hit = Collision::RayVsModel(ray, model->Vertices(), model->m_Indices, Transform::ModelMatrix(boxB.Entity), dist, u, v); - } else { - hit = Collision::RayVsAABB(ray, boxB, dist); - } - if (hit && dist < rayLength) { - //Set the entity to where it was colliding, minus the maximum box size. - //TODO: Perhaps this should be done slightly more properly. - glm::vec3 newOriginPos = ray.Origin() + (dist - 0.707107f*diameter) * ray.Direction(); - glm::vec3 resolve = newOriginPos - boxA.Origin(); - (glm::vec3&)cTransform["Position"] += resolve; - boxA = *Collision::EntityAbsoluteAABB(entity); - if (resolve.y > 0) { - everHitTheGround = true; - (bool)cPhysics["IsOnGround"] = true; - ((glm::vec3&)cPhysics["Velocity"]).y = 0.f; + bool hit; + float dist; + if (boxB.Entity.HasComponent("Model")) { + RawModel* model; + std::string res = (std::string)boxB.Entity["Model"]["Resource"]; + try { + model = ResourceManager::Load(res); + } catch (const std::exception&) { + continue; + } + float u, v; + hit = Collision::RayVsModel(ray, model->Vertices(), model->m_Indices, Transform::ModelMatrix(boxB.Entity), dist, u, v); + } else { + hit = Collision::RayVsAABB(ray, boxB, dist); + } + if (hit && dist < rayLength) { + //Set the entity to where it was colliding, minus the maximum box size. + //TODO: Perhaps this should be done slightly more properly. + glm::vec3 newOriginPos = ray.Origin() + (dist - 0.707107f*diameter) * ray.Direction(); + glm::vec3 resolve = newOriginPos - boxA.Origin(); + (glm::vec3&)cTransform["Position"] += resolve; + boxA = *Collision::EntityAbsoluteAABB(entity); + if (resolve.y > 0) { + everHitTheGround = true; + (bool)cPhysics["IsOnGround"] = true; + ((glm::vec3&)cPhysics["Velocity"]).y = 0.f; + } + break; } - break; } } } @@ -90,6 +90,7 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"]; if (Collision::AABBvsTriangles(boxA, model->Vertices(), model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) { (glm::vec3&)cTransform["Position"] += resolutionVector; + boxA = *Collision::EntityAbsoluteAABB(entity); cPhysics["Velocity"] = inOutVelocity; if (isOnGround) { everHitTheGround = true; @@ -99,6 +100,7 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c } else if (Collision::AABBVsAABB(boxA, boxB, resolutionVector)) { //Enter here if boxB has no Model. (glm::vec3&)cTransform["Position"] += resolutionVector; + boxA = *Collision::EntityAbsoluteAABB(entity); if (resolutionVector.y > 0) { everHitTheGround = true; (bool)cPhysics["IsOnGround"] = true; @@ -112,5 +114,5 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c (bool)cPhysics["IsOnGround"] = false; } - (glm::vec3&)cPhysics["PrevOrigin"] = boxA.Origin(); + m_PrevPositions[entity] = boxA.Origin(); } From 9e6c67596d0d3c43e4d628c35a2ff9a6f14f985d Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 25 Feb 2016 17:51:28 +0100 Subject: [PATCH 061/252] Basic editor copy and paste. Doesn't actually copy the entity until you paste it. --- include/Engine/Core/EntityWrapper.h | 2 ++ include/Engine/Core/World.h | 2 +- include/Engine/Editor/EditorGUI.h | 8 ++++++ include/Engine/Editor/EditorSystem.h | 1 + src/Engine/Core/EntityWrapper.cpp | 37 +++++++++++++++++++++++++++- src/Engine/Core/World.cpp | 2 +- src/Engine/Editor/EditorGUI.cpp | 13 ++++++++++ src/Engine/Editor/EditorSystem.cpp | 6 +++++ src/Engine/Network/Server.cpp | 4 +-- src/Game/Systems/SpawnerSystem.cpp | 2 +- 10 files changed, 71 insertions(+), 6 deletions(-) diff --git a/include/Engine/Core/EntityWrapper.h b/include/Engine/Core/EntityWrapper.h index b0e65d9e..4643e28b 100644 --- a/include/Engine/Core/EntityWrapper.h +++ b/include/Engine/Core/EntityWrapper.h @@ -29,6 +29,7 @@ struct EntityWrapper EntityWrapper Parent(); EntityWrapper FirstChildByName(const std::string& name); EntityWrapper FirstParentWithComponent(const std::string& componentType); + EntityWrapper Clone(EntityWrapper parent = EntityWrapper::Invalid); bool IsChildOf(EntityWrapper potentialParent); bool Valid() const; @@ -39,6 +40,7 @@ struct EntityWrapper private: EntityWrapper firstChildByNameRecursive(const std::string& name, EntityID parent); + EntityWrapper cloneRecursive(EntityWrapper entity, EntityWrapper parent); }; namespace std diff --git a/include/Engine/Core/World.h b/include/Engine/Core/World.h index 1604df37..c9f738ce 100644 --- a/include/Engine/Core/World.h +++ b/include/Engine/Core/World.h @@ -40,7 +40,7 @@ public: // Change the parent of an entity void SetParent(EntityID entity, EntityID parent); // Get children of an entity - const std::pair::const_iterator, std::unordered_multimap::const_iterator> GetChildren(EntityID entity); + const std::pair::const_iterator, std::unordered_multimap::const_iterator> GetDirectChildren(EntityID entity); // Get all component pools const std::unordered_map& GetComponentPools() const { return m_ComponentPools; } // Get the entity children map diff --git a/include/Engine/Editor/EditorGUI.h b/include/Engine/Editor/EditorGUI.h index 7a0289c6..57574e66 100644 --- a/include/Engine/Editor/EditorGUI.h +++ b/include/Engine/Editor/EditorGUI.h @@ -73,6 +73,12 @@ public: // Called when the user means to rename an entity. typedef std::function OnEntityChangeName_t; void SetEntityChangeNameCallback(OnEntityChangeName_t f) { m_OnEntityChangeName = f; } + // Called when the user pastes an entity previously "copied" + // @param EntityWrapper The entity to copy + // @param EntityWrapper The entity to parent the new copy to + // @return The new copy of the entity + typedef std::function OnEntityPaste_t; + void SetEntityPasteCallback(OnEntityPaste_t f) { m_OnEntityPaste = f; } // Called when the user means to attach a new component to an entity. typedef std::function OnComponentAttach_t; void SetComponentAttachCallback(OnComponentAttach_t f) { m_OnComponentAttach = f; } @@ -111,6 +117,7 @@ private: std::string m_DroppedFile = ""; bool m_Paused = false; bool m_MouseLocked = false; + EntityWrapper m_CopyTarget = EntityWrapper::Invalid; // Callbacks OnEntitySelectedCallback_t m_OnEntitySelected = nullptr; @@ -124,6 +131,7 @@ private: OnComponentDelete_t m_OnComponentDelete = nullptr; OnWidgetMode_t m_OnWidgetMode = nullptr; OnWidgetSpace_t m_OnWidgetSpace = nullptr; + OnEntityPaste_t m_OnEntityPaste = nullptr; // Events EventRelay m_EKeyDown; diff --git a/include/Engine/Editor/EditorSystem.h b/include/Engine/Editor/EditorSystem.h index fcaa2e47..06ee53b6 100644 --- a/include/Engine/Editor/EditorSystem.h +++ b/include/Engine/Editor/EditorSystem.h @@ -56,6 +56,7 @@ private: void OnEntityDelete(EntityWrapper entity); void OnEntityChangeParent(EntityWrapper entity, EntityWrapper parent); void OnEntityChangeName(EntityWrapper entity, const std::string& name); + EntityWrapper OnEntityPaste(EntityWrapper entityToCopy, EntityWrapper parent); void OnComponentAttach(EntityWrapper entity, const std::string& componentType); void OnComponentDelete(EntityWrapper entity, const std::string& componentType); void OnWidgetSpace(EditorGUI::WidgetSpace widgetSpace); diff --git a/src/Engine/Core/EntityWrapper.cpp b/src/Engine/Core/EntityWrapper.cpp index 4b45b8d0..ace1f4a7 100644 --- a/src/Engine/Core/EntityWrapper.cpp +++ b/src/Engine/Core/EntityWrapper.cpp @@ -51,6 +51,17 @@ EntityWrapper EntityWrapper::FirstParentWithComponent(const std::string& compone return EntityWrapper::Invalid; } +EntityWrapper EntityWrapper::Clone(EntityWrapper parent /*= Invalid*/) +{ + if (!Valid()) { + return EntityWrapper::Invalid; + } + + EntityWrapper clone = cloneRecursive(*this, EntityWrapper::Invalid); + this->World->SetParent(clone.ID, parent.ID); + return clone; +} + bool EntityWrapper::IsChildOf(EntityWrapper potentialParent) { EntityWrapper entity = *this; @@ -111,7 +122,7 @@ EntityWrapper EntityWrapper::firstChildByNameRecursive(const std::string& name, return EntityWrapper::Invalid; } - auto itPair = this->World->GetChildren(parent); + auto itPair = this->World->GetDirectChildren(parent); if (itPair.first == itPair.second) { return EntityWrapper::Invalid; } @@ -131,3 +142,27 @@ EntityWrapper EntityWrapper::firstChildByNameRecursive(const std::string& name, return EntityWrapper::Invalid; } +EntityWrapper EntityWrapper::cloneRecursive(EntityWrapper entity, EntityWrapper parent) +{ + EntityWrapper clone = EntityWrapper(entity.World, entity.World->CreateEntity(parent.ID)); + entity.World->SetName(clone.ID, entity.Name()); + + // Clone components + for (auto& kv : entity.World->GetComponentPools()) { + if (kv.second->KnowsEntity(entity.ID)) { + ComponentWrapper c1 = kv.second->GetByEntity(entity.ID); + ComponentWrapper c2 = entity.World->AttachComponent(clone.ID, kv.first); + c1.Copy(c2); + } + } + + // Clone children + auto children = entity.World->GetDirectChildren(entity.ID); + for (auto it = children.first; it != children.second; ++it) { + EntityWrapper child(entity.World, it->second); + cloneRecursive(child, clone); + } + + return clone; +} + diff --git a/src/Engine/Core/World.cpp b/src/Engine/Core/World.cpp index 8788a92e..9b323ff4 100644 --- a/src/Engine/Core/World.cpp +++ b/src/Engine/Core/World.cpp @@ -127,7 +127,7 @@ void World::SetParent(EntityID entity, EntityID parent) m_EntityChildren.insert(std::make_pair(parent, entity)); } -const std::pair::const_iterator, std::unordered_multimap::const_iterator> World::GetChildren(EntityID entity) +const std::pair::const_iterator, std::unordered_multimap::const_iterator> World::GetDirectChildren(EntityID entity) { return m_EntityChildren.equal_range(entity); } diff --git a/src/Engine/Editor/EditorGUI.cpp b/src/Engine/Editor/EditorGUI.cpp index 70775a2b..f2690f13 100644 --- a/src/Engine/Editor/EditorGUI.cpp +++ b/src/Engine/Editor/EditorGUI.cpp @@ -598,6 +598,19 @@ bool EditorGUI::OnKeyDown(const Events::KeyDown& e) entityImport(m_World); } + if (e.ModCtrl && e.KeyCode == GLFW_KEY_C) { + m_CopyTarget = m_CurrentSelection; + } + + if (e.ModCtrl && e.KeyCode == GLFW_KEY_V) { + if (m_OnEntityPaste != nullptr) { + EntityWrapper copy = m_OnEntityPaste(m_CopyTarget, m_CurrentSelection); + if (copy != EntityWrapper::Invalid) { + SelectEntity(copy); + } + } + } + if (e.KeyCode == GLFW_KEY_DELETE) { if (m_CurrentSelection.Valid()) { entityDelete(m_CurrentSelection); diff --git a/src/Engine/Editor/EditorSystem.cpp b/src/Engine/Editor/EditorSystem.cpp index 97ea9d53..4bee1427 100644 --- a/src/Engine/Editor/EditorSystem.cpp +++ b/src/Engine/Editor/EditorSystem.cpp @@ -28,6 +28,7 @@ EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame m_EditorGUI->SetEntityDeleteCallback(std::bind(&EditorSystem::OnEntityDelete, this, std::placeholders::_1)); m_EditorGUI->SetEntityChangeParentCallback(std::bind(&EditorSystem::OnEntityChangeParent, this, std::placeholders::_1, std::placeholders::_2)); m_EditorGUI->SetEntityChangeNameCallback(std::bind(&EditorSystem::OnEntityChangeName, this, std::placeholders::_1, std::placeholders::_2)); + m_EditorGUI->SetEntityPasteCallback(std::bind(&EditorSystem::OnEntityPaste, this, std::placeholders::_1, std::placeholders::_2)); m_EditorGUI->SetComponentAttachCallback(std::bind(&EditorSystem::OnComponentAttach, this, std::placeholders::_1, std::placeholders::_2)); m_EditorGUI->SetComponentDeleteCallback(std::bind(&EditorSystem::OnComponentDelete, this, std::placeholders::_1, std::placeholders::_2)); m_EditorGUI->SetWidgetModeCallback(std::bind(&EditorSystem::setWidgetMode, this, std::placeholders::_1)); @@ -160,6 +161,11 @@ void EditorSystem::OnEntityChangeName(EntityWrapper entity, const std::string& n } } +EntityWrapper EditorSystem::OnEntityPaste(EntityWrapper entityToCopy, EntityWrapper parent) +{ + return entityToCopy.Clone(parent); +} + void EditorSystem::OnComponentAttach(EntityWrapper entity, const std::string& componentType) { if (entity.Valid()) { diff --git a/src/Engine/Network/Server.cpp b/src/Engine/Network/Server.cpp index 8783a7b0..d4c82884 100644 --- a/src/Engine/Network/Server.cpp +++ b/src/Engine/Network/Server.cpp @@ -183,7 +183,7 @@ void Server::addInputCommandsToPacket(Packet& packet) void Server::addPlayersToPacket(Packet & packet, EntityID entityID) { - auto itPair = m_World->GetChildren(entityID); + auto itPair = m_World->GetDirectChildren(entityID); std::unordered_map worldComponentPools = m_World->GetComponentPools(); // Loop through every child for (auto it = itPair.first; it != itPair.second; it++) { @@ -233,7 +233,7 @@ void Server::addPlayersToPacket(Packet & packet, EntityID entityID) void Server::addChildrenToPacket(Packet & packet, EntityID entityID) { - auto itPair = m_World->GetChildren(entityID); + auto itPair = m_World->GetDirectChildren(entityID); std::unordered_map worldComponentPools = m_World->GetComponentPools(); // Loop through every child for (auto it = itPair.first; it != itPair.second; it++) { diff --git a/src/Game/Systems/SpawnerSystem.cpp b/src/Game/Systems/SpawnerSystem.cpp index 90f677fe..6500460f 100644 --- a/src/Game/Systems/SpawnerSystem.cpp +++ b/src/Game/Systems/SpawnerSystem.cpp @@ -36,7 +36,7 @@ EntityWrapper SpawnerSystem::Spawn(EntityWrapper spawner, EntityWrapper parent / } // Find any SpawnPoints existing as children of spawner - auto children = spawner.World->GetChildren(spawner.ID); + auto children = spawner.World->GetDirectChildren(spawner.ID); std::vector spawnPoints; for (auto kv = children.first; kv != children.second; ++kv) { const EntityID& child = kv->second; From 034368367807a51bcdcf8417f6df11cab321bdf4 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 25 Feb 2016 17:51:40 +0100 Subject: [PATCH 062/252] Fixed cubemaps being generated over and over again each frame. --- src/Engine/Rendering/CubeMapPass.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Engine/Rendering/CubeMapPass.cpp b/src/Engine/Rendering/CubeMapPass.cpp index 75f5e1c9..e2a55b74 100644 --- a/src/Engine/Rendering/CubeMapPass.cpp +++ b/src/Engine/Rendering/CubeMapPass.cpp @@ -17,6 +17,7 @@ void CubeMapPass::LoadTextures(std::string input) m_CubeMapTextures.push_back(img); } GenerateCubeMapTexture(); + m_PreviusCubeMapTexture = input; } } From 8867e7ac3c0ea9c34eee4a32227d09a75bc5c910 Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Thu, 25 Feb 2016 20:29:41 +0100 Subject: [PATCH 063/252] Working shadows, no cascade blend yet --- include/Engine/Rendering/ShadowPass.h | 41 ++++- resources/Shaders/ExplosionEffect.geom.glsl | 6 +- resources/Shaders/ForwardPlus.frag.glsl | 80 +++++++- resources/Shaders/ForwardPlus.vert.glsl | 13 +- src/Engine/Rendering/DrawFinalPass.cpp | 24 ++- src/Engine/Rendering/Renderer.cpp | 2 +- src/Engine/Rendering/ShadowPass.cpp | 194 +++++++++++--------- 7 files changed, 243 insertions(+), 117 deletions(-) diff --git a/include/Engine/Rendering/ShadowPass.h b/include/Engine/Rendering/ShadowPass.h index 2022a5ab..b7c37b31 100644 --- a/include/Engine/Rendering/ShadowPass.h +++ b/include/Engine/Rendering/ShadowPass.h @@ -9,7 +9,8 @@ #include "ShadowPassState.h" #include "imgui/imgui.h" -#define MAX_SPLITS 5 +#define MAX_SPLITS 3 +#define MAP_SIZE 216.f enum NearFar { Near = 0, Far = 1 }; enum LRBT { Left = 0, Right = 1, Bottom = 2, Top = 3 }; @@ -19,6 +20,18 @@ struct ShadowCamera{ std::array frustumCorners; }; +struct Frustum +{ + float NearClip; + float FarClip; + float FOV; + float AspectRatio; + glm::vec3 MiddlePoint; + float Radius; + std::array LRTB; + std::array CornerPoint; +}; + class ShadowPass { public: @@ -31,15 +44,23 @@ public: void ClearBuffer(); void Draw(RenderScene& scene); - GLuint DepthMap() const { return m_DepthMap[m_ShadowLevel]; } - glm::mat4 lightP() const { return m_LightProjection[m_ShadowLevel]; } - glm::mat4 lightV() const { return m_LightView[m_ShadowLevel]; } + GLuint DepthMap(int level) const { return m_DepthMap[level]; } + std::array lightP() const { return m_LightProjection; } + std::array lightV() const { return m_LightView; } + std::array farDistance() const { return { m_shadFrusta[0].FarClip, m_shadFrusta[1].FarClip, m_shadFrusta[2].FarClip }; } + int CurrentNrOfSplits() const { return m_CurrentNrOfSplits; } private: + void UpdateFrustumPoints(Frustum& frustum, glm::vec3 camera_position, glm::vec3 view_dir, glm::mat4 p, glm::mat4 v); + void UpdateSplitDist(std::array& frusta, float near_distance, float far_distance); + glm::mat4 ApplyCropMatrix(Frustum& frustum, glm::mat4 m, glm::mat4 v); glm::mat4 CalculateFrustum(RenderScene & scene, std::shared_ptr directionalLightJob, ShadowCamera shad_cam); - std::array UpdateFrustumPoints(Camera* cam, glm::vec3 center, glm::vec3 view_dir); - void UpdateSplitDist(std::array shadow_cams, float far_distance, float near_distance); - glm::mat4 FindNewFrustum(ShadowCamera shadow_cam); + glm::mat4 FindNewFrustum(Frustum frustum, glm::mat4 v, glm::mat4 p); + void InitializeCameras(RenderScene & scene); + float FindRadius(Frustum& frustum); + void PointsToLightspace(Frustum& frustum, glm::mat4 v); + void RadiusToLightspace(Frustum& frustum, glm::mat4 v); + EventBroker* m_EventBroker; const IRenderer* m_Renderer; @@ -63,9 +84,11 @@ private: int m_ShadowLevel = 0; int m_CurrentNrOfSplits = 3; - float m_SplitWeight = 0.5f; + float m_SplitWeight = 0.75f; - std::array m_shadCams; + //std::array m_shadCams; + Frustum m_MainCamera; + std::array m_shadFrusta; }; #endif \ No newline at end of file diff --git a/resources/Shaders/ExplosionEffect.geom.glsl b/resources/Shaders/ExplosionEffect.geom.glsl index 3471e4f2..b4a90e3b 100644 --- a/resources/Shaders/ExplosionEffect.geom.glsl +++ b/resources/Shaders/ExplosionEffect.geom.glsl @@ -1,5 +1,7 @@ #version 430 +#define MAX_SPLITS 3 + uniform mat4 M; uniform mat4 V; uniform mat4 P; @@ -22,7 +24,7 @@ in VertexData{ vec2 TextureCoordinate; vec4 ExplosionColor; float ExplosionPercentageElapsed; - vec4 PositionLightSpace; + vec4 PositionLightSpace[MAX_SPLITS]; }Input[]; out VertexData{ @@ -33,7 +35,7 @@ out VertexData{ vec2 TextureCoordinate; vec4 ExplosionColor; float ExplosionPercentageElapsed; - vec4 PositionLightSpace; + vec4 PositionLightSpace[MAX_SPLITS]; }Output; layout(triangles) in; diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 1f3ba711..76169707 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -1,5 +1,7 @@ #version 430 +#define MAX_SPLITS 3 + uniform mat4 M; uniform mat4 V; uniform mat4 P; @@ -9,11 +11,15 @@ uniform vec2 ScreenDimensions; uniform vec4 FillColor; uniform vec4 AmbientColor; uniform float FillPercentage; +uniform float FarDistance[MAX_SPLITS]; + layout (binding = 0) uniform sampler2D DiffuseTexture; layout (binding = 1) uniform sampler2D NormalMapTexture; layout (binding = 2) uniform sampler2D SpecularMapTexture; layout (binding = 3) uniform sampler2D GlowMapTexture; -layout (binding = 4) uniform sampler2DShadow DepthMap; +layout (binding = 4) uniform sampler2DShadow DepthMap0; +layout (binding = 5) uniform sampler2DShadow DepthMap1; +layout (binding = 6) uniform sampler2DShadow DepthMap2; #define TILE_SIZE 16 @@ -57,7 +63,7 @@ in VertexData{ vec2 TextureCoordinate; vec4 ExplosionColor; float ExplosionPercentageElapsed; - vec4 PositionLightSpace; + vec4 PositionLightSpace[MAX_SPLITS]; }Input; out vec4 sceneColor; @@ -186,8 +192,52 @@ float CalcShadowValue(vec4 positionLightSpace, vec3 normal, vec3 lightDir, sampl } +int getShadowIndex(float far_distance[MAX_SPLITS]) +{ + int index = 2; + if( gl_FragCoord.z < far_distance[0] ) + { + index = 0; + } + else if( gl_FragCoord.z < far_distance[1] && gl_FragCoord.z > far_distance[0] ) + { + index = 1; + } + + return index; +} + +//sampler2DShadow whichDepthMap( int DepthMapIndex ) +//{ +// if( DepthMapIndex == 0 ) +// { +// return DepthMap0; +// } +// else if( DepthMapIndex == 1 ) +// { +// return DepthMap1; +// } +// else +// { +// return DepthMap2; +// } +// +//} + void main() { + //sampler2DShadow DepthMaps[3] = { sampler2DShadow(DepthMap0), sampler2DShadow(DepthMap1), sampler2DShadow(DepthMap2) }; + //sampler2DShadow DepthMaps[3] = { DepthMap0, DepthMap1, DepthMap2 }; + //sampler2DShadow DepthMaps[3] = sampler2DShadow[]( DepthMap0, DepthMap1, DepthMap2 ); + //sampler2DShadow DepthMaps[3] = sampler2DShadow[3]( DepthMap0, DepthMap1, DepthMap2 ); + //sampler2DShadow DepthMaps[3]; + + //sampler2DShadow DepthMapOne = DepthMap0; + + //DepthMaps[0] = DepthMap0; + //DepthMaps[1] = DepthMap1; + //DepthMaps[2] = DepthMap2; + vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate); vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate); vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate); @@ -220,18 +270,32 @@ void main() if(light.Type == 1) { // point light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, position, normal, light.Falloff); } else if (light.Type == 2) { //Directional + int DepthMapIndex = getShadowIndex(FarDistance); + //sampler2DShadow WhichDepthMap = whichDepthMap(DepthMapIndex); + light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal); - shadowFactor = CalcShadowValue(Input.PositionLightSpace, Input.Normal, vec3(light.Direction), DepthMap); + + shadowFactor = CalcShadowValue(Input.PositionLightSpace[0], Input.Normal, vec3(light.Direction), DepthMap0); + //if( DepthMapIndex == 0 ) + //{ + // shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap0); + //} + //else if( DepthMapIndex == 1 ) + //{ + // shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap1); + //} + //else + //{ + // shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap2); + //} } totalLighting.Diffuse += light_result.Diffuse; - totalLighting.Specular += light_result.Specular; + totalLighting.Specular += light_result.Specular; } - //totalLighting.Diffuse *= (1.5 + vec4(AmbientColor.rgb, 1.0)) - vec4(vec3(shadowFactor), 0.0); - //totalLighting.Specular *= (1.5 + vec4(AmbientColor.rgb, 1.0)) - vec4(vec3(shadowFactor), 0.0); - totalLighting.Diffuse *= (1.0 + vec4(AmbientColor.rgb, 1.0)) + vec4(vec3(shadowFactor, shadowFactor, 0.0), 0.0); - totalLighting.Specular *= (1.0 + vec4(AmbientColor.rgb, 1.0)) + vec4(vec3(shadowFactor, shadowFactor, 0.0), 0.0); + totalLighting.Diffuse *= (1.5 + vec4(AmbientColor.rgb, 1.0)) - vec4(vec3(shadowFactor), 0.0); + totalLighting.Specular *= (1.5 + vec4(AmbientColor.rgb, 1.0)) - vec4(vec3(shadowFactor), 0.0); //LightResult getInformation; diff --git a/resources/Shaders/ForwardPlus.vert.glsl b/resources/Shaders/ForwardPlus.vert.glsl index be7fa273..fb280e3a 100644 --- a/resources/Shaders/ForwardPlus.vert.glsl +++ b/resources/Shaders/ForwardPlus.vert.glsl @@ -1,10 +1,12 @@ #version 430 +#define MAX_SPLITS 3 + uniform mat4 M; uniform mat4 V; uniform mat4 P; -uniform mat4 LightV; -uniform mat4 LightP; +uniform mat4 LightV[MAX_SPLITS]; +uniform mat4 LightP[MAX_SPLITS]; uniform mat4 Bones[100]; layout(location = 0) in vec3 Position; @@ -23,7 +25,7 @@ out VertexData{ vec2 TextureCoordinate; vec4 ExplosionColor; float ExplosionPercentageElapsed; - vec4 PositionLightSpace; + vec4 PositionLightSpace[MAX_SPLITS]; }Output; // N @@ -60,5 +62,8 @@ void main() Output.ExplosionPercentageElapsed = 0.0; //Output.PositionLightSpace = lightPos; // N - Output.PositionLightSpace = LightP * LightV * M * vec4(Position, 1.0); + for(int i = 0; i < MAX_SPLITS; i++) + { + Output.PositionLightSpace[i] = LightP[i] * LightV[i] * M * vec4(Position, 1.0); + } } \ No newline at end of file diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 776bb1b3..8770adb4 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -244,8 +244,11 @@ void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptrlightP())); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightV"), 1, GL_FALSE, glm::value_ptr(m_ShadowPass->lightV())); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightP"), MAX_SPLITS, GL_FALSE, glm::value_ptr(*m_ShadowPass->lightP().data())); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightV"), MAX_SPLITS, GL_FALSE, glm::value_ptr(*m_ShadowPass->lightV().data())); + glUniform1fv(glGetUniformLocation(shaderHandle, "FarDistance"), MAX_SPLITS, m_ShadowPass->farDistance().data()); + + //GLfloat m_NearFarPlane[2] = { -40.f, 30.f }; //GLfloat m_LRBT[4] = { -40.f, 100.f, -50.f, 50.f }; //glm::mat4 m_LightProjection = glm::ortho(m_LRBT[Left], m_LRBT[Right], m_LRBT[Bottom], m_LRBT[Top], m_NearFarPlane[Near], m_NearFarPlane[Far]); @@ -317,11 +320,16 @@ void DrawFinalPass::BindModelTextures(std::shared_ptr& job) glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture); } - glActiveTexture(GL_TEXTURE4); - if (m_ShadowPass->DepthMap() != NULL) { - glBindTexture(GL_TEXTURE_2D, m_ShadowPass->DepthMap()); - } else { - glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); - } + for (int i = 0; i < m_ShadowPass->CurrentNrOfSplits(); i++) + { + glActiveTexture(GL_TEXTURE4 + i); + if (m_ShadowPass->DepthMap(i) != NULL) { + glBindTexture(GL_TEXTURE_2D, m_ShadowPass->DepthMap(i)); + } else { + glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); + } + } + + } diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index f8e1cd6b..5aa411fc 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -137,7 +137,7 @@ void Renderer::Draw(RenderFrame& frame) m_DrawScreenQuadPass->Draw(m_PickingPass->PickingTexture()); } if (m_DebugTextureToDraw == 5) { - m_DrawScreenQuadPass->Draw(m_ShadowPass->DepthMap()); + m_DrawScreenQuadPass->Draw(m_ShadowPass->DepthMap(0)); } m_ImGuiRenderPass->Draw(); diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index 412a1fc7..1c31f91e 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -1,11 +1,12 @@ #include "Rendering/ShadowPass.h" + ShadowPass::ShadowPass(IRenderer * renderer) { - m_Renderer = renderer; + m_Renderer = renderer; - InitializeFrameBuffers(); - InitializeShaderPrograms(); + InitializeFrameBuffers(); + InitializeShaderPrograms(); } ShadowPass::~ShadowPass() @@ -13,101 +14,94 @@ ShadowPass::~ShadowPass() // m_shadCams } -// Compute the 8 corner points of the current view frustum -std::array ShadowPass::UpdateFrustumPoints(Camera* cam, glm::vec3 center, glm::vec3 view_dir) +void ShadowPass::InitializeCameras(RenderScene & scene) { - glm::vec3 up = glm::vec3(0.f, 1.f, 0.f); - glm::vec3 right = glm::normalize(glm::cross(view_dir, up)); - - //glm::vec3 farCenter = center + view_dir * cam->FarClip(); - //glm::vec3 nearCenter = center + view_dir * cam->NearClip(); - glm::vec3 farCenter = view_dir * cam->FarClip(); - glm::vec3 nearCenter = view_dir * cam->NearClip(); - - up = glm::normalize(glm::cross(right, view_dir)); - - float near_height = tan(cam->FOV() / 2.f) * cam->NearClip(); - float near_width = near_height * cam->AspectRatio(); - float far_height = tan(cam->FOV() / 2.f) * cam->FarClip(); - float far_width = far_height * cam->AspectRatio(); - - std::array frustumPoints; - frustumPoints[0] = nearCenter - up * near_height - right * near_width; - frustumPoints[1] = nearCenter + up * near_height - right * near_width; - frustumPoints[2] = nearCenter + up * near_height + right * near_width; - frustumPoints[3] = nearCenter - up * near_height + right * near_width; - - frustumPoints[4] = farCenter - up * far_height - right * far_width; - frustumPoints[5] = farCenter + up * far_height - right * far_width; - frustumPoints[6] = farCenter + up * far_height + right * far_width; - frustumPoints[7] = farCenter - up * far_height + right * far_width; - - return frustumPoints; + for (int i = 0; i < m_CurrentNrOfSplits; i++) { + m_shadFrusta[i].AspectRatio = scene.Camera->AspectRatio(); + m_shadFrusta[i].FOV = scene.Camera->FOV(); + } } // UpdateSplitDist computes the near and far distances for every frustum slice // in camera eye space - that is, at what distance does a slice start and end -void ShadowPass::UpdateSplitDist(std::array shadow_cams, float near_distance, float far_distance) +void ShadowPass::UpdateSplitDist(std::array& frusta, float near_distance, float far_distance) { float lambda = m_SplitWeight; float ratio = far_distance / near_distance; - shadow_cams[0].camera->SetNearClip(near_distance); + frusta[0].NearClip = near_distance; for (int i = 1; i < m_CurrentNrOfSplits; i++) { float si = i / static_cast(m_CurrentNrOfSplits); - shadow_cams[i].camera->SetNearClip(lambda * (near_distance * powf(ratio, si)) + (1 - lambda) * (near_distance + (far_distance - near_distance) * si)); - shadow_cams[i - 1].camera->SetFarClip(shadow_cams[i].camera->NearClip() * 1.005f); + frusta[i].NearClip = lambda * (near_distance * powf(ratio, si)) + (1 - lambda) * (near_distance + (far_distance - near_distance) * si); + frusta[i - 1].FarClip = frusta[i].NearClip * 1.005f; } - shadow_cams[m_CurrentNrOfSplits - 1].camera->SetFarClip(far_distance); + frusta[m_CurrentNrOfSplits - 1].FarClip = far_distance; } -// Create a new light frustum based on the 8 corner points of a view frustum segment -glm::mat4 ShadowPass::FindNewFrustum(ShadowCamera shadow_cam) +// Compute the 8 corner points of the current view frustum in world space +void ShadowPass::UpdateFrustumPoints(Frustum& frustum, glm::vec3 camera_position, glm::vec3 view_dir, glm::mat4 p, glm::mat4 v) { - float maxX = -1000.0f; - float maxY = -1000.0f; - float maxZ; - float minX = 1000.0f; - float minY = 1000.0f; - float minZ; + glm::vec3 up = glm::vec3(0.f, 1.f, 0.f); + glm::vec3 right = glm::normalize(glm::cross(view_dir, up)); - glm::vec4 transf; + glm::vec3 far_center = camera_position + glm::normalize(view_dir) * frustum.FarClip; + glm::vec3 near_center = camera_position + glm::normalize(view_dir) * frustum.NearClip; + frustum.MiddlePoint = near_center + (far_center - near_center) * 0.5f; - for (int i = 0; i < 8; i++) - { - transf = glm::vec4(shadow_cam.frustumCorners[i], 1.f); + up = glm::normalize(glm::cross(right, view_dir)); - if (transf.x > maxX) maxX = transf.x; - if (transf.x < minX) minX = transf.x; - if (transf.y > maxY) maxY = transf.y; - if (transf.y < minY) minY = transf.y; + // these heights and widths are half the heights and widths of the near and far plane rectangles. + float near_height = tan(frustum.FOV / 2.f) * frustum.NearClip; + float near_width = near_height * frustum.AspectRatio; + float far_height = tan(frustum.FOV / 2.f) * frustum.FarClip; + float far_width = far_height * frustum.AspectRatio; + + frustum.CornerPoint[0] = near_center - up * near_height - right * near_width; + frustum.CornerPoint[1] = near_center + up * near_height - right * near_width; + frustum.CornerPoint[2] = near_center + up * near_height + right * near_width; + frustum.CornerPoint[3] = near_center - up * near_height + right * near_width; + + frustum.CornerPoint[4] = far_center - up * far_height - right * far_width; + frustum.CornerPoint[5] = far_center + up * far_height - right * far_width; + frustum.CornerPoint[6] = far_center + up * far_height + right * far_width; + frustum.CornerPoint[7] = far_center - up * far_height + right * far_width; + + // Alternative way + //std::array CornerPoint = { + // glm::vec4(-1.f, -1.f, -1.f, 1.f), + // glm::vec4(-1.f, 1.f, -1.f, 1.f), + // glm::vec4(1.f, 1.f, -1.f, 1.f), + // glm::vec4(1.f, -1.f, -1.f, 1.f), + // glm::vec4(-1.f, -1.f, 1.f, 1.f), + // glm::vec4(-1.f, 1.f, 1.f, 1.f), + // glm::vec4(1.f, 1.f, 1.f, 1.f), + // glm::vec4(1.f, -1.f, 1.f, 1.f) }; + + //std::array final; + + //for (int i = 0; i < 8; i++) { + // glm::vec4 anus = glm::inverse(p) * CornerPoint[i]; + // anus = anus / anus.w; + // final[i] = glm::vec3(glm::inverse(v) * anus); + //} +} + +float ShadowPass::FindRadius(Frustum& frustum) +{ + float radius = 0.f; + + for (int i = 0; i < 8; i++) { + float distance = glm::distance(frustum.MiddlePoint, frustum.CornerPoint[i]); + if (distance > radius) { + radius = distance; + } } - //float scaleX = 2.0f / (maxX - minX); - //float scaleY = 2.0f / (maxY - minY); - //float offsetX = -0.5f * (maxX + minX) * scaleX; - //float offsetY = -0.5f * (maxY + minY) * scaleY; - // - //glm::mat4 nv_mvp = glm::mat4(); - //nv_mvp[0][0] = scaleX; - //nv_mvp[1][1] = scaleY; - //nv_mvp[0][3] = offsetX; - //nv_mvp[1][3] = offsetY; - //glm::transpose(nv_mvp); - - glm::mat4 p = glm::ortho(minX, maxX, minY, maxY, m_NearFarPlane[Near], m_NearFarPlane[Far]); - - return p; -} - -glm::mat4 ShadowPass::CalculateFrustum(RenderScene & scene, std::shared_ptr directionalLightJob, ShadowCamera shad_cam) -{ - glm::vec3 middle = shad_cam.camera->Position() + (shad_cam.camera->Forward() * shad_cam.camera->FarClip() * 0.5f); - - return glm::lookAt(glm::vec3(0.f) + middle, glm::vec3(directionalLightJob->Direction) + middle, glm::vec3(-1.f, 0.f, 0.f)); + frustum.Radius = radius; + return radius; } void ShadowPass::InitializeFrameBuffers() @@ -154,6 +148,36 @@ void ShadowPass::ClearBuffer() } } +void ShadowPass::PointsToLightspace(Frustum& frustum, glm::mat4 v) +{ + float left = INFINITY; + float right = -INFINITY; + float bottom = INFINITY; + float top = -INFINITY; + + for (int i = 0; i < 8; i++) + { + glm::vec3 tempPoint = glm::vec3(v * glm::vec4(frustum.CornerPoint[i], 1.f)); + + if (tempPoint.x < left) { left = tempPoint.x; } + if (tempPoint.x > right) { right = tempPoint.x; } + if (tempPoint.y < bottom) { bottom = tempPoint.y; } + if (tempPoint.y > top) { top = tempPoint.y; } + } + + frustum.LRTB = { left, right, bottom, top }; +} + +void ShadowPass::RadiusToLightspace(Frustum& frustum, glm::mat4 v) +{ + float left = -frustum.Radius; + float right = frustum.Radius; + float bottom = -frustum.Radius; + float top =frustum.Radius; + + frustum.LRTB = { left, right, bottom, top }; +} + void ShadowPass::Draw(RenderScene & scene) { ImGui::DragFloat4("ShadowMapCam", m_LRBT, 1.f, -1000.f, 1000.f); @@ -161,15 +185,12 @@ void ShadowPass::Draw(RenderScene & scene) ImGui::Checkbox("EnableShadow", &m_ShadowOn); ImGui::DragInt("ShadowLevel", &m_ShadowLevel, 0.05f, 0, m_CurrentNrOfSplits - 1); - for (int i = 0; i < m_CurrentNrOfSplits; i++) { - m_shadCams[i].camera = new Camera(*scene.Camera); - //m_shadCams[i].frustumCorners = tempPoints; - } - - UpdateSplitDist(m_shadCams, scene.Camera->NearClip(), scene.Camera->FarClip()); + InitializeCameras(scene); + UpdateSplitDist(m_shadFrusta, scene.Camera->NearClip(), scene.Camera->FarClip()); for (int i = 0; i < m_CurrentNrOfSplits; i++) { - m_shadCams[i].frustumCorners = UpdateFrustumPoints(m_shadCams[i].camera, m_shadCams[i].camera->Position(), m_shadCams[i].camera->Forward()); + UpdateFrustumPoints(m_shadFrusta[i], scene.Camera->Position(), scene.Camera->Forward(), scene.Camera->ProjectionMatrix(), scene.Camera->ViewMatrix()); + //float test = FindRadius(m_shadFrusta[i]); ShadowPassState* state = new ShadowPassState(m_DepthBuffer[i].GetHandle()); @@ -187,8 +208,11 @@ void ShadowPass::Draw(RenderScene & scene) auto directionalLightJob = std::dynamic_pointer_cast(job); if (directionalLightJob) { - m_LightView[i] = CalculateFrustum(scene, directionalLightJob, m_shadCams[i]); - m_LightProjection[i] = FindNewFrustum(m_shadCams[i]); + m_LightView[i] = glm::lookAt(glm::vec3(-directionalLightJob->Direction) + m_shadFrusta[i].MiddlePoint, m_shadFrusta[i].MiddlePoint, glm::vec3(0.f, 1.f, 0.f)); + + PointsToLightspace(m_shadFrusta[i], m_LightView[i]); + m_LightProjection[i] = glm::ortho(m_shadFrusta[i].LRTB[Left], m_shadFrusta[i].LRTB[Right], m_shadFrusta[i].LRTB[Bottom], m_shadFrusta[i].LRTB[Top], -30.f, 30.f); + //m_LightProjection[i] = glm::ortho(m_shadFrusta[i].LRTB[Left], m_shadFrusta[i].LRTB[Right], m_shadFrusta[i].LRTB[Bottom], m_shadFrusta[i].LRTB[Top], -0.f, 300.f); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection[i])); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView[i])); @@ -197,7 +221,7 @@ void ShadowPass::Draw(RenderScene & scene) for (auto &objectJob : scene.OpaqueObjects) { auto modelJob = std::dynamic_pointer_cast(objectJob); - + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); glBindVertexArray(modelJob->Model->VAO); From df2e4abb527938bcaf4689b8e392f835456ff1f7 Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Thu, 25 Feb 2016 21:21:38 +0100 Subject: [PATCH 064/252] WE HAVE WORKING CASCADE SHADOWS --- resources/Shaders/ForwardPlus.frag.glsl | 35 +++++++++++++------------ src/Engine/Rendering/ShadowPass.cpp | 4 +-- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 76169707..f4fd0dd1 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -194,12 +194,14 @@ float CalcShadowValue(vec4 positionLightSpace, vec3 normal, vec3 lightDir, sampl int getShadowIndex(float far_distance[MAX_SPLITS]) { + float depth = gl_FragCoord.z / gl_FragCoord.w; + int index = 2; - if( gl_FragCoord.z < far_distance[0] ) + if( depth < far_distance[0] ) { index = 0; } - else if( gl_FragCoord.z < far_distance[1] && gl_FragCoord.z > far_distance[0] ) + else if( depth < far_distance[1] && depth > far_distance[0] ) { index = 1; } @@ -207,7 +209,7 @@ int getShadowIndex(float far_distance[MAX_SPLITS]) return index; } -//sampler2DShadow whichDepthMap( int DepthMapIndex ) +//sampler2DShadow whichDepthMap(int DepthMapIndex) //{ // if( DepthMapIndex == 0 ) // { @@ -221,7 +223,6 @@ int getShadowIndex(float far_distance[MAX_SPLITS]) // { // return DepthMap2; // } -// //} void main() @@ -275,19 +276,19 @@ void main() light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal); - shadowFactor = CalcShadowValue(Input.PositionLightSpace[0], Input.Normal, vec3(light.Direction), DepthMap0); - //if( DepthMapIndex == 0 ) - //{ - // shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap0); - //} - //else if( DepthMapIndex == 1 ) - //{ - // shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap1); - //} - //else - //{ - // shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap2); - //} + //shadowFactor = CalcShadowValue(Input.PositionLightSpace[0], Input.Normal, vec3(light.Direction), DepthMap0); + if( DepthMapIndex == 0 ) + { + shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap0); + } + else if( DepthMapIndex == 1 ) + { + shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap1); + } + else + { + shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap2); + } } totalLighting.Diffuse += light_result.Diffuse; diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index 1c31f91e..a5ef4663 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -111,7 +111,7 @@ void ShadowPass::InitializeFrameBuffers() for (int i = 0; i < m_CurrentNrOfSplits; i++) { glBindTexture(GL_TEXTURE_2D, m_DepthMap[i]); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, resolutionSizeWidth / (1 + i), resolutionSizeHeigth + (1 + i), 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, resolutionSizeWidth / (1 /*+ i*/), resolutionSizeHeigth + (1 /*+ i*/), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); @@ -197,7 +197,7 @@ void ShadowPass::Draw(RenderScene & scene) GLuint shaderHandle = m_ShadowProgram->GetHandle(); m_ShadowProgram->Bind(); - glViewport(0, 0, resolutionSizeWidth / (1 + i), resolutionSizeHeigth); + glViewport(0, 0, resolutionSizeWidth / (1/* + i*/), resolutionSizeHeigth); glDisable(GL_TEXTURE_2D); glCullFace(GL_FRONT); //state->Disable(GL_CULL_FACE); From af034673f6244002820bf459556ad43c0e65a4c5 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Fri, 26 Feb 2016 10:17:47 +0100 Subject: [PATCH 065/252] BoneAttachments now working and BlendTrees are created in the AnimationSystem --- include/Engine/Rendering/AnimationSystem.h | 15 +- include/Engine/Rendering/BlendTree.h | 4 +- .../Engine/Rendering/BoneAttachmentSystem.h | 1 + include/Engine/Rendering/ModelJob.h | 5 +- include/Engine/Rendering/Skeleton.h | 28 +-- include/Game/Systems/LifetimeSystem.h | 2 +- resources/Schema/Entities/AnimationTests2.xml | 234 ++++++++++-------- src/Engine/Rendering/AnimationSystem.cpp | 89 +++++-- src/Engine/Rendering/BlendTree.cpp | 13 +- src/Engine/Rendering/BoneAttachmentSystem.cpp | 77 ++---- src/Engine/Rendering/DrawFinalPass.cpp | 69 +++--- src/Engine/Rendering/PickingPass.cpp | 24 +- src/Engine/Rendering/Skeleton.cpp | 16 +- 13 files changed, 308 insertions(+), 269 deletions(-) diff --git a/include/Engine/Rendering/AnimationSystem.h b/include/Engine/Rendering/AnimationSystem.h index dbe4b3fc..d05dc765 100644 --- a/include/Engine/Rendering/AnimationSystem.h +++ b/include/Engine/Rendering/AnimationSystem.h @@ -9,20 +9,17 @@ #include "Rendering/Model.h" #include "Rendering/EAnimationComplete.h" #include "Rendering/Skeleton.h" -#include +#include "Rendering/BlendTree.h" -class AnimationSystem : public PureSystem +class AnimationSystem : public ImpureSystem { public: - AnimationSystem(SystemParams params) - : System(params) - , PureSystem("Animation") - { - - } + AnimationSystem(SystemParams params); ~AnimationSystem() { } - virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& animationComponent, double dt) override; + virtual void Update(double dt) override; private: + void CreateBlendTrees(); + void UpdateAnimations(double dt); }; diff --git a/include/Engine/Rendering/BlendTree.h b/include/Engine/Rendering/BlendTree.h index 8d192cfe..a472465b 100644 --- a/include/Engine/Rendering/BlendTree.h +++ b/include/Engine/Rendering/BlendTree.h @@ -62,7 +62,7 @@ public: std::vector GetFinalPose() { return m_FinalPose; } - + glm::mat4 GetBoneTransform(int boneID); void PrintTree(); @@ -72,6 +72,8 @@ private: Node* m_Root = nullptr; std::vector m_FinalPose; + std::map m_FinalBoneTransforms; + std::vector AccumulateFinalPose(); BlendTree::Node* FillTreeByName(Node* parentNode, std::string name, EntityWrapper parentEntity); diff --git a/include/Engine/Rendering/BoneAttachmentSystem.h b/include/Engine/Rendering/BoneAttachmentSystem.h index 55c2a1c8..2791d877 100644 --- a/include/Engine/Rendering/BoneAttachmentSystem.h +++ b/include/Engine/Rendering/BoneAttachmentSystem.h @@ -8,6 +8,7 @@ #include "Core/ResourceManager.h" #include "Rendering/Model.h" #include "Rendering/Skeleton.h" +#include "Rendering/BlendTree.h" //Needs to be a higher orderlevel than AnimationSystem class BoneAttachmentSystem : public PureSystem diff --git a/include/Engine/Rendering/ModelJob.h b/include/Engine/Rendering/ModelJob.h index 4ea7a1f6..adc21c6f 100644 --- a/include/Engine/Rendering/ModelJob.h +++ b/include/Engine/Rendering/ModelJob.h @@ -125,7 +125,10 @@ struct ModelJob : RenderJob if (Skeleton != nullptr) { EntityWrapper entityWrapper = EntityWrapper(world, modelComponent.EntityID); - BlendTree = std::shared_ptr<::BlendTree>(new ::BlendTree(entityWrapper, Skeleton)); + + if(Skeleton->BlendTrees.find(entityWrapper) != Skeleton->BlendTrees.end()) { + BlendTree = Skeleton->BlendTrees.at(entityWrapper); + } } } }; diff --git a/include/Engine/Rendering/Skeleton.h b/include/Engine/Rendering/Skeleton.h index fa5a329d..ffa08452 100644 --- a/include/Engine/Rendering/Skeleton.h +++ b/include/Engine/Rendering/Skeleton.h @@ -6,27 +6,9 @@ #include "../GLM.h" #include #include +#include "../Core/EntityWrapper.h" -//struct Bone -//{ -// Bone(std::string name, glm::mat4 offsetMatrix) -// : Name(name) -// , OffsetMatrix(offsetMatrix) -// { } -// -// ~Bone() -// { -// for (auto kv : Children) { -// delete kv.second; -// } -// } -// -// std::string Name; -// glm::mat4 OffsetMatrix; -// glm::mat4 LocalMatrix; -// -// std::map Children; -//}; +class BlendTree; class Skeleton { @@ -75,6 +57,8 @@ public: std::map Bones; + std::unordered_map> BlendTrees; + // Attach a new bone to the skeleton // Returns: New bone index int CreateBone(int ID, int parentID, std::string name, glm::mat4 offsetMatrix); @@ -86,13 +70,13 @@ public: std::map BlendPoses(const std::map& pose1, const std::map& pose2, float weight); std::map OverridePose(const std::map& overridePose, const std::map& targetPose); std::map BlendPoseAdditive(const std::map& additivePose, const std::map& targetPose); - std::vector GetFinalPose(std::map& boneMatrices); + void GetFinalPose(std::map& boneMatrices, std::vector& finalPose, std::map& boneTransforms); std::map Animations; private: glm::mat4 GetAdditiveBonePose(const Bone* bone, const Animation* animation, double time); glm::mat4 GetBonePose(const Bone* bone, const Animation* animation, double time, bool noRootMotion); - void AccumulateFinalPose(std::map& boneMatrices, const Bone* bone, glm::mat4 parentMatrix); + void AccumulateFinalPose(std::map& boneMatrices, std::map& boneTransforms, const Bone* bone, glm::mat4 parentMatrix); void AdditiveBoneTransforms(const Animation* animation, double time, std::map& boneMatrices, const Bone* bone); void AccumulateBoneTransforms(bool noRootMotion, const Animation* animation, double time, std::map& boneMatrices, const Bone* bone, glm::mat4 parentMatrix); diff --git a/include/Game/Systems/LifetimeSystem.h b/include/Game/Systems/LifetimeSystem.h index 6dee644d..d19308d5 100644 --- a/include/Game/Systems/LifetimeSystem.h +++ b/include/Game/Systems/LifetimeSystem.h @@ -10,7 +10,7 @@ public: : System(params) , PureSystem("Lifetime") { - LOG_INFO("ASDASDASSA"); + } virtual void Update(double dt) override; diff --git a/resources/Schema/Entities/AnimationTests2.xml b/resources/Schema/Entities/AnimationTests2.xml index 4779bbaf..ca7c705d 100644 --- a/resources/Schema/Entities/AnimationTests2.xml +++ b/resources/Schema/Entities/AnimationTests2.xml @@ -9,19 +9,22 @@ - + + - + + 0.10000047832727432 + Models/Widgets/Lights/DirectionalLightWidget.mesh - + @@ -30,36 +33,22 @@ - 10 + 8 + 0.20000000298023224 - + - - - - - - 10 - - - - - - - - + Models/Core/UnitPlane.mesh - - - + @@ -85,7 +74,9 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh + + @@ -94,7 +85,6 @@ AimRifleA - true @@ -114,7 +104,7 @@ ShootFastRifleU - + 1 @@ -123,63 +113,28 @@ - - BlendWalkRun - StrafeAnimation - 1 - + + RunF + + 1 + - - - - - StrafeRightF - - 1 - - - - - - - - - RunAnimtaion - WalkAnimation - 0.43000054359436035 - - - - - - - - RunF - - 1 - - - - - - - - - WalkF - - 1 - - - - - - - - + + + + + 3 + + + + + + + @@ -206,7 +161,9 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh + + @@ -215,7 +172,8 @@ AimRifleA - + + 0.5 true @@ -235,7 +193,7 @@ ShootFastRifleU - + 1 @@ -247,7 +205,7 @@ BlendWalkRun StrafeAnimation - 1 + 0 @@ -255,8 +213,8 @@ - StrafeRightF - + StrafeLeftF + 1 @@ -268,7 +226,7 @@ RunAnimtaion WalkAnimation - 0.43000054359436035 + 1 @@ -277,7 +235,7 @@ RunF - + 1 @@ -288,7 +246,7 @@ WalkF - + 1 @@ -301,6 +259,20 @@ + + + + + 3 + 0.80000001192092896 + 0.30000001192092896 + + + + + + + @@ -327,7 +299,9 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh + + @@ -336,7 +310,7 @@ AimRifleA - + true @@ -355,8 +329,8 @@ - ShootFastRifleU - + ShootRifleU + 1 @@ -368,7 +342,7 @@ BlendWalkRun StrafeAnimation - 1 + 0 @@ -377,7 +351,7 @@ StrafeRightF - + 1 @@ -398,7 +372,7 @@ RunF - + 1 @@ -409,7 +383,7 @@ WalkF - + 1 @@ -422,6 +396,19 @@ + + + + + 3 + 0.30000001192092896 + + + + + + + @@ -448,7 +435,9 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh + + @@ -457,7 +446,7 @@ AimRifleA - + true @@ -473,17 +462,6 @@ - - - - ShootFastRifleU - - 1 - - - - - @@ -498,7 +476,7 @@ StrafeRightF - + 1 @@ -510,7 +488,7 @@ RunAnimtaion WalkAnimation - 0.43000054359436035 + 1 @@ -518,8 +496,8 @@ - RunF - + CrouchWalkF + 1 @@ -530,7 +508,7 @@ WalkF - + 1 @@ -541,10 +519,50 @@ + + + + ReloadSwitchU + + 1 + + + + + + + + + + 3 + + + + + + + + + + + Models/Core/UnitSphere.mesh + + + + + 3 + + + + + + + + diff --git a/src/Engine/Rendering/AnimationSystem.cpp b/src/Engine/Rendering/AnimationSystem.cpp index 1b260b08..9a74da29 100644 --- a/src/Engine/Rendering/AnimationSystem.cpp +++ b/src/Engine/Rendering/AnimationSystem.cpp @@ -1,66 +1,109 @@ #include "Rendering/AnimationSystem.h" -void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& animationComponent, double dt) +AnimationSystem::AnimationSystem(SystemParams params) + : System(params) { - - EntityWrapper parent = entity.FirstParentWithComponent("Model"); - Model* model; - try { - model = ResourceManager::Load<::Model, true>(parent["Model"]["Resource"]); - } catch (const std::exception&) { +} + +void AnimationSystem::Update(double dt) +{ + UpdateAnimations(dt); + CreateBlendTrees(); +} + +void AnimationSystem::CreateBlendTrees() +{ + auto modelComponents = m_World->GetComponents("Model"); + if (modelComponents == nullptr) { return; } - Skeleton* skeleton = model->m_RawModel->m_Skeleton; - if (skeleton == nullptr) { + for (auto& modelC : *modelComponents) { + EntityWrapper entity = EntityWrapper(m_World, modelC.EntityID); + + Model* model; + try { + model = ResourceManager::Load<::Model, true>(entity["Model"]["Resource"]); + } catch (const std::exception&) { + continue;; + } + + Skeleton* skeleton = model->m_RawModel->m_Skeleton; + if (skeleton == nullptr) { + continue; + } + + skeleton->BlendTrees[entity] = std::shared_ptr(new BlendTree(entity, skeleton)); + } +} + +void AnimationSystem::UpdateAnimations(double dt) +{ + auto animationComponents = m_World->GetComponents("Animation"); + if(animationComponents == nullptr) { return; } - for (int i = 1; i <= 1; i++) { - const Skeleton::Animation* animation = skeleton->GetAnimation(animationComponent["AnimationName"]); + for (auto& animationC : *animationComponents) { + EntityWrapper entity = EntityWrapper(m_World, animationC.EntityID); + EntityWrapper parent = entity.FirstParentWithComponent("Model"); + + Model* model; + try { + model = ResourceManager::Load<::Model, true>(parent["Model"]["Resource"]); + } catch (const std::exception&) { + return; + } + + Skeleton* skeleton = model->m_RawModel->m_Skeleton; + if (skeleton == nullptr) { + return; + } + + const Skeleton::Animation* animation = skeleton->GetAnimation(animationC["AnimationName"]); if (animation == nullptr) { continue;; } - double animationSpeed = (double)animationComponent["Speed"]; + double animationSpeed = (double)animationC["Speed"]; if (animationSpeed != 0.0) { - double nextTime = (double)animationComponent["Time"] + animationSpeed * dt; + double nextTime = (double)animationC["Time"] + animationSpeed * dt; - if (!(bool)animationComponent["Loop"]) { + if (!(bool)animationC["Loop"]) { if (nextTime > animation->Duration) { nextTime = animation->Duration; Events::AnimationComplete e; e.Entity = entity; - e.Name = (std::string)animationComponent["AnimationName"]; + e.Name = (std::string)animationC["AnimationName"]; m_EventBroker->Publish(e); } else if (nextTime < 0) { Events::AnimationComplete e; e.Entity = entity; - e.Name = (std::string)animationComponent["AnimationName"]; + e.Name = (std::string)animationC["AnimationName"]; m_EventBroker->Publish(e); nextTime = 0; } - (double&)animationComponent["Speed"] = 0.0; - + (double&)animationC["Speed"] = 0.0; + } else { if (nextTime > animation->Duration) { Events::AnimationComplete e; e.Entity = entity; - e.Name = (std::string)animationComponent["AnimationName"]; + e.Name = (std::string)animationC["AnimationName"]; m_EventBroker->Publish(e); - while(nextTime > animation->Duration) { + while (nextTime > animation->Duration) { nextTime -= animation->Duration; } } else if (nextTime < 0) { Events::AnimationComplete e; e.Entity = entity; - e.Name = (std::string)animationComponent["AnimationName"]; + e.Name = (std::string)animationC["AnimationName"]; m_EventBroker->Publish(e); while (nextTime < 0) { @@ -69,8 +112,8 @@ void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& a } } - (double&)animationComponent["Time"] = nextTime; + (double&)animationC["Time"] = nextTime; } - } + } } diff --git a/src/Engine/Rendering/BlendTree.cpp b/src/Engine/Rendering/BlendTree.cpp index 1d628a06..0d87665f 100644 --- a/src/Engine/Rendering/BlendTree.cpp +++ b/src/Engine/Rendering/BlendTree.cpp @@ -76,6 +76,17 @@ BlendTree::~BlendTree() } } + +glm::mat4 BlendTree::GetBoneTransform(int boneID) +{ + if(m_FinalBoneTransforms.find(boneID) != m_FinalBoneTransforms.end()) { + return m_FinalBoneTransforms.at(boneID); + } else { + return glm::mat4(1); + } + +} + void BlendTree::PrintTree() { Node* currentNode = m_Root; @@ -213,7 +224,7 @@ std::vector BlendTree::AccumulateFinalPose() std::map pose; Blend(pose); - finalPose = m_Skeleton->GetFinalPose(pose); + m_Skeleton->GetFinalPose(pose, finalPose, m_FinalBoneTransforms); return finalPose; } diff --git a/src/Engine/Rendering/BoneAttachmentSystem.cpp b/src/Engine/Rendering/BoneAttachmentSystem.cpp index 0e259f4b..43dc8634 100644 --- a/src/Engine/Rendering/BoneAttachmentSystem.cpp +++ b/src/Engine/Rendering/BoneAttachmentSystem.cpp @@ -8,10 +8,13 @@ void BoneAttachmentSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapp return; } - auto parent = entity.FirstParentWithComponent("Animation"); - if (!parent.HasComponent("Model")) { + auto parent = entity.FirstParentWithComponent("Model"); + + if(!parent.Valid()) { return; } + + Model* model; try { model = ResourceManager::Load<::Model, true>(parent["Model"]["Resource"]); @@ -35,61 +38,29 @@ void BoneAttachmentSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapp return; } - /* std::vector<::Skeleton::AnimationData> Animations; - ::Skeleton::AnimationOffset AnimationOffset; - glm::mat4 boneTransform; + if (skeleton->BlendTrees.find(parent) != skeleton->BlendTrees.end()) { - if (parent.HasComponent("Animation")) { - ::Skeleton::AnimationData animationData; - animationData.animation = model->m_RawModel->m_Skeleton->GetAnimation(parent["Animation"]["AnimationName"]); - if (animationData.animation != nullptr) { - animationData.time = (double)parent["Animation"]["Time"]; - Animations.push_back(animationData); - } - } - if (parent.HasComponent("AnimationOffset")) { - AnimationOffset.animation = model->m_RawModel->m_Skeleton->GetAnimation(parent["AnimationOffset"]["AnimationName"]); - AnimationOffset.time = (double)parent["AnimationOffset"]["Time"]; + glm::mat4 boneTransform = skeleton->BlendTrees.at(parent)->GetBoneTransform(id); - if(AnimationOffset.animation != nullptr) { - boneTransform = skeleton->GetBoneTransform(false, skeleton->Bones.at(id), Animations, AnimationOffset, glm::mat4(1)); - } else { - boneTransform = skeleton->GetBoneTransform(false, skeleton->Bones.at(id), Animations, glm::mat4(1)); - } + glm::vec3 scale; + glm::quat rotation; + glm::vec3 translation; + glm::vec3 skew; + glm::vec4 perspective; + glm::decompose(boneTransform, scale, rotation, translation, skew, perspective); + + glm::vec3 angles = glm::vec3(-glm::pitch(rotation), -glm::yaw(rotation), -glm::roll(rotation)); - } else { - boneTransform = skeleton->GetBoneTransform(false, skeleton->Bones.at(id), Animations, glm::mat4(1)); + if ((bool)entity["BoneAttachment"]["InheritPosition"]) { + (glm::vec3&)entity["Transform"]["Position"] = translation + (glm::vec3)entity["BoneAttachment"]["PositionOffset"]; + } + if ((bool)entity["BoneAttachment"]["InheritOrientation"]) { + (glm::vec3&)entity["Transform"]["Orientation"] = angles + (glm::vec3)entity["BoneAttachment"]["OrientationOffset"]; + } + if ((bool)entity["BoneAttachment"]["InheritScale"]) { + (glm::vec3&)entity["Transform"]["Scale"] = scale * (glm::vec3)entity["BoneAttachment"]["ScaleOffset"]; + } } - - - glm::vec3 scale; - glm::quat rotation; - glm::vec3 translation; - glm::vec3 skew; - glm::vec4 perspective; - glm::decompose(boneTransform, scale, rotation, translation, skew, perspective); - - glm::vec3 angles = glm::vec3(-glm::pitch(rotation), -glm::yaw(rotation), -glm::roll(rotation)); -/ * - - angles.y = asin(-boneTransform[0][2]); - if (cos(angles.y) != 0) { - angles.x = atan2(boneTransform[1][2], boneTransform[2][2]); - angles.z = atan2(boneTransform[0][1], boneTransform[0][0]); - } else { - angles.x = atan2(-boneTransform[2][0], boneTransform[1][1]); - angles.z = 0; - }* / - - if ((bool)entity["BoneAttachment"]["InheritPosition"]) { - (glm::vec3&)entity["Transform"]["Position"] = translation + (glm::vec3)entity["BoneAttachment"]["PositionOffset"]; - } - if ((bool)entity["BoneAttachment"]["InheritOrientation"]) { - (glm::vec3&)entity["Transform"]["Orientation"] = angles + (glm::vec3)entity["BoneAttachment"]["OrientationOffset"]; - } - if ((bool)entity["BoneAttachment"]["InheritScale"]) { - (glm::vec3&)entity["Transform"]["Scale"] = scale * (glm::vec3)entity["BoneAttachment"]["ScaleOffset"]; - }*/ } diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index b139f2ba..7360d064 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -337,9 +337,11 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& BindExplosionUniforms(explosionSkinnedHandle, explosionEffectJob, scene); //bind textures BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob); - std::vector frameBones; - frameBones = explosionEffectJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + if (explosionEffectJob->BlendTree != nullptr) { + std::vector frameBones; + frameBones = explosionEffectJob->BlendTree->GetFinalPose(); + glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } } else { m_ExplosionEffectProgram->Bind(); GLERROR("Bind ExplosionEffect program"); @@ -360,10 +362,11 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& //bind textures BindExplosionTextures(explosionSplatMapSkinnedHandle, explosionEffectJob); GLERROR("asdasd"); - std::vector frameBones; - frameBones = explosionEffectJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); - + if (explosionEffectJob->BlendTree != nullptr) { + std::vector frameBones; + frameBones = explosionEffectJob->BlendTree->GetFinalPose(); + glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } } else { m_ExplosionEffectSplatMapProgram->Bind(); GLERROR("Bind ExplosionEffectSplatMap program"); @@ -401,10 +404,12 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& BindModelUniforms(forwardSkinnedHandle, modelJob, scene); //bind textures BindModelTextures(forwardSkinnedHandle, modelJob); - std::vector frameBones; - frameBones = modelJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + if (modelJob->BlendTree != nullptr) { + std::vector frameBones; + frameBones = modelJob->BlendTree->GetFinalPose(); + glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } } else { m_ForwardPlusProgram->Bind(); GLERROR("Bind ForwardPlusProgram"); @@ -425,10 +430,11 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& //bind textures BindModelTextures(forwardSplatMapSkinnedHandle, modelJob); GLERROR("asdasd"); - std::vector frameBones; - frameBones = modelJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); - + if (modelJob->BlendTree != nullptr) { + std::vector frameBones; + frameBones = modelJob->BlendTree->GetFinalPose(); + glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } } else { m_ForwardPlusSplatMapProgram->Bind(); GLERROR("Bind SplatMap program"); @@ -469,9 +475,11 @@ void DrawFinalPass::DrawShieldToStencilBuffer(std::listMatrix)); 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())); - std::vector frameBones; - frameBones = modelJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + if (modelJob->BlendTree != nullptr) { + std::vector frameBones; + frameBones = modelJob->BlendTree->GetFinalPose(); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } } else { m_ShieldToStencilProgram->Bind(); GLuint shaderHandle = m_ShieldToStencilProgram->GetHandle(); @@ -523,10 +531,11 @@ void DrawFinalPass::DrawShieldedModelRenderQueue(std::list frameBones; - frameBones = explosionEffectJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); - + if (explosionEffectJob->BlendTree != nullptr) { + std::vector frameBones; + frameBones = explosionEffectJob->BlendTree->GetFinalPose(); + glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } if (GLERROR("Animation")) { continue; } @@ -558,10 +567,11 @@ void DrawFinalPass::DrawShieldedModelRenderQueue(std::list frameBones; - frameBones = modelJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(forwardHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); - + if (modelJob->BlendTree != nullptr) { + std::vector frameBones; + frameBones = modelJob->BlendTree->GetFinalPose(); + glUniformMatrix4fv(glGetUniformLocation(forwardHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } //draw glBindVertexArray(modelJob->Model->VAO); @@ -590,10 +600,11 @@ void DrawFinalPass::DrawToDepthBuffer(std::list>& job glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); - std::vector frameBones; - frameBones = modelJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); - + if (modelJob->BlendTree != nullptr) { + std::vector frameBones; + frameBones = modelJob->BlendTree->GetFinalPose(); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } } else { m_FillDepthBufferProgram->Bind(); GLuint shaderHandle = m_FillDepthBufferProgram->GetHandle(); diff --git a/src/Engine/Rendering/PickingPass.cpp b/src/Engine/Rendering/PickingPass.cpp index 64483755..4d156e46 100644 --- a/src/Engine/Rendering/PickingPass.cpp +++ b/src/Engine/Rendering/PickingPass.cpp @@ -100,12 +100,10 @@ void PickingPass::Draw(RenderScene& scene) glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1]))); - if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) { - + if (modelJob->BlendTree != nullptr) { std::vector frameBones; frameBones = modelJob->BlendTree->GetFinalPose(); glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); - } } else { m_PickingProgram->Bind(); @@ -155,9 +153,11 @@ void PickingPass::Draw(RenderScene& scene) glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1]))); - std::vector frameBones; - frameBones = modelJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + if (modelJob->BlendTree != nullptr) { + std::vector frameBones; + frameBones = modelJob->BlendTree->GetFinalPose(); + glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } } else { m_PickingProgram->Bind(); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); @@ -206,9 +206,11 @@ void PickingPass::Draw(RenderScene& scene) glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1]))); - std::vector frameBones; - frameBones = modelJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + if (modelJob->BlendTree != nullptr) { + std::vector frameBones; + frameBones = modelJob->BlendTree->GetFinalPose(); + glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } } else { m_PickingProgram->Bind(); @@ -261,12 +263,10 @@ void PickingPass::Draw(RenderScene& scene) glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1]))); - if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) { - + if (modelJob->BlendTree != nullptr) { std::vector frameBones; frameBones = modelJob->BlendTree->GetFinalPose(); glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); - } } else { m_PickingProgram->Bind(); diff --git a/src/Engine/Rendering/Skeleton.cpp b/src/Engine/Rendering/Skeleton.cpp index 077e9d02..4583de92 100644 --- a/src/Engine/Rendering/Skeleton.cpp +++ b/src/Engine/Rendering/Skeleton.cpp @@ -94,7 +94,7 @@ void Skeleton::AdditiveBoneTransforms(const Animation* animation, double time, s { if (animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) { glm::mat4 refPose = GetAdditiveBonePose(bone, animation, 0.0); - glm::mat4 srcPose = GetAdditiveBonePose(bone, animation, time); + glm::mat4 srcPose = GetAdditiveBonePose(bone, animation, time + 1.0/60.0); glm::mat4 boneMatrix = srcPose * glm::inverse(refPose); boneMatrices[bone->ID] = boneMatrix; } @@ -335,21 +335,17 @@ std::map Skeleton::BlendPoseAdditive(const std::map Skeleton::GetFinalPose(std::map& boneMatrices) +void Skeleton::GetFinalPose(std::map& boneMatrices, std::vector& finalPose, std::map& boneTransforms) { - std::vector finalPose; - - AccumulateFinalPose(boneMatrices, RootBone, glm::mat4(1)); - + AccumulateFinalPose(boneMatrices, boneTransforms, RootBone, glm::mat4(1)); for(auto& b : boneMatrices) { finalPose.push_back(b.second); } - return finalPose; } -void Skeleton::AccumulateFinalPose(std::map& boneMatrices, const Bone* bone, glm::mat4 parentMatrix) +void Skeleton::AccumulateFinalPose(std::map& boneMatrices, std::map& boneTransforms, const Bone* bone, glm::mat4 parentMatrix) { glm::mat4 boneMatrix; @@ -370,8 +366,10 @@ void Skeleton::AccumulateFinalPose(std::map& boneMatrices, const } } + boneTransforms[bone->ID] = boneMatrix; + for (auto &child : bone->Children) { - AccumulateFinalPose(boneMatrices, child, boneMatrix); + AccumulateFinalPose(boneMatrices, boneTransforms, child, boneMatrix); } } From f220d8088c13285239625b86f6519dc93fb3a6ee Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Fri, 26 Feb 2016 10:53:16 +0100 Subject: [PATCH 066/252] Begin clean-up --- include/Engine/Rendering/ShadowPass.h | 30 +++++++--------------- src/Engine/Rendering/DrawFinalPass.cpp | 6 ++--- src/Engine/Rendering/ShadowPass.cpp | 35 +++++++++++++------------- 3 files changed, 29 insertions(+), 42 deletions(-) diff --git a/include/Engine/Rendering/ShadowPass.h b/include/Engine/Rendering/ShadowPass.h index b7c37b31..373bc21b 100644 --- a/include/Engine/Rendering/ShadowPass.h +++ b/include/Engine/Rendering/ShadowPass.h @@ -9,17 +9,12 @@ #include "ShadowPassState.h" #include "imgui/imgui.h" -#define MAX_SPLITS 3 +#define MAX_SPLITS 4 #define MAP_SIZE 216.f enum NearFar { Near = 0, Far = 1 }; enum LRBT { Left = 0, Right = 1, Bottom = 2, Top = 3 }; -struct ShadowCamera{ - Camera* camera; - std::array frustumCorners; -}; - struct Frustum { float NearClip; @@ -28,7 +23,7 @@ struct Frustum float AspectRatio; glm::vec3 MiddlePoint; float Radius; - std::array LRTB; + std::array LRBT; std::array CornerPoint; }; @@ -45,24 +40,19 @@ public: void Draw(RenderScene& scene); GLuint DepthMap(int level) const { return m_DepthMap[level]; } - std::array lightP() const { return m_LightProjection; } - std::array lightV() const { return m_LightView; } - std::array farDistance() const { return { m_shadFrusta[0].FarClip, m_shadFrusta[1].FarClip, m_shadFrusta[2].FarClip }; } + std::array LightP() const { return m_LightProjection; } + std::array LightV() const { return m_LightView; } + std::array FarDistance() const { return { m_shadowFrusta[0].FarClip, m_shadowFrusta[1].FarClip, m_shadowFrusta[2].FarClip, m_shadowFrusta[3].FarClip }; } int CurrentNrOfSplits() const { return m_CurrentNrOfSplits; } private: void UpdateFrustumPoints(Frustum& frustum, glm::vec3 camera_position, glm::vec3 view_dir, glm::mat4 p, glm::mat4 v); void UpdateSplitDist(std::array& frusta, float near_distance, float far_distance); - glm::mat4 ApplyCropMatrix(Frustum& frustum, glm::mat4 m, glm::mat4 v); - - glm::mat4 CalculateFrustum(RenderScene & scene, std::shared_ptr directionalLightJob, ShadowCamera shad_cam); - glm::mat4 FindNewFrustum(Frustum frustum, glm::mat4 v, glm::mat4 p); void InitializeCameras(RenderScene & scene); float FindRadius(Frustum& frustum); void PointsToLightspace(Frustum& frustum, glm::mat4 v); void RadiusToLightspace(Frustum& frustum, glm::mat4 v); - - EventBroker* m_EventBroker; + EventBroker* m_EventBroker; const IRenderer* m_Renderer; std::array m_DepthMap; @@ -77,8 +67,8 @@ private: GLfloat m_NearFarPlane[2] = { -34.f, 27.f }; GLfloat m_LRBT[4] = { -10.f, 10.f, -10.f, 10.f }; - GLuint resolutionSizeWidth = 1024 * 2; - GLuint resolutionSizeHeigth = 1024 * 2; + GLuint m_ResolutionSizeWidth = 1024 * 2; + GLuint m_ResolutionSizeHeigth = 1024 * 2; bool m_ShadowOn = true; int m_ShadowLevel = 0; @@ -86,9 +76,7 @@ private: int m_CurrentNrOfSplits = 3; float m_SplitWeight = 0.75f; - //std::array m_shadCams; - Frustum m_MainCamera; - std::array m_shadFrusta; + std::array m_shadowFrusta; }; #endif \ No newline at end of file diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 8770adb4..537bc3dc 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -244,9 +244,9 @@ void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptrlightP().data())); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightV"), MAX_SPLITS, GL_FALSE, glm::value_ptr(*m_ShadowPass->lightV().data())); - glUniform1fv(glGetUniformLocation(shaderHandle, "FarDistance"), MAX_SPLITS, m_ShadowPass->farDistance().data()); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightP"), MAX_SPLITS, GL_FALSE, glm::value_ptr(*m_ShadowPass->LightP().data())); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightV"), MAX_SPLITS, GL_FALSE, glm::value_ptr(*m_ShadowPass->LightV().data())); + glUniform1fv(glGetUniformLocation(shaderHandle, "FarDistance"), MAX_SPLITS, m_ShadowPass->FarDistance().data()); //GLfloat m_NearFarPlane[2] = { -40.f, 30.f }; diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index a5ef4663..c3eb8c73 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -11,14 +11,14 @@ ShadowPass::ShadowPass(IRenderer * renderer) ShadowPass::~ShadowPass() { - // m_shadCams + } void ShadowPass::InitializeCameras(RenderScene & scene) { for (int i = 0; i < m_CurrentNrOfSplits; i++) { - m_shadFrusta[i].AspectRatio = scene.Camera->AspectRatio(); - m_shadFrusta[i].FOV = scene.Camera->FOV(); + m_shadowFrusta[i].AspectRatio = scene.Camera->AspectRatio(); + m_shadowFrusta[i].FOV = scene.Camera->FOV(); } } @@ -69,7 +69,7 @@ void ShadowPass::UpdateFrustumPoints(Frustum& frustum, glm::vec3 camera_position frustum.CornerPoint[6] = far_center + up * far_height + right * far_width; frustum.CornerPoint[7] = far_center - up * far_height + right * far_width; - // Alternative way + // Alternative way. //std::array CornerPoint = { // glm::vec4(-1.f, -1.f, -1.f, 1.f), // glm::vec4(-1.f, 1.f, -1.f, 1.f), @@ -80,12 +80,12 @@ void ShadowPass::UpdateFrustumPoints(Frustum& frustum, glm::vec3 camera_position // glm::vec4(1.f, 1.f, 1.f, 1.f), // glm::vec4(1.f, -1.f, 1.f, 1.f) }; - //std::array final; + //std::array FinalPoints; //for (int i = 0; i < 8; i++) { - // glm::vec4 anus = glm::inverse(p) * CornerPoint[i]; - // anus = anus / anus.w; - // final[i] = glm::vec3(glm::inverse(v) * anus); + // glm::vec4 NDC = glm::inverse(p) * CornerPoint[i]; + // NDC = NDC / NDC.w; + // FinalPoints[i] = glm::vec3(glm::inverse(v) * NDC); //} } @@ -111,7 +111,7 @@ void ShadowPass::InitializeFrameBuffers() for (int i = 0; i < m_CurrentNrOfSplits; i++) { glBindTexture(GL_TEXTURE_2D, m_DepthMap[i]); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, resolutionSizeWidth / (1 /*+ i*/), resolutionSizeHeigth + (1 /*+ i*/), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, m_ResolutionSizeWidth / (1 /*+ i*/), m_ResolutionSizeHeigth + (1 /*+ i*/), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); @@ -165,7 +165,7 @@ void ShadowPass::PointsToLightspace(Frustum& frustum, glm::mat4 v) if (tempPoint.y > top) { top = tempPoint.y; } } - frustum.LRTB = { left, right, bottom, top }; + frustum.LRBT = { left, right, bottom, top }; } void ShadowPass::RadiusToLightspace(Frustum& frustum, glm::mat4 v) @@ -175,7 +175,7 @@ void ShadowPass::RadiusToLightspace(Frustum& frustum, glm::mat4 v) float bottom = -frustum.Radius; float top =frustum.Radius; - frustum.LRTB = { left, right, bottom, top }; + frustum.LRBT = { left, right, bottom, top }; } void ShadowPass::Draw(RenderScene & scene) @@ -186,10 +186,10 @@ void ShadowPass::Draw(RenderScene & scene) ImGui::DragInt("ShadowLevel", &m_ShadowLevel, 0.05f, 0, m_CurrentNrOfSplits - 1); InitializeCameras(scene); - UpdateSplitDist(m_shadFrusta, scene.Camera->NearClip(), scene.Camera->FarClip()); + UpdateSplitDist(m_shadowFrusta, scene.Camera->NearClip(), scene.Camera->FarClip()); for (int i = 0; i < m_CurrentNrOfSplits; i++) { - UpdateFrustumPoints(m_shadFrusta[i], scene.Camera->Position(), scene.Camera->Forward(), scene.Camera->ProjectionMatrix(), scene.Camera->ViewMatrix()); + UpdateFrustumPoints(m_shadowFrusta[i], scene.Camera->Position(), scene.Camera->Forward(), scene.Camera->ProjectionMatrix(), scene.Camera->ViewMatrix()); //float test = FindRadius(m_shadFrusta[i]); ShadowPassState* state = new ShadowPassState(m_DepthBuffer[i].GetHandle()); @@ -197,7 +197,7 @@ void ShadowPass::Draw(RenderScene & scene) GLuint shaderHandle = m_ShadowProgram->GetHandle(); m_ShadowProgram->Bind(); - glViewport(0, 0, resolutionSizeWidth / (1/* + i*/), resolutionSizeHeigth); + glViewport(0, 0, m_ResolutionSizeWidth / (1/* + i*/), m_ResolutionSizeHeigth); glDisable(GL_TEXTURE_2D); glCullFace(GL_FRONT); //state->Disable(GL_CULL_FACE); @@ -208,11 +208,10 @@ void ShadowPass::Draw(RenderScene & scene) auto directionalLightJob = std::dynamic_pointer_cast(job); if (directionalLightJob) { - m_LightView[i] = glm::lookAt(glm::vec3(-directionalLightJob->Direction) + m_shadFrusta[i].MiddlePoint, m_shadFrusta[i].MiddlePoint, glm::vec3(0.f, 1.f, 0.f)); + m_LightView[i] = glm::lookAt(glm::vec3(-directionalLightJob->Direction) + m_shadowFrusta[i].MiddlePoint, m_shadowFrusta[i].MiddlePoint, glm::vec3(0.f, 1.f, 0.f)); - PointsToLightspace(m_shadFrusta[i], m_LightView[i]); - m_LightProjection[i] = glm::ortho(m_shadFrusta[i].LRTB[Left], m_shadFrusta[i].LRTB[Right], m_shadFrusta[i].LRTB[Bottom], m_shadFrusta[i].LRTB[Top], -30.f, 30.f); - //m_LightProjection[i] = glm::ortho(m_shadFrusta[i].LRTB[Left], m_shadFrusta[i].LRTB[Right], m_shadFrusta[i].LRTB[Bottom], m_shadFrusta[i].LRTB[Top], -0.f, 300.f); + PointsToLightspace(m_shadowFrusta[i], m_LightView[i]); + m_LightProjection[i] = glm::ortho(m_shadowFrusta[i].LRBT[Left], m_shadowFrusta[i].LRBT[Right], m_shadowFrusta[i].LRBT[Bottom], m_shadowFrusta[i].LRBT[Top], -30.f, 30.f); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection[i])); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView[i])); From 18450ff4f37e5b296bb6e813a3717d744272a6d9 Mon Sep 17 00:00:00 2001 From: Jocke Date: Fri, 26 Feb 2016 11:08:05 +0100 Subject: [PATCH 067/252] Death explosion should always get triggered now. (I hope) --- include/Engine/Network/Client.h | 1 + src/Engine/Network/Client.cpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/Engine/Network/Client.h b/include/Engine/Network/Client.h index 968c4bba..be76e265 100644 --- a/include/Engine/Network/Client.h +++ b/include/Engine/Network/Client.h @@ -19,6 +19,7 @@ #include "Core/World.h" #include "Core/EventBroker.h" #include "Core/ConfigFile.h" +#include "Core/EPlayerDeath.h" #include "Input/EInputCommand.h" #include "Core/EPlayerDamage.h" #include "../Game/Events/EDoubleJump.h" diff --git a/src/Engine/Network/Client.cpp b/src/Engine/Network/Client.cpp index d94ccbc6..d8da7e16 100644 --- a/src/Engine/Network/Client.cpp +++ b/src/Engine/Network/Client.cpp @@ -261,8 +261,14 @@ void Client::parseEntityDeletion(Packet & packet) if (m_ServerIDToClientID.find(entityToDelete) != m_ServerIDToClientID.end()) { EntityID localEntity = m_ServerIDToClientID.at(entityToDelete); if (m_World->ValidEntity(localEntity)) { - m_World->DeleteEntity(localEntity); - deleteFromServerClientMaps(entityToDelete, localEntity); + if (m_World->HasComponent(localEntity,"Player")) { + Events::PlayerDeath e; + e.Player = EntityWrapper(m_World, localEntity); + m_EventBroker->Publish(e); + } else { + m_World->DeleteEntity(localEntity); + deleteFromServerClientMaps(entityToDelete, localEntity); + } } } } From f56705d921aba781fc6845c7bcc27e26e6da2bf3 Mon Sep 17 00:00:00 2001 From: Teejoon Date: Fri, 26 Feb 2016 11:51:20 +0100 Subject: [PATCH 068/252] You can now change the quality of SSAO by sliding the SSAO Quality --- include/Engine/Rendering/DrawFinalPass.h | 8 +- include/Engine/Rendering/IRenderer.h | 1 + include/Engine/Rendering/Renderer.h | 9 +- include/Engine/Rendering/SSAOPass.h | 42 +++- resources/DefaultConfig.ini | 35 ++- resources/Shaders/ForwardPlus.frag.glsl | 3 +- .../Shaders/ForwardPlusSplatMapRGB.frag.glsl | 3 +- resources/Shaders/SSAO.frag.glsl | 19 +- resources/Shaders/SSAO.vert.glsl | 5 + resources/Shaders/SSAOViewSpaceZ.frag.glsl | 6 +- src/Engine/Rendering/CubeMapPass.cpp | 1 + src/Engine/Rendering/DrawFinalPass.cpp | 36 +-- src/Engine/Rendering/FrameBuffer.cpp | 42 ++-- src/Engine/Rendering/Renderer.cpp | 13 +- src/Engine/Rendering/SSAOPass.cpp | 210 +++++++++++++++--- src/Game/Game.cpp | 2 +- 16 files changed, 334 insertions(+), 101 deletions(-) diff --git a/include/Engine/Rendering/DrawFinalPass.h b/include/Engine/Rendering/DrawFinalPass.h index 1800c90e..e522cdc5 100644 --- a/include/Engine/Rendering/DrawFinalPass.h +++ b/include/Engine/Rendering/DrawFinalPass.h @@ -5,6 +5,7 @@ #include "DrawFinalPassState.h" #include "LightCullingPass.h" #include "CubeMapPass.h" +#include "SSAOPass.h" #include "FrameBuffer.h" #include "ShaderProgram.h" #include "Util/UnorderedMapVec2.h" @@ -14,12 +15,12 @@ class DrawFinalPass { public: - DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass); + DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass); ~DrawFinalPass() { } void InitializeTextures(); void InitializeFrameBuffers(); void InitializeShaderPrograms(); - void Draw(RenderScene& scene, GLuint SSAOTexture); + void Draw(RenderScene& scene); void ClearBuffer(); void OnWindowResize(); @@ -38,7 +39,7 @@ private: void GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const; void DrawSprites(std::list>&jobs, RenderScene& scene); - void DrawModelRenderQueues(std::list>& jobs, RenderScene& scene, GLuint SSAOTexture); + void DrawModelRenderQueues(std::list>& jobs, RenderScene& scene); void DrawShieldToStencilBuffer(std::list>& jobs, RenderScene& scene); void DrawShieldedModelRenderQueue(std::list>& jobs, RenderScene& scene); void DrawToDepthBuffer(std::list>& jobs, RenderScene& scene); @@ -71,6 +72,7 @@ private: const IRenderer* m_Renderer; const LightCullingPass* m_LightCullingPass; const CubeMapPass* m_CubeMapPass; + const SSAOPass* m_SSAOPass; ShaderProgram* m_ForwardPlusProgram; ShaderProgram* m_ExplosionEffectProgram; diff --git a/include/Engine/Rendering/IRenderer.h b/include/Engine/Rendering/IRenderer.h index 4441bb7d..97293f06 100644 --- a/include/Engine/Rendering/IRenderer.h +++ b/include/Engine/Rendering/IRenderer.h @@ -5,6 +5,7 @@ #include "../OpenGL.h" #include "../GLM.h" #include "../Core/Util/Rectangle.h" +#include "../Core/ConfigFile.h" #include "Util/ScreenCoords.h" #include "Camera.h" #include "RenderQueue.h" diff --git a/include/Engine/Rendering/Renderer.h b/include/Engine/Rendering/Renderer.h index f3a6bf31..246b328d 100644 --- a/include/Engine/Rendering/Renderer.h +++ b/include/Engine/Rendering/Renderer.h @@ -32,8 +32,9 @@ class Renderer : public IRenderer static void glfwFrameBufferCallback(GLFWwindow* window, int width, int height); public: - Renderer(EventBroker* eventBroker) - : m_EventBroker(eventBroker) + Renderer(EventBroker* eventBroker, ConfigFile* config) + : m_EventBroker(eventBroker) + , m_Config(config) { } virtual void Initialize() override; @@ -47,6 +48,7 @@ private: //----------------------Variables----------------------// static std::unordered_map m_WindowToRenderer; + ConfigFile* m_Config; EventBroker* m_EventBroker; TextPass* m_TextPass; @@ -67,6 +69,9 @@ private: float m_SSAO_IntensityScale = 1.0f; int m_SSAO_NumOfSamples = 24; int m_SSAO_NumOfTurns = 7; + int m_SSAO_iterations = 9; + int m_SSAO_TextureQuality = 0; + int m_SSAO_Quality = 0; PickingPass* m_PickingPass; LightCullingPass* m_LightCullingPass; diff --git a/include/Engine/Rendering/SSAOPass.h b/include/Engine/Rendering/SSAOPass.h index 792d1d82..a2cf349d 100644 --- a/include/Engine/Rendering/SSAOPass.h +++ b/include/Engine/Rendering/SSAOPass.h @@ -13,18 +13,32 @@ class SSAOPass { public: - SSAOPass(IRenderer* rendere); - ~SSAOPass() { - delete m_DrawBloomPass; - }; + SSAOPass(IRenderer* renderer, ConfigFile* config); + ~SSAOPass() { }; + + void ChangeQuality(int quality); void Draw(GLuint depthBuffer, Camera* camera); - void Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int NumOfTurns); + void Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int numOfTurns, int iterations, int quality); void ClearBuffer(); void OnWindowResize(); //Return the SSAO of the texture sent to Draw - GLuint SSAOTexture() const { return m_DrawBloomPass->GaussianTexture(); } + GLuint SSAOTexture() const { + if (m_Quality == 0) { + return m_WhiteTexture->m_Texture; + } else { + return m_GaussianTexture_vert; + } + } + + int TextureQuality() const { + if (m_Quality == 0) { + return 13; + } else { + return m_TextureQuality; + } + } private: void InitializeTexture(); @@ -40,6 +54,7 @@ private: Model* m_ScreenQuad; const IRenderer* m_Renderer; + ConfigFile* m_Config; float m_Radius; float m_Bias; @@ -47,6 +62,11 @@ private: float m_IntensityScale; int m_NumOfSamples; int m_NumOfTurns; + int m_Iterations; + int m_TextureQuality; + int m_Quality; + + Texture* m_WhiteTexture; GLuint m_SSAOTexture; FrameBuffer m_SSAOFramBuffer; @@ -54,10 +74,16 @@ private: GLuint m_SSAOViewSpaceZTexture; FrameBuffer m_SSAOViewSpaceZFramBuffer; + GLuint m_GaussianTexture_horiz; + GLuint m_GaussianTexture_vert; + + FrameBuffer m_GaussianFrameBuffer_horiz; + FrameBuffer m_GaussianFrameBuffer_vert; + ShaderProgram* m_SSAOProgram; ShaderProgram* m_SSAOViewSpaceZProgram; - - DrawBloomPass* m_DrawBloomPass; + ShaderProgram* m_GaussianProgram_horiz; + ShaderProgram* m_GaussianProgram_vert; }; #endif \ No newline at end of file diff --git a/resources/DefaultConfig.ini b/resources/DefaultConfig.ini index 60ee4823..d4696bba 100644 --- a/resources/DefaultConfig.ini +++ b/resources/DefaultConfig.ini @@ -36,4 +36,37 @@ ResourceLoading=true [Sound] BGMVolume=1.0 SFXVolume=1.0 -Announcer=female \ No newline at end of file +Announcer=female + +[SSAO] +Quality=0 + +[SSAO1] +Radius=1.0 +Bias=0.02 +Contrast=1.5 +Intensity=1.0 +NumSamples=8 +NumTurns=3 +NumIterations=5 +TextureQuality=2 + +[SSAO2] +Radius=1.0 +Bias=0.02 +Contrast=1.5 +Intensity=1.0 +NumSamples=16 +NumTurns=13 +NumIterations=9 +TextureQuality=1 + +[SSAO3] +Radius=1.0 +Bias=0.02 +Contrast=1.5 +Intensity=1.0 +NumSamples=24 +NumTurns=17 +NumIterations=13 +TextureQuality=0 \ No newline at end of file diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 6fbc9c27..00f95888 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -13,6 +13,7 @@ uniform vec4 AmbientColor; uniform float FillPercentage; uniform float GlowIntensity = 10; uniform vec3 CameraPosition; +uniform int SSAOQuality; uniform vec2 DiffuseUVRepeat; uniform vec2 NormalUVRepeat; @@ -125,7 +126,7 @@ vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textu void main() { - float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy), 0).r; + float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy) >> int(SSAOQuality), 0).r; ao = (clamp(1.0 - (1.0 - ao), 0.0, 1.0) + MIN_AMBIENT_LIGHT) / (1.0 + MIN_AMBIENT_LIGHT); vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate * DiffuseUVRepeat); vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat); diff --git a/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl b/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl index cf358b96..c67a9c99 100644 --- a/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl +++ b/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl @@ -11,6 +11,7 @@ uniform vec4 DiffuseColor; uniform vec4 FillColor; uniform vec4 Color; uniform vec4 AmbientColor; +uniform int SSAOQuality; //Get bineded at the same time as the textures uniform vec2 DiffuseUVRepeat1; @@ -177,7 +178,7 @@ vec4 CalcBlendedNormal(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B, void main() { - float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy), 0).r; + float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy) >> int(SSAOQuality), 0).r; ao = (clamp(1.0 - (1.0 - ao), 0.0, 1.0) + MIN_AMBIENT_LIGHT) / (1.0 + MIN_AMBIENT_LIGHT); vec4 splatTexel = texture2D(SplatMapTexture, Input.TextureCoordinate); diff --git a/resources/Shaders/SSAO.frag.glsl b/resources/Shaders/SSAO.frag.glsl index 68c830f8..749881c4 100644 --- a/resources/Shaders/SSAO.frag.glsl +++ b/resources/Shaders/SSAO.frag.glsl @@ -2,11 +2,11 @@ //Number of samples per pixel uniform int uNumOfSamples; -//#define NUM_SAMPLES (11) +//#define uNumOfSamples (11) //Number of turns around the cirle uniform int uNumOfTurns; -//#define NUM_TURNS (7) +//#define uNumOfTurns (7) layout (binding = 0) uniform sampler2D ViewSpaceZ; @@ -16,15 +16,16 @@ uniform float uProjScale; //#define ProjScale 500 uniform float uRadius; -//#define Radius 1.0f +//#define uRadius 1.0f uniform float uBias; -//#define Bias 0.012f +//#define uBias 0.05f uniform float uContrast; -//#define IntensityDivR6 1 +//#define uContrast 1.5f uniform float uIntensityScale; +//#define uIntensityScale 1.0f out float AO; @@ -88,13 +89,7 @@ void main() { vec3 origin = getVSPosition(originScreenCoord); - float radius; - if(origin.z < uRadius){ - radius = origin.z; - } else { - radius = uRadius; - } - + float radius = min(origin.z, uRadius); vec3 originNormal = getVSFaceNormal(origin); diff --git a/resources/Shaders/SSAO.vert.glsl b/resources/Shaders/SSAO.vert.glsl index a019c5ef..346bc141 100644 --- a/resources/Shaders/SSAO.vert.glsl +++ b/resources/Shaders/SSAO.vert.glsl @@ -2,7 +2,12 @@ layout (location = 0) in vec3 Position; +out VertexData{ + vec2 TextureCoordinate; +}Output; + void main() { gl_Position = vec4(Position, 1.0); + Output.TextureCoordinate = (vec2(Position) + 1) / 2; } \ No newline at end of file diff --git a/resources/Shaders/SSAOViewSpaceZ.frag.glsl b/resources/Shaders/SSAOViewSpaceZ.frag.glsl index dbcfd899..d1bf6f17 100644 --- a/resources/Shaders/SSAOViewSpaceZ.frag.glsl +++ b/resources/Shaders/SSAOViewSpaceZ.frag.glsl @@ -3,11 +3,15 @@ layout (binding = 0) uniform sampler2D DepthBuffer; uniform vec3 ClipInfo; +in VertexData{ + vec2 TextureCoordinate; +}Input; + out float depthLinear; //Just for Debug, should be depthLinear //out vec4 fragmentColor; void main() { - float depthSample = texelFetch(DepthBuffer, ivec2(gl_FragCoord.xy), 0).r; + float depthSample = texture2D(DepthBuffer, Input.TextureCoordinate).r; depthLinear = ClipInfo[0] / (ClipInfo[1] * depthSample + ClipInfo[2]); //float depthLinear = (NearClip) / ( -depthSample + 1.0f); //fragmentColor = vec4(depthLinear, depthLinear, depthLinear, 1.0f); diff --git a/src/Engine/Rendering/CubeMapPass.cpp b/src/Engine/Rendering/CubeMapPass.cpp index 75f5e1c9..fc318498 100644 --- a/src/Engine/Rendering/CubeMapPass.cpp +++ b/src/Engine/Rendering/CubeMapPass.cpp @@ -17,6 +17,7 @@ void CubeMapPass::LoadTextures(std::string input) m_CubeMapTextures.push_back(img); } GenerateCubeMapTexture(); + m_PreviusCubeMapTexture = input; } } diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 6cd2c1f1..48c07941 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -1,9 +1,9 @@ #include "Rendering/DrawFinalPass.h" - -DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass) - : m_Renderer(renderer) - , m_LightCullingPass(lightCullingPass) - , m_CubeMapPass(cubeMapPass) +DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass) + : m_Renderer(renderer) + , m_LightCullingPass(lightCullingPass) + , m_CubeMapPass(cubeMapPass) + , m_SSAOPass(ssaoPass) { //TODO: Make sure that uniforms are not sent into shader if not needed. m_ShieldPixelRate = 8; @@ -175,7 +175,7 @@ void DrawFinalPass::InitializeShaderPrograms() GLERROR("Creating DepthFill program"); } -void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture) +void DrawFinalPass::Draw(RenderScene& scene) { GLERROR("Pre"); DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle()); @@ -191,10 +191,10 @@ void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture) //Fill depth buffer state->StencilMask(0x00); - DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene, SSAOTexture); + DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene); GLERROR("OpaqueObjects"); state->BlendFunc(GL_ONE, GL_ONE); - DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene, SSAOTexture); + DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene); GLERROR("TransparentObjects"); state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); DrawSprites(scene.Jobs.SpriteJob, scene); @@ -210,11 +210,11 @@ void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture) //Draw Opaque shielded objects state->StencilFunc(GL_NOTEQUAL, 1, 0xFF); state->StencilMask(0x00); - DrawModelRenderQueues(scene.Jobs.OpaqueShieldedObjects, scene, SSAOTexture); //might need changing + DrawModelRenderQueues(scene.Jobs.OpaqueShieldedObjects, scene); //might need changing GLERROR("Shielded Opaque object"); //Draw Transparen Shielded objects - DrawModelRenderQueues(scene.Jobs.TransparentShieldedObjects, scene, SSAOTexture); //might need changing + DrawModelRenderQueues(scene.Jobs.TransparentShieldedObjects, scene); //might need changing GLERROR("Shielded Transparent objects"); GLERROR("END"); @@ -250,9 +250,9 @@ void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture) stateLowRes->Enable(GL_DEPTH_TEST); stateLowRes->StencilFunc(GL_LEQUAL, 1, 0xFF); stateLowRes->StencilMask(0x00); - DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene, SSAOTexture); + DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene); GLERROR("OpaqueObjects"); - DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene, SSAOTexture); + DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene); GLERROR("TransparentObjects"); glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); @@ -340,7 +340,7 @@ void DrawFinalPass::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm: GLERROR("MipMap Texture initialization failed"); } -void DrawFinalPass::DrawModelRenderQueues(std::list>& jobs, RenderScene& scene, GLuint SSAOTexture) +void DrawFinalPass::DrawModelRenderQueues(std::list>& jobs, RenderScene& scene) { GLuint forwardHandle = m_ForwardPlusProgram->GetHandle(); GLERROR("forwardHandle"); @@ -364,7 +364,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO()); glActiveTexture(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, SSAOTexture); + glBindTexture(GL_TEXTURE_2D, m_SSAOPass->SSAOTexture()); for (auto &job : jobs) { auto explosionEffectJob = std::dynamic_pointer_cast(job); @@ -383,7 +383,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob); glActiveTexture(GL_TEXTURE5); glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); - glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + glUniform3fv(glGetUniformLocation(explosionSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); std::vector frameBones; if (explosionEffectJob->AnimationOffset.animation != nullptr) { @@ -401,7 +401,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& BindExplosionTextures(explosionHandle, explosionEffectJob); glActiveTexture(GL_TEXTURE5); glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); - glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + glUniform3fv(glGetUniformLocation(explosionHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); } break; @@ -463,7 +463,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& BindModelTextures(forwardSkinnedHandle, modelJob); glActiveTexture(GL_TEXTURE5); glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); - glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + glUniform3fv(glGetUniformLocation(forwardSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); std::vector frameBones; if (modelJob->AnimationOffset.animation != nullptr) { @@ -753,6 +753,7 @@ void DrawFinalPass::DrawSprites(std::list>&jobs, Rend void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) { + glUniform1i(glGetUniformLocation(shaderHandle, "SSAOQuality"), m_SSAOPass->TextureQuality()); GLERROR("Bind 1 uniform"); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix)); GLERROR("Bind 2 uniform"); @@ -801,6 +802,7 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) { + glUniform1i(glGetUniformLocation(shaderHandle, "SSAOQuality"), m_SSAOPass->TextureQuality()); GLERROR("Bind 1 uniform"); GLint Location_M = glGetUniformLocation(shaderHandle, "M"); glUniformMatrix4fv(Location_M, 1, GL_FALSE, glm::value_ptr(job->Matrix)); diff --git a/src/Engine/Rendering/FrameBuffer.cpp b/src/Engine/Rendering/FrameBuffer.cpp index 794fb84e..9ba0d2d8 100644 --- a/src/Engine/Rendering/FrameBuffer.cpp +++ b/src/Engine/Rendering/FrameBuffer.cpp @@ -42,33 +42,33 @@ void FrameBuffer::Generate() GLERROR("PRE"); std::vector attachments; - - glGenFramebuffers(1, &m_BufferHandle); + if (m_BufferHandle == 0) { + glGenFramebuffers(1, &m_BufferHandle); + } glBindFramebuffer(GL_FRAMEBUFFER, m_BufferHandle); GLERROR("1"); - for (auto it = m_Resources.begin(); it != m_Resources.end(); it++) { - switch ((*it)->m_ResourceType) { - case GL_TEXTURE_2D: - glFramebufferTexture2D(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle, 0); - GLERROR("FrameBuffer generate: glFramebufferTexture2D"); + for (auto it = m_Resources.begin(); it != m_Resources.end(); it++) { + switch ((*it)->m_ResourceType) { + case GL_TEXTURE_2D: + glFramebufferTexture2D(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle, 0); + GLERROR("FrameBuffer generate: glFramebufferTexture2D"); - break; - case GL_RENDERBUFFER: - glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle); - GLERROR("FrameBuffer generate: glFramebufferRenderbuffer"); - break; - } - GLERROR("2"); + break; + case GL_RENDERBUFFER: + glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle); + GLERROR("FrameBuffer generate: glFramebufferRenderbuffer"); + break; + } + GLERROR("2"); - if ((*it)->m_Attachment != GL_DEPTH_ATTACHMENT && (*it)->m_Attachment != GL_STENCIL_ATTACHMENT && (*it)->m_Attachment != GL_DEPTH_STENCIL_ATTACHMENT) { - attachments.push_back((*it)->m_Attachment); - } - GLERROR("Attachment"); - - } - GLERROR("3"); + if ((*it)->m_Attachment != GL_DEPTH_ATTACHMENT && (*it)->m_Attachment != GL_STENCIL_ATTACHMENT && (*it)->m_Attachment != GL_DEPTH_STENCIL_ATTACHMENT) { + attachments.push_back((*it)->m_Attachment); + } + GLERROR("Attachment"); + } + GLERROR("3"); GLenum* bufferTextures = &attachments[0]; glDrawBuffers(attachments.size(), bufferTextures); diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index 251bba2b..fcf2bc84 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -121,7 +121,11 @@ void Renderer::Draw(RenderFrame& frame) ImGui::SliderFloat("SSAO IntensityScale", &m_SSAO_IntensityScale, 0.0f, 10.0f); ImGui::SliderInt("SSAO Number of Samples", &m_SSAO_NumOfSamples, 2, 100); ImGui::SliderInt("SSAO Number of Turns", &m_SSAO_NumOfTurns, 0, 50); - m_SSAOPass->Setting(m_SSAO_Radius, m_SSAO_Bias, m_SSAO_Contrast, m_SSAO_IntensityScale, m_SSAO_NumOfSamples, m_SSAO_NumOfTurns); + ImGui::SliderInt("SSAO Blur Iterations", &m_SSAO_iterations, 0, 20); + ImGui::SliderInt("SSAO TextureQuality", &m_SSAO_TextureQuality, 0, 4); + ImGui::SliderInt("SSAO Quality", &m_SSAO_Quality, 0, 3); + //m_SSAOPass->Setting(m_SSAO_Radius, m_SSAO_Bias, m_SSAO_Contrast, m_SSAO_IntensityScale, m_SSAO_NumOfSamples, m_SSAO_NumOfTurns, m_SSAO_iterations, m_SSAO_TextureQuality); + m_SSAOPass->ChangeQuality(m_SSAO_Quality); GLERROR("SSAO Settings"); //clear buffer 0 glClearColor(0.f, 0.f, 0.f, 0.f); @@ -159,7 +163,7 @@ void Renderer::Draw(RenderFrame& frame) PerformanceTimer::StartTimerAndStopPrevious("Renderer-Light Culling"); m_LightCullingPass->CullLights(*scene); GLERROR("LightCulling"); - m_DrawFinalPass->Draw(*scene, ao); + m_DrawFinalPass->Draw(*scene); PerformanceTimer::StartTimerAndStopPrevious("Renderer-Draw Geometry+Light"); GLERROR("Draw Geometry+Light"); //m_DrawScenePass->Draw(*scene); @@ -248,9 +252,10 @@ void Renderer::InitializeRenderPasses() m_PickingPass = new PickingPass(this, m_EventBroker); m_LightCullingPass = new LightCullingPass(this); m_CubeMapPass = new CubeMapPass(this); - m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass); + m_SSAOPass = new SSAOPass(this, m_Config); + m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass, m_SSAOPass); m_DrawScreenQuadPass = new DrawScreenQuadPass(this); m_DrawBloomPass = new DrawBloomPass(this); m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this); - m_SSAOPass = new SSAOPass(this); + } diff --git a/src/Engine/Rendering/SSAOPass.cpp b/src/Engine/Rendering/SSAOPass.cpp index d4cdcb19..7d39e34a 100644 --- a/src/Engine/Rendering/SSAOPass.cpp +++ b/src/Engine/Rendering/SSAOPass.cpp @@ -1,50 +1,134 @@ #include "Rendering/SSAOPass.h" -SSAOPass::SSAOPass(IRenderer* renderer) +SSAOPass::SSAOPass(IRenderer* renderer, ConfigFile* config) + : m_Renderer(renderer) + , m_Config(config) { - m_Renderer = renderer; + m_WhiteTexture = CommonFunctions::LoadTexture("Textures/Core/White.png", false); + + m_Quality = m_Config->Get("SSAO.Quality", 0); + if (m_Quality == 0) { + return; + } + + ChangeQuality(m_Quality); + +} + +void SSAOPass::ChangeQuality(int quality) +{ + if (m_Quality == quality) { + return; + } + + m_Quality = quality; + + if (m_Quality == 0) { + glDeleteTextures(1, &m_SSAOTexture); + glDeleteTextures(1, &m_SSAOViewSpaceZTexture); + glDeleteTextures(1, &m_GaussianTexture_horiz); + glDeleteTextures(1, &m_GaussianTexture_vert); + return; + } + + std::string qStr = std::to_string(m_Quality); + Setting( + m_Config->Get("SSAO" + qStr + ".Radius", 0.01), + m_Config->Get("SSAO" + qStr + ".Bias", 0.012), + m_Config->Get("SSAO" + qStr + ".Contrast", 1.0), + m_Config->Get("SSAO" + qStr + ".Intensity", 1.0), + m_Config->Get("SSAO" + qStr + ".NumSamples", 0), + m_Config->Get("SSAO" + qStr + ".NumTurns", 0), + m_Config->Get("SSAO" + qStr + ".NumIterations", 0), + m_Config->Get("SSAO" + qStr + ".TextureQuality", 4) + ); + + m_ScreenQuad = ResourceManager::Load("Models/Core/ScreenQuad.mesh"); InitializeTexture(); InitializeBuffer(); InitializeShaderProgram(); - Setting(0.1f, 0.012f, 1.0f, 1.0f, 13, 7); - m_DrawBloomPass = new DrawBloomPass(renderer); + } void SSAOPass::InitializeShaderProgram() { m_SSAOProgram = ResourceManager::Load("##SSAOProgram"); - m_SSAOProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/SSAO.vert.glsl"))); - m_SSAOProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/SSAO.frag.glsl"))); - m_SSAOProgram->Compile(); - m_SSAOProgram->Link(); + if (m_SSAOProgram->GetHandle() == 0) { + m_SSAOProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/SSAO.vert.glsl"))); + m_SSAOProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/SSAO.frag.glsl"))); + m_SSAOProgram->Compile(); + m_SSAOProgram->Link(); + } m_SSAOViewSpaceZProgram = ResourceManager::Load("##SSAOViewSpaceZProgram"); - m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/SSAO.vert.glsl"))); - m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/SSAOViewSpaceZ.frag.glsl"))); - m_SSAOViewSpaceZProgram->Compile(); - m_SSAOViewSpaceZProgram->Link(); + if (m_SSAOViewSpaceZProgram->GetHandle() == 0) { + m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/SSAO.vert.glsl"))); + m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/SSAOViewSpaceZ.frag.glsl"))); + m_SSAOViewSpaceZProgram->Compile(); + m_SSAOViewSpaceZProgram->Link(); + } + + m_GaussianProgram_horiz = ResourceManager::Load("##GaussianProgramHoriz"); + if (m_GaussianProgram_horiz->GetHandle() == 0) { + m_GaussianProgram_horiz->AddShader(std::shared_ptr(new VertexShader("Shaders/Gaussian_horiz.vert.glsl"))); + m_GaussianProgram_horiz->AddShader(std::shared_ptr(new FragmentShader("Shaders/Gaussian_horiz.frag.glsl"))); + m_GaussianProgram_horiz->Compile(); + m_GaussianProgram_horiz->Link(); + } + + m_GaussianProgram_vert = ResourceManager::Load("##GaussianProgramVert"); + if (m_GaussianProgram_vert->GetHandle() == 0) { + m_GaussianProgram_vert->AddShader(std::shared_ptr(new VertexShader("Shaders/Gaussian_vert.vert.glsl"))); + m_GaussianProgram_vert->AddShader(std::shared_ptr(new FragmentShader("Shaders/Gaussian_vert.frag.glsl"))); + m_GaussianProgram_vert->Compile(); + m_GaussianProgram_vert->Link(); + } } void SSAOPass::InitializeTexture() { - GenerateTexture(&m_SSAOTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_R8, GL_RED, GL_FLOAT); - GenerateTexture(&m_SSAOViewSpaceZTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_R32F, GL_RED, GL_FLOAT); + GenerateTexture(&m_SSAOTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RED, GL_FLOAT); + GenerateTexture(&m_SSAOViewSpaceZTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R32F, GL_RED, GL_FLOAT); + + GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RGB, GL_FLOAT); + GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RGB, GL_FLOAT); } void SSAOPass::InitializeBuffer() { - m_SSAOFramBuffer.AddResource(std::shared_ptr(new Texture2D(&m_SSAOTexture, GL_COLOR_ATTACHMENT0))); - m_SSAOFramBuffer.Generate(); + if (m_SSAOFramBuffer.GetHandle() == 0) { + m_SSAOFramBuffer.AddResource(std::shared_ptr(new Texture2D(&m_SSAOTexture, GL_COLOR_ATTACHMENT0))); + } + m_SSAOFramBuffer.Generate(); + + + if (m_SSAOViewSpaceZFramBuffer.GetHandle() == 0) { + m_SSAOViewSpaceZFramBuffer.AddResource(std::shared_ptr(new Texture2D(&m_SSAOViewSpaceZTexture, GL_COLOR_ATTACHMENT0))); + } + m_SSAOViewSpaceZFramBuffer.Generate(); + + + + if (m_GaussianFrameBuffer_horiz.GetHandle() == 0) { + m_GaussianFrameBuffer_horiz.AddResource(std::shared_ptr(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0))); + } + m_GaussianFrameBuffer_horiz.Generate(); + + + if (m_GaussianFrameBuffer_vert.GetHandle() == 0) { + m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0))); + } + m_GaussianFrameBuffer_vert.Generate(); - m_SSAOViewSpaceZFramBuffer.AddResource(std::shared_ptr(new Texture2D(&m_SSAOViewSpaceZTexture, GL_COLOR_ATTACHMENT0))); - m_SSAOViewSpaceZFramBuffer.Generate(); } void SSAOPass::ClearBuffer() { + return; + m_SSAOFramBuffer.Bind(); glClearColor(1.f, 1.f, 1.f, 1.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -54,19 +138,32 @@ void SSAOPass::ClearBuffer() glClearColor(1.f, 1.f, 1.f, 1.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); m_SSAOViewSpaceZFramBuffer.Unbind(); + + m_GaussianFrameBuffer_horiz.Bind(); + glClearColor(1.f, 1.f, 1.f, 1.f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + m_GaussianFrameBuffer_horiz.Unbind(); + + m_GaussianFrameBuffer_vert.Bind(); + glClearColor(1.f, 1.f, 1.f, 1.f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + m_GaussianFrameBuffer_vert.Unbind(); } -void SSAOPass::Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int NumOfTurns) { +void SSAOPass::Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int numOfTurns, int iterations, int quality) { m_Radius = radius; m_Bias = bias; m_Contrast = contrast; m_IntensityScale = intensityScale; m_NumOfSamples = numOfSamples; - m_NumOfTurns = NumOfTurns; + m_NumOfTurns = numOfTurns; + m_Iterations = iterations; + m_TextureQuality = quality; } void SSAOPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const { + glDeleteTextures(1, texture); glGenTextures(1, texture); glBindTexture(GL_TEXTURE_2D, *texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping); @@ -79,6 +176,10 @@ void SSAOPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filterin void SSAOPass::Draw(GLuint depthBuffer, Camera* camera) { + if (m_Quality == 0) { + return; + } + SSAOPassState state; GLuint viewSpaceZPShaderHandle = m_SSAOViewSpaceZProgram->GetHandle(); GLuint SSAOShaderHandle = m_SSAOProgram->GetHandle(); @@ -98,6 +199,7 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera) (-1.0f), (+1.0f) );*/ + glViewport(0, 0, (m_Renderer->GetViewportSize().Width >> m_TextureQuality), (m_Renderer->GetViewportSize().Height >> m_TextureQuality)); //JOHAN TODO: Get this into state glUniform3fv(glGetUniformLocation(viewSpaceZPShaderHandle, "ClipInfo"), 1, glm::value_ptr(clipInfo)); glBindVertexArray(m_ScreenQuad->VAO); @@ -107,9 +209,9 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera) glm::vec4 projInfo = glm::vec4( ((1.0 - camera->ProjectionMatrix()[0][2]) / camera->ProjectionMatrix()[0][0]), - (-2.0 / (m_Renderer->GetViewportSize().Width * camera->ProjectionMatrix()[0][0])), + (-2.0 / ((m_Renderer->GetViewportSize().Width >> m_TextureQuality) * camera->ProjectionMatrix()[0][0])), ((1.0 + camera->ProjectionMatrix()[1][2]) / camera->ProjectionMatrix()[1][1]), - (-2.0 / (m_Renderer->GetViewportSize().Height * camera->ProjectionMatrix()[1][1])) + (-2.0 / ((m_Renderer->GetViewportSize().Height >> m_TextureQuality) * camera->ProjectionMatrix()[1][1])) ); @@ -120,26 +222,76 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera) glBindTexture(GL_TEXTURE_2D, m_SSAOViewSpaceZTexture); // How many pixel there are in a 1m long object 1m away from the camera - glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uProjScale"), m_Renderer->GetViewportSize().Height / (-2.0f * glm::tan(camera->FOV() * 0.5f))); + glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uProjScale"), (m_Renderer->GetViewportSize().Height >> m_TextureQuality) / (-2.0f * glm::tan(camera->FOV() * 0.5f))); glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uRadius"), m_Radius); glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uBias"), m_Bias); glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uContrast"), m_Contrast); glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uIntensityScale"), m_IntensityScale); glUniform1i(glGetUniformLocation(SSAOShaderHandle, "uNumOfSamples"), m_NumOfSamples); - glUniform1i(glGetUniformLocation(SSAOShaderHandle, "uNumOfTurns"), m_NumOfTurns);; + glUniform1i(glGetUniformLocation(SSAOShaderHandle, "uNumOfTurns"), m_NumOfTurns); glUniform4fv(glGetUniformLocation(SSAOShaderHandle, "uProjInfo"), 1, glm::value_ptr(projInfo)); glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1 , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex); - m_DrawBloomPass->ClearBuffer(); - m_DrawBloomPass->Draw(m_SSAOTexture); + DrawBloomPassState BloomState; + GLuint shaderHandle_horiz = m_GaussianProgram_horiz->GetHandle(); + GLuint shaderHandle_vert = m_GaussianProgram_vert->GetHandle(); + + m_GaussianFrameBuffer_horiz.Bind(); + m_GaussianProgram_horiz->Bind(); + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, m_SSAOTexture); + + glBindVertexArray(m_ScreenQuad->VAO); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer); + glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1 + , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex); + //Iterate some times to make it more gaussian. + for (int i = 1; i < m_Iterations; i++) { + //Vertical pass + m_GaussianFrameBuffer_vert.Bind(); + m_GaussianProgram_vert->Bind(); + + glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz); + + glBindVertexArray(m_ScreenQuad->VAO); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer); + glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1 + , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex); + //horizontal pass + + m_GaussianFrameBuffer_horiz.Bind(); + m_GaussianProgram_horiz->Bind(); + + glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_vert); + + glBindVertexArray(m_ScreenQuad->VAO); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer); + glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1 + , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex); + } + + //final vertical gaussian after the iterations are done + + m_GaussianFrameBuffer_vert.Bind(); + m_GaussianProgram_vert->Bind(); + + glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz); + glBindVertexArray(m_ScreenQuad->VAO); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer); + glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1 + , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex); + + glViewport(0, 0, (m_Renderer->GetViewportSize().Width), (m_Renderer->GetViewportSize().Height)); } void SSAOPass::OnWindowResize() { - m_DrawBloomPass->OnWindowResize(); + if (m_Quality == 0) { + return; + } + InitializeTexture(); - m_SSAOFramBuffer.Generate(); - m_SSAOViewSpaceZFramBuffer.Generate(); } \ No newline at end of file diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 24b7cd1e..3495730e 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -54,7 +54,7 @@ Game::Game(int argc, char* argv[]) m_EventBroker = new EventBroker(); // Create the renderer - m_Renderer = new Renderer(m_EventBroker); + m_Renderer = new Renderer(m_EventBroker, m_Config); m_Renderer->SetFullscreen(m_Config->Get("Video.Fullscreen", false)); m_Renderer->SetVSYNC(m_Config->Get("Video.VSYNC", false)); m_Renderer->SetResolution(Rectangle::Rectangle( From 0c60b637c30908893012b37f5be14b7269f3bbb9 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Fri, 26 Feb 2016 12:52:10 +0100 Subject: [PATCH 069/252] Who's merging without compiling? --- src/Engine/Network/Server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Engine/Network/Server.cpp b/src/Engine/Network/Server.cpp index 30d3b67d..7c614cee 100644 --- a/src/Engine/Network/Server.cpp +++ b/src/Engine/Network/Server.cpp @@ -601,7 +601,7 @@ void Server::parsePlayerTransform(Packet& packet) bool Server::shouldSendToClient(EntityWrapper childEntity) { - auto children = m_World->GetChildren(childEntity.ID); + auto children = m_World->GetDirectChildren(childEntity.ID); for (auto it = children.first; it != children.second; it++) { EntityWrapper child(m_World, it->second); if(child.HasComponent("CapturePoint")) { From 0805375483accc1e5d5069ed878d79560b809348 Mon Sep 17 00:00:00 2001 From: Teejoon Date: Fri, 26 Feb 2016 13:25:19 +0100 Subject: [PATCH 070/252] Deleted SSAO sliders except Quality --- include/Engine/Rendering/Renderer.h | 11 ----------- src/Engine/Rendering/Renderer.cpp | 16 +++------------- 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/include/Engine/Rendering/Renderer.h b/include/Engine/Rendering/Renderer.h index 246b328d..47e88e57 100644 --- a/include/Engine/Rendering/Renderer.h +++ b/include/Engine/Rendering/Renderer.h @@ -60,17 +60,6 @@ private: Model* m_UnitQuad; Model* m_UnitSphere; - int m_DebugTextureToDraw = 0; - int m_CubeMapTexture = 0; - bool m_ResizeWindow = false; - float m_SSAO_Radius = 1.0f; - float m_SSAO_Bias = 0.05f; - float m_SSAO_Contrast = 1.5f; - float m_SSAO_IntensityScale = 1.0f; - int m_SSAO_NumOfSamples = 24; - int m_SSAO_NumOfTurns = 7; - int m_SSAO_iterations = 9; - int m_SSAO_TextureQuality = 0; int m_SSAO_Quality = 0; PickingPass* m_PickingPass; diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index fcf2bc84..4c7cd39f 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -115,23 +115,13 @@ void Renderer::Draw(RenderFrame& frame) m_CubeMapPass->LoadTextures("Sky"); } - ImGui::SliderFloat("SSAO sample radius", &m_SSAO_Radius, 0.01f, 5.0f); - ImGui::SliderFloat("SSAO bias", &m_SSAO_Bias, 0.0f, 0.1f); - ImGui::SliderFloat("SSAO contrast", &m_SSAO_Contrast, 0.0f, 10.0f); - ImGui::SliderFloat("SSAO IntensityScale", &m_SSAO_IntensityScale, 0.0f, 10.0f); - ImGui::SliderInt("SSAO Number of Samples", &m_SSAO_NumOfSamples, 2, 100); - ImGui::SliderInt("SSAO Number of Turns", &m_SSAO_NumOfTurns, 0, 50); - ImGui::SliderInt("SSAO Blur Iterations", &m_SSAO_iterations, 0, 20); - ImGui::SliderInt("SSAO TextureQuality", &m_SSAO_TextureQuality, 0, 4); - ImGui::SliderInt("SSAO Quality", &m_SSAO_Quality, 0, 3); - //m_SSAOPass->Setting(m_SSAO_Radius, m_SSAO_Bias, m_SSAO_Contrast, m_SSAO_IntensityScale, m_SSAO_NumOfSamples, m_SSAO_NumOfTurns, m_SSAO_iterations, m_SSAO_TextureQuality); m_SSAOPass->ChangeQuality(m_SSAO_Quality); GLERROR("SSAO Settings"); //clear buffer 0 glClearColor(0.f, 0.f, 0.f, 0.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - //Clear other buffers + //Clear other buffers PerformanceTimer::StartTimer("Renderer-ClearBuffers"); m_PickingPass->ClearPicking(); m_DrawFinalPass->ClearBuffer(); @@ -145,10 +135,10 @@ void Renderer::Draw(RenderFrame& frame) GLERROR("Drawing pickingpass"); PerformanceTimer::StopTimer("Renderer-Depth"); } - PerformanceTimer::StartTimer("AO generation"); + PerformanceTimer::StartTimer("Renderer-AO generation"); m_SSAOPass->Draw(m_PickingPass->DepthBuffer(), frame.RenderScenes.front()->Camera); GLuint ao = m_SSAOPass->SSAOTexture(); - PerformanceTimer::StopTimer("AO generation"); + PerformanceTimer::StopTimer("Renderer-AO generation"); for (auto scene : frame.RenderScenes){ PerformanceTimer::StartTimer("Renderer-Drawing PickingPass"); From 62e22d38217d1d8184c64bf263b55f9346fbc81f Mon Sep 17 00:00:00 2001 From: Teejoon Date: Fri, 26 Feb 2016 13:32:16 +0100 Subject: [PATCH 071/252] Fix --- include/Engine/Rendering/Renderer.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/Engine/Rendering/Renderer.h b/include/Engine/Rendering/Renderer.h index 47e88e57..4ed57e31 100644 --- a/include/Engine/Rendering/Renderer.h +++ b/include/Engine/Rendering/Renderer.h @@ -60,6 +60,9 @@ private: Model* m_UnitQuad; Model* m_UnitSphere; + int m_DebugTextureToDraw = 0; + int m_CubeMapTexture = 0; + bool m_ResizeWindow = false; int m_SSAO_Quality = 0; PickingPass* m_PickingPass; From a48e1b567ac5b700924754bfaf5a1227298c1076 Mon Sep 17 00:00:00 2001 From: Jocke Date: Fri, 26 Feb 2016 16:49:25 +0100 Subject: [PATCH 072/252] Removed comments --- src/Engine/Network/Client.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Engine/Network/Client.cpp b/src/Engine/Network/Client.cpp index d8da7e16..c65d333a 100644 --- a/src/Engine/Network/Client.cpp +++ b/src/Engine/Network/Client.cpp @@ -101,8 +101,7 @@ void Client::Update() void Client::parseMessageType(Packet& packet) { - // Pop packetSize which is used by TCP Client to - // create a packet of the correct size + // Pop packetSize packet.ReadPrimitive(); int messageType = packet.ReadPrimitive(); if (messageType == -1) @@ -233,7 +232,6 @@ void Client::parseSpawnEvents() m_EventBroker->Publish(e); } m_PlayerSpawnEvents = tempSpawn; - // m_PlayerSpawnEvents.clear(); } void Client::parsePlayersSpawned(Packet& packet) From 22c391df54c3aa5479339c6e26dd7dbdedde5537 Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Fri, 26 Feb 2016 17:40:35 +0100 Subject: [PATCH 073/252] Initial work on texture arrays --- include/Engine/Rendering/FrameBuffer.h | 14 +++++ include/Engine/Rendering/ShadowPass.h | 9 ++- resources/Shaders/ExplosionEffect.geom.glsl | 2 +- resources/Shaders/ForwardPlus.frag.glsl | 63 ++++++--------------- resources/Shaders/ForwardPlus.vert.glsl | 2 +- src/Engine/Rendering/DrawFinalPass.cpp | 14 ++--- src/Engine/Rendering/FrameBuffer.cpp | 24 +++++++- src/Engine/Rendering/Renderer.cpp | 6 +- src/Engine/Rendering/ShadowPass.cpp | 53 ++++++++++------- 9 files changed, 101 insertions(+), 86 deletions(-) diff --git a/include/Engine/Rendering/FrameBuffer.h b/include/Engine/Rendering/FrameBuffer.h index cf63b6c6..325fbe3b 100644 --- a/include/Engine/Rendering/FrameBuffer.h +++ b/include/Engine/Rendering/FrameBuffer.h @@ -8,10 +8,12 @@ class BufferResource { public: BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment); + BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment, GLuint layers); GLuint* m_ResourceHandle; GLenum m_ResourceType; GLenum m_Attachment; + GLuint m_Layers; private: }; @@ -22,6 +24,9 @@ class ResourceType : public BufferResource public: ResourceType(GLuint* resourceHandle, GLenum attachment) : BufferResource(resourceHandle, RESOURCETYPE, attachment) { } + + ResourceType(GLuint* resourceHandle, GLenum attachment, GLuint layers) + : BufferResource(resourceHandle, RESOURCETYPE, attachment, layers) { } }; class Texture2D : public ResourceType @@ -43,6 +48,15 @@ public: ~RenderBuffer(); }; +class Texture2DArray : public ResourceType +{ +public: + Texture2DArray(GLuint* resourceHandle, GLenum attachment, GLuint layers) + : ResourceType(resourceHandle, attachment, layers) { }; + + ~Texture2DArray(); +}; + class FrameBuffer { public: diff --git a/include/Engine/Rendering/ShadowPass.h b/include/Engine/Rendering/ShadowPass.h index 373bc21b..192d54c7 100644 --- a/include/Engine/Rendering/ShadowPass.h +++ b/include/Engine/Rendering/ShadowPass.h @@ -39,7 +39,8 @@ public: void ClearBuffer(); void Draw(RenderScene& scene); - GLuint DepthMap(int level) const { return m_DepthMap[level]; } + //GLuint DepthMap(int level) const { return m_DepthMap[level]; } + GLuint DepthMap() const { return m_DepthMap; } std::array LightP() const { return m_LightProjection; } std::array LightV() const { return m_LightView; } std::array FarDistance() const { return { m_shadowFrusta[0].FarClip, m_shadowFrusta[1].FarClip, m_shadowFrusta[2].FarClip, m_shadowFrusta[3].FarClip }; } @@ -55,8 +56,10 @@ private: EventBroker* m_EventBroker; const IRenderer* m_Renderer; - std::array m_DepthMap; - std::array m_DepthBuffer; + //std::array m_DepthMap; + //std::array m_DepthBuffer; + GLuint m_DepthMap; + FrameBuffer m_DepthBuffer; std::array m_LightProjection; std::array m_LightView; diff --git a/resources/Shaders/ExplosionEffect.geom.glsl b/resources/Shaders/ExplosionEffect.geom.glsl index b4a90e3b..ffc78900 100644 --- a/resources/Shaders/ExplosionEffect.geom.glsl +++ b/resources/Shaders/ExplosionEffect.geom.glsl @@ -1,6 +1,6 @@ #version 430 -#define MAX_SPLITS 3 +#define MAX_SPLITS 4 uniform mat4 M; uniform mat4 V; diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index f4fd0dd1..7f80826a 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -1,6 +1,6 @@ #version 430 -#define MAX_SPLITS 3 +#define MAX_SPLITS 4 uniform mat4 M; uniform mat4 V; @@ -17,9 +17,8 @@ layout (binding = 0) uniform sampler2D DiffuseTexture; layout (binding = 1) uniform sampler2D NormalMapTexture; layout (binding = 2) uniform sampler2D SpecularMapTexture; layout (binding = 3) uniform sampler2D GlowMapTexture; -layout (binding = 4) uniform sampler2DShadow DepthMap0; -layout (binding = 5) uniform sampler2DShadow DepthMap1; -layout (binding = 6) uniform sampler2DShadow DepthMap2; +layout (binding = 4) uniform sampler2DShadow DepthMap[MAX_SPLITS]; + #define TILE_SIZE 16 @@ -209,36 +208,8 @@ int getShadowIndex(float far_distance[MAX_SPLITS]) return index; } -//sampler2DShadow whichDepthMap(int DepthMapIndex) -//{ -// if( DepthMapIndex == 0 ) -// { -// return DepthMap0; -// } -// else if( DepthMapIndex == 1 ) -// { -// return DepthMap1; -// } -// else -// { -// return DepthMap2; -// } -//} - void main() { - //sampler2DShadow DepthMaps[3] = { sampler2DShadow(DepthMap0), sampler2DShadow(DepthMap1), sampler2DShadow(DepthMap2) }; - //sampler2DShadow DepthMaps[3] = { DepthMap0, DepthMap1, DepthMap2 }; - //sampler2DShadow DepthMaps[3] = sampler2DShadow[]( DepthMap0, DepthMap1, DepthMap2 ); - //sampler2DShadow DepthMaps[3] = sampler2DShadow[3]( DepthMap0, DepthMap1, DepthMap2 ); - //sampler2DShadow DepthMaps[3]; - - //sampler2DShadow DepthMapOne = DepthMap0; - - //DepthMaps[0] = DepthMap0; - //DepthMaps[1] = DepthMap1; - //DepthMaps[2] = DepthMap2; - vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate); vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate); vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate); @@ -271,24 +242,22 @@ void main() if(light.Type == 1) { // point light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, position, normal, light.Falloff); } else if (light.Type == 2) { //Directional - int DepthMapIndex = getShadowIndex(FarDistance); - //sampler2DShadow WhichDepthMap = whichDepthMap(DepthMapIndex); + //int DepthMapIndex = getShadowIndex(FarDistance); light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal); - //shadowFactor = CalcShadowValue(Input.PositionLightSpace[0], Input.Normal, vec3(light.Direction), DepthMap0); - if( DepthMapIndex == 0 ) - { - shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap0); - } - else if( DepthMapIndex == 1 ) - { - shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap1); - } - else - { - shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap2); - } + //if( DepthMapIndex == 0 ) + //{ + shadowFactor = CalcShadowValue(Input.PositionLightSpace[0], Input.Normal, vec3(light.Direction), DepthMap[0]); + //} + //else if( DepthMapIndex == 1 ) + //{ + // shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap1); + //} + //else + //{ + // shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap2); + //} } totalLighting.Diffuse += light_result.Diffuse; diff --git a/resources/Shaders/ForwardPlus.vert.glsl b/resources/Shaders/ForwardPlus.vert.glsl index fb280e3a..0d9661cc 100644 --- a/resources/Shaders/ForwardPlus.vert.glsl +++ b/resources/Shaders/ForwardPlus.vert.glsl @@ -1,6 +1,6 @@ #version 430 -#define MAX_SPLITS 3 +#define MAX_SPLITS 4 uniform mat4 M; uniform mat4 V; diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 537bc3dc..72bd8711 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -320,15 +320,15 @@ void DrawFinalPass::BindModelTextures(std::shared_ptr& job) glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture); } - for (int i = 0; i < m_ShadowPass->CurrentNrOfSplits(); i++) - { - glActiveTexture(GL_TEXTURE4 + i); - if (m_ShadowPass->DepthMap(i) != NULL) { - glBindTexture(GL_TEXTURE_2D, m_ShadowPass->DepthMap(i)); + //for (int i = 0; i < m_ShadowPass->CurrentNrOfSplits(); i++) + //{ + glActiveTexture(GL_TEXTURE4); + if (m_ShadowPass->DepthMap() != NULL) { + glBindTexture(GL_TEXTURE_2D_ARRAY, m_ShadowPass->DepthMap()); } else { - glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); + glBindTexture(GL_TEXTURE_2D_ARRAY, m_WhiteTexture->m_Texture); } - } + //} } diff --git a/src/Engine/Rendering/FrameBuffer.cpp b/src/Engine/Rendering/FrameBuffer.cpp index 44ffb20e..b5dad961 100644 --- a/src/Engine/Rendering/FrameBuffer.cpp +++ b/src/Engine/Rendering/FrameBuffer.cpp @@ -9,6 +9,14 @@ BufferResource::BufferResource(GLuint* resourceHandle, GLenum resourceType, GLen m_Attachment = attachment; } +BufferResource::BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment, GLuint layers) +{ + m_ResourceHandle = resourceHandle; + m_ResourceType = resourceType; + m_Attachment = attachment; + m_Layers = layers; +} + Texture2D::~Texture2D() { if (m_ResourceHandle != 0) { @@ -16,6 +24,12 @@ Texture2D::~Texture2D() } } +Texture2DArray::~Texture2DArray() +{ + if (m_ResourceHandle != 0) { + glDeleteTextures(1, m_ResourceHandle); + } +} RenderBuffer::~RenderBuffer() { @@ -48,18 +62,22 @@ void FrameBuffer::Generate() switch ((*it)->m_ResourceType) { case GL_TEXTURE_2D: glFramebufferTexture2D(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle, 0); + attachments.push_back((*it)->m_Attachment); GLERROR("FrameBuffer generate: glFramebufferTexture2D"); break; case GL_RENDERBUFFER: glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle); GLERROR("FrameBuffer generate: glFramebufferRenderbuffer"); break; + case GL_TEXTURE_2D_ARRAY: + glFramebufferTexture(GL_FRAMEBUFFER, (*it)->m_Attachment, *(*it)->m_ResourceHandle, 0); + attachments.push_back((*it)->m_Attachment); + GLERROR("FrameBuffer generate: GL_TEXTURE_2D_ARRAY"); + + break; } - if ((*it)->m_ResourceType == GL_TEXTURE_2D) { - attachments.push_back((*it)->m_Attachment); - } } GLenum* bufferTextures = &attachments[0]; diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index 5aa411fc..1341ac15 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -136,9 +136,9 @@ void Renderer::Draw(RenderFrame& frame) if (m_DebugTextureToDraw == 4) { m_DrawScreenQuadPass->Draw(m_PickingPass->PickingTexture()); } - if (m_DebugTextureToDraw == 5) { - m_DrawScreenQuadPass->Draw(m_ShadowPass->DepthMap(0)); - } + //if (m_DebugTextureToDraw == 5) { + // m_DrawScreenQuadPass->Draw(m_ShadowPass->DepthMap()); + //} m_ImGuiRenderPass->Draw(); glfwSwapBuffers(m_Window); diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index c3eb8c73..c734f695 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -106,26 +106,37 @@ float ShadowPass::FindRadius(Frustum& frustum) void ShadowPass::InitializeFrameBuffers() { - // Depth texture - glGenTextures(m_CurrentNrOfSplits, m_DepthMap.data()); + GLERROR("depthMap failed PRE"); + // Depth texture + glGenTextures(1, &m_DepthMap); - for (int i = 0; i < m_CurrentNrOfSplits; i++) { - glBindTexture(GL_TEXTURE_2D, m_DepthMap[i]); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, m_ResolutionSizeWidth / (1 /*+ i*/), m_ResolutionSizeHeigth + (1 /*+ i*/), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); - glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, glm::vec4(1.f).data); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); - //glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY); + GLERROR("depthMap failed1"); + glBindTexture(GL_TEXTURE_2D_ARRAY, m_DepthMap); + GLERROR("depthMap failed2"); + glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_DEPTH_COMPONENT16, m_ResolutionSizeWidth, m_ResolutionSizeHeigth, m_CurrentNrOfSplits); + GLERROR("depthMap failed3"); - m_DepthBuffer[i].AddResource(std::shared_ptr(new Texture2D(&m_DepthMap[i], GL_DEPTH_ATTACHMENT))); - m_DepthBuffer[i].Generate(); - } + glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, m_ResolutionSizeWidth, m_ResolutionSizeHeigth, m_CurrentNrOfSplits, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr); + GLERROR("depthMap failed4"); - GLERROR("depthMap failed"); + //for (int i = 0; i < m_CurrentNrOfSplits; i++) { + // glBindTexture(GL_TEXTURE_2D, m_DepthMap[i]); + // glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, m_ResolutionSizeWidth / (1 /*+ i*/), m_ResolutionSizeHeigth + (1 /*+ i*/), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr); + glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); + glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); + glTexParameterfv(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_BORDER_COLOR, glm::vec4(1.f).data); + glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); + //glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY); + GLERROR("depthMap failed5"); + + m_DepthBuffer.AddResource(std::shared_ptr(new Texture2DArray(&m_DepthMap, GL_DEPTH_ATTACHMENT, m_CurrentNrOfSplits))); + m_DepthBuffer.Generate(); + //} + + GLERROR("depthMap failed END"); } void ShadowPass::InitializeShaderPrograms() @@ -141,10 +152,10 @@ void ShadowPass::InitializeShaderPrograms() void ShadowPass::ClearBuffer() { for (int i = 0; i < m_CurrentNrOfSplits; i++) { - m_DepthBuffer[i].Bind(); + m_DepthBuffer.Bind(); glClearColor(0.f, 0.f, 0.f, 0.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - m_DepthBuffer[i].Unbind(); + m_DepthBuffer.Unbind(); } } @@ -192,7 +203,7 @@ void ShadowPass::Draw(RenderScene & scene) UpdateFrustumPoints(m_shadowFrusta[i], scene.Camera->Position(), scene.Camera->Forward(), scene.Camera->ProjectionMatrix(), scene.Camera->ViewMatrix()); //float test = FindRadius(m_shadFrusta[i]); - ShadowPassState* state = new ShadowPassState(m_DepthBuffer[i].GetHandle()); + ShadowPassState* state = new ShadowPassState(m_DepthBuffer.GetHandle()); GLuint shaderHandle = m_ShadowProgram->GetHandle(); m_ShadowProgram->Bind(); @@ -230,7 +241,7 @@ void ShadowPass::Draw(RenderScene & scene) GLERROR("Shadow Draw ERROR"); } } - m_DepthBuffer[i].Unbind(); + m_DepthBuffer.Unbind(); delete state; } From b320d8d1e4717c9cb4dd5b922a4f36ca3f63252e Mon Sep 17 00:00:00 2001 From: Teejoon Date: Fri, 26 Feb 2016 18:01:38 +0100 Subject: [PATCH 074/252] WIP --- include/Engine/Rendering/DrawBloomPass.h | 17 +++++-- include/Engine/Rendering/Renderer.h | 1 + include/Engine/Rendering/SSAOPass.h | 2 +- src/Engine/Rendering/DrawBloomPass.cpp | 55 ++++++++++++++++----- src/Engine/Rendering/DrawFinalPass.cpp | 4 +- src/Engine/Rendering/DrawFinalPassState.cpp | 1 + src/Engine/Rendering/Renderer.cpp | 8 ++- src/Engine/Rendering/SSAOPass.cpp | 20 +++----- src/Engine/Rendering/Util/ScreenCoords.cpp | 9 +++- 9 files changed, 84 insertions(+), 33 deletions(-) diff --git a/include/Engine/Rendering/DrawBloomPass.h b/include/Engine/Rendering/DrawBloomPass.h index 07c90e23..2fffbdc7 100644 --- a/include/Engine/Rendering/DrawBloomPass.h +++ b/include/Engine/Rendering/DrawBloomPass.h @@ -12,7 +12,7 @@ class DrawBloomPass { public: - DrawBloomPass(IRenderer* renderer /* ,Texture or finalpass*/ ); + DrawBloomPass(IRenderer* renderer, ConfigFile* config); ~DrawBloomPass() { } void InitializeTextures(); void InitializeFrameBuffers(); @@ -23,23 +23,32 @@ public: void FillGaussianBuffer(FrameBuffer* fb); void Draw(GLuint texture); + void ChangeQuality(int quality); void OnWindowResize(); //Getters //Return the blurred result of the texture that was sent into draw - GLuint GaussianTexture() const { return m_GaussianTexture_vert; } + GLuint GaussianTexture() const { + if (m_Quality == 0) { + return m_BlackTexture->m_Texture; + } else { + return m_GaussianTexture_vert; + } + } private: void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const; - Texture* m_WhiteTexture; + Texture* m_BlackTexture; Model* m_ScreenQuad; const IRenderer* m_Renderer; + ConfigFile* m_Config; //const LightCullingPass* m_LightCullingPass - GLuint m_iterations = 9; + int m_Iterations; + int m_Quality = 0; GLuint m_GaussianTexture_horiz; GLuint m_GaussianTexture_vert; diff --git a/include/Engine/Rendering/Renderer.h b/include/Engine/Rendering/Renderer.h index 4ed57e31..a64a4aa3 100644 --- a/include/Engine/Rendering/Renderer.h +++ b/include/Engine/Rendering/Renderer.h @@ -64,6 +64,7 @@ private: int m_CubeMapTexture = 0; bool m_ResizeWindow = false; int m_SSAO_Quality = 0; + int m_GLOW_Quality = 2; PickingPass* m_PickingPass; LightCullingPass* m_LightCullingPass; diff --git a/include/Engine/Rendering/SSAOPass.h b/include/Engine/Rendering/SSAOPass.h index a2cf349d..ce3f85ed 100644 --- a/include/Engine/Rendering/SSAOPass.h +++ b/include/Engine/Rendering/SSAOPass.h @@ -64,7 +64,7 @@ private: int m_NumOfTurns; int m_Iterations; int m_TextureQuality; - int m_Quality; + int m_Quality = 0; Texture* m_WhiteTexture; diff --git a/src/Engine/Rendering/DrawBloomPass.cpp b/src/Engine/Rendering/DrawBloomPass.cpp index e8ad4cd5..fe93c167 100644 --- a/src/Engine/Rendering/DrawBloomPass.cpp +++ b/src/Engine/Rendering/DrawBloomPass.cpp @@ -1,19 +1,39 @@ #include "Rendering/DrawBloomPass.h" -DrawBloomPass::DrawBloomPass(IRenderer* renderer) +DrawBloomPass::DrawBloomPass(IRenderer* renderer, ConfigFile* config) + : m_Renderer(renderer) + , m_Config(config) { - m_Renderer = renderer; + InitializeTextures(); - m_ScreenQuad = ResourceManager::Load("Models/Core/ScreenQuad.mesh"); + ChangeQuality(m_Config->Get("GLOW.Quality", 2)); +} - InitializeTextures(); - InitializeBuffers(); - InitializeShaderPrograms(); +void DrawBloomPass::ChangeQuality(int quality) +{ + if (m_Quality == quality) { + return; + } + m_Quality = quality; + + m_ScreenQuad = ResourceManager::Load("Models/Core/ScreenQuad.mesh"); + + if (m_Quality == 0) { + glDeleteTextures(1, &m_GaussianTexture_horiz); + glDeleteTextures(1, &m_GaussianTexture_vert); + return; + } + + std::string qStr = std::to_string(m_Quality); + m_Iterations = m_Config->Get("GLOW" + qStr + ".NumIterations", 0); + + InitializeBuffers(); + InitializeShaderPrograms(); } void DrawBloomPass::InitializeTextures() { - m_WhiteTexture = CommonFunctions::LoadTexture("Textures/Core/White.png", false); + m_BlackTexture = CommonFunctions::LoadTexture("Textures/Core/Black.png", false); } void DrawBloomPass::InitializeShaderPrograms() @@ -40,18 +60,24 @@ void DrawBloomPass::InitializeBuffers() { GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); - m_GaussianFrameBuffer_horiz.AddResource(std::shared_ptr(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0))); + if (m_GaussianFrameBuffer_horiz.GetHandle() == 0) { + m_GaussianFrameBuffer_horiz.AddResource(std::shared_ptr(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0))); + } m_GaussianFrameBuffer_horiz.Generate(); GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); - - m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0))); + if (m_GaussianFrameBuffer_vert.GetHandle() == 0) { + m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0))); + } m_GaussianFrameBuffer_vert.Generate(); } void DrawBloomPass::ClearBuffer() { + if (m_Quality == 0) { + return; + } GLERROR("PRE"); m_GaussianFrameBuffer_horiz.Bind(); glClearColor(0.f, 0.f, 0.f, 0.f); @@ -66,6 +92,9 @@ void DrawBloomPass::ClearBuffer() void DrawBloomPass::Draw(GLuint texture) { + if (m_Quality == 0) { + return; + } GLERROR("DrawBloomPass::Draw: Pre"); DrawBloomPassState state; @@ -84,7 +113,7 @@ void DrawBloomPass::Draw(GLuint texture) glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1 , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex); //Iterate some times to make it more gaussian. - for (int i = 1; i < m_iterations; i++) { + for (int i = 1; i < m_Iterations; i++) { //Vertical pass m_GaussianFrameBuffer_vert.Bind(); m_GaussianProgram_vert->Bind(); @@ -125,6 +154,9 @@ void DrawBloomPass::Draw(GLuint texture) void DrawBloomPass::OnWindowResize() { + if (m_Quality == 0) { + return; + } GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); m_GaussianFrameBuffer_vert.Generate(); GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); @@ -133,6 +165,7 @@ void DrawBloomPass::OnWindowResize() void DrawBloomPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const { + glDeleteTextures(1, texture); glGenTextures(1, texture); glBindTexture(GL_TEXTURE_2D, *texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping); diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 48c07941..7b373452 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -162,14 +162,14 @@ void DrawFinalPass::InitializeShaderPrograms() m_FillDepthBufferProgram = ResourceManager::Load("#FillDepthBufferProgram"); m_FillDepthBufferProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/FillDepthBuffer.vert.glsl"))); - m_FillDepthBufferProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/FillDepthBuffer.frag.glsl"))); + //m_FillDepthBufferProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/FillDepthBuffer.frag.glsl"))); m_FillDepthBufferProgram->Compile(); m_FillDepthBufferProgram->Link(); GLERROR("Creating DepthFill program"); m_FillDepthBufferSkinnedProgram = ResourceManager::Load("#FillDepthBufferProgramSkinned"); m_FillDepthBufferSkinnedProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/FillDepthBufferSkinned.vert.glsl"))); - m_FillDepthBufferSkinnedProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/FillDepthBuffer.frag.glsl"))); + //m_FillDepthBufferSkinnedProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/FillDepthBuffer.frag.glsl"))); m_FillDepthBufferSkinnedProgram->Compile(); m_FillDepthBufferSkinnedProgram->Link(); GLERROR("Creating DepthFill program"); diff --git a/src/Engine/Rendering/DrawFinalPassState.cpp b/src/Engine/Rendering/DrawFinalPassState.cpp index 8b5ddc8b..9741a0ce 100644 --- a/src/Engine/Rendering/DrawFinalPassState.cpp +++ b/src/Engine/Rendering/DrawFinalPassState.cpp @@ -8,6 +8,7 @@ DrawFinalPassState::DrawFinalPassState(GLuint frameBuffer) Enable(GL_BLEND); BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); Enable(GL_DEPTH_TEST); + glDepthFunc(GL_LEQUAL); Enable(GL_CULL_FACE); Enable(GL_STENCIL_TEST); StencilFunc(GL_NOTEQUAL, 1, 0xFF); diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index 4c7cd39f..85c9b97e 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -4,6 +4,8 @@ std::unordered_map Renderer::m_WindowToRenderer; void Renderer::Initialize() { + m_SSAO_Quality = m_Config->Get("SSAO.Quality", 0); + m_GLOW_Quality = m_Config->Get("GLOW.Quality", 0); InitializeWindow(); InitializeRenderPasses(); @@ -107,6 +109,7 @@ void Renderer::Update(double dt) void Renderer::Draw(RenderFrame& frame) { GLERROR("PRE"); + glBindFramebuffer(GL_FRAMEBUFFER, 0); ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking\0Ambient Occlusion"); ImGui::Combo("CubeMap", &m_CubeMapTexture, "Nevada(512)\0Sky(1024)"); if(m_CubeMapTexture == 0) { @@ -115,7 +118,10 @@ void Renderer::Draw(RenderFrame& frame) m_CubeMapPass->LoadTextures("Sky"); } + ImGui::SliderInt("SSAO Quality", &m_SSAO_Quality, 0, 3); + ImGui::SliderInt("Glow Quality", &m_GLOW_Quality, 0, 3); m_SSAOPass->ChangeQuality(m_SSAO_Quality); + m_DrawBloomPass->ChangeQuality(m_GLOW_Quality); GLERROR("SSAO Settings"); //clear buffer 0 glClearColor(0.f, 0.f, 0.f, 0.f); @@ -245,7 +251,7 @@ void Renderer::InitializeRenderPasses() m_SSAOPass = new SSAOPass(this, m_Config); m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass, m_SSAOPass); m_DrawScreenQuadPass = new DrawScreenQuadPass(this); - m_DrawBloomPass = new DrawBloomPass(this); + m_DrawBloomPass = new DrawBloomPass(this, m_Config); m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this); } diff --git a/src/Engine/Rendering/SSAOPass.cpp b/src/Engine/Rendering/SSAOPass.cpp index 7d39e34a..495fcfc9 100644 --- a/src/Engine/Rendering/SSAOPass.cpp +++ b/src/Engine/Rendering/SSAOPass.cpp @@ -6,12 +6,7 @@ SSAOPass::SSAOPass(IRenderer* renderer, ConfigFile* config) { m_WhiteTexture = CommonFunctions::LoadTexture("Textures/Core/White.png", false); - m_Quality = m_Config->Get("SSAO.Quality", 0); - if (m_Quality == 0) { - return; - } - - ChangeQuality(m_Quality); + ChangeQuality(m_Config->Get("SSAO.Quality", 0)); } @@ -102,33 +97,34 @@ void SSAOPass::InitializeBuffer() if (m_SSAOFramBuffer.GetHandle() == 0) { m_SSAOFramBuffer.AddResource(std::shared_ptr(new Texture2D(&m_SSAOTexture, GL_COLOR_ATTACHMENT0))); } - m_SSAOFramBuffer.Generate(); + m_SSAOFramBuffer.Generate(); if (m_SSAOViewSpaceZFramBuffer.GetHandle() == 0) { m_SSAOViewSpaceZFramBuffer.AddResource(std::shared_ptr(new Texture2D(&m_SSAOViewSpaceZTexture, GL_COLOR_ATTACHMENT0))); } - m_SSAOViewSpaceZFramBuffer.Generate(); + m_SSAOViewSpaceZFramBuffer.Generate(); if (m_GaussianFrameBuffer_horiz.GetHandle() == 0) { m_GaussianFrameBuffer_horiz.AddResource(std::shared_ptr(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0))); } - m_GaussianFrameBuffer_horiz.Generate(); + m_GaussianFrameBuffer_horiz.Generate(); if (m_GaussianFrameBuffer_vert.GetHandle() == 0) { m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0))); } - m_GaussianFrameBuffer_vert.Generate(); + m_GaussianFrameBuffer_vert.Generate(); } void SSAOPass::ClearBuffer() { - return; - + if (m_Quality == 0) { + return; + } m_SSAOFramBuffer.Bind(); glClearColor(1.f, 1.f, 1.f, 1.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); diff --git a/src/Engine/Rendering/Util/ScreenCoords.cpp b/src/Engine/Rendering/Util/ScreenCoords.cpp index 36f1295e..8b7768c8 100644 --- a/src/Engine/Rendering/Util/ScreenCoords.cpp +++ b/src/Engine/Rendering/Util/ScreenCoords.cpp @@ -31,22 +31,27 @@ glm::vec3 ScreenCoords::ToWorldPos(glm::vec2 screenCoord, float depth, float scr ScreenCoords::PixelData ScreenCoords::ToPixelData(float x, float y, FrameBuffer* PickDataBuffer, GLuint DepthBuffer) { + GLERROR("Pre"); PickDataBuffer->Bind(); unsigned char pdata[3]; glReadPixels(x, y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pdata); + GLERROR("glReadPixels(pdata) Error"); PickDataBuffer->Unbind(); - glBindFramebuffer(GL_FRAMEBUFFER, DepthBuffer); + glBindFramebuffer(GL_FRAMEBUFFER, DepthBuffer); + GLERROR("glBindFramebuffer(DepthBuffer) Error"); float depthData; glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depthData); + GLERROR("glReadPixels(depthData) Error"); glBindFramebuffer(GL_FRAMEBUFFER, 0); + GLERROR("glBindFramebuffer(0) Error"); PixelData p; p.Color[0] = (int)pdata[0]; p.Color[1] = (int)pdata[1]; p.Depth = depthData; - GLERROR("ScreenCoords::ToPixelData Error"); + GLERROR("End"); return p; } From 38d8cdded221dd9a82535ea99024b142ed8b9be0 Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Sat, 27 Feb 2016 15:53:28 +0100 Subject: [PATCH 075/252] Texture Array is now working. Enjoy your single Bind(). --- include/Engine/Rendering/ShadowPass.h | 4 +- resources/Shaders/ForwardPlus.frag.glsl | 74 +++++++++++++--------- src/Engine/Rendering/FrameBuffer.cpp | 1 - src/Engine/Rendering/Renderer.cpp | 6 +- src/Engine/Rendering/ShadowPass.cpp | 78 +++++++++++------------- src/Engine/Rendering/ShadowPassState.cpp | 4 ++ 6 files changed, 91 insertions(+), 76 deletions(-) diff --git a/include/Engine/Rendering/ShadowPass.h b/include/Engine/Rendering/ShadowPass.h index 192d54c7..6fab8a3a 100644 --- a/include/Engine/Rendering/ShadowPass.h +++ b/include/Engine/Rendering/ShadowPass.h @@ -68,7 +68,7 @@ private: GLuint m_DepthFBO; GLfloat m_NearFarPlane[2] = { -34.f, 27.f }; - GLfloat m_LRBT[4] = { -10.f, 10.f, -10.f, 10.f }; + //GLfloat m_LRBT[4] = { -10.f, 10.f, -10.f, 10.f }; GLuint m_ResolutionSizeWidth = 1024 * 2; GLuint m_ResolutionSizeHeigth = 1024 * 2; @@ -77,7 +77,7 @@ private: int m_ShadowLevel = 0; int m_CurrentNrOfSplits = 3; - float m_SplitWeight = 0.75f; + float m_SplitWeight = 0.7f; std::array m_shadowFrusta; }; diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 7f80826a..7659f3b0 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -17,7 +17,7 @@ layout (binding = 0) uniform sampler2D DiffuseTexture; layout (binding = 1) uniform sampler2D NormalMapTexture; layout (binding = 2) uniform sampler2D SpecularMapTexture; layout (binding = 3) uniform sampler2D GlowMapTexture; -layout (binding = 4) uniform sampler2DShadow DepthMap[MAX_SPLITS]; +layout (binding = 4) uniform sampler2DArrayShadow DepthMap; #define TILE_SIZE 16 @@ -138,32 +138,59 @@ vec2 poissonDisk[16] = vec2[]( vec2( 0.14383161, -0.14100790 ) ); -float random(vec3 seed, int i) +float Random(vec3 seed, int i) { vec4 seed4 = vec4(seed, i); float dot_product = dot(seed4, vec4(12.9898, 78.233, 45.164, 94.673)); return fract(sin(dot_product) * 43758.5453); } -float CalcShadowValue(vec4 positionLightSpace, vec3 normal, vec3 lightDir, sampler2DShadow depthTexture) +// Standard hardware-calculated PCF method +float PCFShadow(sampler2DArrayShadow depth_texture_array, vec3 projection_coords, int layer_index) +{ + return texture(depth_texture_array, vec4(projection_coords.xy, layer_index, projection_coords.z)); +} + +float CalcShadowValue(vec4 light_space_pos, vec3 normal, vec3 light_dir, sampler2DArrayShadow depth_texture_array, int layer_index) { - - //float bias = 0.005; - //float bias = max(0.05 * (1.0 - dot(normal, lightDir)), 0.005); - float bias = 0.005 * tan(acos(clamp(dot(normal, -lightDir), 0.0, 1.0))); - - vec3 projCoords = vec3(positionLightSpace.xy, positionLightSpace.z + bias) / positionLightSpace.w; - projCoords = projCoords * 0.5 + 0.5; - //float shadowMapDepth = texture(depthTexture, projCoords.xy).r; float shadowMapDepth; + float bias; + + // Various bias methods. + + //bias = 0.005; + //bias = max(0.05 * (1.0 - dot(normal, light_dir)), 0.005); + bias = 0.005 * tan(acos(clamp(dot(normal, -light_dir), 0.0, 1.0))); + + // Calculate coordinates in projection space + vec3 projCoords = vec3(light_space_pos.xy, light_space_pos.z + bias) / light_space_pos.w; + projCoords = projCoords * 0.5 + 0.5; + + // Various methods for shadow calculation in fastest to slowest order. + + shadowMapDepth = PCFShadow(depth_texture_array, projCoords, layer_index); + + // PCF + Four-tap Poisson model method + //float SplitWeight = 0.7; //for (int i = 0; i < 4; i++) //{ - // int index = i; - // //int index = int(16.0 * random(gl_FragCoord.xyy, i)) % 16; - // shadowMapDepth += 0.25 * texture(depthTexture, projCoords + vec3(poissonDisk[index], 0.0) / 700.0); + // int loop = i; + // vec3 newProjCoords = projCoords + vec3(poissonDisk[loop], 0.0) / (1500.0 * SplitWeight * (1.0 + layer_index)); + // shadowMapDepth += 0.25 * texture(depthTexture, vec4(newProjCoords.xy, layer_index, newProjCoords.z)); //} - - shadowMapDepth = texture(depthTexture, projCoords); + // + //// PCF + Four-tap Poisson model method + //float SplitWeight = 0.7; + //for (int i = 0; i < 4; i++) + //{ + // int loop = i; + // vec3 newProjCoords = projCoords + vec3(poissonDisk[loop], 0.0) / (1500.0 * SplitWeight * (1.0 + layer_index)); + // //int loop = int(16.0 * Random(gl_FragCoord.xyy, i)) % 16; + // shadowMapDepth += 0.25 * texture(depthTexture, vec4(newProjCoords.xy, layer_index, newProjCoords.z)); + //} + + + //float geometryDepth = projCoords.z; //float shadow = geometryDepth - bias > shadowMapDepth ? 1.0 : 0.0; @@ -242,22 +269,11 @@ void main() if(light.Type == 1) { // point light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, position, normal, light.Falloff); } else if (light.Type == 2) { //Directional - //int DepthMapIndex = getShadowIndex(FarDistance); + int DepthMapIndex = getShadowIndex(FarDistance); light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal); - //if( DepthMapIndex == 0 ) - //{ - shadowFactor = CalcShadowValue(Input.PositionLightSpace[0], Input.Normal, vec3(light.Direction), DepthMap[0]); - //} - //else if( DepthMapIndex == 1 ) - //{ - // shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap1); - //} - //else - //{ - // shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap2); - //} + shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap, DepthMapIndex); } totalLighting.Diffuse += light_result.Diffuse; diff --git a/src/Engine/Rendering/FrameBuffer.cpp b/src/Engine/Rendering/FrameBuffer.cpp index b5dad961..cc563600 100644 --- a/src/Engine/Rendering/FrameBuffer.cpp +++ b/src/Engine/Rendering/FrameBuffer.cpp @@ -73,7 +73,6 @@ void FrameBuffer::Generate() glFramebufferTexture(GL_FRAMEBUFFER, (*it)->m_Attachment, *(*it)->m_ResourceHandle, 0); attachments.push_back((*it)->m_Attachment); GLERROR("FrameBuffer generate: GL_TEXTURE_2D_ARRAY"); - break; } diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index 1341ac15..a26a7f09 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -136,9 +136,9 @@ void Renderer::Draw(RenderFrame& frame) if (m_DebugTextureToDraw == 4) { m_DrawScreenQuadPass->Draw(m_PickingPass->PickingTexture()); } - //if (m_DebugTextureToDraw == 5) { - // m_DrawScreenQuadPass->Draw(m_ShadowPass->DepthMap()); - //} + if (m_DebugTextureToDraw == 5) { + m_DrawScreenQuadPass->Draw(m_ShadowPass->DepthMap()); + } m_ImGuiRenderPass->Draw(); glfwSwapBuffers(m_Window); diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index c734f695..dd423f25 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -119,9 +119,6 @@ void ShadowPass::InitializeFrameBuffers() glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, m_ResolutionSizeWidth, m_ResolutionSizeHeigth, m_CurrentNrOfSplits, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr); GLERROR("depthMap failed4"); - //for (int i = 0; i < m_CurrentNrOfSplits; i++) { - // glBindTexture(GL_TEXTURE_2D, m_DepthMap[i]); - // glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, m_ResolutionSizeWidth / (1 /*+ i*/), m_ResolutionSizeHeigth + (1 /*+ i*/), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); @@ -129,7 +126,6 @@ void ShadowPass::InitializeFrameBuffers() glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); glTexParameterfv(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_BORDER_COLOR, glm::vec4(1.f).data); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); - //glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY); GLERROR("depthMap failed5"); m_DepthBuffer.AddResource(std::shared_ptr(new Texture2DArray(&m_DepthMap, GL_DEPTH_ATTACHMENT, m_CurrentNrOfSplits))); @@ -151,12 +147,15 @@ void ShadowPass::InitializeShaderPrograms() void ShadowPass::ClearBuffer() { + m_DepthBuffer.Bind(); + for (int i = 0; i < m_CurrentNrOfSplits; i++) { - m_DepthBuffer.Bind(); - glClearColor(0.f, 0.f, 0.f, 0.f); + glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_DepthMap, 0, i); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - m_DepthBuffer.Unbind(); } + + m_DepthBuffer.Unbind(); } void ShadowPass::PointsToLightspace(Frustum& frustum, glm::mat4 v) @@ -191,67 +190,64 @@ void ShadowPass::RadiusToLightspace(Frustum& frustum, glm::mat4 v) void ShadowPass::Draw(RenderScene & scene) { - ImGui::DragFloat4("ShadowMapCam", m_LRBT, 1.f, -1000.f, 1000.f); +// ImGui::DragFloat4("ShadowMapCam", m_LRBT, 1.f, -1000.f, 1000.f); ImGui::DragFloat2("ShadowMapNearFar", m_NearFarPlane, 1.f, -1000.f, 1000.f); ImGui::Checkbox("EnableShadow", &m_ShadowOn); - ImGui::DragInt("ShadowLevel", &m_ShadowLevel, 0.05f, 0, m_CurrentNrOfSplits - 1); + //ImGui::DragInt("ShadowLevel", &m_ShadowLevel, 0.05f, 0, m_CurrentNrOfSplits - 1); InitializeCameras(scene); UpdateSplitDist(m_shadowFrusta, scene.Camera->NearClip(), scene.Camera->FarClip()); + ShadowPassState* state = new ShadowPassState(m_DepthBuffer.GetHandle()); + + m_ShadowProgram->Bind(); + for (int i = 0; i < m_CurrentNrOfSplits; i++) { UpdateFrustumPoints(m_shadowFrusta[i], scene.Camera->Position(), scene.Camera->Forward(), scene.Camera->ProjectionMatrix(), scene.Camera->ViewMatrix()); //float test = FindRadius(m_shadFrusta[i]); - ShadowPassState* state = new ShadowPassState(m_DepthBuffer.GetHandle()); - GLuint shaderHandle = m_ShadowProgram->GetHandle(); - m_ShadowProgram->Bind(); + + glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_DepthMap, 0, i); - glViewport(0, 0, m_ResolutionSizeWidth / (1/* + i*/), m_ResolutionSizeHeigth); - glDisable(GL_TEXTURE_2D); - glCullFace(GL_FRONT); + glViewport(0, 0, m_ResolutionSizeWidth, m_ResolutionSizeHeigth); + //state->Disable(GL_CULL_FACE); - if (m_ShadowOn == true) - { - for (auto &job : scene.DirectionalLightJobs) { - auto directionalLightJob = std::dynamic_pointer_cast(job); + for (auto &job : scene.DirectionalLightJobs) { + auto directionalLightJob = std::dynamic_pointer_cast(job); - if (directionalLightJob) { - m_LightView[i] = glm::lookAt(glm::vec3(-directionalLightJob->Direction) + m_shadowFrusta[i].MiddlePoint, m_shadowFrusta[i].MiddlePoint, glm::vec3(0.f, 1.f, 0.f)); - - PointsToLightspace(m_shadowFrusta[i], m_LightView[i]); - m_LightProjection[i] = glm::ortho(m_shadowFrusta[i].LRBT[Left], m_shadowFrusta[i].LRBT[Right], m_shadowFrusta[i].LRBT[Bottom], m_shadowFrusta[i].LRBT[Top], -30.f, 30.f); + if (directionalLightJob) { + m_LightView[i] = glm::lookAt(glm::vec3(-directionalLightJob->Direction) + m_shadowFrusta[i].MiddlePoint, m_shadowFrusta[i].MiddlePoint, glm::vec3(0.f, 1.f, 0.f)); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection[i])); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView[i])); + PointsToLightspace(m_shadowFrusta[i], m_LightView[i]); + m_LightProjection[i] = glm::ortho(m_shadowFrusta[i].LRBT[Left], m_shadowFrusta[i].LRBT[Right], m_shadowFrusta[i].LRBT[Bottom], m_shadowFrusta[i].LRBT[Top], m_NearFarPlane[Near], m_NearFarPlane[Far]); - GLERROR("ShadowLight ERROR"); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection[i])); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView[i])); - for (auto &objectJob : scene.OpaqueObjects) { - auto modelJob = std::dynamic_pointer_cast(objectJob); - - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); + GLERROR("ShadowLight ERROR"); - 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))); + for (auto &objectJob : scene.OpaqueObjects) { + auto modelJob = std::dynamic_pointer_cast(objectJob); - GLERROR("Shadow Draw ERROR"); - } + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); + + 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("Shadow Draw ERROR"); } - m_DepthBuffer.Unbind(); - - delete state; } + } glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); - glEnable(GL_TEXTURE_2D); - glCullFace(GL_BACK); m_ShadowProgram->Unbind(); } + m_DepthBuffer.Unbind(); + delete state; } diff --git a/src/Engine/Rendering/ShadowPassState.cpp b/src/Engine/Rendering/ShadowPassState.cpp index caa09b9f..f84b6436 100644 --- a/src/Engine/Rendering/ShadowPassState.cpp +++ b/src/Engine/Rendering/ShadowPassState.cpp @@ -8,6 +8,10 @@ ShadowPassState::ShadowPassState(GLuint frameBuffer) Enable(GL_DEPTH_TEST); Enable(GL_CULL_FACE); Disable(GL_BLEND); + Disable(GL_TEXTURE_2D); + CullFace(GL_FRONT); + ClearColor(glm::vec4(255.f, 128.f, 128.f, 128.f)); + GLERROR("---4"); } ShadowPassState::~ShadowPassState() From ecab5de0567f1b6dffd237da40d3ea5f88b2de2c Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Sat, 27 Feb 2016 16:35:15 +0100 Subject: [PATCH 076/252] Various shadow calculation methods implemented and ready for use. --- resources/Shaders/ForwardPlus.frag.glsl | 136 +++++++++++++----------- resources/Shaders/Shadow.frag.glsl | 10 +- resources/Shaders/Shadow.vert.glsl | 5 - src/Engine/Rendering/DrawFinalPass.cpp | 16 ++- 4 files changed, 82 insertions(+), 85 deletions(-) diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 7659f3b0..b3240911 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -1,6 +1,7 @@ #version 430 #define MAX_SPLITS 4 +#define SPLIT_WEIGHT 0.7 uniform mat4 M; uniform mat4 V; @@ -73,6 +74,25 @@ struct LightResult { vec4 Specular; }; +vec2 poissonDisk[16] = vec2[]( + vec2( -0.94201624, -0.39906216 ), + vec2( 0.94558609, -0.76890725 ), + vec2( -0.094184101, -0.92938870 ), + vec2( 0.34495938, 0.29387760 ), + vec2( -0.91588581, 0.45771432 ), + vec2( -0.81544232, -0.87912464 ), + vec2( -0.38277543, 0.27676845 ), + vec2( 0.97484398, 0.75648379 ), + vec2( 0.44323325, -0.97511554 ), + vec2( 0.53742981, -0.47373420 ), + vec2( -0.26496911, -0.41893023 ), + vec2( 0.79197514, 0.19090188 ), + vec2( -0.24188840, 0.99706507 ), + vec2( -0.81409955, 0.91437590 ), + vec2( 0.19984126, 0.78641367 ), + vec2( 0.14383161, -0.14100790 ) + ); + float CalcAttenuation(float radius, float dist, float falloff) { return 1.0 - smoothstep(radius * 0.3, radius, dist); } @@ -119,25 +139,6 @@ vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textu return vec4(TBN * normalize(NormalMap), 0.0); } -vec2 poissonDisk[16] = vec2[]( - vec2( -0.94201624, -0.39906216 ), - vec2( 0.94558609, -0.76890725 ), - vec2( -0.094184101, -0.92938870 ), - vec2( 0.34495938, 0.29387760 ), - vec2( -0.91588581, 0.45771432 ), - vec2( -0.81544232, -0.87912464 ), - vec2( -0.38277543, 0.27676845 ), - vec2( 0.97484398, 0.75648379 ), - vec2( 0.44323325, -0.97511554 ), - vec2( 0.53742981, -0.47373420 ), - vec2( -0.26496911, -0.41893023 ), - vec2( 0.79197514, 0.19090188 ), - vec2( -0.24188840, 0.99706507 ), - vec2( -0.81409955, 0.91437590 ), - vec2( 0.19984126, 0.78641367 ), - vec2( 0.14383161, -0.14100790 ) -); - float Random(vec3 seed, int i) { vec4 seed4 = vec4(seed, i); @@ -151,6 +152,57 @@ float PCFShadow(sampler2DArrayShadow depth_texture_array, vec3 projection_coords return texture(depth_texture_array, vec4(projection_coords.xy, layer_index, projection_coords.z)); } +// PCF + Poisson model method +float PoissonShadow(sampler2DArrayShadow depth_texture_array, vec3 projection_coords, int layer_index, int taps, float spread) +{ + int loop; + float multiplier = 1.0 / float(taps); + float shadowMapDepth; + + for (int i = 0; i < taps; i++) + { + loop = i; + vec3 newProjCoords = projection_coords + vec3(poissonDisk[loop], 0.0) / (spread * SPLIT_WEIGHT * (1.0 + layer_index)); + shadowMapDepth += multiplier * texture(depth_texture_array, vec4(newProjCoords.xy, layer_index, newProjCoords.z)); + } + + return shadowMapDepth; +} + +// PCF + Poisson + RandomSample model method +float PoissonDotShadow(sampler2DArrayShadow depth_texture_array, vec3 projection_coords, int layer_index, int taps, float spread) +{ + int loop; + float multiplier = 1.0 / float(taps); + float shadowMapDepth; + + for (int i = 0; i < taps; i++) + { + loop = int(16.0 * Random(gl_FragCoord.xyy, i)) % 16; + vec3 newProjCoords = projection_coords + vec3(poissonDisk[loop], 0.0) / (spread * SPLIT_WEIGHT * (1.0 + layer_index)); + shadowMapDepth += multiplier * texture(depth_texture_array, vec4(newProjCoords.xy, layer_index, newProjCoords.z)); + } + + return shadowMapDepth; +} + +// Hardware PCF + Additional software PCF method +float SoftwarePCF(sampler2DArrayShadow depth_texture_array, vec3 projection_coords, int layer_index, float bias) +{ + float shadow = 0.0; + + vec3 texelSize = 1.0 / textureSize(depth_texture_array, 0); + for(int x = -1; x <= 1; x++) + { + for(int y = -1; y <= 1; y++) + { + shadow += texture(depth_texture_array, vec4(projection_coords.xy + vec2(x, y) * texelSize.xy, layer_index, projection_coords.z)); + } + } + + return shadow / 9.0; +} + float CalcShadowValue(vec4 light_space_pos, vec3 normal, vec3 light_dir, sampler2DArrayShadow depth_texture_array, int layer_index) { float shadowMapDepth; @@ -169,53 +221,13 @@ float CalcShadowValue(vec4 light_space_pos, vec3 normal, vec3 light_dir, sampler // Various methods for shadow calculation in fastest to slowest order. shadowMapDepth = PCFShadow(depth_texture_array, projCoords, layer_index); - - // PCF + Four-tap Poisson model method - //float SplitWeight = 0.7; - //for (int i = 0; i < 4; i++) - //{ - // int loop = i; - // vec3 newProjCoords = projCoords + vec3(poissonDisk[loop], 0.0) / (1500.0 * SplitWeight * (1.0 + layer_index)); - // shadowMapDepth += 0.25 * texture(depthTexture, vec4(newProjCoords.xy, layer_index, newProjCoords.z)); - //} - // - //// PCF + Four-tap Poisson model method - //float SplitWeight = 0.7; - //for (int i = 0; i < 4; i++) - //{ - // int loop = i; - // vec3 newProjCoords = projCoords + vec3(poissonDisk[loop], 0.0) / (1500.0 * SplitWeight * (1.0 + layer_index)); - // //int loop = int(16.0 * Random(gl_FragCoord.xyy, i)) % 16; - // shadowMapDepth += 0.25 * texture(depthTexture, vec4(newProjCoords.xy, layer_index, newProjCoords.z)); - //} - - - - - //float geometryDepth = projCoords.z; - //float shadow = geometryDepth - bias > shadowMapDepth ? 1.0 : 0.0; - //float shadow = 1.0 - bias > shadowMapDepth ? 0.0 : 1.0; + //shadowMapDepth = PoissonShadow(depth_texture_array, projCoords, layer_index, 4, 1500.0); + //shadowMapDepth = PoissonDotShadow(depth_texture_array, projCoords, layer_index, 4, 1500.0); + //shadowMapDepth = SoftwarePCF(depth_texture_array, projCoords, layer_index, bias); float shadow = 1.0 - shadowMapDepth; - - //vec2 texelSize = 1.0 / textureSize(depthTexture, 0); - //for(int x = -1; x <= 1; x++) - //{ - // for(int y = -1; y <= 1; y++) - // { - // float pcfDepth = texture(depthTexture, projCoords.xy + vec2(x, y) * texelSize).r; - // shadow += geometryDepth - bias > pcfDepth ? 1.0 : 0.0; - // } - //} - //shadow /= 9.0; - - //if(projCoords.z > 1.0) - //{ - // shadow = 0.0; - //} return shadow; - } int getShadowIndex(float far_distance[MAX_SPLITS]) diff --git a/resources/Shaders/Shadow.frag.glsl b/resources/Shaders/Shadow.frag.glsl index 798d1cda..58290b59 100644 --- a/resources/Shaders/Shadow.frag.glsl +++ b/resources/Shaders/Shadow.frag.glsl @@ -1,18 +1,10 @@ #version 430 - - -//in VertexData{ -// vec3 Position; -//}Input; - -//layout(location = 0 ) out vec4 ShadowMap; layout(location = 0 ) out float ShadowMap; void main() { - //ShadowMap = vec4(vec3(gl_FragCoord.z), 1.0); - //ShadowMap = (gl_FragCoord.z); + } diff --git a/resources/Shaders/Shadow.vert.glsl b/resources/Shaders/Shadow.vert.glsl index 16c0b26e..8a0dc8f4 100644 --- a/resources/Shaders/Shadow.vert.glsl +++ b/resources/Shaders/Shadow.vert.glsl @@ -6,12 +6,7 @@ uniform mat4 P; layout(location = 0) in vec3 Position; -//out VertexData{ -// vec3 Position; -//}Output; - void main() { -// Output.Position = Position; gl_Position = P * V * M * vec4(Position, 1.0); } \ No newline at end of file diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 72bd8711..98a56f6b 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -320,15 +320,13 @@ void DrawFinalPass::BindModelTextures(std::shared_ptr& job) glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture); } - //for (int i = 0; i < m_ShadowPass->CurrentNrOfSplits(); i++) - //{ - glActiveTexture(GL_TEXTURE4); - if (m_ShadowPass->DepthMap() != NULL) { - glBindTexture(GL_TEXTURE_2D_ARRAY, m_ShadowPass->DepthMap()); - } else { - glBindTexture(GL_TEXTURE_2D_ARRAY, m_WhiteTexture->m_Texture); - } - //} + glActiveTexture(GL_TEXTURE4); + if (m_ShadowPass->DepthMap() != NULL) { + glBindTexture(GL_TEXTURE_2D_ARRAY, m_ShadowPass->DepthMap()); + } + else { + glBindTexture(GL_TEXTURE_2D_ARRAY, m_WhiteTexture->m_Texture); + } } From 8647267cad3dcd549c131229e1a2554410c8ba0c Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Sat, 27 Feb 2016 18:04:33 +0100 Subject: [PATCH 077/252] Make code less dumb, save 7 fps --- include/Engine/Rendering/ShadowPass.h | 38 +++++------ resources/Shaders/ForwardPlus.frag.glsl | 87 +++++++++++++++--------- resources/Shaders/ForwardPlus.vert.glsl | 6 +- src/Engine/Editor/EditorSystem.cpp | 2 +- src/Engine/Rendering/ShadowPass.cpp | 88 +++++++++++-------------- 5 files changed, 113 insertions(+), 108 deletions(-) diff --git a/include/Engine/Rendering/ShadowPass.h b/include/Engine/Rendering/ShadowPass.h index 6fab8a3a..1ff09338 100644 --- a/include/Engine/Rendering/ShadowPass.h +++ b/include/Engine/Rendering/ShadowPass.h @@ -10,10 +10,9 @@ #include "imgui/imgui.h" #define MAX_SPLITS 4 -#define MAP_SIZE 216.f -enum NearFar { Near = 0, Far = 1 }; -enum LRBT { Left = 0, Right = 1, Bottom = 2, Top = 3 }; +enum NearFar { NEAR = 0, FAR = 1 }; +enum LRBT { LEFT = 0, RIGHT = 1, BOTTOM = 2, TOP = 3 }; struct Frustum { @@ -30,8 +29,8 @@ struct Frustum class ShadowPass { public: - ShadowPass(IRenderer* renderer); + ShadowPass(IRenderer * renderer, int ShadowResX, int ShadowResY); ~ShadowPass(); void InitializeFrameBuffers(); @@ -39,45 +38,40 @@ public: void ClearBuffer(); void Draw(RenderScene& scene); - //GLuint DepthMap(int level) const { return m_DepthMap[level]; } GLuint DepthMap() const { return m_DepthMap; } std::array LightP() const { return m_LightProjection; } std::array LightV() const { return m_LightView; } std::array FarDistance() const { return { m_shadowFrusta[0].FarClip, m_shadowFrusta[1].FarClip, m_shadowFrusta[2].FarClip, m_shadowFrusta[3].FarClip }; } int CurrentNrOfSplits() const { return m_CurrentNrOfSplits; } + + void SetSplitWeight(float split_weight) { m_SplitWeight = split_weight; }; private: - void UpdateFrustumPoints(Frustum& frustum, glm::vec3 camera_position, glm::vec3 view_dir, glm::mat4 p, glm::mat4 v); - void UpdateSplitDist(std::array& frusta, float near_distance, float far_distance); void InitializeCameras(RenderScene & scene); - float FindRadius(Frustum& frustum); + void UpdateSplitDist(std::array& frusta, float near_distance, float far_distance); + void UpdateFrustumPoints(Frustum& frustum, glm::vec3 camera_position, glm::vec3 view_dir); + void UpdateFrustumPoints(Frustum& frustum, glm::mat4 p, glm::mat4 v); + void PointsToLightspace(Frustum& frustum, glm::mat4 v); - void RadiusToLightspace(Frustum& frustum, glm::mat4 v); + + float FindRadius(Frustum& frustum); + void RadiusToLightspace(Frustum& frustum); EventBroker* m_EventBroker; const IRenderer* m_Renderer; - //std::array m_DepthMap; - //std::array m_DepthBuffer; GLuint m_DepthMap; FrameBuffer m_DepthBuffer; + ShaderProgram* m_ShadowProgram; std::array m_LightProjection; std::array m_LightView; - ShaderProgram* m_ShadowProgram; - GLuint m_DepthFBO; - GLfloat m_NearFarPlane[2] = { -34.f, 27.f }; - //GLfloat m_LRBT[4] = { -10.f, 10.f, -10.f, 10.f }; - GLuint m_ResolutionSizeWidth = 1024 * 2; - GLuint m_ResolutionSizeHeigth = 1024 * 2; + GLuint m_ResolutionSizeHeight = 1024 * 2; - bool m_ShadowOn = true; - int m_ShadowLevel = 0; - - int m_CurrentNrOfSplits = 3; - float m_SplitWeight = 0.7f; + int m_CurrentNrOfSplits = 4; + float m_SplitWeight = 0.91f; std::array m_shadowFrusta; }; diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index b3240911..d29abfdc 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -1,7 +1,6 @@ #version 430 #define MAX_SPLITS 4 -#define SPLIT_WEIGHT 0.7 uniform mat4 M; uniform mat4 V; @@ -139,6 +138,7 @@ vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textu return vec4(TBN * normalize(NormalMap), 0.0); } +// Returns a "random" value. float Random(vec3 seed, int i) { vec4 seed4 = vec4(seed, i); @@ -162,7 +162,7 @@ float PoissonShadow(sampler2DArrayShadow depth_texture_array, vec3 projection_co for (int i = 0; i < taps; i++) { loop = i; - vec3 newProjCoords = projection_coords + vec3(poissonDisk[loop], 0.0) / (spread * SPLIT_WEIGHT * (1.0 + layer_index)); + vec3 newProjCoords = projection_coords + vec3(poissonDisk[loop], 0.0) / (spread * (1.0 + layer_index)); shadowMapDepth += multiplier * texture(depth_texture_array, vec4(newProjCoords.xy, layer_index, newProjCoords.z)); } @@ -179,7 +179,7 @@ float PoissonDotShadow(sampler2DArrayShadow depth_texture_array, vec3 projection for (int i = 0; i < taps; i++) { loop = int(16.0 * Random(gl_FragCoord.xyy, i)) % 16; - vec3 newProjCoords = projection_coords + vec3(poissonDisk[loop], 0.0) / (spread * SPLIT_WEIGHT * (1.0 + layer_index)); + vec3 newProjCoords = projection_coords + vec3(poissonDisk[loop], 0.0) / (spread * (1.0 + layer_index)); shadowMapDepth += multiplier * texture(depth_texture_array, vec4(newProjCoords.xy, layer_index, newProjCoords.z)); } @@ -196,7 +196,7 @@ float SoftwarePCF(sampler2DArrayShadow depth_texture_array, vec3 projection_coor { for(int y = -1; y <= 1; y++) { - shadow += texture(depth_texture_array, vec4(projection_coords.xy + vec2(x, y) * texelSize.xy, layer_index, projection_coords.z)); + shadow += texture(depth_texture_array, vec4(projection_coords.xy + vec2(x, y) * texelSize.xy / (1.0 + layer_index), layer_index, projection_coords.z)); } } @@ -206,40 +206,56 @@ float SoftwarePCF(sampler2DArrayShadow depth_texture_array, vec3 projection_coor float CalcShadowValue(vec4 light_space_pos, vec3 normal, vec3 light_dir, sampler2DArrayShadow depth_texture_array, int layer_index) { float shadowMapDepth; - float bias; + float bias = 0.005; // Various bias methods. - //bias = 0.005; - //bias = max(0.05 * (1.0 - dot(normal, light_dir)), 0.005); - bias = 0.005 * tan(acos(clamp(dot(normal, -light_dir), 0.0, 1.0))); + bias = max(0.05 * (1.0 - dot(normal, light_dir)), bias); + //bias = bias * tan(acos(clamp(dot(normal, -light_dir), 0.0, 1.0))); + + // Calculate coordinates in projection space. - // Calculate coordinates in projection space vec3 projCoords = vec3(light_space_pos.xy, light_space_pos.z + bias) / light_space_pos.w; projCoords = projCoords * 0.5 + 0.5; // Various methods for shadow calculation in fastest to slowest order. shadowMapDepth = PCFShadow(depth_texture_array, projCoords, layer_index); - //shadowMapDepth = PoissonShadow(depth_texture_array, projCoords, layer_index, 4, 1500.0); - //shadowMapDepth = PoissonDotShadow(depth_texture_array, projCoords, layer_index, 4, 1500.0); + //shadowMapDepth = PoissonShadow(depth_texture_array, projCoords, layer_index, 4, 25.0 * FarDistance[MAX_SPLITS - 1]); + //shadowMapDepth = PoissonDotShadow(depth_texture_array, projCoords, layer_index, 4, 25.0 * FarDistance[MAX_SPLITS]); //shadowMapDepth = SoftwarePCF(depth_texture_array, projCoords, layer_index, bias); - - float shadow = 1.0 - shadowMapDepth; - return shadow; + return 1.0 - shadowMapDepth; } -int getShadowIndex(float far_distance[MAX_SPLITS]) +int getShadowIndex(float far_distance[1]) +{ + return 0; +} + +int getShadowIndex(float far_distance[2]) +{ + float depth = gl_FragCoord.z / gl_FragCoord.w; + + int index = 1; + if ( depth < far_distance[0] ) + { + index = 0; + } + + return index; +} + +int getShadowIndex(float far_distance[3]) { float depth = gl_FragCoord.z / gl_FragCoord.w; int index = 2; - if( depth < far_distance[0] ) + if ( depth < far_distance[0] ) { index = 0; } - else if( depth < far_distance[1] && depth > far_distance[0] ) + else if ( depth < far_distance[1] && depth > far_distance[0] ) { index = 1; } @@ -247,6 +263,27 @@ int getShadowIndex(float far_distance[MAX_SPLITS]) return index; } +int getShadowIndex(float far_distance[4]) +{ + float depth = gl_FragCoord.z / gl_FragCoord.w; + + int index = 3; + if ( depth < far_distance[0] ) + { + index = 0; + } + else if ( depth < far_distance[1] && depth > far_distance[0] ) + { + index = 1; + } + else if ( depth < far_distance[2] && depth > far_distance[1] ) + { + index = 2; + } + + return index; +} + void main() { vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate); @@ -282,9 +319,7 @@ void main() light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, position, normal, light.Falloff); } else if (light.Type == 2) { //Directional int DepthMapIndex = getShadowIndex(FarDistance); - light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal); - shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap, DepthMapIndex); } @@ -298,19 +333,7 @@ void main() //LightResult getInformation; vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); - color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); - - //color_result = (totalLighting.Diffuse + (1.0 - shadowFactor) * (getInformation.Diffuse + (getInformation.Specular * specularTexel))) * color_result; - - - - - - - - - //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; - + color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); float pos = ((P * vec4(Input.Position, 1)).y + 1.0)/2.0; diff --git a/resources/Shaders/ForwardPlus.vert.glsl b/resources/Shaders/ForwardPlus.vert.glsl index 0d9661cc..d77ee20a 100644 --- a/resources/Shaders/ForwardPlus.vert.glsl +++ b/resources/Shaders/ForwardPlus.vert.glsl @@ -47,11 +47,8 @@ void main() + BoneWeights[2] * Bones[int(BoneIndices[2])] + BoneWeights[3] * Bones[int(BoneIndices[3])]; } - - //vec4 lightPos = LightP * LightV * M * vec4(Position, 1.0); // N - + gl_Position = P*V*M*boneTransform * vec4(Position, 1.0); - //gl_Position = lightPos; // N Output.Position = (boneTransform * vec4(Position, 1.0)).xyz; Output.TextureCoordinate = TextureCoords; @@ -61,7 +58,6 @@ void main() Output.ExplosionColor = vec4(1.0); Output.ExplosionPercentageElapsed = 0.0; - //Output.PositionLightSpace = lightPos; // N for(int i = 0; i < MAX_SPLITS; i++) { Output.PositionLightSpace[i] = LightP[i] * LightV[i] * M * vec4(Position, 1.0); diff --git a/src/Engine/Editor/EditorSystem.cpp b/src/Engine/Editor/EditorSystem.cpp index a13bac0b..6128c1f9 100644 --- a/src/Engine/Editor/EditorSystem.cpp +++ b/src/Engine/Editor/EditorSystem.cpp @@ -18,7 +18,7 @@ EditorSystem::EditorSystem(World* world, EventBroker* eventBroker, IRenderer* re m_ActualCamera = m_EditorCamera; m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Transform"); auto cCamera = m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Camera"); - (double&)cCamera["FarClip"] = 60.0; + (double&)cCamera["FarClip"] = 300.0; m_EditorCameraInputController = new EditorCameraInputController(m_EventBroker, -1); diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index dd423f25..33a42e3b 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -1,6 +1,16 @@ #include "Rendering/ShadowPass.h" +ShadowPass::ShadowPass(IRenderer * renderer, int shadow_res_x, int shadow_res_y) +{ + m_Renderer = renderer; + m_ResolutionSizeWidth = shadow_res_x; + m_ResolutionSizeHeight = shadow_res_y; + + InitializeFrameBuffers(); + InitializeShaderPrograms(); +} + ShadowPass::ShadowPass(IRenderer * renderer) { m_Renderer = renderer; @@ -41,8 +51,28 @@ void ShadowPass::UpdateSplitDist(std::array& frusta, float frusta[m_CurrentNrOfSplits - 1].FarClip = far_distance; } +void ShadowPass::UpdateFrustumPoints(Frustum& frustum, glm::mat4 p, glm::mat4 v) +{ + std::array CornerPoint = { + glm::vec4(-1.f, -1.f, -1.f, 1.f), + glm::vec4(-1.f, 1.f, -1.f, 1.f), + glm::vec4(1.f, 1.f, -1.f, 1.f), + glm::vec4(1.f, -1.f, -1.f, 1.f), + glm::vec4(-1.f, -1.f, 1.f, 1.f), + glm::vec4(-1.f, 1.f, 1.f, 1.f), + glm::vec4(1.f, 1.f, 1.f, 1.f), + glm::vec4(1.f, -1.f, 1.f, 1.f) + }; + + for (int i = 0; i < 8; i++) { + glm::vec4 NDC = glm::inverse(p) * CornerPoint[i]; + NDC = NDC / NDC.w; + frustum.CornerPoint[i] = glm::vec3(glm::inverse(v) * NDC); + } +} + // Compute the 8 corner points of the current view frustum in world space -void ShadowPass::UpdateFrustumPoints(Frustum& frustum, glm::vec3 camera_position, glm::vec3 view_dir, glm::mat4 p, glm::mat4 v) +void ShadowPass::UpdateFrustumPoints(Frustum& frustum, glm::vec3 camera_position, glm::vec3 view_dir) { glm::vec3 up = glm::vec3(0.f, 1.f, 0.f); glm::vec3 right = glm::normalize(glm::cross(view_dir, up)); @@ -68,25 +98,6 @@ void ShadowPass::UpdateFrustumPoints(Frustum& frustum, glm::vec3 camera_position frustum.CornerPoint[5] = far_center + up * far_height - right * far_width; frustum.CornerPoint[6] = far_center + up * far_height + right * far_width; frustum.CornerPoint[7] = far_center - up * far_height + right * far_width; - - // Alternative way. - //std::array CornerPoint = { - // glm::vec4(-1.f, -1.f, -1.f, 1.f), - // glm::vec4(-1.f, 1.f, -1.f, 1.f), - // glm::vec4(1.f, 1.f, -1.f, 1.f), - // glm::vec4(1.f, -1.f, -1.f, 1.f), - // glm::vec4(-1.f, -1.f, 1.f, 1.f), - // glm::vec4(-1.f, 1.f, 1.f, 1.f), - // glm::vec4(1.f, 1.f, 1.f, 1.f), - // glm::vec4(1.f, -1.f, 1.f, 1.f) }; - - //std::array FinalPoints; - - //for (int i = 0; i < 8; i++) { - // glm::vec4 NDC = glm::inverse(p) * CornerPoint[i]; - // NDC = NDC / NDC.w; - // FinalPoints[i] = glm::vec3(glm::inverse(v) * NDC); - //} } float ShadowPass::FindRadius(Frustum& frustum) @@ -106,18 +117,13 @@ float ShadowPass::FindRadius(Frustum& frustum) void ShadowPass::InitializeFrameBuffers() { - GLERROR("depthMap failed PRE"); // Depth texture glGenTextures(1, &m_DepthMap); - GLERROR("depthMap failed1"); glBindTexture(GL_TEXTURE_2D_ARRAY, m_DepthMap); - GLERROR("depthMap failed2"); - glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_DEPTH_COMPONENT16, m_ResolutionSizeWidth, m_ResolutionSizeHeigth, m_CurrentNrOfSplits); - GLERROR("depthMap failed3"); + glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_DEPTH_COMPONENT16, m_ResolutionSizeWidth, m_ResolutionSizeHeight, m_CurrentNrOfSplits); - glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, m_ResolutionSizeWidth, m_ResolutionSizeHeigth, m_CurrentNrOfSplits, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr); - GLERROR("depthMap failed4"); + glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, m_ResolutionSizeWidth, m_ResolutionSizeHeight, m_CurrentNrOfSplits, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR); @@ -126,11 +132,9 @@ void ShadowPass::InitializeFrameBuffers() glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); glTexParameterfv(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_BORDER_COLOR, glm::vec4(1.f).data); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); - GLERROR("depthMap failed5"); m_DepthBuffer.AddResource(std::shared_ptr(new Texture2DArray(&m_DepthMap, GL_DEPTH_ATTACHMENT, m_CurrentNrOfSplits))); m_DepthBuffer.Generate(); - //} GLERROR("depthMap failed END"); } @@ -178,7 +182,7 @@ void ShadowPass::PointsToLightspace(Frustum& frustum, glm::mat4 v) frustum.LRBT = { left, right, bottom, top }; } -void ShadowPass::RadiusToLightspace(Frustum& frustum, glm::mat4 v) +void ShadowPass::RadiusToLightspace(Frustum& frustum) { float left = -frustum.Radius; float right = frustum.Radius; @@ -190,10 +194,7 @@ void ShadowPass::RadiusToLightspace(Frustum& frustum, glm::mat4 v) void ShadowPass::Draw(RenderScene & scene) { -// ImGui::DragFloat4("ShadowMapCam", m_LRBT, 1.f, -1000.f, 1000.f); ImGui::DragFloat2("ShadowMapNearFar", m_NearFarPlane, 1.f, -1000.f, 1000.f); - ImGui::Checkbox("EnableShadow", &m_ShadowOn); - //ImGui::DragInt("ShadowLevel", &m_ShadowLevel, 0.05f, 0, m_CurrentNrOfSplits - 1); InitializeCameras(scene); UpdateSplitDist(m_shadowFrusta, scene.Camera->NearClip(), scene.Camera->FarClip()); @@ -201,19 +202,14 @@ void ShadowPass::Draw(RenderScene & scene) ShadowPassState* state = new ShadowPassState(m_DepthBuffer.GetHandle()); m_ShadowProgram->Bind(); + GLuint shaderHandle = m_ShadowProgram->GetHandle(); + glViewport(0, 0, m_ResolutionSizeWidth, m_ResolutionSizeHeight); for (int i = 0; i < m_CurrentNrOfSplits; i++) { - UpdateFrustumPoints(m_shadowFrusta[i], scene.Camera->Position(), scene.Camera->Forward(), scene.Camera->ProjectionMatrix(), scene.Camera->ViewMatrix()); - //float test = FindRadius(m_shadFrusta[i]); - - GLuint shaderHandle = m_ShadowProgram->GetHandle(); + UpdateFrustumPoints(m_shadowFrusta[i], scene.Camera->Position(), scene.Camera->Forward()); glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_DepthMap, 0, i); - - glViewport(0, 0, m_ResolutionSizeWidth, m_ResolutionSizeHeigth); - //state->Disable(GL_CULL_FACE); - for (auto &job : scene.DirectionalLightJobs) { auto directionalLightJob = std::dynamic_pointer_cast(job); @@ -221,7 +217,7 @@ void ShadowPass::Draw(RenderScene & scene) m_LightView[i] = glm::lookAt(glm::vec3(-directionalLightJob->Direction) + m_shadowFrusta[i].MiddlePoint, m_shadowFrusta[i].MiddlePoint, glm::vec3(0.f, 1.f, 0.f)); PointsToLightspace(m_shadowFrusta[i], m_LightView[i]); - m_LightProjection[i] = glm::ortho(m_shadowFrusta[i].LRBT[Left], m_shadowFrusta[i].LRBT[Right], m_shadowFrusta[i].LRBT[Bottom], m_shadowFrusta[i].LRBT[Top], m_NearFarPlane[Near], m_NearFarPlane[Far]); + m_LightProjection[i] = glm::ortho(m_shadowFrusta[i].LRBT[LEFT], m_shadowFrusta[i].LRBT[RIGHT], m_shadowFrusta[i].LRBT[BOTTOM], m_shadowFrusta[i].LRBT[TOP], m_NearFarPlane[NEAR], m_NearFarPlane[FAR]); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection[i])); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView[i])); @@ -240,14 +236,10 @@ void ShadowPass::Draw(RenderScene & scene) GLERROR("Shadow Draw ERROR"); } } - } - - glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); - - m_ShadowProgram->Unbind(); - } + m_ShadowProgram->Unbind(); + glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); m_DepthBuffer.Unbind(); delete state; } From 14b0a64720cead73c7c3ed124cd126f6f6ef8a32 Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Sat, 27 Feb 2016 18:42:51 +0100 Subject: [PATCH 078/252] begin fixing transparent object's shadows --- include/Engine/Rendering/ShadowPass.h | 24 +++++----- .../Schema/Entities/QualityAssurance.xml | 2 +- resources/Shaders/ForwardPlus.frag.glsl | 4 +- src/Engine/Rendering/DrawFinalPass.cpp | 13 +++--- src/Engine/Rendering/Renderer.cpp | 3 -- src/Engine/Rendering/ShadowPass.cpp | 44 ++++++++++++------- src/Engine/Rendering/ShadowPassState.cpp | 5 +-- 7 files changed, 51 insertions(+), 44 deletions(-) diff --git a/include/Engine/Rendering/ShadowPass.h b/include/Engine/Rendering/ShadowPass.h index 1ff09338..a26ddf97 100644 --- a/include/Engine/Rendering/ShadowPass.h +++ b/include/Engine/Rendering/ShadowPass.h @@ -29,19 +29,19 @@ struct Frustum class ShadowPass { public: - ShadowPass(IRenderer* renderer); + ShadowPass(IRenderer* renderer); ShadowPass(IRenderer * renderer, int ShadowResX, int ShadowResY); - ~ShadowPass(); - - void InitializeFrameBuffers(); - void InitializeShaderPrograms(); - void ClearBuffer(); - void Draw(RenderScene& scene); + ~ShadowPass(); + + void InitializeFrameBuffers(); + void InitializeShaderPrograms(); + void ClearBuffer(); + void Draw(RenderScene& scene); GLuint DepthMap() const { return m_DepthMap; } std::array LightP() const { return m_LightProjection; } std::array LightV() const { return m_LightView; } - std::array FarDistance() const { return { m_shadowFrusta[0].FarClip, m_shadowFrusta[1].FarClip, m_shadowFrusta[2].FarClip, m_shadowFrusta[3].FarClip }; } + std::array FarDistance() const { return{ m_shadowFrusta[0].FarClip, m_shadowFrusta[1].FarClip, m_shadowFrusta[2].FarClip, m_shadowFrusta[3].FarClip }; } int CurrentNrOfSplits() const { return m_CurrentNrOfSplits; } void SetSplitWeight(float split_weight) { m_SplitWeight = split_weight; }; @@ -55,7 +55,7 @@ private: float FindRadius(Frustum& frustum); void RadiusToLightspace(Frustum& frustum); - + EventBroker* m_EventBroker; const IRenderer* m_Renderer; @@ -66,9 +66,9 @@ private: std::array m_LightProjection; std::array m_LightView; - GLfloat m_NearFarPlane[2] = { -34.f, 27.f }; - GLuint m_ResolutionSizeWidth = 1024 * 2; - GLuint m_ResolutionSizeHeight = 1024 * 2; + GLfloat m_NearFarPlane[2] = { -34.f, 27.f }; + GLuint m_ResolutionSizeWidth = 1024 * 2; + GLuint m_ResolutionSizeHeight = 1024 * 2; int m_CurrentNrOfSplits = 4; float m_SplitWeight = 0.91f; diff --git a/resources/Schema/Entities/QualityAssurance.xml b/resources/Schema/Entities/QualityAssurance.xml index e057cf38..04dfc6aa 100644 --- a/resources/Schema/Entities/QualityAssurance.xml +++ b/resources/Schema/Entities/QualityAssurance.xml @@ -569,7 +569,7 @@ Models/Core/UnitCube.mesh - + true diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index d29abfdc..8250d96d 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -210,8 +210,8 @@ float CalcShadowValue(vec4 light_space_pos, vec3 normal, vec3 light_dir, sampler // Various bias methods. - bias = max(0.05 * (1.0 - dot(normal, light_dir)), bias); - //bias = bias * tan(acos(clamp(dot(normal, -light_dir), 0.0, 1.0))); + //bias = max(0.05 * (1.0 - dot(normal, light_dir)), bias); + bias = bias * tan(acos(clamp(dot(normal, -light_dir), 0.0, 1.0))); // Calculate coordinates in projection space. diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 98a56f6b..a1139902 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -226,6 +226,12 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptrFillColor)); glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), job->FillPercentage); glUniform4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor)); + + //Shadow + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightP"), MAX_SPLITS, GL_FALSE, glm::value_ptr(*m_ShadowPass->LightP().data())); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightV"), MAX_SPLITS, GL_FALSE, glm::value_ptr(*m_ShadowPass->LightV().data())); + glUniform1fv(glGetUniformLocation(shaderHandle, "FarDistance"), MAX_SPLITS, m_ShadowPass->FarDistance().data()); + GLERROR("END"); } @@ -248,13 +254,6 @@ void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptrLightV().data())); glUniform1fv(glGetUniformLocation(shaderHandle, "FarDistance"), MAX_SPLITS, m_ShadowPass->FarDistance().data()); - - //GLfloat m_NearFarPlane[2] = { -40.f, 30.f }; - //GLfloat m_LRBT[4] = { -40.f, 100.f, -50.f, 50.f }; - //glm::mat4 m_LightProjection = glm::ortho(m_LRBT[Left], m_LRBT[Right], m_LRBT[Bottom], m_LRBT[Top], m_NearFarPlane[Near], m_NearFarPlane[Far]); - //glm::mat4 m_LightView = glm::lookAt(glm::vec3(-20.0f, 20.0f, -20.0f), glm::vec3(0.0f), glm::vec3(1.0)); - //glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightP"), 1, GL_FALSE, glm::value_ptr(m_LightProjection)); - //glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightV"), 1, GL_FALSE, glm::value_ptr(m_LightView)); GLERROR("END"); } diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index a26a7f09..cc6ab11b 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -136,9 +136,6 @@ void Renderer::Draw(RenderFrame& frame) if (m_DebugTextureToDraw == 4) { m_DrawScreenQuadPass->Draw(m_PickingPass->PickingTexture()); } - if (m_DebugTextureToDraw == 5) { - m_DrawScreenQuadPass->Draw(m_ShadowPass->DepthMap()); - } m_ImGuiRenderPass->Draw(); glfwSwapBuffers(m_Window); diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index 33a42e3b..be09626d 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -53,7 +53,7 @@ void ShadowPass::UpdateSplitDist(std::array& frusta, float void ShadowPass::UpdateFrustumPoints(Frustum& frustum, glm::mat4 p, glm::mat4 v) { - std::array CornerPoint = { + std::array CornerPoint = { glm::vec4(-1.f, -1.f, -1.f, 1.f), glm::vec4(-1.f, 1.f, -1.f, 1.f), glm::vec4(1.f, 1.f, -1.f, 1.f), @@ -81,7 +81,7 @@ void ShadowPass::UpdateFrustumPoints(Frustum& frustum, glm::vec3 camera_position glm::vec3 near_center = camera_position + glm::normalize(view_dir) * frustum.NearClip; frustum.MiddlePoint = near_center + (far_center - near_center) * 0.5f; - up = glm::normalize(glm::cross(right, view_dir)); + up = glm::normalize(glm::cross(right, view_dir)); // these heights and widths are half the heights and widths of the near and far plane rectangles. float near_height = tan(frustum.FOV / 2.f) * frustum.NearClip; @@ -118,7 +118,7 @@ float ShadowPass::FindRadius(Frustum& frustum) void ShadowPass::InitializeFrameBuffers() { // Depth texture - glGenTextures(1, &m_DepthMap); + glGenTextures(1, &m_DepthMap); glBindTexture(GL_TEXTURE_2D_ARRAY, m_DepthMap); glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_DEPTH_COMPONENT16, m_ResolutionSizeWidth, m_ResolutionSizeHeight, m_CurrentNrOfSplits); @@ -136,17 +136,17 @@ void ShadowPass::InitializeFrameBuffers() m_DepthBuffer.AddResource(std::shared_ptr(new Texture2DArray(&m_DepthMap, GL_DEPTH_ATTACHMENT, m_CurrentNrOfSplits))); m_DepthBuffer.Generate(); - GLERROR("depthMap failed END"); + GLERROR("depthMap failed END"); } void ShadowPass::InitializeShaderPrograms() { - m_ShadowProgram = ResourceManager::Load("#ShadowProgram"); - m_ShadowProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/Shadow.vert.glsl"))); - m_ShadowProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/Shadow.frag.glsl"))); - m_ShadowProgram->Compile(); - m_ShadowProgram->BindFragDataLocation(0, "ShadowMap"); - m_ShadowProgram->Link(); + m_ShadowProgram = ResourceManager::Load("#ShadowProgram"); + m_ShadowProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/Shadow.vert.glsl"))); + m_ShadowProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/Shadow.frag.glsl"))); + m_ShadowProgram->Compile(); + m_ShadowProgram->BindFragDataLocation(0, "ShadowMap"); + m_ShadowProgram->Link(); } void ShadowPass::ClearBuffer() @@ -155,7 +155,7 @@ void ShadowPass::ClearBuffer() for (int i = 0; i < m_CurrentNrOfSplits; i++) { glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_DepthMap, 0, i); - + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } @@ -187,7 +187,7 @@ void ShadowPass::RadiusToLightspace(Frustum& frustum) float left = -frustum.Radius; float right = frustum.Radius; float bottom = -frustum.Radius; - float top =frustum.Radius; + float top = frustum.Radius; frustum.LRBT = { left, right, bottom, top }; } @@ -198,7 +198,7 @@ void ShadowPass::Draw(RenderScene & scene) InitializeCameras(scene); UpdateSplitDist(m_shadowFrusta, scene.Camera->NearClip(), scene.Camera->FarClip()); - + ShadowPassState* state = new ShadowPassState(m_DepthBuffer.GetHandle()); m_ShadowProgram->Bind(); @@ -207,9 +207,9 @@ void ShadowPass::Draw(RenderScene & scene) for (int i = 0; i < m_CurrentNrOfSplits; i++) { UpdateFrustumPoints(m_shadowFrusta[i], scene.Camera->Position(), scene.Camera->Forward()); - + glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_DepthMap, 0, i); - + for (auto &job : scene.DirectionalLightJobs) { auto directionalLightJob = std::dynamic_pointer_cast(job); @@ -235,6 +235,20 @@ void ShadowPass::Draw(RenderScene & scene) GLERROR("Shadow Draw ERROR"); } + + state->CullFace(GL_BACK); + for (auto &objectJob : scene.TransparentObjects) { + auto modelJob = std::dynamic_pointer_cast(objectJob); + + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); + + 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("Shadow Draw ERROR"); + } + state->CullFace(GL_FRONT); } } } diff --git a/src/Engine/Rendering/ShadowPassState.cpp b/src/Engine/Rendering/ShadowPassState.cpp index f84b6436..67e0dd1f 100644 --- a/src/Engine/Rendering/ShadowPassState.cpp +++ b/src/Engine/Rendering/ShadowPassState.cpp @@ -2,16 +2,13 @@ ShadowPassState::ShadowPassState(GLuint frameBuffer) { - GLERROR("---2"); BindFramebuffer(frameBuffer); - GLERROR("---3"); Enable(GL_DEPTH_TEST); Enable(GL_CULL_FACE); Disable(GL_BLEND); Disable(GL_TEXTURE_2D); CullFace(GL_FRONT); - ClearColor(glm::vec4(255.f, 128.f, 128.f, 128.f)); - GLERROR("---4"); + ClearColor(glm::vec4(0.f, 0.f, 0.f, 0.f)); } ShadowPassState::~ShadowPassState() From d3a245606ae675871423650cde27378219a7eb55 Mon Sep 17 00:00:00 2001 From: Teejoon Date: Sun, 28 Feb 2016 15:02:40 +0100 Subject: [PATCH 079/252] SSAO and Glow is no longe conflicting with each other. Texture should get the id = 0 when they are deleted and not assigned a new texture after. Else they will start to conflict with each other. --- include/Engine/Rendering/DrawBloomPass.h | 6 ++--- include/Engine/Rendering/SSAOPass.h | 12 ++++----- src/Engine/Rendering/DrawBloomPass.cpp | 30 ++++++++++++++--------- src/Engine/Rendering/Renderer.cpp | 3 +-- src/Engine/Rendering/SSAOPass.cpp | 31 ++++++++++++++++-------- 5 files changed, 49 insertions(+), 33 deletions(-) diff --git a/include/Engine/Rendering/DrawBloomPass.h b/include/Engine/Rendering/DrawBloomPass.h index 2fffbdc7..4ddb7e05 100644 --- a/include/Engine/Rendering/DrawBloomPass.h +++ b/include/Engine/Rendering/DrawBloomPass.h @@ -39,7 +39,7 @@ public: private: - void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const; + void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type); Texture* m_BlackTexture; Model* m_ScreenQuad; @@ -50,8 +50,8 @@ private: int m_Iterations; int m_Quality = 0; - GLuint m_GaussianTexture_horiz; - GLuint m_GaussianTexture_vert; + GLuint m_GaussianTexture_horiz = 0; + GLuint m_GaussianTexture_vert = 0; FrameBuffer m_GaussianFrameBuffer_horiz; FrameBuffer m_GaussianFrameBuffer_vert; diff --git a/include/Engine/Rendering/SSAOPass.h b/include/Engine/Rendering/SSAOPass.h index ce3f85ed..a5f638cd 100644 --- a/include/Engine/Rendering/SSAOPass.h +++ b/include/Engine/Rendering/SSAOPass.h @@ -28,7 +28,7 @@ public: if (m_Quality == 0) { return m_WhiteTexture->m_Texture; } else { - return m_GaussianTexture_vert; + return m_Gaussian_vert; } } @@ -46,7 +46,7 @@ private: void InitializeShaderProgram(); void InitializeBuffer(); - void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const; + void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type); //void blurHorizontal(GLuint depthBuffer); //void blurVertical(GLuint depthBuffer); @@ -68,14 +68,14 @@ private: Texture* m_WhiteTexture; - GLuint m_SSAOTexture; + GLuint m_SSAOTexture = 0; FrameBuffer m_SSAOFramBuffer; - GLuint m_SSAOViewSpaceZTexture; + GLuint m_SSAOViewSpaceZTexture = 0; FrameBuffer m_SSAOViewSpaceZFramBuffer; - GLuint m_GaussianTexture_horiz; - GLuint m_GaussianTexture_vert; + GLuint m_Gaussian_horiz = 0; + GLuint m_Gaussian_vert = 0; FrameBuffer m_GaussianFrameBuffer_horiz; FrameBuffer m_GaussianFrameBuffer_vert; diff --git a/src/Engine/Rendering/DrawBloomPass.cpp b/src/Engine/Rendering/DrawBloomPass.cpp index fe93c167..4fe885af 100644 --- a/src/Engine/Rendering/DrawBloomPass.cpp +++ b/src/Engine/Rendering/DrawBloomPass.cpp @@ -9,6 +9,11 @@ DrawBloomPass::DrawBloomPass(IRenderer* renderer, ConfigFile* config) ChangeQuality(m_Config->Get("GLOW.Quality", 2)); } +void DrawBloomPass::InitializeTextures() +{ + m_BlackTexture = CommonFunctions::LoadTexture("Textures/Core/Black.png", false); +} + void DrawBloomPass::ChangeQuality(int quality) { if (m_Quality == quality) { @@ -21,19 +26,16 @@ void DrawBloomPass::ChangeQuality(int quality) if (m_Quality == 0) { glDeleteTextures(1, &m_GaussianTexture_horiz); glDeleteTextures(1, &m_GaussianTexture_vert); + m_GaussianTexture_horiz = 0; + m_GaussianTexture_vert = 0; return; } - - std::string qStr = std::to_string(m_Quality); - m_Iterations = m_Config->Get("GLOW" + qStr + ".NumIterations", 0); + InitializeTextures(); InitializeBuffers(); InitializeShaderPrograms(); -} - -void DrawBloomPass::InitializeTextures() -{ - m_BlackTexture = CommonFunctions::LoadTexture("Textures/Core/Black.png", false); + std::string qStr = std::to_string(m_Quality); + m_Iterations = m_Config->Get("GLOW" + qStr + ".NumIterations", 0); } void DrawBloomPass::InitializeShaderPrograms() @@ -55,7 +57,6 @@ void DrawBloomPass::InitializeShaderPrograms() } } - void DrawBloomPass::InitializeBuffers() { GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); @@ -63,13 +64,13 @@ void DrawBloomPass::InitializeBuffers() if (m_GaussianFrameBuffer_horiz.GetHandle() == 0) { m_GaussianFrameBuffer_horiz.AddResource(std::shared_ptr(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0))); } - m_GaussianFrameBuffer_horiz.Generate(); + m_GaussianFrameBuffer_horiz.Generate(); GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); if (m_GaussianFrameBuffer_vert.GetHandle() == 0) { m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0))); } - m_GaussianFrameBuffer_vert.Generate(); + m_GaussianFrameBuffer_vert.Generate(); } @@ -118,6 +119,7 @@ void DrawBloomPass::Draw(GLuint texture) m_GaussianFrameBuffer_vert.Bind(); m_GaussianProgram_vert->Bind(); + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz); glBindVertexArray(m_ScreenQuad->VAO); @@ -125,16 +127,19 @@ void DrawBloomPass::Draw(GLuint texture) glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1 , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex); //horizontal pass + m_GaussianFrameBuffer_vert.Unbind(); m_GaussianFrameBuffer_horiz.Bind(); m_GaussianProgram_horiz->Bind(); + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_vert); glBindVertexArray(m_ScreenQuad->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer); glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1 , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex); + m_GaussianFrameBuffer_horiz.Unbind(); } //final vertical gaussian after the iterations are done @@ -142,6 +147,7 @@ void DrawBloomPass::Draw(GLuint texture) m_GaussianFrameBuffer_vert.Bind(); m_GaussianProgram_vert->Bind(); + glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz); glBindVertexArray(m_ScreenQuad->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer); @@ -163,7 +169,7 @@ void DrawBloomPass::OnWindowResize() m_GaussianFrameBuffer_horiz.Generate(); } -void DrawBloomPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const +void DrawBloomPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) { glDeleteTextures(1, texture); glGenTextures(1, texture); diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index 85c9b97e..76ee9506 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -143,7 +143,6 @@ void Renderer::Draw(RenderFrame& frame) } PerformanceTimer::StartTimer("Renderer-AO generation"); m_SSAOPass->Draw(m_PickingPass->DepthBuffer(), frame.RenderScenes.front()->Camera); - GLuint ao = m_SSAOPass->SSAOTexture(); PerformanceTimer::StopTimer("Renderer-AO generation"); for (auto scene : frame.RenderScenes){ @@ -159,8 +158,8 @@ void Renderer::Draw(RenderFrame& frame) PerformanceTimer::StartTimerAndStopPrevious("Renderer-Light Culling"); m_LightCullingPass->CullLights(*scene); GLERROR("LightCulling"); + PerformanceTimer::StartTimerAndStopPrevious("Renderer-Draw Geometry+Light"); m_DrawFinalPass->Draw(*scene); - PerformanceTimer::StartTimerAndStopPrevious("Renderer-Draw Geometry+Light"); GLERROR("Draw Geometry+Light"); //m_DrawScenePass->Draw(*scene); diff --git a/src/Engine/Rendering/SSAOPass.cpp b/src/Engine/Rendering/SSAOPass.cpp index 495fcfc9..0ffa5647 100644 --- a/src/Engine/Rendering/SSAOPass.cpp +++ b/src/Engine/Rendering/SSAOPass.cpp @@ -21,8 +21,12 @@ void SSAOPass::ChangeQuality(int quality) if (m_Quality == 0) { glDeleteTextures(1, &m_SSAOTexture); glDeleteTextures(1, &m_SSAOViewSpaceZTexture); - glDeleteTextures(1, &m_GaussianTexture_horiz); - glDeleteTextures(1, &m_GaussianTexture_vert); + glDeleteTextures(1, &m_Gaussian_horiz); + glDeleteTextures(1, &m_Gaussian_vert); + m_SSAOTexture = 0; + m_SSAOViewSpaceZTexture = 0; + m_Gaussian_horiz = 0; + m_Gaussian_vert = 0; return; } @@ -88,8 +92,8 @@ void SSAOPass::InitializeTexture() { GenerateTexture(&m_SSAOTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RED, GL_FLOAT); GenerateTexture(&m_SSAOViewSpaceZTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R32F, GL_RED, GL_FLOAT); - GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RGB, GL_FLOAT); - GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RGB, GL_FLOAT); + GenerateTexture(&m_Gaussian_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RGB, GL_FLOAT); + GenerateTexture(&m_Gaussian_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RGB, GL_FLOAT); } void SSAOPass::InitializeBuffer() @@ -108,13 +112,13 @@ void SSAOPass::InitializeBuffer() if (m_GaussianFrameBuffer_horiz.GetHandle() == 0) { - m_GaussianFrameBuffer_horiz.AddResource(std::shared_ptr(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0))); + m_GaussianFrameBuffer_horiz.AddResource(std::shared_ptr(new Texture2D(&m_Gaussian_horiz, GL_COLOR_ATTACHMENT0))); } m_GaussianFrameBuffer_horiz.Generate(); if (m_GaussianFrameBuffer_vert.GetHandle() == 0) { - m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0))); + m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr(new Texture2D(&m_Gaussian_vert, GL_COLOR_ATTACHMENT0))); } m_GaussianFrameBuffer_vert.Generate(); @@ -157,7 +161,7 @@ void SSAOPass::Setting(float radius, float bias, float contrast, float intensity m_TextureQuality = quality; } -void SSAOPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const +void SSAOPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) { glDeleteTextures(1, texture); glGenTextures(1, texture); @@ -251,23 +255,27 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera) m_GaussianFrameBuffer_vert.Bind(); m_GaussianProgram_vert->Bind(); - glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, m_Gaussian_horiz); glBindVertexArray(m_ScreenQuad->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer); glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1 , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex); //horizontal pass + m_GaussianFrameBuffer_vert.Unbind(); m_GaussianFrameBuffer_horiz.Bind(); m_GaussianProgram_horiz->Bind(); - glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_vert); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, m_Gaussian_vert); glBindVertexArray(m_ScreenQuad->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer); glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1 , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex); + m_GaussianFrameBuffer_horiz.Unbind(); } //final vertical gaussian after the iterations are done @@ -275,12 +283,15 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera) m_GaussianFrameBuffer_vert.Bind(); m_GaussianProgram_vert->Bind(); - glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, m_Gaussian_horiz); glBindVertexArray(m_ScreenQuad->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer); glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1 , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex); + m_GaussianFrameBuffer_vert.Unbind(); + glViewport(0, 0, (m_Renderer->GetViewportSize().Width), (m_Renderer->GetViewportSize().Height)); } From 9cbc6f77556e559d3797060f3cc8e200d74369a8 Mon Sep 17 00:00:00 2001 From: Teejoon Date: Sun, 28 Feb 2016 16:16:22 +0100 Subject: [PATCH 080/252] Added GenerateTexture, GenerateMipMapTexture and DeleteTexture to CommonFunctions --- include/Engine/Rendering/DrawBloomPass.h | 2 - include/Engine/Rendering/DrawFinalPass.h | 3 -- include/Engine/Rendering/FrameBuffer.h | 9 ++++ include/Engine/Rendering/IRenderer.h | 1 + include/Engine/Rendering/SSAOPass.h | 2 - .../Engine/Rendering/Util/CommonFunctions.h | 3 ++ src/Engine/Rendering/DrawBloomPass.cpp | 25 +++-------- src/Engine/Rendering/DrawFinalPass.cpp | 42 ++++--------------- src/Engine/Rendering/FrameBuffer.cpp | 6 +++ src/Engine/Rendering/SSAOPass.cpp | 33 ++++----------- src/Engine/Rendering/Util/CommonFunctions.cpp | 33 +++++++++++++++ 11 files changed, 74 insertions(+), 85 deletions(-) diff --git a/include/Engine/Rendering/DrawBloomPass.h b/include/Engine/Rendering/DrawBloomPass.h index 4ddb7e05..ee3a8489 100644 --- a/include/Engine/Rendering/DrawBloomPass.h +++ b/include/Engine/Rendering/DrawBloomPass.h @@ -39,8 +39,6 @@ public: private: - void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type); - Texture* m_BlackTexture; Model* m_ScreenQuad; diff --git a/include/Engine/Rendering/DrawFinalPass.h b/include/Engine/Rendering/DrawFinalPass.h index e522cdc5..5e6f64b9 100644 --- a/include/Engine/Rendering/DrawFinalPass.h +++ b/include/Engine/Rendering/DrawFinalPass.h @@ -35,9 +35,6 @@ public: FrameBuffer* FinalPassFrameBufferLowRes() { return &m_FinalPassFrameBufferLowRes; } private: - void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const; - void GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const; - void DrawSprites(std::list>&jobs, RenderScene& scene); void DrawModelRenderQueues(std::list>& jobs, RenderScene& scene); void DrawShieldToStencilBuffer(std::list>& jobs, RenderScene& scene); diff --git a/include/Engine/Rendering/FrameBuffer.h b/include/Engine/Rendering/FrameBuffer.h index cf63b6c6..89418799 100644 --- a/include/Engine/Rendering/FrameBuffer.h +++ b/include/Engine/Rendering/FrameBuffer.h @@ -33,6 +33,15 @@ public: ~Texture2D(); }; +class Texture2DMultiSample : public ResourceType +{ +public: + Texture2DMultiSample(GLuint* resourceHandle, GLenum attachment) + : ResourceType(resourceHandle, attachment) { }; + + ~Texture2DMultiSample(); +}; + class RenderBuffer : public ResourceType { public: diff --git a/include/Engine/Rendering/IRenderer.h b/include/Engine/Rendering/IRenderer.h index 97293f06..2e6f3a97 100644 --- a/include/Engine/Rendering/IRenderer.h +++ b/include/Engine/Rendering/IRenderer.h @@ -11,6 +11,7 @@ #include "RenderQueue.h" #include "Model.h" #include "../Core/World.h" //So temp +#include "Util/CommonFunctions.h" struct PickData diff --git a/include/Engine/Rendering/SSAOPass.h b/include/Engine/Rendering/SSAOPass.h index a5f638cd..1cb28009 100644 --- a/include/Engine/Rendering/SSAOPass.h +++ b/include/Engine/Rendering/SSAOPass.h @@ -46,8 +46,6 @@ private: void InitializeShaderProgram(); void InitializeBuffer(); - void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type); - //void blurHorizontal(GLuint depthBuffer); //void blurVertical(GLuint depthBuffer); diff --git a/include/Engine/Rendering/Util/CommonFunctions.h b/include/Engine/Rendering/Util/CommonFunctions.h index e178f52d..7ff6e3f9 100644 --- a/include/Engine/Rendering/Util/CommonFunctions.h +++ b/include/Engine/Rendering/Util/CommonFunctions.h @@ -9,6 +9,9 @@ namespace CommonFunctions { Texture* LoadTexture(std::string path, bool threaded); +void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type); +void GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps); +void DeleteTexture(GLuint* texture); }; #endif \ No newline at end of file diff --git a/src/Engine/Rendering/DrawBloomPass.cpp b/src/Engine/Rendering/DrawBloomPass.cpp index 4fe885af..0216d940 100644 --- a/src/Engine/Rendering/DrawBloomPass.cpp +++ b/src/Engine/Rendering/DrawBloomPass.cpp @@ -24,8 +24,8 @@ void DrawBloomPass::ChangeQuality(int quality) m_ScreenQuad = ResourceManager::Load("Models/Core/ScreenQuad.mesh"); if (m_Quality == 0) { - glDeleteTextures(1, &m_GaussianTexture_horiz); - glDeleteTextures(1, &m_GaussianTexture_vert); + CommonFunctions::DeleteTexture(&m_GaussianTexture_horiz); + CommonFunctions::DeleteTexture(&m_GaussianTexture_vert); m_GaussianTexture_horiz = 0; m_GaussianTexture_vert = 0; return; @@ -59,14 +59,14 @@ void DrawBloomPass::InitializeShaderPrograms() void DrawBloomPass::InitializeBuffers() { - GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); + CommonFunctions::GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); if (m_GaussianFrameBuffer_horiz.GetHandle() == 0) { m_GaussianFrameBuffer_horiz.AddResource(std::shared_ptr(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0))); } m_GaussianFrameBuffer_horiz.Generate(); - GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); + CommonFunctions::GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); if (m_GaussianFrameBuffer_vert.GetHandle() == 0) { m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0))); } @@ -163,21 +163,8 @@ void DrawBloomPass::OnWindowResize() if (m_Quality == 0) { return; } - GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); + CommonFunctions::GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); m_GaussianFrameBuffer_vert.Generate(); - GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); + CommonFunctions::GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); m_GaussianFrameBuffer_horiz.Generate(); } - -void DrawBloomPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) -{ - glDeleteTextures(1, texture); - glGenTextures(1, texture); - glBindTexture(GL_TEXTURE_2D, *texture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering); - glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, dimensions.x, dimensions.y, 0, format, type, nullptr);//TODO: Renderer: Fix the precision and Resolution - GLERROR("Texture initialization failed"); -} diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 7b373452..017ba9ba 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -29,9 +29,9 @@ void DrawFinalPass::InitializeFrameBuffers() GLERROR("RenderBuffer generation"); - GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); + CommonFunctions::GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); //GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); - GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); + CommonFunctions::GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); //GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_FLOAT, 4); //GenerateTexture(&m_StencilTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_STENCIL, GL_STENCIL_INDEX8, GL_INT); @@ -47,9 +47,9 @@ void DrawFinalPass::InitializeFrameBuffers() glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, (int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)); GLERROR("RenderBufferLowRes generation"); - GenerateTexture(&m_SceneTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), GL_RGB16F, GL_RGB, GL_FLOAT); + CommonFunctions::GenerateTexture(&m_SceneTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), GL_RGB16F, GL_RGB, GL_FLOAT); //GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); - GenerateTexture(&m_BloomTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), GL_RGB16F, GL_RGB, GL_FLOAT); + CommonFunctions::GenerateTexture(&m_BloomTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), GL_RGB16F, GL_RGB, GL_FLOAT); //GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_FLOAT, 4); //GenerateTexture(&m_StencilTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_STENCIL, GL_STENCIL_INDEX8, GL_INT); @@ -300,46 +300,20 @@ void DrawFinalPass::OnWindowResize() glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); - GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); - GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); + CommonFunctions::GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); + CommonFunctions::GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); m_FinalPassFrameBuffer.Generate(); glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBufferLowRes); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, (int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)); - GenerateTexture(&m_SceneTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), GL_RGB16F, GL_RGB, GL_FLOAT); - GenerateTexture(&m_BloomTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), GL_RGB16F, GL_RGB, GL_FLOAT); + CommonFunctions::GenerateTexture(&m_SceneTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), GL_RGB16F, GL_RGB, GL_FLOAT); + CommonFunctions::GenerateTexture(&m_BloomTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), GL_RGB16F, GL_RGB, GL_FLOAT); m_FinalPassFrameBufferLowRes.Generate(); GLERROR("Error changing texture resolutions"); } -void DrawFinalPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const -{ - glGenTextures(1, texture); - glBindTexture(GL_TEXTURE_2D, *texture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering); - glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, dimensions.x, dimensions.y, 0, format, type, nullptr);//TODO: Renderer: Fix the precision and Resolution - GLERROR("Texture initialization failed"); -} - -void DrawFinalPass::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const -{ - glGenTextures(1, texture); - glBindTexture(GL_TEXTURE_2D, *texture); - glTexStorage2D(GL_TEXTURE_2D, numMipMaps, GL_RGBA8, dimensions.x, dimensions.y); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, dimensions.x, dimensions.y, format, type, texture); - glGenerateMipmap(GL_TEXTURE_2D); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - GLERROR("MipMap Texture initialization failed"); -} - void DrawFinalPass::DrawModelRenderQueues(std::list>& jobs, RenderScene& scene) { GLuint forwardHandle = m_ForwardPlusProgram->GetHandle(); diff --git a/src/Engine/Rendering/FrameBuffer.cpp b/src/Engine/Rendering/FrameBuffer.cpp index 9ba0d2d8..8638ebca 100644 --- a/src/Engine/Rendering/FrameBuffer.cpp +++ b/src/Engine/Rendering/FrameBuffer.cpp @@ -16,6 +16,12 @@ Texture2D::~Texture2D() } } +Texture2DMultiSample::~Texture2DMultiSample() +{ + if (m_ResourceHandle != 0) { + glDeleteTextures(1, m_ResourceHandle); + } +} RenderBuffer::~RenderBuffer() { diff --git a/src/Engine/Rendering/SSAOPass.cpp b/src/Engine/Rendering/SSAOPass.cpp index 0ffa5647..8515cf95 100644 --- a/src/Engine/Rendering/SSAOPass.cpp +++ b/src/Engine/Rendering/SSAOPass.cpp @@ -19,14 +19,10 @@ void SSAOPass::ChangeQuality(int quality) m_Quality = quality; if (m_Quality == 0) { - glDeleteTextures(1, &m_SSAOTexture); - glDeleteTextures(1, &m_SSAOViewSpaceZTexture); - glDeleteTextures(1, &m_Gaussian_horiz); - glDeleteTextures(1, &m_Gaussian_vert); - m_SSAOTexture = 0; - m_SSAOViewSpaceZTexture = 0; - m_Gaussian_horiz = 0; - m_Gaussian_vert = 0; + CommonFunctions::DeleteTexture(&m_SSAOTexture); + CommonFunctions::DeleteTexture(&m_SSAOViewSpaceZTexture); + CommonFunctions::DeleteTexture(&m_Gaussian_horiz); + CommonFunctions::DeleteTexture(&m_Gaussian_vert); return; } @@ -89,11 +85,11 @@ void SSAOPass::InitializeShaderProgram() } void SSAOPass::InitializeTexture() { - GenerateTexture(&m_SSAOTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RED, GL_FLOAT); - GenerateTexture(&m_SSAOViewSpaceZTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R32F, GL_RED, GL_FLOAT); + CommonFunctions::GenerateTexture(&m_SSAOTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RED, GL_FLOAT); + CommonFunctions::GenerateTexture(&m_SSAOViewSpaceZTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R32F, GL_RED, GL_FLOAT); - GenerateTexture(&m_Gaussian_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RGB, GL_FLOAT); - GenerateTexture(&m_Gaussian_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RGB, GL_FLOAT); + CommonFunctions::GenerateTexture(&m_Gaussian_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RGB, GL_FLOAT); + CommonFunctions::GenerateTexture(&m_Gaussian_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RGB, GL_FLOAT); } void SSAOPass::InitializeBuffer() @@ -161,19 +157,6 @@ void SSAOPass::Setting(float radius, float bias, float contrast, float intensity m_TextureQuality = quality; } -void SSAOPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) -{ - glDeleteTextures(1, texture); - glGenTextures(1, texture); - glBindTexture(GL_TEXTURE_2D, *texture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering); - glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, dimensions.x, dimensions.y, 0, format, type, nullptr); - GLERROR("Texture initialization failed"); -} - void SSAOPass::Draw(GLuint depthBuffer, Camera* camera) { if (m_Quality == 0) { diff --git a/src/Engine/Rendering/Util/CommonFunctions.cpp b/src/Engine/Rendering/Util/CommonFunctions.cpp index 382cb790..5c5c449e 100644 --- a/src/Engine/Rendering/Util/CommonFunctions.cpp +++ b/src/Engine/Rendering/Util/CommonFunctions.cpp @@ -17,3 +17,36 @@ Texture* CommonFunctions::LoadTexture(std::string path, bool threaded) return img; } + +void CommonFunctions::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) +{ + glDeleteTextures(1, texture); + glGenTextures(1, texture); + glBindTexture(GL_TEXTURE_2D, *texture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering); + glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, dimensions.x, dimensions.y, 0, format, type, nullptr); + GLERROR("Texture initialization failed"); +} + +void CommonFunctions::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) +{ + glGenTextures(1, texture); + glBindTexture(GL_TEXTURE_2D, *texture); + glTexStorage2D(GL_TEXTURE_2D, numMipMaps, GL_RGBA8, dimensions.x, dimensions.y); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, dimensions.x, dimensions.y, format, type, texture); + glGenerateMipmap(GL_TEXTURE_2D); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + GLERROR("MipMap Texture initialization failed"); +} + +void CommonFunctions::DeleteTexture(GLuint* texture) +{ + glDeleteTextures(1, texture); + *texture = 0; +} \ No newline at end of file From 144e548b7a660ff1e58d2f881692efbc3fe6b91f Mon Sep 17 00:00:00 2001 From: Tleety Date: Sun, 28 Feb 2016 17:17:24 +0100 Subject: [PATCH 081/252] Added AbilityCooldownHUD component and system to track the cooldown on the dashability, this needs to be extended for other abilities when they are implemented. However current dash time needs to be included into the component, since we can currently just see the max cooldown time. --- .../Game/Systems/AbilityCooldownHUDSystem.h | 17 + resources/Schema/Components.xsd | 1 + .../Schema/Components/AbilityCooldownHUD.xml | 3 + .../Schema/Components/AbilityCooldownHUD.xsd | 9 + resources/Schema/Entities/PlayerRed.xml | 91 ++- .../Schema/Entities/QualityAssurance.xml | 730 +++++++++++++++++- resources/Schema/Types/Entity.xsd | 1 + src/Game/Game.cpp | 2 + src/Game/Systems/AbilityCooldownHUDSystem.cpp | 28 + 9 files changed, 835 insertions(+), 47 deletions(-) create mode 100644 include/Game/Systems/AbilityCooldownHUDSystem.h create mode 100644 resources/Schema/Components/AbilityCooldownHUD.xml create mode 100644 resources/Schema/Components/AbilityCooldownHUD.xsd create mode 100644 src/Game/Systems/AbilityCooldownHUDSystem.cpp diff --git a/include/Game/Systems/AbilityCooldownHUDSystem.h b/include/Game/Systems/AbilityCooldownHUDSystem.h new file mode 100644 index 00000000..610b4dc2 --- /dev/null +++ b/include/Game/Systems/AbilityCooldownHUDSystem.h @@ -0,0 +1,17 @@ +#ifndef AbilityCooldownHUDSystem_h__ +#define AbilityCooldownHUDSystem_h__ + +#include "../../Engine/Core/System.h" +#include "../../Engine/GLM.h" + +class AbilityCooldownHUDSystem : public ImpureSystem +{ +public: + AbilityCooldownHUDSystem(SystemParams params) + : System(params) + { } + + virtual void Update(double dt) override; +}; + +#endif \ No newline at end of file diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index 42abed82..b90a445d 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -46,4 +46,5 @@ + \ No newline at end of file diff --git a/resources/Schema/Components/AbilityCooldownHUD.xml b/resources/Schema/Components/AbilityCooldownHUD.xml new file mode 100644 index 00000000..8f91bbc3 --- /dev/null +++ b/resources/Schema/Components/AbilityCooldownHUD.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/resources/Schema/Components/AbilityCooldownHUD.xsd b/resources/Schema/Components/AbilityCooldownHUD.xsd new file mode 100644 index 00000000..066a9442 --- /dev/null +++ b/resources/Schema/Components/AbilityCooldownHUD.xsd @@ -0,0 +1,9 @@ + + + + + + HUD element for tracking ability cooldown + + + \ No newline at end of file diff --git a/resources/Schema/Entities/PlayerRed.xml b/resources/Schema/Entities/PlayerRed.xml index d56fa3c1..1e419b4d 100644 --- a/resources/Schema/Entities/PlayerRed.xml +++ b/resources/Schema/Entities/PlayerRed.xml @@ -23,7 +23,9 @@ - + + + @@ -111,6 +113,7 @@ Textures/HealthHUD3.png + false @@ -121,7 +124,55 @@ - + + + + + + 1 + + + + Textures/Core/White.png + false + + + + + + + + + + + + + + 2.0 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + Textures/Props/FoliageDiff.png + false + + + + + + + + + @@ -137,6 +188,7 @@ Textures/Core/UnitHexagon.png + false @@ -155,6 +207,7 @@ Textures/Core/UnitHexagon_Rotated.png + false @@ -171,6 +224,7 @@ Textures/Core/UnitHexagon.png + false @@ -185,11 +239,11 @@ 3 - 0.80222018197612788 Textures/Core/UnitHexagon_Rotated.png + false @@ -206,6 +260,7 @@ Textures/Core/UnitHexagon.png + false @@ -220,10 +275,12 @@ 4 + 1 Textures/Core/UnitHexagon_Rotated.png + false @@ -240,6 +297,7 @@ Textures/Core/UnitHexagon.png + false @@ -258,6 +316,7 @@ Textures/Core/UnitHexagon_Rotated.png + false @@ -274,8 +333,9 @@ Textures/Core/UnitHexagon.png + false - + @@ -286,16 +346,18 @@ - + 1 + Textures/Core/UnitHexagon_Rotated.png + false - + @@ -364,7 +426,7 @@ Idle - 1.2667383999985162 + 1.2417589624457968 1 @@ -385,8 +447,8 @@ Models/Weapons/Red/AssaultWeaponRed.mesh - - + + @@ -492,10 +554,13 @@ - Idle - 0.26532318661337229 + Run + 0.012377234178668317 1 + 1 + 0.5 + 1.8342275085993549 @@ -519,8 +584,8 @@ Models/Weapons/Red/AssaultWeaponRed.mesh - - + + diff --git a/resources/Schema/Entities/QualityAssurance.xml b/resources/Schema/Entities/QualityAssurance.xml index 0aa2fbe7..3f880c91 100644 --- a/resources/Schema/Entities/QualityAssurance.xml +++ b/resources/Schema/Entities/QualityAssurance.xml @@ -40,7 +40,7 @@ - + @@ -93,7 +93,7 @@ - + @@ -108,7 +108,11 @@ - + + + + + Models/Characters/Assault/AssaultAnimated.mesh @@ -120,7 +124,11 @@ - + + + + + Models/Characters/Assault/AssaultAnimated.mesh @@ -168,21 +176,643 @@ - + - + - - - Models/Characters/Assault/AssaultAnimated.mesh - + + + + + + 600 + + + + + + + + + 5 + + + + + + - + + + + + + + + + + + + + Models/Widgets/Camera.mesh + false + + + + + + + + + + + + + + + + + + + Textures/Weapons/Crosshair/SmallThickHoleDot.png + false + + + + + + + + + + + + + Schema/Entities/HitMarker.xml + + + + + + + + + + + + + + 1 + + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + 1 + + + + Textures/HealthHUD3.png + + + + + + + + + + + + + + + Textures/Test/SmallDiff.png + false + + + + + + + + + + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 2 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 3 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 4 + + + 1 + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 1 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + 1 + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + Idle + 1.0970008697500191 + 1 + + + + + Models/Characters/Assault/FirstPerson.mesh + + + + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Red/AssaultWeaponRed.mesh + + + + + + + + + + + Schema/Entities/RayRed.xml + + + + + + + + + + + Schema/Entities/ReloadEffectViewRed.xml + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + + + + 32 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + 360 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + + + + Models/Widgets/Camera.mesh + false + + + + + + + + + + + + Run + 0.86761914148289065 + 1 + 1 + + 0.5 + 1.8342275085993549 + + + + AimRifle + + + + + Models/Characters/Assault/AssaultAnimations.mesh + + + + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Red/AssaultWeaponRed.mesh + + + + + + + + + + + Schema/Entities/RayRed.xml + + + + + + + + + + + Schema/Entities/ReloadEffectWorldRed.xml + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + false + + + + + + + + + + + + Models/Core/UnitCube.mesh + + false + + + + + + + + + + + Insert name here + Fonts/DroidSans.ttf,100 + + + + + + + + + + + + + + Textures/Icons/Arrow.png + false + + + + + + 50 + true + + + + + + + + + @@ -213,7 +843,7 @@ - + @@ -277,7 +907,7 @@ - + @@ -309,7 +939,7 @@ - + @@ -659,7 +1289,7 @@ - + @@ -706,7 +1336,7 @@ - + @@ -766,7 +1396,7 @@ - + @@ -813,7 +1443,7 @@ - + @@ -859,7 +1489,7 @@ - + @@ -906,7 +1536,7 @@ - + @@ -953,7 +1583,7 @@ - + @@ -1367,7 +1997,7 @@ - + @@ -1376,7 +2006,7 @@ true - 0.8256214817261025 + 2.8360836966480178 3.7999999523162842 true @@ -1423,7 +2053,7 @@ - + @@ -1432,7 +2062,7 @@ - 1.8641349174045843 + 1.47485045667446 Models/Characters/Assault/AssaultTPose.mesh @@ -1475,18 +2105,22 @@ - + - + + + + + true - 1.8641349174045843 + 1.47485045667446 true @@ -1531,7 +2165,7 @@ - + @@ -1541,7 +2175,7 @@ true - 1.2301962937648341 + 8.7351898541697892 10 3 @@ -1589,7 +2223,7 @@ - + @@ -1599,7 +2233,7 @@ true - 3.4214855659573402 + 4.5370673150397351 true 5 true @@ -1712,6 +2346,7 @@ + Fonts/DroidSans.ttf,100 @@ -1780,7 +2415,7 @@ true - 0.8256214817261025 + 2.8360836966480178 3.7999999523162842 true @@ -1823,7 +2458,11 @@ - + + + + + @@ -1925,6 +2564,7 @@ Textures/Props/FoliageDiff.png + @@ -1934,6 +2574,7 @@ Textures/Props/FoliageDiff.png + @@ -1954,6 +2595,7 @@ Textures/Core/UnitHexagon.png + @@ -1971,6 +2613,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -1986,6 +2629,7 @@ Textures/Core/UnitHexagon.png + @@ -2003,6 +2647,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -2018,6 +2663,7 @@ Textures/Core/UnitHexagon.png + @@ -2036,6 +2682,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -2051,6 +2698,7 @@ Textures/Core/UnitHexagon.png + @@ -2068,6 +2716,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -2083,6 +2732,7 @@ Textures/Core/UnitHexagon.png + @@ -2099,6 +2749,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -2167,6 +2818,7 @@ Textures/Core/ErrorTexture.png + @@ -2178,6 +2830,7 @@ Textures/Core/White.png + @@ -2206,6 +2859,7 @@ Textures/Core/White.png + @@ -2234,6 +2888,7 @@ Textures/Core/White.png + @@ -2262,6 +2917,7 @@ Textures/Core/White.png + @@ -2290,6 +2946,7 @@ Textures/Core/White.png + @@ -2331,6 +2988,7 @@ Textures/Core/ErrorTexture.png + @@ -2342,6 +3000,7 @@ Textures/Core/White.png + @@ -2370,6 +3029,7 @@ Textures/Core/White.png + @@ -2398,6 +3058,7 @@ Textures/Core/White.png + @@ -2426,6 +3087,7 @@ Textures/Core/White.png + diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index a9c5f641..d2887e95 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -50,6 +50,7 @@ + diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 24b7cd1e..f98bcb4c 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -25,6 +25,7 @@ #include "Rendering/AnimationSystem.h" #include "Network/MultiplayerSnapshotFilter.h" #include "Game/Systems/AmmunitionHUDSystem.h" +#include "Game/Systems/AbilityCooldownHUDSystem.h" #include "Game/Systems/KillFeedSystem.h" #include "GUI/ButtonSystem.h" #include "GUI/MainMenuSystem.h" @@ -128,6 +129,7 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); + m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer); m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer); diff --git a/src/Game/Systems/AbilityCooldownHUDSystem.cpp b/src/Game/Systems/AbilityCooldownHUDSystem.cpp new file mode 100644 index 00000000..12d268c7 --- /dev/null +++ b/src/Game/Systems/AbilityCooldownHUDSystem.cpp @@ -0,0 +1,28 @@ +#include "Game/Systems/AbilityCooldownHUDSystem.h" + +void AbilityCooldownHUDSystem::Update(double dt) +{ + //HUD element for tracking cooldown on the parent entity with Dashability TODO: Make sure it support other abilities when they are made. + + auto abilityHUDs = m_World->GetComponents("AbilityCooldownHUD"); + if (abilityHUDs == nullptr) + return; + + for (auto& abilityHUDC : *abilityHUDs) { + EntityWrapper entity = EntityWrapper(m_World, abilityHUDC.EntityID); + EntityWrapper abilityEntity = entity.FirstParentWithComponent("DashAbility"); + if (!abilityEntity.Valid()) + return; + EntityWrapper cooldownTextEntity = entity.FirstChildByName("Cooldown"); + if(cooldownTextEntity.Valid()) { + if(cooldownTextEntity.HasComponent("Text")) + { + double abilityCD = (double)abilityEntity["DashAbility"]["CoolDownMaxTimer"]; + std::string t = (std::string&)cooldownTextEntity["Text"]["Content"] = std::to_string(abilityCD).substr(0, 3); + if(entity.HasComponent("Fill")) { + entity["Fill"]["Percentage"] = abilityCD/abilityCD; //TODO: current time needs to be in the component. + } + } + } + } +} From 6dd7f1a657147ad8b8134ab6cd48b0f846949b3b Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Sun, 28 Feb 2016 18:00:23 +0100 Subject: [PATCH 082/252] Buggy transparent shadows. Transparent textures might glow. --- include/Engine/Rendering/ShadowPass.h | 3 +++ resources/Schema/Entities/QualityAssurance.xml | 4 ++-- resources/Shaders/ForwardPlus.frag.glsl | 4 ++-- resources/Shaders/Shadow.frag.glsl | 16 +++++++++++++++- resources/Shaders/Shadow.vert.glsl | 8 +++++++- src/Engine/Rendering/Renderer.cpp | 10 +--------- src/Engine/Rendering/ShadowPass.cpp | 11 +++++++++++ src/Engine/Rendering/ShadowPassState.cpp | 2 ++ 8 files changed, 43 insertions(+), 15 deletions(-) diff --git a/include/Engine/Rendering/ShadowPass.h b/include/Engine/Rendering/ShadowPass.h index a26ddf97..c4007cce 100644 --- a/include/Engine/Rendering/ShadowPass.h +++ b/include/Engine/Rendering/ShadowPass.h @@ -62,6 +62,7 @@ private: GLuint m_DepthMap; FrameBuffer m_DepthBuffer; ShaderProgram* m_ShadowProgram; + //ShaderProgram* m_TransparentShadowProgram; std::array m_LightProjection; std::array m_LightView; @@ -74,6 +75,8 @@ private: float m_SplitWeight = 0.91f; std::array m_shadowFrusta; + + Texture* m_WhiteTexture = ResourceManager::Load("Textures/Core/White.png"); }; #endif \ No newline at end of file diff --git a/resources/Schema/Entities/QualityAssurance.xml b/resources/Schema/Entities/QualityAssurance.xml index 04dfc6aa..86281abd 100644 --- a/resources/Schema/Entities/QualityAssurance.xml +++ b/resources/Schema/Entities/QualityAssurance.xml @@ -568,8 +568,8 @@ - Models/Core/UnitCube.mesh - + Models/BushAlive.mesh + true diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 8250d96d..c3e1a681 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -327,8 +327,8 @@ void main() totalLighting.Specular += light_result.Specular; } - totalLighting.Diffuse *= (1.5 + vec4(AmbientColor.rgb, 1.0)) - vec4(vec3(shadowFactor), 0.0); - totalLighting.Specular *= (1.5 + vec4(AmbientColor.rgb, 1.0)) - vec4(vec3(shadowFactor), 0.0); + totalLighting.Diffuse *= (1.0 + vec4(AmbientColor.rgba)) - vec4(vec3(shadowFactor), 0.0); + totalLighting.Specular *= (1.0 + vec4(AmbientColor.rgba)) - vec4(vec3(shadowFactor), 0.0); //LightResult getInformation; diff --git a/resources/Shaders/Shadow.frag.glsl b/resources/Shaders/Shadow.frag.glsl index 58290b59..3287df7c 100644 --- a/resources/Shaders/Shadow.frag.glsl +++ b/resources/Shaders/Shadow.frag.glsl @@ -1,10 +1,24 @@ #version 430 -layout(location = 0 ) out float ShadowMap; +#define ALPHA_CUTOFF 0.3 + +layout (binding = 12) uniform sampler2D DiffuseTexture; +uniform float Alpha; + +in VertexData{ + vec2 TextureCoordinate; +}Input; + +layout (location = 0) out float ShadowMap; void main() { + vec4 diffuseTexel = texture(DiffuseTexture, Input.TextureCoordinate) * Alpha; + if (diffuseTexel.a < ALPHA_CUTOFF) + { + discard; + } } diff --git a/resources/Shaders/Shadow.vert.glsl b/resources/Shaders/Shadow.vert.glsl index 8a0dc8f4..7b1b26fb 100644 --- a/resources/Shaders/Shadow.vert.glsl +++ b/resources/Shaders/Shadow.vert.glsl @@ -4,9 +4,15 @@ uniform mat4 M; uniform mat4 V; uniform mat4 P; -layout(location = 0) in vec3 Position; +layout (location = 0) in vec3 Position; +layout (location = 4) in vec2 TextureCoords; + +out VertexData{ + vec2 TextureCoordinate; +}Output; void main() { gl_Position = P * V * M * vec4(Position, 1.0); + Output.TextureCoordinate = TextureCoords; } \ No newline at end of file diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index cc6ab11b..cdbd5786 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -68,14 +68,6 @@ void Renderer::InitializeShaders() { m_BasicForwardProgram = ResourceManager::Load("#m_BasicForwardProgram"); m_ExplosionEffectProgram = ResourceManager::Load("#ExplosionEffectProgram"); - //m_ExplosionEffectProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/ExplosionEffect.vert.glsl"))); - //m_ExplosionEffectProgram->AddShader(std::shared_ptr(new GeometryShader("Shaders/ExplosionEffect.geom.glsl"))); - //m_ExplosionEffectProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/ExplosionEffect.frag.glsl"))); - //m_ExplosionEffectProgram->Compile(); - //m_ExplosionEffectProgram->Link(); - - - } void Renderer::InputUpdate(double dt) @@ -93,7 +85,7 @@ void Renderer::Update(double dt) void Renderer::Draw(RenderFrame& frame) { - ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0Gaussian\0Picking\0Shadow"); + ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0Gaussian\0Picking"); //clear buffer 0 glClearColor(0.f, 0.f, 0.f, 0.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index be09626d..c0ee1e54 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -147,6 +147,8 @@ void ShadowPass::InitializeShaderPrograms() m_ShadowProgram->Compile(); m_ShadowProgram->BindFragDataLocation(0, "ShadowMap"); m_ShadowProgram->Link(); + + } void ShadowPass::ClearBuffer() @@ -241,6 +243,15 @@ void ShadowPass::Draw(RenderScene & scene) auto modelJob = std::dynamic_pointer_cast(objectJob); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); + glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), modelJob->Color.a); + + glActiveTexture(GL_TEXTURE12); + if (modelJob->DiffuseTexture != nullptr) { + glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture->m_Texture); + } + else { + glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); + } glBindVertexArray(modelJob->Model->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer); diff --git a/src/Engine/Rendering/ShadowPassState.cpp b/src/Engine/Rendering/ShadowPassState.cpp index 67e0dd1f..ef789487 100644 --- a/src/Engine/Rendering/ShadowPassState.cpp +++ b/src/Engine/Rendering/ShadowPassState.cpp @@ -9,6 +9,8 @@ ShadowPassState::ShadowPassState(GLuint frameBuffer) Disable(GL_TEXTURE_2D); CullFace(GL_FRONT); ClearColor(glm::vec4(0.f, 0.f, 0.f, 0.f)); + //Enable(GL_ALPHA_TEST); + //glAlphaFunc(GL_GREATER, 0.9f); } ShadowPassState::~ShadowPassState() From 7749fc5474d893c20ab5c09782cd3f4bb8b42910 Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Sun, 28 Feb 2016 19:46:50 +0100 Subject: [PATCH 083/252] Small fixing up --- resources/Shaders/ForwardPlus.frag.glsl | 14 ++++--- resources/Shaders/Shadow.frag.glsl | 2 +- src/Engine/Rendering/ShadowPass.cpp | 54 +++++++++++++++---------- 3 files changed, 41 insertions(+), 29 deletions(-) diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index c3e1a681..3b94df9e 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -211,19 +211,21 @@ float CalcShadowValue(vec4 light_space_pos, vec3 normal, vec3 light_dir, sampler // Various bias methods. //bias = max(0.05 * (1.0 - dot(normal, light_dir)), bias); - bias = bias * tan(acos(clamp(dot(normal, -light_dir), 0.0, 1.0))); + //bias = bias * tan(acos(clamp(dot(normal, -light_dir), 0.0, 1.0))); + bias = bias + bias * tan(acos(clamp(dot(normal, -light_dir), 0.0, 1.0))); // Calculate coordinates in projection space. vec3 projCoords = vec3(light_space_pos.xy, light_space_pos.z + bias) / light_space_pos.w; projCoords = projCoords * 0.5 + 0.5; + //projCoords = (floor(projCoords * 255.0)) / 255.0; // Various methods for shadow calculation in fastest to slowest order. - shadowMapDepth = PCFShadow(depth_texture_array, projCoords, layer_index); + //shadowMapDepth = PCFShadow(depth_texture_array, projCoords, layer_index); //shadowMapDepth = PoissonShadow(depth_texture_array, projCoords, layer_index, 4, 25.0 * FarDistance[MAX_SPLITS - 1]); - //shadowMapDepth = PoissonDotShadow(depth_texture_array, projCoords, layer_index, 4, 25.0 * FarDistance[MAX_SPLITS]); - //shadowMapDepth = SoftwarePCF(depth_texture_array, projCoords, layer_index, bias); + //shadowMapDepth = PoissonDotShadow(depth_texture_array, projCoords, layer_index, 4, 25.0 * FarDistance[MAX_SPLITS - 1]); + shadowMapDepth = SoftwarePCF(depth_texture_array, projCoords, layer_index, bias); return 1.0 - shadowMapDepth; } @@ -327,8 +329,8 @@ void main() totalLighting.Specular += light_result.Specular; } - totalLighting.Diffuse *= (1.0 + vec4(AmbientColor.rgba)) - vec4(vec3(shadowFactor), 0.0); - totalLighting.Specular *= (1.0 + vec4(AmbientColor.rgba)) - vec4(vec3(shadowFactor), 0.0); + totalLighting.Diffuse *= (1.5 + vec4(AmbientColor.rgba)) - vec4(vec3(shadowFactor), 0.0); + totalLighting.Specular *= (1.5 + vec4(AmbientColor.rgba)) - vec4(vec3(shadowFactor), 0.0); //LightResult getInformation; diff --git a/resources/Shaders/Shadow.frag.glsl b/resources/Shaders/Shadow.frag.glsl index 3287df7c..a03e17c7 100644 --- a/resources/Shaders/Shadow.frag.glsl +++ b/resources/Shaders/Shadow.frag.glsl @@ -2,7 +2,7 @@ #define ALPHA_CUTOFF 0.3 -layout (binding = 12) uniform sampler2D DiffuseTexture; +layout (binding = 24) uniform sampler2D DiffuseTexture; uniform float Alpha; in VertexData{ diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index c0ee1e54..185d24ab 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -186,6 +186,8 @@ void ShadowPass::PointsToLightspace(Frustum& frustum, glm::mat4 v) void ShadowPass::RadiusToLightspace(Frustum& frustum) { + float quantizationStep = 1.0f / m_ResolutionSizeHeight; + float left = -frustum.Radius; float right = frustum.Radius; float bottom = -frustum.Radius; @@ -219,6 +221,8 @@ void ShadowPass::Draw(RenderScene & scene) m_LightView[i] = glm::lookAt(glm::vec3(-directionalLightJob->Direction) + m_shadowFrusta[i].MiddlePoint, m_shadowFrusta[i].MiddlePoint, glm::vec3(0.f, 1.f, 0.f)); PointsToLightspace(m_shadowFrusta[i], m_LightView[i]); + //FindRadius(m_shadowFrusta[i]); + //RadiusToLightspace(m_shadowFrusta[i]); m_LightProjection[i] = glm::ortho(m_shadowFrusta[i].LRBT[LEFT], m_shadowFrusta[i].LRBT[RIGHT], m_shadowFrusta[i].LRBT[BOTTOM], m_shadowFrusta[i].LRBT[TOP], m_NearFarPlane[NEAR], m_NearFarPlane[FAR]); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection[i])); @@ -227,37 +231,43 @@ void ShadowPass::Draw(RenderScene & scene) GLERROR("ShadowLight ERROR"); for (auto &objectJob : scene.OpaqueObjects) { - auto modelJob = std::dynamic_pointer_cast(objectJob); + if (!std::dynamic_pointer_cast(objectJob)) + { + auto modelJob = std::dynamic_pointer_cast(objectJob); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); - 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))); + 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("Shadow Draw ERROR"); + GLERROR("Shadow Draw ERROR"); + } } state->CullFace(GL_BACK); for (auto &objectJob : scene.TransparentObjects) { - auto modelJob = std::dynamic_pointer_cast(objectJob); + if (!std::dynamic_pointer_cast(objectJob)) + { + auto modelJob = std::dynamic_pointer_cast(objectJob); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); - glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), modelJob->Color.a); - - glActiveTexture(GL_TEXTURE12); - if (modelJob->DiffuseTexture != nullptr) { - glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture->m_Texture); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); + glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), modelJob->Color.a); + + glActiveTexture(GL_TEXTURE24); + if (modelJob->DiffuseTexture != nullptr) { + glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture->m_Texture); + } + else { + glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); + } + + 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("Shadow Draw ERROR"); } - else { - glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); - } - - 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("Shadow Draw ERROR"); } state->CullFace(GL_FRONT); } From bb76c9d248bb94d503e5331c25bcf55d567f2a01 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 25 Feb 2016 16:24:38 +0100 Subject: [PATCH 084/252] WIP multi-weapon behaviours --- include/Engine/Core/EntityWrapper.h | 4 + include/Engine/Core/System.h | 2 +- .../Systems/Weapon/AssaultWeaponBehaviour.h | 30 +-- .../Systems/Weapon/DefenderWeaponBehaviour.h | 38 +++ include/Game/Systems/Weapon/WeaponBehaviour.h | 173 +++++++++++- resources/Schema/Components.xsd | 2 + resources/Schema/Components/AssaultWeapon.xml | 1 + resources/Schema/Components/AssaultWeapon.xsd | 2 + .../Schema/Components/DefenderWeapon.xml | 16 ++ .../Schema/Components/DefenderWeapon.xsd | 44 +++ resources/Schema/Components/Player.xml | 1 + resources/Schema/Components/Player.xsd | 1 + resources/Schema/Components/Weapon.xml | 3 - resources/Schema/Components/Weapon.xsd | 17 -- .../Schema/Components/WeaponAttachment.xml | 5 + .../Schema/Components/WeaponAttachment.xsd | 28 ++ .../Schema/Entities/AssaultWeaponView.xml | 99 +++++++ .../Schema/Entities/AssaultWeaponWorld.xml | 40 +++ resources/Schema/Entities/DefenderShield.xml | 40 +++ .../Schema/Entities/DefenderWeaponView.xml | 99 +++++++ .../Schema/Entities/DefenderWeaponViewRed.xml | 99 +++++++ .../Schema/Entities/DefenderWeaponWorld.xml | 41 +++ .../Entities/DefenderWeaponWorldRed.xml | 41 +++ resources/Schema/Entities/MovementTest.xml | 253 +----------------- resources/Schema/Entities/Player.xml | 204 +++++--------- resources/Schema/Entities/PlayerRed.xml | 209 ++++++--------- resources/Schema/Types/Entity.xsd | 2 + resources/Schema/Types/WeaponSlotEnum.xsd | 16 ++ src/Engine/Core/EntityWrapper.cpp | 43 +++ src/Engine/Core/Util/Logging.cpp | 4 +- src/Game/Game.cpp | 8 +- .../Network/MultiplayerSnapshotFilter.cpp | 1 + src/Game/Systems/DamageIndicatorSystem.cpp | 2 +- ...aviour.cpp => AssaultWeaponBehaviour.cpp_} | 52 ++-- .../Weapon/DefenderWeaponBehaviour.cpp | 188 +++++++++++++ .../{WeaponSystem.cpp => WeaponSystem.cpp_} | 56 +++- 36 files changed, 1251 insertions(+), 613 deletions(-) create mode 100644 include/Game/Systems/Weapon/DefenderWeaponBehaviour.h create mode 100755 resources/Schema/Components/DefenderWeapon.xml create mode 100755 resources/Schema/Components/DefenderWeapon.xsd delete mode 100644 resources/Schema/Components/Weapon.xml delete mode 100644 resources/Schema/Components/Weapon.xsd create mode 100644 resources/Schema/Components/WeaponAttachment.xml create mode 100644 resources/Schema/Components/WeaponAttachment.xsd create mode 100755 resources/Schema/Entities/AssaultWeaponView.xml create mode 100755 resources/Schema/Entities/AssaultWeaponWorld.xml create mode 100755 resources/Schema/Entities/DefenderShield.xml create mode 100755 resources/Schema/Entities/DefenderWeaponView.xml create mode 100755 resources/Schema/Entities/DefenderWeaponViewRed.xml create mode 100755 resources/Schema/Entities/DefenderWeaponWorld.xml create mode 100755 resources/Schema/Entities/DefenderWeaponWorldRed.xml mode change 100644 => 100755 resources/Schema/Entities/PlayerRed.xml create mode 100644 resources/Schema/Types/WeaponSlotEnum.xsd rename src/Game/Systems/Weapon/{AssaultWeaponBehaviour.cpp => AssaultWeaponBehaviour.cpp_} (87%) create mode 100644 src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp rename src/Game/Systems/Weapon/{WeaponSystem.cpp => WeaponSystem.cpp_} (56%) diff --git a/include/Engine/Core/EntityWrapper.h b/include/Engine/Core/EntityWrapper.h index 4643e28b..8ece8e59 100644 --- a/include/Engine/Core/EntityWrapper.h +++ b/include/Engine/Core/EntityWrapper.h @@ -30,10 +30,13 @@ struct EntityWrapper EntityWrapper FirstChildByName(const std::string& name); EntityWrapper FirstParentWithComponent(const std::string& componentType); EntityWrapper Clone(EntityWrapper parent = EntityWrapper::Invalid); + std::vector ChildrenWithComponent(const std::string& componentType); + void DeleteChildren(); bool IsChildOf(EntityWrapper potentialParent); bool Valid() const; ComponentWrapper operator[](const char* componentName); + ComponentWrapper operator[](const std::string& componentName); bool operator==(const EntityWrapper& e) const; bool operator!=(const EntityWrapper& e) const; explicit operator EntityID() const; @@ -41,6 +44,7 @@ struct EntityWrapper private: EntityWrapper firstChildByNameRecursive(const std::string& name, EntityID parent); EntityWrapper cloneRecursive(EntityWrapper entity, EntityWrapper parent); + void childrenWithComponentRecursive(const std::string& componentType, EntityWrapper& entity, std::vector& childrenWithComponent); }; namespace std diff --git a/include/Engine/Core/System.h b/include/Engine/Core/System.h index 1a387855..23d5f9a5 100644 --- a/include/Engine/Core/System.h +++ b/include/Engine/Core/System.h @@ -68,7 +68,7 @@ protected: const std::string m_ComponentType; - virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cPlayer, double dt) = 0; + virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt) = 0; }; class ImpureSystem : public virtual System diff --git a/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h b/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h index 7bd9c175..993dd060 100644 --- a/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h +++ b/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h @@ -1,37 +1,33 @@ +#ifndef AssaultWeaponBehaviour_h__ +#define AssaultWeaponBehaviour_h__ + #include "Sound/EPlaySoundOnEntity.h" #include "Collision/Collision.h" -#include "Rendering/AnimationSystem.h" #include "Core/ConfigFile.h" #include "WeaponBehaviour.h" #include "../SpawnerSystem.h" #include "Core/EPlayerDamage.h" #include "Core/EShoot.h" - -class AssaultWeaponBehaviour : public WeaponBehaviour +class AssaultWeaponBehaviour : public WeaponBehaviour { public: - AssaultWeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree* collisionOctree, EntityWrapper weaponEntity); - - virtual void Fire() override; - virtual void CeaseFire() override; - virtual void Reload() override; + AssaultWeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree* collisionOctree) + : WeaponBehaviour(systemParams, "AssaultWeapon", renderer, collisionOctree) + { } - virtual void Update(double dt) override; +protected: + virtual void OnPrimaryFire(WeaponInfo& wi) override; + virtual void OnCeasePrimaryFire(WeaponInfo& wi) override; + virtual void OnReload(WeaponInfo& wi) override; private: - EntityWrapper m_FirstPersonModel; - EntityWrapper m_ThirdPersonModel; // State bool m_Firing = false; bool m_Reloading = false; double m_ReloadTimer = 0.0; - EntityWrapper m_FirstPersonReloadImpersonator; - EntityWrapper m_ThirdPersonReloadImpersonator; double m_TimeSinceLastFire = 0.0; - - EventRelay m_EAnimationComplete; - bool OnAnimationComplete(Events::AnimationComplete& e); + EntityWrapper m_FirstPersonReloadImpostor; bool hasAmmo(); void fireRound(); @@ -47,3 +43,5 @@ private: bool shoot(double damage); void showHitMarker(); }; + +#endif \ No newline at end of file diff --git a/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h b/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h new file mode 100644 index 00000000..5ca13d3e --- /dev/null +++ b/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h @@ -0,0 +1,38 @@ +#include "WeaponBehaviour.h" +#include "Collision/Collision.h" +#include "Core/EPlayerDamage.h" +#include "Rendering/ESetCamera.h" + +class DefenderWeaponBehaviour : public WeaponBehaviour +{ +public: + DefenderWeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree* collisionOctree) + : System(systemParams) + , WeaponBehaviour(systemParams, "DefenderWeapon", renderer, collisionOctree) + , m_RandomEngine(m_RandomDevice()) + { + EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &DefenderWeaponBehaviour::OnSetCamera); + } + + void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cWeapon, double dt) override; + void UpdateWeapon(WeaponInfo& wi, double dt) override; + void OnPrimaryFire(WeaponInfo& wi) override; + void OnCeasePrimaryFire(WeaponInfo& wi) override; + bool OnInputCommand(WeaponInfo& wi, const Events::InputCommand& e) override; + +private: + std::random_device m_RandomDevice; + std::mt19937 m_RandomEngine; + EntityWrapper m_CurrentCamera; + + EventRelay m_ESetCamera; + bool OnSetCamera(const Events::SetCamera& e); + + // Weapon functions + void fireShell(WeaponInfo& wi); + void dealDamage(WeaponInfo& wi, glm::vec3 direction, double damage); + + // Utility + float traceRayDistance(glm::vec3 origin, glm::vec3 direction); + Camera cameraFromEntity(EntityWrapper camera); +}; \ No newline at end of file diff --git a/include/Game/Systems/Weapon/WeaponBehaviour.h b/include/Game/Systems/Weapon/WeaponBehaviour.h index 7a0b4626..f23269df 100644 --- a/include/Game/Systems/Weapon/WeaponBehaviour.h +++ b/include/Game/Systems/Weapon/WeaponBehaviour.h @@ -5,30 +5,177 @@ #include "Rendering/IRenderer.h" #include "Core/Octree.h" #include "Collision/EntityAABB.h" +#include "Input/EInputCommand.h" +#include "Systems/SpawnerSystem.h" -class WeaponBehaviour : public System +template +class WeaponBehaviour : public PureSystem { + friend class WeaponSystem; + public: - WeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree* collisionOctree, EntityWrapper player) - : System(systemParams) + WeaponBehaviour(SystemParams params, std::string componentType, IRenderer* renderer, Octree* collisionOctree) + : System(params) + , PureSystem(componentType) , m_Renderer(renderer) , m_CollisionOctree(collisionOctree) - , m_Player(player) - { } + { + EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &WeaponBehaviour::_OnInputCommand) + } virtual ~WeaponBehaviour() = default; - WeaponBehaviour(const WeaponBehaviour&) = delete; - WeaponBehaviour& operator=(const WeaponBehaviour &) = delete; - - virtual void Fire() = 0; - virtual void CeaseFire() { } - virtual void Reload() { } - virtual void Update(double dt) { } + virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt) override + { + auto weapon = getActiveWeapon(entity); + if (!weapon) { + return; + } else { + UpdateWeapon(*weapon, dt); + } + } protected: + struct WeaponInfo + { + std::string WeaponComponent; + EntityWrapper Player; + EntityWrapper WeaponEntity; + EntityWrapper FirstPersonEntity; + EntityWrapper ThirdPersonEntity; + ComponentWrapper GetComponent() { return WeaponEntity[WeaponComponent]; } + }; + IRenderer* m_Renderer; Octree* m_CollisionOctree; - EntityWrapper m_Player; + std::unordered_map m_ActiveWeapons; + + virtual void UpdateWeapon(WeaponInfo& wi, double dt) { } + virtual void OnPrimaryFire(WeaponInfo& wi) { } + virtual void OnCeasePrimaryFire(WeaponInfo& wi) { } + virtual void OnReload(WeaponInfo& wi) { } + virtual bool OnInputCommand(WeaponInfo& wi, const Events::InputCommand& e) { return false; } + +private: + EventRelay m_EInputCommand; + bool _OnInputCommand(const Events::InputCommand& e) + { + EntityWrapper player = e.Player; + if (e.PlayerID == -1) { + player = LocalPlayer; + } + + // Make sure the player is alive + if (!player.Valid()) { + return false; + } + + // Make sure the player has this weapon + auto weapon = getWeaponComponent(player); + if (!weapon) { + return false; + } + + // Weapon selection + if (e.Command == "SelectWeapon") { + if (static_cast(e.Value) == static_cast((*weapon)["Slot"])) { + selectWeapon(player); + } + } + + // Only handle weapon actions if the weapon is active + auto activeWeapon = getActiveWeapon(player); + if (!activeWeapon) { + return false; + } + + // Fire + if (e.Command == "PrimaryFire") { + if (e.Value > 0) { + OnPrimaryFire(*activeWeapon); + } else { + OnCeasePrimaryFire(*activeWeapon); + } + } + + // Reload + if (e.Command == "Reload" && e.Value != 0) { + OnReload(*activeWeapon); + } + + return OnInputCommand(*activeWeapon, e); + } + + boost::optional getWeaponComponent(EntityWrapper player) + { + if (!player.HasComponent(m_ComponentType)) { + return boost::none; + } + + return player[m_ComponentType]; + } + + boost::optional getActiveWeapon(EntityWrapper player) + { + auto it = m_ActiveWeapons.find(player); + if (it == m_ActiveWeapons.end()) { + return boost::none; + } + WeaponInfo& activeWeapon = it->second; + + if (!activeWeapon.FirstPersonEntity.Valid() && !activeWeapon.ThirdPersonEntity.Valid()) { + return boost::none; + } + + return activeWeapon; + } + + void selectWeapon(EntityWrapper player) + { + // Find the weapon attachments matching the weapon type + std::vector weaponAttachments = player.ChildrenWithComponent("WeaponAttachment"); + EntityWrapper firstPersonAttachment; + EntityWrapper thirdPersonAttachment; + for (auto& attachment : weaponAttachments) { + ComponentWrapper cWeaponAttachment = attachment["WeaponAttachment"]; + if ((std::string&)cWeaponAttachment["Weapon"] == m_ComponentType) { + ComponentWrapper::SubscriptProxy person = cWeaponAttachment["Person"]; + if ((ComponentInfo::EnumType)person == person.Enum("FirstPerson")) { + firstPersonAttachment = attachment; + } else if ((ComponentInfo::EnumType)person == person.Enum("ThirdPerson")) { + thirdPersonAttachment = attachment; + } + } + } + + if (!firstPersonAttachment.Valid() && !thirdPersonAttachment.Valid()) { + LOG_WARNING("No weapon attachment found for %s of player #%i", m_ComponentType.c_str(), player.ID); + return; + } + + // Purge other weapon entities + for (auto& attachment : weaponAttachments) { + //if (attachment == firstPersonAttachment || attachment == thirdPersonAttachment) { + // continue; + //} + attachment.DeleteChildren(); + } + + // Spawn the weapon(s) + EntityWrapper firstPersonWeapon; + EntityWrapper thirdPersonWeapon; + if (firstPersonAttachment.Valid()) { + firstPersonWeapon = SpawnerSystem::Spawn(firstPersonAttachment, firstPersonAttachment); + } + if (thirdPersonAttachment.Valid()) { + thirdPersonWeapon = SpawnerSystem::Spawn(thirdPersonAttachment, thirdPersonAttachment); + } + + m_ActiveWeapons[player].WeaponComponent = m_ComponentType; + m_ActiveWeapons[player].Player = player; + m_ActiveWeapons[player].WeaponEntity = player; + m_ActiveWeapons[player].FirstPersonEntity = firstPersonWeapon; + m_ActiveWeapons[player].ThirdPersonEntity = thirdPersonWeapon; + } }; #endif diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index 42abed82..cad50c7e 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -46,4 +46,6 @@ + + \ No newline at end of file diff --git a/resources/Schema/Components/AssaultWeapon.xml b/resources/Schema/Components/AssaultWeapon.xml index 6c645624..c835217b 100755 --- a/resources/Schema/Components/AssaultWeapon.xml +++ b/resources/Schema/Components/AssaultWeapon.xml @@ -8,4 +8,5 @@ 120 0.01 2 + \ No newline at end of file diff --git a/resources/Schema/Components/AssaultWeapon.xsd b/resources/Schema/Components/AssaultWeapon.xsd index 95df64b7..7e9854a2 100755 --- a/resources/Schema/Components/AssaultWeapon.xsd +++ b/resources/Schema/Components/AssaultWeapon.xsd @@ -2,6 +2,7 @@ + @@ -28,6 +29,7 @@ Time it takes to reload the weapon in seconds + diff --git a/resources/Schema/Components/DefenderWeapon.xml b/resources/Schema/Components/DefenderWeapon.xml new file mode 100755 index 00000000..998f3bde --- /dev/null +++ b/resources/Schema/Components/DefenderWeapon.xml @@ -0,0 +1,16 @@ + + + 8 + 8 + 64 + 64 + 90 + 0.174533 + 10 + 120 + 0.01 + 0.5 + + false + 0 + \ No newline at end of file diff --git a/resources/Schema/Components/DefenderWeapon.xsd b/resources/Schema/Components/DefenderWeapon.xsd new file mode 100755 index 00000000..3fe5a64a --- /dev/null +++ b/resources/Schema/Components/DefenderWeapon.xsd @@ -0,0 +1,44 @@ + + + + + + + + + + + Ammo currently loaded into the magazine + + + Max number of rounds in a magazine + + + Current ammo carried + + + Maximum ammo able to be carried + + + Damage dealt if all shotgun pellets hit + + + Spread angle in radians + + + + Rate of fire in rounds per minute + + + View punch in radians for each shell fired + + + Time it takes to load ONE SHELL into the weapon in seconds + + + + + + + + diff --git a/resources/Schema/Components/Player.xml b/resources/Schema/Components/Player.xml index 00cff257..1aaeff25 100644 --- a/resources/Schema/Components/Player.xml +++ b/resources/Schema/Components/Player.xml @@ -3,4 +3,5 @@ 3 1.5 + \ No newline at end of file diff --git a/resources/Schema/Components/Player.xsd b/resources/Schema/Components/Player.xsd index 1b33d222..ebaed462 100644 --- a/resources/Schema/Components/Player.xsd +++ b/resources/Schema/Components/Player.xsd @@ -12,6 +12,7 @@ + diff --git a/resources/Schema/Components/Weapon.xml b/resources/Schema/Components/Weapon.xml deleted file mode 100644 index 38c6fce9..00000000 --- a/resources/Schema/Components/Weapon.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/resources/Schema/Components/Weapon.xsd b/resources/Schema/Components/Weapon.xsd deleted file mode 100644 index 8bddd8a9..00000000 --- a/resources/Schema/Components/Weapon.xsd +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/resources/Schema/Components/WeaponAttachment.xml b/resources/Schema/Components/WeaponAttachment.xml new file mode 100644 index 00000000..8867b2b7 --- /dev/null +++ b/resources/Schema/Components/WeaponAttachment.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/resources/Schema/Components/WeaponAttachment.xsd b/resources/Schema/Components/WeaponAttachment.xsd new file mode 100644 index 00000000..3b1291ae --- /dev/null +++ b/resources/Schema/Components/WeaponAttachment.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + Combine with a spawner to define a weapon attachment point + + + + The weapon component type this attachment refers to + + + + + + \ No newline at end of file diff --git a/resources/Schema/Entities/AssaultWeaponView.xml b/resources/Schema/Entities/AssaultWeaponView.xml new file mode 100755 index 00000000..4b985fbb --- /dev/null +++ b/resources/Schema/Entities/AssaultWeaponView.xml @@ -0,0 +1,99 @@ + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + + + + Schema/Entities/RayBlue.xml + + + + + + + + + + + Schema/Entities/ReloadEffectView.xml + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + + + + 32 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + 360 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/AssaultWeaponWorld.xml b/resources/Schema/Entities/AssaultWeaponWorld.xml new file mode 100755 index 00000000..6fcb97b3 --- /dev/null +++ b/resources/Schema/Entities/AssaultWeaponWorld.xml @@ -0,0 +1,40 @@ + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + + + + Schema/Entities/RayBlue.xml + + + + + + + + + + + Schema/Entities/ReloadEffectWorld.xml + + + + + + + + diff --git a/resources/Schema/Entities/DefenderShield.xml b/resources/Schema/Entities/DefenderShield.xml new file mode 100755 index 00000000..da760e72 --- /dev/null +++ b/resources/Schema/Entities/DefenderShield.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + + + + + + + + + + + + + Models/Core/UnitHexagon.mesh + + true + + + + + + + + + + + + diff --git a/resources/Schema/Entities/DefenderWeaponView.xml b/resources/Schema/Entities/DefenderWeaponView.xml new file mode 100755 index 00000000..f6b6e89d --- /dev/null +++ b/resources/Schema/Entities/DefenderWeaponView.xml @@ -0,0 +1,99 @@ + + + + + + R_Arm_Weapon_Joint + + + + Models/Weapons/Blue/DefenderGunBlue.mesh + + + + + + + + + + + Schema/Entities/RayBlue.xml + + + + + + + + + + + Schema/Entities/ReloadEffectView.xml + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + + + + 32 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + 360 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/DefenderWeaponViewRed.xml b/resources/Schema/Entities/DefenderWeaponViewRed.xml new file mode 100755 index 00000000..b5b1c322 --- /dev/null +++ b/resources/Schema/Entities/DefenderWeaponViewRed.xml @@ -0,0 +1,99 @@ + + + + + + R_Arm_Weapon_Joint + + + + Models/Weapons/Red/DefenderGunRed.mesh + + + + + + + + + + + Schema/Entities/RayRed.xml + + + + + + + + + + + Schema/Entities/ReloadEffectView.xml + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + + + + 32 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + 360 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/DefenderWeaponWorld.xml b/resources/Schema/Entities/DefenderWeaponWorld.xml new file mode 100755 index 00000000..826301b4 --- /dev/null +++ b/resources/Schema/Entities/DefenderWeaponWorld.xml @@ -0,0 +1,41 @@ + + + + + + R_Arm_Weapon_Joint + + + + Models/Weapons/Blue/DefenderGunBlue.mesh + + + + + + + + + + + + Schema/Entities/RayBlue.xml + + + + + + + + + + + Schema/Entities/ReloadEffectWorld.xml + + + + + + + + diff --git a/resources/Schema/Entities/DefenderWeaponWorldRed.xml b/resources/Schema/Entities/DefenderWeaponWorldRed.xml new file mode 100755 index 00000000..7f697304 --- /dev/null +++ b/resources/Schema/Entities/DefenderWeaponWorldRed.xml @@ -0,0 +1,41 @@ + + + + + + R_Arm_Weapon_Joint + + + + Models/Weapons/Red/DefenderGunRed.mesh + + + + + + + + + + + + Schema/Entities/RayRed.xml + + + + + + + + + + + Schema/Entities/ReloadEffectWorld.xml + + + + + + + + diff --git a/resources/Schema/Entities/MovementTest.xml b/resources/Schema/Entities/MovementTest.xml index 84aaa03a..41474568 100644 --- a/resources/Schema/Entities/MovementTest.xml +++ b/resources/Schema/Entities/MovementTest.xml @@ -10,7 +10,7 @@ - Schema/Entities/Player.xml + Schema/Entities/PlayerRed.xml @@ -118,257 +118,6 @@ - - - - - - - - 600 - - - - - - - - - 5 - - - - - - - - - - - - - - - - - - - - - - - Fonts/DroidSans.ttf,100 - - - - - - - - - - - - - - Models/Widgets/Camera.mesh - false - - - - - - - - - - - - - - - - - - - 1 - - - - - Models/Core/UnitHexagon.mesh - - - - - - - - - - - - - - Textures/Weapons/Crosshair/SmallThickHoleDot.png - false - - - - - - - - - - - - - - Idle - 1.9569972344146196 - 1 - - - Models/Characters/Assault/FirstPerson.mesh - true - - - - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - true - - - - - - - - - - - Schema/Entities/RayBlue.xml - - - - - - - - - - - - - Schema/Entities/WeaponReloadEffect.xml - - - - - - - - - - - - - - Models/Widgets/Camera.mesh - false - - - - - - - - - - - - Idle - 1.8055945618467364 - 1 - - - AimRifle - - - - - Models/Characters/Assault/AssaultAnimations.mesh - - - - - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - false - - - - - - - - - - - Schema/Entities/RayBlue.xml - - - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - false - - - - - - - - - - - - Models/Core/UnitCube.mesh - - false - - - - - - - - - diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 4f012955..7976fe2b 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -7,23 +7,30 @@ - 600 + + + - + + 1.6944730461160304 + 5 + - + + + @@ -303,7 +310,8 @@ - + + @@ -363,7 +371,7 @@ Idle - 0.97725610639912475 + 0.67172915251515519 1 @@ -375,100 +383,29 @@ - + - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - - - - - + + Schema/Entities/DefenderWeaponView.xml + + + + DefenderWeapon + - - - - - Schema/Entities/RayBlue.xml - - - - - - - - - - - Schema/Entities/ReloadEffectView.xml - - - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - - - - - - 32 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - 360 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - + + + + + + Schema/Entities/AssaultWeaponView.xml + + + + AssaultWeapon + + + @@ -492,7 +429,6 @@ Idle - 0.87583812735846323 1 @@ -501,6 +437,7 @@ AimRifle + Models/Characters/Assault/AssaultAnimations.mesh @@ -509,41 +446,35 @@ - + - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - - - - - + + Schema/Entities/DefenderWeaponWorld.xml + + + + DefenderWeapon + + + + - - - - - Schema/Entities/RayBlue.xml - - - - - - - - - - - Schema/Entities/ReloadEffectWorld.xml - - - - - - + + + + + + Schema/Entities/AssaultWeaponWorld.xml + + + + AssaultWeapon + + + + + + @@ -609,6 +540,17 @@ + + + + Schema/Entities/DefenderShield.xml + + + + + + + diff --git a/resources/Schema/Entities/PlayerRed.xml b/resources/Schema/Entities/PlayerRed.xml old mode 100644 new mode 100755 index d56fa3c1..69116f21 --- a/resources/Schema/Entities/PlayerRed.xml +++ b/resources/Schema/Entities/PlayerRed.xml @@ -7,23 +7,30 @@ - 600 + + + - + + 1.6944730461160304 + 5 + - + + + @@ -364,7 +371,7 @@ Idle - 1.2667383999985162 + 0.67172915251515519 1 @@ -376,100 +383,29 @@ - + - - R_Arm_Weapon_Joint - - - Models/Weapons/Red/AssaultWeaponRed.mesh - - - - - + + Schema/Entities/DefenderWeaponViewRed.xml + + + + DefenderWeapon + - - - - - Schema/Entities/RayRed.xml - - - - - - - - - - - Schema/Entities/ReloadEffectViewRed.xml - - - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - - - - - - 32 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - 360 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - + + + + + + Schema/Entities/AssaultWeaponView.xml + + + + AssaultWeapon + + + @@ -493,7 +429,6 @@ Idle - 0.26532318661337229 1 @@ -502,6 +437,7 @@ AimRifle + Models/Characters/Assault/AssaultAnimations.mesh @@ -510,41 +446,35 @@ - + - - R_Arm_Weapon_Joint - - - Models/Weapons/Red/AssaultWeaponRed.mesh - - - - - + + Schema/Entities/DefenderWeaponWorldRed.xml + + + + DefenderWeapon + + + + - - - - - Schema/Entities/RayRed.xml - - - - - - - - - - - Schema/Entities/ReloadEffectWorldRed.xml - - - - - - + + + + + + Schema/Entities/AssaultWeaponWorld.xml + + + + AssaultWeapon + + + + + + @@ -583,20 +513,20 @@ - + - + Textures/Icons/Arrow.png false - + @@ -604,12 +534,23 @@ true - + + + + + Schema/Entities/DefenderShield.xml + + + + + + + diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index a9c5f641..0965ef89 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -50,6 +50,8 @@ + + diff --git a/resources/Schema/Types/WeaponSlotEnum.xsd b/resources/Schema/Types/WeaponSlotEnum.xsd new file mode 100644 index 00000000..6713ca9d --- /dev/null +++ b/resources/Schema/Types/WeaponSlotEnum.xsd @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Engine/Core/EntityWrapper.cpp b/src/Engine/Core/EntityWrapper.cpp index ace1f4a7..b3bef55a 100644 --- a/src/Engine/Core/EntityWrapper.cpp +++ b/src/Engine/Core/EntityWrapper.cpp @@ -62,6 +62,29 @@ EntityWrapper EntityWrapper::Clone(EntityWrapper parent /*= Invalid*/) return clone; } +std::vector EntityWrapper::ChildrenWithComponent(const std::string& componentType) +{ + std::vector childrenWithComponent; + childrenWithComponentRecursive(componentType, *this, childrenWithComponent); + return childrenWithComponent; +} + +void EntityWrapper::DeleteChildren() +{ + auto itPair = this->World->GetDirectChildren(this->ID); + if (itPair.first == itPair.second) { + return; + } + + std::vector entitiesToDelete; + for (auto it = itPair.first; it != itPair.second; it++) { + entitiesToDelete.push_back(it->second); + } + for (auto& e : entitiesToDelete) { + this->World->DeleteEntity(e); + } +} + bool EntityWrapper::IsChildOf(EntityWrapper potentialParent) { EntityWrapper entity = *this; @@ -101,6 +124,11 @@ ComponentWrapper EntityWrapper::operator[](const char* componentName) } } +ComponentWrapper EntityWrapper::operator[](const std::string& componentName) +{ + return this->operator[](componentName.c_str()); +} + bool EntityWrapper::operator==(const EntityWrapper& e) const { return (this->ID == e.ID) && (this->World == e.World); @@ -166,3 +194,18 @@ EntityWrapper EntityWrapper::cloneRecursive(EntityWrapper entity, EntityWrapper return clone; } +void EntityWrapper::childrenWithComponentRecursive(const std::string& componentType, EntityWrapper& entity, std::vector& childrenWithComponent) +{ + auto itPair = this->World->GetDirectChildren(entity.ID); + if (itPair.first == itPair.second) { + return; + } + + for (auto it = itPair.first; it != itPair.second; ++it) { + EntityWrapper child = EntityWrapper(entity.World, it->second); + if (child.HasComponent(componentType)) { + childrenWithComponent.push_back(child); + } + childrenWithComponentRecursive(componentType, child, childrenWithComponent); + } +} diff --git a/src/Engine/Core/Util/Logging.cpp b/src/Engine/Core/Util/Logging.cpp index 63a6f380..c7612fd8 100644 --- a/src/Engine/Core/Util/Logging.cpp +++ b/src/Engine/Core/Util/Logging.cpp @@ -33,8 +33,8 @@ void _LOG(_LOG_LEVEL logLevel, const char* file, const char* func, unsigned int va_end(args); if (logLevel == LOG_LEVEL_ERROR) { - std::cerr << file << ":" << line << " " << func << std::endl; - std::cerr << _LOG_LEVEL_PREFIX[logLevel] << message << std::endl; + //std::cerr << file << ":" << line << " " << func << std::endl; + //std::cerr << _LOG_LEVEL_PREFIX[logLevel] << message << std::endl; } else { std::cout << _LOG_LEVEL_PREFIX[logLevel] << message << std::endl; } diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 24b7cd1e..5388fd04 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -16,7 +16,7 @@ #include "Game/Systems/PickupSpawnSystem.h" #include "Game/Systems/AmmoPickupSystem.h" #include "Game/Systems/DamageIndicatorSystem.h" -#include "Game/Systems/Weapon/WeaponSystem.h" +#include "Game/Systems/Weapon/DefenderWeaponBehaviour.h" #include "Rendering/AnimationSystem.h" #include "Game/Systems/HealthHUDSystem.h" #include "Rendering/BoneAttachmentSystem.h" @@ -98,6 +98,10 @@ Game::Game(int argc, char* argv[]) m_NetworkClient->Connect(m_NetworkAddress, m_NetworkPort); m_Renderer->SetWindowTitle(m_Renderer->WindowTitle() + " CLIENT"); } + } else { + // If network is disabled, pretend we're a server + m_IsClient = true; + m_IsServer = true; } // Create Octrees @@ -120,7 +124,7 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); - m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer, m_OctreeCollision); + m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer, m_OctreeCollision); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); diff --git a/src/Game/Network/MultiplayerSnapshotFilter.cpp b/src/Game/Network/MultiplayerSnapshotFilter.cpp index 69b7f282..295cdd7a 100644 --- a/src/Game/Network/MultiplayerSnapshotFilter.cpp +++ b/src/Game/Network/MultiplayerSnapshotFilter.cpp @@ -13,6 +13,7 @@ bool MultiplayerSnapshotFilter::FilterComponent(EntityWrapper entity, SharedComp component.Info.Name == "Transform" || component.Info.Name == "Physics" || component.Info.Name == "AssaultWeapon" + || component.Info.Name == "DefenderWeapon" || component.Info.Name == "Animation" || component.Info.Name == "AnimationOffset" || entity.Name() == "PlayerName" diff --git a/src/Game/Systems/DamageIndicatorSystem.cpp b/src/Game/Systems/DamageIndicatorSystem.cpp index 92fbe607..ca26052d 100644 --- a/src/Game/Systems/DamageIndicatorSystem.cpp +++ b/src/Game/Systems/DamageIndicatorSystem.cpp @@ -13,7 +13,7 @@ DamageIndicatorSystem::DamageIndicatorSystem(SystemParams params) } void DamageIndicatorSystem::Update(double dt) { - if (!IsServer) { + if (!IsServer && LocalPlayer.Valid()) { for (auto& iter = updateDamageIndicatorVector.begin(); iter != updateDamageIndicatorVector.end(); iter++) { if (!iter->spriteEntity.Valid()) { updateDamageIndicatorVector.erase(iter); diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp_ similarity index 87% rename from src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp rename to src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp_ index 84d3ccd4..c3b3385f 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp_ @@ -1,13 +1,5 @@ #include "Systems/Weapon/AssaultWeaponBehaviour.h" -AssaultWeaponBehaviour::AssaultWeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree* collisionOctree, EntityWrapper player) - : WeaponBehaviour(systemParams, renderer, collisionOctree, player) -{ - m_FirstPersonModel = m_Player.FirstChildByName("Hands"); - m_ThirdPersonModel = m_Player.FirstChildByName("PlayerModel"); - EVENT_SUBSCRIBE_MEMBER(m_EAnimationComplete, &AssaultWeaponBehaviour::OnAnimationComplete); -} - void AssaultWeaponBehaviour::Fire() { m_TimeSinceLastFire = 0.0; @@ -36,7 +28,7 @@ void AssaultWeaponBehaviour::Reload() return; } - // Don't reload if we're completly out of ammo + // Don't reload if we're completely out of ammo if (ammo == 0) { playEmptySound(); m_TimeSinceLastFire = -0.0f; // HACK: To make empty sound play with interval @@ -56,14 +48,14 @@ void AssaultWeaponBehaviour::Update(double dt) { if (m_Reloading) { m_ReloadTimer -= dt; - // Re-enable glow on reload impersonator half-way through the animation + // Re-enable glow on reload impostor half-way through the animation if (IsClient) { if (m_ReloadTimer <= (double)m_Player["AssaultWeapon"]["ReloadTime"] / 2.0) { - if (m_FirstPersonReloadImpersonator.Valid()) { - m_FirstPersonReloadImpersonator["Model"]["GlowMap"] = true; + if (m_FirstPersonReloadImpostor.Valid()) { + m_FirstPersonReloadImpostor["Model"]["GlowMap"] = true; } - if (m_ThirdPersonReloadImpersonator.Valid()) { - m_ThirdPersonReloadImpersonator["Model"]["GlowMap"] = true; + if (m_ThirdPersonReloadImpostor.Valid()) { + m_ThirdPersonReloadImpostor["Model"]["GlowMap"] = true; } } } @@ -96,21 +88,6 @@ void AssaultWeaponBehaviour::Update(double dt) } } -bool AssaultWeaponBehaviour::OnAnimationComplete(Events::AnimationComplete& e) -{ - if (e.Entity != m_FirstPersonModel) { - return false; - } - - //if (e.Name == "ShootRifle") { - // if (!m_Firing) { - // playIdleAnimation(); - // } - //} - - return true; -} - bool AssaultWeaponBehaviour::hasAmmo() { ComponentWrapper& cAssaultWeapon = m_Player["AssaultWeapon"]; @@ -177,7 +154,6 @@ void AssaultWeaponBehaviour::spawnTracer() float AssaultWeaponBehaviour::traceRayDistance(glm::vec3 origin, glm::vec3 direction) { - // TODO: Cast a ray and size tracer appropriately float distance; glm::vec3 pos; auto entity = Collision::EntityFirstHitByRay(Ray(origin, direction), m_CollisionOctree, distance, pos); @@ -215,6 +191,12 @@ void AssaultWeaponBehaviour::playEmptySound() void AssaultWeaponBehaviour::viewPunch() { + // Since we send absolute client orientations to server, running this server side would + // cause aim desync. + if (!IsClient) { + return; + } + EntityWrapper playerCamera = m_Player.FirstChildByName("Camera"); if (!playerCamera.Valid()) { return; @@ -323,8 +305,8 @@ void AssaultWeaponBehaviour::playReloadAnimation() EntityWrapper firstPersonWeaponModel = m_Player.FirstChildByName("WeaponModel"); EntityWrapper reloadSpawner = m_Player.FirstChildByName("FirstPersonReloadSpawner"); if (IsClient) { - m_FirstPersonReloadImpersonator = SpawnerSystem::Spawn(reloadSpawner, reloadSpawner); - firstPersonWeaponModel["Model"].Copy(m_FirstPersonReloadImpersonator["Model"]); + m_FirstPersonReloadImpostor = SpawnerSystem::Spawn(reloadSpawner, reloadSpawner); + firstPersonWeaponModel["Model"].Copy(m_FirstPersonReloadImpostor["Model"]); } firstPersonWeaponModel["Model"]["Visible"] = false; } @@ -332,8 +314,8 @@ void AssaultWeaponBehaviour::playReloadAnimation() EntityWrapper thirdPersonWeaponModel = m_Player.FirstChildByName("ThirdPersonWeaponModel"); EntityWrapper reloadSpawner = m_Player.FirstChildByName("ThirdPersonReloadSpawner"); if (IsClient) { - m_ThirdPersonReloadImpersonator = SpawnerSystem::Spawn(reloadSpawner, reloadSpawner); - thirdPersonWeaponModel["Model"].Copy(m_ThirdPersonReloadImpersonator["Model"]); + m_ThirdPersonReloadImpostor = SpawnerSystem::Spawn(reloadSpawner, reloadSpawner); + thirdPersonWeaponModel["Model"].Copy(m_ThirdPersonReloadImpostor["Model"]); } thirdPersonWeaponModel["Model"]["Visible"] = false; } @@ -371,7 +353,7 @@ bool AssaultWeaponBehaviour::shoot(double damage) return false; } - // Don't let us shoot ourselves in the foot + // Don't let us shoot ourselves in the foot somehow if (victim == LocalPlayer) { return false; } diff --git a/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp b/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp new file mode 100644 index 00000000..028bd10c --- /dev/null +++ b/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp @@ -0,0 +1,188 @@ +#include "Systems/Weapon/DefenderWeaponBehaviour.h" + +void DefenderWeaponBehaviour::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cWeapon, double dt) +{ + (double&)cWeapon["TimeSinceLastFire"] += dt; + WeaponBehaviour::UpdateComponent(entity, cWeapon, dt); +} + +void DefenderWeaponBehaviour::UpdateWeapon(WeaponInfo& wi, double dt) +{ + ComponentWrapper cWeapon = wi.GetComponent(); + + bool isFiring = cWeapon["IsFiring"]; + bool cooldownPassed = (double)cWeapon["TimeSinceLastFire"] >= (60.0 / (double)cWeapon["RPM"]); + bool isNotShielding = wi.Player.ChildrenWithComponent("Shield").size() == 0; + if (isFiring && cooldownPassed && isNotShielding) { + fireShell(wi); + } +} + +void DefenderWeaponBehaviour::OnPrimaryFire(WeaponInfo& wi) +{ + ComponentWrapper cWeapon = wi.GetComponent(); + cWeapon["IsFiring"] = true; + bool cooldownPassed = (double)cWeapon["TimeSinceLastFire"] >= (60.0 / (double)cWeapon["RPM"]); + bool isNotShielding = wi.Player.ChildrenWithComponent("Shield").size() == 0; + if (cooldownPassed && isNotShielding) { + fireShell(wi); + } +} + +void DefenderWeaponBehaviour::OnCeasePrimaryFire(WeaponInfo& wi) +{ + ComponentWrapper cWeapon = wi.GetComponent(); + cWeapon["IsFiring"] = false; +} + +bool DefenderWeaponBehaviour::OnInputCommand(WeaponInfo& wi, const Events::InputCommand& e) +{ + if (e.Command == "SpecialAbility" && IsServer) { + EntityWrapper attachment = wi.Player.FirstChildByName("ShieldAttachment"); + if (attachment.Valid()) { + if (e.Value > 0) { + SpawnerSystem::Spawn(attachment, attachment); + } else { + attachment.DeleteChildren(); + } + } + } + + return false; +} + +bool DefenderWeaponBehaviour::OnSetCamera(const Events::SetCamera& e) +{ + m_CurrentCamera = e.CameraEntity; + return true; +} + +void DefenderWeaponBehaviour::fireShell(WeaponInfo& wi) +{ + ComponentWrapper cWeapon = wi.GetComponent(); + + cWeapon["TimeSinceLastFire"] = 0.0; + int numPellets = cWeapon["NumPellets"]; + float spreadAngle = cWeapon["SpreadAngle"]; + std::uniform_real_distribution randomSpreadAngle(-spreadAngle, spreadAngle); + + // Calculate pellet angles + // HACK: Random for now? + // TODO: Make distribution even for each quadrant + std::vector pelletAngles; + for (int i = 0; i < numPellets; i++) { + pelletAngles.push_back(glm::vec2(randomSpreadAngle(m_RandomEngine), randomSpreadAngle(m_RandomEngine))); + LOG_DEBUG("%f %f", pelletAngles[i].x, pelletAngles[i].y); + } + + double pelletDamage = (double)cWeapon["BaseDamage"] / numPellets; + + // Tracers + EntityWrapper weaponModelEntity; + if (wi.Player == LocalPlayer) { + weaponModelEntity = wi.FirstPersonEntity; + } else { + weaponModelEntity = wi.ThirdPersonEntity; + } + if (weaponModelEntity.Valid()) { + EntityWrapper spawner = weaponModelEntity.FirstChildByName("WeaponMuzzle"); + for (auto& angles : pelletAngles) { + glm::vec3 direction = Transform::AbsoluteOrientation(spawner) * glm::quat(glm::vec3(angles, 0.f)) * glm::vec3(0, 0, -1); + float distance = traceRayDistance(Transform::AbsolutePosition(spawner), direction); + EntityWrapper ray = SpawnerSystem::Spawn(spawner); + ((glm::vec3&)ray["Transform"]["Scale"]).z = (distance / 100.f); + glm::vec3& orientation = ray["Transform"]["Orientation"]; + orientation.x += angles.x; + orientation.y += angles.y; + glm::vec3 trajectory = direction * distance; + dealDamage(wi, direction, pelletDamage); + } + } + +} + +void DefenderWeaponBehaviour::dealDamage(WeaponInfo& wi, glm::vec3 direction, double damage) +{ + // Only deal damage client side + if (!IsClient) { + return; + } + + // Only handle shooting for the local player + if (wi.Player != LocalPlayer) { + return; + } + + // Make sure the player isn't shooting from the grave + if (!wi.Player.Valid()) { + return; + } + + glm::vec3 maxRange = direction * 2.f; + EntityWrapper camera = wi.Player.FirstChildByName("Camera"); + glm::vec3 cameraPosition = Transform::AbsolutePosition(camera); + if (!camera.Valid()) { + return; + } + Rectangle screenResolution = m_Renderer->GetViewportSize(); + glm::vec2 centerScreen = glm::vec2(screenResolution.Width / 2, screenResolution.Height / 2); + glm::vec2 screenCoords = cameraFromEntity(m_CurrentCamera).WorldToScreen(cameraPosition + maxRange, m_Renderer->GetViewportSize()); + PickData pickData = m_Renderer->Pick(centerScreen + screenCoords); + EntityWrapper victim(m_World, pickData.Entity); + if (!victim.Valid()) { + return; + } + + // Don't let us shoot ourselves in the foot somehow + if (victim == LocalPlayer) { + return; + } + + // Only care about players being hit + if (!victim.HasComponent("Player")) { + victim = victim.FirstParentWithComponent("Player"); + } + if (!victim.Valid()) { + return; + } + + // Check for friendly fire + if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)wi.Player["Team"]["Team"]) { + return; + } + + // Deal damage! + Events::PlayerDamage ePlayerDamage; + ePlayerDamage.Inflictor = wi.Player; + ePlayerDamage.Victim = victim; + ePlayerDamage.Damage = damage; + m_EventBroker->Publish(ePlayerDamage); + LOG_DEBUG("Damage: %f", damage); +} + +float DefenderWeaponBehaviour::traceRayDistance(glm::vec3 origin, glm::vec3 direction) +{ + float distance; + glm::vec3 pos; + auto entity = Collision::EntityFirstHitByRay(Ray(origin, direction), m_CollisionOctree, distance, pos); + if (entity) { + return distance; + } else { + return 100.f; + } +} + +Camera DefenderWeaponBehaviour::cameraFromEntity(EntityWrapper camera) +{ + ComponentWrapper cTransform = camera["Transform"]; + ComponentWrapper cCamera = camera["Camera"]; + Camera cam( + (float)m_Renderer->Resolution().Width / m_Renderer->Resolution().Height, + (double)cCamera["FOV"], + (double)cCamera["NearClip"], + (double)cCamera["FarClip"] + ); + cam.SetPosition(cTransform["Position"]); + cam.SetOrientation(glm::quat((const glm::vec3&)cTransform["Orientation"])); + return cam; +} diff --git a/src/Game/Systems/Weapon/WeaponSystem.cpp b/src/Game/Systems/Weapon/WeaponSystem.cpp_ similarity index 56% rename from src/Game/Systems/Weapon/WeaponSystem.cpp rename to src/Game/Systems/Weapon/WeaponSystem.cpp_ index 3a49ae90..d33c5098 100644 --- a/src/Game/Systems/Weapon/WeaponSystem.cpp +++ b/src/Game/Systems/Weapon/WeaponSystem.cpp_ @@ -13,7 +13,7 @@ WeaponSystem::WeaponSystem(SystemParams params, IRenderer* renderer, Octree weaponAttachments = player.ChildrenWithComponent("WeaponAttachment"); + + // Find the weapon attachments matching the slot selected + EntityWrapper firstPersonAttachment; + EntityWrapper thirdPersonAttachment; + for (auto& attachment : weaponAttachments) { + ComponentWrapper cWeaponAttachment = attachment["WeaponAttachment"]; + if ((ComponentInfo::EnumType)cWeaponAttachment["Slot"] == slot) { + ComponentWrapper::SubscriptProxy person = cWeaponAttachment["Person"]; + if (person == person.Enum("FirstPerson")) { + firstPersonAttachment = attachment; + } else if (person == person.Enum("ThirdPerson")) { + thirdPersonAttachment = attachment; + } + } + } + + if (firstPersonAttachment.Valid() && thirdPersonAttachment.Valid()) { + LOG_WARNING("No weapon attachment found for slot %i of player #%i", slot, player.ID); + return; + } + + // TODO: Delete old weapons + + // Spawn the weapon(s) + EntityWrapper firstPersonWeapon; + EntityWrapper thirdPersonWeapon; + if (firstPersonAttachment.Valid()) { + firstPersonWeapon = SpawnerSystem::Spawn(firstPersonAttachment, firstPersonAttachment); + } + if (thirdPersonAttachment.Valid()) { + firstPersonWeapon = SpawnerSystem::Spawn(thirdPersonAttachment, thirdPersonAttachment); + } + + // Create the correct behaviour + if (firstPersonWeapon.Valid()) { + if (firstPersonWeapon.HasComponent("AssaultWeapon") { + + } + } + // Primary if (slot == 1) { // TODO: if class... - if (m_ActiveWeapons.count(player) == 0) { - m_ActiveWeapons.insert(std::make_pair(player, std::make_shared(m_SystemParams, m_Renderer, m_CollisionOctree, player))); - } else { - //m_ActiveWeapons.erase(player); - } + nextBehaviour = std::make_shared(m_SystemParams, m_Renderer, m_CollisionOctree, player); } // Secondary if (slot == 2) { //m_ActiveWeapons[player] = std::make_shared(); } + + if (nextBehaviour != nullptr) { + // TODO: Destroy previous behaviour and make new + if (m_ActiveWeapons.count(player) == 0) { + m_ActiveWeapons[player] = nextBehaviour; + } + } } bool WeaponSystem::OnPlayerSpawned(Events::PlayerSpawned& e) From db5170c6993baf18f0bb5be8a49fa36f44b76093 Mon Sep 17 00:00:00 2001 From: William Moberg Date: Mon, 29 Feb 2016 09:37:51 +0100 Subject: [PATCH 085/252] WIP, should take shortest resolution even if forced upwards because of slopes, not solving the jittering problem though. + debug code. --- src/Engine/Collision/Collision.cpp | 156 ++++++++++++++++------- src/Engine/Collision/CollisionSystem.cpp | 2 + 2 files changed, 113 insertions(+), 45 deletions(-) diff --git a/src/Engine/Collision/Collision.cpp b/src/Engine/Collision/Collision.cpp index 68d99d92..166518c5 100644 --- a/src/Engine/Collision/Collision.cpp +++ b/src/Engine/Collision/Collision.cpp @@ -380,11 +380,11 @@ bool AABBvsTriangle(const AABB& box, enum BoxTriResolveCase { - ResolveDimX, - ResolveDimY, - ResolveDimZ, - Line, //Box edge colliding with triangle line. - Corner //Box corner colliding with the triangle face. + EResolveDimX, + EResolveDimY, + EResolveDimZ, + ELine, //Box edge colliding with triangle line. + ECorner //Box corner colliding with the triangle face. }; struct Resolution { @@ -396,10 +396,55 @@ bool AABBvsTriangle(const AABB& box, float DistanceSq; glm::vec3 Vector; }; + struct CaseResolutions + { + Resolution Vertex; + Resolution Line; + Resolution Corner; + Resolution* Shortest = &Vertex; + + void AddResolution(BoxTriResolveCase resCase, float distanceSq, const glm::vec3& resVec) + { + switch (resCase) { + case EResolveDimY: + case EResolveDimX: + case EResolveDimZ: + if (distanceSq < Vertex.DistanceSq) { + Vertex.Vector = resVec; + Vertex.DistanceSq = distanceSq; + Vertex.Case = resCase; + if (distanceSq < Line.DistanceSq) { + Shortest = &Vertex; + } + } + break; + case ELine: + if (distanceSq < Vertex.DistanceSq && distanceSq < Line.DistanceSq) { + Line.Vector = resVec; + Line.DistanceSq = distanceSq; + Line.Case = resCase; + Shortest = &Line; + } + break; + case ECorner: + //NOTE: It is assumed that the Corner is less than the + //added resolution, since only one corner should be added per triangle. + if (distanceSq < Vertex.DistanceSq && distanceSq < Line.DistanceSq) { + Corner.Vector = resVec; + Corner.DistanceSq = distanceSq; + Corner.Case = resCase; + Shortest = &Corner; + } + break; + default: + break; + } + } + }; //The smallest resolution that solves the collision. - Resolution resolveShortest; + CaseResolutions resolveShortest; //The smallest resolution that solves the collision, that resolves upwards. - Resolution resolveUpwards; + CaseResolutions resolveUpwards; //If player stands on the ground and collides with a ground triangle, //we might step up onto it if the step is small enough. bool canStairStepUp = isOnGround && FaceIsGround(triNormal.y); @@ -421,34 +466,27 @@ bool AABBvsTriangle(const AABB& box, //Project box. glm::vec2 boxMin(min[dim.first], min[dim.second]); glm::vec2 boxMax(max[dim.first], max[dim.second]); - glm::vec2 resolutionVector; - float resolutionDist; + glm::vec2 resolutionVector2D; + float resolutionDistSq; bool pushedFromTriangleLine; //if projections don't overlap, return false. - if (!rectangleVsTriangle(boxMin, boxMax, t2D, resolutionVector, resolutionDist, pushedFromTriangleLine)) { + if (!rectangleVsTriangle(boxMin, boxMax, t2D, resolutionVector2D, resolutionDistSq, pushedFromTriangleLine)) { return false; } else if (resolveCollision) { + glm::vec3 resolve3D = glm::vec3(0.f); + resolve3D[dim.first] = resolutionVector2D.x; + resolve3D[dim.second] = resolutionVector2D.y; + //If we pushed away from triangle line (edge), or if we + //move the player along one coordinate axis (pick the dimension that isn't zero). + BoxTriResolveCase resCase = pushedFromTriangleLine ? ELine : static_cast((abs(resolve3D[dim.first]) < 0.0001f) ? dim.second : dim.first); //Overwrite the smallest resolution if this is smaller. - if (resolutionDist < resolveShortest.DistanceSq) { - resolveShortest.Vector = glm::vec3(0.f); - resolveShortest.Vector[dim.first] = resolutionVector.x; - resolveShortest.Vector[dim.second] = resolutionVector.y; - resolveShortest.DistanceSq = resolutionDist; - //If we pushed away from triangle line (edge), or if we - //move the player along one coordinate axis (pick the dimension that isn't zero). - resolveShortest.Case = pushedFromTriangleLine ? Line : static_cast((abs(resolveShortest.Vector[dim.first]) < 0.0001f) ? dim.second : dim.first); - } + resolveShortest.AddResolution(resCase, resolutionDistSq, resolve3D); + //Overwrite the smallest upward resolution if this is smaller, and resolves upwards. constexpr int yAxis = 1; - bool resIsUpwardsIn3D = dim.first == yAxis && resolutionVector.x > 0 || dim.second == yAxis && resolutionVector.y > 0; - if (canStairStepUp && resIsUpwardsIn3D && resolutionDist < resolveUpwards.DistanceSq) { - resolveUpwards.Vector = glm::vec3(0.f); - resolveUpwards.Vector[dim.first] = resolutionVector.x; - resolveUpwards.Vector[dim.second] = resolutionVector.y; - resolveUpwards.DistanceSq = resolutionDist; - //If we pushed away from triangle line (edge), or if we - //move the player along one coordinate axis (pick the dimension that isn't zero). - resolveUpwards.Case = pushedFromTriangleLine ? Line : static_cast((abs(resolveUpwards.Vector[dim.first]) < 0.0001f) ? dim.second : dim.first); + bool resIsUpwardsIn3D = dim.first == yAxis && resolutionVector2D.x > 0 || dim.second == yAxis && resolutionVector2D.y > 0; + if (canStairStepUp && resIsUpwardsIn3D) { + resolveUpwards.AddResolution(resCase, resolutionDistSq, resolve3D); } } } @@ -472,37 +510,40 @@ bool AABBvsTriangle(const AABB& box, glm::vec3 cornerResolution = (1+t) * diagonal; //Overwrite the smallest resolution if cornerResolution is smaller. float lenSq = glm::length2(cornerResolution); - if (lenSq < resolveShortest.DistanceSq) { - resolveShortest.Vector = cornerResolution; - resolveShortest.Case = Corner; - } - if (canStairStepUp && cornerResolution.y > 0 && lenSq < resolveUpwards.DistanceSq) { - resolveUpwards.Vector = cornerResolution; - resolveUpwards.Case = Corner; - resolveUpwards.DistanceSq = lenSq; + resolveShortest.AddResolution(ECorner, lenSq, cornerResolution); + if (canStairStepUp && cornerResolution.y > 0) { + resolveUpwards.AddResolution(ECorner, lenSq, cornerResolution); } //Force the resolution upwards if it is smaller than the threshold verticalStepHeight. //Else take the shortest resolution. - bool takeUp = resolveUpwards.Vector.y > 0 && resolveUpwards.Vector.y < verticalStepHeight; - Resolution& bestResolve = takeUp ? resolveUpwards : resolveShortest; - outResolution = bestResolve.Vector; + bool takeUp = resolveUpwards.Shortest->Vector.y > 0 && resolveUpwards.Shortest->Vector.y < verticalStepHeight; + CaseResolutions& bestResolve = takeUp ? resolveUpwards : resolveShortest; + outResolution = bestResolve.Shortest->Vector; + std::string dbgString = ""; glm::vec3 projNorm; - switch (bestResolve.Case) { - case ResolveDimY: + switch (bestResolve.Shortest->Case) { + case EResolveDimY: boxVelocity.y = 0.f; if (outResolution.y > 0) isOnGround = true; - case ResolveDimX: - case ResolveDimZ: + case EResolveDimX: + case EResolveDimZ: //If we get here, the resolution is along one coordinate axis. //set velocity to 0 in y if it is along y-axis. + dbgString = "Vertex Collision"; + dbgString += isOnGround ? " Ground" : " Air"; + dbgString += takeUp ? " Force up" : " Normal"; + std::cout << (dbgString.c_str()) << std::endl; + ImGui::Text(dbgString.c_str()); return true; - case Line: + case ELine: + dbgString = "Line Collision"; projNorm = glm::normalize(outResolution); break; - case Corner: + case ECorner: + dbgString = "Corner Collision"; projNorm = triNormal; break; default: @@ -519,6 +560,23 @@ bool AABBvsTriangle(const AABB& box, outResolution.y = len / glm::sin(ang); outResolution.z = 0; } + float y; + if (bestResolve.Shortest->Case == ECorner) { + len = glm::length(bestResolve.Line.Vector); + ang = glm::half_pi() - glm::acos(bestResolve.Line.Vector.y / len); + if (len > 0.0000001f && ang > 0.0000001f) { + y = len / glm::sin(ang); + if (y < outResolution.y) { + outResolution.x = 0; + outResolution.y = y; + outResolution.z = 0; + } + } + } + y = bestResolve.Vertex.Vector.y; + if (bestResolve.Vertex.Case == EResolveDimY && y < outResolution.y) { + outResolution.y = y; + } //Also zero the vertical velocity, if it is positive, else project it onto the normal. //Project the velocity onto the normal of the hit line/face. //w = v - *n, |n|==1. @@ -533,6 +591,10 @@ bool AABBvsTriangle(const AABB& box, boxVelocity = boxVelocity - glm::dot(boxVelocity, projNorm) * projNorm; } } + dbgString += isOnGround ? " Ground" : " Air"; + dbgString += takeUp ? " Force up" : " Normal"; + std::cout << (dbgString.c_str()) << std::endl; + ImGui::Text(dbgString.c_str()); return true; } @@ -546,6 +608,7 @@ bool AABBvsTriangles(const AABB& box, glm::vec3& outResolutionVector, bool resolveCollision) { + std::cout << ("---->>>--AABBvsTriangles--------") << std::endl; bool hit = false; bool everHitTheGround = false; @@ -573,6 +636,9 @@ bool AABBvsTriangles(const AABB& box, if (!everHitTheGround) { isOnGround = false; } + std::cout << (isOnGround ? "Hit Ground" : "In Air") << std::endl; + ImGui::Text(isOnGround ? "Hit Ground" : "In Air"); + std::cout << ("--------AABBvsTriangles---->>>--") << std::endl; return hit; } diff --git a/src/Engine/Collision/CollisionSystem.cpp b/src/Engine/Collision/CollisionSystem.cpp index 9689bf13..30b60df9 100644 --- a/src/Engine/Collision/CollisionSystem.cpp +++ b/src/Engine/Collision/CollisionSystem.cpp @@ -12,6 +12,7 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c if (!boundingBox) { return; } + std::cout << "---->>>--Start Update--------" << std::endl; ComponentWrapper& cTransform = entity["Transform"]; EntityAABB& boxA = *boundingBox; bool everHitTheGround = false; @@ -115,4 +116,5 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c } m_PrevPositions[entity] = boxA.Origin(); + std::cout << "--------End Update---->>>--" << std::endl; } From df7ace662608f963577c18cbd77ead058c6202e3 Mon Sep 17 00:00:00 2001 From: Teejoon Date: Mon, 29 Feb 2016 11:44:29 +0100 Subject: [PATCH 086/252] We only uses one depth buffer now --- include/Engine/Rendering/DrawFinalPass.h | 4 ++-- include/Engine/Rendering/FrameBuffer.h | 9 --------- include/Engine/Rendering/PickingPass.h | 4 +--- include/Engine/Rendering/RenderState.h | 2 ++ .../Engine/Rendering/Util/CommonFunctions.h | 1 + src/Engine/Rendering/DrawBloomPass.cpp | 4 ++-- src/Engine/Rendering/DrawFinalPass.cpp | 18 +++++------------ src/Engine/Rendering/DrawFinalPassState.cpp | 3 ++- src/Engine/Rendering/FrameBuffer.cpp | 6 ------ src/Engine/Rendering/PickingPass.cpp | 19 +++--------------- src/Engine/Rendering/PickingPassState.cpp | 1 + src/Engine/Rendering/RenderState.cpp | 20 +++++++++++++++++++ src/Engine/Rendering/Renderer.cpp | 20 ++++++++++--------- src/Engine/Rendering/SSAOPass.cpp | 13 ++++++------ src/Engine/Rendering/Util/CommonFunctions.cpp | 10 ++++++++++ src/Game/main.cpp | 2 ++ 16 files changed, 69 insertions(+), 67 deletions(-) diff --git a/include/Engine/Rendering/DrawFinalPass.h b/include/Engine/Rendering/DrawFinalPass.h index 5e6f64b9..97322603 100644 --- a/include/Engine/Rendering/DrawFinalPass.h +++ b/include/Engine/Rendering/DrawFinalPass.h @@ -15,7 +15,7 @@ class DrawFinalPass { public: - DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass); + DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass, GLuint* depthBuffer); ~DrawFinalPass() { } void InitializeTextures(); void InitializeFrameBuffers(); @@ -59,7 +59,7 @@ private: GLuint m_SceneTexture; GLuint m_BloomTextureLowRes; GLuint m_SceneTextureLowRes; - GLuint m_DepthBuffer; + GLuint* m_DepthBuffer; GLuint m_DepthBufferLowRes; GLuint m_CubeMapTexture; diff --git a/include/Engine/Rendering/FrameBuffer.h b/include/Engine/Rendering/FrameBuffer.h index 89418799..cf63b6c6 100644 --- a/include/Engine/Rendering/FrameBuffer.h +++ b/include/Engine/Rendering/FrameBuffer.h @@ -33,15 +33,6 @@ public: ~Texture2D(); }; -class Texture2DMultiSample : public ResourceType -{ -public: - Texture2DMultiSample(GLuint* resourceHandle, GLenum attachment) - : ResourceType(resourceHandle, attachment) { }; - - ~Texture2DMultiSample(); -}; - class RenderBuffer : public ResourceType { public: diff --git a/include/Engine/Rendering/PickingPass.h b/include/Engine/Rendering/PickingPass.h index f6434781..df99a615 100644 --- a/include/Engine/Rendering/PickingPass.h +++ b/include/Engine/Rendering/PickingPass.h @@ -28,15 +28,13 @@ public: const ShaderProgram& PickingProgram() const { return *m_PickingProgram; } //const std::unordered_map& PickingColorsToEntity() const { return m_PickingColorsToEntity; } GLuint PickingTexture() const { return m_PickingTexture; } - GLuint DepthBuffer() const { return m_DepthBuffer; } + GLuint* DepthBuffer() { return &m_DepthBuffer; } const FrameBuffer& PickingBuffer() const { return m_PickingBuffer; } PickData Pick(glm::vec2 screenCoord); private: - void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const; - EventBroker* m_EventBroker; const IRenderer* m_Renderer; diff --git a/include/Engine/Rendering/RenderState.h b/include/Engine/Rendering/RenderState.h index c1886247..24f908a9 100644 --- a/include/Engine/Rendering/RenderState.h +++ b/include/Engine/Rendering/RenderState.h @@ -24,6 +24,8 @@ public: bool StencilFunc(GLenum func, GLint ref, GLuint mask); bool StencilMask(GLuint mask); bool DepthMask(GLboolean flag); + bool DepthFunc(GLenum func); + bool AlphaFunc(GLenum func, GLclampf thresholder); private: std::vector> m_ResetFunctions; diff --git a/include/Engine/Rendering/Util/CommonFunctions.h b/include/Engine/Rendering/Util/CommonFunctions.h index 7ff6e3f9..1ed3d82a 100644 --- a/include/Engine/Rendering/Util/CommonFunctions.h +++ b/include/Engine/Rendering/Util/CommonFunctions.h @@ -10,6 +10,7 @@ namespace CommonFunctions { Texture* LoadTexture(std::string path, bool threaded); void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type); +void GenerateMultiSampleTexture(GLuint* texture, int numSamples, glm::vec2 dimensions, GLint internalFormat); void GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps); void DeleteTexture(GLuint* texture); }; diff --git a/src/Engine/Rendering/DrawBloomPass.cpp b/src/Engine/Rendering/DrawBloomPass.cpp index 0216d940..12777941 100644 --- a/src/Engine/Rendering/DrawBloomPass.cpp +++ b/src/Engine/Rendering/DrawBloomPass.cpp @@ -82,11 +82,11 @@ void DrawBloomPass::ClearBuffer() GLERROR("PRE"); m_GaussianFrameBuffer_horiz.Bind(); glClearColor(0.f, 0.f, 0.f, 0.f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT); m_GaussianFrameBuffer_horiz.Unbind(); m_GaussianFrameBuffer_vert.Bind(); glClearColor(0.f, 0.f, 0.f, 0.f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT); m_GaussianFrameBuffer_vert.Unbind(); GLERROR("END"); } diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 017ba9ba..3e477296 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -1,9 +1,10 @@ #include "Rendering/DrawFinalPass.h" -DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass) +DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass, GLuint* depthBuffer) : m_Renderer(renderer) , m_LightCullingPass(lightCullingPass) , m_CubeMapPass(cubeMapPass) , m_SSAOPass(ssaoPass) + , m_DepthBuffer(depthBuffer) { //TODO: Make sure that uniforms are not sent into shader if not needed. m_ShieldPixelRate = 8; @@ -23,19 +24,13 @@ void DrawFinalPass::InitializeTextures() void DrawFinalPass::InitializeFrameBuffers() { - glGenRenderbuffers(1, &m_DepthBuffer); - glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); - GLERROR("RenderBuffer generation"); - - CommonFunctions::GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); //GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); CommonFunctions::GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); //GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_FLOAT, 4); //GenerateTexture(&m_StencilTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_STENCIL, GL_STENCIL_INDEX8, GL_INT); - m_FinalPassFrameBuffer.AddResource(std::shared_ptr(new RenderBuffer(&m_DepthBuffer, GL_DEPTH_STENCIL_ATTACHMENT))); + m_FinalPassFrameBuffer.AddResource(std::shared_ptr(new Texture2D(m_DepthBuffer, GL_DEPTH_STENCIL_ATTACHMENT))); //m_FinalPassFrameBuffer.AddResource(std::shared_ptr(new Texture2D(&m_StencilTexture, GL_STENCIL_ATTACHMENT))); m_FinalPassFrameBuffer.AddResource(std::shared_ptr(new Texture2D(&m_SceneTexture, GL_COLOR_ATTACHMENT0))); m_FinalPassFrameBuffer.AddResource(std::shared_ptr(new Texture2D(&m_BloomTexture, GL_COLOR_ATTACHMENT1))); @@ -182,7 +177,6 @@ void DrawFinalPass::Draw(RenderScene& scene) if (scene.ClearDepth) { //glClear(GL_DEPTH_BUFFER_BIT); state->Disable(GL_DEPTH_TEST); - state->DepthMask(GL_FALSE); } //TODO: Do we need check for this or will it be per scene always? glClearStencil(0x00); @@ -273,7 +267,7 @@ void DrawFinalPass::ClearBuffer() glClearColor(0.f, 0.f, 0.f, 0.f); GLERROR("1"); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); GLERROR("2"); glDisable(GL_SCISSOR_TEST); @@ -288,7 +282,7 @@ void DrawFinalPass::ClearBuffer() glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); GLERROR("ViewPort,Scissor LowRes"); glClearColor(0.f, 0.f, 0.f, 0.f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT); m_FinalPassFrameBuffer.Unbind(); GLERROR("END"); } @@ -297,8 +291,6 @@ void DrawFinalPass::ClearBuffer() void DrawFinalPass::OnWindowResize() { //InitializeFrameBuffers(); - glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); CommonFunctions::GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); CommonFunctions::GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); diff --git a/src/Engine/Rendering/DrawFinalPassState.cpp b/src/Engine/Rendering/DrawFinalPassState.cpp index 9741a0ce..6e1e3473 100644 --- a/src/Engine/Rendering/DrawFinalPassState.cpp +++ b/src/Engine/Rendering/DrawFinalPassState.cpp @@ -8,7 +8,8 @@ DrawFinalPassState::DrawFinalPassState(GLuint frameBuffer) Enable(GL_BLEND); BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); Enable(GL_DEPTH_TEST); - glDepthFunc(GL_LEQUAL); + DepthMask(GL_FALSE); + DepthFunc(GL_LEQUAL); Enable(GL_CULL_FACE); Enable(GL_STENCIL_TEST); StencilFunc(GL_NOTEQUAL, 1, 0xFF); diff --git a/src/Engine/Rendering/FrameBuffer.cpp b/src/Engine/Rendering/FrameBuffer.cpp index 8638ebca..9ba0d2d8 100644 --- a/src/Engine/Rendering/FrameBuffer.cpp +++ b/src/Engine/Rendering/FrameBuffer.cpp @@ -16,12 +16,6 @@ Texture2D::~Texture2D() } } -Texture2DMultiSample::~Texture2DMultiSample() -{ - if (m_ResourceHandle != 0) { - glDeleteTextures(1, m_ResourceHandle); - } -} RenderBuffer::~RenderBuffer() { diff --git a/src/Engine/Rendering/PickingPass.cpp b/src/Engine/Rendering/PickingPass.cpp index 1eab9939..fb58edf7 100644 --- a/src/Engine/Rendering/PickingPass.cpp +++ b/src/Engine/Rendering/PickingPass.cpp @@ -19,10 +19,10 @@ PickingPass::~PickingPass() void PickingPass::InitializeTextures() { - GenerateTexture(&m_PickingTexture, GL_CLAMP_TO_BORDER, GL_LINEAR, + CommonFunctions::GenerateTexture(&m_PickingTexture, GL_CLAMP_TO_BORDER, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RG8, GL_RG, GL_UNSIGNED_BYTE); - GenerateTexture(&m_DepthBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST, + CommonFunctions::GenerateTexture(&m_DepthBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8); } @@ -366,7 +366,7 @@ void PickingPass::ClearPicking() m_PickingBuffer.Bind(); glClearColor(0.f, 0.f, 0.f, 0.f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); m_PickingBuffer.Unbind(); GLERROR("END"); } @@ -407,16 +407,3 @@ PickData PickingPass::Pick(glm::vec2 screenCoord) pickData.World = pickInfo.World; return pickData; } - -void PickingPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const -{ - //TODO: Renderer: Make this in a sparate class - glGenTextures(1, texture); - glBindTexture(GL_TEXTURE_2D, *texture); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering); - glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, dimensions.x, dimensions.y, 0, format, type, nullptr);//TODO: Renderer: Fix the precision and Resolution - GLERROR("Texture initialization failed"); -} diff --git a/src/Engine/Rendering/PickingPassState.cpp b/src/Engine/Rendering/PickingPassState.cpp index f2d42bff..3c19dc06 100644 --- a/src/Engine/Rendering/PickingPassState.cpp +++ b/src/Engine/Rendering/PickingPassState.cpp @@ -14,6 +14,7 @@ PickingPassState::PickingPassState(GLuint frameBuffer) //ClearColor(clearColor); //Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); GLERROR("END"); + } PickingPassState::~PickingPassState() diff --git a/src/Engine/Rendering/RenderState.cpp b/src/Engine/Rendering/RenderState.cpp index 26ba18a1..56812f9a 100644 --- a/src/Engine/Rendering/RenderState.cpp +++ b/src/Engine/Rendering/RenderState.cpp @@ -135,6 +135,26 @@ bool RenderState::DepthMask(GLboolean flag) return !GLERROR("DepthMask"); } +bool RenderState::DepthFunc(GLenum func) +{ + GLint original; + glGetIntegerv(GL_DEPTH_FUNC, &original); + m_ResetFunctions.push_back(std::bind(glDepthFunc, original)); + glDepthFunc(func); + return !GLERROR("DepthFunc"); +} + +bool RenderState::AlphaFunc(GLenum func, GLclampf thresholder) +{ + GLint originalFunc; + glGetIntegerv(GL_ALPHA_TEST_FUNC, &originalFunc); + GLint originalRef; + glGetIntegerv(GL_ALPHA_TEST_REF, &originalRef); + m_ResetFunctions.push_back(std::bind(glAlphaFunc, originalFunc, originalRef)); + glAlphaFunc(func, thresholder); + return !GLERROR("AlphaFunc"); +} + RenderState::~RenderState() { for (auto& f : boost::adaptors::reverse(m_ResetFunctions)) { diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index 76ee9506..e590cd97 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -28,9 +28,9 @@ void Renderer::glfwFrameBufferCallback(GLFWwindow* window, int width, int height glViewport(0, 0, width, height); Renderer* currentRenderer = m_WindowToRenderer[window]; currentRenderer->m_ViewportSize = Rectangle(width, height); + currentRenderer->m_PickingPass->OnWindowResize(); currentRenderer->m_DrawFinalPass->OnWindowResize(); currentRenderer->m_LightCullingPass->OnWindowResize(); - currentRenderer->m_PickingPass->OnWindowResize(); currentRenderer->m_DrawBloomPass->OnWindowResize(); currentRenderer->m_SSAOPass->OnWindowResize(); } @@ -136,17 +136,16 @@ void Renderer::Draw(RenderFrame& frame) PerformanceTimer::StopTimer("Renderer-ClearBuffers"); GLERROR("ClearBuffers"); for (auto scene : frame.RenderScenes) { - PerformanceTimer::StartTimer("Renderer-Depth"); + PerformanceTimer::StartTimer("Renderer-PickingPass"); m_PickingPass->Draw(*scene); GLERROR("Drawing pickingpass"); - PerformanceTimer::StopTimer("Renderer-Depth"); + PerformanceTimer::StopTimer("Renderer-PickingPass"); } PerformanceTimer::StartTimer("Renderer-AO generation"); - m_SSAOPass->Draw(m_PickingPass->DepthBuffer(), frame.RenderScenes.front()->Camera); + m_SSAOPass->Draw(*m_PickingPass->DepthBuffer(), frame.RenderScenes.front()->Camera); PerformanceTimer::StopTimer("Renderer-AO generation"); for (auto scene : frame.RenderScenes){ - - PerformanceTimer::StartTimer("Renderer-Drawing PickingPass"); + PerformanceTimer::StartTimer("Renderer-Depth"); SortRenderJobsByDepth(*scene); GLERROR("SortByDepth"); PerformanceTimer::StartTimerAndStopPrevious("Renderer-Generate Frustrums"); @@ -206,8 +205,11 @@ void Renderer::Draw(RenderFrame& frame) PerformanceTimer::StartTimer("Renderer-ImGuiRenderPass"); m_ImGuiRenderPass->Draw(); GLERROR("Imgui draw"); + PerformanceTimer::StopTimer("Renderer-ImGuiRenderPass"); + + PerformanceTimer::StartTimer("Renderer-SwapBuffer"); glfwSwapBuffers(m_Window); - PerformanceTimer::StopTimer("Renderer-ImGuiRenderPass"); + PerformanceTimer::StopTimer("Renderer-SwapBuffer"); } PickData Renderer::Pick(glm::vec2 screenCoord) @@ -248,9 +250,9 @@ void Renderer::InitializeRenderPasses() m_LightCullingPass = new LightCullingPass(this); m_CubeMapPass = new CubeMapPass(this); m_SSAOPass = new SSAOPass(this, m_Config); - m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass, m_SSAOPass); + m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass, m_SSAOPass, m_PickingPass->DepthBuffer()); m_DrawScreenQuadPass = new DrawScreenQuadPass(this); m_DrawBloomPass = new DrawBloomPass(this, m_Config); m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this); -} +} \ No newline at end of file diff --git a/src/Engine/Rendering/SSAOPass.cpp b/src/Engine/Rendering/SSAOPass.cpp index 8515cf95..9992db70 100644 --- a/src/Engine/Rendering/SSAOPass.cpp +++ b/src/Engine/Rendering/SSAOPass.cpp @@ -88,8 +88,8 @@ void SSAOPass::InitializeTexture() { CommonFunctions::GenerateTexture(&m_SSAOTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RED, GL_FLOAT); CommonFunctions::GenerateTexture(&m_SSAOViewSpaceZTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R32F, GL_RED, GL_FLOAT); - CommonFunctions::GenerateTexture(&m_Gaussian_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RGB, GL_FLOAT); - CommonFunctions::GenerateTexture(&m_Gaussian_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RGB, GL_FLOAT); + CommonFunctions::GenerateTexture(&m_Gaussian_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RED, GL_FLOAT); + CommonFunctions::GenerateTexture(&m_Gaussian_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RED, GL_FLOAT); } void SSAOPass::InitializeBuffer() @@ -127,22 +127,22 @@ void SSAOPass::ClearBuffer() } m_SSAOFramBuffer.Bind(); glClearColor(1.f, 1.f, 1.f, 1.f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT); m_SSAOFramBuffer.Unbind(); m_SSAOViewSpaceZFramBuffer.Bind(); glClearColor(1.f, 1.f, 1.f, 1.f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT); m_SSAOViewSpaceZFramBuffer.Unbind(); m_GaussianFrameBuffer_horiz.Bind(); glClearColor(1.f, 1.f, 1.f, 1.f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT); m_GaussianFrameBuffer_horiz.Unbind(); m_GaussianFrameBuffer_vert.Bind(); glClearColor(1.f, 1.f, 1.f, 1.f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT); m_GaussianFrameBuffer_vert.Unbind(); } @@ -284,4 +284,5 @@ void SSAOPass::OnWindowResize() { } InitializeTexture(); + InitializeBuffer(); } \ No newline at end of file diff --git a/src/Engine/Rendering/Util/CommonFunctions.cpp b/src/Engine/Rendering/Util/CommonFunctions.cpp index 5c5c449e..913e005e 100644 --- a/src/Engine/Rendering/Util/CommonFunctions.cpp +++ b/src/Engine/Rendering/Util/CommonFunctions.cpp @@ -31,6 +31,16 @@ void CommonFunctions::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum f GLERROR("Texture initialization failed"); } +void CommonFunctions::GenerateMultiSampleTexture(GLuint* texture, int numSamples, glm::vec2 dimensions, GLint internalFormat) +{ + glDeleteTextures(1, texture); + glGenTextures(1, texture); + glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, *texture); + glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, numSamples, internalFormat, dimensions.x, dimensions.y, false); + GLERROR("Texture initialization failed"); +} + + void CommonFunctions::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) { glGenTextures(1, texture); diff --git a/src/Game/main.cpp b/src/Game/main.cpp index dd2a5a84..3c9b6d38 100644 --- a/src/Game/main.cpp +++ b/src/Game/main.cpp @@ -9,7 +9,9 @@ int main(int argc, char* argv[]) Game game(argc, argv); while (game.Running()) { + PerformanceTimer::StartTimer("Game-Tick"); game.Tick(); + PerformanceTimer::StopTimer("Game-Tick"); } return 0; From 8e21c5a5e42b2fafcff7b20348146881d143823c Mon Sep 17 00:00:00 2001 From: William Moberg Date: Mon, 29 Feb 2016 15:38:36 +0100 Subject: [PATCH 087/252] Reverts last WIP since it probably added code without improving anything. Revert "WIP, should take shortest resolution even if forced upwards because of slopes, not solving the jittering problem though. + debug code." This reverts commit db5170c6993baf18f0bb5be8a49fa36f44b76093. --- src/Engine/Collision/Collision.cpp | 156 +++++++---------------- src/Engine/Collision/CollisionSystem.cpp | 2 - 2 files changed, 45 insertions(+), 113 deletions(-) diff --git a/src/Engine/Collision/Collision.cpp b/src/Engine/Collision/Collision.cpp index 166518c5..68d99d92 100644 --- a/src/Engine/Collision/Collision.cpp +++ b/src/Engine/Collision/Collision.cpp @@ -380,11 +380,11 @@ bool AABBvsTriangle(const AABB& box, enum BoxTriResolveCase { - EResolveDimX, - EResolveDimY, - EResolveDimZ, - ELine, //Box edge colliding with triangle line. - ECorner //Box corner colliding with the triangle face. + ResolveDimX, + ResolveDimY, + ResolveDimZ, + Line, //Box edge colliding with triangle line. + Corner //Box corner colliding with the triangle face. }; struct Resolution { @@ -396,55 +396,10 @@ bool AABBvsTriangle(const AABB& box, float DistanceSq; glm::vec3 Vector; }; - struct CaseResolutions - { - Resolution Vertex; - Resolution Line; - Resolution Corner; - Resolution* Shortest = &Vertex; - - void AddResolution(BoxTriResolveCase resCase, float distanceSq, const glm::vec3& resVec) - { - switch (resCase) { - case EResolveDimY: - case EResolveDimX: - case EResolveDimZ: - if (distanceSq < Vertex.DistanceSq) { - Vertex.Vector = resVec; - Vertex.DistanceSq = distanceSq; - Vertex.Case = resCase; - if (distanceSq < Line.DistanceSq) { - Shortest = &Vertex; - } - } - break; - case ELine: - if (distanceSq < Vertex.DistanceSq && distanceSq < Line.DistanceSq) { - Line.Vector = resVec; - Line.DistanceSq = distanceSq; - Line.Case = resCase; - Shortest = &Line; - } - break; - case ECorner: - //NOTE: It is assumed that the Corner is less than the - //added resolution, since only one corner should be added per triangle. - if (distanceSq < Vertex.DistanceSq && distanceSq < Line.DistanceSq) { - Corner.Vector = resVec; - Corner.DistanceSq = distanceSq; - Corner.Case = resCase; - Shortest = &Corner; - } - break; - default: - break; - } - } - }; //The smallest resolution that solves the collision. - CaseResolutions resolveShortest; + Resolution resolveShortest; //The smallest resolution that solves the collision, that resolves upwards. - CaseResolutions resolveUpwards; + Resolution resolveUpwards; //If player stands on the ground and collides with a ground triangle, //we might step up onto it if the step is small enough. bool canStairStepUp = isOnGround && FaceIsGround(triNormal.y); @@ -466,27 +421,34 @@ bool AABBvsTriangle(const AABB& box, //Project box. glm::vec2 boxMin(min[dim.first], min[dim.second]); glm::vec2 boxMax(max[dim.first], max[dim.second]); - glm::vec2 resolutionVector2D; - float resolutionDistSq; + glm::vec2 resolutionVector; + float resolutionDist; bool pushedFromTriangleLine; //if projections don't overlap, return false. - if (!rectangleVsTriangle(boxMin, boxMax, t2D, resolutionVector2D, resolutionDistSq, pushedFromTriangleLine)) { + if (!rectangleVsTriangle(boxMin, boxMax, t2D, resolutionVector, resolutionDist, pushedFromTriangleLine)) { return false; } else if (resolveCollision) { - glm::vec3 resolve3D = glm::vec3(0.f); - resolve3D[dim.first] = resolutionVector2D.x; - resolve3D[dim.second] = resolutionVector2D.y; - //If we pushed away from triangle line (edge), or if we - //move the player along one coordinate axis (pick the dimension that isn't zero). - BoxTriResolveCase resCase = pushedFromTriangleLine ? ELine : static_cast((abs(resolve3D[dim.first]) < 0.0001f) ? dim.second : dim.first); //Overwrite the smallest resolution if this is smaller. - resolveShortest.AddResolution(resCase, resolutionDistSq, resolve3D); - + if (resolutionDist < resolveShortest.DistanceSq) { + resolveShortest.Vector = glm::vec3(0.f); + resolveShortest.Vector[dim.first] = resolutionVector.x; + resolveShortest.Vector[dim.second] = resolutionVector.y; + resolveShortest.DistanceSq = resolutionDist; + //If we pushed away from triangle line (edge), or if we + //move the player along one coordinate axis (pick the dimension that isn't zero). + resolveShortest.Case = pushedFromTriangleLine ? Line : static_cast((abs(resolveShortest.Vector[dim.first]) < 0.0001f) ? dim.second : dim.first); + } //Overwrite the smallest upward resolution if this is smaller, and resolves upwards. constexpr int yAxis = 1; - bool resIsUpwardsIn3D = dim.first == yAxis && resolutionVector2D.x > 0 || dim.second == yAxis && resolutionVector2D.y > 0; - if (canStairStepUp && resIsUpwardsIn3D) { - resolveUpwards.AddResolution(resCase, resolutionDistSq, resolve3D); + bool resIsUpwardsIn3D = dim.first == yAxis && resolutionVector.x > 0 || dim.second == yAxis && resolutionVector.y > 0; + if (canStairStepUp && resIsUpwardsIn3D && resolutionDist < resolveUpwards.DistanceSq) { + resolveUpwards.Vector = glm::vec3(0.f); + resolveUpwards.Vector[dim.first] = resolutionVector.x; + resolveUpwards.Vector[dim.second] = resolutionVector.y; + resolveUpwards.DistanceSq = resolutionDist; + //If we pushed away from triangle line (edge), or if we + //move the player along one coordinate axis (pick the dimension that isn't zero). + resolveUpwards.Case = pushedFromTriangleLine ? Line : static_cast((abs(resolveUpwards.Vector[dim.first]) < 0.0001f) ? dim.second : dim.first); } } } @@ -510,40 +472,37 @@ bool AABBvsTriangle(const AABB& box, glm::vec3 cornerResolution = (1+t) * diagonal; //Overwrite the smallest resolution if cornerResolution is smaller. float lenSq = glm::length2(cornerResolution); - resolveShortest.AddResolution(ECorner, lenSq, cornerResolution); - if (canStairStepUp && cornerResolution.y > 0) { - resolveUpwards.AddResolution(ECorner, lenSq, cornerResolution); + if (lenSq < resolveShortest.DistanceSq) { + resolveShortest.Vector = cornerResolution; + resolveShortest.Case = Corner; + } + if (canStairStepUp && cornerResolution.y > 0 && lenSq < resolveUpwards.DistanceSq) { + resolveUpwards.Vector = cornerResolution; + resolveUpwards.Case = Corner; + resolveUpwards.DistanceSq = lenSq; } //Force the resolution upwards if it is smaller than the threshold verticalStepHeight. //Else take the shortest resolution. - bool takeUp = resolveUpwards.Shortest->Vector.y > 0 && resolveUpwards.Shortest->Vector.y < verticalStepHeight; - CaseResolutions& bestResolve = takeUp ? resolveUpwards : resolveShortest; - outResolution = bestResolve.Shortest->Vector; + bool takeUp = resolveUpwards.Vector.y > 0 && resolveUpwards.Vector.y < verticalStepHeight; + Resolution& bestResolve = takeUp ? resolveUpwards : resolveShortest; + outResolution = bestResolve.Vector; - std::string dbgString = ""; glm::vec3 projNorm; - switch (bestResolve.Shortest->Case) { - case EResolveDimY: + switch (bestResolve.Case) { + case ResolveDimY: boxVelocity.y = 0.f; if (outResolution.y > 0) isOnGround = true; - case EResolveDimX: - case EResolveDimZ: + case ResolveDimX: + case ResolveDimZ: //If we get here, the resolution is along one coordinate axis. //set velocity to 0 in y if it is along y-axis. - dbgString = "Vertex Collision"; - dbgString += isOnGround ? " Ground" : " Air"; - dbgString += takeUp ? " Force up" : " Normal"; - std::cout << (dbgString.c_str()) << std::endl; - ImGui::Text(dbgString.c_str()); return true; - case ELine: - dbgString = "Line Collision"; + case Line: projNorm = glm::normalize(outResolution); break; - case ECorner: - dbgString = "Corner Collision"; + case Corner: projNorm = triNormal; break; default: @@ -560,23 +519,6 @@ bool AABBvsTriangle(const AABB& box, outResolution.y = len / glm::sin(ang); outResolution.z = 0; } - float y; - if (bestResolve.Shortest->Case == ECorner) { - len = glm::length(bestResolve.Line.Vector); - ang = glm::half_pi() - glm::acos(bestResolve.Line.Vector.y / len); - if (len > 0.0000001f && ang > 0.0000001f) { - y = len / glm::sin(ang); - if (y < outResolution.y) { - outResolution.x = 0; - outResolution.y = y; - outResolution.z = 0; - } - } - } - y = bestResolve.Vertex.Vector.y; - if (bestResolve.Vertex.Case == EResolveDimY && y < outResolution.y) { - outResolution.y = y; - } //Also zero the vertical velocity, if it is positive, else project it onto the normal. //Project the velocity onto the normal of the hit line/face. //w = v - *n, |n|==1. @@ -591,10 +533,6 @@ bool AABBvsTriangle(const AABB& box, boxVelocity = boxVelocity - glm::dot(boxVelocity, projNorm) * projNorm; } } - dbgString += isOnGround ? " Ground" : " Air"; - dbgString += takeUp ? " Force up" : " Normal"; - std::cout << (dbgString.c_str()) << std::endl; - ImGui::Text(dbgString.c_str()); return true; } @@ -608,7 +546,6 @@ bool AABBvsTriangles(const AABB& box, glm::vec3& outResolutionVector, bool resolveCollision) { - std::cout << ("---->>>--AABBvsTriangles--------") << std::endl; bool hit = false; bool everHitTheGround = false; @@ -636,9 +573,6 @@ bool AABBvsTriangles(const AABB& box, if (!everHitTheGround) { isOnGround = false; } - std::cout << (isOnGround ? "Hit Ground" : "In Air") << std::endl; - ImGui::Text(isOnGround ? "Hit Ground" : "In Air"); - std::cout << ("--------AABBvsTriangles---->>>--") << std::endl; return hit; } diff --git a/src/Engine/Collision/CollisionSystem.cpp b/src/Engine/Collision/CollisionSystem.cpp index 30b60df9..9689bf13 100644 --- a/src/Engine/Collision/CollisionSystem.cpp +++ b/src/Engine/Collision/CollisionSystem.cpp @@ -12,7 +12,6 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c if (!boundingBox) { return; } - std::cout << "---->>>--Start Update--------" << std::endl; ComponentWrapper& cTransform = entity["Transform"]; EntityAABB& boxA = *boundingBox; bool everHitTheGround = false; @@ -116,5 +115,4 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c } m_PrevPositions[entity] = boxA.Origin(); - std::cout << "--------End Update---->>>--" << std::endl; } From d47a806c64e8d1711ad448af169f98463feb1c4d Mon Sep 17 00:00:00 2001 From: William Moberg Date: Mon, 29 Feb 2016 15:49:23 +0100 Subject: [PATCH 088/252] Made a easy hack to solve jittering when standing still. Jittering should still be present when moving, but at least it is less prominent when moving. --- src/Engine/Collision/CollisionSystem.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Engine/Collision/CollisionSystem.cpp b/src/Engine/Collision/CollisionSystem.cpp index 9689bf13..95609ea6 100644 --- a/src/Engine/Collision/CollisionSystem.cpp +++ b/src/Engine/Collision/CollisionSystem.cpp @@ -12,6 +12,7 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c if (!boundingBox) { return; } + ComponentWrapper& cTransform = entity["Transform"]; EntityAABB& boxA = *boundingBox; bool everHitTheGround = false; @@ -86,10 +87,12 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c glm::mat4 modelMatrix = Transform::ModelMatrix(boxB.Entity); glm::vec3 inOutVelocity = (glm::vec3)cPhysics["Velocity"]; + bool notMovingxz = glm::all(glm::lessThan(glm::abs(glm::vec2(inOutVelocity.x, inOutVelocity.z)), glm::vec2(0.01f))) && prevPosIt != m_PrevPositions.end(); bool isOnGround = (bool)cPhysics["IsOnGround"]; float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"]; if (Collision::AABBvsTriangles(boxA, model->Vertices(), model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) { - (glm::vec3&)cTransform["Position"] += resolutionVector; + //Move the position to previous position if it is not moving in the xz-plane, else resolve with the resolution vector. + (glm::vec3&)cTransform["Position"] += notMovingxz ? prevPosIt->second - boxA.Origin() : resolutionVector; boxA = *Collision::EntityAbsoluteAABB(entity); cPhysics["Velocity"] = inOutVelocity; if (isOnGround) { From 3c35c0a956ce470e2abef733f99aea0dbe61221a Mon Sep 17 00:00:00 2001 From: William Moberg Date: Mon, 29 Feb 2016 15:50:26 +0100 Subject: [PATCH 089/252] Frustum culling octree updates after collisions, no more disappearing weapons. --- src/Game/Game.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 24b7cd1e..65dbf7e5 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -135,7 +135,6 @@ Game::Game(int argc, char* argv[]) ++updateOrderLevel; m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeCollision, "Collidable"); m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeTrigger, "Player"); - m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeFrustrumCulling); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); @@ -145,6 +144,9 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeCollision); m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeTrigger); + // Octree for frustum culling must be updated after collisions, otherwise players frustum may be moved after tree is filled, and wrong things are culled. + ++updateOrderLevel; + m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeFrustrumCulling); ++updateOrderLevel; m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer, m_RenderFrame, m_OctreeFrustrumCulling); ++updateOrderLevel; From 5bc0483f491417ad7cbbcba7de7e8760176c98c8 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Mon, 29 Feb 2016 15:51:37 +0100 Subject: [PATCH 090/252] Removed AnimationOffset and improved BlendTree --- include/Engine/Core/EntityWrapper.h | 1 + include/Engine/Rendering/BlendTree.h | 2 +- resources/Schema/Components.xsd | 1 - .../Schema/Components/AnimationOffset.xml | 5 - .../Schema/Components/AnimationOffset.xsd | 17 - resources/Schema/Entities/AnimationTests2.xml | 1190 +++++++++++------ resources/Schema/Types/Entity.xsd | 1 - src/Engine/Core/EntityWrapper.cpp | 25 + src/Engine/Rendering/AnimationSystem.cpp | 20 +- src/Engine/Rendering/BlendTree.cpp | 44 +- 10 files changed, 847 insertions(+), 459 deletions(-) delete mode 100644 resources/Schema/Components/AnimationOffset.xml delete mode 100644 resources/Schema/Components/AnimationOffset.xsd diff --git a/include/Engine/Core/EntityWrapper.h b/include/Engine/Core/EntityWrapper.h index b0e65d9e..aa4cae6b 100644 --- a/include/Engine/Core/EntityWrapper.h +++ b/include/Engine/Core/EntityWrapper.h @@ -28,6 +28,7 @@ struct EntityWrapper void AttachComponent(const char* componentName); EntityWrapper Parent(); EntityWrapper FirstChildByName(const std::string& name); + EntityWrapper FirstLevelChildByName(const std::string& name); EntityWrapper FirstParentWithComponent(const std::string& componentType); bool IsChildOf(EntityWrapper potentialParent); bool Valid() const; diff --git a/include/Engine/Rendering/BlendTree.h b/include/Engine/Rendering/BlendTree.h index a472465b..5b38080d 100644 --- a/include/Engine/Rendering/BlendTree.h +++ b/include/Engine/Rendering/BlendTree.h @@ -63,7 +63,7 @@ public: std::vector GetFinalPose() { return m_FinalPose; } glm::mat4 GetBoneTransform(int boneID); - + bool IsValid() { return (m_Root == nullptr ? false : true); } void PrintTree(); diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index fc72762e..a30a4e2c 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -33,7 +33,6 @@ - diff --git a/resources/Schema/Components/AnimationOffset.xml b/resources/Schema/Components/AnimationOffset.xml deleted file mode 100644 index 4aef8219..00000000 --- a/resources/Schema/Components/AnimationOffset.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/resources/Schema/Components/AnimationOffset.xsd b/resources/Schema/Components/AnimationOffset.xsd deleted file mode 100644 index c3430cc2..00000000 --- a/resources/Schema/Components/AnimationOffset.xsd +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - Aim animation offset for the skeleton - - - - - - - - - \ No newline at end of file diff --git a/resources/Schema/Entities/AnimationTests2.xml b/resources/Schema/Entities/AnimationTests2.xml index ca7c705d..84663233 100644 --- a/resources/Schema/Entities/AnimationTests2.xml +++ b/resources/Schema/Entities/AnimationTests2.xml @@ -2,6 +2,10 @@ + + 0.5 + 2.2999999523162842 + @@ -42,25 +46,15 @@ - - - - Models/Core/UnitPlane.mesh - - - - - - - - AimAdditive - BlendOverride + Aim + FinalBlend - Models/Characters/Assault/AssaultAnimations.mesh + 4 + Models/Characters/Assault/Assaulttest.mesh @@ -74,56 +68,13 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - + - + - - - - AimRifleA - true - - - - - - - - - ShootRifleAnimation - MovementBlend - - - - - - - - ShootFastRifleU - - 1 - - - - - - - - - RunF - - 1 - - - - - - - @@ -135,380 +86,63 @@ - - - - - - AimAdditive - BlendOverride - - - Models/Characters/Assault/AssaultAnimations.mesh - - - - - - - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - - - - - - - - - - + AimRifleA - - 0.5 + + false true - + - ShootRifleAnimation + WeaponBlend MovementBlend - - - - ShootFastRifleU - - 1 - - - - - - + - BlendWalkRun - StrafeAnimation - 0 - - - - - - - - StrafeLeftF - - 1 - - - - - - - - - RunAnimtaion - WalkAnimation - 1 - - - - - - - - RunF - - 1 - - - - - - - - - WalkF - - 1 - - - - - - - - - - - - - - - - 3 - 0.80000001192092896 - 0.30000001192092896 - - - - - - - - - - - - - AimAdditive - BlendOverride - - - Models/Characters/Assault/AssaultAnimations.mesh - - - - - - - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - - - - - - - - - - - - - AimRifleA - - true - - - - - - - - - ShootRifleAnimation - MovementBlend - - - - - - - - ShootRifleU - - 1 - - - - - - - - - BlendWalkRun - StrafeAnimation - 0 - - - - - - - - StrafeRightF - - 1 - - - - - - - - - RunAnimtaion - WalkAnimation - 0.43000054359436035 - - - - - - - - RunF - - 1 - - - - - - - - - WalkF - - 1 - - - - - - - - - - - - - - - - 3 - 0.30000001192092896 - - - - - - - - - - - - - AimAdditive - BlendOverride - - - Models/Characters/Assault/AssaultAnimations.mesh - - - - - - - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - - - - - - - - - - - - - AimRifleA - - true - - - - - - - - - ShootRifleAnimation - MovementBlend - - - - - - - - BlendWalkRun - StrafeAnimation + ShootBlend + Reload 1 - - - - StrafeRightF - - 1 - - - - - - + - RunAnimtaion - WalkAnimation + ShootFast + ShootSlow 1 - + - CrouchWalkF - + ShootFastRifleU + 1 - + - WalkF - + ShootRifleU + 1 @@ -517,25 +151,229 @@ + + + + ReloadSwitchU + + 1 + + + + + - + - - ReloadSwitchU - - 1 - + + StandCrouchBlend + Jump + 1 + - + + + + + StandMovement + CrouchMovement + 1 + + + + + + + + Walk + StrafeBlend + 1 + + + + + + + + CrouchWalkF + + 1 + + + + + + + + + Left + Right + 1 + + + + + + + + CrouchStrafeLeftF + + 1 + + + + + + + + + CrouchStrafeRightF + + 1 + + + + + + + + + + + + + RunWalkBlend + StrafeBlend + 1 + + + + + + + + Run + Walk + 0 + + + + + + + + RunF + + 1 + + + + + + + + + WalkF + + 1 + + + + + + + + + + + Left + Right + 0 + + + + + + + + StrafeLeftF + + 1 + + + + + + + + + StrafeRightF + + 1 + + + + + + + + + + + + + + + JumpF + + 1 + + + + + + + + + + + + Aim + FinalBlend + + + Models/Characters/Assault/Assaulttest.mesh + + + + + + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + - 3 @@ -544,24 +382,554 @@ + + + + AimRifleA + false + true + + + + + + + + + WeaponBlend + MovementBlend + + + + + + + + ShootBlend + Reload + 1 + + + + + + + + ShootFast + ShootSlow + 1 + + + + + + + + ShootFastRifleU + + 1 + + + + + + + + + ShootRifleU + + 1 + + + + + + + + + + + ReloadSwitchU + + 1 + + + + + + + + + + + StandCrouchBlend + Jump + 1 + + + + + + + + StandMovement + CrouchMovement + 1 + + + + + + + + Walk + StrafeBlend + 1 + + + + + + + + CrouchWalkF + + 1 + + + + + + + + + Left + Right + 1 + + + + + + + + CrouchStrafeLeftF + + 1 + + + + + + + + + CrouchStrafeRightF + + 1 + + + + + + + + + + + + + RunWalkBlend + StrafeBlend + 1 + + + + + + + + Run + Walk + 1 + + + + + + + + RunF + + 1 + + + + + + + + + WalkF + + 1 + + + + + + + + + + + Left + Right + 1 + + + + + + + + StrafeLeftF + + 1 + + + + + + + + + StrafeRightF + + 1 + + + + + + + + + + + + + + + JumpF + + 1 + + + + + + + + + - + + + Aim + FinalBlend + - Models/Core/UnitSphere.mesh - + Models/Characters/Assault/Assaulttest.mesh + - - - 3 - - - + - + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + + + + + 3 + + + + + + + + + + + AimRifleA + + false + true + + + + + + + + + WeaponBlend + MovementBlend + + + + + + + + ShootBlend + Reload + 1 + + + + + + + + ShootFast + ShootSlow + 1 + + + + + + + + ShootFastRifleU + + 1 + + + + + + + + + ShootRifleU + + 1 + + + + + + + + + + + ReloadSwitchU + + 1 + + + + + + + + + + + StandCrouchBlend + Jump + 1 + + + + + + + + StandMovement + CrouchMovement + 0 + + + + + + + + Walk + StrafeBlend + 1 + + + + + + + + CrouchWalkF + + 1 + + + + + + + + + Left + Right + 1 + + + + + + + + CrouchStrafeLeftF + + 1 + + + + + + + + + CrouchStrafeRightF + + 1 + + + + + + + + + + + + + RunWalkBlend + StrafeBlend + 1 + + + + + + + + Run + Walk + 1 + + + + + + + + RunF + + 1 + + + + + + + + + WalkF + + 1 + + + + + + + + + + + Left + Right + 1 + + + + + + + + StrafeLeftF + + 1 + + + + + + + + + StrafeRightF + + 1 + + + + + + + + + + + + + + + JumpF + + 1 + + + + + + + + + + diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index 4fba7420..b0fbd279 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -49,7 +49,6 @@ - diff --git a/src/Engine/Core/EntityWrapper.cpp b/src/Engine/Core/EntityWrapper.cpp index 4b45b8d0..78bca235 100644 --- a/src/Engine/Core/EntityWrapper.cpp +++ b/src/Engine/Core/EntityWrapper.cpp @@ -39,6 +39,31 @@ EntityWrapper EntityWrapper::FirstChildByName(const std::string& name) return firstChildByNameRecursive(name, this->ID); } + +EntityWrapper EntityWrapper::FirstLevelChildByName(const std::string& name) +{ + EntityID parent = this->ID; + if (!this->World->ValidEntity(parent)) { + return EntityWrapper::Invalid; + } + + auto itPair = this->World->GetChildren(parent); + if (itPair.first == itPair.second) { + return EntityWrapper::Invalid; + } + + for (auto it = itPair.first; it != itPair.second; ++it) { + std::string itName = this->World->GetName(it->second); + if (itName == name) { + return EntityWrapper(this->World, it->second); + } else if (it->second != EntityID_Invalid) { + continue; + } + } + + return EntityWrapper::Invalid; +} + EntityWrapper EntityWrapper::FirstParentWithComponent(const std::string& componentType) { EntityWrapper entity = *this; diff --git a/src/Engine/Rendering/AnimationSystem.cpp b/src/Engine/Rendering/AnimationSystem.cpp index 9a74da29..5bc64535 100644 --- a/src/Engine/Rendering/AnimationSystem.cpp +++ b/src/Engine/Rendering/AnimationSystem.cpp @@ -34,7 +34,16 @@ void AnimationSystem::CreateBlendTrees() continue; } - skeleton->BlendTrees[entity] = std::shared_ptr(new BlendTree(entity, skeleton)); + if (entity.HasComponent("Blend") || entity.HasComponent("BlendOverride") || + entity.HasComponent("BlendAdditive") || entity.HasComponent("Animation")) + { + std::shared_ptr blendTree = std::shared_ptr(new BlendTree(entity, skeleton)); + + if(blendTree->IsValid()) { + skeleton->BlendTrees[entity] = blendTree; + } + + } } } @@ -47,11 +56,16 @@ void AnimationSystem::UpdateAnimations(double dt) for (auto& animationC : *animationComponents) { EntityWrapper entity = EntityWrapper(m_World, animationC.EntityID); - EntityWrapper parent = entity.FirstParentWithComponent("Model"); + EntityWrapper modelEntity; + if(!entity.HasComponent("Model")) { + modelEntity = entity.FirstParentWithComponent("Model"); + } else { + modelEntity = entity; + } Model* model; try { - model = ResourceManager::Load<::Model, true>(parent["Model"]["Resource"]); + model = ResourceManager::Load<::Model, true>(modelEntity["Model"]["Resource"]); } catch (const std::exception&) { return; } diff --git a/src/Engine/Rendering/BlendTree.cpp b/src/Engine/Rendering/BlendTree.cpp index 0d87665f..0305af19 100644 --- a/src/Engine/Rendering/BlendTree.cpp +++ b/src/Engine/Rendering/BlendTree.cpp @@ -6,11 +6,6 @@ BlendTree::BlendTree(EntityWrapper ModelEntity, Skeleton* skeleton) m_Skeleton = skeleton; - auto itPair = ModelEntity.World->GetChildren(ModelEntity.ID); - if (itPair.first == itPair.second) { - return; - } - if (ModelEntity.HasComponent("Animation")) { const Skeleton::Animation* animation = skeleton->GetAnimation(ModelEntity["Animation"]["AnimationName"]); @@ -59,20 +54,21 @@ BlendTree::BlendTree(EntityWrapper ModelEntity, Skeleton* skeleton) BlendTree::~BlendTree() { Node* currentNode = m_Root; + if (currentNode != nullptr) { + while (currentNode->Child[0] != nullptr) { + currentNode = currentNode->Child[0]; + } - while (currentNode->Child[0] != nullptr) { - currentNode = currentNode->Child[0]; - } + std::list m_NodesToRemove; - std::list m_NodesToRemove; + while (currentNode != nullptr) { + m_NodesToRemove.push_back(currentNode); + currentNode = currentNode->Next(); + } - while (currentNode != nullptr) { - m_NodesToRemove.push_back(currentNode); - currentNode = currentNode->Next(); - } - - for (auto it = m_NodesToRemove.begin(); it != m_NodesToRemove.end(); it++) { - delete (*it); + for (auto it = m_NodesToRemove.begin(); it != m_NodesToRemove.end(); it++) { + delete (*it); + } } } @@ -107,7 +103,7 @@ void BlendTree::PrintTree() BlendTree::Node* BlendTree::FillTreeByName(Node* parentNode, std::string name, EntityWrapper parentEntity) { - EntityWrapper childEntity = parentEntity.FirstChildByName(name); // Make first level child by name + EntityWrapper childEntity = parentEntity.FirstLevelChildByName(name); // Make first level child by name if (!childEntity.Valid()) { return nullptr; @@ -133,8 +129,16 @@ BlendTree::Node* BlendTree::FillTreeByName(Node* parentNode, std::string name, E node->Type = NodeType::Blend; (double&)childEntity["Blend"]["Weight"] = glm::clamp((float)(double)childEntity["Blend"]["Weight"], 0.f, 1.f); node->Weight = (double)childEntity["Blend"]["Weight"]; - node->Child[0] = FillTreeByName(node, (std::string)childEntity["Blend"]["Pose1"], childEntity); - node->Child[1] = FillTreeByName(node, (std::string)childEntity["Blend"]["Pose2"], childEntity); + if (node->Weight < 1.f && node->Weight > 0.f) { + node->Child[0] = FillTreeByName(node, (std::string)childEntity["Blend"]["Pose1"], childEntity); + node->Child[1] = FillTreeByName(node, (std::string)childEntity["Blend"]["Pose2"], childEntity); + } else if (node->Weight == 1.f) { + node->Child[0] = FillTreeByName(node, (std::string)childEntity["Blend"]["Pose1"], childEntity); + } else if (node->Weight == 0.f) { + node->Child[1] = FillTreeByName(node, (std::string)childEntity["Blend"]["Pose2"], childEntity); + } + + return node; } else if (childEntity.HasComponent("BlendOverride")) { Node* node = new Node(); @@ -213,7 +217,7 @@ void BlendTree::Blend(std::map& pose) std::vector BlendTree::AccumulateFinalPose() { std::vector finalPose; - if (m_Skeleton == nullptr || m_Root == nullptr) { + if (m_Skeleton == nullptr || m_Root == nullptr || (m_Root->Child[0] == nullptr && m_Root->Child[1] == nullptr)) { for (int i = 0; i < m_Skeleton->Bones.size(); i++) { finalPose.push_back(glm::mat4(1)); From 658eace09304f0e974dd70da05d285aaed912384 Mon Sep 17 00:00:00 2001 From: William Moberg Date: Mon, 29 Feb 2016 18:20:14 +0100 Subject: [PATCH 091/252] Added component CapturePointGameMode that contains respawntime. --- include/Game/Systems/PlayerSpawnSystem.h | 6 ++-- resources/Schema/Components.xsd | 1 + .../Components/CapturePointGameMode.xml | 5 +++ .../Components/CapturePointGameMode.xsd | 18 ++++++++++ src/Game/Game.cpp | 1 - src/Game/Systems/PlayerSpawnSystem.cpp | 35 ++++++++++++------- 6 files changed, 49 insertions(+), 17 deletions(-) create mode 100644 resources/Schema/Components/CapturePointGameMode.xml create mode 100644 resources/Schema/Components/CapturePointGameMode.xsd diff --git a/include/Game/Systems/PlayerSpawnSystem.h b/include/Game/Systems/PlayerSpawnSystem.h index bf87bef8..70f94807 100644 --- a/include/Game/Systems/PlayerSpawnSystem.h +++ b/include/Game/Systems/PlayerSpawnSystem.h @@ -13,8 +13,6 @@ public: PlayerSpawnSystem(SystemParams params); virtual void Update(double dt) override; - - static void SetRespawnTime(float respawnTime) { m_RespawnTime = respawnTime; }; private: struct SpawnRequest @@ -31,8 +29,8 @@ private: //EntityWrapper ID -> Player ID. std::map m_PlayerIDs; - static float m_RespawnTime; - float m_Timer; + float m_ForcedRespawnTime; + bool m_DbgConfigForceRespawn; EventRelay m_OnInputCommand; bool OnInputCommand(Events::InputCommand& e); diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index cad50c7e..f0bb67d2 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -48,4 +48,5 @@ + \ No newline at end of file diff --git a/resources/Schema/Components/CapturePointGameMode.xml b/resources/Schema/Components/CapturePointGameMode.xml new file mode 100644 index 00000000..3104e71f --- /dev/null +++ b/resources/Schema/Components/CapturePointGameMode.xml @@ -0,0 +1,5 @@ + + + 0.0 + 8.0 + \ No newline at end of file diff --git a/resources/Schema/Components/CapturePointGameMode.xsd b/resources/Schema/Components/CapturePointGameMode.xsd new file mode 100644 index 00000000..8b81d67a --- /dev/null +++ b/resources/Schema/Components/CapturePointGameMode.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + The time since the last respawn wave. Players will be spawned when this reaches MaxRespawnTime. + + + Players will be spawned when RespawnTime reaches this. + + + + + \ No newline at end of file diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 5388fd04..3914c3bf 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -48,7 +48,6 @@ Game::Game(int argc, char* argv[]) ResourceManager::UseThreading = m_Config->Get("Multithreading.ResourceLoading", true); DisableMemoryPool::Value = m_Config->Get("Debug.DisableMemoryPool", false); LOG_LEVEL = static_cast<_LOG_LEVEL>(m_Config->Get("Debug.LogLevel", 1)); - PlayerSpawnSystem::SetRespawnTime(m_Config->Get("Debug.RespawnTime", 15.0f)); // Create the core event broker m_EventBroker = new EventBroker(); diff --git a/src/Game/Systems/PlayerSpawnSystem.cpp b/src/Game/Systems/PlayerSpawnSystem.cpp index 6254c674..1ee674cb 100644 --- a/src/Game/Systems/PlayerSpawnSystem.cpp +++ b/src/Game/Systems/PlayerSpawnSystem.cpp @@ -1,29 +1,40 @@ #include "Systems/PlayerSpawnSystem.h" -//This should be set by the config anyway. -float PlayerSpawnSystem::m_RespawnTime = 15.0f; - PlayerSpawnSystem::PlayerSpawnSystem(SystemParams params) : System(params) - , m_Timer(0.f) + , m_DbgConfigForceRespawn(false) { EVENT_SUBSCRIBE_MEMBER(m_OnInputCommand, &PlayerSpawnSystem::OnInputCommand); EVENT_SUBSCRIBE_MEMBER(m_OnPlayerSpawnerd, &PlayerSpawnSystem::OnPlayerSpawned); EVENT_SUBSCRIBE_MEMBER(m_OnPlayerDeath, &PlayerSpawnSystem::OnPlayerDeath); - m_NetworkEnabled = ResourceManager::Load("Config.ini")->Get("Networking.StartNetwork", false); + ConfigFile* config = ResourceManager::Load("Config.ini"); + m_NetworkEnabled = config->Get("Networking.StartNetwork", false); + m_ForcedRespawnTime = config->Get("Debug.RespawnTime", -1.0f); + m_DbgConfigForceRespawn = m_ForcedRespawnTime > 0; } void PlayerSpawnSystem::Update(double dt) { - //Increase timer. - m_Timer += dt; - if (m_Timer < m_RespawnTime) { - return; + // If there are no CapturePointGameMode components we will just spawn immediately. + // Should be able to support older maps with this. + // TODO: In the future we might want to return instead, to avoid spawning in the menu for instance. + auto pool = m_World->GetComponents("CapturePointGameMode"); + if (pool != nullptr) + { + // Take the first CapturePointGameMode component found. + ComponentWrapper& modeComponent = *pool->begin(); + // Increase timer. + double& timer = (double&)modeComponent["RespawnTime"]; + timer += dt; + double maxRespawnTime = m_DbgConfigForceRespawn ? m_ForcedRespawnTime : (double)modeComponent["MaxRespawnTime"]; + if (timer < maxRespawnTime) { + return; + } + // If respawn time has passed, we spawn all players that have requested to be spawned. + timer = 0; } - //If respawn time has passed, we spawn all players that have requested to be spawned. - m_Timer = 0.f; - //If there are no spawn requests, return immediately, if we are client the SpawnRequests should always be empty. + // If there are no spawn requests, return immediately, if we are client the SpawnRequests should always be empty. if (m_SpawnRequests.size() == 0) { return; } From 70374fa10e53f113f7e7eb4a935f1cc2bc9a86c7 Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Mon, 29 Feb 2016 18:20:32 +0100 Subject: [PATCH 092/252] It compiles, but no shadows --- .../Engine/Rendering/DirectionalLightJob.h | 1 - include/Engine/Rendering/ShadowPass.h | 16 +++--- .../Shaders/ForwardPlusSkinned.vert.glsl | 2 + .../Shaders/ForwardPlusSplatMapRGB.frag.glsl | 1 + src/Engine/Rendering/FrameBuffer.cpp | 56 +++++++++---------- src/Engine/Rendering/ShadowPass.cpp | 43 +++++++++----- 6 files changed, 68 insertions(+), 51 deletions(-) diff --git a/include/Engine/Rendering/DirectionalLightJob.h b/include/Engine/Rendering/DirectionalLightJob.h index 0fcfaf84..4c12b1ed 100644 --- a/include/Engine/Rendering/DirectionalLightJob.h +++ b/include/Engine/Rendering/DirectionalLightJob.h @@ -17,7 +17,6 @@ struct DirectionalLightJob : RenderJob { Orientation = Transform::AbsoluteOrientation(m_World, transformComponent.EntityID); Direction = glm::vec4(0,0,-1,0) * glm::inverse(Orientation); - //Direction = glm::vec4((glm::vec3)directionalLightComponent["Direction"], 0.f); Color = (glm::vec4)directionalLightComponent["Color"]; Intensity = (double)directionalLightComponent["Intensity"]; }; diff --git a/include/Engine/Rendering/ShadowPass.h b/include/Engine/Rendering/ShadowPass.h index c4007cce..3f506cb7 100644 --- a/include/Engine/Rendering/ShadowPass.h +++ b/include/Engine/Rendering/ShadowPass.h @@ -14,7 +14,7 @@ enum NearFar { NEAR = 0, FAR = 1 }; enum LRBT { LEFT = 0, RIGHT = 1, BOTTOM = 2, TOP = 3 }; -struct Frustum +struct ShadowFrustum { float NearClip; float FarClip; @@ -47,14 +47,14 @@ public: void SetSplitWeight(float split_weight) { m_SplitWeight = split_weight; }; private: void InitializeCameras(RenderScene & scene); - void UpdateSplitDist(std::array& frusta, float near_distance, float far_distance); - void UpdateFrustumPoints(Frustum& frustum, glm::vec3 camera_position, glm::vec3 view_dir); - void UpdateFrustumPoints(Frustum& frustum, glm::mat4 p, glm::mat4 v); + void UpdateSplitDist(std::array& frusta, float near_distance, float far_distance); + void UpdateFrustumPoints(ShadowFrustum& frustum, glm::vec3 camera_position, glm::vec3 view_dir); + void UpdateFrustumPoints(ShadowFrustum& frustum, glm::mat4 p, glm::mat4 v); - void PointsToLightspace(Frustum& frustum, glm::mat4 v); + void PointsToLightspace(ShadowFrustum& frustum, glm::mat4 v); - float FindRadius(Frustum& frustum); - void RadiusToLightspace(Frustum& frustum); + float FindRadius(ShadowFrustum& frustum); + void RadiusToLightspace(ShadowFrustum& frustum); EventBroker* m_EventBroker; const IRenderer* m_Renderer; @@ -74,7 +74,7 @@ private: int m_CurrentNrOfSplits = 4; float m_SplitWeight = 0.91f; - std::array m_shadowFrusta; + std::array m_shadowFrusta; Texture* m_WhiteTexture = ResourceManager::Load("Textures/Core/White.png"); }; diff --git a/resources/Shaders/ForwardPlusSkinned.vert.glsl b/resources/Shaders/ForwardPlusSkinned.vert.glsl index 5fd55a8c..83db983b 100644 --- a/resources/Shaders/ForwardPlusSkinned.vert.glsl +++ b/resources/Shaders/ForwardPlusSkinned.vert.glsl @@ -21,6 +21,7 @@ out VertexData{ vec2 TextureCoordinate; vec4 ExplosionColor; float ExplosionPercentageElapsed; + vec4 PositionLightSpace[MAX_SPLITS]; }Output; void main() @@ -43,4 +44,5 @@ void main() Output.BiTangent = vec3(M * vec4(BiTangent, 0.0)); Output.ExplosionColor = vec4(1.0); Output.ExplosionPercentageElapsed = 0.0; + Output.PositionLightSpace = boneTransform * vec4(Position, 1.0); } \ No newline at end of file diff --git a/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl b/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl index cf358b96..af50155d 100644 --- a/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl +++ b/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl @@ -82,6 +82,7 @@ in VertexData{ vec2 TextureCoordinate; vec4 ExplosionColor; float ExplosionPercentageElapsed; + vec4 PositionLightSpace[MAX_SPLITS]; }Input; out vec4 sceneColor; diff --git a/src/Engine/Rendering/FrameBuffer.cpp b/src/Engine/Rendering/FrameBuffer.cpp index e0dd9b2d..167de142 100644 --- a/src/Engine/Rendering/FrameBuffer.cpp +++ b/src/Engine/Rendering/FrameBuffer.cpp @@ -61,45 +61,45 @@ void FrameBuffer::Generate() glBindFramebuffer(GL_FRAMEBUFFER, m_BufferHandle); GLERROR("1"); - for (auto it = m_Resources.begin(); it != m_Resources.end(); it++) { - switch ((*it)->m_ResourceType) { - case GL_TEXTURE_2D: - glFramebufferTexture2D(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle, 0); + for (auto it = m_Resources.begin(); it != m_Resources.end(); it++) { + switch ((*it)->m_ResourceType) { + case GL_TEXTURE_2D: + glFramebufferTexture2D(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle, 0); attachments.push_back((*it)->m_Attachment); - GLERROR("FrameBuffer generate: glFramebufferTexture2D"); - break; - case GL_RENDERBUFFER: - glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle); - GLERROR("FrameBuffer generate: glFramebufferRenderbuffer"); - break; + GLERROR("FrameBuffer generate: glFramebufferTexture2D"); + break; + case GL_RENDERBUFFER: + glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle); + GLERROR("FrameBuffer generate: glFramebufferRenderbuffer"); + break; case GL_TEXTURE_2D_ARRAY: glFramebufferTexture(GL_FRAMEBUFFER, (*it)->m_Attachment, *(*it)->m_ResourceHandle, 0); attachments.push_back((*it)->m_Attachment); GLERROR("FrameBuffer generate: GL_TEXTURE_2D_ARRAY"); break; - } - GLERROR("2"); + } + GLERROR("2"); - if ((*it)->m_Attachment != GL_DEPTH_ATTACHMENT && (*it)->m_Attachment != GL_STENCIL_ATTACHMENT && (*it)->m_Attachment != GL_DEPTH_STENCIL_ATTACHMENT) { - GLERROR("Attachment"); + if ((*it)->m_Attachment != GL_DEPTH_ATTACHMENT && (*it)->m_Attachment != GL_STENCIL_ATTACHMENT && (*it)->m_Attachment != GL_DEPTH_STENCIL_ATTACHMENT) { + GLERROR("Attachment"); - } - GLERROR("3"); + } + GLERROR("3"); - GLenum* bufferTextures = &attachments[0]; - glDrawBuffers(attachments.size(), bufferTextures); - if (GLERROR("GLBufferAttachement error")) { - printf(": AttachmentSize %i", attachments.size()); - } - - if (GLenum frameBufferStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { - GLERROR("Framebuffer incomplete"); - //LOG_ERROR("FrameBuffer incomplete: 0x%x\n", frameBufferStatus); - exit(EXIT_FAILURE); - } - GLERROR("END"); + GLenum* bufferTextures = &attachments[0]; + glDrawBuffers(attachments.size(), bufferTextures); + if (GLERROR("GLBufferAttachement error")) { + printf(": AttachmentSize %i", attachments.size()); + } + if (GLenum frameBufferStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { + GLERROR("Framebuffer incomplete"); + //LOG_ERROR("FrameBuffer incomplete: 0x%x\n", frameBufferStatus); + exit(EXIT_FAILURE); + } + GLERROR("END"); + } } void FrameBuffer::Bind() diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index 185d24ab..df0da0e1 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -34,7 +34,7 @@ void ShadowPass::InitializeCameras(RenderScene & scene) // UpdateSplitDist computes the near and far distances for every frustum slice // in camera eye space - that is, at what distance does a slice start and end -void ShadowPass::UpdateSplitDist(std::array& frusta, float near_distance, float far_distance) +void ShadowPass::UpdateSplitDist(std::array& frusta, float near_distance, float far_distance) { float lambda = m_SplitWeight; float ratio = far_distance / near_distance; @@ -51,7 +51,7 @@ void ShadowPass::UpdateSplitDist(std::array& frusta, float frusta[m_CurrentNrOfSplits - 1].FarClip = far_distance; } -void ShadowPass::UpdateFrustumPoints(Frustum& frustum, glm::mat4 p, glm::mat4 v) +void ShadowPass::UpdateFrustumPoints(ShadowFrustum& frustum, glm::mat4 p, glm::mat4 v) { std::array CornerPoint = { glm::vec4(-1.f, -1.f, -1.f, 1.f), @@ -72,7 +72,7 @@ void ShadowPass::UpdateFrustumPoints(Frustum& frustum, glm::mat4 p, glm::mat4 v) } // Compute the 8 corner points of the current view frustum in world space -void ShadowPass::UpdateFrustumPoints(Frustum& frustum, glm::vec3 camera_position, glm::vec3 view_dir) +void ShadowPass::UpdateFrustumPoints(ShadowFrustum& frustum, glm::vec3 camera_position, glm::vec3 view_dir) { glm::vec3 up = glm::vec3(0.f, 1.f, 0.f); glm::vec3 right = glm::normalize(glm::cross(view_dir, up)); @@ -100,7 +100,7 @@ void ShadowPass::UpdateFrustumPoints(Frustum& frustum, glm::vec3 camera_position frustum.CornerPoint[7] = far_center - up * far_height + right * far_width; } -float ShadowPass::FindRadius(Frustum& frustum) +float ShadowPass::FindRadius(ShadowFrustum& frustum) { float radius = 0.f; @@ -164,7 +164,7 @@ void ShadowPass::ClearBuffer() m_DepthBuffer.Unbind(); } -void ShadowPass::PointsToLightspace(Frustum& frustum, glm::mat4 v) +void ShadowPass::PointsToLightspace(ShadowFrustum& frustum, glm::mat4 v) { float left = INFINITY; float right = -INFINITY; @@ -184,7 +184,7 @@ void ShadowPass::PointsToLightspace(Frustum& frustum, glm::mat4 v) frustum.LRBT = { left, right, bottom, top }; } -void ShadowPass::RadiusToLightspace(Frustum& frustum) +void ShadowPass::RadiusToLightspace(ShadowFrustum& frustum) { float quantizationStep = 1.0f / m_ResolutionSizeHeight; @@ -214,7 +214,7 @@ void ShadowPass::Draw(RenderScene & scene) glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_DepthMap, 0, i); - for (auto &job : scene.DirectionalLightJobs) { + for (auto &job : scene.Jobs.DirectionalLight) { auto directionalLightJob = std::dynamic_pointer_cast(job); if (directionalLightJob) { @@ -230,7 +230,7 @@ void ShadowPass::Draw(RenderScene & scene) GLERROR("ShadowLight ERROR"); - for (auto &objectJob : scene.OpaqueObjects) { + for (auto &objectJob : scene.Jobs.OpaqueObjects) { if (!std::dynamic_pointer_cast(objectJob)) { auto modelJob = std::dynamic_pointer_cast(objectJob); @@ -246,20 +246,35 @@ void ShadowPass::Draw(RenderScene & scene) } state->CullFace(GL_BACK); - for (auto &objectJob : scene.TransparentObjects) { + for (auto &objectJob : scene.Jobs.TransparentObjects) { if (!std::dynamic_pointer_cast(objectJob)) { auto modelJob = std::dynamic_pointer_cast(objectJob); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), modelJob->Color.a); - - glActiveTexture(GL_TEXTURE24); - if (modelJob->DiffuseTexture != nullptr) { - glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture->m_Texture); + + switch (modelJob->Type) { + case RawModel::MaterialType::SingleTextures: + case RawModel::MaterialType::Basic: + { + glActiveTexture(GL_TEXTURE24); + if (modelJob->DiffuseTexture.size() > 0 && modelJob->DiffuseTexture[0]->Texture != nullptr) { + glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture[0]->Texture->m_Texture); + glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(modelJob->DiffuseTexture[0]->UVRepeat)); + } + else { + glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); + glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f))); + } + break; } - else { + case RawModel::MaterialType::SplatMapping: + { glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); + glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f))); + break; + } } glBindVertexArray(modelJob->Model->VAO); From 2ed5fad6996778e21b734b9f9015d049fd49f7bc Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Mon, 29 Feb 2016 19:17:16 +0100 Subject: [PATCH 093/252] The shadows are working --- resources/Shaders/ForwardPlus.frag.glsl | 7 ++++--- resources/Shaders/ForwardPlus.vert.glsl | 8 -------- src/Engine/Rendering/DrawFinalPass.cpp | 18 ++++++++---------- src/Engine/Rendering/ShadowPass.cpp | 6 +++--- 4 files changed, 15 insertions(+), 24 deletions(-) diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index d1c75cd0..fc7527be 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -2,6 +2,7 @@ #define MAX_SPLITS 4 #define MIN_AMBIENT_LIGHT 0.3 +#define SHADOW_STRENGTH 0.3 //Should be ambient uniform mat4 M; uniform mat4 V; @@ -235,7 +236,7 @@ float CalcShadowValue(vec4 light_space_pos, vec3 normal, vec3 light_dir, sampler //shadowMapDepth = PoissonDotShadow(depth_texture_array, projCoords, layer_index, 4, 25.0 * FarDistance[MAX_SPLITS - 1]); shadowMapDepth = SoftwarePCF(depth_texture_array, projCoords, layer_index, bias); - return 1.0 - shadowMapDepth; + return shadowMapDepth; } int getShadowIndex(float far_distance[1]) @@ -342,8 +343,8 @@ void main() totalLighting.Specular += vec4(light_result.Specular.rgb * ao, light_result.Specular.a); } - totalLighting.Diffuse *= (1.5 + vec4(AmbientColor.rgba)) - vec4(vec3(shadowFactor), 0.0); - totalLighting.Specular *= (1.5 + vec4(AmbientColor.rgba)) - vec4(vec3(shadowFactor), 0.0); + totalLighting.Diffuse *= vec4(min(vec3(shadowFactor) + AmbientColor.xyz, vec3(1.0)), 1.0); + totalLighting.Specular *= vec4(min(vec3(shadowFactor) + AmbientColor.xyz, vec3(1.0)), 1.0); //LightResult getInformation; diff --git a/resources/Shaders/ForwardPlus.vert.glsl b/resources/Shaders/ForwardPlus.vert.glsl index b8d42b14..2a54415b 100644 --- a/resources/Shaders/ForwardPlus.vert.glsl +++ b/resources/Shaders/ForwardPlus.vert.glsl @@ -25,14 +25,6 @@ out VertexData{ vec4 PositionLightSpace[MAX_SPLITS]; }Output; -// N -mat4 biasMatrix = mat4( -vec4(0.5, 0.0, 0.0, 0.0), -vec4(0.0, 0.5, 0.0, 0.0), -vec4(0.0, 0.0, 0.5, 0.0), -vec4(0.5, 0.5, 0.5, 1.0) -); - void main() { gl_Position = P*V*M * vec4(Position, 1.0); diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 11249703..4470ad1b 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -1014,6 +1014,14 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptrm_Texture); glUniform2fv(glGetUniformLocation(shaderHandle, "GlowUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f))); } + + glActiveTexture(GL_TEXTURE6); + if (m_ShadowPass->DepthMap() != NULL) { + glBindTexture(GL_TEXTURE_2D_ARRAY, m_ShadowPass->DepthMap()); + } + else { + glBindTexture(GL_TEXTURE_2D_ARRAY, m_WhiteTexture->m_Texture); + } break; } case RawModel::MaterialType::SplatMapping: @@ -1081,15 +1089,5 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptrDepthMap() != NULL) { - glBindTexture(GL_TEXTURE_2D_ARRAY, m_ShadowPass->DepthMap()); - } - else { - glBindTexture(GL_TEXTURE_2D_ARRAY, m_WhiteTexture->m_Texture); - } - - } diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index df0da0e1..0fa2193a 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -253,8 +253,8 @@ void ShadowPass::Draw(RenderScene & scene) glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), modelJob->Color.a); - - switch (modelJob->Type) { + + /*switch (modelJob->Type) { case RawModel::MaterialType::SingleTextures: case RawModel::MaterialType::Basic: { @@ -275,7 +275,7 @@ void ShadowPass::Draw(RenderScene & scene) glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f))); break; } - } + }*/ glBindVertexArray(modelJob->Model->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer); From 0908be1e0200092e4c855579badc281f5a3008a0 Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Mon, 29 Feb 2016 19:45:56 +0100 Subject: [PATCH 094/252] Shadows are pretty much done. --- .../Engine/Rendering/DirectionalLightJob.h | 2 + .../Schema/Components/DirectionalLight.xml | 1 + .../Schema/Components/DirectionalLight.xsd | 1 + resources/Shaders/ForwardPlus.frag.glsl | 1 - src/Engine/Rendering/ShadowPass.cpp | 40 ++++++++++--------- 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/include/Engine/Rendering/DirectionalLightJob.h b/include/Engine/Rendering/DirectionalLightJob.h index 4c12b1ed..65d477d1 100644 --- a/include/Engine/Rendering/DirectionalLightJob.h +++ b/include/Engine/Rendering/DirectionalLightJob.h @@ -19,12 +19,14 @@ struct DirectionalLightJob : RenderJob Direction = glm::vec4(0,0,-1,0) * glm::inverse(Orientation); Color = (glm::vec4)directionalLightComponent["Color"]; Intensity = (double)directionalLightComponent["Intensity"]; + //TextureAlphaShadows = (bool)directionalLightComponent["TextureAlphaShadows"]; }; glm::quat Orientation; glm::vec4 Direction; glm::vec4 Color; float Intensity; + bool TextureAlphaShadows = false; void CalculateHash() override { diff --git a/resources/Schema/Components/DirectionalLight.xml b/resources/Schema/Components/DirectionalLight.xml index 7f777ef8..a4b22985 100644 --- a/resources/Schema/Components/DirectionalLight.xml +++ b/resources/Schema/Components/DirectionalLight.xml @@ -2,5 +2,6 @@ 0.8 + true \ No newline at end of file diff --git a/resources/Schema/Components/DirectionalLight.xsd b/resources/Schema/Components/DirectionalLight.xsd index a14248a8..692d9677 100644 --- a/resources/Schema/Components/DirectionalLight.xsd +++ b/resources/Schema/Components/DirectionalLight.xsd @@ -9,6 +9,7 @@ + diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index fc7527be..0fd76f80 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -2,7 +2,6 @@ #define MAX_SPLITS 4 #define MIN_AMBIENT_LIGHT 0.3 -#define SHADOW_STRENGTH 0.3 //Should be ambient uniform mat4 M; uniform mat4 V; diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index 0fa2193a..14cfcc09 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -254,28 +254,31 @@ void ShadowPass::Draw(RenderScene & scene) glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), modelJob->Color.a); - /*switch (modelJob->Type) { - case RawModel::MaterialType::SingleTextures: - case RawModel::MaterialType::Basic: - { - glActiveTexture(GL_TEXTURE24); - if (modelJob->DiffuseTexture.size() > 0 && modelJob->DiffuseTexture[0]->Texture != nullptr) { - glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture[0]->Texture->m_Texture); - glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(modelJob->DiffuseTexture[0]->UVRepeat)); + if (directionalLightJob->TextureAlphaShadows) { + switch (modelJob->Type) { + case RawModel::MaterialType::SingleTextures: + case RawModel::MaterialType::Basic: + { + glActiveTexture(GL_TEXTURE24); + if (modelJob->DiffuseTexture.size() > 0 && modelJob->DiffuseTexture[0]->Texture != nullptr) { + glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture[0]->Texture->m_Texture); + glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(modelJob->DiffuseTexture[0]->UVRepeat)); + } + else { + glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); + glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f))); + } + break; } - else { + case RawModel::MaterialType::SplatMapping: + { + glActiveTexture(GL_TEXTURE24); glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f))); + break; + } } - break; } - case RawModel::MaterialType::SplatMapping: - { - glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); - glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f))); - break; - } - }*/ glBindVertexArray(modelJob->Model->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer); @@ -288,7 +291,8 @@ void ShadowPass::Draw(RenderScene & scene) } } } - m_ShadowProgram->Unbind(); + glActiveTexture(GL_TEXTURE24); + glDisable(GL_TEXTURE_2D); glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); m_DepthBuffer.Unbind(); delete state; From 4153a31e3a3fe9b1bb17cba766f76cdeae21fbfb Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Mon, 29 Feb 2016 19:47:24 +0100 Subject: [PATCH 095/252] Fix goof. --- src/Engine/Rendering/ShadowPass.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index 14cfcc09..3fc2c5d0 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -291,8 +291,6 @@ void ShadowPass::Draw(RenderScene & scene) } } } - glActiveTexture(GL_TEXTURE24); - glDisable(GL_TEXTURE_2D); glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); m_DepthBuffer.Unbind(); delete state; From e2b7e5400da7cf8e95fbfc7da47b6f385a40b1ba Mon Sep 17 00:00:00 2001 From: William Moberg Date: Tue, 1 Mar 2016 10:20:52 +0100 Subject: [PATCH 096/252] Check so CapturePointGameMode pool exists and has a size. --- src/Game/Systems/PlayerSpawnSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Game/Systems/PlayerSpawnSystem.cpp b/src/Game/Systems/PlayerSpawnSystem.cpp index 1ee674cb..e03a1778 100644 --- a/src/Game/Systems/PlayerSpawnSystem.cpp +++ b/src/Game/Systems/PlayerSpawnSystem.cpp @@ -19,7 +19,7 @@ void PlayerSpawnSystem::Update(double dt) // Should be able to support older maps with this. // TODO: In the future we might want to return instead, to avoid spawning in the menu for instance. auto pool = m_World->GetComponents("CapturePointGameMode"); - if (pool != nullptr) + if (pool != nullptr && pool->size() > 0) { // Take the first CapturePointGameMode component found. ComponentWrapper& modeComponent = *pool->begin(); From 21bf7f4df3794dd53257bcab5381393f0566dea9 Mon Sep 17 00:00:00 2001 From: Tleety Date: Tue, 1 Mar 2016 11:03:16 +0100 Subject: [PATCH 097/252] Glow should now legit be working through transparency. --- resources/Shaders/ForwardPlus.frag.glsl | 8 ++++---- src/Engine/Rendering/DrawFinalPass.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 6fbc9c27..a3230eb1 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -169,8 +169,8 @@ void main() vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); - float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0; - color_result = color_result * clamp(1/specularTexel, 0, 1)*2 + reflectionColor * clamp(specularTexel, 0, 1)/2; + //float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0; + //color_result = color_result * clamp(1/specularTexel, 0, 1)*2 + reflectionColor * clamp(specularTexel, 0, 1)/2; //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; @@ -181,9 +181,9 @@ void main() } sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1)); //sceneColor = vec4(reflectionColor.xyz, 1); - color_result += glowTexel*GlowIntensity; + color_result.xyz += glowTexel.xyz*GlowIntensity; - bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), clamp(color_result.a, 0, 1)); + bloomColor = vec4(max(color_result.xyz - 1.0, 0.0), clamp(color_result.a, 0, 1)); //Tiled Debug Code /* diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 6cd2c1f1..d084b919 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -193,10 +193,12 @@ void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture) state->StencilMask(0x00); DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene, SSAOTexture); GLERROR("OpaqueObjects"); - state->BlendFunc(GL_ONE, GL_ONE); + //state->BlendFunc(GL_ONE, GL_ONE); + state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene, SSAOTexture); GLERROR("TransparentObjects"); - state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + //state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); DrawSprites(scene.Jobs.SpriteJob, scene); GLERROR("SpriteJobs"); From eaea6450682e01935acff5e2bb571d629db92803 Mon Sep 17 00:00:00 2001 From: Tleety Date: Tue, 1 Mar 2016 11:19:44 +0100 Subject: [PATCH 098/252] Reflectance should now work as an inverse of the specular alpha value. --- resources/Shaders/ForwardPlus.frag.glsl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index a3230eb1..d88154ef 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -169,8 +169,9 @@ void main() vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); - //float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0; - //color_result = color_result * clamp(1/specularTexel, 0, 1)*2 + reflectionColor * clamp(specularTexel, 0, 1)/2; + float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0; + vec4 reflectionTotal = reflectionColor * (1-specularTexel.a) * color_result.a; + color_result = color_result * clamp(1/specularTexel.a, 0, 1) + reflectionTotal; //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; From 77eaa457022f245e9f2f30a682baef3ba0ff5e86 Mon Sep 17 00:00:00 2001 From: Teejoon Date: Tue, 1 Mar 2016 12:11:27 +0100 Subject: [PATCH 099/252] Merge remote-tracking branch 'origin/master' into HEAD Conflicts: src/Engine/Rendering/CubeMapPass.cpp src/Engine/Rendering/DrawFinalPass.cpp --- include/Engine/Collision/CollisionSystem.h | 1 + include/Engine/Core/EntityWrapper.h | 6 + include/Engine/Core/System.h | 2 +- include/Engine/Core/World.h | 2 +- include/Engine/Editor/EditorGUI.h | 8 + include/Engine/Editor/EditorSystem.h | 1 + include/Engine/Network/Client.h | 1 + include/Game/Systems/PlayerSpawnSystem.h | 6 +- .../Systems/Weapon/AssaultWeaponBehaviour.h | 30 +-- .../Systems/Weapon/DefenderWeaponBehaviour.h | 38 +++ include/Game/Systems/Weapon/WeaponBehaviour.h | 173 +++++++++++- resources/Schema/Components.xsd | 4 + resources/Schema/Components/AssaultWeapon.xml | 1 + resources/Schema/Components/AssaultWeapon.xsd | 2 + .../Components/CapturePointGameMode.xml | 5 + .../Components/CapturePointGameMode.xsd | 18 ++ .../Schema/Components/DefenderWeapon.xml | 16 ++ .../Schema/Components/DefenderWeapon.xsd | 44 +++ resources/Schema/Components/DoubleJump.xml | 4 + resources/Schema/Components/DoubleJump.xsd | 16 ++ resources/Schema/Components/Physics.xml | 1 - resources/Schema/Components/Physics.xsd | 1 - resources/Schema/Components/Player.xml | 2 + resources/Schema/Components/Player.xsd | 4 + resources/Schema/Components/Weapon.xml | 3 - resources/Schema/Components/Weapon.xsd | 17 -- .../Schema/Components/WeaponAttachment.xml | 5 + .../Schema/Components/WeaponAttachment.xsd | 28 ++ .../Schema/Entities/AssaultWeaponView.xml | 99 +++++++ .../Schema/Entities/AssaultWeaponWorld.xml | 40 +++ resources/Schema/Entities/DefenderShield.xml | 40 +++ .../Schema/Entities/DefenderWeaponView.xml | 99 +++++++ .../Schema/Entities/DefenderWeaponViewRed.xml | 99 +++++++ .../Schema/Entities/DefenderWeaponWorld.xml | 41 +++ .../Entities/DefenderWeaponWorldRed.xml | 41 +++ resources/Schema/Entities/MovementTest.xml | 253 +----------------- resources/Schema/Entities/Player.xml | 206 +++++--------- resources/Schema/Entities/PlayerRed.xml | 211 ++++++--------- resources/Schema/Types/Entity.xsd | 2 + resources/Schema/Types/WeaponSlotEnum.xsd | 16 ++ resources/Shaders/ForwardPlus.frag.glsl | 7 +- src/Engine/Collision/CollisionSystem.cpp | 93 ++++--- src/Engine/Core/EntityWrapper.cpp | 80 +++++- src/Engine/Core/Util/Logging.cpp | 4 +- src/Engine/Core/World.cpp | 2 +- src/Engine/Editor/EditorGUI.cpp | 13 + src/Engine/Editor/EditorSystem.cpp | 6 + src/Engine/Network/Client.cpp | 10 +- src/Engine/Network/Server.cpp | 6 +- src/Engine/Rendering/CubeMapPass.cpp | 2 +- src/Engine/Rendering/DrawFinalPass.cpp | 7 +- src/Game/Game.cpp | 13 +- .../Network/MultiplayerSnapshotFilter.cpp | 1 + src/Game/Systems/DamageIndicatorSystem.cpp | 2 +- src/Game/Systems/PlayerMovementSystem.cpp | 17 +- src/Game/Systems/PlayerSpawnSystem.cpp | 35 ++- src/Game/Systems/SpawnerSystem.cpp | 2 +- ...aviour.cpp => AssaultWeaponBehaviour.cpp_} | 52 ++-- .../Weapon/DefenderWeaponBehaviour.cpp | 188 +++++++++++++ .../{WeaponSystem.cpp => WeaponSystem.cpp_} | 56 +++- 60 files changed, 1481 insertions(+), 701 deletions(-) create mode 100644 include/Game/Systems/Weapon/DefenderWeaponBehaviour.h create mode 100644 resources/Schema/Components/CapturePointGameMode.xml create mode 100644 resources/Schema/Components/CapturePointGameMode.xsd create mode 100755 resources/Schema/Components/DefenderWeapon.xml create mode 100755 resources/Schema/Components/DefenderWeapon.xsd create mode 100644 resources/Schema/Components/DoubleJump.xml create mode 100644 resources/Schema/Components/DoubleJump.xsd delete mode 100644 resources/Schema/Components/Weapon.xml delete mode 100644 resources/Schema/Components/Weapon.xsd create mode 100644 resources/Schema/Components/WeaponAttachment.xml create mode 100644 resources/Schema/Components/WeaponAttachment.xsd create mode 100755 resources/Schema/Entities/AssaultWeaponView.xml create mode 100755 resources/Schema/Entities/AssaultWeaponWorld.xml create mode 100755 resources/Schema/Entities/DefenderShield.xml create mode 100755 resources/Schema/Entities/DefenderWeaponView.xml create mode 100755 resources/Schema/Entities/DefenderWeaponViewRed.xml create mode 100755 resources/Schema/Entities/DefenderWeaponWorld.xml create mode 100755 resources/Schema/Entities/DefenderWeaponWorldRed.xml create mode 100644 resources/Schema/Types/WeaponSlotEnum.xsd rename src/Game/Systems/Weapon/{AssaultWeaponBehaviour.cpp => AssaultWeaponBehaviour.cpp_} (87%) create mode 100644 src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp rename src/Game/Systems/Weapon/{WeaponSystem.cpp => WeaponSystem.cpp_} (56%) diff --git a/include/Engine/Collision/CollisionSystem.h b/include/Engine/Collision/CollisionSystem.h index 9cd2fe63..19adea35 100644 --- a/include/Engine/Collision/CollisionSystem.h +++ b/include/Engine/Collision/CollisionSystem.h @@ -24,6 +24,7 @@ public: private: Octree* m_Octree; std::vector m_OctreeResult; + std::unordered_map m_PrevPositions; }; #endif \ No newline at end of file diff --git a/include/Engine/Core/EntityWrapper.h b/include/Engine/Core/EntityWrapper.h index b0e65d9e..8ece8e59 100644 --- a/include/Engine/Core/EntityWrapper.h +++ b/include/Engine/Core/EntityWrapper.h @@ -29,16 +29,22 @@ struct EntityWrapper EntityWrapper Parent(); EntityWrapper FirstChildByName(const std::string& name); EntityWrapper FirstParentWithComponent(const std::string& componentType); + EntityWrapper Clone(EntityWrapper parent = EntityWrapper::Invalid); + std::vector ChildrenWithComponent(const std::string& componentType); + void DeleteChildren(); bool IsChildOf(EntityWrapper potentialParent); bool Valid() const; ComponentWrapper operator[](const char* componentName); + ComponentWrapper operator[](const std::string& componentName); bool operator==(const EntityWrapper& e) const; bool operator!=(const EntityWrapper& e) const; explicit operator EntityID() const; private: EntityWrapper firstChildByNameRecursive(const std::string& name, EntityID parent); + EntityWrapper cloneRecursive(EntityWrapper entity, EntityWrapper parent); + void childrenWithComponentRecursive(const std::string& componentType, EntityWrapper& entity, std::vector& childrenWithComponent); }; namespace std diff --git a/include/Engine/Core/System.h b/include/Engine/Core/System.h index 1a387855..23d5f9a5 100644 --- a/include/Engine/Core/System.h +++ b/include/Engine/Core/System.h @@ -68,7 +68,7 @@ protected: const std::string m_ComponentType; - virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cPlayer, double dt) = 0; + virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt) = 0; }; class ImpureSystem : public virtual System diff --git a/include/Engine/Core/World.h b/include/Engine/Core/World.h index 1604df37..c9f738ce 100644 --- a/include/Engine/Core/World.h +++ b/include/Engine/Core/World.h @@ -40,7 +40,7 @@ public: // Change the parent of an entity void SetParent(EntityID entity, EntityID parent); // Get children of an entity - const std::pair::const_iterator, std::unordered_multimap::const_iterator> GetChildren(EntityID entity); + const std::pair::const_iterator, std::unordered_multimap::const_iterator> GetDirectChildren(EntityID entity); // Get all component pools const std::unordered_map& GetComponentPools() const { return m_ComponentPools; } // Get the entity children map diff --git a/include/Engine/Editor/EditorGUI.h b/include/Engine/Editor/EditorGUI.h index 7a0289c6..57574e66 100644 --- a/include/Engine/Editor/EditorGUI.h +++ b/include/Engine/Editor/EditorGUI.h @@ -73,6 +73,12 @@ public: // Called when the user means to rename an entity. typedef std::function OnEntityChangeName_t; void SetEntityChangeNameCallback(OnEntityChangeName_t f) { m_OnEntityChangeName = f; } + // Called when the user pastes an entity previously "copied" + // @param EntityWrapper The entity to copy + // @param EntityWrapper The entity to parent the new copy to + // @return The new copy of the entity + typedef std::function OnEntityPaste_t; + void SetEntityPasteCallback(OnEntityPaste_t f) { m_OnEntityPaste = f; } // Called when the user means to attach a new component to an entity. typedef std::function OnComponentAttach_t; void SetComponentAttachCallback(OnComponentAttach_t f) { m_OnComponentAttach = f; } @@ -111,6 +117,7 @@ private: std::string m_DroppedFile = ""; bool m_Paused = false; bool m_MouseLocked = false; + EntityWrapper m_CopyTarget = EntityWrapper::Invalid; // Callbacks OnEntitySelectedCallback_t m_OnEntitySelected = nullptr; @@ -124,6 +131,7 @@ private: OnComponentDelete_t m_OnComponentDelete = nullptr; OnWidgetMode_t m_OnWidgetMode = nullptr; OnWidgetSpace_t m_OnWidgetSpace = nullptr; + OnEntityPaste_t m_OnEntityPaste = nullptr; // Events EventRelay m_EKeyDown; diff --git a/include/Engine/Editor/EditorSystem.h b/include/Engine/Editor/EditorSystem.h index fcaa2e47..06ee53b6 100644 --- a/include/Engine/Editor/EditorSystem.h +++ b/include/Engine/Editor/EditorSystem.h @@ -56,6 +56,7 @@ private: void OnEntityDelete(EntityWrapper entity); void OnEntityChangeParent(EntityWrapper entity, EntityWrapper parent); void OnEntityChangeName(EntityWrapper entity, const std::string& name); + EntityWrapper OnEntityPaste(EntityWrapper entityToCopy, EntityWrapper parent); void OnComponentAttach(EntityWrapper entity, const std::string& componentType); void OnComponentDelete(EntityWrapper entity, const std::string& componentType); void OnWidgetSpace(EditorGUI::WidgetSpace widgetSpace); diff --git a/include/Engine/Network/Client.h b/include/Engine/Network/Client.h index 968c4bba..be76e265 100644 --- a/include/Engine/Network/Client.h +++ b/include/Engine/Network/Client.h @@ -19,6 +19,7 @@ #include "Core/World.h" #include "Core/EventBroker.h" #include "Core/ConfigFile.h" +#include "Core/EPlayerDeath.h" #include "Input/EInputCommand.h" #include "Core/EPlayerDamage.h" #include "../Game/Events/EDoubleJump.h" diff --git a/include/Game/Systems/PlayerSpawnSystem.h b/include/Game/Systems/PlayerSpawnSystem.h index bf87bef8..70f94807 100644 --- a/include/Game/Systems/PlayerSpawnSystem.h +++ b/include/Game/Systems/PlayerSpawnSystem.h @@ -13,8 +13,6 @@ public: PlayerSpawnSystem(SystemParams params); virtual void Update(double dt) override; - - static void SetRespawnTime(float respawnTime) { m_RespawnTime = respawnTime; }; private: struct SpawnRequest @@ -31,8 +29,8 @@ private: //EntityWrapper ID -> Player ID. std::map m_PlayerIDs; - static float m_RespawnTime; - float m_Timer; + float m_ForcedRespawnTime; + bool m_DbgConfigForceRespawn; EventRelay m_OnInputCommand; bool OnInputCommand(Events::InputCommand& e); diff --git a/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h b/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h index 7bd9c175..993dd060 100644 --- a/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h +++ b/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h @@ -1,37 +1,33 @@ +#ifndef AssaultWeaponBehaviour_h__ +#define AssaultWeaponBehaviour_h__ + #include "Sound/EPlaySoundOnEntity.h" #include "Collision/Collision.h" -#include "Rendering/AnimationSystem.h" #include "Core/ConfigFile.h" #include "WeaponBehaviour.h" #include "../SpawnerSystem.h" #include "Core/EPlayerDamage.h" #include "Core/EShoot.h" - -class AssaultWeaponBehaviour : public WeaponBehaviour +class AssaultWeaponBehaviour : public WeaponBehaviour { public: - AssaultWeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree* collisionOctree, EntityWrapper weaponEntity); - - virtual void Fire() override; - virtual void CeaseFire() override; - virtual void Reload() override; + AssaultWeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree* collisionOctree) + : WeaponBehaviour(systemParams, "AssaultWeapon", renderer, collisionOctree) + { } - virtual void Update(double dt) override; +protected: + virtual void OnPrimaryFire(WeaponInfo& wi) override; + virtual void OnCeasePrimaryFire(WeaponInfo& wi) override; + virtual void OnReload(WeaponInfo& wi) override; private: - EntityWrapper m_FirstPersonModel; - EntityWrapper m_ThirdPersonModel; // State bool m_Firing = false; bool m_Reloading = false; double m_ReloadTimer = 0.0; - EntityWrapper m_FirstPersonReloadImpersonator; - EntityWrapper m_ThirdPersonReloadImpersonator; double m_TimeSinceLastFire = 0.0; - - EventRelay m_EAnimationComplete; - bool OnAnimationComplete(Events::AnimationComplete& e); + EntityWrapper m_FirstPersonReloadImpostor; bool hasAmmo(); void fireRound(); @@ -47,3 +43,5 @@ private: bool shoot(double damage); void showHitMarker(); }; + +#endif \ No newline at end of file diff --git a/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h b/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h new file mode 100644 index 00000000..5ca13d3e --- /dev/null +++ b/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h @@ -0,0 +1,38 @@ +#include "WeaponBehaviour.h" +#include "Collision/Collision.h" +#include "Core/EPlayerDamage.h" +#include "Rendering/ESetCamera.h" + +class DefenderWeaponBehaviour : public WeaponBehaviour +{ +public: + DefenderWeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree* collisionOctree) + : System(systemParams) + , WeaponBehaviour(systemParams, "DefenderWeapon", renderer, collisionOctree) + , m_RandomEngine(m_RandomDevice()) + { + EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &DefenderWeaponBehaviour::OnSetCamera); + } + + void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cWeapon, double dt) override; + void UpdateWeapon(WeaponInfo& wi, double dt) override; + void OnPrimaryFire(WeaponInfo& wi) override; + void OnCeasePrimaryFire(WeaponInfo& wi) override; + bool OnInputCommand(WeaponInfo& wi, const Events::InputCommand& e) override; + +private: + std::random_device m_RandomDevice; + std::mt19937 m_RandomEngine; + EntityWrapper m_CurrentCamera; + + EventRelay m_ESetCamera; + bool OnSetCamera(const Events::SetCamera& e); + + // Weapon functions + void fireShell(WeaponInfo& wi); + void dealDamage(WeaponInfo& wi, glm::vec3 direction, double damage); + + // Utility + float traceRayDistance(glm::vec3 origin, glm::vec3 direction); + Camera cameraFromEntity(EntityWrapper camera); +}; \ No newline at end of file diff --git a/include/Game/Systems/Weapon/WeaponBehaviour.h b/include/Game/Systems/Weapon/WeaponBehaviour.h index 7a0b4626..f23269df 100644 --- a/include/Game/Systems/Weapon/WeaponBehaviour.h +++ b/include/Game/Systems/Weapon/WeaponBehaviour.h @@ -5,30 +5,177 @@ #include "Rendering/IRenderer.h" #include "Core/Octree.h" #include "Collision/EntityAABB.h" +#include "Input/EInputCommand.h" +#include "Systems/SpawnerSystem.h" -class WeaponBehaviour : public System +template +class WeaponBehaviour : public PureSystem { + friend class WeaponSystem; + public: - WeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree* collisionOctree, EntityWrapper player) - : System(systemParams) + WeaponBehaviour(SystemParams params, std::string componentType, IRenderer* renderer, Octree* collisionOctree) + : System(params) + , PureSystem(componentType) , m_Renderer(renderer) , m_CollisionOctree(collisionOctree) - , m_Player(player) - { } + { + EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &WeaponBehaviour::_OnInputCommand) + } virtual ~WeaponBehaviour() = default; - WeaponBehaviour(const WeaponBehaviour&) = delete; - WeaponBehaviour& operator=(const WeaponBehaviour &) = delete; - - virtual void Fire() = 0; - virtual void CeaseFire() { } - virtual void Reload() { } - virtual void Update(double dt) { } + virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt) override + { + auto weapon = getActiveWeapon(entity); + if (!weapon) { + return; + } else { + UpdateWeapon(*weapon, dt); + } + } protected: + struct WeaponInfo + { + std::string WeaponComponent; + EntityWrapper Player; + EntityWrapper WeaponEntity; + EntityWrapper FirstPersonEntity; + EntityWrapper ThirdPersonEntity; + ComponentWrapper GetComponent() { return WeaponEntity[WeaponComponent]; } + }; + IRenderer* m_Renderer; Octree* m_CollisionOctree; - EntityWrapper m_Player; + std::unordered_map m_ActiveWeapons; + + virtual void UpdateWeapon(WeaponInfo& wi, double dt) { } + virtual void OnPrimaryFire(WeaponInfo& wi) { } + virtual void OnCeasePrimaryFire(WeaponInfo& wi) { } + virtual void OnReload(WeaponInfo& wi) { } + virtual bool OnInputCommand(WeaponInfo& wi, const Events::InputCommand& e) { return false; } + +private: + EventRelay m_EInputCommand; + bool _OnInputCommand(const Events::InputCommand& e) + { + EntityWrapper player = e.Player; + if (e.PlayerID == -1) { + player = LocalPlayer; + } + + // Make sure the player is alive + if (!player.Valid()) { + return false; + } + + // Make sure the player has this weapon + auto weapon = getWeaponComponent(player); + if (!weapon) { + return false; + } + + // Weapon selection + if (e.Command == "SelectWeapon") { + if (static_cast(e.Value) == static_cast((*weapon)["Slot"])) { + selectWeapon(player); + } + } + + // Only handle weapon actions if the weapon is active + auto activeWeapon = getActiveWeapon(player); + if (!activeWeapon) { + return false; + } + + // Fire + if (e.Command == "PrimaryFire") { + if (e.Value > 0) { + OnPrimaryFire(*activeWeapon); + } else { + OnCeasePrimaryFire(*activeWeapon); + } + } + + // Reload + if (e.Command == "Reload" && e.Value != 0) { + OnReload(*activeWeapon); + } + + return OnInputCommand(*activeWeapon, e); + } + + boost::optional getWeaponComponent(EntityWrapper player) + { + if (!player.HasComponent(m_ComponentType)) { + return boost::none; + } + + return player[m_ComponentType]; + } + + boost::optional getActiveWeapon(EntityWrapper player) + { + auto it = m_ActiveWeapons.find(player); + if (it == m_ActiveWeapons.end()) { + return boost::none; + } + WeaponInfo& activeWeapon = it->second; + + if (!activeWeapon.FirstPersonEntity.Valid() && !activeWeapon.ThirdPersonEntity.Valid()) { + return boost::none; + } + + return activeWeapon; + } + + void selectWeapon(EntityWrapper player) + { + // Find the weapon attachments matching the weapon type + std::vector weaponAttachments = player.ChildrenWithComponent("WeaponAttachment"); + EntityWrapper firstPersonAttachment; + EntityWrapper thirdPersonAttachment; + for (auto& attachment : weaponAttachments) { + ComponentWrapper cWeaponAttachment = attachment["WeaponAttachment"]; + if ((std::string&)cWeaponAttachment["Weapon"] == m_ComponentType) { + ComponentWrapper::SubscriptProxy person = cWeaponAttachment["Person"]; + if ((ComponentInfo::EnumType)person == person.Enum("FirstPerson")) { + firstPersonAttachment = attachment; + } else if ((ComponentInfo::EnumType)person == person.Enum("ThirdPerson")) { + thirdPersonAttachment = attachment; + } + } + } + + if (!firstPersonAttachment.Valid() && !thirdPersonAttachment.Valid()) { + LOG_WARNING("No weapon attachment found for %s of player #%i", m_ComponentType.c_str(), player.ID); + return; + } + + // Purge other weapon entities + for (auto& attachment : weaponAttachments) { + //if (attachment == firstPersonAttachment || attachment == thirdPersonAttachment) { + // continue; + //} + attachment.DeleteChildren(); + } + + // Spawn the weapon(s) + EntityWrapper firstPersonWeapon; + EntityWrapper thirdPersonWeapon; + if (firstPersonAttachment.Valid()) { + firstPersonWeapon = SpawnerSystem::Spawn(firstPersonAttachment, firstPersonAttachment); + } + if (thirdPersonAttachment.Valid()) { + thirdPersonWeapon = SpawnerSystem::Spawn(thirdPersonAttachment, thirdPersonAttachment); + } + + m_ActiveWeapons[player].WeaponComponent = m_ComponentType; + m_ActiveWeapons[player].Player = player; + m_ActiveWeapons[player].WeaponEntity = player; + m_ActiveWeapons[player].FirstPersonEntity = firstPersonWeapon; + m_ActiveWeapons[player].ThirdPersonEntity = thirdPersonWeapon; + } }; #endif diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index 42abed82..eb41ed6a 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -46,4 +46,8 @@ + + + + \ No newline at end of file diff --git a/resources/Schema/Components/AssaultWeapon.xml b/resources/Schema/Components/AssaultWeapon.xml index 6c645624..c835217b 100755 --- a/resources/Schema/Components/AssaultWeapon.xml +++ b/resources/Schema/Components/AssaultWeapon.xml @@ -8,4 +8,5 @@ 120 0.01 2 + \ No newline at end of file diff --git a/resources/Schema/Components/AssaultWeapon.xsd b/resources/Schema/Components/AssaultWeapon.xsd index 95df64b7..7e9854a2 100755 --- a/resources/Schema/Components/AssaultWeapon.xsd +++ b/resources/Schema/Components/AssaultWeapon.xsd @@ -2,6 +2,7 @@ + @@ -28,6 +29,7 @@ Time it takes to reload the weapon in seconds + diff --git a/resources/Schema/Components/CapturePointGameMode.xml b/resources/Schema/Components/CapturePointGameMode.xml new file mode 100644 index 00000000..3104e71f --- /dev/null +++ b/resources/Schema/Components/CapturePointGameMode.xml @@ -0,0 +1,5 @@ + + + 0.0 + 8.0 + \ No newline at end of file diff --git a/resources/Schema/Components/CapturePointGameMode.xsd b/resources/Schema/Components/CapturePointGameMode.xsd new file mode 100644 index 00000000..8b81d67a --- /dev/null +++ b/resources/Schema/Components/CapturePointGameMode.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + The time since the last respawn wave. Players will be spawned when this reaches MaxRespawnTime. + + + Players will be spawned when RespawnTime reaches this. + + + + + \ No newline at end of file diff --git a/resources/Schema/Components/DefenderWeapon.xml b/resources/Schema/Components/DefenderWeapon.xml new file mode 100755 index 00000000..998f3bde --- /dev/null +++ b/resources/Schema/Components/DefenderWeapon.xml @@ -0,0 +1,16 @@ + + + 8 + 8 + 64 + 64 + 90 + 0.174533 + 10 + 120 + 0.01 + 0.5 + + false + 0 + \ No newline at end of file diff --git a/resources/Schema/Components/DefenderWeapon.xsd b/resources/Schema/Components/DefenderWeapon.xsd new file mode 100755 index 00000000..3fe5a64a --- /dev/null +++ b/resources/Schema/Components/DefenderWeapon.xsd @@ -0,0 +1,44 @@ + + + + + + + + + + + Ammo currently loaded into the magazine + + + Max number of rounds in a magazine + + + Current ammo carried + + + Maximum ammo able to be carried + + + Damage dealt if all shotgun pellets hit + + + Spread angle in radians + + + + Rate of fire in rounds per minute + + + View punch in radians for each shell fired + + + Time it takes to load ONE SHELL into the weapon in seconds + + + + + + + + diff --git a/resources/Schema/Components/DoubleJump.xml b/resources/Schema/Components/DoubleJump.xml new file mode 100644 index 00000000..bb0d3bc7 --- /dev/null +++ b/resources/Schema/Components/DoubleJump.xml @@ -0,0 +1,4 @@ + + + 4.0 + \ No newline at end of file diff --git a/resources/Schema/Components/DoubleJump.xsd b/resources/Schema/Components/DoubleJump.xsd new file mode 100644 index 00000000..65ff0419 --- /dev/null +++ b/resources/Schema/Components/DoubleJump.xsd @@ -0,0 +1,16 @@ + + + + + + + Enables a Player to double jump. + + + + Vertical velocity set on double jump. + + + + + \ No newline at end of file diff --git a/resources/Schema/Components/Physics.xml b/resources/Schema/Components/Physics.xml index 84b6aba3..6cb73c75 100644 --- a/resources/Schema/Components/Physics.xml +++ b/resources/Schema/Components/Physics.xml @@ -2,7 +2,6 @@ true - false 0.33 diff --git a/resources/Schema/Components/Physics.xsd b/resources/Schema/Components/Physics.xsd index 206e2a23..7fed1fb5 100644 --- a/resources/Schema/Components/Physics.xsd +++ b/resources/Schema/Components/Physics.xsd @@ -13,7 +13,6 @@ m/s^2 - The largest height of a "stair-step" that can be walked over diff --git a/resources/Schema/Components/Player.xml b/resources/Schema/Components/Player.xml index 00cff257..b50274ac 100644 --- a/resources/Schema/Components/Player.xml +++ b/resources/Schema/Components/Player.xml @@ -2,5 +2,7 @@ 3 1.5 + 4.0 + \ No newline at end of file diff --git a/resources/Schema/Components/Player.xsd b/resources/Schema/Components/Player.xsd index 1b33d222..006ae9d7 100644 --- a/resources/Schema/Components/Player.xsd +++ b/resources/Schema/Components/Player.xsd @@ -11,7 +11,11 @@ + + Vertical velocity set when jumping. + + diff --git a/resources/Schema/Components/Weapon.xml b/resources/Schema/Components/Weapon.xml deleted file mode 100644 index 38c6fce9..00000000 --- a/resources/Schema/Components/Weapon.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/resources/Schema/Components/Weapon.xsd b/resources/Schema/Components/Weapon.xsd deleted file mode 100644 index 8bddd8a9..00000000 --- a/resources/Schema/Components/Weapon.xsd +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/resources/Schema/Components/WeaponAttachment.xml b/resources/Schema/Components/WeaponAttachment.xml new file mode 100644 index 00000000..8867b2b7 --- /dev/null +++ b/resources/Schema/Components/WeaponAttachment.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/resources/Schema/Components/WeaponAttachment.xsd b/resources/Schema/Components/WeaponAttachment.xsd new file mode 100644 index 00000000..3b1291ae --- /dev/null +++ b/resources/Schema/Components/WeaponAttachment.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + Combine with a spawner to define a weapon attachment point + + + + The weapon component type this attachment refers to + + + + + + \ No newline at end of file diff --git a/resources/Schema/Entities/AssaultWeaponView.xml b/resources/Schema/Entities/AssaultWeaponView.xml new file mode 100755 index 00000000..4b985fbb --- /dev/null +++ b/resources/Schema/Entities/AssaultWeaponView.xml @@ -0,0 +1,99 @@ + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + + + + Schema/Entities/RayBlue.xml + + + + + + + + + + + Schema/Entities/ReloadEffectView.xml + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + + + + 32 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + 360 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/AssaultWeaponWorld.xml b/resources/Schema/Entities/AssaultWeaponWorld.xml new file mode 100755 index 00000000..6fcb97b3 --- /dev/null +++ b/resources/Schema/Entities/AssaultWeaponWorld.xml @@ -0,0 +1,40 @@ + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + + + + Schema/Entities/RayBlue.xml + + + + + + + + + + + Schema/Entities/ReloadEffectWorld.xml + + + + + + + + diff --git a/resources/Schema/Entities/DefenderShield.xml b/resources/Schema/Entities/DefenderShield.xml new file mode 100755 index 00000000..da760e72 --- /dev/null +++ b/resources/Schema/Entities/DefenderShield.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + + + + + + + + + + + + + Models/Core/UnitHexagon.mesh + + true + + + + + + + + + + + + diff --git a/resources/Schema/Entities/DefenderWeaponView.xml b/resources/Schema/Entities/DefenderWeaponView.xml new file mode 100755 index 00000000..f6b6e89d --- /dev/null +++ b/resources/Schema/Entities/DefenderWeaponView.xml @@ -0,0 +1,99 @@ + + + + + + R_Arm_Weapon_Joint + + + + Models/Weapons/Blue/DefenderGunBlue.mesh + + + + + + + + + + + Schema/Entities/RayBlue.xml + + + + + + + + + + + Schema/Entities/ReloadEffectView.xml + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + + + + 32 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + 360 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/DefenderWeaponViewRed.xml b/resources/Schema/Entities/DefenderWeaponViewRed.xml new file mode 100755 index 00000000..b5b1c322 --- /dev/null +++ b/resources/Schema/Entities/DefenderWeaponViewRed.xml @@ -0,0 +1,99 @@ + + + + + + R_Arm_Weapon_Joint + + + + Models/Weapons/Red/DefenderGunRed.mesh + + + + + + + + + + + Schema/Entities/RayRed.xml + + + + + + + + + + + Schema/Entities/ReloadEffectView.xml + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + + + + 32 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + 360 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/DefenderWeaponWorld.xml b/resources/Schema/Entities/DefenderWeaponWorld.xml new file mode 100755 index 00000000..826301b4 --- /dev/null +++ b/resources/Schema/Entities/DefenderWeaponWorld.xml @@ -0,0 +1,41 @@ + + + + + + R_Arm_Weapon_Joint + + + + Models/Weapons/Blue/DefenderGunBlue.mesh + + + + + + + + + + + + Schema/Entities/RayBlue.xml + + + + + + + + + + + Schema/Entities/ReloadEffectWorld.xml + + + + + + + + diff --git a/resources/Schema/Entities/DefenderWeaponWorldRed.xml b/resources/Schema/Entities/DefenderWeaponWorldRed.xml new file mode 100755 index 00000000..7f697304 --- /dev/null +++ b/resources/Schema/Entities/DefenderWeaponWorldRed.xml @@ -0,0 +1,41 @@ + + + + + + R_Arm_Weapon_Joint + + + + Models/Weapons/Red/DefenderGunRed.mesh + + + + + + + + + + + + Schema/Entities/RayRed.xml + + + + + + + + + + + Schema/Entities/ReloadEffectWorld.xml + + + + + + + + diff --git a/resources/Schema/Entities/MovementTest.xml b/resources/Schema/Entities/MovementTest.xml index 84aaa03a..41474568 100644 --- a/resources/Schema/Entities/MovementTest.xml +++ b/resources/Schema/Entities/MovementTest.xml @@ -10,7 +10,7 @@ - Schema/Entities/Player.xml + Schema/Entities/PlayerRed.xml @@ -118,257 +118,6 @@ - - - - - - - - 600 - - - - - - - - - 5 - - - - - - - - - - - - - - - - - - - - - - - Fonts/DroidSans.ttf,100 - - - - - - - - - - - - - - Models/Widgets/Camera.mesh - false - - - - - - - - - - - - - - - - - - - 1 - - - - - Models/Core/UnitHexagon.mesh - - - - - - - - - - - - - - Textures/Weapons/Crosshair/SmallThickHoleDot.png - false - - - - - - - - - - - - - - Idle - 1.9569972344146196 - 1 - - - Models/Characters/Assault/FirstPerson.mesh - true - - - - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - true - - - - - - - - - - - Schema/Entities/RayBlue.xml - - - - - - - - - - - - - Schema/Entities/WeaponReloadEffect.xml - - - - - - - - - - - - - - Models/Widgets/Camera.mesh - false - - - - - - - - - - - - Idle - 1.8055945618467364 - 1 - - - AimRifle - - - - - Models/Characters/Assault/AssaultAnimations.mesh - - - - - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - false - - - - - - - - - - - Schema/Entities/RayBlue.xml - - - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - false - - - - - - - - - - - - Models/Core/UnitCube.mesh - - false - - - - - - - - - diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 7a5d2eb4..88f153ae 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -7,24 +7,31 @@ - 600 + + + - + + 1.6944730461160304 + + - 5 + - + + + @@ -304,7 +311,8 @@ - + + @@ -364,7 +372,7 @@ Idle - 0.97725610639912475 + 0.67172915251515519 1 @@ -376,100 +384,29 @@ - + - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - - - - - + + Schema/Entities/DefenderWeaponView.xml + + + + DefenderWeapon + - - - - - Schema/Entities/RayBlue.xml - - - - - - - - - - - Schema/Entities/ReloadEffectView.xml - - - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - - - - - - 32 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - 360 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - + + + + + + Schema/Entities/AssaultWeaponView.xml + + + + AssaultWeapon + + + @@ -493,7 +430,6 @@ Idle - 0.87583812735846323 1 @@ -502,6 +438,7 @@ AimRifle + Models/Characters/Assault/AssaultAnimations.mesh @@ -510,41 +447,35 @@ - + - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - - - - - + + Schema/Entities/DefenderWeaponWorld.xml + + + + DefenderWeapon + + + + - - - - - Schema/Entities/RayBlue.xml - - - - - - - - - - - Schema/Entities/ReloadEffectWorld.xml - - - - - - + + + + + + Schema/Entities/AssaultWeaponWorld.xml + + + + AssaultWeapon + + + + + + @@ -610,6 +541,17 @@ + + + + Schema/Entities/DefenderShield.xml + + + + + + + diff --git a/resources/Schema/Entities/PlayerRed.xml b/resources/Schema/Entities/PlayerRed.xml index cd01632e..3cf17558 100644 --- a/resources/Schema/Entities/PlayerRed.xml +++ b/resources/Schema/Entities/PlayerRed.xml @@ -7,24 +7,31 @@ - 600 + + + - + + 1.6944730461160304 + + - 5 + - + + + @@ -365,7 +372,7 @@ Idle - 1.2667383999985162 + 0.67172915251515519 1 @@ -377,100 +384,29 @@ - + - - R_Arm_Weapon_Joint - - - Models/Weapons/Red/AssaultWeaponRed.mesh - - - - - + + Schema/Entities/DefenderWeaponViewRed.xml + + + + DefenderWeapon + - - - - - Schema/Entities/RayRed.xml - - - - - - - - - - - Schema/Entities/ReloadEffectViewRed.xml - - - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - - - - - - 32 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - 360 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - + + + + + + Schema/Entities/AssaultWeaponView.xml + + + + AssaultWeapon + + + @@ -494,7 +430,6 @@ Idle - 0.26532318661337229 1 @@ -503,6 +438,7 @@ AimRifle + Models/Characters/Assault/AssaultAnimations.mesh @@ -511,41 +447,35 @@ - + - - R_Arm_Weapon_Joint - - - Models/Weapons/Red/AssaultWeaponRed.mesh - - - - - + + Schema/Entities/DefenderWeaponWorldRed.xml + + + + DefenderWeapon + + + + - - - - - Schema/Entities/RayRed.xml - - - - - - - - - - - Schema/Entities/ReloadEffectWorldRed.xml - - - - - - + + + + + + Schema/Entities/AssaultWeaponWorld.xml + + + + AssaultWeapon + + + + + + @@ -584,20 +514,20 @@ - + - + Textures/Icons/Arrow.png false - + @@ -605,12 +535,23 @@ true - + + + + + Schema/Entities/DefenderShield.xml + + + + + + + diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index a9c5f641..0965ef89 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -50,6 +50,8 @@ + + diff --git a/resources/Schema/Types/WeaponSlotEnum.xsd b/resources/Schema/Types/WeaponSlotEnum.xsd new file mode 100644 index 00000000..6713ca9d --- /dev/null +++ b/resources/Schema/Types/WeaponSlotEnum.xsd @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 00f95888..aa45d118 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -171,7 +171,8 @@ void main() vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0; - color_result = color_result * clamp(1/specularTexel, 0, 1)*2 + reflectionColor * clamp(specularTexel, 0, 1)/2; + vec4 reflectionTotal = reflectionColor * (1-specularTexel.a) * color_result.a; + color_result = color_result * clamp(1/specularTexel.a, 0, 1) + reflectionTotal; //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; @@ -182,9 +183,9 @@ void main() } sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1)); //sceneColor = vec4(reflectionColor.xyz, 1); - color_result += glowTexel*GlowIntensity; + color_result.xyz += glowTexel.xyz*GlowIntensity; - bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), clamp(color_result.a, 0, 1)); + bloomColor = vec4(max(color_result.xyz - 1.0, 0.0), clamp(color_result.a, 0, 1)); //Tiled Debug Code /* diff --git a/src/Engine/Collision/CollisionSystem.cpp b/src/Engine/Collision/CollisionSystem.cpp index fcc3665f..95609ea6 100644 --- a/src/Engine/Collision/CollisionSystem.cpp +++ b/src/Engine/Collision/CollisionSystem.cpp @@ -12,55 +12,56 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c if (!boundingBox) { return; } + ComponentWrapper& cTransform = entity["Transform"]; EntityAABB& boxA = *boundingBox; bool everHitTheGround = false; - glm::vec3 size = boxA.Size(); - float diameter = std::min(size.x, size.z); - glm::vec3 prevOrigin = (glm::vec3)cPhysics["PrevOrigin"]; - glm::vec3 toCurrentPos = boxA.Origin() - prevOrigin; - float rayLength = glm::length(toCurrentPos) + 0.5f*diameter; - //If the entity has moved farther than the size of its box, we need to handle it specially. - bool traceCollision = rayLength > diameter; - //hack solution: If prevOrigin is less than -9000 in all dimensions, - //then it means it is not set, i.e. this is the first collision check for the entity. - if (traceCollision && glm::any(glm::greaterThan((glm::vec3)cPhysics["PrevOrigin"], glm::vec3(-9000.f)))) { - Ray ray(prevOrigin, toCurrentPos); - m_OctreeResult.clear(); - m_Octree->ObjectsPossiblyHitByRay(ray, m_OctreeResult); - for (auto& boxB : m_OctreeResult) { - if (boxA.Entity == boxB.Entity) { - continue; - } - bool hit; - float dist; - if (boxB.Entity.HasComponent("Model")) { - RawModel* model; - std::string res = (std::string)boxB.Entity["Model"]["Resource"]; - try { - model = ResourceManager::Load(res); - } catch (const std::exception&) { + auto prevPosIt = m_PrevPositions.find(entity); + if (prevPosIt != m_PrevPositions.end()) { + glm::vec3 size = boxA.Size(); + float diameter = std::min(size.x, size.z); + glm::vec3 prevOrigin = prevPosIt->second; + glm::vec3 toCurrentPos = boxA.Origin() - prevOrigin; + float rayLength = glm::length(toCurrentPos) + 0.5f*diameter; + //If the entity has moved farther than the size of its box, we need to handle it specially. + if (rayLength > diameter) { + Ray ray(prevOrigin, toCurrentPos); + m_OctreeResult.clear(); + m_Octree->ObjectsPossiblyHitByRay(ray, m_OctreeResult); + for (auto& boxB : m_OctreeResult) { + if (boxA.Entity == boxB.Entity) { continue; } - float u, v; - hit = Collision::RayVsModel(ray, model->Vertices(), model->m_Indices, Transform::ModelMatrix(boxB.Entity), dist, u, v); - } else { - hit = Collision::RayVsAABB(ray, boxB, dist); - } - if (hit && dist < rayLength) { - //Set the entity to where it was colliding, minus the maximum box size. - //TODO: Perhaps this should be done slightly more properly. - glm::vec3 newOriginPos = ray.Origin() + (dist - 0.707107f*diameter) * ray.Direction(); - glm::vec3 resolve = newOriginPos - boxA.Origin(); - (glm::vec3&)cTransform["Position"] += resolve; - boxA = *Collision::EntityAbsoluteAABB(entity); - if (resolve.y > 0) { - everHitTheGround = true; - (bool)cPhysics["IsOnGround"] = true; - ((glm::vec3&)cPhysics["Velocity"]).y = 0.f; + bool hit; + float dist; + if (boxB.Entity.HasComponent("Model")) { + RawModel* model; + std::string res = (std::string)boxB.Entity["Model"]["Resource"]; + try { + model = ResourceManager::Load(res); + } catch (const std::exception&) { + continue; + } + float u, v; + hit = Collision::RayVsModel(ray, model->Vertices(), model->m_Indices, Transform::ModelMatrix(boxB.Entity), dist, u, v); + } else { + hit = Collision::RayVsAABB(ray, boxB, dist); + } + if (hit && dist < rayLength) { + //Set the entity to where it was colliding, minus the maximum box size. + //TODO: Perhaps this should be done slightly more properly. + glm::vec3 newOriginPos = ray.Origin() + (dist - 0.707107f*diameter) * ray.Direction(); + glm::vec3 resolve = newOriginPos - boxA.Origin(); + (glm::vec3&)cTransform["Position"] += resolve; + boxA = *Collision::EntityAbsoluteAABB(entity); + if (resolve.y > 0) { + everHitTheGround = true; + (bool)cPhysics["IsOnGround"] = true; + ((glm::vec3&)cPhysics["Velocity"]).y = 0.f; + } + break; } - break; } } } @@ -86,10 +87,13 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c glm::mat4 modelMatrix = Transform::ModelMatrix(boxB.Entity); glm::vec3 inOutVelocity = (glm::vec3)cPhysics["Velocity"]; + bool notMovingxz = glm::all(glm::lessThan(glm::abs(glm::vec2(inOutVelocity.x, inOutVelocity.z)), glm::vec2(0.01f))) && prevPosIt != m_PrevPositions.end(); bool isOnGround = (bool)cPhysics["IsOnGround"]; float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"]; if (Collision::AABBvsTriangles(boxA, model->Vertices(), model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) { - (glm::vec3&)cTransform["Position"] += resolutionVector; + //Move the position to previous position if it is not moving in the xz-plane, else resolve with the resolution vector. + (glm::vec3&)cTransform["Position"] += notMovingxz ? prevPosIt->second - boxA.Origin() : resolutionVector; + boxA = *Collision::EntityAbsoluteAABB(entity); cPhysics["Velocity"] = inOutVelocity; if (isOnGround) { everHitTheGround = true; @@ -99,6 +103,7 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c } else if (Collision::AABBVsAABB(boxA, boxB, resolutionVector)) { //Enter here if boxB has no Model. (glm::vec3&)cTransform["Position"] += resolutionVector; + boxA = *Collision::EntityAbsoluteAABB(entity); if (resolutionVector.y > 0) { everHitTheGround = true; (bool)cPhysics["IsOnGround"] = true; @@ -112,5 +117,5 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c (bool)cPhysics["IsOnGround"] = false; } - (glm::vec3&)cPhysics["PrevOrigin"] = boxA.Origin(); + m_PrevPositions[entity] = boxA.Origin(); } diff --git a/src/Engine/Core/EntityWrapper.cpp b/src/Engine/Core/EntityWrapper.cpp index 4b45b8d0..b3bef55a 100644 --- a/src/Engine/Core/EntityWrapper.cpp +++ b/src/Engine/Core/EntityWrapper.cpp @@ -51,6 +51,40 @@ EntityWrapper EntityWrapper::FirstParentWithComponent(const std::string& compone return EntityWrapper::Invalid; } +EntityWrapper EntityWrapper::Clone(EntityWrapper parent /*= Invalid*/) +{ + if (!Valid()) { + return EntityWrapper::Invalid; + } + + EntityWrapper clone = cloneRecursive(*this, EntityWrapper::Invalid); + this->World->SetParent(clone.ID, parent.ID); + return clone; +} + +std::vector EntityWrapper::ChildrenWithComponent(const std::string& componentType) +{ + std::vector childrenWithComponent; + childrenWithComponentRecursive(componentType, *this, childrenWithComponent); + return childrenWithComponent; +} + +void EntityWrapper::DeleteChildren() +{ + auto itPair = this->World->GetDirectChildren(this->ID); + if (itPair.first == itPair.second) { + return; + } + + std::vector entitiesToDelete; + for (auto it = itPair.first; it != itPair.second; it++) { + entitiesToDelete.push_back(it->second); + } + for (auto& e : entitiesToDelete) { + this->World->DeleteEntity(e); + } +} + bool EntityWrapper::IsChildOf(EntityWrapper potentialParent) { EntityWrapper entity = *this; @@ -90,6 +124,11 @@ ComponentWrapper EntityWrapper::operator[](const char* componentName) } } +ComponentWrapper EntityWrapper::operator[](const std::string& componentName) +{ + return this->operator[](componentName.c_str()); +} + bool EntityWrapper::operator==(const EntityWrapper& e) const { return (this->ID == e.ID) && (this->World == e.World); @@ -111,7 +150,7 @@ EntityWrapper EntityWrapper::firstChildByNameRecursive(const std::string& name, return EntityWrapper::Invalid; } - auto itPair = this->World->GetChildren(parent); + auto itPair = this->World->GetDirectChildren(parent); if (itPair.first == itPair.second) { return EntityWrapper::Invalid; } @@ -131,3 +170,42 @@ EntityWrapper EntityWrapper::firstChildByNameRecursive(const std::string& name, return EntityWrapper::Invalid; } +EntityWrapper EntityWrapper::cloneRecursive(EntityWrapper entity, EntityWrapper parent) +{ + EntityWrapper clone = EntityWrapper(entity.World, entity.World->CreateEntity(parent.ID)); + entity.World->SetName(clone.ID, entity.Name()); + + // Clone components + for (auto& kv : entity.World->GetComponentPools()) { + if (kv.second->KnowsEntity(entity.ID)) { + ComponentWrapper c1 = kv.second->GetByEntity(entity.ID); + ComponentWrapper c2 = entity.World->AttachComponent(clone.ID, kv.first); + c1.Copy(c2); + } + } + + // Clone children + auto children = entity.World->GetDirectChildren(entity.ID); + for (auto it = children.first; it != children.second; ++it) { + EntityWrapper child(entity.World, it->second); + cloneRecursive(child, clone); + } + + return clone; +} + +void EntityWrapper::childrenWithComponentRecursive(const std::string& componentType, EntityWrapper& entity, std::vector& childrenWithComponent) +{ + auto itPair = this->World->GetDirectChildren(entity.ID); + if (itPair.first == itPair.second) { + return; + } + + for (auto it = itPair.first; it != itPair.second; ++it) { + EntityWrapper child = EntityWrapper(entity.World, it->second); + if (child.HasComponent(componentType)) { + childrenWithComponent.push_back(child); + } + childrenWithComponentRecursive(componentType, child, childrenWithComponent); + } +} diff --git a/src/Engine/Core/Util/Logging.cpp b/src/Engine/Core/Util/Logging.cpp index 63a6f380..c7612fd8 100644 --- a/src/Engine/Core/Util/Logging.cpp +++ b/src/Engine/Core/Util/Logging.cpp @@ -33,8 +33,8 @@ void _LOG(_LOG_LEVEL logLevel, const char* file, const char* func, unsigned int va_end(args); if (logLevel == LOG_LEVEL_ERROR) { - std::cerr << file << ":" << line << " " << func << std::endl; - std::cerr << _LOG_LEVEL_PREFIX[logLevel] << message << std::endl; + //std::cerr << file << ":" << line << " " << func << std::endl; + //std::cerr << _LOG_LEVEL_PREFIX[logLevel] << message << std::endl; } else { std::cout << _LOG_LEVEL_PREFIX[logLevel] << message << std::endl; } diff --git a/src/Engine/Core/World.cpp b/src/Engine/Core/World.cpp index 8788a92e..9b323ff4 100644 --- a/src/Engine/Core/World.cpp +++ b/src/Engine/Core/World.cpp @@ -127,7 +127,7 @@ void World::SetParent(EntityID entity, EntityID parent) m_EntityChildren.insert(std::make_pair(parent, entity)); } -const std::pair::const_iterator, std::unordered_multimap::const_iterator> World::GetChildren(EntityID entity) +const std::pair::const_iterator, std::unordered_multimap::const_iterator> World::GetDirectChildren(EntityID entity) { return m_EntityChildren.equal_range(entity); } diff --git a/src/Engine/Editor/EditorGUI.cpp b/src/Engine/Editor/EditorGUI.cpp index 70775a2b..f2690f13 100644 --- a/src/Engine/Editor/EditorGUI.cpp +++ b/src/Engine/Editor/EditorGUI.cpp @@ -598,6 +598,19 @@ bool EditorGUI::OnKeyDown(const Events::KeyDown& e) entityImport(m_World); } + if (e.ModCtrl && e.KeyCode == GLFW_KEY_C) { + m_CopyTarget = m_CurrentSelection; + } + + if (e.ModCtrl && e.KeyCode == GLFW_KEY_V) { + if (m_OnEntityPaste != nullptr) { + EntityWrapper copy = m_OnEntityPaste(m_CopyTarget, m_CurrentSelection); + if (copy != EntityWrapper::Invalid) { + SelectEntity(copy); + } + } + } + if (e.KeyCode == GLFW_KEY_DELETE) { if (m_CurrentSelection.Valid()) { entityDelete(m_CurrentSelection); diff --git a/src/Engine/Editor/EditorSystem.cpp b/src/Engine/Editor/EditorSystem.cpp index 97ea9d53..4bee1427 100644 --- a/src/Engine/Editor/EditorSystem.cpp +++ b/src/Engine/Editor/EditorSystem.cpp @@ -28,6 +28,7 @@ EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame m_EditorGUI->SetEntityDeleteCallback(std::bind(&EditorSystem::OnEntityDelete, this, std::placeholders::_1)); m_EditorGUI->SetEntityChangeParentCallback(std::bind(&EditorSystem::OnEntityChangeParent, this, std::placeholders::_1, std::placeholders::_2)); m_EditorGUI->SetEntityChangeNameCallback(std::bind(&EditorSystem::OnEntityChangeName, this, std::placeholders::_1, std::placeholders::_2)); + m_EditorGUI->SetEntityPasteCallback(std::bind(&EditorSystem::OnEntityPaste, this, std::placeholders::_1, std::placeholders::_2)); m_EditorGUI->SetComponentAttachCallback(std::bind(&EditorSystem::OnComponentAttach, this, std::placeholders::_1, std::placeholders::_2)); m_EditorGUI->SetComponentDeleteCallback(std::bind(&EditorSystem::OnComponentDelete, this, std::placeholders::_1, std::placeholders::_2)); m_EditorGUI->SetWidgetModeCallback(std::bind(&EditorSystem::setWidgetMode, this, std::placeholders::_1)); @@ -160,6 +161,11 @@ void EditorSystem::OnEntityChangeName(EntityWrapper entity, const std::string& n } } +EntityWrapper EditorSystem::OnEntityPaste(EntityWrapper entityToCopy, EntityWrapper parent) +{ + return entityToCopy.Clone(parent); +} + void EditorSystem::OnComponentAttach(EntityWrapper entity, const std::string& componentType) { if (entity.Valid()) { diff --git a/src/Engine/Network/Client.cpp b/src/Engine/Network/Client.cpp index d94ccbc6..d8da7e16 100644 --- a/src/Engine/Network/Client.cpp +++ b/src/Engine/Network/Client.cpp @@ -261,8 +261,14 @@ void Client::parseEntityDeletion(Packet & packet) if (m_ServerIDToClientID.find(entityToDelete) != m_ServerIDToClientID.end()) { EntityID localEntity = m_ServerIDToClientID.at(entityToDelete); if (m_World->ValidEntity(localEntity)) { - m_World->DeleteEntity(localEntity); - deleteFromServerClientMaps(entityToDelete, localEntity); + if (m_World->HasComponent(localEntity,"Player")) { + Events::PlayerDeath e; + e.Player = EntityWrapper(m_World, localEntity); + m_EventBroker->Publish(e); + } else { + m_World->DeleteEntity(localEntity); + deleteFromServerClientMaps(entityToDelete, localEntity); + } } } } diff --git a/src/Engine/Network/Server.cpp b/src/Engine/Network/Server.cpp index 7ed069d6..7c614cee 100644 --- a/src/Engine/Network/Server.cpp +++ b/src/Engine/Network/Server.cpp @@ -186,7 +186,7 @@ void Server::addInputCommandsToPacket(Packet& packet) void Server::addPlayersToPacket(Packet & packet, EntityID entityID) { - auto itPair = m_World->GetChildren(entityID); + auto itPair = m_World->GetDirectChildren(entityID); std::unordered_map worldComponentPools = m_World->GetComponentPools(); // Loop through every child for (auto it = itPair.first; it != itPair.second; it++) { @@ -234,7 +234,7 @@ void Server::addPlayersToPacket(Packet & packet, EntityID entityID) void Server::addChildrenToPacket(Packet & packet, EntityID entityID) { - auto itPair = m_World->GetChildren(entityID); + auto itPair = m_World->GetDirectChildren(entityID); std::unordered_map worldComponentPools = m_World->GetComponentPools(); // Loop through every child for (auto it = itPair.first; it != itPair.second; it++) { @@ -601,7 +601,7 @@ void Server::parsePlayerTransform(Packet& packet) bool Server::shouldSendToClient(EntityWrapper childEntity) { - auto children = m_World->GetChildren(childEntity.ID); + auto children = m_World->GetDirectChildren(childEntity.ID); for (auto it = children.first; it != children.second; it++) { EntityWrapper child(m_World, it->second); if(child.HasComponent("CapturePoint")) { diff --git a/src/Engine/Rendering/CubeMapPass.cpp b/src/Engine/Rendering/CubeMapPass.cpp index fc318498..e2a55b74 100644 --- a/src/Engine/Rendering/CubeMapPass.cpp +++ b/src/Engine/Rendering/CubeMapPass.cpp @@ -17,7 +17,7 @@ void CubeMapPass::LoadTextures(std::string input) m_CubeMapTextures.push_back(img); } GenerateCubeMapTexture(); - m_PreviusCubeMapTexture = input; + m_PreviusCubeMapTexture = input; } } diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 3e477296..6b600d22 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -187,10 +187,11 @@ void DrawFinalPass::Draw(RenderScene& scene) state->StencilMask(0x00); DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene); GLERROR("OpaqueObjects"); - state->BlendFunc(GL_ONE, GL_ONE); - DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene); - GLERROR("TransparentObjects"); + //state->BlendFunc(GL_ONE, GL_ONE); state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + GLERROR("TransparentObjects"); + //state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); DrawSprites(scene.Jobs.SpriteJob, scene); GLERROR("SpriteJobs"); diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 3495730e..2946d656 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -16,7 +16,7 @@ #include "Game/Systems/PickupSpawnSystem.h" #include "Game/Systems/AmmoPickupSystem.h" #include "Game/Systems/DamageIndicatorSystem.h" -#include "Game/Systems/Weapon/WeaponSystem.h" +#include "Game/Systems/Weapon/DefenderWeaponBehaviour.h" #include "Rendering/AnimationSystem.h" #include "Game/Systems/HealthHUDSystem.h" #include "Rendering/BoneAttachmentSystem.h" @@ -48,7 +48,6 @@ Game::Game(int argc, char* argv[]) ResourceManager::UseThreading = m_Config->Get("Multithreading.ResourceLoading", true); DisableMemoryPool::Value = m_Config->Get("Debug.DisableMemoryPool", false); LOG_LEVEL = static_cast<_LOG_LEVEL>(m_Config->Get("Debug.LogLevel", 1)); - PlayerSpawnSystem::SetRespawnTime(m_Config->Get("Debug.RespawnTime", 15.0f)); // Create the core event broker m_EventBroker = new EventBroker(); @@ -98,6 +97,10 @@ Game::Game(int argc, char* argv[]) m_NetworkClient->Connect(m_NetworkAddress, m_NetworkPort); m_Renderer->SetWindowTitle(m_Renderer->WindowTitle() + " CLIENT"); } + } else { + // If network is disabled, pretend we're a server + m_IsClient = true; + m_IsServer = true; } // Create Octrees @@ -120,7 +123,7 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); - m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer, m_OctreeCollision); + m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer, m_OctreeCollision); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); @@ -135,7 +138,6 @@ Game::Game(int argc, char* argv[]) ++updateOrderLevel; m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeCollision, "Collidable"); m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeTrigger, "Player"); - m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeFrustrumCulling); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); @@ -145,6 +147,9 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeCollision); m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeTrigger); + // Octree for frustum culling must be updated after collisions, otherwise players frustum may be moved after tree is filled, and wrong things are culled. + ++updateOrderLevel; + m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeFrustrumCulling); ++updateOrderLevel; m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer, m_RenderFrame, m_OctreeFrustrumCulling); ++updateOrderLevel; diff --git a/src/Game/Network/MultiplayerSnapshotFilter.cpp b/src/Game/Network/MultiplayerSnapshotFilter.cpp index 69b7f282..295cdd7a 100644 --- a/src/Game/Network/MultiplayerSnapshotFilter.cpp +++ b/src/Game/Network/MultiplayerSnapshotFilter.cpp @@ -13,6 +13,7 @@ bool MultiplayerSnapshotFilter::FilterComponent(EntityWrapper entity, SharedComp component.Info.Name == "Transform" || component.Info.Name == "Physics" || component.Info.Name == "AssaultWeapon" + || component.Info.Name == "DefenderWeapon" || component.Info.Name == "Animation" || component.Info.Name == "AnimationOffset" || entity.Name() == "PlayerName" diff --git a/src/Game/Systems/DamageIndicatorSystem.cpp b/src/Game/Systems/DamageIndicatorSystem.cpp index 92fbe607..ca26052d 100644 --- a/src/Game/Systems/DamageIndicatorSystem.cpp +++ b/src/Game/Systems/DamageIndicatorSystem.cpp @@ -13,7 +13,7 @@ DamageIndicatorSystem::DamageIndicatorSystem(SystemParams params) } void DamageIndicatorSystem::Update(double dt) { - if (!IsServer) { + if (!IsServer && LocalPlayer.Valid()) { for (auto& iter = updateDamageIndicatorVector.begin(); iter != updateDamageIndicatorVector.end(); iter++) { if (!iter->spriteEntity.Valid()) { updateDamageIndicatorVector.erase(iter); diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 2e2502ec..b9ce23d4 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -116,12 +116,18 @@ void PlayerMovementSystem::updateMovementControllers(double dt) 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 (!controller->PlayerIsDashing() && controller->Jumping() && !controller->Crouching() && (isOnGround || !controller->DoubleJumping())) { - (bool)cPhysics["IsOnGround"] = false; + if (isOnGround) { + controller->SetDoubleJumping(false); + } + //If player presses Jump and is not crouching. + if (controller->Jumping() && !controller->Crouching()) { if (isOnGround) { - controller->SetDoubleJumping(false); - } else { + (bool)cPhysics["IsOnGround"] = false; + velocity.y = player["Player"]["JumpSpeed"]; + } else if (player.HasComponent("DoubleJump") && !controller->DoubleJumping()) { + //Enter here if player can double jump and is doing so. + (bool)cPhysics["IsOnGround"] = false; + velocity.y = player["DoubleJump"]["DoubleJumpSpeed"]; // If IsServer and network is off this will not work if (IsClient) { //put a hexagon at the players feet @@ -133,7 +139,6 @@ void PlayerMovementSystem::updateMovementControllers(double dt) m_EventBroker->Publish(e); } } - velocity.y = 4.f; } if (player.HasComponent("AABB")) { diff --git a/src/Game/Systems/PlayerSpawnSystem.cpp b/src/Game/Systems/PlayerSpawnSystem.cpp index 6254c674..e03a1778 100644 --- a/src/Game/Systems/PlayerSpawnSystem.cpp +++ b/src/Game/Systems/PlayerSpawnSystem.cpp @@ -1,29 +1,40 @@ #include "Systems/PlayerSpawnSystem.h" -//This should be set by the config anyway. -float PlayerSpawnSystem::m_RespawnTime = 15.0f; - PlayerSpawnSystem::PlayerSpawnSystem(SystemParams params) : System(params) - , m_Timer(0.f) + , m_DbgConfigForceRespawn(false) { EVENT_SUBSCRIBE_MEMBER(m_OnInputCommand, &PlayerSpawnSystem::OnInputCommand); EVENT_SUBSCRIBE_MEMBER(m_OnPlayerSpawnerd, &PlayerSpawnSystem::OnPlayerSpawned); EVENT_SUBSCRIBE_MEMBER(m_OnPlayerDeath, &PlayerSpawnSystem::OnPlayerDeath); - m_NetworkEnabled = ResourceManager::Load("Config.ini")->Get("Networking.StartNetwork", false); + ConfigFile* config = ResourceManager::Load("Config.ini"); + m_NetworkEnabled = config->Get("Networking.StartNetwork", false); + m_ForcedRespawnTime = config->Get("Debug.RespawnTime", -1.0f); + m_DbgConfigForceRespawn = m_ForcedRespawnTime > 0; } void PlayerSpawnSystem::Update(double dt) { - //Increase timer. - m_Timer += dt; - if (m_Timer < m_RespawnTime) { - return; + // If there are no CapturePointGameMode components we will just spawn immediately. + // Should be able to support older maps with this. + // TODO: In the future we might want to return instead, to avoid spawning in the menu for instance. + auto pool = m_World->GetComponents("CapturePointGameMode"); + if (pool != nullptr && pool->size() > 0) + { + // Take the first CapturePointGameMode component found. + ComponentWrapper& modeComponent = *pool->begin(); + // Increase timer. + double& timer = (double&)modeComponent["RespawnTime"]; + timer += dt; + double maxRespawnTime = m_DbgConfigForceRespawn ? m_ForcedRespawnTime : (double)modeComponent["MaxRespawnTime"]; + if (timer < maxRespawnTime) { + return; + } + // If respawn time has passed, we spawn all players that have requested to be spawned. + timer = 0; } - //If respawn time has passed, we spawn all players that have requested to be spawned. - m_Timer = 0.f; - //If there are no spawn requests, return immediately, if we are client the SpawnRequests should always be empty. + // If there are no spawn requests, return immediately, if we are client the SpawnRequests should always be empty. if (m_SpawnRequests.size() == 0) { return; } diff --git a/src/Game/Systems/SpawnerSystem.cpp b/src/Game/Systems/SpawnerSystem.cpp index 90f677fe..6500460f 100644 --- a/src/Game/Systems/SpawnerSystem.cpp +++ b/src/Game/Systems/SpawnerSystem.cpp @@ -36,7 +36,7 @@ EntityWrapper SpawnerSystem::Spawn(EntityWrapper spawner, EntityWrapper parent / } // Find any SpawnPoints existing as children of spawner - auto children = spawner.World->GetChildren(spawner.ID); + auto children = spawner.World->GetDirectChildren(spawner.ID); std::vector spawnPoints; for (auto kv = children.first; kv != children.second; ++kv) { const EntityID& child = kv->second; diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp_ similarity index 87% rename from src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp rename to src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp_ index 84d3ccd4..c3b3385f 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp_ @@ -1,13 +1,5 @@ #include "Systems/Weapon/AssaultWeaponBehaviour.h" -AssaultWeaponBehaviour::AssaultWeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree* collisionOctree, EntityWrapper player) - : WeaponBehaviour(systemParams, renderer, collisionOctree, player) -{ - m_FirstPersonModel = m_Player.FirstChildByName("Hands"); - m_ThirdPersonModel = m_Player.FirstChildByName("PlayerModel"); - EVENT_SUBSCRIBE_MEMBER(m_EAnimationComplete, &AssaultWeaponBehaviour::OnAnimationComplete); -} - void AssaultWeaponBehaviour::Fire() { m_TimeSinceLastFire = 0.0; @@ -36,7 +28,7 @@ void AssaultWeaponBehaviour::Reload() return; } - // Don't reload if we're completly out of ammo + // Don't reload if we're completely out of ammo if (ammo == 0) { playEmptySound(); m_TimeSinceLastFire = -0.0f; // HACK: To make empty sound play with interval @@ -56,14 +48,14 @@ void AssaultWeaponBehaviour::Update(double dt) { if (m_Reloading) { m_ReloadTimer -= dt; - // Re-enable glow on reload impersonator half-way through the animation + // Re-enable glow on reload impostor half-way through the animation if (IsClient) { if (m_ReloadTimer <= (double)m_Player["AssaultWeapon"]["ReloadTime"] / 2.0) { - if (m_FirstPersonReloadImpersonator.Valid()) { - m_FirstPersonReloadImpersonator["Model"]["GlowMap"] = true; + if (m_FirstPersonReloadImpostor.Valid()) { + m_FirstPersonReloadImpostor["Model"]["GlowMap"] = true; } - if (m_ThirdPersonReloadImpersonator.Valid()) { - m_ThirdPersonReloadImpersonator["Model"]["GlowMap"] = true; + if (m_ThirdPersonReloadImpostor.Valid()) { + m_ThirdPersonReloadImpostor["Model"]["GlowMap"] = true; } } } @@ -96,21 +88,6 @@ void AssaultWeaponBehaviour::Update(double dt) } } -bool AssaultWeaponBehaviour::OnAnimationComplete(Events::AnimationComplete& e) -{ - if (e.Entity != m_FirstPersonModel) { - return false; - } - - //if (e.Name == "ShootRifle") { - // if (!m_Firing) { - // playIdleAnimation(); - // } - //} - - return true; -} - bool AssaultWeaponBehaviour::hasAmmo() { ComponentWrapper& cAssaultWeapon = m_Player["AssaultWeapon"]; @@ -177,7 +154,6 @@ void AssaultWeaponBehaviour::spawnTracer() float AssaultWeaponBehaviour::traceRayDistance(glm::vec3 origin, glm::vec3 direction) { - // TODO: Cast a ray and size tracer appropriately float distance; glm::vec3 pos; auto entity = Collision::EntityFirstHitByRay(Ray(origin, direction), m_CollisionOctree, distance, pos); @@ -215,6 +191,12 @@ void AssaultWeaponBehaviour::playEmptySound() void AssaultWeaponBehaviour::viewPunch() { + // Since we send absolute client orientations to server, running this server side would + // cause aim desync. + if (!IsClient) { + return; + } + EntityWrapper playerCamera = m_Player.FirstChildByName("Camera"); if (!playerCamera.Valid()) { return; @@ -323,8 +305,8 @@ void AssaultWeaponBehaviour::playReloadAnimation() EntityWrapper firstPersonWeaponModel = m_Player.FirstChildByName("WeaponModel"); EntityWrapper reloadSpawner = m_Player.FirstChildByName("FirstPersonReloadSpawner"); if (IsClient) { - m_FirstPersonReloadImpersonator = SpawnerSystem::Spawn(reloadSpawner, reloadSpawner); - firstPersonWeaponModel["Model"].Copy(m_FirstPersonReloadImpersonator["Model"]); + m_FirstPersonReloadImpostor = SpawnerSystem::Spawn(reloadSpawner, reloadSpawner); + firstPersonWeaponModel["Model"].Copy(m_FirstPersonReloadImpostor["Model"]); } firstPersonWeaponModel["Model"]["Visible"] = false; } @@ -332,8 +314,8 @@ void AssaultWeaponBehaviour::playReloadAnimation() EntityWrapper thirdPersonWeaponModel = m_Player.FirstChildByName("ThirdPersonWeaponModel"); EntityWrapper reloadSpawner = m_Player.FirstChildByName("ThirdPersonReloadSpawner"); if (IsClient) { - m_ThirdPersonReloadImpersonator = SpawnerSystem::Spawn(reloadSpawner, reloadSpawner); - thirdPersonWeaponModel["Model"].Copy(m_ThirdPersonReloadImpersonator["Model"]); + m_ThirdPersonReloadImpostor = SpawnerSystem::Spawn(reloadSpawner, reloadSpawner); + thirdPersonWeaponModel["Model"].Copy(m_ThirdPersonReloadImpostor["Model"]); } thirdPersonWeaponModel["Model"]["Visible"] = false; } @@ -371,7 +353,7 @@ bool AssaultWeaponBehaviour::shoot(double damage) return false; } - // Don't let us shoot ourselves in the foot + // Don't let us shoot ourselves in the foot somehow if (victim == LocalPlayer) { return false; } diff --git a/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp b/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp new file mode 100644 index 00000000..028bd10c --- /dev/null +++ b/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp @@ -0,0 +1,188 @@ +#include "Systems/Weapon/DefenderWeaponBehaviour.h" + +void DefenderWeaponBehaviour::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cWeapon, double dt) +{ + (double&)cWeapon["TimeSinceLastFire"] += dt; + WeaponBehaviour::UpdateComponent(entity, cWeapon, dt); +} + +void DefenderWeaponBehaviour::UpdateWeapon(WeaponInfo& wi, double dt) +{ + ComponentWrapper cWeapon = wi.GetComponent(); + + bool isFiring = cWeapon["IsFiring"]; + bool cooldownPassed = (double)cWeapon["TimeSinceLastFire"] >= (60.0 / (double)cWeapon["RPM"]); + bool isNotShielding = wi.Player.ChildrenWithComponent("Shield").size() == 0; + if (isFiring && cooldownPassed && isNotShielding) { + fireShell(wi); + } +} + +void DefenderWeaponBehaviour::OnPrimaryFire(WeaponInfo& wi) +{ + ComponentWrapper cWeapon = wi.GetComponent(); + cWeapon["IsFiring"] = true; + bool cooldownPassed = (double)cWeapon["TimeSinceLastFire"] >= (60.0 / (double)cWeapon["RPM"]); + bool isNotShielding = wi.Player.ChildrenWithComponent("Shield").size() == 0; + if (cooldownPassed && isNotShielding) { + fireShell(wi); + } +} + +void DefenderWeaponBehaviour::OnCeasePrimaryFire(WeaponInfo& wi) +{ + ComponentWrapper cWeapon = wi.GetComponent(); + cWeapon["IsFiring"] = false; +} + +bool DefenderWeaponBehaviour::OnInputCommand(WeaponInfo& wi, const Events::InputCommand& e) +{ + if (e.Command == "SpecialAbility" && IsServer) { + EntityWrapper attachment = wi.Player.FirstChildByName("ShieldAttachment"); + if (attachment.Valid()) { + if (e.Value > 0) { + SpawnerSystem::Spawn(attachment, attachment); + } else { + attachment.DeleteChildren(); + } + } + } + + return false; +} + +bool DefenderWeaponBehaviour::OnSetCamera(const Events::SetCamera& e) +{ + m_CurrentCamera = e.CameraEntity; + return true; +} + +void DefenderWeaponBehaviour::fireShell(WeaponInfo& wi) +{ + ComponentWrapper cWeapon = wi.GetComponent(); + + cWeapon["TimeSinceLastFire"] = 0.0; + int numPellets = cWeapon["NumPellets"]; + float spreadAngle = cWeapon["SpreadAngle"]; + std::uniform_real_distribution randomSpreadAngle(-spreadAngle, spreadAngle); + + // Calculate pellet angles + // HACK: Random for now? + // TODO: Make distribution even for each quadrant + std::vector pelletAngles; + for (int i = 0; i < numPellets; i++) { + pelletAngles.push_back(glm::vec2(randomSpreadAngle(m_RandomEngine), randomSpreadAngle(m_RandomEngine))); + LOG_DEBUG("%f %f", pelletAngles[i].x, pelletAngles[i].y); + } + + double pelletDamage = (double)cWeapon["BaseDamage"] / numPellets; + + // Tracers + EntityWrapper weaponModelEntity; + if (wi.Player == LocalPlayer) { + weaponModelEntity = wi.FirstPersonEntity; + } else { + weaponModelEntity = wi.ThirdPersonEntity; + } + if (weaponModelEntity.Valid()) { + EntityWrapper spawner = weaponModelEntity.FirstChildByName("WeaponMuzzle"); + for (auto& angles : pelletAngles) { + glm::vec3 direction = Transform::AbsoluteOrientation(spawner) * glm::quat(glm::vec3(angles, 0.f)) * glm::vec3(0, 0, -1); + float distance = traceRayDistance(Transform::AbsolutePosition(spawner), direction); + EntityWrapper ray = SpawnerSystem::Spawn(spawner); + ((glm::vec3&)ray["Transform"]["Scale"]).z = (distance / 100.f); + glm::vec3& orientation = ray["Transform"]["Orientation"]; + orientation.x += angles.x; + orientation.y += angles.y; + glm::vec3 trajectory = direction * distance; + dealDamage(wi, direction, pelletDamage); + } + } + +} + +void DefenderWeaponBehaviour::dealDamage(WeaponInfo& wi, glm::vec3 direction, double damage) +{ + // Only deal damage client side + if (!IsClient) { + return; + } + + // Only handle shooting for the local player + if (wi.Player != LocalPlayer) { + return; + } + + // Make sure the player isn't shooting from the grave + if (!wi.Player.Valid()) { + return; + } + + glm::vec3 maxRange = direction * 2.f; + EntityWrapper camera = wi.Player.FirstChildByName("Camera"); + glm::vec3 cameraPosition = Transform::AbsolutePosition(camera); + if (!camera.Valid()) { + return; + } + Rectangle screenResolution = m_Renderer->GetViewportSize(); + glm::vec2 centerScreen = glm::vec2(screenResolution.Width / 2, screenResolution.Height / 2); + glm::vec2 screenCoords = cameraFromEntity(m_CurrentCamera).WorldToScreen(cameraPosition + maxRange, m_Renderer->GetViewportSize()); + PickData pickData = m_Renderer->Pick(centerScreen + screenCoords); + EntityWrapper victim(m_World, pickData.Entity); + if (!victim.Valid()) { + return; + } + + // Don't let us shoot ourselves in the foot somehow + if (victim == LocalPlayer) { + return; + } + + // Only care about players being hit + if (!victim.HasComponent("Player")) { + victim = victim.FirstParentWithComponent("Player"); + } + if (!victim.Valid()) { + return; + } + + // Check for friendly fire + if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)wi.Player["Team"]["Team"]) { + return; + } + + // Deal damage! + Events::PlayerDamage ePlayerDamage; + ePlayerDamage.Inflictor = wi.Player; + ePlayerDamage.Victim = victim; + ePlayerDamage.Damage = damage; + m_EventBroker->Publish(ePlayerDamage); + LOG_DEBUG("Damage: %f", damage); +} + +float DefenderWeaponBehaviour::traceRayDistance(glm::vec3 origin, glm::vec3 direction) +{ + float distance; + glm::vec3 pos; + auto entity = Collision::EntityFirstHitByRay(Ray(origin, direction), m_CollisionOctree, distance, pos); + if (entity) { + return distance; + } else { + return 100.f; + } +} + +Camera DefenderWeaponBehaviour::cameraFromEntity(EntityWrapper camera) +{ + ComponentWrapper cTransform = camera["Transform"]; + ComponentWrapper cCamera = camera["Camera"]; + Camera cam( + (float)m_Renderer->Resolution().Width / m_Renderer->Resolution().Height, + (double)cCamera["FOV"], + (double)cCamera["NearClip"], + (double)cCamera["FarClip"] + ); + cam.SetPosition(cTransform["Position"]); + cam.SetOrientation(glm::quat((const glm::vec3&)cTransform["Orientation"])); + return cam; +} diff --git a/src/Game/Systems/Weapon/WeaponSystem.cpp b/src/Game/Systems/Weapon/WeaponSystem.cpp_ similarity index 56% rename from src/Game/Systems/Weapon/WeaponSystem.cpp rename to src/Game/Systems/Weapon/WeaponSystem.cpp_ index 3a49ae90..d33c5098 100644 --- a/src/Game/Systems/Weapon/WeaponSystem.cpp +++ b/src/Game/Systems/Weapon/WeaponSystem.cpp_ @@ -13,7 +13,7 @@ WeaponSystem::WeaponSystem(SystemParams params, IRenderer* renderer, Octree weaponAttachments = player.ChildrenWithComponent("WeaponAttachment"); + + // Find the weapon attachments matching the slot selected + EntityWrapper firstPersonAttachment; + EntityWrapper thirdPersonAttachment; + for (auto& attachment : weaponAttachments) { + ComponentWrapper cWeaponAttachment = attachment["WeaponAttachment"]; + if ((ComponentInfo::EnumType)cWeaponAttachment["Slot"] == slot) { + ComponentWrapper::SubscriptProxy person = cWeaponAttachment["Person"]; + if (person == person.Enum("FirstPerson")) { + firstPersonAttachment = attachment; + } else if (person == person.Enum("ThirdPerson")) { + thirdPersonAttachment = attachment; + } + } + } + + if (firstPersonAttachment.Valid() && thirdPersonAttachment.Valid()) { + LOG_WARNING("No weapon attachment found for slot %i of player #%i", slot, player.ID); + return; + } + + // TODO: Delete old weapons + + // Spawn the weapon(s) + EntityWrapper firstPersonWeapon; + EntityWrapper thirdPersonWeapon; + if (firstPersonAttachment.Valid()) { + firstPersonWeapon = SpawnerSystem::Spawn(firstPersonAttachment, firstPersonAttachment); + } + if (thirdPersonAttachment.Valid()) { + firstPersonWeapon = SpawnerSystem::Spawn(thirdPersonAttachment, thirdPersonAttachment); + } + + // Create the correct behaviour + if (firstPersonWeapon.Valid()) { + if (firstPersonWeapon.HasComponent("AssaultWeapon") { + + } + } + // Primary if (slot == 1) { // TODO: if class... - if (m_ActiveWeapons.count(player) == 0) { - m_ActiveWeapons.insert(std::make_pair(player, std::make_shared(m_SystemParams, m_Renderer, m_CollisionOctree, player))); - } else { - //m_ActiveWeapons.erase(player); - } + nextBehaviour = std::make_shared(m_SystemParams, m_Renderer, m_CollisionOctree, player); } // Secondary if (slot == 2) { //m_ActiveWeapons[player] = std::make_shared(); } + + if (nextBehaviour != nullptr) { + // TODO: Destroy previous behaviour and make new + if (m_ActiveWeapons.count(player) == 0) { + m_ActiveWeapons[player] = nextBehaviour; + } + } } bool WeaponSystem::OnPlayerSpawned(Events::PlayerSpawned& e) From 8cda614de456ef9103bed064deeae39260f1419a Mon Sep 17 00:00:00 2001 From: Teejoon Date: Tue, 1 Mar 2016 12:54:01 +0100 Subject: [PATCH 100/252] Added transparent object that disappeared from the merge --- src/Engine/Rendering/DrawFinalPass.cpp | 2 +- src/Engine/Rendering/PickingPassState.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 6b600d22..29499c79 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -189,7 +189,7 @@ void DrawFinalPass::Draw(RenderScene& scene) GLERROR("OpaqueObjects"); //state->BlendFunc(GL_ONE, GL_ONE); state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - + DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene); GLERROR("TransparentObjects"); //state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); DrawSprites(scene.Jobs.SpriteJob, scene); diff --git a/src/Engine/Rendering/PickingPassState.cpp b/src/Engine/Rendering/PickingPassState.cpp index 3c19dc06..767b9577 100644 --- a/src/Engine/Rendering/PickingPassState.cpp +++ b/src/Engine/Rendering/PickingPassState.cpp @@ -9,7 +9,6 @@ PickingPassState::PickingPassState(GLuint frameBuffer) Enable(GL_DEPTH_TEST); Enable(GL_CULL_FACE); Disable(GL_BLEND); - glm::vec4 clearColor = glm::vec4(0.f); //ClearColor(clearColor); //Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); From d32a483bb42a1831962676204c48eacee9ae28a9 Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Tue, 1 Mar 2016 13:17:17 +0100 Subject: [PATCH 101/252] remove farclip override --- src/Engine/Editor/EditorSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Engine/Editor/EditorSystem.cpp b/src/Engine/Editor/EditorSystem.cpp index 67fad18a..e770c154 100644 --- a/src/Engine/Editor/EditorSystem.cpp +++ b/src/Engine/Editor/EditorSystem.cpp @@ -18,7 +18,7 @@ EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame m_ActualCamera = m_EditorCamera; m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Transform"); auto cCamera = m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Camera"); - (double&)cCamera["FarClip"] = 300.0; + //(double&)cCamera["FarClip"] = 300.0; m_EditorCameraInputController = new EditorCameraInputController(m_EventBroker, -1); From 1961c16fe27b7b7c82350c26f519a5a038867061 Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Tue, 1 Mar 2016 13:27:52 +0100 Subject: [PATCH 102/252] add weight slider --- src/Engine/Rendering/ShadowPass.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index 3fc2c5d0..7b45e31a 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -199,6 +199,7 @@ void ShadowPass::RadiusToLightspace(ShadowFrustum& frustum) void ShadowPass::Draw(RenderScene & scene) { ImGui::DragFloat2("ShadowMapNearFar", m_NearFarPlane, 1.f, -1000.f, 1000.f); + ImGui::DragFloat("ShadowClippingWeight", &m_SplitWeight, 0.001f, 0.f, 1.f); InitializeCameras(scene); UpdateSplitDist(m_shadowFrusta, scene.Camera->NearClip(), scene.Camera->FarClip()); From 36f6ade87a461bd5e5d2f53e6cd47afa633d38f2 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Tue, 1 Mar 2016 13:36:34 +0100 Subject: [PATCH 103/252] Fixed editor keyboard shortcuts getting mixed up with GUI input actions --- src/Engine/Editor/EditorGUI.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Engine/Editor/EditorGUI.cpp b/src/Engine/Editor/EditorGUI.cpp index f2690f13..8ce15d0a 100644 --- a/src/Engine/Editor/EditorGUI.cpp +++ b/src/Engine/Editor/EditorGUI.cpp @@ -580,6 +580,11 @@ void EditorGUI::createWidgetToolButton(WidgetMode mode) bool EditorGUI::OnKeyDown(const Events::KeyDown& e) { + ImGuiIO& io = ImGui::GetIO(); + if (io.WantCaptureKeyboard) { + return false; + } + if (e.ModCtrl && e.KeyCode == GLFW_KEY_S) { if (m_CurrentSelection.Valid()) { EntityWrapper baseParent = m_CurrentSelection; From 141c58005fb58886a612ef14627019637495a95d Mon Sep 17 00:00:00 2001 From: antc13 Date: Tue, 1 Mar 2016 15:28:22 +0100 Subject: [PATCH 104/252] Changing Models WIP --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 10a61165..022890f8 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 10a611659ddaadfea6a560e707d395834855a979 +Subproject commit 022890f8f522eb0a88f5ebc7cda9af0b235e438a From 7ba5e01560dbb86ff0d258476d5ed6541d2487e9 Mon Sep 17 00:00:00 2001 From: Tleety Date: Tue, 1 Mar 2016 15:37:28 +0100 Subject: [PATCH 105/252] CapturePointArrow component files --- .../Schema/Components/CapturePointArrow.xml | 5 ++++ .../Schema/Components/CapturePointArrow.xsd | 24 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 resources/Schema/Components/CapturePointArrow.xml create mode 100644 resources/Schema/Components/CapturePointArrow.xsd diff --git a/resources/Schema/Components/CapturePointArrow.xml b/resources/Schema/Components/CapturePointArrow.xml new file mode 100644 index 00000000..2943d57b --- /dev/null +++ b/resources/Schema/Components/CapturePointArrow.xml @@ -0,0 +1,5 @@ + + + 0 + + \ No newline at end of file diff --git a/resources/Schema/Components/CapturePointArrow.xsd b/resources/Schema/Components/CapturePointArrow.xsd new file mode 100644 index 00000000..7984fc50 --- /dev/null +++ b/resources/Schema/Components/CapturePointArrow.xsd @@ -0,0 +1,24 @@ + + + + + + + Hud element for tracking capture points. + + + + + + Corresponds to the number on the capture point it should track. + + + + + Specify the team that own this capturePoint. + + + + + + \ No newline at end of file From 5c6a652316bd875acad548965ddf23a681363596 Mon Sep 17 00:00:00 2001 From: William Moberg Date: Tue, 1 Mar 2016 15:53:59 +0100 Subject: [PATCH 106/252] Fixed so unregistered components are ignored instead of crashing the game. --- resources/Schema/Types/Entity.xsd | 2 ++ src/Engine/Core/EntityFileParser.cpp | 16 +++++++++++++--- src/Engine/Core/Util/Logging.cpp | 4 ++-- src/Engine/Editor/EditorSystem.cpp | 7 ++++--- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index 0965ef89..1c9456ad 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -52,6 +52,8 @@ + + diff --git a/src/Engine/Core/EntityFileParser.cpp b/src/Engine/Core/EntityFileParser.cpp index 23c0c4c4..2beaac14 100644 --- a/src/Engine/Core/EntityFileParser.cpp +++ b/src/Engine/Core/EntityFileParser.cpp @@ -1,6 +1,6 @@ #include "Core/EntityFileParser.h" -EntityFileParser::EntityFileParser(const EntityFile* entityFile) +EntityFileParser::EntityFileParser(const EntityFile* entityFile) : m_EntityFile(entityFile) { m_Handler.SetStartEntityCallback(std::bind(&EntityFileParser::onStartEntity, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); @@ -33,13 +33,20 @@ void EntityFileParser::onStartEntity(EntityID entity, EntityID parent, const std void EntityFileParser::onStartComponent(EntityID entity, const std::string& component) { - EntityID realEntity = m_EntityIDMapper.at(entity); - m_World->AttachComponent(realEntity, component); + if (m_World->GetComponentPools().count(component) != 0) { + EntityID realEntity = m_EntityIDMapper.at(entity); + m_World->AttachComponent(realEntity, component); + } else { + LOG_ERROR("Tried to attach unregistered component \"%s\"! to entity #%i. Ignoring.", component.c_str(), entity); + } //LOG_DEBUG("Attached component of type \"%s\" to entity #%i (%i)", component.c_str(), entity, realEntity); } void EntityFileParser::onStartComponentField(EntityID entity, const std::string& componentType, const std::string& fieldName, const std::map& attributes) { + if (m_World->GetComponentPools().count(componentType) == 0) { + return; + } EntityID realEntity = m_EntityIDMapper.at(entity); ComponentWrapper component = m_World->GetComponent(realEntity, componentType); auto fieldIt = component.Info.Fields.find(fieldName); @@ -61,6 +68,9 @@ void EntityFileParser::onStartComponentField(EntityID entity, const std::string& void EntityFileParser::onFieldData(EntityID entity, const std::string& componentType, const std::string& fieldName, const char* fieldData) { + if (m_World->GetComponentPools().count(componentType) == 0) { + return; + } EntityID realEntity = m_EntityIDMapper.at(entity); ComponentWrapper component = m_World->GetComponent(realEntity, componentType); auto fieldIt = component.Info.Fields.find(fieldName); diff --git a/src/Engine/Core/Util/Logging.cpp b/src/Engine/Core/Util/Logging.cpp index c7612fd8..63a6f380 100644 --- a/src/Engine/Core/Util/Logging.cpp +++ b/src/Engine/Core/Util/Logging.cpp @@ -33,8 +33,8 @@ void _LOG(_LOG_LEVEL logLevel, const char* file, const char* func, unsigned int va_end(args); if (logLevel == LOG_LEVEL_ERROR) { - //std::cerr << file << ":" << line << " " << func << std::endl; - //std::cerr << _LOG_LEVEL_PREFIX[logLevel] << message << std::endl; + std::cerr << file << ":" << line << " " << func << std::endl; + std::cerr << _LOG_LEVEL_PREFIX[logLevel] << message << std::endl; } else { std::cout << _LOG_LEVEL_PREFIX[logLevel] << message << std::endl; } diff --git a/src/Engine/Editor/EditorSystem.cpp b/src/Engine/Editor/EditorSystem.cpp index 4bee1427..47547b8f 100644 --- a/src/Engine/Editor/EditorSystem.cpp +++ b/src/Engine/Editor/EditorSystem.cpp @@ -258,16 +258,17 @@ EntityWrapper EditorSystem::importEntity(EntityWrapper parent, boost::filesystem return EntityWrapper::Invalid; } - try { + //try { auto entityFile = ResourceManager::Load(filePath.string()); EntityFilePreprocessor fpp(entityFile); fpp.RegisterComponents(parent.World); EntityFileParser fp(entityFile); EntityID newEntity = fp.MergeEntities(parent.World, parent.ID); return EntityWrapper(parent.World, newEntity); - } catch (const std::exception&) { + /*} catch (const std::exception& e) { + LOG_ERROR("Failed to import entity \"%s\": \"%s\"", filePath.string().c_str(), e.what()); return EntityWrapper::Invalid; - } + }*/ } void EditorSystem::setWidgetMode(EditorGUI::WidgetMode mode) From b0a66f9e8369801db3b2c322052b29bdb84c2141 Mon Sep 17 00:00:00 2001 From: Tleety Date: Tue, 1 Mar 2016 16:19:59 +0100 Subject: [PATCH 107/252] Components for CapturePoint arrow HUD element and a system skeleton --- .../Game/Systems/CapturePointArrowHUDSystem.h | 20 ++++++++++++++++ resources/Schema/Components.xsd | 1 + .../Schema/Components/CapturePointArrow.xml | 5 ---- .../Schema/Components/CapturePointArrow.xsd | 24 ------------------- .../Components/CapturePointArrowHUD.xml | 4 ++++ .../Components/CapturePointArrowHUD.xsd | 18 ++++++++++++++ resources/Schema/Types/Entity.xsd | 1 + src/Game/Game.cpp | 2 ++ .../Systems/CapturePointArrowHUDSystem.cpp | 13 ++++++++++ 9 files changed, 59 insertions(+), 29 deletions(-) create mode 100644 include/Game/Systems/CapturePointArrowHUDSystem.h delete mode 100644 resources/Schema/Components/CapturePointArrow.xml delete mode 100644 resources/Schema/Components/CapturePointArrow.xsd create mode 100644 resources/Schema/Components/CapturePointArrowHUD.xml create mode 100644 resources/Schema/Components/CapturePointArrowHUD.xsd create mode 100644 src/Game/Systems/CapturePointArrowHUDSystem.cpp diff --git a/include/Game/Systems/CapturePointArrowHUDSystem.h b/include/Game/Systems/CapturePointArrowHUDSystem.h new file mode 100644 index 00000000..30406c3c --- /dev/null +++ b/include/Game/Systems/CapturePointArrowHUDSystem.h @@ -0,0 +1,20 @@ +#ifndef CapturePointArrowHUDSystem_h__ +#define CapturePointArrowHUDSystem_h__ + +#include +#include + +#include "Common.h" +#include "Core/System.h" + +class CapturePointArrowHUDSystem : public ImpureSystem +{ +public: + CapturePointArrowHUDSystem(SystemParams params); + + virtual void Update(double dt) override; + +private: +}; + +#endif \ No newline at end of file diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index eb41ed6a..d8ace908 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -50,4 +50,5 @@ + \ No newline at end of file diff --git a/resources/Schema/Components/CapturePointArrow.xml b/resources/Schema/Components/CapturePointArrow.xml deleted file mode 100644 index 2943d57b..00000000 --- a/resources/Schema/Components/CapturePointArrow.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - 0 - - \ No newline at end of file diff --git a/resources/Schema/Components/CapturePointArrow.xsd b/resources/Schema/Components/CapturePointArrow.xsd deleted file mode 100644 index 7984fc50..00000000 --- a/resources/Schema/Components/CapturePointArrow.xsd +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - Hud element for tracking capture points. - - - - - - Corresponds to the number on the capture point it should track. - - - - - Specify the team that own this capturePoint. - - - - - - \ No newline at end of file diff --git a/resources/Schema/Components/CapturePointArrowHUD.xml b/resources/Schema/Components/CapturePointArrowHUD.xml new file mode 100644 index 00000000..ebe8727a --- /dev/null +++ b/resources/Schema/Components/CapturePointArrowHUD.xml @@ -0,0 +1,4 @@ + + + 0 + \ No newline at end of file diff --git a/resources/Schema/Components/CapturePointArrowHUD.xsd b/resources/Schema/Components/CapturePointArrowHUD.xsd new file mode 100644 index 00000000..d1c035f6 --- /dev/null +++ b/resources/Schema/Components/CapturePointArrowHUD.xsd @@ -0,0 +1,18 @@ + + + + + + HUD element for tracking next capturable Capture Point. + + + + + + Corresponds to the current capturepoint the arrow points Towards + + + + + + \ No newline at end of file diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index 0965ef89..61d8e520 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -52,6 +52,7 @@ + diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 8be665e0..e16d1841 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -25,6 +25,7 @@ #include "Rendering/AnimationSystem.h" #include "Network/MultiplayerSnapshotFilter.h" #include "Game/Systems/AmmunitionHUDSystem.h" +#include "Game/Systems/CapturePointArrowHUDSystem.h" #include "Game/Systems/KillFeedSystem.h" #include "GUI/ButtonSystem.h" #include "GUI/MainMenuSystem.h" @@ -131,6 +132,7 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); + m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer); m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer); diff --git a/src/Game/Systems/CapturePointArrowHUDSystem.cpp b/src/Game/Systems/CapturePointArrowHUDSystem.cpp new file mode 100644 index 00000000..e621d90d --- /dev/null +++ b/src/Game/Systems/CapturePointArrowHUDSystem.cpp @@ -0,0 +1,13 @@ +#include "Systems/CapturePointArrowHUDSystem.h" + +CapturePointArrowHUDSystem::CapturePointArrowHUDSystem(SystemParams params) + : System(params) + , ImpureSystem() +{ +} + + +void CapturePointArrowHUDSystem::Update(double dt) +{ + //Logic here +} \ No newline at end of file From 3d4427dd20d0c8ef62aa24d1c1deaaf18c693ea2 Mon Sep 17 00:00:00 2001 From: William Moberg Date: Tue, 1 Mar 2016 17:32:14 +0100 Subject: [PATCH 108/252] Added entity SpectatorCamera that shows respawntime, will activate when explosion effect is deleted. --- include/Game/Systems/PlayerDeathSystem.h | 5 + .../Schema/Entities/NewMapWSpectatorCam.xml | 5356 +++++++++++++++++ resources/Schema/Entities/SpectatorCamera.xml | 40 + resources/Schema/Types/Entity.xsd | 1 + src/Game/Systems/PlayerDeathSystem.cpp | 24 + src/Game/Systems/PlayerSpawnSystem.cpp | 12 + 6 files changed, 5438 insertions(+) create mode 100644 resources/Schema/Entities/NewMapWSpectatorCam.xml create mode 100644 resources/Schema/Entities/SpectatorCamera.xml diff --git a/include/Game/Systems/PlayerDeathSystem.h b/include/Game/Systems/PlayerDeathSystem.h index 112c202e..f32e32df 100644 --- a/include/Game/Systems/PlayerDeathSystem.h +++ b/include/Game/Systems/PlayerDeathSystem.h @@ -11,6 +11,7 @@ #include "Core/EntityFileParser.h" #include "Core/EPlayerDeath.h" +#include "Core/EEntityDeleted.h" class PlayerDeathSystem : public ImpureSystem { @@ -20,8 +21,12 @@ public: virtual void Update(double dt) override; private: + EntityWrapper m_LocalPlayerDeathEffect; + EventRelay m_OnPlayerDeath; bool OnPlayerDeath(Events::PlayerDeath& e); + EventRelay m_EEntityDeleted; + bool OnEntityDeleted(Events::EntityDeleted& e); void createDeathEffect(EntityWrapper player); diff --git a/resources/Schema/Entities/NewMapWSpectatorCam.xml b/resources/Schema/Entities/NewMapWSpectatorCam.xml new file mode 100644 index 00000000..f74a4857 --- /dev/null +++ b/resources/Schema/Entities/NewMapWSpectatorCam.xml @@ -0,0 +1,5356 @@ + + + + + + 3.6027407165331624 + 15 + + + + + + + + + + + + + + + Models/Props/Ground.mesh + + + + + + + + + Models/Props/Highground1.mesh + + + + + + + + + + Models/Props/Highground2.mesh + + + + + + + + + + Models/Props/Highground1.mesh + + + + + + + + + + + + Models/Props/Highground2.mesh + + + + + + + + + + + + Models/Props/Highground3.mesh + + + + + + + + + + Models/Props/Highground4.mesh + + + + + + + + + + Models/Props/Highground5.mesh + + + + + + + + + + + Models/Props/Highground6.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallTop.mesh + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall1.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall2.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallSmall3.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall4.mesh + + + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar3Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar3Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall4.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall4.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall4.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall4.mesh + + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/WoodenBridge.mesh + + + + + + + + + + + + + + Models/Props/Bridges/WoodenBridge.mesh + + + + + + + + + + + + + + Models/Props/Bridges/WoodenBridge.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + + Models/Props/Bridges/WoodenBridge.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + + Models/Props/Flora/TreeLog.mesh + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointBlue.mesh + + + + + + + + + + + + + 4 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 3 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 2 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 1.5498908015879351 + 1 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointRed.mesh + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + 10 + + + + + + + + + + 10 + + + + + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + 1 + + + + + + + + + + + + + + Schema/Entities/PlayerRed.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/SpectatorCamera.xml b/resources/Schema/Entities/SpectatorCamera.xml new file mode 100644 index 00000000..dbfdecf0 --- /dev/null +++ b/resources/Schema/Entities/SpectatorCamera.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index 1c9456ad..21605953 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -54,6 +54,7 @@ + diff --git a/src/Game/Systems/PlayerDeathSystem.cpp b/src/Game/Systems/PlayerDeathSystem.cpp index 844d2ed1..f645abe7 100644 --- a/src/Game/Systems/PlayerDeathSystem.cpp +++ b/src/Game/Systems/PlayerDeathSystem.cpp @@ -4,6 +4,7 @@ PlayerDeathSystem::PlayerDeathSystem(SystemParams params) : System(params) { EVENT_SUBSCRIBE_MEMBER(m_OnPlayerDeath, &PlayerDeathSystem::OnPlayerDeath); + EVENT_SUBSCRIBE_MEMBER(m_EEntityDeleted, &PlayerDeathSystem::OnEntityDeleted); } void PlayerDeathSystem::Update(double dt) @@ -59,9 +60,32 @@ void PlayerDeathSystem::createDeathEffect(EntityWrapper player) //camera (with lifetime) behind the player if (player == LocalPlayer) { + m_LocalPlayerDeathEffect = deathEffectEW; auto cam = deathEffectEW.FirstChildByName("Camera"); Events::SetCamera eSetCamera; eSetCamera.CameraEntity = cam; m_EventBroker->Publish(eSetCamera); } } + +bool PlayerDeathSystem::OnEntityDeleted(Events::EntityDeleted& e) +{ + // We only care about when the local players death effect is removed. + if (m_LocalPlayerDeathEffect.ID != e.DeletedEntity) { + return false; + } + // Set the spectator camera as active, if it exists. + auto pool = m_World->GetComponents("CapturePointGameMode"); + if (pool == nullptr || pool->size() == 0) { + return false; + } + ComponentWrapper modeComponent = *pool->begin(); + EntityWrapper theLevel = EntityWrapper(m_LocalPlayerDeathEffect.World, modeComponent.EntityID); + EntityWrapper spectatorCam = theLevel.FirstChildByName("SpectatorCamera"); + if (!spectatorCam.Valid() && spectatorCam.HasComponent("Camera")) { + return false; + } + Events::SetCamera eSetCamera; + eSetCamera.CameraEntity = spectatorCam; + m_EventBroker->Publish(eSetCamera); +} diff --git a/src/Game/Systems/PlayerSpawnSystem.cpp b/src/Game/Systems/PlayerSpawnSystem.cpp index e03a1778..2f6928af 100644 --- a/src/Game/Systems/PlayerSpawnSystem.cpp +++ b/src/Game/Systems/PlayerSpawnSystem.cpp @@ -27,6 +27,18 @@ void PlayerSpawnSystem::Update(double dt) double& timer = (double&)modeComponent["RespawnTime"]; timer += dt; double maxRespawnTime = m_DbgConfigForceRespawn ? m_ForcedRespawnTime : (double)modeComponent["MaxRespawnTime"]; + EntityWrapper theLevel = EntityWrapper(m_World, modeComponent.EntityID); + EntityWrapper spectatorCam = theLevel.FirstChildByName("SpectatorCamera"); + if (spectatorCam.Valid()) { + EntityWrapper HUD = spectatorCam.FirstChildByName("SpectatorHUD"); + if (HUD.Valid()) { + EntityWrapper respawnTimer = spectatorCam.FirstChildByName("RespawnTimer"); + if (respawnTimer.Valid()) { + //Update respawn time in the HUD element. + respawnTimer["Text"]["Content"] = "Time to respawn: " + std::to_string(1 + (int)(maxRespawnTime - timer)); + } + } + } if (timer < maxRespawnTime) { return; } From 15195964daba029f1c3d598191fb727dd3518a3f Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Tue, 1 Mar 2016 17:34:30 +0100 Subject: [PATCH 109/252] ECaptured: added NextCapturePoint entitywrapper. Changed CapturePointID to CapturePointTakenID. Fixed so CapturePoints works in singleplayer again. Captured event is now sent in the next Update, since the information for NextCapturePoint is needed --- include/Engine/Core/ECaptured.h | 3 ++- include/Game/Systems/CapturePointSystem.h | 4 ++-- src/Game/Systems/CapturePointSystem.cpp | 21 +++++++++++++++------ src/Game/Systems/SoundSystem.cpp | 2 +- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/include/Engine/Core/ECaptured.h b/include/Engine/Core/ECaptured.h index d891c7b0..48771cd7 100644 --- a/include/Engine/Core/ECaptured.h +++ b/include/Engine/Core/ECaptured.h @@ -12,7 +12,8 @@ namespace Events struct Captured : Event { int TeamNumberThatCapturedCapturePoint; - EntityID CapturePointID; + EntityID CapturePointTakenID; + EntityWrapper NextCapturePoint; }; } diff --git a/include/Game/Systems/CapturePointSystem.h b/include/Game/Systems/CapturePointSystem.h index 34a23e14..3cf72e15 100644 --- a/include/Game/Systems/CapturePointSystem.h +++ b/include/Game/Systems/CapturePointSystem.h @@ -42,9 +42,9 @@ private: int m_NumberOfCapturePoints = 0; std::map m_CapturePointNumberToEntityMap; - //std::vector - bool m_ResetTimers = false; + bool m_RecentlyCapturedNeedNextCapturePointNow = false; + Events::Captured m_CapturedEvent; //vectors which will keep track of enter/leave changes std::vector> m_ETriggerTouchVector; diff --git a/src/Game/Systems/CapturePointSystem.cpp b/src/Game/Systems/CapturePointSystem.cpp index c99a36a6..9f216cf1 100644 --- a/src/Game/Systems/CapturePointSystem.cpp +++ b/src/Game/Systems/CapturePointSystem.cpp @@ -6,7 +6,7 @@ CapturePointSystem::CapturePointSystem(SystemParams params) , PureSystem("CapturePoint") { //subscribe/listenTo playerdamage,healthpickup events (using the eventBroker) - if (!IsClient) { + if (IsServer) { EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch); EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave); EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured); @@ -18,7 +18,7 @@ CapturePointSystem::CapturePointSystem(SystemParams params) //NOTE: needs to run each frame, since we're possibly modifying the captureTimer for the capturePoints by dt void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, ComponentWrapper& cCapturePoint, double dt) { - if (IsClient) { + if (!IsServer) { return; } if (m_WinnerWasFound) { @@ -78,6 +78,9 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp std::map nextPossibleCapturePoint; nextPossibleCapturePoint["Red"] = -1; nextPossibleCapturePoint["Blue"] = -1; + if (m_RecentlyCapturedNeedNextCapturePointNow) { + nextPossibleCapturePoint["Blue"] = -2; + } for (int i = 0; i < m_NumberOfCapturePoints; i++) { if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) { continue; @@ -102,6 +105,13 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp nextPossibleCapturePoint["Blue"] = i - 1; } } + if (m_RecentlyCapturedNeedNextCapturePointNow) { + m_CapturedEvent.NextCapturePoint = m_CapturedEvent.TeamNumberThatCapturedCapturePoint == blueTeam ? + m_CapturePointNumberToEntityMap[nextPossibleCapturePoint["Blue"]] : + m_CapturePointNumberToEntityMap[nextPossibleCapturePoint["Red"]]; + m_EventBroker->Publish(m_CapturedEvent); + m_RecentlyCapturedNeedNextCapturePointNow = false; + } //reset timers and reset the bool that triggers this if (m_ResetTimers) { @@ -188,10 +198,9 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp teamComponent["Team"] = currentTeam; cCapturePoint["CaptureTimer"] = glm::sign((double)cCapturePoint["CaptureTimer"])*captureTimeToTakeOver; //publish Captured event - Events::Captured e; - e.CapturePointID = cCapturePoint.EntityID; - e.TeamNumberThatCapturedCapturePoint = currentTeam; - m_EventBroker->Publish(e); + m_RecentlyCapturedNeedNextCapturePointNow = true; + m_CapturedEvent.CapturePointTakenID = cCapturePoint.EntityID; + m_CapturedEvent.TeamNumberThatCapturedCapturePoint = currentTeam; //NextPossibleCapturePoint will be calculated in the next update... } } diff --git a/src/Game/Systems/SoundSystem.cpp b/src/Game/Systems/SoundSystem.cpp index b4a37ad0..be9c8aaf 100644 --- a/src/Game/Systems/SoundSystem.cpp +++ b/src/Game/Systems/SoundSystem.cpp @@ -94,7 +94,7 @@ bool SoundSystem::OnCaptured(const Events::Captured & e) if (!LocalPlayer.Valid()) { return false; } - int homeTeam = (int)m_World->GetComponent(e.CapturePointID, "Team")["Team"]; + int homeTeam = (int)m_World->GetComponent(e.CapturePointTakenID, "Team")["Team"]; int team = (int)m_World->GetComponent(LocalPlayer.ID, "Team")["Team"]; Events::PlaySoundOnEntity ev; if (team == homeTeam) { From bba002dea94baf0ca2105688b2d1b5f9194fc55c Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Tue, 1 Mar 2016 17:37:30 +0100 Subject: [PATCH 110/252] Removed DebugCode --- src/Game/Systems/CapturePointSystem.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Game/Systems/CapturePointSystem.cpp b/src/Game/Systems/CapturePointSystem.cpp index 9f216cf1..f748ff09 100644 --- a/src/Game/Systems/CapturePointSystem.cpp +++ b/src/Game/Systems/CapturePointSystem.cpp @@ -78,9 +78,6 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp std::map nextPossibleCapturePoint; nextPossibleCapturePoint["Red"] = -1; nextPossibleCapturePoint["Blue"] = -1; - if (m_RecentlyCapturedNeedNextCapturePointNow) { - nextPossibleCapturePoint["Blue"] = -2; - } for (int i = 0; i < m_NumberOfCapturePoints; i++) { if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) { continue; From 5a8261453e33dbec1917f300d66d7a9fcc3f9701 Mon Sep 17 00:00:00 2001 From: William Moberg Date: Tue, 1 Mar 2016 17:40:42 +0100 Subject: [PATCH 111/252] Eliminated some SAXParsing errors from our console output. --- resources/Schema/Types/Entity.xsd | 3 +++ 1 file changed, 3 insertions(+) diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index 21605953..79ac0f1b 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -55,6 +55,9 @@ + + + From aadfdfdd90f5c59673d41f13786d60239e345d4a Mon Sep 17 00:00:00 2001 From: Jocke Date: Tue, 1 Mar 2016 17:55:00 +0100 Subject: [PATCH 112/252] AmmoPickups and HealthPickups will only spawn on the server. When a ammo pickup is taken the Server will send an Event to that Client and it will update its ammo. --- include/Engine/Network/Client.h | 4 +- include/Engine/Network/MessageType.h | 1 + include/Engine/Network/Server.h | 5 +- include/Game/Systems/AmmoPickupSystem.h | 2 + src/Engine/Network/Client.cpp | 11 ++++ src/Engine/Network/Server.cpp | 21 ++++++- src/Game/Systems/AmmoPickupSystem.cpp | 82 +++++++++++++++++-------- src/Game/Systems/PickupSpawnSystem.cpp | 55 +++++++++-------- 8 files changed, 124 insertions(+), 57 deletions(-) diff --git a/include/Engine/Network/Client.h b/include/Engine/Network/Client.h index be76e265..c407f7f8 100644 --- a/include/Engine/Network/Client.h +++ b/include/Engine/Network/Client.h @@ -26,6 +26,7 @@ #include "Network/EInterpolate.h" #include "Network/SnapshotFilter.h" #include "Core/EPlayerSpawned.h" +#include "Core/EAmmoPickup.h" #include "Network/ESearchForServers.h" struct ServerInfo @@ -106,7 +107,8 @@ private: void parsePlayerDamage(Packet& packet); void parseComponentDeletion(Packet& packet); void parseDoubleJump(Packet& packet); - void InterpolateFields(Packet & packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType); + void parseAmmoPickup(Packet& packet); + void InterpolateFields(Packet& packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType); void parseSnapshot(Packet& packet); void identifyPacketLoss(); void hasServerTimedOut(); diff --git a/include/Engine/Network/MessageType.h b/include/Engine/Network/MessageType.h index 00a2a91f..bf773618 100644 --- a/include/Engine/Network/MessageType.h +++ b/include/Engine/Network/MessageType.h @@ -21,6 +21,7 @@ enum class MessageType PlayerTransform, OnDoubleJump, ServerlistRequest, + AmmoPickup, Invalid }; diff --git a/include/Engine/Network/Server.h b/include/Engine/Network/Server.h index aac4e4c8..3c956ed9 100644 --- a/include/Engine/Network/Server.h +++ b/include/Engine/Network/Server.h @@ -20,6 +20,7 @@ #include "../Game/Events/EDoubleJump.h" #include "Core/EEntityDeleted.h" #include "Core/EComponentDeleted.h" +#include "Core/EAmmoPickup.h" class Server : public Network { @@ -88,7 +89,7 @@ private: void parseServerlistRequest(boost::asio::ip::udp::endpoint endpoint); bool shouldSendToClient(EntityWrapper childEntity); - // Debug event + // Events EventRelay m_EInputCommand; bool OnInputCommand(const Events::InputCommand& e); EventRelay m_EPlayerSpawned; @@ -99,6 +100,8 @@ private: bool OnComponentDeleted(const Events::ComponentDeleted& e); EventRelay m_EPlayerDamage; bool OnPlayerDamage(const Events::PlayerDamage& e); + EventRelay m_EAmmoPickup; + bool OnAmmoPickup(const Events::AmmoPickup& e); }; #endif diff --git a/include/Game/Systems/AmmoPickupSystem.h b/include/Game/Systems/AmmoPickupSystem.h index 0fbd9e08..e4a6df59 100644 --- a/include/Game/Systems/AmmoPickupSystem.h +++ b/include/Game/Systems/AmmoPickupSystem.h @@ -20,6 +20,8 @@ public: private: EventRelay m_ETriggerTouch; bool OnTriggerTouch(Events::TriggerTouch& e); + EventRelay m_EAmmoPickup; + bool OnAmmoPickup(Events::AmmoPickup& e); struct NewAmmoPickup { glm::vec3 Pos; diff --git a/src/Engine/Network/Client.cpp b/src/Engine/Network/Client.cpp index c65d333a..aa87f6ff 100644 --- a/src/Engine/Network/Client.cpp +++ b/src/Engine/Network/Client.cpp @@ -143,6 +143,9 @@ void Client::parseMessageType(Packet& packet) case MessageType::OnDoubleJump: parseDoubleJump(packet); break; + case MessageType::AmmoPickup: + parseAmmoPickup(packet); + break; default: break; } @@ -294,6 +297,14 @@ void Client::parseDoubleJump(Packet & packet) } } +void Client::parseAmmoPickup(Packet & packet) +{ + Events::AmmoPickup e; + e.AmmoGain = packet.ReadPrimitive(); + e.Player = m_LocalPlayer; + m_EventBroker->Publish(e); +} + void Client::updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID) { for (auto field : componentInfo.FieldsInOrder) { diff --git a/src/Engine/Network/Server.cpp b/src/Engine/Network/Server.cpp index 7c614cee..08b72304 100644 --- a/src/Engine/Network/Server.cpp +++ b/src/Engine/Network/Server.cpp @@ -13,7 +13,7 @@ Server::Server(World* world, EventBroker* eventBroker, int port) EVENT_SUBSCRIBE_MEMBER(m_EEntityDeleted, &Server::OnEntityDeleted); EVENT_SUBSCRIBE_MEMBER(m_EComponentDeleted, &Server::OnComponentDeleted); EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &Server::OnPlayerDamage); - + EVENT_SUBSCRIBE_MEMBER(m_EAmmoPickup, &Server::OnAmmoPickup); // BindWW if (port == 0) { port = config->Get("Networking.Port", 27666); @@ -510,6 +510,19 @@ bool Server::OnPlayerDamage(const Events::PlayerDamage& e) return true; } +bool Server::OnAmmoPickup(const Events::AmmoPickup & e) +{ + for (auto& kv : m_ConnectedPlayers) { + if (e.Player.ID == kv.second.EntityID) { + Packet packet(MessageType::AmmoPickup); + // We dont send playerID as it will be set at client to local + packet.WritePrimitive(e.AmmoGain); + m_Reliable.Send(packet, kv.second); + } + } + return true; +} + void Server::parseClientPing() { LOG_INFO("%i: Parsing ping", m_PacketID); @@ -604,12 +617,14 @@ bool Server::shouldSendToClient(EntityWrapper childEntity) auto children = m_World->GetDirectChildren(childEntity.ID); for (auto it = children.first; it != children.second; it++) { EntityWrapper child(m_World, it->second); - if(child.HasComponent("CapturePoint")) { + if (child.HasComponent("CapturePoint") || child.HasComponent("HealthPickup") + || child.HasComponent("AmmoPickup")) { return true; } } return childEntity.HasComponent("Player") || childEntity.FirstParentWithComponent("Player").Valid() - || childEntity.HasComponent("CapturePoint"); + || childEntity.HasComponent("CapturePoint") || childEntity.HasComponent("HealthPickup") + || childEntity.HasComponent("AmmoPickup"); } PlayerID Server::GetPlayerIDFromEndpoint() diff --git a/src/Game/Systems/AmmoPickupSystem.cpp b/src/Game/Systems/AmmoPickupSystem.cpp index 250fa494..5927c495 100644 --- a/src/Game/Systems/AmmoPickupSystem.cpp +++ b/src/Game/Systems/AmmoPickupSystem.cpp @@ -3,37 +3,43 @@ AmmoPickupSystem::AmmoPickupSystem(SystemParams params) : System(params) { - EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &AmmoPickupSystem::OnTriggerTouch); + if (IsServer) { + EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &AmmoPickupSystem::OnTriggerTouch); + } + if (IsClient) { + EVENT_SUBSCRIBE_MEMBER(m_EAmmoPickup, &AmmoPickupSystem::OnAmmoPickup); + } } void AmmoPickupSystem::Update(double dt) { - for (auto it = m_ETriggerTouchVector.begin(); it != m_ETriggerTouchVector.end(); ++it) - { - auto& ammoPickupPosition = *it; - //set the double timer value (value 3) - ammoPickupPosition.DecreaseThisRespawnTimer -= dt; - if (ammoPickupPosition.DecreaseThisRespawnTimer < 0.0) { - //spawn and delete the vector item - auto entityFile = ResourceManager::Load("Schema/Entities/AmmoPickup.xml"); - EntityFileParser parser(entityFile); - EntityID ammoPickupID = parser.MergeEntities(m_World); + if (IsServer) { + for (auto it = m_ETriggerTouchVector.begin(); it != m_ETriggerTouchVector.end(); ++it) { + auto& ammoPickupPosition = *it; + //set the double timer value (value 3) + ammoPickupPosition.DecreaseThisRespawnTimer -= dt; + if (ammoPickupPosition.DecreaseThisRespawnTimer < 0.0) { + //spawn and delete the vector item + auto entityFile = ResourceManager::Load("Schema/Entities/AmmoPickup.xml"); + EntityFileParser parser(entityFile); + EntityID ammoPickupID = parser.MergeEntities(m_World); - //let the world know a pickup has spawned (graphics effects, etc) - Events::PickupSpawned ePickupSpawned; - ePickupSpawned.Pickup = EntityWrapper(m_World, ammoPickupID); - m_EventBroker->Publish(ePickupSpawned); + //let the world know a pickup has spawned (graphics effects, etc) + Events::PickupSpawned ePickupSpawned; + ePickupSpawned.Pickup = EntityWrapper(m_World, ammoPickupID); + m_EventBroker->Publish(ePickupSpawned); - //set values from the old entity to the new entity - auto& newAmmoPickupEntity = EntityWrapper(m_World, ammoPickupID); - newAmmoPickupEntity["Transform"]["Position"] = ammoPickupPosition.Pos; - newAmmoPickupEntity["AmmoPickup"]["AmmoGain"] = ammoPickupPosition.AmmoGain; - newAmmoPickupEntity["AmmoPickup"]["RespawnTimer"] = ammoPickupPosition.RespawnTimer; - m_World->SetParent(newAmmoPickupEntity.ID, ammoPickupPosition.parentID); + //set values from the old entity to the new entity + auto& newAmmoPickupEntity = EntityWrapper(m_World, ammoPickupID); + newAmmoPickupEntity["Transform"]["Position"] = ammoPickupPosition.Pos; + newAmmoPickupEntity["AmmoPickup"]["AmmoGain"] = ammoPickupPosition.AmmoGain; + newAmmoPickupEntity["AmmoPickup"]["RespawnTimer"] = ammoPickupPosition.RespawnTimer; + m_World->SetParent(newAmmoPickupEntity.ID, ammoPickupPosition.parentID); - //erase the current element (AmmoPickupPosition) - m_ETriggerTouchVector.erase(it); - break; + //erase the current element (AmmoPickupPosition) + m_ETriggerTouchVector.erase(it); + break; + } } } } @@ -41,7 +47,11 @@ void AmmoPickupSystem::Update(double dt) bool AmmoPickupSystem::OnTriggerTouch(Events::TriggerTouch& e) { - if (e.Entity != LocalPlayer) { + /*if (e.Entity != LocalPlayer) { + return false; + }*/ + + if (!e.Entity.Valid()) { return false; } //TODO: add other weapontypes @@ -66,7 +76,7 @@ bool AmmoPickupSystem::OnTriggerTouch(Events::TriggerTouch& e) ePlayerAmmoPickup.Player = e.Entity; m_EventBroker->Publish(ePlayerAmmoPickup); //immediately give the player the ammo - currentAmmo = std::min(currentAmmo + ammoGiven, maxWeaponAmmo); + //currentAmmo = std::min(currentAmmo + ammoGiven, maxWeaponAmmo); //copy position, ammogain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object) //we need to copy all values since each value can be different for each ammoPickup @@ -77,3 +87,23 @@ bool AmmoPickupSystem::OnTriggerTouch(Events::TriggerTouch& e) m_World->DeleteEntity(e.Trigger.ID); return true; } + +bool AmmoPickupSystem::OnAmmoPickup(Events::AmmoPickup & e) +{ + if (!e.Player.Valid()) { + return false; + } + //TODO: add other weapontypes + if (!e.Player.HasComponent("AssaultWeapon")) { + return false; + } + int maxWeaponAmmo = (int)e.Player["AssaultWeapon"]["MaxAmmo"]; + int& currentAmmo = (int)e.Player["AssaultWeapon"]["Ammo"]; + //cant pick up ammopacks if you are already at MaxAmmo + if (currentAmmo >= maxWeaponAmmo) { + return false; + } + + currentAmmo = std::min(currentAmmo + e.AmmoGain, maxWeaponAmmo); + return false; +} diff --git a/src/Game/Systems/PickupSpawnSystem.cpp b/src/Game/Systems/PickupSpawnSystem.cpp index abf59007..94fee4c6 100644 --- a/src/Game/Systems/PickupSpawnSystem.cpp +++ b/src/Game/Systems/PickupSpawnSystem.cpp @@ -3,37 +3,40 @@ PickupSpawnSystem::PickupSpawnSystem(SystemParams params) : System(params) { - EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &PickupSpawnSystem::OnTriggerTouch); + if (IsServer) { + EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &PickupSpawnSystem::OnTriggerTouch); + } } void PickupSpawnSystem::Update(double dt) { - for (auto it = m_ETriggerTouchVector.begin(); it != m_ETriggerTouchVector.end(); ++it) - { - auto& healthPickupPosition = *it; - //set the double timer value (value 3) - healthPickupPosition.DecreaseThisRespawnTimer -= dt; - if (healthPickupPosition.DecreaseThisRespawnTimer < 0) { - //spawn and delete the vector item - auto entityFile = ResourceManager::Load("Schema/Entities/HealthPickup.xml"); - EntityFileParser parser(entityFile); - EntityID healthPickupID = parser.MergeEntities(m_World); + if (IsServer) { + for (auto it = m_ETriggerTouchVector.begin(); it != m_ETriggerTouchVector.end(); ++it) { + auto& healthPickupPosition = *it; + //set the double timer value (value 3) + healthPickupPosition.DecreaseThisRespawnTimer -= dt; + if (healthPickupPosition.DecreaseThisRespawnTimer < 0) { + //spawn and delete the vector item + auto entityFile = ResourceManager::Load("Schema/Entities/HealthPickup.xml"); + EntityFileParser parser(entityFile); + EntityID healthPickupID = parser.MergeEntities(m_World); - //let the world know a pickup has spawned (graphics effects, etc) - Events::PickupSpawned ePickupSpawned; - ePickupSpawned.Pickup = EntityWrapper(m_World, healthPickupID); - m_EventBroker->Publish(ePickupSpawned); + //let the world know a pickup has spawned (graphics effects, etc) + Events::PickupSpawned ePickupSpawned; + ePickupSpawned.Pickup = EntityWrapper(m_World, healthPickupID); + m_EventBroker->Publish(ePickupSpawned); - //set values from the old entity to the new entity - auto& newHealthPickupEntity = EntityWrapper(m_World, healthPickupID); - newHealthPickupEntity["Transform"]["Position"] = healthPickupPosition.Pos; - newHealthPickupEntity["HealthPickup"]["HealthGain"] = healthPickupPosition.HealthGain; - newHealthPickupEntity["HealthPickup"]["RespawnTimer"] = healthPickupPosition.RespawnTimer; - m_World->SetParent(newHealthPickupEntity.ID, healthPickupPosition.parentID); + //set values from the old entity to the new entity + auto& newHealthPickupEntity = EntityWrapper(m_World, healthPickupID); + newHealthPickupEntity["Transform"]["Position"] = healthPickupPosition.Pos; + newHealthPickupEntity["HealthPickup"]["HealthGain"] = healthPickupPosition.HealthGain; + newHealthPickupEntity["HealthPickup"]["RespawnTimer"] = healthPickupPosition.RespawnTimer; + m_World->SetParent(newHealthPickupEntity.ID, healthPickupPosition.parentID); - //erase the current element (healthPickupPosition) - m_ETriggerTouchVector.erase(it); - break; + //erase the current element (healthPickupPosition) + m_ETriggerTouchVector.erase(it); + break; + } } } } @@ -58,8 +61,8 @@ bool PickupSpawnSystem::OnTriggerTouch(Events::TriggerTouch& e) //copy position, healthgain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object) //we need to copy all values since each value can be different for each healthPickup - m_ETriggerTouchVector.push_back({ (glm::vec3)e.Trigger["Transform"]["Position"] ,e.Trigger["HealthPickup"]["HealthGain"], - e.Trigger["HealthPickup"]["RespawnTimer"],e.Trigger["HealthPickup"]["RespawnTimer"], m_World->GetParent(e.Trigger.ID) }); + m_ETriggerTouchVector.push_back({ (glm::vec3)e.Trigger["Transform"]["Position"], e.Trigger["HealthPickup"]["HealthGain"], + e.Trigger["HealthPickup"]["RespawnTimer"], e.Trigger["HealthPickup"]["RespawnTimer"], m_World->GetParent(e.Trigger.ID) }); //delete the healthpickup m_World->DeleteEntity(e.Trigger.ID); From f147929aa931adec0ce852e7112482ec50c97a39 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Tue, 1 Mar 2016 17:57:18 +0100 Subject: [PATCH 113/252] Moved the Dash CoolDown (CoolDownTimer) to the component (DashAbility). Fixed 2 warnings --- .../Engine/Input/FirstPersonInputController.h | 17 ++++++++--------- resources/Schema/Components/DashAbility.xml | 1 + resources/Schema/Components/DashAbility.xsd | 5 ++++- src/Game/Systems/PlayerMovementSystem.cpp | 5 +++-- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index 7dc24a2c..d86af088 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -27,7 +27,7 @@ public: virtual bool OnCommand(const Events::InputCommand& e) override; virtual void Reset(); - void AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer); + void AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer, double& assaultDashCoolDownTimer); virtual bool AssaultDashDoubleTapped() const { return m_AssaultDashDoubleTapped; } virtual bool PlayerIsDashing() const { return m_PlayerIsDashing; } @@ -41,7 +41,6 @@ protected: bool m_Crouching = false; //assault dash membervariables - needed to calculate the doubletap- and dashlogic double m_AssaultDashDoubleTapDeltaTime = 0.0; - double m_AssaultDashCoolDownTimer = 0.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; @@ -191,21 +190,21 @@ bool FirstPersonInputController::OnLockMouse(const Events::LockMou } template -void FirstPersonInputController::AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer) { +void FirstPersonInputController::AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer, double& assaultDashCoolDownTimer) { m_AssaultDashDoubleTapDeltaTime += dt; - m_AssaultDashCoolDownTimer -= dt; + assaultDashCoolDownTimer -= dt; //cooldown = assaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work) - if (m_AssaultDashCoolDownTimer > (assaultDashCoolDownMaxTimer - 0.25f)) { + if (assaultDashCoolDownTimer > (assaultDashCoolDownMaxTimer - 0.25f)) { m_PlayerIsDashing = true; } else { m_PlayerIsDashing = false; } //dashing with shift - if (m_ShiftDashing && m_AssaultDashCoolDownTimer <= 0.0f) { + if (m_ShiftDashing && assaultDashCoolDownTimer <= 0.0f) { //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 = assaultDashCoolDownMaxTimer; + assaultDashCoolDownTimer = assaultDashCoolDownMaxTimer; m_AssaultDashDoubleTapped = true; m_AssaultDashDoubleTapDeltaTime = 0.f; return; @@ -227,7 +226,7 @@ void FirstPersonInputController::AssaultDashCheck(double dt, bool } m_ValidDoubleTap = false; - if (!(m_AssaultDashCoolDownTimer <= 0.0f)) { + if (!(assaultDashCoolDownTimer <= 0.0f)) { //if we cant dash at the moment, then just reset the tap-sensitivity-timer m_AssaultDashDoubleTapDeltaTime = 0.f; return; @@ -235,7 +234,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 = assaultDashCoolDownMaxTimer; + assaultDashCoolDownTimer = assaultDashCoolDownMaxTimer; Events::DashAbility e; m_EventBroker->Publish(e); diff --git a/resources/Schema/Components/DashAbility.xml b/resources/Schema/Components/DashAbility.xml index a313c447..a71e4e52 100644 --- a/resources/Schema/Components/DashAbility.xml +++ b/resources/Schema/Components/DashAbility.xml @@ -1,4 +1,5 @@ 2.0 + 0.0 \ No newline at end of file diff --git a/resources/Schema/Components/DashAbility.xsd b/resources/Schema/Components/DashAbility.xsd index 4273cc71..6fc59c77 100644 --- a/resources/Schema/Components/DashAbility.xsd +++ b/resources/Schema/Components/DashAbility.xsd @@ -10,7 +10,10 @@ - This is the cooldown on dash + This is the max cooldown on dash + + + This is the current cooldown on dash diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index b9ce23d4..47612ca0 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -48,7 +48,7 @@ void PlayerMovementSystem::updateMovementControllers(double dt) EntityWrapper playerModel = player.FirstChildByName("PlayerModel"); if (playerModel.Valid()) { ComponentWrapper cAnimationOffset = playerModel["AnimationOffset"]; - float pitch = cameraOrientation.x + 0.2; + float pitch = cameraOrientation.x + 0.2f; double time = (pitch + glm::half_pi()) / glm::pi(); cAnimationOffset["Time"] = time; } @@ -66,7 +66,7 @@ void PlayerMovementSystem::updateMovementControllers(double dt) ComponentWrapper cPhysics = player["Physics"]; //Assault Dash Check if (player.HasComponent("DashAbility")) { - controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f, player["DashAbility"]["CoolDownMaxTimer"]); + controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f, player["DashAbility"]["CoolDownMaxTimer"], player["DashAbility"]["CoolDownTimer"]); } wishDirection = controller->Movement() * glm::inverse(glm::quat(ori)); //this makes sure you can only dash in the 4 directions: forw,backw,left,right @@ -311,6 +311,7 @@ bool PlayerMovementSystem::OnDoubleJump(Events::DoubleJump & e) return false; } spawnHexagon(EntityWrapper(m_World, e.entityID)); + return true; } void PlayerMovementSystem::spawnHexagon(EntityWrapper target) From 1ae2f3f5f35e16d8cebf00421354a9eb0f3cb227 Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Tue, 1 Mar 2016 19:10:13 +0100 Subject: [PATCH 114/252] Begin clean-up --- include/Engine/Rendering/DirectionalLightJob.h | 1 - include/Engine/Rendering/FrameBuffer.h | 14 -------------- include/Engine/Rendering/ShadowPass.h | 2 +- resources/Schema/Components/DirectionalLight.xml | 1 - resources/Schema/Components/DirectionalLight.xsd | 1 - src/Engine/Rendering/FrameBuffer.cpp | 15 --------------- src/Engine/Rendering/ShadowPass.cpp | 2 +- 7 files changed, 2 insertions(+), 34 deletions(-) diff --git a/include/Engine/Rendering/DirectionalLightJob.h b/include/Engine/Rendering/DirectionalLightJob.h index 65d477d1..96b2ec9c 100644 --- a/include/Engine/Rendering/DirectionalLightJob.h +++ b/include/Engine/Rendering/DirectionalLightJob.h @@ -19,7 +19,6 @@ struct DirectionalLightJob : RenderJob Direction = glm::vec4(0,0,-1,0) * glm::inverse(Orientation); Color = (glm::vec4)directionalLightComponent["Color"]; Intensity = (double)directionalLightComponent["Intensity"]; - //TextureAlphaShadows = (bool)directionalLightComponent["TextureAlphaShadows"]; }; glm::quat Orientation; diff --git a/include/Engine/Rendering/FrameBuffer.h b/include/Engine/Rendering/FrameBuffer.h index 325fbe3b..cf63b6c6 100644 --- a/include/Engine/Rendering/FrameBuffer.h +++ b/include/Engine/Rendering/FrameBuffer.h @@ -8,12 +8,10 @@ class BufferResource { public: BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment); - BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment, GLuint layers); GLuint* m_ResourceHandle; GLenum m_ResourceType; GLenum m_Attachment; - GLuint m_Layers; private: }; @@ -24,9 +22,6 @@ class ResourceType : public BufferResource public: ResourceType(GLuint* resourceHandle, GLenum attachment) : BufferResource(resourceHandle, RESOURCETYPE, attachment) { } - - ResourceType(GLuint* resourceHandle, GLenum attachment, GLuint layers) - : BufferResource(resourceHandle, RESOURCETYPE, attachment, layers) { } }; class Texture2D : public ResourceType @@ -48,15 +43,6 @@ public: ~RenderBuffer(); }; -class Texture2DArray : public ResourceType -{ -public: - Texture2DArray(GLuint* resourceHandle, GLenum attachment, GLuint layers) - : ResourceType(resourceHandle, attachment, layers) { }; - - ~Texture2DArray(); -}; - class FrameBuffer { public: diff --git a/include/Engine/Rendering/ShadowPass.h b/include/Engine/Rendering/ShadowPass.h index 3f506cb7..372ba6f2 100644 --- a/include/Engine/Rendering/ShadowPass.h +++ b/include/Engine/Rendering/ShadowPass.h @@ -41,7 +41,7 @@ public: GLuint DepthMap() const { return m_DepthMap; } std::array LightP() const { return m_LightProjection; } std::array LightV() const { return m_LightView; } - std::array FarDistance() const { return{ m_shadowFrusta[0].FarClip, m_shadowFrusta[1].FarClip, m_shadowFrusta[2].FarClip, m_shadowFrusta[3].FarClip }; } + std::array FarDistance() const { std::array f; for (int i = 0; i < MAX_SPLITS; i++) f[i] = m_shadowFrusta[i].FarClip; return f; } int CurrentNrOfSplits() const { return m_CurrentNrOfSplits; } void SetSplitWeight(float split_weight) { m_SplitWeight = split_weight; }; diff --git a/resources/Schema/Components/DirectionalLight.xml b/resources/Schema/Components/DirectionalLight.xml index a4b22985..7f777ef8 100644 --- a/resources/Schema/Components/DirectionalLight.xml +++ b/resources/Schema/Components/DirectionalLight.xml @@ -2,6 +2,5 @@ 0.8 - true \ No newline at end of file diff --git a/resources/Schema/Components/DirectionalLight.xsd b/resources/Schema/Components/DirectionalLight.xsd index 692d9677..a14248a8 100644 --- a/resources/Schema/Components/DirectionalLight.xsd +++ b/resources/Schema/Components/DirectionalLight.xsd @@ -9,7 +9,6 @@ - diff --git a/src/Engine/Rendering/FrameBuffer.cpp b/src/Engine/Rendering/FrameBuffer.cpp index 167de142..7c86a7e2 100644 --- a/src/Engine/Rendering/FrameBuffer.cpp +++ b/src/Engine/Rendering/FrameBuffer.cpp @@ -9,14 +9,6 @@ BufferResource::BufferResource(GLuint* resourceHandle, GLenum resourceType, GLen m_Attachment = attachment; } -BufferResource::BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment, GLuint layers) -{ - m_ResourceHandle = resourceHandle; - m_ResourceType = resourceType; - m_Attachment = attachment; - m_Layers = layers; -} - Texture2D::~Texture2D() { if (m_ResourceHandle != 0) { @@ -24,13 +16,6 @@ Texture2D::~Texture2D() } } -Texture2DArray::~Texture2DArray() -{ - if (m_ResourceHandle != 0) { - glDeleteTextures(1, m_ResourceHandle); - } -} - RenderBuffer::~RenderBuffer() { if (m_ResourceHandle != 0) { diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index 7b45e31a..d7741dff 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -133,7 +133,7 @@ void ShadowPass::InitializeFrameBuffers() glTexParameterfv(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_BORDER_COLOR, glm::vec4(1.f).data); glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); - m_DepthBuffer.AddResource(std::shared_ptr(new Texture2DArray(&m_DepthMap, GL_DEPTH_ATTACHMENT, m_CurrentNrOfSplits))); + m_DepthBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthMap, GL_DEPTH_ATTACHMENT))); m_DepthBuffer.Generate(); GLERROR("depthMap failed END"); From 6281e200005fb311687a517d19c14cc8e5b6bee1 Mon Sep 17 00:00:00 2001 From: Tleety Date: Tue, 1 Mar 2016 20:31:09 +0100 Subject: [PATCH 115/252] Arrow should now track the CapturePoint specified in the Component. --- .../Game/Systems/CapturePointArrowHUDSystem.h | 3 + include/Game/Systems/CapturePointHUDSystem.h | 2 +- resources/Schema/Entities/PlayerRed.xml | 58 ++++--- .../Schema/Entities/QualityAssurance.xml | 154 +++++++++++++----- .../Systems/CapturePointArrowHUDSystem.cpp | 105 +++++++++++- 5 files changed, 261 insertions(+), 61 deletions(-) diff --git a/include/Game/Systems/CapturePointArrowHUDSystem.h b/include/Game/Systems/CapturePointArrowHUDSystem.h index 30406c3c..4c197f02 100644 --- a/include/Game/Systems/CapturePointArrowHUDSystem.h +++ b/include/Game/Systems/CapturePointArrowHUDSystem.h @@ -3,9 +3,12 @@ #include #include +#include #include "Common.h" #include "Core/System.h" +#include "Core/Transform.h" + class CapturePointArrowHUDSystem : public ImpureSystem { diff --git a/include/Game/Systems/CapturePointHUDSystem.h b/include/Game/Systems/CapturePointHUDSystem.h index 41db0c12..53ca9b73 100644 --- a/include/Game/Systems/CapturePointHUDSystem.h +++ b/include/Game/Systems/CapturePointHUDSystem.h @@ -7,7 +7,7 @@ #include "Common.h" #include "Core/System.h" -#include "Engine/Collision/ETrigger.h" +#include "Collision/ETrigger.h" class CapturePointHUDSystem : public ImpureSystem { diff --git a/resources/Schema/Entities/PlayerRed.xml b/resources/Schema/Entities/PlayerRed.xml index 3cf17558..8982f58d 100644 --- a/resources/Schema/Entities/PlayerRed.xml +++ b/resources/Schema/Entities/PlayerRed.xml @@ -13,7 +13,7 @@ - 1.6944730461160304 + 326.69883589440087 @@ -30,7 +30,7 @@ - + @@ -193,7 +193,6 @@ 3 - 0.80222018197612788 @@ -228,6 +227,7 @@ 4 + 1 @@ -283,7 +283,7 @@ Textures/Core/UnitHexagon.png - + @@ -294,7 +294,8 @@ - + 1 + Textures/Core/UnitHexagon_Rotated.png @@ -303,7 +304,7 @@ - + @@ -372,7 +373,7 @@ Idle - 0.67172915251515519 + 0.20909021680133577 1 @@ -386,30 +387,44 @@ + + DefenderWeapon + Schema/Entities/DefenderWeaponViewRed.xml - - DefenderWeapon - + + AssaultWeapon + Schema/Entities/AssaultWeaponView.xml - - AssaultWeapon - + + + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + @@ -430,6 +445,7 @@ Idle + 0.22069183859343156 1 @@ -449,31 +465,31 @@ - - Schema/Entities/DefenderWeaponWorldRed.xml - - DefenderWeapon + + Schema/Entities/DefenderWeaponWorldRed.xml + + - - Schema/Entities/AssaultWeaponWorld.xml - - AssaultWeapon + + Schema/Entities/AssaultWeaponWorld.xml + + diff --git a/resources/Schema/Entities/QualityAssurance.xml b/resources/Schema/Entities/QualityAssurance.xml index 0aa2fbe7..04cc288a 100644 --- a/resources/Schema/Entities/QualityAssurance.xml +++ b/resources/Schema/Entities/QualityAssurance.xml @@ -2,6 +2,9 @@ + + 4.7473226580121377 + @@ -40,7 +43,7 @@ - + @@ -81,19 +84,19 @@ + + 1 + + 0.80000001192092896 Models/Widgets/Lights/DirectionalLightWidget.mesh - - 1 - - - + @@ -108,7 +111,11 @@ - + + + + + Models/Characters/Assault/AssaultAnimated.mesh @@ -120,7 +127,11 @@ - + + + + + Models/Characters/Assault/AssaultAnimated.mesh @@ -168,13 +179,17 @@ - + - + + + + + Models/Characters/Assault/AssaultAnimated.mesh @@ -213,7 +228,7 @@ - + @@ -277,7 +292,7 @@ - + @@ -309,7 +324,7 @@ - + @@ -659,7 +674,7 @@ - + @@ -706,7 +721,7 @@ - + @@ -766,7 +781,7 @@ - + @@ -813,7 +828,7 @@ - + @@ -859,7 +874,7 @@ - + @@ -906,7 +921,7 @@ - + @@ -953,7 +968,7 @@ - + @@ -1013,6 +1028,7 @@ 15 + Models/Core/UnitCube.mesh @@ -1027,7 +1043,6 @@ - @@ -1063,6 +1078,7 @@ 1 + Models/Core/UnitCube.mesh @@ -1073,7 +1089,6 @@ - @@ -1107,6 +1122,7 @@ 2 + Models/Core/UnitCube.mesh @@ -1117,7 +1133,6 @@ - @@ -1153,6 +1168,7 @@ 3 + Models/Core/UnitCube.mesh @@ -1163,7 +1179,6 @@ - @@ -1203,6 +1218,7 @@ -15 4 + Models/Core/UnitCube.mesh @@ -1217,7 +1233,6 @@ - @@ -1367,7 +1382,7 @@ - + @@ -1376,7 +1391,7 @@ true - 0.8256214817261025 + 2.5396116058983438 3.7999999523162842 true @@ -1423,7 +1438,7 @@ - + @@ -1432,7 +1447,7 @@ - 1.8641349174045843 + 1.5396208215609732 Models/Characters/Assault/AssaultTPose.mesh @@ -1475,18 +1490,22 @@ - + - + + + + + true - 1.8641349174045843 + 1.5396208215609732 true @@ -1531,7 +1550,7 @@ - + @@ -1541,7 +1560,7 @@ true - 1.2301962937648341 + 4.4522528839264339 10 3 @@ -1589,7 +1608,7 @@ - + @@ -1599,7 +1618,7 @@ true - 3.4214855659573402 + 3.2362842141074992 true 5 true @@ -1690,6 +1709,7 @@ 5 + @@ -1712,6 +1732,7 @@ + Fonts/DroidSans.ttf,100 @@ -1780,7 +1801,7 @@ true - 0.8256214817261025 + 2.5396116058983438 3.7999999523162842 true @@ -1823,7 +1844,11 @@ - + + + + + @@ -1925,6 +1950,7 @@ Textures/Props/FoliageDiff.png + @@ -1934,6 +1960,7 @@ Textures/Props/FoliageDiff.png + @@ -1954,6 +1981,7 @@ Textures/Core/UnitHexagon.png + @@ -1971,6 +1999,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -1986,6 +2015,7 @@ Textures/Core/UnitHexagon.png + @@ -2003,6 +2033,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -2018,6 +2049,7 @@ Textures/Core/UnitHexagon.png + @@ -2036,6 +2068,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -2051,6 +2084,7 @@ Textures/Core/UnitHexagon.png + @@ -2068,6 +2102,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -2083,6 +2118,7 @@ Textures/Core/UnitHexagon.png + @@ -2099,6 +2135,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -2167,6 +2204,7 @@ Textures/Core/ErrorTexture.png + @@ -2178,6 +2216,7 @@ Textures/Core/White.png + @@ -2206,6 +2245,7 @@ Textures/Core/White.png + @@ -2234,6 +2274,7 @@ Textures/Core/White.png + @@ -2262,6 +2303,7 @@ Textures/Core/White.png + @@ -2290,6 +2332,7 @@ Textures/Core/White.png + @@ -2331,6 +2374,7 @@ Textures/Core/ErrorTexture.png + @@ -2342,6 +2386,7 @@ Textures/Core/White.png + @@ -2370,6 +2415,7 @@ Textures/Core/White.png + @@ -2398,6 +2444,7 @@ Textures/Core/White.png + @@ -2426,6 +2473,7 @@ Textures/Core/White.png + @@ -2482,6 +2530,36 @@ + + + + + + + + + + + + 2 + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + + + + + + + diff --git a/src/Game/Systems/CapturePointArrowHUDSystem.cpp b/src/Game/Systems/CapturePointArrowHUDSystem.cpp index e621d90d..92c6ec0a 100644 --- a/src/Game/Systems/CapturePointArrowHUDSystem.cpp +++ b/src/Game/Systems/CapturePointArrowHUDSystem.cpp @@ -9,5 +9,108 @@ CapturePointArrowHUDSystem::CapturePointArrowHUDSystem(SystemParams params) void CapturePointArrowHUDSystem::Update(double dt) { - //Logic here + + bool LoadCheck = true; + int redTeam; + int blueTeam; + int spectatorTeam; + + //Get list for all CapturePointArrowHUDComponents + auto ArrowHUDs = m_World->GetComponents("CapturePointArrowHUD"); + auto CapturePoints = m_World->GetComponents("CapturePoint"); + if(ArrowHUDs == nullptr) { + return; + } + + for(auto& cArrowHUD : *ArrowHUDs) { + //Get what team the current arrow corresponds to + EntityWrapper ArrowEntity = EntityWrapper(m_World, cArrowHUD.EntityID); + EntityWrapper teamEntity = ArrowEntity.FirstParentWithComponent("Team"); + if (!teamEntity.Valid()) { + continue; + } + auto cTeam = teamEntity["Team"]; + int currentTeam = (int)cTeam["Team"]; + + if (LoadCheck) { + redTeam = (int)cTeam["Team"].Enum("Red"); + blueTeam = (int)cTeam["Team"].Enum("Blue"); + spectatorTeam = (int)cTeam["Team"].Enum("Spectator"); + LoadCheck = false; + } + + //if red team, get red team next point, otherwise blue team next point. + //Untill this is awailable we will just use the hardcoded value in the component. + //This will also give us a position, so we wont need to loop through all capturePoints. + glm::vec3 pos; + int target = cArrowHUD["CurrentTarget"]; + for(auto& cCP : *CapturePoints) { + if((int)cCP["CapturePointNumber"] == target) { + EntityWrapper CPEntity = EntityWrapper(m_World, cCP.EntityID); + pos = Transform::AbsolutePosition(CPEntity); + break; + } + } + glm::vec3& arrowOri = ArrowEntity["Transform"]["Orientation"]; + glm::vec3 lookVector = glm::normalize(Transform::AbsolutePosition(ArrowEntity) - pos); //Maybe should be player instead + float pitch = std::asin(-lookVector.y); + float yaw = std::atan2(lookVector.x, lookVector.z); + arrowOri.x = pitch; + arrowOri.y = yaw; + arrowOri.z = 0.f; + EntityWrapper parent = ArrowEntity.Parent(); + if (parent.Valid()) { + arrowOri -= Transform::AbsoluteOrientationEuler(parent); + } + } + + /* + bool LoadCheck = true; + int redTeam; + int blueTeam; + int spectatorTeam; + + auto CapturePointHUDElements = m_World->GetComponents("CapturePointHUD"); + auto CapturePoints = m_World->GetComponents("CapturePoint"); + if (CapturePointHUDElements == nullptr) { + return; + } + + if (!CapturePointHUDElements) { + return; + } + + for (auto& cCapturePointHUD : *CapturePointHUDElements) { + int HUD_ID = cCapturePointHUD["CapturePointNumber"]; + EntityWrapper entityHUD = EntityWrapper(m_World, cCapturePointHUD.EntityID); + EntityWrapper entityHUDparent = entityHUD.Parent(); + + for (auto& cCapturePoint : *CapturePoints) { + EntityWrapper entityCP = EntityWrapper(m_World, cCapturePoint.EntityID); + + //Check if the HUD corresponds to the Capture Point Number + if (HUD_ID == (int)entityCP["CapturePoint"]["CapturePointNumber"]) { + ComponentWrapper& teamComponent = entityCP["Team"]; + if (LoadCheck) { + redTeam = (int)teamComponent["Team"].Enum("Red"); + blueTeam = (int)teamComponent["Team"].Enum("Blue"); + spectatorTeam = (int)teamComponent["Team"].Enum("Spectator"); + LoadCheck = false; + } + //Color hud with team color + auto capturePointTeam = (int)teamComponent["Team"]; + entityHUDparent["Sprite"]["Color"] = capturePointTeam == blueTeam ? glm::vec4(0, 0.2f, 1, 0.7f) : capturePointTeam == redTeam ? glm::vec4(1, 0.0f, 0, 0.7f) : glm::vec4(1, 1, 1, 0.3f); + + //Progress is scaled with time + double currentCaptureTime = (double)entityCP["CapturePoint"]["CaptureTimer"]; + double progress = glm::abs(currentCaptureTime)/15.0; + int currentCapturingTeam = currentCaptureTime > 0 ? redTeam : currentCaptureTime < 0 ? blueTeam : spectatorTeam; + ((glm::vec3&)entityHUD["Transform"]["Orientation"]).z = currentCapturingTeam == redTeam ? glm::half_pi()+glm::pi() : glm::half_pi(); + glm::vec4 fillColor = currentCapturingTeam == redTeam ? glm::vec4(1, 0.f, 0, 0.7f) : glm::vec4(0, 0.2f, 1, 0.7f); + entityHUD["Fill"]["Color"] = fillColor; + entityHUD["Fill"]["Percentage"] = progress; + } + } + } + */ } \ No newline at end of file From ab40fa715b8d47681ab58561c95b4aa02bf94391 Mon Sep 17 00:00:00 2001 From: Tleety Date: Tue, 1 Mar 2016 21:57:30 +0100 Subject: [PATCH 116/252] The arrow should now track CapturePoints correctly at start and when they are captured. --- .../Game/Systems/CapturePointArrowHUDSystem.h | 7 + .../Systems/CapturePointArrowHUDSystem.cpp | 131 ++++++++++-------- 2 files changed, 82 insertions(+), 56 deletions(-) diff --git a/include/Game/Systems/CapturePointArrowHUDSystem.h b/include/Game/Systems/CapturePointArrowHUDSystem.h index 4c197f02..26462879 100644 --- a/include/Game/Systems/CapturePointArrowHUDSystem.h +++ b/include/Game/Systems/CapturePointArrowHUDSystem.h @@ -8,6 +8,7 @@ #include "Common.h" #include "Core/System.h" #include "Core/Transform.h" +#include "Core/ECaptured.h" class CapturePointArrowHUDSystem : public ImpureSystem @@ -18,6 +19,12 @@ public: virtual void Update(double dt) override; private: + EventRelay m_ECapturedEvent; + bool OnCapturePointCaptured(Events::Captured& e); + + bool m_InitialtargetsSet = false; + glm::vec3 m_RedTeamCurrentTarget; + glm::vec3 m_BlueTeamCurrentTarget; }; #endif \ No newline at end of file diff --git a/src/Game/Systems/CapturePointArrowHUDSystem.cpp b/src/Game/Systems/CapturePointArrowHUDSystem.cpp index 92c6ec0a..ee2254c7 100644 --- a/src/Game/Systems/CapturePointArrowHUDSystem.cpp +++ b/src/Game/Systems/CapturePointArrowHUDSystem.cpp @@ -4,12 +4,12 @@ CapturePointArrowHUDSystem::CapturePointArrowHUDSystem(SystemParams params) : System(params) , ImpureSystem() { + EVENT_SUBSCRIBE_MEMBER(m_ECapturedEvent, &CapturePointArrowHUDSystem::OnCapturePointCaptured); } void CapturePointArrowHUDSystem::Update(double dt) { - bool LoadCheck = true; int redTeam; int blueTeam; @@ -25,11 +25,13 @@ void CapturePointArrowHUDSystem::Update(double dt) for(auto& cArrowHUD : *ArrowHUDs) { //Get what team the current arrow corresponds to EntityWrapper ArrowEntity = EntityWrapper(m_World, cArrowHUD.EntityID); - EntityWrapper teamEntity = ArrowEntity.FirstParentWithComponent("Team"); - if (!teamEntity.Valid()) { + if (!ArrowEntity.Valid()) { continue; } - auto cTeam = teamEntity["Team"]; + if(!ArrowEntity.HasComponent("Team")) { + continue; + } + auto cTeam = ArrowEntity["Team"]; int currentTeam = (int)cTeam["Team"]; if (LoadCheck) { @@ -37,20 +39,60 @@ void CapturePointArrowHUDSystem::Update(double dt) blueTeam = (int)cTeam["Team"].Enum("Blue"); spectatorTeam = (int)cTeam["Team"].Enum("Spectator"); LoadCheck = false; + + + if (!m_InitialtargetsSet) { + glm::vec3 target1, target2; + EntityWrapper home1, home2; + + for (auto& cCP : *CapturePoints) { + auto homePointTeam = (int)cCP["HomePointForTeam"]; + auto CPID = (int)cCP["CapturePointNumber"]; + + if(CPID == 0) { + //Home point for one team + home1 = EntityWrapper(m_World, cCP.EntityID); + } else if (CPID == 1) { + //First target for one team, so save it for later use. + target1 = Transform::AbsolutePosition(EntityWrapper(m_World, cCP.EntityID)); + } else if (CPID == 3) { + //First target for one team, so save it for later use. + target2 = Transform::AbsolutePosition(EntityWrapper(m_World, cCP.EntityID)); + } else if (CPID == 4) { + //Home point for one team + home2 = EntityWrapper(m_World, cCP.EntityID); + } + } + //Check what team is the owner of Home1 and set their target to the next capturepoint + if((int)home1["CapturePoint"]["HomePointForTeam"] == redTeam) { + m_RedTeamCurrentTarget = target1; + } else if ((int)home1["CapturePoint"]["HomePointForTeam"] == blueTeam) { + m_BlueTeamCurrentTarget = target1; + } + + //Check what team is the owner of Home2 and set their target to the next capturepoint + if ((int)home2["CapturePoint"]["HomePointForTeam"] == redTeam) { + m_RedTeamCurrentTarget = target2; + } else if ((int)home2["CapturePoint"]["HomePointForTeam"] == blueTeam) { + m_BlueTeamCurrentTarget = target2; + } + } + + } //if red team, get red team next point, otherwise blue team next point. //Untill this is awailable we will just use the hardcoded value in the component. //This will also give us a position, so we wont need to loop through all capturePoints. glm::vec3 pos; - int target = cArrowHUD["CurrentTarget"]; - for(auto& cCP : *CapturePoints) { - if((int)cCP["CapturePointNumber"] == target) { - EntityWrapper CPEntity = EntityWrapper(m_World, cCP.EntityID); - pos = Transform::AbsolutePosition(CPEntity); - break; - } + if(currentTeam == redTeam) { + pos = m_RedTeamCurrentTarget; + } else if (currentTeam == blueTeam) { + pos = m_BlueTeamCurrentTarget; } + + pos = currentTeam == redTeam ? m_RedTeamCurrentTarget : currentTeam == blueTeam ? m_BlueTeamCurrentTarget : glm::vec3(0.f); + glm::vec3& arrowOri = ArrowEntity["Transform"]["Orientation"]; glm::vec3 lookVector = glm::normalize(Transform::AbsolutePosition(ArrowEntity) - pos); //Maybe should be player instead float pitch = std::asin(-lookVector.y); @@ -63,54 +105,31 @@ void CapturePointArrowHUDSystem::Update(double dt) arrowOri -= Transform::AbsoluteOrientationEuler(parent); } } +} - /* - bool LoadCheck = true; - int redTeam; - int blueTeam; - int spectatorTeam; - - auto CapturePointHUDElements = m_World->GetComponents("CapturePointHUD"); - auto CapturePoints = m_World->GetComponents("CapturePoint"); - if (CapturePointHUDElements == nullptr) { - return; +bool CapturePointArrowHUDSystem::OnCapturePointCaptured(Events::Captured& e) +{ + if (!e.NextCapturePoint.HasComponent("Team")) + { + return 0; } - if (!CapturePointHUDElements) { - return; + auto cTeam = e.NextCapturePoint["Team"]; + + int redTeam = (int)cTeam["Team"].Enum("Red"); + int blueTeam = (int)cTeam["Team"].Enum("Blue"); + int spectatorTeam = (int)cTeam["Team"].Enum("Spectator"); + int target = -1; + + if (e.NextCapturePoint.HasComponent("CapturePoint")) { + target = (int)e.NextCapturePoint["CapturePoint"]["CapturePointNumber"]; + } else { + return 0; } - for (auto& cCapturePointHUD : *CapturePointHUDElements) { - int HUD_ID = cCapturePointHUD["CapturePointNumber"]; - EntityWrapper entityHUD = EntityWrapper(m_World, cCapturePointHUD.EntityID); - EntityWrapper entityHUDparent = entityHUD.Parent(); - - for (auto& cCapturePoint : *CapturePoints) { - EntityWrapper entityCP = EntityWrapper(m_World, cCapturePoint.EntityID); - - //Check if the HUD corresponds to the Capture Point Number - if (HUD_ID == (int)entityCP["CapturePoint"]["CapturePointNumber"]) { - ComponentWrapper& teamComponent = entityCP["Team"]; - if (LoadCheck) { - redTeam = (int)teamComponent["Team"].Enum("Red"); - blueTeam = (int)teamComponent["Team"].Enum("Blue"); - spectatorTeam = (int)teamComponent["Team"].Enum("Spectator"); - LoadCheck = false; - } - //Color hud with team color - auto capturePointTeam = (int)teamComponent["Team"]; - entityHUDparent["Sprite"]["Color"] = capturePointTeam == blueTeam ? glm::vec4(0, 0.2f, 1, 0.7f) : capturePointTeam == redTeam ? glm::vec4(1, 0.0f, 0, 0.7f) : glm::vec4(1, 1, 1, 0.3f); - - //Progress is scaled with time - double currentCaptureTime = (double)entityCP["CapturePoint"]["CaptureTimer"]; - double progress = glm::abs(currentCaptureTime)/15.0; - int currentCapturingTeam = currentCaptureTime > 0 ? redTeam : currentCaptureTime < 0 ? blueTeam : spectatorTeam; - ((glm::vec3&)entityHUD["Transform"]["Orientation"]).z = currentCapturingTeam == redTeam ? glm::half_pi()+glm::pi() : glm::half_pi(); - glm::vec4 fillColor = currentCapturingTeam == redTeam ? glm::vec4(1, 0.f, 0, 0.7f) : glm::vec4(0, 0.2f, 1, 0.7f); - entityHUD["Fill"]["Color"] = fillColor; - entityHUD["Fill"]["Percentage"] = progress; - } - } + if(e.TeamNumberThatCapturedCapturePoint == redTeam) { + m_RedTeamCurrentTarget = Transform::AbsolutePosition(e.NextCapturePoint); + } else if (e.TeamNumberThatCapturedCapturePoint == blueTeam) { + m_BlueTeamCurrentTarget = Transform::AbsolutePosition(e.NextCapturePoint);; } - */ -} \ No newline at end of file +} From 6eb0b83d6be486f9363dd9f89469c28e97068bce Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Tue, 1 Mar 2016 22:46:19 +0100 Subject: [PATCH 117/252] Fixed editor camera speed changing when scrolling on UI elements --- include/Engine/Editor/EditorCameraInputController.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/Engine/Editor/EditorCameraInputController.h b/include/Engine/Editor/EditorCameraInputController.h index 4c139e01..6cb31d99 100644 --- a/include/Engine/Editor/EditorCameraInputController.h +++ b/include/Engine/Editor/EditorCameraInputController.h @@ -104,6 +104,11 @@ protected: if (!m_Enabled) { return false; } + + ImGuiIO& io = ImGui::GetIO(); + if (io.WantCaptureMouse || io.WantCaptureKeyboard) { + return false; + } m_SpeedMultiplier += e.DeltaY * (0.1 * m_SpeedMultiplier); m_Config->Set("Editor.CameraSpeed", m_SpeedMultiplier); From 799990f44dbfd50b04a074d54d9c078efa49fb9a Mon Sep 17 00:00:00 2001 From: Tleety Date: Tue, 1 Mar 2016 22:54:13 +0100 Subject: [PATCH 118/252] Next CP indicator should now be fully working. --- assets | 2 +- resources/Schema/Entities/NewMap2version2.xml | 4690 +++++++++++++++++ .../Schema/Entities/NewMap2version3NEW.xml | 4612 ++++++++++++++++ resources/Schema/Entities/Player.xml | 61 +- resources/Schema/Entities/PlayerRed.xml | 9 +- .../Systems/CapturePointArrowHUDSystem.cpp | 8 +- 6 files changed, 9354 insertions(+), 28 deletions(-) create mode 100644 resources/Schema/Entities/NewMap2version2.xml create mode 100644 resources/Schema/Entities/NewMap2version3NEW.xml diff --git a/assets b/assets index 10a61165..72530423 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 10a611659ddaadfea6a560e707d395834855a979 +Subproject commit 72530423ad3744341f42cbfdcba18295a2cfac90 diff --git a/resources/Schema/Entities/NewMap2version2.xml b/resources/Schema/Entities/NewMap2version2.xml new file mode 100644 index 00000000..fcb81666 --- /dev/null +++ b/resources/Schema/Entities/NewMap2version2.xml @@ -0,0 +1,4690 @@ + + + + + + + + + + + + + + + + + + Models/Props/GroundTest.mesh + + + + + + + + + Models/Props/Walls/SciFiWallTop.mesh + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + true + + + + + + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall1.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall2.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallSmall3.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall4.mesh + + + + + + + + + + + + Models/Props/Highground1.mesh + + + + + + + + + + Models/Props/Highground2.mesh + + + + + + + + + + + Models/Props/Highground3.mesh + + + + + + + + + + + Models/Props/Highground4.mesh + + + + + + + + + + + Models/Props/Highground5.mesh + + + + + + + + + + Models/Props/Highground6.mesh + + + + + + + + + + + Models/Props/Highground7.mesh + + + + + + + + + + + + + Models/Props/Highground8.mesh + + + + + + + + + + + + + Models/Props/Highground9.mesh + + + + + + + + + + + + + Models/Props/Highground10.mesh + + + + + + + + + + + + + Models/Props/Highground6.mesh + + + + + + + + + + + + + Models/Props/Highground1.mesh + + + + + + + + + + + + Models/Props/Highground2.mesh + + + + + + + + + + + + + Models/Props/Highground3.mesh + + + + + + + + + + + + + Models/Props/Highground4.mesh + + + + + + + + + + + + + Models/Props/Highground5.mesh + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar3Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar3Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 5 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + 4 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + + 3 + + + + + + + + + + + + 2 + 1 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 5 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + 4 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + + 3 + + + + + + + + + + + + 2 + 1 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 8 + + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointBlue.mesh + + + + + + + + + + + + + 4 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 3 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 2 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 1 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointRed.mesh + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + + 10 + + + + + + + + + + + 1 + false + + + + + + + + + + + + 10 + + + + + + + + + + + + + + Schema/Entities/PlayerRed.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + diff --git a/resources/Schema/Entities/NewMap2version3NEW.xml b/resources/Schema/Entities/NewMap2version3NEW.xml new file mode 100644 index 00000000..d24675cd --- /dev/null +++ b/resources/Schema/Entities/NewMap2version3NEW.xml @@ -0,0 +1,4612 @@ + + + + + + + + + + + + + + + + + + Models/Props/GroundTest.mesh + + + + + + + + + Models/Props/Walls/SciFiWallTop.mesh + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + true + + + + + + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall1.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall2.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallSmall3.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall4.mesh + + + + + + + + + + + + Models/Props/Highground1.mesh + + + + + + + + + + Models/Props/Highground2.mesh + + + + + + + + + + + Models/Props/Highground3.mesh + + + + + + + + + + + Models/Props/Highground4.mesh + + + + + + + + + + + Models/Props/Highground5.mesh + + + + + + + + + + Models/Props/Highground6.mesh + + + + + + + + + + + Models/Props/Highground7.mesh + + + + + + + + + + + + + Models/Props/Highground8.mesh + + + + + + + + + + + + + Models/Props/Highground9.mesh + + + + + + + + + + + + + Models/Props/Highground10.mesh + + + + + + + + + + + + + Models/Props/Highground6.mesh + + + + + + + + + + + + + Models/Props/Highground1.mesh + + + + + + + + + + + + Models/Props/Highground2.mesh + + + + + + + + + + + + + Models/Props/Highground3.mesh + + + + + + + + + + + + + Models/Props/Highground4.mesh + + + + + + + + + + + + + Models/Props/Highground5.mesh + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar3Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar3Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 5 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + 4 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + + 3 + + + + + + + + + + + + 2 + 1 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 5 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + 4 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + + 3 + + + + + + + + + + + + 2 + 1 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointBlue.mesh + + + + + + + + + + + + + -15 + 4 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 3 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 2 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 1 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointRed.mesh + + + + + + + + + + + + + 15 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + + 10 + + + + + + + + + + + 1 + false + + + + + + + + + + + + 10 + + + + + + + + + + + + + + Schema/Entities/PlayerRed.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 88f153ae..2edbd4a5 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -13,7 +13,7 @@ - 1.6944730461160304 + 23.911064541134579 @@ -193,7 +193,6 @@ 3 - 0.80222018197612788 @@ -228,6 +227,7 @@ 4 + 1 @@ -283,7 +283,7 @@ Textures/Core/UnitHexagon.png - + @@ -294,7 +294,8 @@ - + 1 + Textures/Core/UnitHexagon_Rotated.png @@ -303,7 +304,7 @@ - + @@ -372,7 +373,7 @@ Idle - 0.67172915251515519 + 0.22110820884665827 1 @@ -386,30 +387,49 @@ + + DefenderWeapon + Schema/Entities/DefenderWeaponView.xml - - DefenderWeapon - + + AssaultWeapon + Schema/Entities/AssaultWeaponView.xml - - AssaultWeapon - + + + + + Models/Widgets/Arrows/Arrow10.mesh + + + + + + + + + + + + + + @@ -430,6 +450,7 @@ Idle + 1.6993789132803556 1 @@ -449,31 +470,31 @@ - - Schema/Entities/DefenderWeaponWorld.xml - - DefenderWeapon + + Schema/Entities/DefenderWeaponWorld.xml + + - - Schema/Entities/AssaultWeaponWorld.xml - - AssaultWeapon + + Schema/Entities/AssaultWeaponWorld.xml + + diff --git a/resources/Schema/Entities/PlayerRed.xml b/resources/Schema/Entities/PlayerRed.xml index 8982f58d..7f81ab05 100644 --- a/resources/Schema/Entities/PlayerRed.xml +++ b/resources/Schema/Entities/PlayerRed.xml @@ -13,7 +13,7 @@ - 326.69883589440087 + 361.81593010381596 @@ -373,7 +373,7 @@ Idle - 0.20909021680133577 + 1.6231050125476969 1 @@ -417,10 +417,11 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh + - + @@ -445,7 +446,7 @@ Idle - 0.22069183859343156 + 1.8847063959212136 1 diff --git a/src/Game/Systems/CapturePointArrowHUDSystem.cpp b/src/Game/Systems/CapturePointArrowHUDSystem.cpp index ee2254c7..e86a6844 100644 --- a/src/Game/Systems/CapturePointArrowHUDSystem.cpp +++ b/src/Game/Systems/CapturePointArrowHUDSystem.cpp @@ -64,6 +64,9 @@ void CapturePointArrowHUDSystem::Update(double dt) } } //Check what team is the owner of Home1 and set their target to the next capturepoint + if(!home1.Valid() || !home2.Valid()) { + return; + } if((int)home1["CapturePoint"]["HomePointForTeam"] == redTeam) { m_RedTeamCurrentTarget = target1; } else if ((int)home1["CapturePoint"]["HomePointForTeam"] == blueTeam) { @@ -77,10 +80,7 @@ void CapturePointArrowHUDSystem::Update(double dt) m_BlueTeamCurrentTarget = target2; } } - - } - //if red team, get red team next point, otherwise blue team next point. //Untill this is awailable we will just use the hardcoded value in the component. //This will also give us a position, so we wont need to loop through all capturePoints. @@ -132,4 +132,6 @@ bool CapturePointArrowHUDSystem::OnCapturePointCaptured(Events::Captured& e) } else if (e.TeamNumberThatCapturedCapturePoint == blueTeam) { m_BlueTeamCurrentTarget = Transform::AbsolutePosition(e.NextCapturePoint);; } + + m_InitialtargetsSet = true; } From ef66f3ebe54998e0a998aaf264a4245ec1c43041 Mon Sep 17 00:00:00 2001 From: Teejoon Date: Tue, 1 Mar 2016 23:14:23 +0100 Subject: [PATCH 119/252] Transparancy with shild fix --- .../Rendering/DrawColorCorrectionPass.h | 2 +- include/Engine/Rendering/DrawFinalPass.h | 42 +- include/Engine/Rendering/ExplosionEffectJob.h | 4 +- include/Engine/Rendering/ModelJob.h | 6 +- include/Engine/Rendering/RenderQueue.h | 2 - .../Shaders/DrawColorCorrection.frag.glsl | 13 +- .../Shaders/ForwardPlusShieldCheck.frag.glsl | 207 ++++ ...orwardPlusSplatMapRGBShieldCheck.frag.glsl | 254 ++++ resources/Shaders/SpriteShieldCheck.frag.glsl | 41 + src/Engine/Editor/EditorRenderSystem.cpp | 2 +- .../Rendering/DrawColorCorrectionPass.cpp | 6 +- src/Engine/Rendering/DrawFinalPass.cpp | 1019 +++++++++++------ src/Engine/Rendering/DrawFinalPassState.cpp | 16 +- src/Engine/Rendering/PickingPass.cpp | 3 +- src/Engine/Rendering/RenderSystem.cpp | 19 +- src/Engine/Rendering/Renderer.cpp | 16 +- 16 files changed, 1252 insertions(+), 400 deletions(-) create mode 100644 resources/Shaders/ForwardPlusShieldCheck.frag.glsl create mode 100644 resources/Shaders/ForwardPlusSplatMapRGBShieldCheck.frag.glsl create mode 100644 resources/Shaders/SpriteShieldCheck.frag.glsl diff --git a/include/Engine/Rendering/DrawColorCorrectionPass.h b/include/Engine/Rendering/DrawColorCorrectionPass.h index 231e2d33..fcde73d7 100644 --- a/include/Engine/Rendering/DrawColorCorrectionPass.h +++ b/include/Engine/Rendering/DrawColorCorrectionPass.h @@ -17,7 +17,7 @@ public: void InitializeFrameBuffers(); void InitializeShaderPrograms(); - void Draw(GLuint sceneTexture, GLuint bloomTexture, GLuint sceneTextureLowRes, GLuint bloomTextureLowRes, GLfloat gamma, GLfloat exposure); + void Draw(GLuint sceneTexture, GLuint bloomTexture, GLfloat gamma, GLfloat exposure); private: const IRenderer* m_Renderer; diff --git a/include/Engine/Rendering/DrawFinalPass.h b/include/Engine/Rendering/DrawFinalPass.h index 97322603..3b83d52f 100644 --- a/include/Engine/Rendering/DrawFinalPass.h +++ b/include/Engine/Rendering/DrawFinalPass.h @@ -15,7 +15,7 @@ class DrawFinalPass { public: - DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass, GLuint* depthBuffer); + DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass); ~DrawFinalPass() { } void InitializeTextures(); void InitializeFrameBuffers(); @@ -26,20 +26,23 @@ public: //Return the texture that is used in later stages to apply the bloom effect GLuint BloomTexture() const { return m_BloomTexture; } - GLuint BloomTextureLowRes() const { return m_BloomTextureLowRes; } //Return the texture with diffuse and lighting of the scene. GLuint SceneTexture() const { return m_SceneTexture; } - GLuint SceneTextureLowRes() const { return m_SceneTextureLowRes; } //Return the framebuffer used in the scene rendering stage. FrameBuffer* FinalPassFrameBuffer() { return &m_FinalPassFrameBuffer; } - FrameBuffer* FinalPassFrameBufferLowRes() { return &m_FinalPassFrameBufferLowRes; } private: void DrawSprites(std::list>&jobs, RenderScene& scene); void DrawModelRenderQueues(std::list>& jobs, RenderScene& scene); - void DrawShieldToStencilBuffer(std::list>& jobs, RenderScene& scene); + void DrawModelRenderQueuesWithShieldCheck(std::list>& jobs, RenderScene& scene); void DrawShieldedModelRenderQueue(std::list>& jobs, RenderScene& scene); - void DrawToDepthBuffer(std::list>& jobs, RenderScene& scene); + void DrawToDepthStencilBuffer(std::list>& jobs, RenderScene& scene); + + void DrawExplosionSetup(ShaderProgram* shader, GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene); + void DrawSkinnedExplosionSetup(ShaderProgram* shader, GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene); + + void DrawModelSetup(ShaderProgram* shader, GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene); + void DrawSkinnedModelSetup(ShaderProgram* shader, GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene); void BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene); void BindModelUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene); @@ -54,13 +57,11 @@ private: Texture* m_ErrorTexture; FrameBuffer m_FinalPassFrameBuffer; - FrameBuffer m_FinalPassFrameBufferLowRes; + FrameBuffer m_ShieldDepthFrameBuffer; GLuint m_BloomTexture; GLuint m_SceneTexture; - GLuint m_BloomTextureLowRes; - GLuint m_SceneTextureLowRes; - GLuint* m_DepthBuffer; - GLuint m_DepthBufferLowRes; + GLuint m_DepthBuffer; + GLuint m_ShieldBuffer; GLuint m_CubeMapTexture; //maqke this component based i guess? @@ -76,16 +77,27 @@ private: ShaderProgram* m_ExplosionEffectSplatMapProgram; ShaderProgram* m_SpriteProgram; ShaderProgram* m_ForwardPlusSplatMapProgram; - ShaderProgram* m_ShieldToStencilProgram; - ShaderProgram* m_FillDepthBufferProgram; + ShaderProgram* m_FillDepthStencilBufferProgram; + + ShaderProgram* m_ForwardPlusShieldCheckProgram; + ShaderProgram* m_ExplosionEffectShieldCheckProgram; + ShaderProgram* m_ExplosionEffectSplatMapShieldCheckProgram; + ShaderProgram* m_SpriteShieldCheckProgram; + ShaderProgram* m_ForwardPlusSplatMapShieldCheckProgram; + ShaderProgram* m_ForwardPlusSkinnedProgram; ShaderProgram* m_ExplosionEffectSkinnedProgram; ShaderProgram* m_ExplosionEffectSplatMapSkinnedProgram; ShaderProgram* m_ForwardPlusSplatMapSkinnedProgram; - ShaderProgram* m_ShieldToStencilSkinnedProgram; - ShaderProgram* m_FillDepthBufferSkinnedProgram; + ShaderProgram* m_FillDepthStencilBufferSkinnedProgram; + + ShaderProgram* m_ForwardPlusSkinnedShieldCheckProgram; + ShaderProgram* m_ExplosionEffectSkinnedShieldCheckProgram; + ShaderProgram* m_ExplosionEffectSplatMapSkinnedShieldCheckProgram; + ShaderProgram* m_ForwardPlusSplatMapSkinnedShieldCheckProgram; + ShaderProgram* m_FillDepthBufferSkinnedShieldCheckProgram; }; #endif \ No newline at end of file diff --git a/include/Engine/Rendering/ExplosionEffectJob.h b/include/Engine/Rendering/ExplosionEffectJob.h index 8f339526..695a8dfe 100644 --- a/include/Engine/Rendering/ExplosionEffectJob.h +++ b/include/Engine/Rendering/ExplosionEffectJob.h @@ -15,8 +15,8 @@ struct ExplosionEffectJob : ModelJob { - ExplosionEffectJob(ComponentWrapper explosionEffectComponent, ::Model* model, Camera* camera, glm::mat4 matrix, ::RawModel::MaterialProperties matGroup, ComponentWrapper modelComponent, ::World* world, glm::vec4 fillColor, float fillPercentage) - : ModelJob(model, camera, matrix, matGroup, modelComponent, world, fillColor, fillPercentage) + ExplosionEffectJob(ComponentWrapper explosionEffectComponent, ::Model* model, Camera* camera, glm::mat4 matrix, ::RawModel::MaterialProperties matGroup, ComponentWrapper modelComponent, ::World* world, glm::vec4 fillColor, float fillPercentage, bool isShielded) + : ModelJob(model, camera, matrix, matGroup, modelComponent, world, fillColor, fillPercentage, isShielded) { ExplosionOrigin = (glm::vec3)explosionEffectComponent["ExplosionOrigin"]; TimeSinceDeath = (double)explosionEffectComponent["TimeSinceDeath"]; diff --git a/include/Engine/Rendering/ModelJob.h b/include/Engine/Rendering/ModelJob.h index c2a469d2..58993ea1 100644 --- a/include/Engine/Rendering/ModelJob.h +++ b/include/Engine/Rendering/ModelJob.h @@ -18,7 +18,7 @@ struct ModelJob : RenderJob { - ModelJob(Model* model, Camera* camera, glm::mat4 matrix, ::RawModel::MaterialProperties matProp, ComponentWrapper modelComponent, World* world, glm::vec4 fillColor, float fillPercentage) + ModelJob(Model* model, Camera* camera, glm::mat4 matrix, ::RawModel::MaterialProperties matProp, ComponentWrapper modelComponent, World* world, glm::vec4 fillColor, float fillPercentage, bool isShielded) : RenderJob() { Model = model; @@ -117,7 +117,7 @@ struct ModelJob : RenderJob FillColor = fillColor; FillPercentage = fillPercentage; - + IsShielded = isShielded; if (model->IsSkinned()) { Skeleton = Model->m_RawModel->m_Skeleton; @@ -181,7 +181,7 @@ struct ModelJob : RenderJob glm::vec4 FillColor = glm::vec4(0); float FillPercentage = 0.0; - + bool IsShielded; void CalculateHash() override { Hash = ShaderID << 20 + ModelID << 10 + TextureID; diff --git a/include/Engine/Rendering/RenderQueue.h b/include/Engine/Rendering/RenderQueue.h index 647adab8..e3c46e85 100644 --- a/include/Engine/Rendering/RenderQueue.h +++ b/include/Engine/Rendering/RenderQueue.h @@ -24,7 +24,6 @@ struct RenderScene std::list> OpaqueObjects; std::list> TransparentObjects; std::list> OpaqueShieldedObjects; - std::list> TransparentShieldedObjects; std::list> ShieldObjects; std::list> SpriteJob; std::list> PointLight; @@ -41,7 +40,6 @@ struct RenderScene Jobs.OpaqueObjects.clear(); Jobs.TransparentObjects.clear(); Jobs.OpaqueShieldedObjects.clear(); - Jobs.TransparentShieldedObjects.clear(); Jobs.ShieldObjects.clear(); Jobs.SpriteJob.clear(); Jobs.DirectionalLight.clear(); diff --git a/resources/Shaders/DrawColorCorrection.frag.glsl b/resources/Shaders/DrawColorCorrection.frag.glsl index bae50887..d8273547 100644 --- a/resources/Shaders/DrawColorCorrection.frag.glsl +++ b/resources/Shaders/DrawColorCorrection.frag.glsl @@ -2,8 +2,6 @@ layout (binding = 0) uniform sampler2D SceneTexture; layout (binding = 1) uniform sampler2D BloomTexture; -layout (binding = 2) uniform sampler2D SceneTextureLowRes; -layout (binding = 3) uniform sampler2D BloomTextureLowRes; uniform float Exposure; uniform float Gamma; @@ -17,21 +15,12 @@ void main() { vec4 hdrColor = texture(SceneTexture, Input.TextureCoordinate); vec4 bloomColor = texture(BloomTexture, Input.TextureCoordinate); - vec4 hdrColorLowRes = texture(SceneTextureLowRes, Input.TextureCoordinate); - vec4 bloomColorLowRes = texture(BloomTextureLowRes, Input.TextureCoordinate); //hdrColor = hdrColor * SSAO; hdrColor += bloomColor; - hdrColorLowRes; - float hdrColorsum = hdrColorLowRes.r + hdrColorLowRes.g + hdrColorLowRes.b; //Toon mapping thingy - vec3 result; - if(hdrColorsum > 0.0) { - result = vec3(1.0) - exp(-hdrColorLowRes.rgb * Exposure); - } else { - result = vec3(1.0) - exp(-hdrColor.rgb * Exposure); - } + vec3 result = vec3(1.0) - exp(-hdrColor.rgb * Exposure); //gamme correction result = pow(result, vec3(1.0 / Gamma)); diff --git a/resources/Shaders/ForwardPlusShieldCheck.frag.glsl b/resources/Shaders/ForwardPlusShieldCheck.frag.glsl new file mode 100644 index 00000000..35db495b --- /dev/null +++ b/resources/Shaders/ForwardPlusShieldCheck.frag.glsl @@ -0,0 +1,207 @@ +#version 430 + +#define MIN_AMBIENT_LIGHT 0.3 + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform vec4 Color; +uniform vec4 DiffuseColor; +uniform vec2 ScreenDimensions; +uniform vec4 FillColor; +uniform vec4 AmbientColor; +uniform float FillPercentage; +uniform float GlowIntensity = 10; +uniform vec3 CameraPosition; +uniform int SSAOQuality; + +uniform vec2 DiffuseUVRepeat; +uniform vec2 NormalUVRepeat; +uniform vec2 SpecularUVRepeat; +uniform vec2 GlowUVRepeat; +layout (binding = 0) uniform sampler2D AOTexture; +layout (binding = 1) uniform sampler2D DiffuseTexture; +layout (binding = 2) uniform sampler2D NormalMapTexture; +layout (binding = 3) uniform sampler2D SpecularMapTexture; +layout (binding = 4) uniform sampler2D GlowMapTexture; +layout (binding = 5) uniform samplerCube CubeMap; +layout (binding = 31) uniform sampler2D ShieldBuffer; + +#define TILE_SIZE 16 + +struct LightSource { + vec4 Position; + vec4 Direction; + vec4 Color; + float Radius; + float Intensity; + float Falloff; + int Type; +}; + +layout (std430, binding = 1) buffer LightBuffer +{ + LightSource List[]; +} LightSources; + +struct LightGrid { + float Start; + float Amount; + vec2 Padding; +}; + +layout (std430, binding = 2) buffer LightGridBuffer +{ + LightGrid Data[]; +} LightGrids; + +layout (std430, binding = 4) buffer LightIndexBuffer +{ + float LightIndex[]; +}; + + +in VertexData{ + vec3 Position; + vec3 Normal; + vec3 Tangent; + vec3 BiTangent; + vec2 TextureCoordinate; + vec4 ExplosionColor; + float ExplosionPercentageElapsed; +}Input; + +out vec4 sceneColor; +out vec4 bloomColor; + +struct LightResult { + vec4 Diffuse; + vec4 Specular; +}; + +float CalcAttenuation(float radius, float dist, float falloff) { + return 1.0 - smoothstep(radius * falloff, radius, dist); +} + +vec4 CalcSpecular(vec4 lightColor, vec4 viewVec, vec4 lightVec, vec4 normal) { + vec4 R = normalize( reflect(-lightVec, normal)); + float RdotV = max( dot(R, viewVec), 0.0); + return lightColor * pow(RdotV, 90.0); +} + +vec4 CalcDiffuse(vec4 lightColor, vec4 lightVec, vec4 normal) { + float power = max( dot(normal, lightVec), 0.0); + return lightColor * power; +} + +LightResult CalcPointLightSource(vec4 lightPos, float lightRadius, vec4 lightColor, float intensity, vec4 viewVec, vec4 position, vec4 normal, float falloff) +{ + vec4 L = lightPos - position; + float dist = length(L); + L = normalize(L); + + float attenuation = CalcAttenuation(lightRadius, dist, falloff); + + LightResult result; + result.Diffuse = CalcDiffuse(lightColor, L, normal) * attenuation * intensity; + result.Specular = CalcSpecular(lightColor, viewVec, L, normal) * attenuation * intensity; + return result; +} + +LightResult CalcDirectionalLightSource(vec4 direction, vec4 color, float intensity, vec4 viewVec, vec4 vertNormal) +{ + vec4 L = normalize( -vec4(direction.xyz, 0) ); + + LightResult result; + result.Diffuse = CalcDiffuse(color, L, vertNormal) * intensity; + result.Specular = CalcSpecular(color, viewVec, L, vertNormal) * intensity; + return result; +} + +vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textureCoordinate, sampler2D normalMap) +{ + mat3 TBN = mat3(tangent, bitangent, normal); + vec3 NormalMap = texture(normalMap, textureCoordinate).xyz * 2.0 - vec3(1.0); + return vec4(TBN * normalize(NormalMap), 0.0); +} + +void main() +{ + float shieldDepthValue = texelFetch(ShieldBuffer, ivec2(gl_FragCoord.xy), 0).r; + + if(shieldDepthValue < gl_FragCoord.z){ + discard; + } + + float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy) >> int(SSAOQuality), 0).r; + ao = (clamp(1.0 - (1.0 - ao), 0.0, 1.0) + MIN_AMBIENT_LIGHT) / (1.0 + MIN_AMBIENT_LIGHT); + vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate * DiffuseUVRepeat); + vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat); + vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate * SpecularUVRepeat); + vec4 position = V * M * vec4(Input.Position, 1.0); + vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate * NormalUVRepeat, NormalMapTexture); + normal = normalize(normal); + //vec4 normal = normalize(V * vec4(Input.Normal, 0.0)); + vec4 viewVec = normalize(-position); + vec3 I = normalize(vec3(M * vec4(Input.Position, 1.0)) - CameraPosition); + vec3 R = reflect(-I, Input.Normal); + //R = vec3(P * vec4(R, 1.0)); + vec4 reflectionColor = texture(CubeMap, R); + + vec2 tilePos; + tilePos.x = int(gl_FragCoord.x/TILE_SIZE); + tilePos.y = int(gl_FragCoord.y/TILE_SIZE); + + LightResult totalLighting; + totalLighting.Diffuse = vec4(AmbientColor.rgb * ao, 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); + int amount = int(LightGrids.Data[currentTile].Amount); + + for(int i = start; i < start + amount; i++) { + + int l = int(LightIndex[i]); + LightSource light = LightSources.List[l]; + + LightResult light_result; + //These if statements should be removed. + if(light.Type == 1) { // point + light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, position, normal, light.Falloff); + } else if (light.Type == 2) { //Directional + light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal); + } + totalLighting.Diffuse += vec4(light_result.Diffuse.rgb * ao, light_result.Diffuse.a); + totalLighting.Specular += vec4(light_result.Specular.rgb * ao, light_result.Specular.a); + } + + vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); + color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); + float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0; + vec4 reflectionTotal = reflectionColor * (1-specularTexel.a) * color_result.a; + color_result = color_result * clamp(1/specularTexel.a, 0, 1) + reflectionTotal; + //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; + + if(pos <= FillPercentage) { + color_result += FillColor; + } + sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1)); + //sceneColor = vec4(reflectionColor.xyz, 1); + color_result.xyz += glowTexel.xyz*GlowIntensity; + + bloomColor = vec4(max(color_result.xyz - 1.0, 0.0), clamp(color_result.a, 0, 1)); + + //Tiled Debug Code + /* + if(int(gl_FragCoord.x)%16 == 0 || int(gl_FragCoord.y)%16 == 0 ) { + sceneColor += vec4(0.5, 0, 0, 0); + } else { + sceneColor += vec4(LightGrids.Data[int(tilePos.x + tilePos.y*80)].Amount/LightSources.List.length(), 0, 0, 1); + } + */ +} + + diff --git a/resources/Shaders/ForwardPlusSplatMapRGBShieldCheck.frag.glsl b/resources/Shaders/ForwardPlusSplatMapRGBShieldCheck.frag.glsl new file mode 100644 index 00000000..fa3af6ac --- /dev/null +++ b/resources/Shaders/ForwardPlusSplatMapRGBShieldCheck.frag.glsl @@ -0,0 +1,254 @@ +#version 430 + +#define MIN_AMBIENT_LIGHT 0.3 + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; +uniform vec2 ScreenDimensions; +uniform float FillPercentage; +uniform vec4 DiffuseColor; +uniform vec4 FillColor; +uniform vec4 Color; +uniform vec4 AmbientColor; +uniform int SSAOQuality; + +//Get bineded at the same time as the textures +uniform vec2 DiffuseUVRepeat1; +uniform vec2 DiffuseUVRepeat2; +uniform vec2 DiffuseUVRepeat3; +uniform vec2 NormalUVRepeat1; +uniform vec2 NormalUVRepeat2; +uniform vec2 NormalUVRepeat3; +uniform vec2 SpecularUVRepeat1; +uniform vec2 SpecularUVRepeat2; +uniform vec2 SpecularUVRepeat3; +uniform vec2 GlowUVRepeat1; +uniform vec2 GlowUVRepeat2; +uniform vec2 GlowUVRepeat3; +layout (binding = 0) uniform sampler2D AOTexture; +layout (binding = 1) uniform sampler2D SplatMapTexture; +layout (binding = 2) uniform sampler2D DiffuseTexture1; +layout (binding = 3) uniform sampler2D DiffuseTexture2; +layout (binding = 4) uniform sampler2D DiffuseTexture3; +layout (binding = 5) uniform sampler2D NormalMapTexture1; +layout (binding = 6) uniform sampler2D NormalMapTexture2; +layout (binding = 7) uniform sampler2D NormalMapTexture3; +layout (binding = 8) uniform sampler2D SpecularMapTexture1; +layout (binding = 9) uniform sampler2D SpecularMapTexture2; +layout (binding = 10) uniform sampler2D SpecularMapTexture3; +layout (binding = 11) uniform sampler2D GlowMapTexture1; +layout (binding = 12) uniform sampler2D GlowMapTexture2; +layout (binding = 13) uniform sampler2D GlowMapTexture3; +layout (binding = 13) uniform sampler2D GlowMapTexture3; +layout (binding = 31) uniform samplerCube ShieldBuffer; + +#define TILE_SIZE 16 + +struct LightSource { + vec4 Position; + vec4 Direction; + vec4 Color; + float Radius; + float Intensity; + float Falloff; + int Type; +}; + +layout (std430, binding = 1) buffer LightBuffer +{ + LightSource List[]; +} LightSources; + +struct LightGrid { + float Start; + float Amount; + vec2 Padding; +}; + +layout (std430, binding = 2) buffer LightGridBuffer +{ + LightGrid Data[]; +} LightGrids; + +layout (std430, binding = 4) buffer LightIndexBuffer +{ + float LightIndex[]; +}; + + +in VertexData{ + vec3 Position; + vec3 Normal; + vec3 Tangent; + vec3 BiTangent; + vec2 TextureCoordinate; + vec4 ExplosionColor; + float ExplosionPercentageElapsed; +}Input; + +out vec4 sceneColor; +out vec4 bloomColor; + +struct LightResult { + vec4 Diffuse; + vec4 Specular; +}; + +float CalcAttenuation(float radius, float dist, float falloff) { + return 1.0 - smoothstep(radius * 0.3, radius, dist); +} + +vec4 CalcSpecular(vec4 lightColor, vec4 viewVec, vec4 lightVec, vec4 normal) { + vec4 R = normalize( reflect(-lightVec, normal)); + float RdotV = max( dot(R, viewVec), 0.0); + return lightColor * pow(RdotV, 90.0); +} + +vec4 CalcDiffuse(vec4 lightColor, vec4 lightVec, vec4 normal) { + float power = max( dot(normal, lightVec), 0.0); + return lightColor * power; +} + +LightResult CalcPointLightSource(vec4 lightPos, float lightRadius, vec4 lightColor, float intensity, vec4 viewVec, vec4 position, vec4 normal, float falloff) +{ + vec4 L = lightPos - position; + float dist = length(L); + L = normalize(L); + + float attenuation = CalcAttenuation(lightRadius, dist, falloff); + + LightResult result; + result.Diffuse = CalcDiffuse(lightColor, L, normal) * attenuation * intensity; + result.Specular = CalcSpecular(lightColor, viewVec, L, normal) * attenuation * intensity; + return result; +} + +LightResult CalcDirectionalLightSource(vec4 direction, vec4 color, float intensity, vec4 viewVec, vec4 vertNormal) +{ + vec4 L = normalize( -vec4(direction.xyz, 0) ); + + LightResult result; + result.Diffuse = CalcDiffuse(color, L, vertNormal) * intensity; + result.Specular = CalcSpecular(color, viewVec, L, vertNormal) * intensity; + return result; +} + +vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textureCoordinate, sampler2D normalMap) +{ + mat3 TBN = mat3(tangent, bitangent, normal); + vec3 NormalMap = texture(normalMap, textureCoordinate).xyz * 2.0 - vec3(1.0); + return vec4(TBN * normalize(NormalMap), 0.0); +} + +vec4 CalcBlendedTexel(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B, + vec2 R_TileValues, vec2 G_TileValues, vec2 B_TileValues){ + vec4 R_Channel = texture2D(R, Input.TextureCoordinate * R_TileValues); + vec4 G_Channel = texture2D(G, Input.TextureCoordinate * G_TileValues); + vec4 B_Channel = texture2D(B, Input.TextureCoordinate * B_TileValues); + + float total = blendValue.r + blendValue.g + blendValue.b; + float totalDiv = 1.0f / total; + blendValue.r = blendValue.r * totalDiv; + blendValue.g = blendValue.g * totalDiv; + blendValue.b = blendValue.b * totalDiv; + + return blendValue.r * R_Channel + + blendValue.g * G_Channel + + blendValue.b * B_Channel; +} + +vec4 CalcBlendedNormal(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B, + vec2 R_TileValues, vec2 G_TileValues, vec2 B_TileValues){ + mat3 TBN = mat3(Input.Tangent, Input.BiTangent, Input.Normal); + vec3 R_Channel = texture(R, Input.TextureCoordinate * R_TileValues).xyz * 2.0 - vec3(1.0); + vec3 G_Channel = texture(G, Input.TextureCoordinate * G_TileValues).xyz * 2.0 - vec3(1.0); + vec3 B_Channel = texture(B, Input.TextureCoordinate * B_TileValues).xyz * 2.0 - vec3(1.0); + + float total = blendValue.r + blendValue.g + blendValue.b + blendValue.a; + float totalDiv = 1 / total; + blendValue.r = blendValue.r * totalDiv; + blendValue.g = blendValue.g * totalDiv; + blendValue.b = blendValue.b * totalDiv; + + vec3 Normal_result = blendValue.r * R_Channel + + blendValue.g * G_Channel + + blendValue.b * B_Channel; + + return vec4(TBN * normalize(Normal_result), 0.0); +} + +void main() +{ + float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy) >> int(SSAOQuality), 0).r; + ao = (clamp(1.0 - (1.0 - ao), 0.0, 1.0) + MIN_AMBIENT_LIGHT) / (1.0 + MIN_AMBIENT_LIGHT); + + vec4 splatTexel = texture2D(SplatMapTexture, Input.TextureCoordinate); + + vec4 diffuseTexel = CalcBlendedTexel(splatTexel, DiffuseTexture1, DiffuseTexture2, DiffuseTexture3, + DiffuseUVRepeat1, DiffuseUVRepeat2, DiffuseUVRepeat3); + vec4 glowTexel = CalcBlendedTexel(splatTexel, GlowMapTexture1, GlowMapTexture2, GlowMapTexture3, + GlowUVRepeat1, GlowUVRepeat2, GlowUVRepeat3); + vec4 specularTexel = CalcBlendedTexel(splatTexel, SpecularMapTexture1, SpecularMapTexture2, SpecularMapTexture3, + SpecularUVRepeat1, SpecularUVRepeat2, SpecularUVRepeat3); + vec4 position = V * M * vec4(Input.Position, 1.0); + //vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, SplatMapTexture); + vec4 normal = V * CalcBlendedNormal(splatTexel, NormalMapTexture1, NormalMapTexture2, NormalMapTexture3, + NormalUVRepeat1, NormalUVRepeat2, NormalUVRepeat3); + normal = normalize(normal); + //vec4 normal = normalize(V * vec4(Input.Normal, 0.0)); + vec4 viewVec = normalize(-position); + + vec2 tilePos; + tilePos.x = int(gl_FragCoord.x/TILE_SIZE); + tilePos.y = int(gl_FragCoord.y/TILE_SIZE); + + LightResult totalLighting; + totalLighting.Diffuse = vec4(AmbientColor.rgb * ao, 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); + int amount = int(LightGrids.Data[currentTile].Amount); + + for(int i = start; i < start + amount; i++) { + + int l = int(LightIndex[i]); + LightSource light = LightSources.List[l]; + + LightResult light_result; + //These if statements should be removed. + if(light.Type == 1) { // point + light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, position, normal, light.Falloff); + } else if (light.Type == 2) { //Directional + light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal); + } + totalLighting.Diffuse += vec4(light_result.Diffuse.rgb * ao, light_result.Diffuse.a); + totalLighting.Specular += vec4(light_result.Specular.rgb * ao, light_result.Specular.a); + } + + 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; + + if(pos <= FillPercentage) { + color_result += FillColor; + } + sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1)); + color_result += glowTexel*3; + + bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), 1.0); + + //Tiled Debug Code + /* + if(int(gl_FragCoord.x)%16 == 0 || int(gl_FragCoord.y)%16 == 0 ) { + sceneColor += vec4(0.5, 0, 0, 0); + } else { + sceneColor += vec4(LightGrids.Data[int(tilePos.x + tilePos.y*80)].Amount/LightSources.List.length(), 0, 0, 1); + } + */ +} + + diff --git a/resources/Shaders/SpriteShieldCheck.frag.glsl b/resources/Shaders/SpriteShieldCheck.frag.glsl new file mode 100644 index 00000000..754be6ac --- /dev/null +++ b/resources/Shaders/SpriteShieldCheck.frag.glsl @@ -0,0 +1,41 @@ +#version 430 + +uniform vec4 Color; +uniform vec4 FillColor; +uniform float FillPercentage; +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; + +layout (binding = 1) uniform sampler2D DiffuseTexture; +layout (binding = 2) uniform sampler2D GlowMapTexture; + + +in VertexData{ + vec3 Position; + vec3 Normal; + vec2 TextureCoordinate; +}Input; + + +out vec4 sceneColor; +out vec4 bloomColor; + +void main() +{ + vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate); + vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate); + + vec4 color_result = Color * diffuseTexel; + + float pos = ((P * vec4(Input.Position, 1)).y + 1.0)/2.0; + if(pos <= FillPercentage) { + color_result = FillColor*diffuseTexel.a; + } + sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1)); + + //bloomColor = vec4(clamp((glowTexel.xyz*3) - 1.0, 0, 100), 1.0); + bloomColor = vec4(1.0, 1.0, 1.0, 0.0); +} + + diff --git a/src/Engine/Editor/EditorRenderSystem.cpp b/src/Engine/Editor/EditorRenderSystem.cpp index 9a385e7d..f5fcc1a1 100644 --- a/src/Engine/Editor/EditorRenderSystem.cpp +++ b/src/Engine/Editor/EditorRenderSystem.cpp @@ -54,7 +54,7 @@ void EditorRenderSystem::Update(double dt) EntityWrapper entity(m_World, cModel.EntityID); 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); + std::shared_ptr modelJob = std::make_shared(model, scene.Camera, modelMatrix, matGroup, cModel, entity.World, glm::vec4(0), 0.f, false); if (cModel["Transparent"]) { scene.Jobs.TransparentObjects.push_back(modelJob); } else { diff --git a/src/Engine/Rendering/DrawColorCorrectionPass.cpp b/src/Engine/Rendering/DrawColorCorrectionPass.cpp index c82d614f..70d3a053 100644 --- a/src/Engine/Rendering/DrawColorCorrectionPass.cpp +++ b/src/Engine/Rendering/DrawColorCorrectionPass.cpp @@ -18,7 +18,7 @@ void DrawColorCorrectionPass::InitializeShaderPrograms() m_ColorCorrectionProgram->Link(); } -void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLuint sceneTextureLowRes, GLuint bloomTextureLowRes, GLfloat gamma, GLfloat exposure) +void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLfloat gamma, GLfloat exposure) { //glBindFramebuffer(GL_FRAMEBUFFER, 0); GLERROR("DrawScreenQuadPass::Draw: Pre"); @@ -33,10 +33,6 @@ void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLu glBindTexture(GL_TEXTURE_2D, sceneTexture); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, bloomTexture); - glActiveTexture(GL_TEXTURE2); - glBindTexture(GL_TEXTURE_2D, sceneTextureLowRes); - glActiveTexture(GL_TEXTURE3); - glBindTexture(GL_TEXTURE_2D, bloomTextureLowRes); glBindVertexArray(m_ScreenQuad->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer); diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 44ab8fd4..16c154e3 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -1,10 +1,9 @@ #include "Rendering/DrawFinalPass.h" -DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass, GLuint* depthBuffer) +DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass) : m_Renderer(renderer) , m_LightCullingPass(lightCullingPass) , m_CubeMapPass(cubeMapPass) , m_SSAOPass(ssaoPass) - , m_DepthBuffer(depthBuffer) { //TODO: Make sure that uniforms are not sent into shader if not needed. m_ShieldPixelRate = 8; @@ -30,30 +29,20 @@ void DrawFinalPass::InitializeFrameBuffers() //GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_FLOAT, 4); //GenerateTexture(&m_StencilTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_STENCIL, GL_STENCIL_INDEX8, GL_INT); - m_FinalPassFrameBuffer.AddResource(std::shared_ptr(new Texture2D(m_DepthBuffer, GL_DEPTH_STENCIL_ATTACHMENT))); + CommonFunctions::GenerateTexture(&m_DepthBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST, + glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8); + + m_FinalPassFrameBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthBuffer, GL_DEPTH_STENCIL_ATTACHMENT))); //m_FinalPassFrameBuffer.AddResource(std::shared_ptr(new Texture2D(&m_StencilTexture, GL_STENCIL_ATTACHMENT))); m_FinalPassFrameBuffer.AddResource(std::shared_ptr(new Texture2D(&m_SceneTexture, GL_COLOR_ATTACHMENT0))); m_FinalPassFrameBuffer.AddResource(std::shared_ptr(new Texture2D(&m_BloomTexture, GL_COLOR_ATTACHMENT1))); m_FinalPassFrameBuffer.Generate(); GLERROR("FBO generation"); - glGenRenderbuffers(1, &m_DepthBufferLowRes); - glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBufferLowRes); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, (int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)); - GLERROR("RenderBufferLowRes generation"); - - CommonFunctions::GenerateTexture(&m_SceneTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), GL_RGB16F, GL_RGB, GL_FLOAT); - //GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); - CommonFunctions::GenerateTexture(&m_BloomTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), GL_RGB16F, GL_RGB, GL_FLOAT); - //GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_FLOAT, 4); - //GenerateTexture(&m_StencilTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_STENCIL, GL_STENCIL_INDEX8, GL_INT); - - m_FinalPassFrameBufferLowRes.AddResource(std::shared_ptr(new RenderBuffer(&m_DepthBufferLowRes, GL_DEPTH_STENCIL_ATTACHMENT))); - //m_FinalPassFrameBufferLowRes.AddResource(std::shared_ptr(new Texture2D(&m_StencilTexture, GL_STENCIL_ATTACHMENT))); - m_FinalPassFrameBufferLowRes.AddResource(std::shared_ptr(new Texture2D(&m_SceneTextureLowRes, GL_COLOR_ATTACHMENT0))); - m_FinalPassFrameBufferLowRes.AddResource(std::shared_ptr(new Texture2D(&m_BloomTextureLowRes, GL_COLOR_ATTACHMENT1))); - m_FinalPassFrameBufferLowRes.Generate(); - GLERROR("FBO2 generation"); + CommonFunctions::GenerateTexture(&m_ShieldBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST, + glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT); + m_ShieldDepthFrameBuffer.AddResource(std::shared_ptr(new Texture2D(&m_ShieldBuffer, GL_DEPTH_ATTACHMENT))); + m_ShieldDepthFrameBuffer.Generate(); } void DrawFinalPass::InitializeShaderPrograms() @@ -85,6 +74,7 @@ void DrawFinalPass::InitializeShaderPrograms() m_SpriteProgram->BindFragDataLocation(1, "bloomColor"); m_SpriteProgram->Link(); GLERROR("Creating sprite program"); + m_ForwardPlusSplatMapProgram = ResourceManager::Load("#ForwardPlusSplatMapProgram"); m_ForwardPlusSplatMapProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/ForwardPlus.vert.glsl"))); m_ForwardPlusSplatMapProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/ForwardPlusSplatMapRGB.frag.glsl"))); @@ -140,152 +130,184 @@ void DrawFinalPass::InitializeShaderPrograms() m_ForwardPlusSplatMapSkinnedProgram->BindFragDataLocation(1, "bloomColor"); m_ForwardPlusSplatMapSkinnedProgram->Link(); GLERROR("Creating Forward SplatMap Skinned program"); + + m_FillDepthStencilBufferProgram = ResourceManager::Load("#FillDepthBufferProgram"); + m_FillDepthStencilBufferProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/FillDepthBuffer.vert.glsl"))); + m_FillDepthStencilBufferProgram->Compile(); + m_FillDepthStencilBufferProgram->Link(); + GLERROR("Creating DepthFill program"); + + m_FillDepthStencilBufferSkinnedProgram = ResourceManager::Load("#FillDepthBufferProgramSkinned"); + m_FillDepthStencilBufferSkinnedProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/FillDepthBufferSkinned.vert.glsl"))); + m_FillDepthStencilBufferSkinnedProgram->Compile(); + m_FillDepthStencilBufferSkinnedProgram->Link(); + GLERROR("Creating DepthFill program"); + + + + + + m_ForwardPlusShieldCheckProgram = ResourceManager::Load("#ForwardPlusShieldCheckProgram"); + m_ForwardPlusShieldCheckProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/ForwardPlus.vert.glsl"))); + m_ForwardPlusShieldCheckProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/ForwardPlusShieldCheck.frag.glsl"))); + m_ForwardPlusShieldCheckProgram->Compile(); + m_ForwardPlusShieldCheckProgram->BindFragDataLocation(0, "sceneColor"); + m_ForwardPlusShieldCheckProgram->BindFragDataLocation(1, "bloomColor"); + m_ForwardPlusShieldCheckProgram->Link(); + GLERROR("Creating forward+ program"); + + m_ExplosionEffectShieldCheckProgram = ResourceManager::Load("#ExplosionEffectShieldCheckProgram"); + m_ExplosionEffectShieldCheckProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/ForwardPlus.vert.glsl"))); + m_ExplosionEffectShieldCheckProgram->AddShader(std::shared_ptr(new GeometryShader("Shaders/ExplosionEffect.geom.glsl"))); + m_ExplosionEffectShieldCheckProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/ForwardPlusShieldCheck.frag.glsl"))); + m_ExplosionEffectShieldCheckProgram->Compile(); + m_ExplosionEffectShieldCheckProgram->BindFragDataLocation(0, "sceneColor"); + m_ExplosionEffectShieldCheckProgram->BindFragDataLocation(1, "bloomColor"); + m_ExplosionEffectShieldCheckProgram->Link(); + GLERROR("Creating explosion program"); + + m_SpriteShieldCheckProgram = ResourceManager::Load("#SpriteShieldCheckProgram"); + m_SpriteShieldCheckProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/Sprite.vert.glsl"))); + m_SpriteShieldCheckProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/SpriteShieldCheck.frag.glsl"))); + m_SpriteShieldCheckProgram->Compile(); + m_SpriteShieldCheckProgram->BindFragDataLocation(0, "sceneColor"); + m_SpriteShieldCheckProgram->BindFragDataLocation(1, "bloomColor"); + m_SpriteShieldCheckProgram->Link(); + GLERROR("Creating sprite program"); + + m_ForwardPlusSplatMapShieldCheckProgram = ResourceManager::Load("#ForwardPlusSplatMapShieldCheckProgram"); + m_ForwardPlusSplatMapShieldCheckProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/ForwardPlus.vert.glsl"))); + m_ForwardPlusSplatMapShieldCheckProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/ForwardPlusSplatMapRGBShieldCheck.frag.glsl"))); + m_ForwardPlusSplatMapShieldCheckProgram->Compile(); + m_ForwardPlusSplatMapShieldCheckProgram->BindFragDataLocation(0, "sceneColor"); + m_ForwardPlusSplatMapShieldCheckProgram->BindFragDataLocation(1, "bloomColor"); + m_ForwardPlusSplatMapShieldCheckProgram->Link(); + GLERROR("Creating Forward SplatMap program"); + + m_ExplosionEffectSplatMapShieldCheckProgram = ResourceManager::Load("#ExplosionEffectSplatMapShieldCheckProgram"); + m_ExplosionEffectSplatMapShieldCheckProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/ForwardPlus.vert.glsl"))); + m_ExplosionEffectSplatMapShieldCheckProgram->AddShader(std::shared_ptr(new GeometryShader("Shaders/ExplosionEffect.geom.glsl"))); + m_ExplosionEffectSplatMapShieldCheckProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/ForwardPlusSplatMapRGBShieldCheck.frag.glsl"))); + m_ExplosionEffectSplatMapShieldCheckProgram->Compile(); + m_ExplosionEffectSplatMapShieldCheckProgram->BindFragDataLocation(0, "sceneColor"); + m_ExplosionEffectSplatMapShieldCheckProgram->BindFragDataLocation(1, "bloomColor"); + m_ExplosionEffectSplatMapShieldCheckProgram->Link(); + GLERROR("Creating explosion SplatMap program"); + + m_ForwardPlusSkinnedShieldCheckProgram = ResourceManager::Load("#ForwardPlusSkinnedShieldCheckProgram"); + m_ForwardPlusSkinnedShieldCheckProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/ForwardPlusSkinned.vert.glsl"))); + m_ForwardPlusSkinnedShieldCheckProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/ForwardPlusShieldCheck.frag.glsl"))); + m_ForwardPlusSkinnedShieldCheckProgram->Compile(); + m_ForwardPlusSkinnedShieldCheckProgram->BindFragDataLocation(0, "sceneColor"); + m_ForwardPlusSkinnedShieldCheckProgram->BindFragDataLocation(1, "bloomColor"); + m_ForwardPlusSkinnedShieldCheckProgram->Link(); + GLERROR("Creating forward+ Skinned program"); + + m_ExplosionEffectSkinnedShieldCheckProgram = ResourceManager::Load("#ExplosionEffectSkinnedShieldCheckProgram"); + m_ExplosionEffectSkinnedShieldCheckProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/ForwardPlusSkinned.vert.glsl"))); + m_ExplosionEffectSkinnedShieldCheckProgram->AddShader(std::shared_ptr(new GeometryShader("Shaders/ExplosionEffect.geom.glsl"))); + m_ExplosionEffectSkinnedShieldCheckProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/ForwardPlusShieldCheck.frag.glsl"))); + m_ExplosionEffectSkinnedShieldCheckProgram->Compile(); + m_ExplosionEffectSkinnedShieldCheckProgram->BindFragDataLocation(0, "sceneColor"); + m_ExplosionEffectSkinnedShieldCheckProgram->BindFragDataLocation(1, "bloomColor"); + m_ExplosionEffectSkinnedShieldCheckProgram->Link(); + GLERROR("Creating explosion Skinned program"); + + m_ExplosionEffectSplatMapSkinnedShieldCheckProgram = ResourceManager::Load("#ExplosionEffectSplatMapSkinnedShieldCheckProgram"); + m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/ForwardPlusSkinned.vert.glsl"))); + m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/ForwardPlusSplatMapRGBShieldCheck.frag.glsl"))); + m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->Compile(); + m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->BindFragDataLocation(0, "sceneColor"); + m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->BindFragDataLocation(1, "bloomColor"); + m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->Link(); + GLERROR("Creating Forward SplatMap Skinned program"); + + m_ForwardPlusSplatMapSkinnedShieldCheckProgram = ResourceManager::Load("#ForwardPlusSplatMapSkinnedShieldCheckProgram"); + m_ForwardPlusSplatMapSkinnedShieldCheckProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/ForwardPlusSkinned.vert.glsl"))); + m_ForwardPlusSplatMapSkinnedShieldCheckProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/ForwardPlusSplatMapRGBShieldCheck.frag.glsl"))); + m_ForwardPlusSplatMapSkinnedShieldCheckProgram->Compile(); + m_ForwardPlusSplatMapSkinnedShieldCheckProgram->BindFragDataLocation(0, "sceneColor"); + m_ForwardPlusSplatMapSkinnedShieldCheckProgram->BindFragDataLocation(1, "bloomColor"); + m_ForwardPlusSplatMapSkinnedShieldCheckProgram->Link(); + GLERROR("Creating Forward SplatMap Skinned program"); - m_ShieldToStencilProgram = ResourceManager::Load("#ShieldToStencilProgram"); - m_ShieldToStencilProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/ShieldStencil.vert.glsl"))); - m_ShieldToStencilProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/ShieldStencil.frag.glsl"))); - m_ShieldToStencilProgram->Compile(); - m_ShieldToStencilProgram->Link(); - GLERROR("Creating Shield program"); - - m_ShieldToStencilSkinnedProgram = ResourceManager::Load("#ShieldToStencilProgramSkinned"); - m_ShieldToStencilSkinnedProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/ShieldStencilSkinned.vert.glsl"))); - m_ShieldToStencilSkinnedProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/ShieldStencil.frag.glsl"))); - m_ShieldToStencilSkinnedProgram->Compile(); - m_ShieldToStencilSkinnedProgram->Link(); - GLERROR("Creating Shield Skinned program"); - - m_FillDepthBufferProgram = ResourceManager::Load("#FillDepthBufferProgram"); - m_FillDepthBufferProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/FillDepthBuffer.vert.glsl"))); - //m_FillDepthBufferProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/FillDepthBuffer.frag.glsl"))); - m_FillDepthBufferProgram->Compile(); - m_FillDepthBufferProgram->Link(); - GLERROR("Creating DepthFill program"); - - m_FillDepthBufferSkinnedProgram = ResourceManager::Load("#FillDepthBufferProgramSkinned"); - m_FillDepthBufferSkinnedProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/FillDepthBufferSkinned.vert.glsl"))); - //m_FillDepthBufferSkinnedProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/FillDepthBuffer.frag.glsl"))); - m_FillDepthBufferSkinnedProgram->Compile(); - m_FillDepthBufferSkinnedProgram->Link(); - GLERROR("Creating DepthFill program"); } void DrawFinalPass::Draw(RenderScene& scene) { GLERROR("Pre"); - DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle()); + DrawStencilState* stateDethp = new DrawStencilState(m_ShieldDepthFrameBuffer.GetHandle()); + //Draw shields to stencil + DrawToDepthStencilBuffer(scene.Jobs.ShieldObjects, scene); + GLERROR("StencilPass"); + delete stateDethp; + + + DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle()); if (scene.ClearDepth) { //glClear(GL_DEPTH_BUFFER_BIT); state->Disable(GL_DEPTH_TEST); + state->DepthMask(GL_FALSE); } //TODO: Do we need check for this or will it be per scene always? glClearStencil(0x00); glClear(GL_STENCIL_BUFFER_BIT); //Fill depth buffer - - state->StencilMask(0x00); - DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene); - GLERROR("OpaqueObjects"); - //state->BlendFunc(GL_ONE, GL_ONE); - state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - //state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene); - GLERROR("TransparentObjects"); - //state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - DrawSprites(scene.Jobs.SpriteJob, scene); - GLERROR("SpriteJobs"); - - //DrawStencilState* stencilState = new DrawStencilState(m_FinalPassFrameBuffer.GetHandle()); - //Draw shields to stencil pass - state->StencilFunc(GL_ALWAYS, 1, 0xFF); - state->StencilMask(0xFF); - DrawShieldToStencilBuffer(scene.Jobs.ShieldObjects, scene); - GLERROR("StencilPass"); + state->Enable(GL_STENCIL_TEST); + state->StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); + state->StencilFunc(GL_ALWAYS, 1, 0xFF); + state->StencilMask(0xFF); + state->DepthMask(GL_FALSE); + //DrawToDepthStencilBuffer(scene.Jobs.ShieldObjects, scene); + state->DepthMask(GL_TRUE); //Draw Opaque shielded objects + state->Disable(GL_STENCIL_TEST); state->StencilFunc(GL_NOTEQUAL, 1, 0xFF); state->StencilMask(0x00); - DrawModelRenderQueues(scene.Jobs.OpaqueShieldedObjects, scene); //might need changing + DrawModelRenderQueuesWithShieldCheck(scene.Jobs.OpaqueShieldedObjects, scene); //might need changing GLERROR("Shielded Opaque object"); + //Draw Opaque objects + //state->StencilMask(0x00); + DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene); + GLERROR("OpaqueObjects"); + + //state->Disable(GL_STENCIL_TEST); //Draw Transparen Shielded objects - DrawModelRenderQueues(scene.Jobs.TransparentShieldedObjects, scene); //might need changing + DrawModelRenderQueuesWithShieldCheck(scene.Jobs.TransparentObjects, scene); //might need changing GLERROR("Shielded Transparent objects"); + //Draw Transparen objects + //state->BlendFunc(GL_ONE, GL_ONE); + //state->StencilFunc(GL_EQUAL, 1, 0xFF); + state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + //DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene); + GLERROR("TransparentObjects"); + //state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + DrawSprites(scene.Jobs.SpriteJob, scene); + GLERROR("SpriteJobs"); + + delete state; GLERROR("END"); - delete state; - - - DrawFinalPassState* stateLowRes = new DrawFinalPassState(m_FinalPassFrameBufferLowRes.GetHandle()); - //Draw the lowres texture that will be shown behind the shield. - stateLowRes->Enable(GL_SCISSOR_TEST); - stateLowRes->Enable(GL_DEPTH_TEST); - //TODO: Viewports and scissor should be in state - glViewport(0, 0, m_Renderer->GetViewportSize().Width/m_ShieldPixelRate, m_Renderer->GetViewportSize().Height/m_ShieldPixelRate); - glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); - - glClearStencil(0x00); - glClear(GL_STENCIL_BUFFER_BIT); - - //TODO: This should not be here... - stateLowRes->StencilFunc(GL_ALWAYS, 1, 0xFF); - stateLowRes->StencilMask(0x00); - DrawToDepthBuffer(scene.Jobs.OpaqueObjects, scene); - DrawToDepthBuffer(scene.Jobs.TransparentObjects, scene); - - //Draw shields to stencil pass - stateLowRes->StencilFunc(GL_ALWAYS, 1, 0xFF); - stateLowRes->StencilMask(0xFF); - stateLowRes->Enable(GL_DEPTH_TEST); - DrawShieldToStencilBuffer(scene.Jobs.ShieldObjects, scene); - GLERROR("StencilPass"); - - //glClear(GL_DEPTH_BUFFER_BIT); - - stateLowRes->Enable(GL_DEPTH_TEST); - stateLowRes->StencilFunc(GL_LEQUAL, 1, 0xFF); - stateLowRes->StencilMask(0x00); - DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene); - GLERROR("OpaqueObjects"); - DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene); - GLERROR("TransparentObjects"); - glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); - glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); - delete stateLowRes; + } void DrawFinalPass::ClearBuffer() { GLERROR("PRE"); - m_FinalPassFrameBufferLowRes.Bind(); - GLERROR("Bind LowRes"); - - glViewport(0, 0, m_Renderer->GetViewportSize().Width/m_ShieldPixelRate, m_Renderer->GetViewportSize().Height/m_ShieldPixelRate); - glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); - GLERROR("ViewPort,Scissor LowRes"); - - glClearColor(0.f, 0.f, 0.f, 0.f); - GLERROR("1"); - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - GLERROR("2"); - - glDisable(GL_SCISSOR_TEST); - GLERROR("3"); - - m_FinalPassFrameBufferLowRes.Unbind(); - - GLERROR("prebind HighRes"); + m_ShieldDepthFrameBuffer.Bind(); + glClear(GL_DEPTH_BUFFER_BIT); + m_ShieldDepthFrameBuffer.Unbind(); m_FinalPassFrameBuffer.Bind(); GLERROR("Bind HighRes"); glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); GLERROR("ViewPort,Scissor LowRes"); glClearColor(0.f, 0.f, 0.f, 0.f); - glClear(GL_COLOR_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); m_FinalPassFrameBuffer.Unbind(); GLERROR("END"); } @@ -294,39 +316,25 @@ void DrawFinalPass::ClearBuffer() void DrawFinalPass::OnWindowResize() { //InitializeFrameBuffers(); - + CommonFunctions::GenerateTexture(&m_DepthBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST, + glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8); CommonFunctions::GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); CommonFunctions::GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); m_FinalPassFrameBuffer.Generate(); - - glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBufferLowRes); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, (int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)); - - CommonFunctions::GenerateTexture(&m_SceneTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), GL_RGB16F, GL_RGB, GL_FLOAT); - CommonFunctions::GenerateTexture(&m_BloomTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), GL_RGB16F, GL_RGB, GL_FLOAT); - m_FinalPassFrameBufferLowRes.Generate(); GLERROR("Error changing texture resolutions"); } void DrawFinalPass::DrawModelRenderQueues(std::list>& jobs, RenderScene& scene) { GLuint forwardHandle = m_ForwardPlusProgram->GetHandle(); - GLERROR("forwardHandle"); GLuint explosionHandle = m_ExplosionEffectProgram->GetHandle(); - GLERROR("explosionHandle"); GLuint explosionSplatMapHandle = m_ExplosionEffectSplatMapProgram->GetHandle(); - GLERROR("explosionSplatMapHandle"); - GLuint forwardSplatHandle = m_ForwardPlusSplatMapProgram->GetHandle(); - GLERROR("forwardSplatHandle"); + GLuint forwardSplatMapHandle = m_ForwardPlusSplatMapProgram->GetHandle(); GLuint forwardSkinnedHandle = m_ForwardPlusSkinnedProgram->GetHandle(); - GLERROR("forwardSkinnedHandle"); GLuint explosionSkinnedHandle = m_ExplosionEffectSkinnedProgram->GetHandle(); - GLERROR("explosionSkinnedHandle"); GLuint explosionSplatMapSkinnedHandle = m_ExplosionEffectSplatMapSkinnedProgram->GetHandle(); - GLERROR("explosionSplatMapSkinnedHandle"); GLuint forwardSplatMapSkinnedHandle = m_ForwardPlusSplatMapSkinnedProgram->GetHandle(); - GLERROR("forwardSplatSkinnedHandle"); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO()); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO()); @@ -340,71 +348,79 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& if (explosionEffectJob) { switch (explosionEffectJob->Type) { case RawModel::MaterialType::Basic: - case RawModel::MaterialType::SingleTextures: - { - if (explosionEffectJob->Model->IsSkinned()) { + case RawModel::MaterialType::SingleTextures: + { + if (explosionEffectJob->Model->IsSkinned()) { - m_ExplosionEffectSkinnedProgram->Bind(); - GLERROR("Bind ExplosionEffectSkinned program"); - //bind uniforms - BindExplosionUniforms(explosionSkinnedHandle, explosionEffectJob, scene); - //bind textures - BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob); - glActiveTexture(GL_TEXTURE5); - glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); - glUniform3fv(glGetUniformLocation(explosionSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + m_ExplosionEffectSkinnedProgram->Bind(); + GLERROR("Bind ExplosionEffectSkinned program"); + //bind uniforms + BindExplosionUniforms(explosionSkinnedHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(explosionSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); - std::vector frameBones; - if (explosionEffectJob->AnimationOffset.animation != nullptr) { - frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); - } else { - frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); - } - glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); - } else { - m_ExplosionEffectProgram->Bind(); - GLERROR("Bind ExplosionEffect program"); - //bind uniforms - BindExplosionUniforms(explosionHandle, explosionEffectJob, scene); - //bind textures - BindExplosionTextures(explosionHandle, explosionEffectJob); - glActiveTexture(GL_TEXTURE5); - glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); - glUniform3fv(glGetUniformLocation(explosionHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + std::vector frameBones; + if (explosionEffectJob->AnimationOffset.animation != nullptr) { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); + } + else { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); + } + glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + DrawSkinnedExplosionSetup(m_ExplosionEffectSkinnedProgram, explosionSkinnedHandle, explosionEffectJob, scene); + } + else { + m_ExplosionEffectProgram->Bind(); + GLERROR("Bind ExplosionEffect program"); + //bind uniforms + BindExplosionUniforms(explosionHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionHandle, explosionEffectJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(explosionHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); - } - break; - } - case RawModel::MaterialType::SplatMapping: - { - if (explosionEffectJob->Model->IsSkinned()) { - m_ExplosionEffectSplatMapSkinnedProgram->Bind(); - GLERROR("Bind ExplosionEffectSplatMapSkinned program"); - //bind uniforms - BindExplosionUniforms(explosionSplatMapSkinnedHandle, explosionEffectJob, scene); - //bind textures - BindExplosionTextures(explosionSplatMapSkinnedHandle, explosionEffectJob); - GLERROR("asdasd"); - std::vector frameBones; - if (explosionEffectJob->AnimationOffset.animation != nullptr) { - frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); - } else { - frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); - } - glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + DrawExplosionSetup(m_ExplosionEffectProgram, explosionHandle, explosionEffectJob, scene); + } + break; + } + case RawModel::MaterialType::SplatMapping: + { + if (explosionEffectJob->Model->IsSkinned()) { + m_ExplosionEffectSplatMapSkinnedProgram->Bind(); + GLERROR("Bind ExplosionEffectSplatMapSkinned program"); + //bind uniforms + BindExplosionUniforms(explosionSplatMapSkinnedHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionSplatMapSkinnedHandle, explosionEffectJob); + GLERROR("asdasd"); + std::vector frameBones; + if (explosionEffectJob->AnimationOffset.animation != nullptr) { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); + } + else { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); + } + glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); - } else { - m_ExplosionEffectSplatMapProgram->Bind(); - GLERROR("Bind ExplosionEffectSplatMap program"); - //bind uniforms - //bind uniforms - BindExplosionUniforms(explosionSplatMapHandle, explosionEffectJob, scene); - //bind textures - BindExplosionTextures(explosionSplatMapHandle, explosionEffectJob); - GLERROR("asdasd"); - } - break; - } + DrawSkinnedExplosionSetup(m_ExplosionEffectSplatMapSkinnedProgram, explosionSplatMapSkinnedHandle, explosionEffectJob, scene); + } + else { + m_ExplosionEffectSplatMapProgram->Bind(); + GLERROR("Bind ExplosionEffectSplatMap program"); + //bind uniforms + //bind uniforms + BindExplosionUniforms(explosionSplatMapHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionSplatMapHandle, explosionEffectJob); + GLERROR("asdasd"); + DrawExplosionSetup(m_ExplosionEffectSplatMapProgram, explosionSplatMapHandle, explosionEffectJob, scene); + } + break; + } } glDisable(GL_CULL_FACE); @@ -414,132 +430,409 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& glDrawElements(GL_TRIANGLES, explosionEffectJob->EndIndex - explosionEffectJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(explosionEffectJob->StartIndex*sizeof(unsigned int))); glEnable(GL_CULL_FACE); GLERROR("explosion effect end"); - } else { - auto modelJob = std::dynamic_pointer_cast(job); - if (modelJob) { - //bind forward program - //TODO: JOHAN/TOBIAS: Bind shader based on ModelJob->ShaderID; - switch (modelJob->Type) { - case RawModel::MaterialType::Basic: - case RawModel::MaterialType::SingleTextures: - { - if (modelJob->Model->IsSkinned()) { - m_ForwardPlusSkinnedProgram->Bind(); - GLERROR("Bind ForwardPlusSkinnedProgram"); - //bind uniforms - BindModelUniforms(forwardSkinnedHandle, modelJob, scene); - //bind textures - BindModelTextures(forwardSkinnedHandle, modelJob); - glActiveTexture(GL_TEXTURE5); - glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); - glUniform3fv(glGetUniformLocation(forwardSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + } else { + auto modelJob = std::dynamic_pointer_cast(job); + if (modelJob) { + //bind forward program + //TODO: JOHAN/TOBIAS: Bind shader based on ModelJob->ShaderID; + switch (modelJob->Type) { + case RawModel::MaterialType::Basic: + case RawModel::MaterialType::SingleTextures: + { + if (modelJob->Model->IsSkinned()) { + m_ForwardPlusSkinnedProgram->Bind(); + GLERROR("Bind ForwardPlusSkinnedProgram"); + //bind uniforms + BindModelUniforms(forwardSkinnedHandle, modelJob, scene); + //bind textures + BindModelTextures(forwardSkinnedHandle, modelJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(forwardSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); - std::vector frameBones; - if (modelJob->AnimationOffset.animation != nullptr) { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); - } else { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); - } - glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + std::vector frameBones; + if (modelJob->AnimationOffset.animation != nullptr) { + frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); + } + else { + frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); + } + glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); - } else { - m_ForwardPlusProgram->Bind(); - GLERROR("Bind ForwardPlusProgram"); - //bind uniforms - BindModelUniforms(forwardHandle, modelJob, scene); - //bind textures - BindModelTextures(forwardHandle, modelJob); - glActiveTexture(GL_TEXTURE5); - glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); - glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); - } - break; - } - case RawModel::MaterialType::SplatMapping: - { - if (modelJob->Model->IsSkinned()) { - m_ForwardPlusSplatMapSkinnedProgram->Bind(); - GLERROR("Bind SplatMap program"); - //bind uniforms - BindModelUniforms(forwardSplatMapSkinnedHandle, modelJob, scene); - //bind textures - BindModelTextures(forwardSplatMapSkinnedHandle, modelJob); - GLERROR("asdasd"); - std::vector frameBones; - if (modelJob->AnimationOffset.animation != nullptr) { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); - } else { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); - } - glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } + else { + m_ForwardPlusProgram->Bind(); + GLERROR("Bind ForwardPlusProgram"); + //bind uniforms + BindModelUniforms(forwardHandle, modelJob, scene); + //bind textures + BindModelTextures(forwardHandle, modelJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + } + break; + } + case RawModel::MaterialType::SplatMapping: + { + if (modelJob->Model->IsSkinned()) { + m_ForwardPlusSplatMapSkinnedProgram->Bind(); + GLERROR("Bind SplatMap program"); + //bind uniforms + BindModelUniforms(forwardSplatMapSkinnedHandle, modelJob, scene); + //bind textures + BindModelTextures(forwardSplatMapSkinnedHandle, modelJob); + GLERROR("asdasd"); + std::vector frameBones; + if (modelJob->AnimationOffset.animation != nullptr) { + frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); + } + else { + frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); + } + glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); - } else { - m_ForwardPlusSplatMapProgram->Bind(); - GLERROR("Bind SplatMap program"); - //bind uniforms - BindModelUniforms(forwardSplatHandle, modelJob, scene); - //bind textures - BindModelTextures(forwardSplatHandle, modelJob); - GLERROR("asdasd"); - } - break; - } - } - //draw - 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))); - if (GLERROR("models end")) { - continue; - } + } + else { + m_ForwardPlusSplatMapProgram->Bind(); + GLERROR("Bind SplatMap program"); + //bind uniforms + BindModelUniforms(forwardSplatMapHandle, modelJob, scene); + //bind textures + BindModelTextures(forwardSplatMapHandle, modelJob); + GLERROR("asdasd"); + } + break; + } } - } - } -} - - -void DrawFinalPass::DrawShieldToStencilBuffer(std::list>& jobs, RenderScene& scene) -{ - - - for (auto &job : jobs) { - auto modelJob = std::dynamic_pointer_cast(job); - if (modelJob) { - - if(modelJob->Model->IsSkinned()) { - m_ShieldToStencilSkinnedProgram->Bind(); - GLuint shaderHandle = m_ShieldToStencilSkinnedProgram->GetHandle(); - - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->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())); - std::vector frameBones; - if (modelJob->AnimationOffset.animation != nullptr) { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); - } else { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); + //draw + 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))); + if (GLERROR("models end")) { + continue; } - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); - } else { - m_ShieldToStencilProgram->Bind(); - GLuint shaderHandle = m_ShieldToStencilProgram->GetHandle(); - - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->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())); - - } - - 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))); - if (GLERROR("models end")) { - continue; } } } } +void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list>& jobs, RenderScene& scene) +{ + GLuint forwardHandle = m_ForwardPlusProgram->GetHandle(); + GLuint explosionHandle = m_ExplosionEffectProgram->GetHandle(); + GLuint explosionSplatMapHandle = m_ExplosionEffectSplatMapProgram->GetHandle(); + GLuint forwardSplatMapHandle = m_ForwardPlusSplatMapProgram->GetHandle(); + GLuint forwardSkinnedHandle = m_ForwardPlusSkinnedProgram->GetHandle(); + GLuint explosionSkinnedHandle = m_ExplosionEffectSkinnedProgram->GetHandle(); + GLuint explosionSplatMapSkinnedHandle = m_ExplosionEffectSplatMapSkinnedProgram->GetHandle(); + GLuint forwardSplatMapSkinnedHandle = m_ForwardPlusSplatMapSkinnedProgram->GetHandle(); + + GLuint forwardShieldCheckHandle = m_ForwardPlusShieldCheckProgram->GetHandle(); + GLuint explosionShieldCheckHandle = m_ExplosionEffectShieldCheckProgram->GetHandle(); + GLuint explosionSplatMapShieldCheckHandle = m_ExplosionEffectSplatMapShieldCheckProgram->GetHandle(); + GLuint forwardSplatShieldCheckHandle = m_ForwardPlusSplatMapShieldCheckProgram->GetHandle(); + GLuint forwardSkinnedShieldCheckHandle = m_ForwardPlusSkinnedShieldCheckProgram->GetHandle(); + GLuint explosionSkinnedShieldCheckHandle = m_ExplosionEffectSkinnedShieldCheckProgram->GetHandle(); + GLuint explosionSplatMapSkinnedShieldCheckHandle = m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->GetHandle(); + GLuint forwardSplatMapSkinnedShieldCheckHandle = m_ForwardPlusSplatMapSkinnedShieldCheckProgram->GetHandle(); + + glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO()); + glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO()); + glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO()); + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, m_SSAOPass->SSAOTexture()); + + glActiveTexture(GL_TEXTURE31); + glBindTexture(GL_TEXTURE_2D, m_ShieldBuffer); + + for (auto &job : jobs) { + auto explosionEffectJob = std::dynamic_pointer_cast(job); + if (explosionEffectJob) { + if (explosionEffectJob->IsShielded) { + switch (explosionEffectJob->Type) { + case RawModel::MaterialType::Basic: + case RawModel::MaterialType::SingleTextures: + { + if (explosionEffectJob->Model->IsSkinned()) { + + m_ExplosionEffectSkinnedShieldCheckProgram->Bind(); + GLERROR("Bind ExplosionEffectSkinned program"); + //bind uniforms + BindExplosionUniforms(explosionSkinnedShieldCheckHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionSkinnedShieldCheckHandle, explosionEffectJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(explosionSkinnedShieldCheckHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + + std::vector frameBones; + if (explosionEffectJob->AnimationOffset.animation != nullptr) { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); + } + else { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); + } + glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedShieldCheckHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } + else { + m_ExplosionEffectShieldCheckProgram->Bind(); + GLERROR("Bind ExplosionEffect program"); + //bind uniforms + BindExplosionUniforms(explosionShieldCheckHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionShieldCheckHandle, explosionEffectJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(explosionShieldCheckHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + + } + break; + } + case RawModel::MaterialType::SplatMapping: + { + if (explosionEffectJob->Model->IsSkinned()) { + m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->Bind(); + GLERROR("Bind ExplosionEffectSplatMapSkinned program"); + //bind uniforms + BindExplosionUniforms(explosionSplatMapSkinnedShieldCheckHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionSplatMapSkinnedShieldCheckHandle, explosionEffectJob); + GLERROR("asdasd"); + std::vector frameBones; + if (explosionEffectJob->AnimationOffset.animation != nullptr) { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); + } + else { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); + } + glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedShieldCheckHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + + } + else { + m_ExplosionEffectSplatMapShieldCheckProgram->Bind(); + GLERROR("Bind ExplosionEffectSplatMap program"); + //bind uniforms + //bind uniforms + BindExplosionUniforms(explosionSplatMapShieldCheckHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionSplatMapShieldCheckHandle, explosionEffectJob); + GLERROR("asdasd"); + } + break; + } + } + } + else { + switch (explosionEffectJob->Type) { + case RawModel::MaterialType::Basic: + case RawModel::MaterialType::SingleTextures: + { + if (explosionEffectJob->Model->IsSkinned()) { + DrawSkinnedExplosionSetup(m_ExplosionEffectSkinnedProgram, explosionSkinnedHandle, explosionEffectJob, scene); + } + else { + DrawExplosionSetup(m_ExplosionEffectProgram, explosionHandle, explosionEffectJob, scene); + } + break; + } + case RawModel::MaterialType::SplatMapping: + { + if (explosionEffectJob->Model->IsSkinned()) { + DrawSkinnedExplosionSetup(m_ExplosionEffectSplatMapSkinnedProgram, explosionSplatMapSkinnedHandle, explosionEffectJob, scene); + } + else { + DrawExplosionSetup(m_ExplosionEffectSplatMapProgram, explosionSplatMapHandle, explosionEffectJob, scene); + } + break; + } + } + } + glDisable(GL_CULL_FACE); + + //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); + GLERROR("explosion effect end"); + } else { + auto explosionEffectJob = std::dynamic_pointer_cast(job); + if (explosionEffectJob) { + switch (explosionEffectJob->Type) { + case RawModel::MaterialType::Basic: + case RawModel::MaterialType::SingleTextures: + { + if (explosionEffectJob->Model->IsSkinned()) { + + m_ExplosionEffectSkinnedProgram->Bind(); + GLERROR("Bind ExplosionEffectSkinned program"); + //bind uniforms + BindExplosionUniforms(explosionSkinnedHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(explosionSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + + std::vector frameBones; + if (explosionEffectJob->AnimationOffset.animation != nullptr) { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); + } + else { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); + } + glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + DrawSkinnedExplosionSetup(m_ExplosionEffectSkinnedProgram, explosionSkinnedHandle, explosionEffectJob, scene); + } + else { + m_ExplosionEffectProgram->Bind(); + GLERROR("Bind ExplosionEffect program"); + //bind uniforms + BindExplosionUniforms(explosionHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionHandle, explosionEffectJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(explosionHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + + DrawExplosionSetup(m_ExplosionEffectProgram, explosionHandle, explosionEffectJob, scene); + } + break; + } + case RawModel::MaterialType::SplatMapping: + { + if (explosionEffectJob->Model->IsSkinned()) { + m_ExplosionEffectSplatMapSkinnedProgram->Bind(); + GLERROR("Bind ExplosionEffectSplatMapSkinned program"); + //bind uniforms + BindExplosionUniforms(explosionSplatMapSkinnedHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionSplatMapSkinnedHandle, explosionEffectJob); + GLERROR("asdasd"); + std::vector frameBones; + if (explosionEffectJob->AnimationOffset.animation != nullptr) { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); + } + else { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); + } + glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + + DrawSkinnedExplosionSetup(m_ExplosionEffectSplatMapSkinnedProgram, explosionSplatMapSkinnedHandle, explosionEffectJob, scene); + } + else { + m_ExplosionEffectSplatMapProgram->Bind(); + GLERROR("Bind ExplosionEffectSplatMap program"); + //bind uniforms + //bind uniforms + BindExplosionUniforms(explosionSplatMapHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionSplatMapHandle, explosionEffectJob); + GLERROR("asdasd"); + DrawExplosionSetup(m_ExplosionEffectSplatMapProgram, explosionSplatMapHandle, explosionEffectJob, scene); + } + break; + } + } + glDisable(GL_CULL_FACE); + + //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); + GLERROR("explosion effect end"); + } + else { + auto modelJob = std::dynamic_pointer_cast(job); + if (modelJob) { + //bind forward program + //TODO: JOHAN/TOBIAS: Bind shader based on ModelJob->ShaderID; + switch (modelJob->Type) { + case RawModel::MaterialType::Basic: + case RawModel::MaterialType::SingleTextures: + { + if (modelJob->Model->IsSkinned()) { + m_ForwardPlusSkinnedProgram->Bind(); + GLERROR("Bind ForwardPlusSkinnedProgram"); + //bind uniforms + BindModelUniforms(forwardSkinnedHandle, modelJob, scene); + //bind textures + BindModelTextures(forwardSkinnedHandle, modelJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(forwardSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + + std::vector frameBones; + if (modelJob->AnimationOffset.animation != nullptr) { + frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); + } + else { + frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); + } + glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + + } + else { + m_ForwardPlusProgram->Bind(); + GLERROR("Bind ForwardPlusProgram"); + //bind uniforms + BindModelUniforms(forwardHandle, modelJob, scene); + //bind textures + BindModelTextures(forwardHandle, modelJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + } + break; + } + case RawModel::MaterialType::SplatMapping: + { + if (modelJob->Model->IsSkinned()) { + m_ForwardPlusSplatMapSkinnedProgram->Bind(); + GLERROR("Bind SplatMap program"); + //bind uniforms + BindModelUniforms(forwardSplatMapSkinnedHandle, modelJob, scene); + //bind textures + BindModelTextures(forwardSplatMapSkinnedHandle, modelJob); + GLERROR("asdasd"); + std::vector frameBones; + if (modelJob->AnimationOffset.animation != nullptr) { + frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); + } + else { + frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); + } + glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + + } + else { + m_ForwardPlusSplatMapProgram->Bind(); + GLERROR("Bind SplatMap program"); + //bind uniforms + BindModelUniforms(forwardSplatMapHandle, modelJob, scene); + //bind textures + BindModelTextures(forwardSplatMapHandle, modelJob); + GLERROR("asdasd"); + } + break; + } + } + //draw + 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))); + if (GLERROR("models end")) { + continue; + } + } + } + } + } +} + void DrawFinalPass::DrawShieldedModelRenderQueue(std::list>& jobs, RenderScene& scene) { GLuint forwardHandle = m_ForwardPlusProgram->GetHandle(); @@ -632,7 +925,7 @@ void DrawFinalPass::DrawShieldedModelRenderQueue(std::list>& jobs, RenderScene& scene) +void DrawFinalPass::DrawToDepthStencilBuffer(std::list>& jobs, RenderScene& scene) { @@ -640,8 +933,8 @@ void DrawFinalPass::DrawToDepthBuffer(std::list>& job auto modelJob = std::dynamic_pointer_cast(job); if(modelJob->Model->IsSkinned()) { - m_FillDepthBufferSkinnedProgram->Bind(); - GLuint shaderHandle = m_FillDepthBufferSkinnedProgram->GetHandle(); + m_FillDepthStencilBufferSkinnedProgram->Bind(); + GLuint shaderHandle = m_FillDepthStencilBufferSkinnedProgram->GetHandle(); 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())); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); @@ -655,8 +948,8 @@ void DrawFinalPass::DrawToDepthBuffer(std::list>& job glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } else { - m_FillDepthBufferProgram->Bind(); - GLuint shaderHandle = m_FillDepthBufferProgram->GetHandle(); + m_FillDepthStencilBufferProgram->Bind(); + GLuint shaderHandle = m_FillDepthStencilBufferProgram->GetHandle(); 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())); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); @@ -720,6 +1013,76 @@ void DrawFinalPass::DrawSprites(std::list>&jobs, Rend // m_SpriteProgram->Unbind(); } +void DrawFinalPass::DrawExplosionSetup(ShaderProgram* shader, GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) +{ + shader->Bind(); + GLERROR("Bind ExplosionEffect program"); + //bind uniforms + BindExplosionUniforms(shaderHandle, job, scene); + //bind textures + BindExplosionTextures(shaderHandle, job); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(shaderHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); +} + +void DrawFinalPass::DrawSkinnedExplosionSetup(ShaderProgram* shader, GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) +{ + shader->Bind(); + GLERROR("Bind ExplosionEffectSkinned program"); + //bind uniforms + BindExplosionUniforms(shaderHandle, job, scene); + //bind textures + BindExplosionTextures(shaderHandle, job); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(shaderHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + + std::vector frameBones; + if (job->AnimationOffset.animation != nullptr) { + frameBones = job->Skeleton->GetFrameBones(job->Animations, job->AnimationOffset); + } + else { + frameBones = job->Skeleton->GetFrameBones(job->Animations); + } + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); +} + +void DrawFinalPass::DrawModelSetup(ShaderProgram* shader, GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) +{ + m_ForwardPlusProgram->Bind(); + GLERROR("Bind ForwardPlusProgram"); + //bind uniforms + BindModelUniforms(shaderHandle, job, scene); + //bind textures + BindModelTextures(shaderHandle, job); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(shaderHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); +} + +void DrawFinalPass::DrawSkinnedModelSetup(ShaderProgram* shader, GLuint shaderHandle , std::shared_ptr& job, RenderScene& scene) +{ + shader->Bind(); + GLERROR("Bind ForwardPlusSkinnedProgram"); + //bind uniforms + BindModelUniforms(shaderHandle, job, scene); + //bind textures + BindModelTextures(shaderHandle, job); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(shaderHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + + std::vector frameBones; + if (job->AnimationOffset.animation != nullptr) { + frameBones = job->Skeleton->GetFrameBones(job->Animations, job->AnimationOffset); + } + else { + frameBones = job->Skeleton->GetFrameBones(job->Animations); + } + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); +} + void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) { glUniform1i(glGetUniformLocation(shaderHandle, "SSAOQuality"), m_SSAOPass->TextureQuality()); diff --git a/src/Engine/Rendering/DrawFinalPassState.cpp b/src/Engine/Rendering/DrawFinalPassState.cpp index 6e1e3473..62500fa5 100644 --- a/src/Engine/Rendering/DrawFinalPassState.cpp +++ b/src/Engine/Rendering/DrawFinalPassState.cpp @@ -8,13 +8,12 @@ DrawFinalPassState::DrawFinalPassState(GLuint frameBuffer) Enable(GL_BLEND); BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); Enable(GL_DEPTH_TEST); - DepthMask(GL_FALSE); - DepthFunc(GL_LEQUAL); + DepthMask(GL_TRUE); Enable(GL_CULL_FACE); - Enable(GL_STENCIL_TEST); - StencilFunc(GL_NOTEQUAL, 1, 0xFF); - StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); - StencilMask(0xFF); + // Enable(GL_STENCIL_TEST); + // StencilFunc(GL_NOTEQUAL, 1, 0xFF); + // StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); + // StencilMask(0xFF); ClearColor(glm::vec4(0.f, 0.f, 0.f, 0.f)); } @@ -26,11 +25,8 @@ DrawFinalPassState::~DrawFinalPassState() DrawStencilState::DrawStencilState(GLuint frameBuffer) { BindFramebuffer(frameBuffer); - Enable(GL_STENCIL_TEST); - StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); - StencilFunc(GL_ALWAYS, 1, 0xFF); - StencilMask(0xFF); Enable(GL_DEPTH_TEST); + DepthMask(GL_TRUE); ClearColor(glm::vec4(0.f)); } diff --git a/src/Engine/Rendering/PickingPass.cpp b/src/Engine/Rendering/PickingPass.cpp index fb58edf7..7b9e2498 100644 --- a/src/Engine/Rendering/PickingPass.cpp +++ b/src/Engine/Rendering/PickingPass.cpp @@ -23,11 +23,12 @@ void PickingPass::InitializeTextures() glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RG8, GL_RG, GL_UNSIGNED_BYTE); CommonFunctions::GenerateTexture(&m_DepthBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST, - glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8); + glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT); } void PickingPass::InitializeFrameBuffers() { + m_PickingBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthBuffer, GL_DEPTH_ATTACHMENT))); m_PickingBuffer.AddResource(std::shared_ptr(new Texture2D(&m_PickingTexture, GL_COLOR_ATTACHMENT0))); m_PickingBuffer.Generate(); diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index 7b0ea84f..a1f00c88 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -240,6 +240,8 @@ void RenderSystem::fillModels(RenderScene::Queues &Jobs) fillColor = (glm::vec4)fillComponent["Color"]; } + bool isShielded = m_World->HasComponent(cModel.EntityID, "Shielded") || m_World->HasComponent(cModel.EntityID, "Player"); + glm::mat4 modelMatrix = Transform::ModelMatrix(cModel.EntityID, m_World); //Loop through all materialgroups of a model for (auto matGroup : model->MaterialGroups()) { @@ -255,20 +257,19 @@ void RenderSystem::fillModels(RenderScene::Queues &Jobs) cModel, m_World, fillColor, - fillPercentage + fillPercentage, + isShielded )); if (m_World->HasComponent(cModel.EntityID, "Shield")){ explosionEffectJob->CalculateHash(); Jobs.ShieldObjects.push_back(explosionEffectJob); - } else if (m_World->HasComponent(cModel.EntityID, "Shielded") - || m_World->HasComponent(cModel.EntityID, "Player")) { - + } else if (isShielded) { if (explosionEffectJob->Color.a != 1.f || explosionEffectJob->EndColor.a != 1.f || explosionEffectJob->DiffuseColor.a != 1.f) { cModel["Transparent"] = true; } if (cModel["Transparent"]) { - Jobs.TransparentShieldedObjects.push_back(explosionEffectJob); + Jobs.TransparentObjects.push_back(explosionEffectJob); } else { explosionEffectJob->CalculateHash(); Jobs.OpaqueShieldedObjects.push_back(explosionEffectJob); @@ -294,20 +295,20 @@ void RenderSystem::fillModels(RenderScene::Queues &Jobs) cModel, m_World, fillColor, - fillPercentage + fillPercentage, + isShielded )); if (m_World->HasComponent(cModel.EntityID, "Shield")) { modelJob->CalculateHash(); Jobs.ShieldObjects.push_back(modelJob); - } else if (m_World->HasComponent(cModel.EntityID, "Shielded") - || m_World->HasComponent(cModel.EntityID, "Player")) { + } else if (isShielded) { if (modelJob->Color.a != 1.f || modelJob->DiffuseColor.a != 1.f) { cModel["Transparent"] = true; } if (cModel["Transparent"]) { - Jobs.TransparentShieldedObjects.push_back(modelJob); + Jobs.TransparentObjects.push_back(modelJob); } else { modelJob->CalculateHash(); Jobs.OpaqueShieldedObjects.push_back(modelJob); diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index e590cd97..3ce985b6 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -110,7 +110,7 @@ void Renderer::Draw(RenderFrame& frame) { GLERROR("PRE"); glBindFramebuffer(GL_FRAMEBUFFER, 0); - ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking\0Ambient Occlusion"); + ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0Gaussian\0Picking\0Ambient Occlusion"); ImGui::Combo("CubeMap", &m_CubeMapTexture, "Nevada(512)\0Sky(1024)"); if(m_CubeMapTexture == 0) { m_CubeMapPass->LoadTextures("Nevada"); @@ -174,7 +174,7 @@ void Renderer::Draw(RenderFrame& frame) if (m_DebugTextureToDraw == 0) { PerformanceTimer::StartTimer("Renderer-Color Correction Pass"); - m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture(), m_DrawFinalPass->SceneTextureLowRes(), m_DrawFinalPass->BloomTextureLowRes(), frame.Gamma, frame.Exposure); + m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture(), frame.Gamma, frame.Exposure); PerformanceTimer::StopTimer("Renderer-Color Correction Pass"); } @@ -186,18 +186,12 @@ void Renderer::Draw(RenderFrame& frame) m_DrawScreenQuadPass->Draw(m_DrawFinalPass->BloomTexture()); } if (m_DebugTextureToDraw == 3) { - m_DrawScreenQuadPass->Draw(m_DrawFinalPass->SceneTextureLowRes()); - } - if (m_DebugTextureToDraw == 4) { - m_DrawScreenQuadPass->Draw(m_DrawFinalPass->BloomTextureLowRes()); - } - if (m_DebugTextureToDraw == 5) { m_DrawScreenQuadPass->Draw(m_DrawBloomPass->GaussianTexture()); } - if (m_DebugTextureToDraw == 6) { + if (m_DebugTextureToDraw == 4) { m_DrawScreenQuadPass->Draw(m_PickingPass->PickingTexture()); } - if (m_DebugTextureToDraw == 7) { + if (m_DebugTextureToDraw == 5) { m_DrawScreenQuadPass->Draw(m_SSAOPass->SSAOTexture()); } PerformanceTimer::StopTimer("Renderer-Misc Debug Draws"); @@ -250,7 +244,7 @@ void Renderer::InitializeRenderPasses() m_LightCullingPass = new LightCullingPass(this); m_CubeMapPass = new CubeMapPass(this); m_SSAOPass = new SSAOPass(this, m_Config); - m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass, m_SSAOPass, m_PickingPass->DepthBuffer()); + m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass, m_SSAOPass); m_DrawScreenQuadPass = new DrawScreenQuadPass(this); m_DrawBloomPass = new DrawBloomPass(this, m_Config); m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this); From 96768e66de68b699ad802933ec70afefc84581ee Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 2 Mar 2016 09:57:41 +0100 Subject: [PATCH 120/252] Redplayer arrow fix --- resources/Schema/Entities/PlayerRed.xml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/resources/Schema/Entities/PlayerRed.xml b/resources/Schema/Entities/PlayerRed.xml index 7f81ab05..fab8e21e 100644 --- a/resources/Schema/Entities/PlayerRed.xml +++ b/resources/Schema/Entities/PlayerRed.xml @@ -13,7 +13,7 @@ - 361.81593010381596 + 384.13256760035051 @@ -373,7 +373,7 @@ Idle - 1.6231050125476969 + 0.75626404186195373 1 @@ -417,11 +417,15 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - + + + + + - + @@ -446,7 +450,7 @@ Idle - 1.8847063959212136 + 1.1511986314122282 1 From 5a6374f013f40ba8f78dfc33cc969ae711420c88 Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Wed, 2 Mar 2016 10:57:22 +0100 Subject: [PATCH 121/252] Fix the remainder of errors. Might have borked splatmap in the process. --- assets | 2 +- src/Engine/Editor/EditorSystem.cpp | 3 ++- src/Engine/Rendering/DrawFinalPass.cpp | 14 +++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/assets b/assets index 1d09801c..72530423 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 1d09801cf45452e082ad08bac5e29e3102f31724 +Subproject commit 72530423ad3744341f42cbfdcba18295a2cfac90 diff --git a/src/Engine/Editor/EditorSystem.cpp b/src/Engine/Editor/EditorSystem.cpp index e770c154..0aefac9d 100644 --- a/src/Engine/Editor/EditorSystem.cpp +++ b/src/Engine/Editor/EditorSystem.cpp @@ -18,7 +18,8 @@ EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame m_ActualCamera = m_EditorCamera; m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Transform"); auto cCamera = m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Camera"); - //(double&)cCamera["FarClip"] = 300.0; + // TOBIAS TVINGADE MIG ATT HÅRDKODA + (double&)cCamera["FarClip"] = 400.0; m_EditorCameraInputController = new EditorCameraInputController(m_EventBroker, -1); diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index ef930ca6..ac4fa8e4 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -368,6 +368,13 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, SSAOTexture); + glActiveTexture(GL_TEXTURE6); + if (m_ShadowPass->DepthMap() != NULL) { + glBindTexture(GL_TEXTURE_2D_ARRAY, m_ShadowPass->DepthMap()); + } + else { + glBindTexture(GL_TEXTURE_2D_ARRAY, m_WhiteTexture->m_Texture); + } for (auto &job : jobs) { auto explosionEffectJob = std::dynamic_pointer_cast(job); @@ -1017,13 +1024,6 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptrDepthMap() != NULL) { - glBindTexture(GL_TEXTURE_2D_ARRAY, m_ShadowPass->DepthMap()); - } - else { - glBindTexture(GL_TEXTURE_2D_ARRAY, m_WhiteTexture->m_Texture); - } break; } case RawModel::MaterialType::SplatMapping: From cfba8efd24bedf9c0469a1b35dcfd4b31c576e41 Mon Sep 17 00:00:00 2001 From: Jocke Date: Wed, 2 Mar 2016 10:59:03 +0100 Subject: [PATCH 122/252] WritePrimitive would spam a warning when snapshots got bigger than 512 and it got resized. --- include/Engine/Network/Packet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Engine/Network/Packet.h b/include/Engine/Network/Packet.h index b688b8c6..95419e10 100644 --- a/include/Engine/Network/Packet.h +++ b/include/Engine/Network/Packet.h @@ -24,7 +24,7 @@ public: { // Check if we are trying to add more than the package can fit. if (m_MaxPacketSize < m_Offset + sizeof(T)) { - LOG_WARNING("Packet AddPrimitive(): You are trying to add more than we have allocated for! New size is %i bytes\n", m_MaxPacketSize*2); + //LOG_WARNING("Packet AddPrimitive(): You are trying to add more than we have allocated for! New size is %i bytes\n", m_MaxPacketSize*2); resizeData(); } memcpy(m_Data + m_Offset, &val, sizeof(T)); From 4652cd786110419a7d6e42321e7ae3c64483d0cb Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Wed, 2 Mar 2016 11:53:04 +0100 Subject: [PATCH 123/252] Added the already-at-maxammo/health-save-trigger for the PickupSystems --- include/Game/Systems/AmmoPickupSystem.h | 9 ++ include/Game/Systems/PickupSpawnSystem.h | 9 +- src/Game/Systems/AmmoPickupSystem.cpp | 101 ++++++++++++++--------- src/Game/Systems/PickupSpawnSystem.cpp | 70 +++++++++++----- 4 files changed, 129 insertions(+), 60 deletions(-) diff --git a/include/Game/Systems/AmmoPickupSystem.h b/include/Game/Systems/AmmoPickupSystem.h index e4a6df59..7917e765 100644 --- a/include/Game/Systems/AmmoPickupSystem.h +++ b/include/Game/Systems/AmmoPickupSystem.h @@ -20,6 +20,9 @@ public: private: EventRelay m_ETriggerTouch; bool OnTriggerTouch(Events::TriggerTouch& e); + EventRelay m_ETriggerLeave; + bool OnTriggerLeave(Events::TriggerLeave& e); + EventRelay m_EAmmoPickup; bool OnAmmoPickup(Events::AmmoPickup& e); @@ -31,5 +34,11 @@ private: EntityID parentID; }; std::vector m_ETriggerTouchVector; + struct EntityAtMaxValuePickupStruct { + EntityWrapper player; + EntityWrapper trigger; + }; + std::vector m_PickupAtMaximum; + void DoPickup(EntityWrapper &player, EntityWrapper &trigger); }; #endif diff --git a/include/Game/Systems/PickupSpawnSystem.h b/include/Game/Systems/PickupSpawnSystem.h index 66c5f630..be99141c 100644 --- a/include/Game/Systems/PickupSpawnSystem.h +++ b/include/Game/Systems/PickupSpawnSystem.h @@ -9,7 +9,6 @@ #include "Core/EPlayerHealthPickup.h" #include "Engine/Collision/ETrigger.h" #include "Common.h" -#include class PickupSpawnSystem : public ImpureSystem { @@ -21,6 +20,8 @@ public: private: EventRelay m_ETriggerTouch; bool OnTriggerTouch(Events::TriggerTouch& e); + EventRelay m_ETriggerLeave; + bool OnTriggerLeave(Events::TriggerLeave& e); struct NewHealthPickup { glm::vec3 Pos; @@ -30,5 +31,11 @@ private: EntityID parentID; }; std::vector m_ETriggerTouchVector; + struct EntityAtMaxValuePickupStruct { + EntityWrapper player; + EntityWrapper trigger; + }; + std::vector m_PickupAtMaximum; + void DoPickup(EntityWrapper &player, EntityWrapper &trigger); }; #endif diff --git a/src/Game/Systems/AmmoPickupSystem.cpp b/src/Game/Systems/AmmoPickupSystem.cpp index 5927c495..6a24ee95 100644 --- a/src/Game/Systems/AmmoPickupSystem.cpp +++ b/src/Game/Systems/AmmoPickupSystem.cpp @@ -5,6 +5,7 @@ AmmoPickupSystem::AmmoPickupSystem(SystemParams params) { if (IsServer) { EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &AmmoPickupSystem::OnTriggerTouch); + EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &AmmoPickupSystem::OnTriggerLeave); } if (IsClient) { EVENT_SUBSCRIBE_MEMBER(m_EAmmoPickup, &AmmoPickupSystem::OnAmmoPickup); @@ -15,42 +16,47 @@ void AmmoPickupSystem::Update(double dt) { if (IsServer) { for (auto it = m_ETriggerTouchVector.begin(); it != m_ETriggerTouchVector.end(); ++it) { - auto& ammoPickupPosition = *it; - //set the double timer value (value 3) - ammoPickupPosition.DecreaseThisRespawnTimer -= dt; - if (ammoPickupPosition.DecreaseThisRespawnTimer < 0.0) { - //spawn and delete the vector item + auto& somePickup = *it; + somePickup.DecreaseThisRespawnTimer -= dt; + if (somePickup.DecreaseThisRespawnTimer < 0.0) { auto entityFile = ResourceManager::Load("Schema/Entities/AmmoPickup.xml"); EntityFileParser parser(entityFile); EntityID ammoPickupID = parser.MergeEntities(m_World); - //let the world know a pickup has spawned (graphics effects, etc) + //let the world know a pickup has spawned Events::PickupSpawned ePickupSpawned; ePickupSpawned.Pickup = EntityWrapper(m_World, ammoPickupID); m_EventBroker->Publish(ePickupSpawned); - //set values from the old entity to the new entity + //copy values from the old entity to the new entity auto& newAmmoPickupEntity = EntityWrapper(m_World, ammoPickupID); - newAmmoPickupEntity["Transform"]["Position"] = ammoPickupPosition.Pos; - newAmmoPickupEntity["AmmoPickup"]["AmmoGain"] = ammoPickupPosition.AmmoGain; - newAmmoPickupEntity["AmmoPickup"]["RespawnTimer"] = ammoPickupPosition.RespawnTimer; - m_World->SetParent(newAmmoPickupEntity.ID, ammoPickupPosition.parentID); + newAmmoPickupEntity["Transform"]["Position"] = somePickup.Pos; + newAmmoPickupEntity["AmmoPickup"]["AmmoGain"] = somePickup.AmmoGain; + newAmmoPickupEntity["AmmoPickup"]["RespawnTimer"] = somePickup.RespawnTimer; + m_World->SetParent(newAmmoPickupEntity.ID, somePickup.parentID); - //erase the current element (AmmoPickupPosition) + //erase the current element (somePickup) m_ETriggerTouchVector.erase(it); break; } } + //still touching m_PickupAtMaximum? + for (auto& it = m_PickupAtMaximum.begin(); it != m_PickupAtMaximum.end(); ++it) { + if (!it->player.Valid()) { + m_PickupAtMaximum.erase(it); + break; + } + if ((int)it->player["AssaultWeapon"]["Ammo"] < (int)it->player["AssaultWeapon"]["MaxAmmo"]) { + DoPickup(it->player, it->trigger); + m_PickupAtMaximum.erase(it); + break; + } + } } } - bool AmmoPickupSystem::OnTriggerTouch(Events::TriggerTouch& e) { - /*if (e.Entity != LocalPlayer) { - return false; - }*/ - if (!e.Entity.Valid()) { return false; } @@ -61,30 +67,13 @@ bool AmmoPickupSystem::OnTriggerTouch(Events::TriggerTouch& e) if (!e.Trigger.HasComponent("AmmoPickup")) { return false; } - int maxWeaponAmmo = (int)e.Entity["AssaultWeapon"]["MaxAmmo"]; - int& currentAmmo = (int)e.Entity["AssaultWeapon"]["Ammo"]; - int ammoGiven = 0.01*(double)e.Trigger["AmmoPickup"]["AmmoGain"] * maxWeaponAmmo; - //cant pick up ammopacks if you are already at MaxAmmo - if (currentAmmo >= maxWeaponAmmo) { + //if at maxammo, save the trigger-touch to a vector since standing inside it will not re-trigger the trigger + if ((int)e.Entity["AssaultWeapon"]["Ammo"] >= (int)e.Entity["AssaultWeapon"]["MaxAmmo"]) { + m_PickupAtMaximum.push_back({ e.Entity, e.Trigger }); return false; } - - //personEntered = e.Entity, thingEntered = e.Trigger - Events::AmmoPickup ePlayerAmmoPickup; - ePlayerAmmoPickup.AmmoGain = ammoGiven; - ePlayerAmmoPickup.Player = e.Entity; - m_EventBroker->Publish(ePlayerAmmoPickup); - //immediately give the player the ammo - //currentAmmo = std::min(currentAmmo + ammoGiven, maxWeaponAmmo); - - //copy position, ammogain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object) - //we need to copy all values since each value can be different for each ammoPickup - m_ETriggerTouchVector.push_back({ e.Trigger["Transform"]["Position"], e.Trigger["AmmoPickup"]["AmmoGain"], - e.Trigger["AmmoPickup"]["RespawnTimer"], e.Trigger["AmmoPickup"]["RespawnTimer"], m_World->GetParent(e.Trigger.ID) }); - - //delete the ammopickup - m_World->DeleteEntity(e.Trigger.ID); + DoPickup(e.Entity, e.Trigger); return true; } @@ -107,3 +96,39 @@ bool AmmoPickupSystem::OnAmmoPickup(Events::AmmoPickup & e) currentAmmo = std::min(currentAmmo + e.AmmoGain, maxWeaponAmmo); return false; } + +bool AmmoPickupSystem::OnTriggerLeave(Events::TriggerLeave& e) { + if (!e.Trigger.HasComponent("AmmoPickup")) { + return false; + } + //triggerleave erases possible m_PickupAtMaximum + for (auto& it = m_PickupAtMaximum.begin(); it != m_PickupAtMaximum.end(); ++it) { + if (it->trigger.ID == e.Trigger.ID && it->player.ID == e.Entity.ID) { + m_PickupAtMaximum.erase(it); + break; + } + } + return true; +} + +void AmmoPickupSystem::DoPickup(EntityWrapper &player, EntityWrapper &trigger) { + int maxWeaponAmmo = (int)player["AssaultWeapon"]["MaxAmmo"]; + int& currentAmmo = (int)player["AssaultWeapon"]["Ammo"]; + int ammoGiven = 0.01*(double)trigger["AmmoPickup"]["AmmoGain"] * maxWeaponAmmo; + + Events::AmmoPickup ePlayerAmmoPickup; + ePlayerAmmoPickup.AmmoGain = ammoGiven; + ePlayerAmmoPickup.Player = player; + m_EventBroker->Publish(ePlayerAmmoPickup); + + //immediately give the player the ammo (on server) + currentAmmo = std::min(currentAmmo + ammoGiven, maxWeaponAmmo); + + //copy position, ammogain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object) + //we need to copy all values since each value can be different for each ammoPickup + m_ETriggerTouchVector.push_back({ (glm::vec3)trigger["Transform"]["Position"], trigger["AmmoPickup"]["AmmoGain"], + trigger["AmmoPickup"]["RespawnTimer"], trigger["AmmoPickup"]["RespawnTimer"], m_World->GetParent(trigger.ID) }); + + //delete the ammopickup + m_World->DeleteEntity(trigger.ID); +} diff --git a/src/Game/Systems/PickupSpawnSystem.cpp b/src/Game/Systems/PickupSpawnSystem.cpp index 94fee4c6..6bfd2ee6 100644 --- a/src/Game/Systems/PickupSpawnSystem.cpp +++ b/src/Game/Systems/PickupSpawnSystem.cpp @@ -5,6 +5,7 @@ PickupSpawnSystem::PickupSpawnSystem(SystemParams params) { if (IsServer) { EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &PickupSpawnSystem::OnTriggerTouch); + EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &PickupSpawnSystem::OnTriggerLeave); } } @@ -12,11 +13,10 @@ void PickupSpawnSystem::Update(double dt) { if (IsServer) { for (auto it = m_ETriggerTouchVector.begin(); it != m_ETriggerTouchVector.end(); ++it) { - auto& healthPickupPosition = *it; - //set the double timer value (value 3) - healthPickupPosition.DecreaseThisRespawnTimer -= dt; - if (healthPickupPosition.DecreaseThisRespawnTimer < 0) { - //spawn and delete the vector item + auto& somePickup = *it; + somePickup.DecreaseThisRespawnTimer -= dt; + if (somePickup.DecreaseThisRespawnTimer < 0.0) { + //spawn the new healthPickup auto entityFile = ResourceManager::Load("Schema/Entities/HealthPickup.xml"); EntityFileParser parser(entityFile); EntityID healthPickupID = parser.MergeEntities(m_World); @@ -26,45 +26,73 @@ void PickupSpawnSystem::Update(double dt) ePickupSpawned.Pickup = EntityWrapper(m_World, healthPickupID); m_EventBroker->Publish(ePickupSpawned); - //set values from the old entity to the new entity + //copy values from the old entity to the new entity auto& newHealthPickupEntity = EntityWrapper(m_World, healthPickupID); - newHealthPickupEntity["Transform"]["Position"] = healthPickupPosition.Pos; - newHealthPickupEntity["HealthPickup"]["HealthGain"] = healthPickupPosition.HealthGain; - newHealthPickupEntity["HealthPickup"]["RespawnTimer"] = healthPickupPosition.RespawnTimer; - m_World->SetParent(newHealthPickupEntity.ID, healthPickupPosition.parentID); + newHealthPickupEntity["Transform"]["Position"] = somePickup.Pos; + newHealthPickupEntity["HealthPickup"]["HealthGain"] = somePickup.HealthGain; + newHealthPickupEntity["HealthPickup"]["RespawnTimer"] = somePickup.RespawnTimer; + m_World->SetParent(newHealthPickupEntity.ID, somePickup.parentID); - //erase the current element (healthPickupPosition) + //erase the current element (somePickup) m_ETriggerTouchVector.erase(it); break; } } + //still touching PickupAtMaximum? + for (auto& it = m_PickupAtMaximum.begin(); it != m_PickupAtMaximum.end(); ++it) { + if (!it->player.Valid()) { + m_PickupAtMaximum.erase(it); + break; + } + if ((double)it->player["Health"]["Health"] < (double)it->player["Health"]["MaxHealth"]) { + DoPickup(it->player, it->trigger); + m_PickupAtMaximum.erase(it); + break; + } + } } } - - bool PickupSpawnSystem::OnTriggerTouch(Events::TriggerTouch& e) { if (!e.Trigger.HasComponent("HealthPickup")) { return false; } - double healthGiven = 0.01*(double)e.Trigger["HealthPickup"]["HealthGain"] * (double)e.Entity["Health"]["MaxHealth"]; - //cant pick up healthpacks if you are already at MaxHealth + //if at maxhealth, save the trigger-touch to a vector since standing inside it will not re-trigger the trigger if ((double)e.Entity["Health"]["Health"] >= (double)e.Entity["Health"]["MaxHealth"]) { + m_PickupAtMaximum.push_back({ e.Entity, e.Trigger }); return false; } - //personEntered = e.Entity, thingEntered = e.Trigger + DoPickup(e.Entity, e.Trigger); + return true; +} +bool PickupSpawnSystem::OnTriggerLeave(Events::TriggerLeave& e) { + if (!e.Trigger.HasComponent("HealthPickup")) { + return false; + } + //triggerleave erases possible m_PickupAtMaximum + for (auto& it = m_PickupAtMaximum.begin(); it != m_PickupAtMaximum.end(); ++it) { + if (it->trigger.ID == e.Trigger.ID && it->player.ID == e.Entity.ID) { + m_PickupAtMaximum.erase(it); + break; + } + } + return true; +} +void PickupSpawnSystem::DoPickup(EntityWrapper &player, EntityWrapper &trigger) { + double healthGiven = 0.01*(double)trigger["HealthPickup"]["HealthGain"] * (double)player["Health"]["MaxHealth"]; + + //only the server will increase the players hp and set it in the next delta Events::PlayerHealthPickup ePlayerHealthPickup; ePlayerHealthPickup.HealthAmount = healthGiven; - ePlayerHealthPickup.Player = e.Entity; + ePlayerHealthPickup.Player = player; m_EventBroker->Publish(ePlayerHealthPickup); //copy position, healthgain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object) //we need to copy all values since each value can be different for each healthPickup - m_ETriggerTouchVector.push_back({ (glm::vec3)e.Trigger["Transform"]["Position"], e.Trigger["HealthPickup"]["HealthGain"], - e.Trigger["HealthPickup"]["RespawnTimer"], e.Trigger["HealthPickup"]["RespawnTimer"], m_World->GetParent(e.Trigger.ID) }); + m_ETriggerTouchVector.push_back({ (glm::vec3)trigger["Transform"]["Position"] ,trigger["HealthPickup"]["HealthGain"], + trigger["HealthPickup"]["RespawnTimer"],trigger["HealthPickup"]["RespawnTimer"], m_World->GetParent(trigger.ID) }); //delete the healthpickup - m_World->DeleteEntity(e.Trigger.ID); - return true; + m_World->DeleteEntity(trigger.ID); } From de9657700b1f0aed3ed42eab5724a5cc17a9b792 Mon Sep 17 00:00:00 2001 From: Teejoon Date: Wed, 2 Mar 2016 11:59:48 +0100 Subject: [PATCH 124/252] Fixed draw final pass with shided objects having to many if-statments. Shields is working with transparancy Player cameras should have nearclip fater away and far clip nearer. Defaultconfig push --- include/Engine/Rendering/DrawFinalPass.h | 6 - resources/DefaultConfig.ini | 16 +- resources/Schema/Entities/Player.xml | 43 +- resources/Schema/Entities/PlayerRed.xml | 43 +- src/Engine/Rendering/DrawFinalPass.cpp | 676 +++++++++----------- src/Engine/Rendering/DrawFinalPassState.cpp | 1 + 6 files changed, 380 insertions(+), 405 deletions(-) diff --git a/include/Engine/Rendering/DrawFinalPass.h b/include/Engine/Rendering/DrawFinalPass.h index 3b83d52f..cfddd5c6 100644 --- a/include/Engine/Rendering/DrawFinalPass.h +++ b/include/Engine/Rendering/DrawFinalPass.h @@ -38,12 +38,6 @@ private: void DrawShieldedModelRenderQueue(std::list>& jobs, RenderScene& scene); void DrawToDepthStencilBuffer(std::list>& jobs, RenderScene& scene); - void DrawExplosionSetup(ShaderProgram* shader, GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene); - void DrawSkinnedExplosionSetup(ShaderProgram* shader, GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene); - - void DrawModelSetup(ShaderProgram* shader, GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene); - void DrawSkinnedModelSetup(ShaderProgram* shader, GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene); - void BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene); void BindModelUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene); diff --git a/resources/DefaultConfig.ini b/resources/DefaultConfig.ini index d4696bba..e99e3437 100644 --- a/resources/DefaultConfig.ini +++ b/resources/DefaultConfig.ini @@ -68,5 +68,17 @@ Contrast=1.5 Intensity=1.0 NumSamples=24 NumTurns=17 -NumIterations=13 -TextureQuality=0 \ No newline at end of file +NumIterations=9 +TextureQuality=0 + +[GLOW] +Quality=3; + +[GLOW1] +NumIterations=5 + +[GLOW2] +NumIterations=9 + +[GLOW3] +NumIterations=13 \ No newline at end of file diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 88f153ae..28ace561 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -13,7 +13,7 @@ - 1.6944730461160304 + 52.867678870419283 @@ -37,7 +37,10 @@ - + + 0.10000000149011612 + 300 + @@ -372,7 +375,7 @@ Idle - 0.67172915251515519 + 1.9408570429715581 1 @@ -386,25 +389,25 @@ + + DefenderWeapon + Schema/Entities/DefenderWeaponView.xml - - DefenderWeapon - + + AssaultWeapon + Schema/Entities/AssaultWeaponView.xml - - AssaultWeapon - @@ -414,7 +417,10 @@ - + + 0.10000000149011612 + 300 + Models/Widgets/Camera.mesh false @@ -430,6 +436,7 @@ Idle + 1.5631122524686134 1 @@ -449,31 +456,31 @@ - - Schema/Entities/DefenderWeaponWorld.xml - - DefenderWeapon + + Schema/Entities/DefenderWeaponWorld.xml + + - - Schema/Entities/AssaultWeaponWorld.xml - - AssaultWeapon + + Schema/Entities/AssaultWeaponWorld.xml + + diff --git a/resources/Schema/Entities/PlayerRed.xml b/resources/Schema/Entities/PlayerRed.xml index 3cf17558..c46b9d79 100644 --- a/resources/Schema/Entities/PlayerRed.xml +++ b/resources/Schema/Entities/PlayerRed.xml @@ -13,7 +13,7 @@ - 1.6944730461160304 + 22.22055262342397 @@ -37,7 +37,10 @@ - + + 0.10000000149011612 + 300 + @@ -372,7 +375,7 @@ Idle - 0.67172915251515519 + 1.1978087298230946 1 @@ -386,25 +389,25 @@ + + DefenderWeapon + Schema/Entities/DefenderWeaponViewRed.xml - - DefenderWeapon - + + AssaultWeapon + Schema/Entities/AssaultWeaponView.xml - - AssaultWeapon - @@ -414,7 +417,10 @@ - + + 0.10000000149011612 + 300 + Models/Widgets/Camera.mesh false @@ -430,6 +436,7 @@ Idle + 0.69274608502888668 1 @@ -449,31 +456,31 @@ - - Schema/Entities/DefenderWeaponWorldRed.xml - - DefenderWeapon + + Schema/Entities/DefenderWeaponWorldRed.xml + + - - Schema/Entities/AssaultWeaponWorld.xml - - AssaultWeapon + + Schema/Entities/AssaultWeaponWorld.xml + + diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 16c154e3..6cdf42d1 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -236,7 +236,7 @@ void DrawFinalPass::InitializeShaderPrograms() void DrawFinalPass::Draw(RenderScene& scene) { GLERROR("Pre"); - DrawStencilState* stateDethp = new DrawStencilState(m_ShieldDepthFrameBuffer.GetHandle()); + DrawFinalPassState* stateDethp = new DrawFinalPassState(m_ShieldDepthFrameBuffer.GetHandle()); //Draw shields to stencil DrawToDepthStencilBuffer(scene.Jobs.ShieldObjects, scene); GLERROR("StencilPass"); @@ -276,13 +276,13 @@ void DrawFinalPass::Draw(RenderScene& scene) //state->Disable(GL_STENCIL_TEST); //Draw Transparen Shielded objects + state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); DrawModelRenderQueuesWithShieldCheck(scene.Jobs.TransparentObjects, scene); //might need changing GLERROR("Shielded Transparent objects"); //Draw Transparen objects //state->BlendFunc(GL_ONE, GL_ONE); //state->StencilFunc(GL_EQUAL, 1, 0xFF); - state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene); GLERROR("TransparentObjects"); //state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -349,78 +349,72 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& switch (explosionEffectJob->Type) { case RawModel::MaterialType::Basic: case RawModel::MaterialType::SingleTextures: - { - if (explosionEffectJob->Model->IsSkinned()) { + { + if (explosionEffectJob->Model->IsSkinned()) { - m_ExplosionEffectSkinnedProgram->Bind(); - GLERROR("Bind ExplosionEffectSkinned program"); - //bind uniforms - BindExplosionUniforms(explosionSkinnedHandle, explosionEffectJob, scene); - //bind textures - BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob); - glActiveTexture(GL_TEXTURE5); - glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); - glUniform3fv(glGetUniformLocation(explosionSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + m_ExplosionEffectSkinnedProgram->Bind(); + GLERROR("Bind ExplosionEffectSkinned program"); + //bind uniforms + BindExplosionUniforms(explosionSkinnedHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(explosionSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); - std::vector frameBones; - if (explosionEffectJob->AnimationOffset.animation != nullptr) { - frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); + std::vector frameBones; + if (explosionEffectJob->AnimationOffset.animation != nullptr) { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); + } + else { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); + } + glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } else { - frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); + m_ExplosionEffectProgram->Bind(); + GLERROR("Bind ExplosionEffect program"); + //bind uniforms + BindExplosionUniforms(explosionHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionHandle, explosionEffectJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(explosionHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); } - glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); - DrawSkinnedExplosionSetup(m_ExplosionEffectSkinnedProgram, explosionSkinnedHandle, explosionEffectJob, scene); - } - else { - m_ExplosionEffectProgram->Bind(); - GLERROR("Bind ExplosionEffect program"); - //bind uniforms - BindExplosionUniforms(explosionHandle, explosionEffectJob, scene); - //bind textures - BindExplosionTextures(explosionHandle, explosionEffectJob); - glActiveTexture(GL_TEXTURE5); - glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); - glUniform3fv(glGetUniformLocation(explosionHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); - - DrawExplosionSetup(m_ExplosionEffectProgram, explosionHandle, explosionEffectJob, scene); - } - break; + break; } case RawModel::MaterialType::SplatMapping: - { - if (explosionEffectJob->Model->IsSkinned()) { - m_ExplosionEffectSplatMapSkinnedProgram->Bind(); - GLERROR("Bind ExplosionEffectSplatMapSkinned program"); - //bind uniforms - BindExplosionUniforms(explosionSplatMapSkinnedHandle, explosionEffectJob, scene); - //bind textures - BindExplosionTextures(explosionSplatMapSkinnedHandle, explosionEffectJob); - GLERROR("asdasd"); - std::vector frameBones; - if (explosionEffectJob->AnimationOffset.animation != nullptr) { - frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); + { + if (explosionEffectJob->Model->IsSkinned()) { + m_ExplosionEffectSplatMapSkinnedProgram->Bind(); + GLERROR("Bind ExplosionEffectSplatMapSkinned program"); + //bind uniforms + BindExplosionUniforms(explosionSplatMapSkinnedHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionSplatMapSkinnedHandle, explosionEffectJob); + GLERROR("asdasd"); + std::vector frameBones; + if (explosionEffectJob->AnimationOffset.animation != nullptr) { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); + } + else { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); + } + glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } else { - frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); + m_ExplosionEffectSplatMapProgram->Bind(); + GLERROR("Bind ExplosionEffectSplatMap program"); + //bind uniforms + //bind uniforms + BindExplosionUniforms(explosionSplatMapHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionSplatMapHandle, explosionEffectJob); + GLERROR("asdasd"); } - glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); - - DrawSkinnedExplosionSetup(m_ExplosionEffectSplatMapSkinnedProgram, explosionSplatMapSkinnedHandle, explosionEffectJob, scene); + break; } - else { - m_ExplosionEffectSplatMapProgram->Bind(); - GLERROR("Bind ExplosionEffectSplatMap program"); - //bind uniforms - //bind uniforms - BindExplosionUniforms(explosionSplatMapHandle, explosionEffectJob, scene); - //bind textures - BindExplosionTextures(explosionSplatMapHandle, explosionEffectJob); - GLERROR("asdasd"); - DrawExplosionSetup(m_ExplosionEffectSplatMapProgram, explosionSplatMapHandle, explosionEffectJob, scene); - } - break; - } } glDisable(GL_CULL_FACE); @@ -554,99 +548,145 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::listType) { case RawModel::MaterialType::Basic: case RawModel::MaterialType::SingleTextures: - { - if (explosionEffectJob->Model->IsSkinned()) { + { + if (explosionEffectJob->Model->IsSkinned()) { - m_ExplosionEffectSkinnedShieldCheckProgram->Bind(); - GLERROR("Bind ExplosionEffectSkinned program"); - //bind uniforms - BindExplosionUniforms(explosionSkinnedShieldCheckHandle, explosionEffectJob, scene); - //bind textures - BindExplosionTextures(explosionSkinnedShieldCheckHandle, explosionEffectJob); - glActiveTexture(GL_TEXTURE5); - glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); - glUniform3fv(glGetUniformLocation(explosionSkinnedShieldCheckHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + m_ExplosionEffectSkinnedShieldCheckProgram->Bind(); + GLERROR("Bind ExplosionEffectSkinned program"); + //bind uniforms + BindExplosionUniforms(explosionSkinnedShieldCheckHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionSkinnedShieldCheckHandle, explosionEffectJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(explosionSkinnedShieldCheckHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); - std::vector frameBones; - if (explosionEffectJob->AnimationOffset.animation != nullptr) { - frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); + std::vector frameBones; + if (explosionEffectJob->AnimationOffset.animation != nullptr) { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); + } + else { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); + } + glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedShieldCheckHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } else { - frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); - } - glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedShieldCheckHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); - } - else { - m_ExplosionEffectShieldCheckProgram->Bind(); - GLERROR("Bind ExplosionEffect program"); - //bind uniforms - BindExplosionUniforms(explosionShieldCheckHandle, explosionEffectJob, scene); - //bind textures - BindExplosionTextures(explosionShieldCheckHandle, explosionEffectJob); - glActiveTexture(GL_TEXTURE5); - glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); - glUniform3fv(glGetUniformLocation(explosionShieldCheckHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + m_ExplosionEffectShieldCheckProgram->Bind(); + GLERROR("Bind ExplosionEffect program"); + //bind uniforms + BindExplosionUniforms(explosionShieldCheckHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionShieldCheckHandle, explosionEffectJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(explosionShieldCheckHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + } + break; } - break; - } case RawModel::MaterialType::SplatMapping: - { - if (explosionEffectJob->Model->IsSkinned()) { - m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->Bind(); - GLERROR("Bind ExplosionEffectSplatMapSkinned program"); - //bind uniforms - BindExplosionUniforms(explosionSplatMapSkinnedShieldCheckHandle, explosionEffectJob, scene); - //bind textures - BindExplosionTextures(explosionSplatMapSkinnedShieldCheckHandle, explosionEffectJob); - GLERROR("asdasd"); - std::vector frameBones; - if (explosionEffectJob->AnimationOffset.animation != nullptr) { - frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); + { + if (explosionEffectJob->Model->IsSkinned()) { + m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->Bind(); + GLERROR("Bind ExplosionEffectSplatMapSkinned program"); + //bind uniforms + BindExplosionUniforms(explosionSplatMapSkinnedShieldCheckHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionSplatMapSkinnedShieldCheckHandle, explosionEffectJob); + GLERROR("asdasd"); + std::vector frameBones; + if (explosionEffectJob->AnimationOffset.animation != nullptr) { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); + } + else { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); + } + glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedShieldCheckHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { - frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); + m_ExplosionEffectSplatMapShieldCheckProgram->Bind(); + GLERROR("Bind ExplosionEffectSplatMap program"); + //bind uniforms + //bind uniforms + BindExplosionUniforms(explosionSplatMapShieldCheckHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionSplatMapShieldCheckHandle, explosionEffectJob); + GLERROR("asdasd"); } - glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedShieldCheckHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); - + break; } - else { - m_ExplosionEffectSplatMapShieldCheckProgram->Bind(); - GLERROR("Bind ExplosionEffectSplatMap program"); - //bind uniforms - //bind uniforms - BindExplosionUniforms(explosionSplatMapShieldCheckHandle, explosionEffectJob, scene); - //bind textures - BindExplosionTextures(explosionSplatMapShieldCheckHandle, explosionEffectJob); - GLERROR("asdasd"); - } - break; } - } - } - else { + } else { switch (explosionEffectJob->Type) { case RawModel::MaterialType::Basic: case RawModel::MaterialType::SingleTextures: - { - if (explosionEffectJob->Model->IsSkinned()) { - DrawSkinnedExplosionSetup(m_ExplosionEffectSkinnedProgram, explosionSkinnedHandle, explosionEffectJob, scene); + { + if (explosionEffectJob->Model->IsSkinned()) { + + m_ExplosionEffectSkinnedProgram->Bind(); + GLERROR("Bind ExplosionEffectSkinned program"); + //bind uniforms + BindExplosionUniforms(explosionSkinnedHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(explosionSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + + std::vector frameBones; + if (explosionEffectJob->AnimationOffset.animation != nullptr) { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); + } + else { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); + } + glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } + else { + m_ExplosionEffectProgram->Bind(); + GLERROR("Bind ExplosionEffect program"); + //bind uniforms + BindExplosionUniforms(explosionHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionHandle, explosionEffectJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(explosionHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + } + break; } - else { - DrawExplosionSetup(m_ExplosionEffectProgram, explosionHandle, explosionEffectJob, scene); - } - break; - } case RawModel::MaterialType::SplatMapping: - { - if (explosionEffectJob->Model->IsSkinned()) { - DrawSkinnedExplosionSetup(m_ExplosionEffectSplatMapSkinnedProgram, explosionSplatMapSkinnedHandle, explosionEffectJob, scene); + { + if (explosionEffectJob->Model->IsSkinned()) { + m_ExplosionEffectSplatMapSkinnedProgram->Bind(); + GLERROR("Bind ExplosionEffectSplatMapSkinned program"); + //bind uniforms + BindExplosionUniforms(explosionSplatMapSkinnedHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionSplatMapSkinnedHandle, explosionEffectJob); + GLERROR("asdasd"); + std::vector frameBones; + if (explosionEffectJob->AnimationOffset.animation != nullptr) { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); + } + else { + frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); + } + glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } + else { + m_ExplosionEffectSplatMapProgram->Bind(); + GLERROR("Bind ExplosionEffectSplatMap program"); + //bind uniforms + //bind uniforms + BindExplosionUniforms(explosionSplatMapHandle, explosionEffectJob, scene); + //bind textures + BindExplosionTextures(explosionSplatMapHandle, explosionEffectJob); + GLERROR("asdasd"); + } + break; } - else { - DrawExplosionSetup(m_ExplosionEffectSplatMapProgram, explosionSplatMapHandle, explosionEffectJob, scene); - } - break; - } } } glDisable(GL_CULL_FACE); @@ -658,176 +698,160 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list(job); - if (explosionEffectJob) { - switch (explosionEffectJob->Type) { - case RawModel::MaterialType::Basic: - case RawModel::MaterialType::SingleTextures: - { - if (explosionEffectJob->Model->IsSkinned()) { - - m_ExplosionEffectSkinnedProgram->Bind(); - GLERROR("Bind ExplosionEffectSkinned program"); - //bind uniforms - BindExplosionUniforms(explosionSkinnedHandle, explosionEffectJob, scene); - //bind textures - BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob); - glActiveTexture(GL_TEXTURE5); - glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); - glUniform3fv(glGetUniformLocation(explosionSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); - - std::vector frameBones; - if (explosionEffectJob->AnimationOffset.animation != nullptr) { - frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); - } - else { - frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); - } - glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); - DrawSkinnedExplosionSetup(m_ExplosionEffectSkinnedProgram, explosionSkinnedHandle, explosionEffectJob, scene); - } - else { - m_ExplosionEffectProgram->Bind(); - GLERROR("Bind ExplosionEffect program"); - //bind uniforms - BindExplosionUniforms(explosionHandle, explosionEffectJob, scene); - //bind textures - BindExplosionTextures(explosionHandle, explosionEffectJob); - glActiveTexture(GL_TEXTURE5); - glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); - glUniform3fv(glGetUniformLocation(explosionHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); - - DrawExplosionSetup(m_ExplosionEffectProgram, explosionHandle, explosionEffectJob, scene); - } - break; - } - case RawModel::MaterialType::SplatMapping: - { - if (explosionEffectJob->Model->IsSkinned()) { - m_ExplosionEffectSplatMapSkinnedProgram->Bind(); - GLERROR("Bind ExplosionEffectSplatMapSkinned program"); - //bind uniforms - BindExplosionUniforms(explosionSplatMapSkinnedHandle, explosionEffectJob, scene); - //bind textures - BindExplosionTextures(explosionSplatMapSkinnedHandle, explosionEffectJob); - GLERROR("asdasd"); - std::vector frameBones; - if (explosionEffectJob->AnimationOffset.animation != nullptr) { - frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); - } - else { - frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); - } - glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); - - DrawSkinnedExplosionSetup(m_ExplosionEffectSplatMapSkinnedProgram, explosionSplatMapSkinnedHandle, explosionEffectJob, scene); - } - else { - m_ExplosionEffectSplatMapProgram->Bind(); - GLERROR("Bind ExplosionEffectSplatMap program"); - //bind uniforms - //bind uniforms - BindExplosionUniforms(explosionSplatMapHandle, explosionEffectJob, scene); - //bind textures - BindExplosionTextures(explosionSplatMapHandle, explosionEffectJob); - GLERROR("asdasd"); - DrawExplosionSetup(m_ExplosionEffectSplatMapProgram, explosionSplatMapHandle, explosionEffectJob, scene); - } - break; - } - } - glDisable(GL_CULL_FACE); - - //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); - GLERROR("explosion effect end"); - } - else { - auto modelJob = std::dynamic_pointer_cast(job); - if (modelJob) { - //bind forward program - //TODO: JOHAN/TOBIAS: Bind shader based on ModelJob->ShaderID; + auto modelJob = std::dynamic_pointer_cast(job); + if (modelJob) { + //bind forward program + //TODO: JOHAN/TOBIAS: Bind shader based on ModelJob->ShaderID; + if (modelJob->IsShielded) { switch (modelJob->Type) { case RawModel::MaterialType::Basic: case RawModel::MaterialType::SingleTextures: - { - if (modelJob->Model->IsSkinned()) { - m_ForwardPlusSkinnedProgram->Bind(); - GLERROR("Bind ForwardPlusSkinnedProgram"); - //bind uniforms - BindModelUniforms(forwardSkinnedHandle, modelJob, scene); - //bind textures - BindModelTextures(forwardSkinnedHandle, modelJob); - glActiveTexture(GL_TEXTURE5); - glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); - glUniform3fv(glGetUniformLocation(forwardSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + { + if (modelJob->Model->IsSkinned()) { + m_ForwardPlusSkinnedShieldCheckProgram->Bind(); + GLERROR("Bind ForwardPlusSkinnedProgram"); + //bind uniforms + BindModelUniforms(forwardSkinnedShieldCheckHandle, modelJob, scene); + //bind textures + BindModelTextures(forwardSkinnedShieldCheckHandle, modelJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(forwardSkinnedShieldCheckHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + + std::vector frameBones; + if (modelJob->AnimationOffset.animation != nullptr) { + frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); + } + else { + frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); + } + glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedShieldCheckHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); - std::vector frameBones; - if (modelJob->AnimationOffset.animation != nullptr) { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); } else { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); + m_ForwardPlusShieldCheckProgram->Bind(); + GLERROR("Bind ForwardPlusProgram"); + //bind uniforms + BindModelUniforms(forwardShieldCheckHandle, modelJob, scene); + //bind textures + BindModelTextures(forwardShieldCheckHandle, modelJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(forwardShieldCheckHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); } - glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); - + break; } - else { - m_ForwardPlusProgram->Bind(); - GLERROR("Bind ForwardPlusProgram"); - //bind uniforms - BindModelUniforms(forwardHandle, modelJob, scene); - //bind textures - BindModelTextures(forwardHandle, modelJob); - glActiveTexture(GL_TEXTURE5); - glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); - glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); - } - break; - } case RawModel::MaterialType::SplatMapping: - { - if (modelJob->Model->IsSkinned()) { - m_ForwardPlusSplatMapSkinnedProgram->Bind(); - GLERROR("Bind SplatMap program"); - //bind uniforms - BindModelUniforms(forwardSplatMapSkinnedHandle, modelJob, scene); - //bind textures - BindModelTextures(forwardSplatMapSkinnedHandle, modelJob); - GLERROR("asdasd"); - std::vector frameBones; - if (modelJob->AnimationOffset.animation != nullptr) { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); + { + if (modelJob->Model->IsSkinned()) { + m_ForwardPlusSplatMapSkinnedShieldCheckProgram->Bind(); + GLERROR("Bind SplatMap program"); + //bind uniforms + BindModelUniforms(forwardSplatMapSkinnedShieldCheckHandle, modelJob, scene); + //bind textures + BindModelTextures(forwardSplatMapSkinnedShieldCheckHandle, modelJob); + GLERROR("asdasd"); + std::vector frameBones; + if (modelJob->AnimationOffset.animation != nullptr) { + frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); + } + else { + frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); + } + glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedShieldCheckHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { - frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); + m_ForwardPlusSplatMapShieldCheckProgram->Bind(); + GLERROR("Bind SplatMap program"); + //bind uniforms + BindModelUniforms(forwardSplatShieldCheckHandle, modelJob, scene); + //bind textures + BindModelTextures(forwardSplatShieldCheckHandle, modelJob); + GLERROR("asdasd"); } - glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + break; + } + } + } else { + switch (modelJob->Type) { + case RawModel::MaterialType::Basic: + case RawModel::MaterialType::SingleTextures: + { + if (modelJob->Model->IsSkinned()) { + m_ForwardPlusSkinnedProgram->Bind(); + GLERROR("Bind ForwardPlusSkinnedProgram"); + //bind uniforms + BindModelUniforms(forwardSkinnedHandle, modelJob, scene); + //bind textures + BindModelTextures(forwardSkinnedHandle, modelJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(forwardSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + std::vector frameBones; + if (modelJob->AnimationOffset.animation != nullptr) { + frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); + } + else { + frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); + } + glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + + } + else { + m_ForwardPlusProgram->Bind(); + GLERROR("Bind ForwardPlusProgram"); + //bind uniforms + BindModelUniforms(forwardHandle, modelJob, scene); + //bind textures + BindModelTextures(forwardHandle, modelJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + } + break; } - else { - m_ForwardPlusSplatMapProgram->Bind(); - GLERROR("Bind SplatMap program"); - //bind uniforms - BindModelUniforms(forwardSplatMapHandle, modelJob, scene); - //bind textures - BindModelTextures(forwardSplatMapHandle, modelJob); - GLERROR("asdasd"); + case RawModel::MaterialType::SplatMapping: + { + if (modelJob->Model->IsSkinned()) { + m_ForwardPlusSplatMapSkinnedProgram->Bind(); + GLERROR("Bind SplatMap program"); + //bind uniforms + BindModelUniforms(forwardSplatMapSkinnedHandle, modelJob, scene); + //bind textures + BindModelTextures(forwardSplatMapSkinnedHandle, modelJob); + GLERROR("asdasd"); + std::vector frameBones; + if (modelJob->AnimationOffset.animation != nullptr) { + frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); + } + else { + frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); + } + glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + + } + else { + m_ForwardPlusSplatMapProgram->Bind(); + GLERROR("Bind SplatMap program"); + //bind uniforms + BindModelUniforms(forwardSplatMapHandle, modelJob, scene); + //bind textures + BindModelTextures(forwardSplatMapHandle, modelJob); + GLERROR("asdasd"); + } + break; } - break; - } - } - //draw - 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))); - if (GLERROR("models end")) { - continue; } } + //draw + 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))); + if (GLERROR("models end")) { + continue; + } } } } @@ -1013,76 +1037,6 @@ void DrawFinalPass::DrawSprites(std::list>&jobs, Rend // m_SpriteProgram->Unbind(); } -void DrawFinalPass::DrawExplosionSetup(ShaderProgram* shader, GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) -{ - shader->Bind(); - GLERROR("Bind ExplosionEffect program"); - //bind uniforms - BindExplosionUniforms(shaderHandle, job, scene); - //bind textures - BindExplosionTextures(shaderHandle, job); - glActiveTexture(GL_TEXTURE5); - glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); - glUniform3fv(glGetUniformLocation(shaderHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); -} - -void DrawFinalPass::DrawSkinnedExplosionSetup(ShaderProgram* shader, GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) -{ - shader->Bind(); - GLERROR("Bind ExplosionEffectSkinned program"); - //bind uniforms - BindExplosionUniforms(shaderHandle, job, scene); - //bind textures - BindExplosionTextures(shaderHandle, job); - glActiveTexture(GL_TEXTURE5); - glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); - glUniform3fv(glGetUniformLocation(shaderHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); - - std::vector frameBones; - if (job->AnimationOffset.animation != nullptr) { - frameBones = job->Skeleton->GetFrameBones(job->Animations, job->AnimationOffset); - } - else { - frameBones = job->Skeleton->GetFrameBones(job->Animations); - } - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); -} - -void DrawFinalPass::DrawModelSetup(ShaderProgram* shader, GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) -{ - m_ForwardPlusProgram->Bind(); - GLERROR("Bind ForwardPlusProgram"); - //bind uniforms - BindModelUniforms(shaderHandle, job, scene); - //bind textures - BindModelTextures(shaderHandle, job); - glActiveTexture(GL_TEXTURE5); - glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); - glUniform3fv(glGetUniformLocation(shaderHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); -} - -void DrawFinalPass::DrawSkinnedModelSetup(ShaderProgram* shader, GLuint shaderHandle , std::shared_ptr& job, RenderScene& scene) -{ - shader->Bind(); - GLERROR("Bind ForwardPlusSkinnedProgram"); - //bind uniforms - BindModelUniforms(shaderHandle, job, scene); - //bind textures - BindModelTextures(shaderHandle, job); - glActiveTexture(GL_TEXTURE5); - glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); - glUniform3fv(glGetUniformLocation(shaderHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); - - std::vector frameBones; - if (job->AnimationOffset.animation != nullptr) { - frameBones = job->Skeleton->GetFrameBones(job->Animations, job->AnimationOffset); - } - else { - frameBones = job->Skeleton->GetFrameBones(job->Animations); - } - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); -} - void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) { glUniform1i(glGetUniformLocation(shaderHandle, "SSAOQuality"), m_SSAOPass->TextureQuality()); diff --git a/src/Engine/Rendering/DrawFinalPassState.cpp b/src/Engine/Rendering/DrawFinalPassState.cpp index 62500fa5..5c238985 100644 --- a/src/Engine/Rendering/DrawFinalPassState.cpp +++ b/src/Engine/Rendering/DrawFinalPassState.cpp @@ -27,6 +27,7 @@ DrawStencilState::DrawStencilState(GLuint frameBuffer) BindFramebuffer(frameBuffer); Enable(GL_DEPTH_TEST); DepthMask(GL_TRUE); + Enable(GL_CULL_FACE); ClearColor(glm::vec4(0.f)); } From 654084839252b7c6c9dd63be197e17252a0f3001 Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 2 Mar 2016 11:59:56 +0100 Subject: [PATCH 125/252] WIP --- .../Systems/CapturePointArrowHUDSystem.cpp | 154 ++++++++++++------ src/Game/Systems/CapturePointSystem.cpp | 1 + 2 files changed, 104 insertions(+), 51 deletions(-) diff --git a/src/Game/Systems/CapturePointArrowHUDSystem.cpp b/src/Game/Systems/CapturePointArrowHUDSystem.cpp index e86a6844..3488c0a8 100644 --- a/src/Game/Systems/CapturePointArrowHUDSystem.cpp +++ b/src/Game/Systems/CapturePointArrowHUDSystem.cpp @@ -10,74 +10,134 @@ CapturePointArrowHUDSystem::CapturePointArrowHUDSystem(SystemParams params) void CapturePointArrowHUDSystem::Update(double dt) { - bool LoadCheck = true; + bool loadCheck = true; int redTeam; int blueTeam; int spectatorTeam; //Get list for all CapturePointArrowHUDComponents - auto ArrowHUDs = m_World->GetComponents("CapturePointArrowHUD"); - auto CapturePoints = m_World->GetComponents("CapturePoint"); - if(ArrowHUDs == nullptr) { + auto arrowHUDs = m_World->GetComponents("CapturePointArrowHUD"); + auto capturePoints = m_World->GetComponents("CapturePoint"); + if(arrowHUDs == nullptr) { return; } - for(auto& cArrowHUD : *ArrowHUDs) { + for(auto& cArrowHUD : *arrowHUDs) { //Get what team the current arrow corresponds to - EntityWrapper ArrowEntity = EntityWrapper(m_World, cArrowHUD.EntityID); - if (!ArrowEntity.Valid()) { + EntityWrapper arrowEntity = EntityWrapper(m_World, cArrowHUD.EntityID); + if (!arrowEntity.Valid()) { continue; } - if(!ArrowEntity.HasComponent("Team")) { + if(!arrowEntity.HasComponent("Team")) { continue; } - auto cTeam = ArrowEntity["Team"]; + auto cTeam = arrowEntity["Team"]; int currentTeam = (int)cTeam["Team"]; - if (LoadCheck) { + if (loadCheck) { redTeam = (int)cTeam["Team"].Enum("Red"); blueTeam = (int)cTeam["Team"].Enum("Blue"); spectatorTeam = (int)cTeam["Team"].Enum("Spectator"); - LoadCheck = false; + loadCheck = false; if (!m_InitialtargetsSet) { - glm::vec3 target1, target2; - EntityWrapper home1, home2; + std::unordered_map blueTargets, redTargets; + EntityWrapper homeBlue, homeRed; + int lastCP = -INFINITY; + int firstCP = INFINITY; - for (auto& cCP : *CapturePoints) { + for (auto& cCP : *capturePoints) { auto homePointTeam = (int)cCP["HomePointForTeam"]; - auto CPID = (int)cCP["CapturePointNumber"]; + EntityWrapper capturePointEntity = EntityWrapper(m_World, cCP.EntityID); + int capturePointID = (int)capturePointEntity["CapturePoint"]["CapturePointNumber"]; - if(CPID == 0) { - //Home point for one team - home1 = EntityWrapper(m_World, cCP.EntityID); - } else if (CPID == 1) { - //First target for one team, so save it for later use. - target1 = Transform::AbsolutePosition(EntityWrapper(m_World, cCP.EntityID)); - } else if (CPID == 3) { - //First target for one team, so save it for later use. - target2 = Transform::AbsolutePosition(EntityWrapper(m_World, cCP.EntityID)); - } else if (CPID == 4) { - //Home point for one team - home2 = EntityWrapper(m_World, cCP.EntityID); + if(capturePointID < firstCP) { + firstCP = capturePointID; + } + + if(capturePointID > lastCP) { + lastCP = capturePointID; + } + + if (!capturePointEntity.HasComponent("Team")) { + continue; + } + + int currentOwner = (int)capturePointEntity["Team"]["Team"]; + + if(currentOwner != redTeam) { + //This capturePoint is not owned by the red team and is therefor an eligible target for red team + glm::vec3 targetPos = Transform::AbsolutePosition(capturePointEntity); + redTargets.insert(std::pair(capturePointID, targetPos)); + } + if(currentOwner != blueTeam) { + //This capturePoint is not owned by the blue team and is therefor an eligible target for blue team + glm::vec3 targetPos = Transform::AbsolutePosition(capturePointEntity); + blueTargets.insert(std::pair(capturePointID, targetPos)); + } + + if(homePointTeam == blueTeam) { + //CP is the home point for blue team. + homeBlue = capturePointEntity; + } else if (homePointTeam == redTeam) { + //CP is the home point for red team. + homeRed = capturePointEntity; } } - //Check what team is the owner of Home1 and set their target to the next capturepoint - if(!home1.Valid() || !home2.Valid()) { + + if(!homeRed.Valid() || !homeBlue.Valid()) { + //One or both teams have no home point, cant continue return; } - if((int)home1["CapturePoint"]["HomePointForTeam"] == redTeam) { - m_RedTeamCurrentTarget = target1; - } else if ((int)home1["CapturePoint"]["HomePointForTeam"] == blueTeam) { - m_BlueTeamCurrentTarget = target1; + + std::unordered_map::const_iterator got; + //Find next target for red team. + if((int)homeRed["CapturePoint"]["CapturePointNumber"] == lastCP) { + //Red home base is the last capture point, count back from lastCP and find next target + for (int i = lastCP; i >= firstCP; i--) { + got = redTargets.find(i); + if(got == redTargets.end()) { + continue; + } else { + m_RedTeamCurrentTarget = got->second; + } + } + } else if ((int)homeRed["CapturePoint"]["CapturePointNumber"] == firstCP) { + //Red home is the first capture point, count forward from firstCP and find next target. + for (int i = firstCP; i <= lastCP; i++) { + got = redTargets.find(i); + if(got == redTargets.end()) { + //Target was not found, try the next one after that. + continue; + } else { + m_RedTeamCurrentTarget = got->second; + } + } } - //Check what team is the owner of Home2 and set their target to the next capturepoint - if ((int)home2["CapturePoint"]["HomePointForTeam"] == redTeam) { - m_RedTeamCurrentTarget = target2; - } else if ((int)home2["CapturePoint"]["HomePointForTeam"] == blueTeam) { - m_BlueTeamCurrentTarget = target2; + //Find next target for blue team + if ((int)homeBlue["CapturePoint"]["CapturePointNumber"] == lastCP) { + //Red home base is the last capture point, count back from lastCP and find next target + for (int i = lastCP; i >= firstCP; i--) { + got = blueTargets.find(i); + if (got == blueTargets.end()) { + continue; + } else { + m_BlueTeamCurrentTarget = got->second; + } + } + } else if ((int)homeBlue["CapturePoint"]["CapturePointNumber"] == firstCP) { + //Red home is the first capture point, count forward from firstCP and find next target. + for (int i = firstCP; i <= lastCP; i++) { + got = blueTargets.find(i); + if (got == blueTargets.end()) { + //Target was not found, try the next one after that. + continue; + } else { + m_BlueTeamCurrentTarget = got->second; + } + } } } } @@ -93,14 +153,14 @@ void CapturePointArrowHUDSystem::Update(double dt) pos = currentTeam == redTeam ? m_RedTeamCurrentTarget : currentTeam == blueTeam ? m_BlueTeamCurrentTarget : glm::vec3(0.f); - glm::vec3& arrowOri = ArrowEntity["Transform"]["Orientation"]; - glm::vec3 lookVector = glm::normalize(Transform::AbsolutePosition(ArrowEntity) - pos); //Maybe should be player instead + glm::vec3& arrowOri = arrowEntity["Transform"]["Orientation"]; + glm::vec3 lookVector = glm::normalize(Transform::AbsolutePosition(arrowEntity) - pos); //Maybe should be player instead float pitch = std::asin(-lookVector.y); float yaw = std::atan2(lookVector.x, lookVector.z); arrowOri.x = pitch; arrowOri.y = yaw; arrowOri.z = 0.f; - EntityWrapper parent = ArrowEntity.Parent(); + EntityWrapper parent = arrowEntity.Parent(); if (parent.Valid()) { arrowOri -= Transform::AbsoluteOrientationEuler(parent); } @@ -109,8 +169,7 @@ void CapturePointArrowHUDSystem::Update(double dt) bool CapturePointArrowHUDSystem::OnCapturePointCaptured(Events::Captured& e) { - if (!e.NextCapturePoint.HasComponent("Team")) - { + if (!e.NextCapturePoint.HasComponent("Team")) { return 0; } @@ -119,18 +178,11 @@ bool CapturePointArrowHUDSystem::OnCapturePointCaptured(Events::Captured& e) int redTeam = (int)cTeam["Team"].Enum("Red"); int blueTeam = (int)cTeam["Team"].Enum("Blue"); int spectatorTeam = (int)cTeam["Team"].Enum("Spectator"); - int target = -1; - - if (e.NextCapturePoint.HasComponent("CapturePoint")) { - target = (int)e.NextCapturePoint["CapturePoint"]["CapturePointNumber"]; - } else { - return 0; - } if(e.TeamNumberThatCapturedCapturePoint == redTeam) { m_RedTeamCurrentTarget = Transform::AbsolutePosition(e.NextCapturePoint); } else if (e.TeamNumberThatCapturedCapturePoint == blueTeam) { - m_BlueTeamCurrentTarget = Transform::AbsolutePosition(e.NextCapturePoint);; + m_BlueTeamCurrentTarget = Transform::AbsolutePosition(e.NextCapturePoint); } m_InitialtargetsSet = true; diff --git a/src/Game/Systems/CapturePointSystem.cpp b/src/Game/Systems/CapturePointSystem.cpp index f748ff09..6cbb1b2f 100644 --- a/src/Game/Systems/CapturePointSystem.cpp +++ b/src/Game/Systems/CapturePointSystem.cpp @@ -103,6 +103,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp } } if (m_RecentlyCapturedNeedNextCapturePointNow) { + //TODO: Next capture point for both teams m_CapturedEvent.NextCapturePoint = m_CapturedEvent.TeamNumberThatCapturedCapturePoint == blueTeam ? m_CapturePointNumberToEntityMap[nextPossibleCapturePoint["Blue"]] : m_CapturePointNumberToEntityMap[nextPossibleCapturePoint["Red"]]; From 07ccb9c04195ea45f2882fce2b92dbc071559a16 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Wed, 2 Mar 2016 13:30:04 +0100 Subject: [PATCH 126/252] AutoAnimationBlend on unique node working but scale is not working correctly --- include/Engine/Rendering/AnimationSystem.h | 54 +- include/Engine/Rendering/BlendTree.h | 12 +- include/Engine/Rendering/EAnimationBlend.h | 21 + .../Engine/Rendering/EAutoAnimationBlend.h | 21 + include/Engine/Rendering/Skeleton.h | 2 +- resources/Schema/Entities/AnimationTests2.xml | 1175 ++++++++--------- resources/Schema/Entities/Skeleton.xml | 233 ++-- resources/Schema/Entities/derp.xml | 298 +++++ src/Engine/Core/Util/Logging.cpp | 4 +- src/Engine/Rendering/AnimationSystem.cpp | 227 +++- src/Engine/Rendering/BlendTree.cpp | 88 +- src/Engine/Rendering/Renderer.cpp | 2 +- src/Engine/Rendering/Skeleton.cpp | 16 +- 13 files changed, 1404 insertions(+), 749 deletions(-) create mode 100644 include/Engine/Rendering/EAnimationBlend.h create mode 100644 include/Engine/Rendering/EAutoAnimationBlend.h create mode 100644 resources/Schema/Entities/derp.xml diff --git a/include/Engine/Rendering/AnimationSystem.h b/include/Engine/Rendering/AnimationSystem.h index d05dc765..1ea076fd 100644 --- a/include/Engine/Rendering/AnimationSystem.h +++ b/include/Engine/Rendering/AnimationSystem.h @@ -3,13 +3,19 @@ #include "GLM.h" -#include "Common.h" -#include "Core/System.h" -#include "Core/ResourceManager.h" +#include "../Common.h" +#include "../Core/System.h" +#include "../Core/ResourceManager.h" #include "Rendering/Model.h" #include "Rendering/EAnimationComplete.h" #include "Rendering/Skeleton.h" #include "Rendering/BlendTree.h" +#include "Rendering/EAnimationBlend.h" +#include "Rendering/EAutoAnimationBlend.h" +#include "../Input/EInputCommand.h" +#include "../Core/EntityWrapper.h" + +#include "imgui/imgui.h" class AnimationSystem : public ImpureSystem { @@ -20,7 +26,49 @@ public: private: void CreateBlendTrees(); void UpdateAnimations(double dt); + void UpdateWeights(double dt); + void AnimationComplete(EntityWrapper animationEntity); + EventRelay m_EAnimationBlend; + bool OnAnimationBlend(Events::AnimationBlend& e); + EventRelay m_EAutoAnimationBlend; + bool OnAutoAnimationBlend(Events::AutoAnimationBlend& e); + + + EventRelay m_EInputCommand; + bool OnInputCommand(const Events::InputCommand& e); + + struct BlendJob + { + EntityWrapper BlendEntity = EntityWrapper::Invalid; + double StartWeight; + double GoalWeight; + double Duration; + double CurrentTime = 0.0; + }; + + struct QueuedBlendJob : BlendJob + { + EntityWrapper AnimationEntity = EntityWrapper::Invalid; + }; + + struct AutoBlendJob + { + EntityWrapper RootNode = EntityWrapper::Invalid; + double Duration; + double CurrentTime = 0.0; + BlendTree::AutoBlendInfo BlendInfo; + }; + + std::list m_AutoBlendJobs; + std::list m_BlendJobs; + std::list m_QueuedBlendJobs; + + char m_AnimationName1[20] = "Run"; + float m_BlendTime1 = 0.5f; + + char m_AnimationName2[20] = "Jump"; + float m_BlendTime2 = 0.5f; }; #endif \ No newline at end of file diff --git a/include/Engine/Rendering/BlendTree.h b/include/Engine/Rendering/BlendTree.h index 5b38080d..b19fbe4f 100644 --- a/include/Engine/Rendering/BlendTree.h +++ b/include/Engine/Rendering/BlendTree.h @@ -23,12 +23,13 @@ public: struct Node { std::string Name; + EntityWrapper Entity; Node* Parent = nullptr; Node* Child[2] = { nullptr, nullptr }; NodeType Type; std::map Pose; //std::vector Pose; - float Weight = 0.f; + double Weight = 0.0; Node* Next() { Node* next = this; @@ -54,7 +55,12 @@ public: }; - + struct AutoBlendInfo + { + std::string NodeName; + double progress; + std::unordered_map StartWeights; + }; BlendTree(EntityWrapper ModelEntity, Skeleton* skeleton); @@ -66,6 +72,7 @@ public: bool IsValid() { return (m_Root == nullptr ? false : true); } void PrintTree(); + BlendTree::AutoBlendInfo AutoBlendStep(AutoBlendInfo blendInfo); private: Skeleton* m_Skeleton = nullptr; @@ -76,6 +83,7 @@ private: std::vector AccumulateFinalPose(); BlendTree::Node* FillTreeByName(Node* parentNode, std::string name, EntityWrapper parentEntity); + std::vector FindNodesByName(std::string name); void Blend(std::map& pose); }; diff --git a/include/Engine/Rendering/EAnimationBlend.h b/include/Engine/Rendering/EAnimationBlend.h new file mode 100644 index 00000000..880a2fd0 --- /dev/null +++ b/include/Engine/Rendering/EAnimationBlend.h @@ -0,0 +1,21 @@ +#ifndef Events_AnimationBlend_h__ +#define Events_AnimationBlend_h__ + +#include "../Core/EventBroker.h" +#include "../Core/EntityWrapper.h" + +namespace Events +{ + +struct AnimationBlend : Event +{ + EntityWrapper BlendEntity = EntityWrapper::Invalid; + double GoalWeight; + double Duration; + + EntityWrapper AnimationEntity = EntityWrapper::Invalid; +}; + +} + +#endif diff --git a/include/Engine/Rendering/EAutoAnimationBlend.h b/include/Engine/Rendering/EAutoAnimationBlend.h new file mode 100644 index 00000000..b148664f --- /dev/null +++ b/include/Engine/Rendering/EAutoAnimationBlend.h @@ -0,0 +1,21 @@ +#ifndef Events_AutoAnimationBlend_h__ +#define Events_AutoAnimationBlend_h__ + +#include "../Core/EventBroker.h" +#include "../Core/EntityWrapper.h" + +namespace Events +{ + +struct AutoAnimationBlend : Event +{ + EntityWrapper RootNode = EntityWrapper::Invalid; + std::string NodeName; + double Duration; + + EntityWrapper AnimationEntity = EntityWrapper::Invalid; +}; + +} + +#endif diff --git a/include/Engine/Rendering/Skeleton.h b/include/Engine/Rendering/Skeleton.h index ffa08452..e812bf12 100644 --- a/include/Engine/Rendering/Skeleton.h +++ b/include/Engine/Rendering/Skeleton.h @@ -67,7 +67,7 @@ public: std::map GetFrameBones(const Animation* animation, double time, bool additive, bool noRootMotion = false); glm::mat4 GetBoneTransform(const Bone* bone, const Animation* animation, float time, glm::mat4 childMatrix); - std::map BlendPoses(const std::map& pose1, const std::map& pose2, float weight); + std::map BlendPoses(const std::map& pose1, const std::map& pose2, double weight); std::map OverridePose(const std::map& overridePose, const std::map& targetPose); std::map BlendPoseAdditive(const std::map& additivePose, const std::map& targetPose); void GetFinalPose(std::map& boneMatrices, std::vector& finalPose, std::map& boneTransforms); diff --git a/resources/Schema/Entities/AnimationTests2.xml b/resources/Schema/Entities/AnimationTests2.xml index 84663233..fa2a8463 100644 --- a/resources/Schema/Entities/AnimationTests2.xml +++ b/resources/Schema/Entities/AnimationTests2.xml @@ -3,8 +3,8 @@ - 0.5 - 2.2999999523162842 + 0.40000000596046448 + 3 @@ -21,7 +21,7 @@ - 0.10000047832727432 + 0.80000001192092896 Models/Widgets/Lights/DirectionalLightWidget.mesh @@ -53,8 +53,8 @@ FinalBlend - 4 - Models/Characters/Assault/Assaulttest.mesh + 5 + Models/Characters/Defender/DefenderRed.mesh @@ -68,9 +68,9 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - + - + @@ -112,7 +112,7 @@ ShootBlend Reload - 1 + 0 @@ -131,7 +131,7 @@ ShootFastRifleU - + 1 @@ -142,7 +142,7 @@ ShootRifleU - + 1 @@ -155,8 +155,8 @@ ReloadSwitchU - - 1 + + false @@ -169,598 +169,7 @@ StandCrouchBlend Jump - 1 - - - - - - - - StandMovement - CrouchMovement - 1 - - - - - - - - Walk - StrafeBlend - 1 - - - - - - - - CrouchWalkF - - 1 - - - - - - - - - Left - Right - 1 - - - - - - - - CrouchStrafeLeftF - - 1 - - - - - - - - - CrouchStrafeRightF - - 1 - - - - - - - - - - - - - RunWalkBlend - StrafeBlend - 1 - - - - - - - - Run - Walk - 0 - - - - - - - - RunF - - 1 - - - - - - - - - WalkF - - 1 - - - - - - - - - - - Left - Right - 0 - - - - - - - - StrafeLeftF - - 1 - - - - - - - - - StrafeRightF - - 1 - - - - - - - - - - - - - - - JumpF - - 1 - - - - - - - - - - - - - - - Aim - FinalBlend - - - Models/Characters/Assault/Assaulttest.mesh - - - - - - - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - - - - - - - - - - - - - 3 - - - - - - - - - - - AimRifleA - false - true - - - - - - - - - WeaponBlend - MovementBlend - - - - - - - - ShootBlend - Reload - 1 - - - - - - - - ShootFast - ShootSlow - 1 - - - - - - - - ShootFastRifleU - - 1 - - - - - - - - - ShootRifleU - - 1 - - - - - - - - - - - ReloadSwitchU - - 1 - - - - - - - - - - - StandCrouchBlend - Jump - 1 - - - - - - - - StandMovement - CrouchMovement - 1 - - - - - - - - Walk - StrafeBlend - 1 - - - - - - - - CrouchWalkF - - 1 - - - - - - - - - Left - Right - 1 - - - - - - - - CrouchStrafeLeftF - - 1 - - - - - - - - - CrouchStrafeRightF - - 1 - - - - - - - - - - - - - RunWalkBlend - StrafeBlend - 1 - - - - - - - - Run - Walk - 1 - - - - - - - - RunF - - 1 - - - - - - - - - WalkF - - 1 - - - - - - - - - - - Left - Right - 1 - - - - - - - - StrafeLeftF - - 1 - - - - - - - - - StrafeRightF - - 1 - - - - - - - - - - - - - - - JumpF - - 1 - - - - - - - - - - - - - - - Aim - FinalBlend - - - Models/Characters/Assault/Assaulttest.mesh - - - - - - - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - - - - - - - - - - - - - 3 - - - - - - - - - - - AimRifleA - - false - true - - - - - - - - - WeaponBlend - MovementBlend - - - - - - - - ShootBlend - Reload - 1 - - - - - - - - ShootFast - ShootSlow - 1 - - - - - - - - ShootFastRifleU - - 1 - - - - - - - - - ShootRifleU - - 1 - - - - - - - - - - - ReloadSwitchU - - 1 - - - - - - - - - - - StandCrouchBlend - Jump - 1 + 0.48000049591064453 @@ -789,7 +198,7 @@ CrouchWalkF - + 1 @@ -810,7 +219,7 @@ CrouchStrafeLeftF - + 1 @@ -821,7 +230,7 @@ CrouchStrafeRightF - + 1 @@ -837,7 +246,7 @@ RunWalkBlend StrafeBlend - 1 + 0 @@ -847,7 +256,7 @@ Run Walk - 1 + 0 @@ -856,8 +265,7 @@ RunF - - 1 + @@ -867,7 +275,7 @@ WalkF - + 1 @@ -881,7 +289,7 @@ Left Right - 1 + 0 @@ -890,7 +298,7 @@ StrafeLeftF - + 1 @@ -901,7 +309,7 @@ StrafeRightF - + 1 @@ -918,8 +326,8 @@ JumpF - - 1 + + false @@ -929,8 +337,541 @@ + + + + + + + + + + + R_Arm_Weapon_Joint + + + + Models/Core/UnitCube.mesh + + true + + + + + + + + + + + + + R_Hand + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + R_Arm + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + R_Shoulder + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + Neck + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + Spine_3 + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + Spine_2 + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + Spine_1 + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + Hip + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + L_Leg_Top + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + L_Leg_Bottom + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + L_Foot + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + L_Toe + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + L_Shoulder + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + L_Arm + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + L_Hand + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + L_Shoulder_Armor_Joint + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + Chin + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + Head + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + Perietal + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + L_Elbow + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + R_Leg_Bottom + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + R_Elbow + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + R_Leg_Top + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + R_Foot + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + R_Toe + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + R_Shoulder_Armor_Joint + + true + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + + + + + + diff --git a/resources/Schema/Entities/Skeleton.xml b/resources/Schema/Entities/Skeleton.xml index b8deb2eb..76674dec 100644 --- a/resources/Schema/Entities/Skeleton.xml +++ b/resources/Schema/Entities/Skeleton.xml @@ -18,9 +18,9 @@ true - + - + @@ -29,16 +29,17 @@ R_Hand - + + true Models/Core/UnitCube.mesh - - - + + + @@ -47,16 +48,17 @@ R_Arm - + + true Models/Core/UnitCube.mesh - - - + + + @@ -65,16 +67,17 @@ R_Shoulder - + + true Models/Core/UnitCube.mesh - - - + + + @@ -83,16 +86,17 @@ Neck - + + true Models/Core/UnitCube.mesh - - - + + + @@ -101,16 +105,17 @@ Spine_3 - + + true Models/Core/UnitCube.mesh - - - + + + @@ -119,16 +124,17 @@ Spine_2 - + + true Models/Core/UnitCube.mesh - - - + + + @@ -137,16 +143,17 @@ Spine_1 - + + true Models/Core/UnitCube.mesh - - - + + + @@ -155,15 +162,17 @@ Hip - + + true Models/Core/UnitCube.mesh - - + + + @@ -172,16 +181,17 @@ L_Leg_Top - + + true Models/Core/UnitCube.mesh - + - + @@ -190,16 +200,17 @@ L_Leg_Bottom - + + true Models/Core/UnitCube.mesh - + - + @@ -208,16 +219,17 @@ L_Foot - + + true Models/Core/UnitCube.mesh - - - + + + @@ -226,16 +238,17 @@ L_Toe - + + true Models/Core/UnitCube.mesh - - - + + + @@ -244,16 +257,17 @@ L_Shoulder - + + true Models/Core/UnitCube.mesh - - - + + + @@ -262,16 +276,17 @@ L_Arm - + + true Models/Core/UnitCube.mesh - - - + + + @@ -280,16 +295,17 @@ L_Hand - + + true Models/Core/UnitCube.mesh - - - + + + @@ -298,16 +314,17 @@ L_Shoulder_Armor_Joint - + + true Models/Core/UnitCube.mesh - - - + + + @@ -316,16 +333,17 @@ Chin - + + true Models/Core/UnitCube.mesh - - - + + + @@ -334,16 +352,17 @@ Head - + + true Models/Core/UnitCube.mesh - - - + + + @@ -352,16 +371,17 @@ Perietal - + + true Models/Core/UnitCube.mesh - - - + + + @@ -370,16 +390,17 @@ L_Elbow - + + true Models/Core/UnitCube.mesh - - - + + + @@ -388,16 +409,17 @@ R_Leg_Bottom - + + true Models/Core/UnitCube.mesh - - - + + + @@ -406,16 +428,17 @@ R_Elbow - + + true Models/Core/UnitCube.mesh - - - + + + @@ -424,16 +447,17 @@ R_Leg_Top - + + true Models/Core/UnitCube.mesh - - - + + + @@ -442,16 +466,17 @@ R_Foot - + + true Models/Core/UnitCube.mesh - - - + + + @@ -460,16 +485,17 @@ R_Toe - + + true Models/Core/UnitCube.mesh - - - + + + @@ -478,16 +504,17 @@ R_Shoulder_Armor_Joint - + + true Models/Core/UnitCube.mesh - - - + + + diff --git a/resources/Schema/Entities/derp.xml b/resources/Schema/Entities/derp.xml new file mode 100644 index 00000000..b8735335 --- /dev/null +++ b/resources/Schema/Entities/derp.xml @@ -0,0 +1,298 @@ + + + + + + Aim + FinalBlend + + + 4 + Models/Characters/Sniper/SniperBlue.mesh + + + + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + + + + + 3 + + + + + + + + + + + AimRifleA + + false + true + + + + + + + + + WeaponBlend + MovementBlend + + + + + + + + ShootBlend + Reload + 1 + + + + + + + + ShootFast + ShootSlow + 1 + + + + + + + + ShootFastRifleU + + 1 + + + + + + + + + ShootRifleU + + 1 + + + + + + + + + + + ReloadSwitchU + + false + + + + + + + + + + + StandCrouchBlend + Jump + 1 + + + + + + + + StandMovement + CrouchMovement + 1 + + + + + + + + Walk + StrafeBlend + 1 + + + + + + + + CrouchWalkF + + 1 + + + + + + + + + Left + Right + 1 + + + + + + + + CrouchStrafeLeftF + + 1 + + + + + + + + + CrouchStrafeRightF + + 1 + + + + + + + + + + + + + RunWalkBlend + StrafeBlend + 1 + + + + + + + + Run + Walk + 1 + + + + + + + + RunF + + 1 + + + + + + + + + WalkF + + 1 + + + + + + + + + + + Left + Right + 0 + + + + + + + + StrafeLeftF + + 1 + + + + + + + + + StrafeRightF + + 1 + + + + + + + + + + + + + + + JumpF + + false + + + + + + + + + + + + diff --git a/src/Engine/Core/Util/Logging.cpp b/src/Engine/Core/Util/Logging.cpp index 63a6f380..e5427965 100644 --- a/src/Engine/Core/Util/Logging.cpp +++ b/src/Engine/Core/Util/Logging.cpp @@ -33,8 +33,8 @@ void _LOG(_LOG_LEVEL logLevel, const char* file, const char* func, unsigned int va_end(args); if (logLevel == LOG_LEVEL_ERROR) { - std::cerr << file << ":" << line << " " << func << std::endl; - std::cerr << _LOG_LEVEL_PREFIX[logLevel] << message << std::endl; + /*std::cerr << file << ":" << line << " " << func << std::endl; + std::cerr << _LOG_LEVEL_PREFIX[logLevel] << message << std::endl;*/ } else { std::cout << _LOG_LEVEL_PREFIX[logLevel] << message << std::endl; } diff --git a/src/Engine/Rendering/AnimationSystem.cpp b/src/Engine/Rendering/AnimationSystem.cpp index 5bc64535..11a21881 100644 --- a/src/Engine/Rendering/AnimationSystem.cpp +++ b/src/Engine/Rendering/AnimationSystem.cpp @@ -3,13 +3,21 @@ AnimationSystem::AnimationSystem(SystemParams params) : System(params) { - + EVENT_SUBSCRIBE_MEMBER(m_EAnimationBlend, &AnimationSystem::OnAnimationBlend); + EVENT_SUBSCRIBE_MEMBER(m_EAutoAnimationBlend, &AnimationSystem::OnAutoAnimationBlend); + EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &AnimationSystem::OnInputCommand); } void AnimationSystem::Update(double dt) { + ImGui::InputText("AnimationName1", &m_AnimationName1[0], sizeof(m_AnimationName1)); + ImGui::SliderFloat("Blendtime1", &m_BlendTime1, 0.f, 10.f); + ImGui::InputText("AnimationName2", &m_AnimationName2[0], sizeof(m_AnimationName2)); + ImGui::SliderFloat("Blendtime2", &m_BlendTime2, 0.f, 10.f); + UpdateAnimations(dt); CreateBlendTrees(); + UpdateWeights(dt); } void AnimationSystem::CreateBlendTrees() @@ -94,16 +102,17 @@ void AnimationSystem::UpdateAnimations(double dt) e.Entity = entity; e.Name = (std::string)animationC["AnimationName"]; m_EventBroker->Publish(e); + AnimationComplete(entity); + (double&)animationC["Speed"] = 0.0; } else if (nextTime < 0) { Events::AnimationComplete e; e.Entity = entity; e.Name = (std::string)animationC["AnimationName"]; m_EventBroker->Publish(e); + AnimationComplete(entity); nextTime = 0; + (double&)animationC["Speed"] = 0.0; } - - (double&)animationC["Speed"] = 0.0; - } else { if (nextTime > animation->Duration) { Events::AnimationComplete e; @@ -131,3 +140,213 @@ void AnimationSystem::UpdateAnimations(double dt) } } + +void AnimationSystem::UpdateWeights(double dt) +{ + /* for (auto it = m_BlendJobs.begin(); it != m_BlendJobs.end(); it++) { + if (!it->BlendEntity.Valid()) { + it = m_BlendJobs.erase(it); + continue; + } + + if (it->BlendEntity.HasComponent("Blend")) { + it->CurrentTime += dt; + double progress = it->CurrentTime / it->Duration; + progress = glm::clamp(progress, 0.0, 1.0); + + double weight = ((it->GoalWeight - it->StartWeight) * progress) + it->StartWeight; + (double&)it->BlendEntity["Blend"]["Weight"] = weight; + + if(weight == it->GoalWeight) { + it = m_BlendJobs.erase(it); + } + } + }*/ + + + for (auto it = m_AutoBlendJobs.begin(); it != m_AutoBlendJobs.end();) { + it->CurrentTime += dt; + + if (!it->RootNode.Valid()) { + it = m_AutoBlendJobs.erase(it); + continue; + } + + if (!it->RootNode.HasComponent("Model")) { + it = m_AutoBlendJobs.erase(it); + continue; + } + + Model* model; + try { + model = ResourceManager::Load<::Model, true>(it->RootNode["Model"]["Resource"]); + } catch (const std::exception&) { + continue; + } + + Skeleton* skeleton = model->m_RawModel->m_Skeleton; + if (skeleton == nullptr) { + continue; + } + + std::shared_ptr blendTree; + if(skeleton->BlendTrees.find(it->RootNode) != skeleton->BlendTrees.end()) { + blendTree = skeleton->BlendTrees.at(it->RootNode); + } else { + it = m_AutoBlendJobs.erase(it); + continue; + } + + + it->BlendInfo.progress = glm::clamp(it->CurrentTime / it->Duration, 0.0, 1.0); + it->BlendInfo = blendTree->AutoBlendStep(it->BlendInfo); + + + if (it->CurrentTime >= it->Duration) { + it = m_AutoBlendJobs.erase(it); + continue; + } + + ++it; + } +} + + +void AnimationSystem::AnimationComplete(EntityWrapper animationEntity) +{ + for (auto it = m_QueuedBlendJobs.begin(); it != m_QueuedBlendJobs.end(); it++) { + if (!it->BlendEntity.Valid() || !it->AnimationEntity.Valid()) { + it = m_QueuedBlendJobs.erase(it); + continue; + } + + if(animationEntity == it->AnimationEntity) { + BlendJob bj; + bj.BlendEntity = it->BlendEntity; + bj.StartWeight = it->StartWeight; + bj.GoalWeight = it->GoalWeight; + bj.Duration = it->Duration; + bj.CurrentTime = 0.0; + m_BlendJobs.push_back(bj); + it = m_QueuedBlendJobs.erase(it); + } + + } + +} + +bool AnimationSystem::OnAnimationBlend(Events::AnimationBlend& e) +{ + if(!e.BlendEntity.Valid()) { + return false; + } + if(!e.BlendEntity.HasComponent("Blend")){ + return false; + } + + if (e.AnimationEntity.Valid()) { + if (e.AnimationEntity.HasComponent("Animation")) { + QueuedBlendJob qbj; + qbj.BlendEntity = e.BlendEntity; + qbj.StartWeight = (double)e.BlendEntity["Blend"]["Weight"]; + qbj.GoalWeight = e.GoalWeight; + qbj.Duration = e.Duration; + qbj.CurrentTime = 0.0; + qbj.AnimationEntity = e.AnimationEntity; + m_QueuedBlendJobs.push_back(qbj); + return true; + } + } + + BlendJob bj; + bj.BlendEntity = e.BlendEntity; + bj.StartWeight = (double)e.BlendEntity["Blend"]["Weight"]; + bj.GoalWeight = e.GoalWeight; + bj.Duration = e.Duration; + bj.CurrentTime = 0.0; + m_BlendJobs.push_back(bj); + + return true; +} + + +bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e) +{ + if(!e.RootNode.Valid()) { + return false; + } + + if(!e.RootNode.HasComponent("Model")) { + return false; + } + + AutoBlendJob abj; + abj.RootNode = e.RootNode; + abj.CurrentTime = 0.0; + abj.Duration = e.Duration; + + BlendTree::AutoBlendInfo abInfo; + abInfo.NodeName = e.NodeName; + abInfo.progress = 0.0; + + abj.BlendInfo = abInfo; + + m_AutoBlendJobs.push_back(abj); + + +} + +bool AnimationSystem::OnInputCommand(const Events::InputCommand& e) +{ + + if (e.Value == 1.f) { + if (e.Command == "BlendTest0") { + + + auto blendComponents = m_World->GetComponents("BlendAdditive"); + + if (blendComponents == nullptr) { + return false; + } + + + for (auto& bc : *blendComponents) { + EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); + + if (entity.Name() == "Assault") { + + Events::AutoAnimationBlend aeb; + aeb.Duration = m_BlendTime1; + aeb.NodeName = m_AnimationName1; + aeb.RootNode = entity; + m_EventBroker->Publish(aeb); + + } + } + + } else if (e.Command == "BlendTest1") { + + auto blendComponents = m_World->GetComponents("BlendAdditive"); + + if (blendComponents == nullptr) { + return false; + } + + + for (auto& bc : *blendComponents) { + EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); + + if (entity.Name() == "Assault") { + + Events::AutoAnimationBlend aeb; + aeb.Duration = m_BlendTime2; + aeb.NodeName = m_AnimationName2; + aeb.RootNode = entity; + m_EventBroker->Publish(aeb); + + } + } + } + } +} + diff --git a/src/Engine/Rendering/BlendTree.cpp b/src/Engine/Rendering/BlendTree.cpp index 0305af19..8ef67f0f 100644 --- a/src/Engine/Rendering/BlendTree.cpp +++ b/src/Engine/Rendering/BlendTree.cpp @@ -14,6 +14,7 @@ BlendTree::BlendTree(EntityWrapper ModelEntity, Skeleton* skeleton) } m_Root = new Node(); + m_Root->Entity = ModelEntity; m_Root->Name = ModelEntity.Name(); m_Root->Pose = m_Skeleton->GetFrameBones(animation, (double)ModelEntity["Animation"]["Time"], (bool)ModelEntity["Animation"]["Additive"]); m_Root->Parent = nullptr; @@ -21,15 +22,18 @@ BlendTree::BlendTree(EntityWrapper ModelEntity, Skeleton* skeleton) } else if (ModelEntity.HasComponent("Blend")) { m_Root = new Node(); + m_Root->Entity = ModelEntity; m_Root->Name = ModelEntity.Name(); m_Root->Parent = nullptr; m_Root->Type = NodeType::Blend; m_Root->Weight = (double)ModelEntity["Blend"]["Weight"]; + (double&)ModelEntity["Blend"]["Weight"] = glm::clamp((double)ModelEntity["Blend"]["Weight"], 0.0, 1.0); m_Root->Child[0] = FillTreeByName(m_Root, (std::string)ModelEntity["Blend"]["Pose1"], ModelEntity); m_Root->Child[1] = FillTreeByName(m_Root, (std::string)ModelEntity["Blend"]["Pose2"], ModelEntity); } else if (ModelEntity.HasComponent("BlendOverride")) { m_Root = new Node(); + m_Root->Entity = ModelEntity; m_Root->Name = ModelEntity.Name(); m_Root->Parent = nullptr; m_Root->Type = NodeType::Override; @@ -38,6 +42,7 @@ BlendTree::BlendTree(EntityWrapper ModelEntity, Skeleton* skeleton) } else if (ModelEntity.HasComponent("BlendAdditive")) { m_Root = new Node(); + m_Root->Entity = ModelEntity; m_Root->Name = ModelEntity.Name(); m_Root->Parent = nullptr; m_Root->Type = NodeType::Additive; @@ -97,8 +102,6 @@ void BlendTree::PrintTree() LOG_INFO("%s", currentNode->Name.c_str()); currentNode = currentNode->Next(); } - - } BlendTree::Node* BlendTree::FillTreeByName(Node* parentNode, std::string name, EntityWrapper parentEntity) @@ -116,6 +119,7 @@ BlendTree::Node* BlendTree::FillTreeByName(Node* parentNode, std::string name, E } Node* node = new Node(); + node->Entity = childEntity; node->Name = childEntity.Name(); node->Pose = m_Skeleton->GetFrameBones(animation, (double)childEntity["Animation"]["Time"], (bool)childEntity["Animation"]["Additive"]); node->Parent = parentNode; @@ -124,24 +128,26 @@ BlendTree::Node* BlendTree::FillTreeByName(Node* parentNode, std::string name, E } else if (childEntity.HasComponent("Blend")) { Node* node = new Node(); + node->Entity = childEntity; node->Name = childEntity.Name(); node->Parent = parentNode; node->Type = NodeType::Blend; - (double&)childEntity["Blend"]["Weight"] = glm::clamp((float)(double)childEntity["Blend"]["Weight"], 0.f, 1.f); + (double&)childEntity["Blend"]["Weight"] = glm::clamp((double)childEntity["Blend"]["Weight"], 0.0, 1.0); node->Weight = (double)childEntity["Blend"]["Weight"]; - if (node->Weight < 1.f && node->Weight > 0.f) { + //if (node->Weight < 1.f && node->Weight > 0.f) { node->Child[0] = FillTreeByName(node, (std::string)childEntity["Blend"]["Pose1"], childEntity); node->Child[1] = FillTreeByName(node, (std::string)childEntity["Blend"]["Pose2"], childEntity); - } else if (node->Weight == 1.f) { + /* } else if (node->Weight == 1.f) { node->Child[0] = FillTreeByName(node, (std::string)childEntity["Blend"]["Pose1"], childEntity); } else if (node->Weight == 0.f) { node->Child[1] = FillTreeByName(node, (std::string)childEntity["Blend"]["Pose2"], childEntity); - } + }*/ return node; } else if (childEntity.HasComponent("BlendOverride")) { Node* node = new Node(); + node->Entity = childEntity; node->Name = childEntity.Name(); node->Parent = parentNode; node->Type = NodeType::Override; @@ -150,6 +156,7 @@ BlendTree::Node* BlendTree::FillTreeByName(Node* parentNode, std::string name, E return node; } else if (childEntity.HasComponent("BlendAdditive")) { Node* node = new Node(); + node->Entity = childEntity; node->Name = childEntity.Name(); node->Parent = parentNode; node->Type = NodeType::Additive; @@ -162,6 +169,75 @@ BlendTree::Node* BlendTree::FillTreeByName(Node* parentNode, std::string name, E return nullptr; } + +std::vector BlendTree::FindNodesByName(std::string name) +{ + std::vector Nodes; + Node* currentNode = m_Root; + + while (currentNode->Child[0] != nullptr) { + currentNode = currentNode->Child[0]; + } + + while (currentNode != nullptr) { + if(currentNode->Name == name) { + Nodes.push_back(currentNode); + } + currentNode = currentNode->Next(); + } + return Nodes; +} + + +BlendTree::AutoBlendInfo BlendTree::AutoBlendStep(AutoBlendInfo blendInfo) +{ + std::vector goalNodes = FindNodesByName(blendInfo.NodeName); + + if(goalNodes.size() == 0) { + return blendInfo; + } else if(goalNodes.size() == 1) { + Node* currentNode = goalNodes[0]->Parent; + Node* lastNode = goalNodes[0]; + + while (currentNode != nullptr) + { + + + if(!currentNode->Entity.HasComponent("Blend")) { + return blendInfo; + } + + double startWeight; + if(blendInfo.StartWeights.find(currentNode->Entity) != blendInfo.StartWeights.end()) { + startWeight = blendInfo.StartWeights.at(currentNode->Entity); + } else { + startWeight = currentNode->Weight; + blendInfo.StartWeights[currentNode->Entity] = startWeight; + } + + double goalWeight; + if(currentNode->Child[0] == lastNode) { + goalWeight = 0.0; + } else if (currentNode->Child[1] == lastNode) { + goalWeight = 1.0; + } + + double weight = ((goalWeight - startWeight) * blendInfo.progress) + startWeight; + (double&)currentNode->Entity["Blend"]["Weight"] = weight; + currentNode->Weight = weight; + + lastNode = currentNode; + currentNode = currentNode->Parent; + } + + + } else if(goalNodes.size() >= 2) { + + } + + return blendInfo; +} + void BlendTree::Blend(std::map& pose) { Node* currentNode; diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index 251bba2b..fd75911d 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -142,7 +142,7 @@ void Renderer::Draw(RenderFrame& frame) PerformanceTimer::StopTimer("Renderer-Depth"); } PerformanceTimer::StartTimer("AO generation"); - m_SSAOPass->Draw(m_PickingPass->DepthBuffer(), frame.RenderScenes.front()->Camera); + //m_SSAOPass->Draw(m_PickingPass->DepthBuffer(), frame.RenderScenes.front()->Camera); GLuint ao = m_SSAOPass->SSAOTexture(); PerformanceTimer::StopTimer("AO generation"); for (auto scene : frame.RenderScenes){ diff --git a/src/Engine/Rendering/Skeleton.cpp b/src/Engine/Rendering/Skeleton.cpp index 4583de92..b6fea0bb 100644 --- a/src/Engine/Rendering/Skeleton.cpp +++ b/src/Engine/Rendering/Skeleton.cpp @@ -57,7 +57,7 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, const Animation* anim Animation::Keyframe::BoneProperty nextBoneProperty = nextFrame.BoneProperties; glm::vec3 position = currentBoneProperty.Position * (1.f - progress) + nextBoneProperty.Position * progress; - glm::quat rotation = glm::slerp(currentBoneProperty.Rotation, nextBoneProperty.Rotation, progress); + glm::quat rotation = glm::normalize(glm::slerp(currentBoneProperty.Rotation, nextBoneProperty.Rotation, progress)); glm::vec3 scale = currentBoneProperty.Scale * (1.f - progress) + nextBoneProperty.Scale * progress; // Flag for no root motion @@ -71,7 +71,7 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, const Animation* anim } else { // 1 keyframes for the current bone currentFrame = boneKeyFrames.at(0); - boneMatrix = (glm::translate(currentFrame.BoneProperties.Position) * glm::toMat4(currentFrame.BoneProperties.Rotation) * glm::scale(currentFrame.BoneProperties.Scale)); + boneMatrix = (glm::translate(currentFrame.BoneProperties.Position) * glm::toMat4(glm::normalize(currentFrame.BoneProperties.Rotation)) * glm::scale(currentFrame.BoneProperties.Scale)); boneMatrices[bone->ID] = boneMatrix;// *bone->OffsetMatrix; } } else { // 0 keyframes for the current bone @@ -244,7 +244,7 @@ glm::mat4 Skeleton::GetBoneTransform(const Bone* bone, const Animation* animatio } if (progress > 1.0f || progress < 0.0f) { - LOG_INFO("Progress %f", progress); + //LOG_INFO("Progress %f", progress); progress = glm::clamp(progress, 0.0f, 1.0f); } Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties; @@ -276,7 +276,7 @@ glm::mat4 Skeleton::GetBoneTransform(const Bone* bone, const Animation* animatio } } -std::map Skeleton::BlendPoses(const std::map& pose1, const std::map& pose2, float weight) +std::map Skeleton::BlendPoses(const std::map& pose1, const std::map& pose2, double weight) { std::map finalPose; @@ -285,8 +285,8 @@ std::map Skeleton::BlendPoses(const std::map& po glm::mat4 blendedPose = glm::mat4(0); if(pose1.find(boneID) != pose1.end() && pose2.find(boneID) != pose2.end()) { - blendedPose += pose1.at(boneID) * weight; - blendedPose += pose2.at(boneID) * (1.f - weight); + blendedPose += pose1.at(boneID) * (float)(1.0 - weight); + blendedPose += pose2.at(boneID) * (float)weight; finalPose[boneID] = blendedPose; } else if(pose1.find(boneID) != pose1.end()) { finalPose[boneID] = pose1.at(boneID); @@ -347,15 +347,11 @@ void Skeleton::GetFinalPose(std::map& boneMatrices, std::vector< void Skeleton::AccumulateFinalPose(std::map& boneMatrices, std::map& boneTransforms, const Bone* bone, glm::mat4 parentMatrix) { - glm::mat4 boneMatrix; - if (boneMatrices.find(bone->ID) != boneMatrices.end()) { - boneMatrix = parentMatrix * boneMatrices.at(bone->ID); boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix; - } else { if (bone->Parent) { boneMatrix = parentMatrix * (glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix); From c3f24f494d2352604d10ba349a512a51edb67da2 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Wed, 2 Mar 2016 13:34:47 +0100 Subject: [PATCH 127/252] fixup! AutoAnimationBlend on unique node working but scale is not working correctly Commited some things that shouldn't have been commited --- src/Engine/Core/Util/Logging.cpp | 4 ++-- src/Engine/Rendering/Renderer.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Engine/Core/Util/Logging.cpp b/src/Engine/Core/Util/Logging.cpp index e5427965..63a6f380 100644 --- a/src/Engine/Core/Util/Logging.cpp +++ b/src/Engine/Core/Util/Logging.cpp @@ -33,8 +33,8 @@ void _LOG(_LOG_LEVEL logLevel, const char* file, const char* func, unsigned int va_end(args); if (logLevel == LOG_LEVEL_ERROR) { - /*std::cerr << file << ":" << line << " " << func << std::endl; - std::cerr << _LOG_LEVEL_PREFIX[logLevel] << message << std::endl;*/ + std::cerr << file << ":" << line << " " << func << std::endl; + std::cerr << _LOG_LEVEL_PREFIX[logLevel] << message << std::endl; } else { std::cout << _LOG_LEVEL_PREFIX[logLevel] << message << std::endl; } diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index fd75911d..251bba2b 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -142,7 +142,7 @@ void Renderer::Draw(RenderFrame& frame) PerformanceTimer::StopTimer("Renderer-Depth"); } PerformanceTimer::StartTimer("AO generation"); - //m_SSAOPass->Draw(m_PickingPass->DepthBuffer(), frame.RenderScenes.front()->Camera); + m_SSAOPass->Draw(m_PickingPass->DepthBuffer(), frame.RenderScenes.front()->Camera); GLuint ao = m_SSAOPass->SSAOTexture(); PerformanceTimer::StopTimer("AO generation"); for (auto scene : frame.RenderScenes){ From 6968e71e0706a8adedbf8b135b7d25a6cf056107 Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 2 Mar 2016 13:36:24 +0100 Subject: [PATCH 128/252] Arrow should now correctly track the next point no matter when you join the game --- src/Game/Systems/CapturePointArrowHUDSystem.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Game/Systems/CapturePointArrowHUDSystem.cpp b/src/Game/Systems/CapturePointArrowHUDSystem.cpp index 3488c0a8..bf6951a2 100644 --- a/src/Game/Systems/CapturePointArrowHUDSystem.cpp +++ b/src/Game/Systems/CapturePointArrowHUDSystem.cpp @@ -101,6 +101,7 @@ void CapturePointArrowHUDSystem::Update(double dt) continue; } else { m_RedTeamCurrentTarget = got->second; + break; } } } else if ((int)homeRed["CapturePoint"]["CapturePointNumber"] == firstCP) { @@ -112,6 +113,7 @@ void CapturePointArrowHUDSystem::Update(double dt) continue; } else { m_RedTeamCurrentTarget = got->second; + break; } } } @@ -125,6 +127,7 @@ void CapturePointArrowHUDSystem::Update(double dt) continue; } else { m_BlueTeamCurrentTarget = got->second; + break; } } } else if ((int)homeBlue["CapturePoint"]["CapturePointNumber"] == firstCP) { @@ -136,6 +139,7 @@ void CapturePointArrowHUDSystem::Update(double dt) continue; } else { m_BlueTeamCurrentTarget = got->second; + break; } } } @@ -151,7 +155,7 @@ void CapturePointArrowHUDSystem::Update(double dt) pos = m_BlueTeamCurrentTarget; } - pos = currentTeam == redTeam ? m_RedTeamCurrentTarget : currentTeam == blueTeam ? m_BlueTeamCurrentTarget : glm::vec3(0.f); + //pos = currentTeam == redTeam ? m_RedTeamCurrentTarget : currentTeam == blueTeam ? m_BlueTeamCurrentTarget : glm::vec3(0.f); glm::vec3& arrowOri = arrowEntity["Transform"]["Orientation"]; glm::vec3 lookVector = glm::normalize(Transform::AbsolutePosition(arrowEntity) - pos); //Maybe should be player instead From 629ebb871f9f6bb70484f3aa15f1a919b1415242 Mon Sep 17 00:00:00 2001 From: William Moberg Date: Wed, 2 Mar 2016 13:45:49 +0100 Subject: [PATCH 129/252] SpectatorCamera shows capturepoint HUD and respawntimer. It no longer requires CapturePointGameMode component to work. --- include/Engine/Core/World.h | 3 + .../Schema/Entities/NewMapWSpectatorCam.xml | 183 ++++++++++++++++- resources/Schema/Entities/SpectatorCamera.xml | 185 +++++++++++++++++- src/Engine/Core/World.cpp | 18 ++ src/Game/Systems/PlayerDeathSystem.cpp | 14 +- src/Game/Systems/PlayerSpawnSystem.cpp | 51 +++-- 6 files changed, 420 insertions(+), 34 deletions(-) diff --git a/include/Engine/Core/World.h b/include/Engine/Core/World.h index c9f738ce..d8e2c7ba 100644 --- a/include/Engine/Core/World.h +++ b/include/Engine/Core/World.h @@ -6,6 +6,7 @@ #include "ObjectPool.h" #include "ComponentPool.h" #include "EventBroker.h" +struct EntityWrapper; class World { @@ -49,6 +50,8 @@ public: void SetName(EntityID entity, const std::string& name); // Get the textual name of an entity std::string GetName(EntityID entity) const; + // Get the first entity in the world with the name. + EntityWrapper GetFirstEntityByName(const std::string& name); private: EventBroker* m_EventBroker = nullptr; diff --git a/resources/Schema/Entities/NewMapWSpectatorCam.xml b/resources/Schema/Entities/NewMapWSpectatorCam.xml index f74a4857..5e8b6bc2 100644 --- a/resources/Schema/Entities/NewMapWSpectatorCam.xml +++ b/resources/Schema/Entities/NewMapWSpectatorCam.xml @@ -5335,18 +5335,197 @@ Fonts/DroidSans.ttf,64 - + - + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 2 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 3 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 4 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 1 + + + 0.59265931447347009 + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/SpectatorCamera.xml b/resources/Schema/Entities/SpectatorCamera.xml index dbfdecf0..5c3dc514 100644 --- a/resources/Schema/Entities/SpectatorCamera.xml +++ b/resources/Schema/Entities/SpectatorCamera.xml @@ -19,20 +19,199 @@ - + Time to respawn: 0 Fonts/DroidSans.ttf,64 - + - + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 2 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 3 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 4 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 1 + + + 0.59265931447347009 + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + diff --git a/src/Engine/Core/World.cpp b/src/Engine/Core/World.cpp index 9b323ff4..65bc60d2 100644 --- a/src/Engine/Core/World.cpp +++ b/src/Engine/Core/World.cpp @@ -1,6 +1,7 @@ #include "Core/World.h" #include "Core/EEntityDeleted.h" #include "Core/EComponentDeleted.h" +#include "Core/EntityWrapper.h" World::~World() { @@ -151,6 +152,23 @@ std::string World::GetName(EntityID entity) const } } +EntityWrapper World::GetFirstEntityByName(const std::string& name) +{ + auto itPair = GetDirectChildren(EntityID_Invalid); + for (auto it = itPair.first; it != itPair.second; it++) { + EntityID childEntityID = it->second; + EntityWrapper childEntity(this, childEntityID); + if (!childEntity.Valid()) { + continue; + } + EntityWrapper entityWithName = childEntity.Name() == name ? childEntity : childEntity.FirstChildByName(name); + if (entityWithName.Valid()) { + return entityWithName; + } + } + return EntityWrapper::Invalid; +} + EntityID World::generateEntityID() { // TODO: Make EntityID generation smarter diff --git a/src/Game/Systems/PlayerDeathSystem.cpp b/src/Game/Systems/PlayerDeathSystem.cpp index f645abe7..0f05da57 100644 --- a/src/Game/Systems/PlayerDeathSystem.cpp +++ b/src/Game/Systems/PlayerDeathSystem.cpp @@ -74,18 +74,14 @@ bool PlayerDeathSystem::OnEntityDeleted(Events::EntityDeleted& e) if (m_LocalPlayerDeathEffect.ID != e.DeletedEntity) { return false; } - // Set the spectator camera as active, if it exists. - auto pool = m_World->GetComponents("CapturePointGameMode"); - if (pool == nullptr || pool->size() == 0) { - return false; - } - ComponentWrapper modeComponent = *pool->begin(); - EntityWrapper theLevel = EntityWrapper(m_LocalPlayerDeathEffect.World, modeComponent.EntityID); - EntityWrapper spectatorCam = theLevel.FirstChildByName("SpectatorCamera"); - if (!spectatorCam.Valid() && spectatorCam.HasComponent("Camera")) { + + // Look for the spectator camera entity in the level. + EntityWrapper spectatorCam = m_World->GetFirstEntityByName("SpectatorCamera"); + if (!spectatorCam.Valid() || !spectatorCam.HasComponent("Camera") || LocalPlayer.Valid()) { return false; } Events::SetCamera eSetCamera; eSetCamera.CameraEntity = spectatorCam; m_EventBroker->Publish(eSetCamera); + return true; } diff --git a/src/Game/Systems/PlayerSpawnSystem.cpp b/src/Game/Systems/PlayerSpawnSystem.cpp index 2f6928af..b2bb1ecf 100644 --- a/src/Game/Systems/PlayerSpawnSystem.cpp +++ b/src/Game/Systems/PlayerSpawnSystem.cpp @@ -27,8 +27,7 @@ void PlayerSpawnSystem::Update(double dt) double& timer = (double&)modeComponent["RespawnTime"]; timer += dt; double maxRespawnTime = m_DbgConfigForceRespawn ? m_ForcedRespawnTime : (double)modeComponent["MaxRespawnTime"]; - EntityWrapper theLevel = EntityWrapper(m_World, modeComponent.EntityID); - EntityWrapper spectatorCam = theLevel.FirstChildByName("SpectatorCamera"); + EntityWrapper spectatorCam = m_World->GetFirstEntityByName("SpectatorCamera"); if (spectatorCam.Valid()) { EntityWrapper HUD = spectatorCam.FirstChildByName("SpectatorHUD"); if (HUD.Valid()) { @@ -66,7 +65,14 @@ void PlayerSpawnSystem::Update(double dt) // If the spawner has a team affiliation, check it if (spawner.HasComponent("Team")) { - if ((int)spawner["Team"]["Team"] != req.Team) { + auto cSpawnerTeam = spawner["Team"]; + if ((int)cSpawnerTeam["Team"] != req.Team) { + // Increase num spawned players if someone picks spectator, since it is valid to pick spectator + // but don't spawn anything, goto next spawnrequest. + if (req.Team == (int)cSpawnerTeam["Team"].Enum("Spectator")) { + ++numSpawnedPlayers; + break; + } continue; } } @@ -87,9 +93,9 @@ void PlayerSpawnSystem::Update(double dt) } } if (numSpawnedPlayers != (int)m_SpawnRequests.size()) { - LOG_DEBUG("%i players were supposed to be spawned, but %i was spawned.", (int)m_SpawnRequests.size(), numSpawnedPlayers); + LOG_DEBUG("%i players were supposed to be spawned or set as spectator, but only %i was handled.", (int)m_SpawnRequests.size(), numSpawnedPlayers); } else { - LOG_DEBUG("%i players were spawned.", numSpawnedPlayers); + LOG_DEBUG("%i players were spawned or set as spectator.", numSpawnedPlayers); } m_SpawnRequests.clear(); } @@ -100,24 +106,29 @@ bool PlayerSpawnSystem::OnInputCommand(Events::InputCommand& e) return false; } + if (e.Value == 0) { + return false; + } + + // A dead client should be able to swap to the spectator camera. + if (IsClient && !LocalPlayer.Valid()) { + // Set the spectator camera as active, if it exists. + // Find the camera. + EntityWrapper spectatorCam = m_World->GetFirstEntityByName("SpectatorCamera"); + if (spectatorCam.Valid() && spectatorCam.HasComponent("Camera")) { + Events::SetCamera eSetCamera; + eSetCamera.CameraEntity = spectatorCam; + m_EventBroker->Publish(eSetCamera); + } + } + // Team picks should be processed ONLY server-side! // Don't make a spawn request if we're the client. if (!IsServer && m_NetworkEnabled) { return false; } - if (e.Value == 0) { - return false; - } - - //TODO: Spectating? - //Right now, return if someone picks spectator. - //1 signifies spectator here, could not get Playerteam component since it may be invalid or without team comp. - if ((ComponentInfo::EnumType)e.Value == 1) { - return false; - } - - //Check if the player already requested spawn. + // Check if the player already requested spawn. auto iter = m_SpawnRequests.begin(); for (; iter != m_SpawnRequests.end(); ++iter) { if (iter->PlayerID == e.PlayerID) { @@ -126,11 +137,11 @@ bool PlayerSpawnSystem::OnInputCommand(Events::InputCommand& e) } if (iter != m_SpawnRequests.end()) { - //If player is in queue to spawn, then change their team affiliation in the request. + // If player is in queue to spawn, then change their team affiliation in the request. iter->Team = (ComponentInfo::EnumType)e.Value; } else if (m_PlayerEntities.count(e.PlayerID) == 0 || !m_PlayerEntities[e.PlayerID].Valid()) { - //If player is not in queue to spawn, then create a spawn request, - //but only if they are spectating and/or just connected. + // If player is not in queue to spawn, then create a spawn request, + // but only if they are spectating and/or just connected. SpawnRequest req; req.PlayerID = e.PlayerID; req.Team = (ComponentInfo::EnumType)e.Value; From ab7fd8954675185fc26ee176bf9ea0102c7b1d06 Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 2 Mar 2016 13:56:35 +0100 Subject: [PATCH 130/252] Should now correctly track if another player takes your last capture point --- include/Engine/Core/ECaptured.h | 3 +- .../Schema/Entities/NewMap2version3NEW.xml | 75 +++++++++---------- .../Systems/CapturePointArrowHUDSystem.cpp | 42 ++++------- src/Game/Systems/CapturePointSystem.cpp | 5 +- 4 files changed, 57 insertions(+), 68 deletions(-) diff --git a/include/Engine/Core/ECaptured.h b/include/Engine/Core/ECaptured.h index 48771cd7..047c5d7d 100644 --- a/include/Engine/Core/ECaptured.h +++ b/include/Engine/Core/ECaptured.h @@ -13,7 +13,8 @@ struct Captured : Event { int TeamNumberThatCapturedCapturePoint; EntityID CapturePointTakenID; - EntityWrapper NextCapturePoint; + EntityWrapper BlueTeamNextCapturePoint; + EntityWrapper RedTeamNextCapturePoint; }; } diff --git a/resources/Schema/Entities/NewMap2version3NEW.xml b/resources/Schema/Entities/NewMap2version3NEW.xml index d24675cd..5b224de3 100644 --- a/resources/Schema/Entities/NewMap2version3NEW.xml +++ b/resources/Schema/Entities/NewMap2version3NEW.xml @@ -810,6 +810,7 @@ + 8 @@ -820,9 +821,8 @@ - + - @@ -852,6 +852,7 @@ + 8 @@ -862,9 +863,8 @@ - + - @@ -894,6 +894,7 @@ + 8 @@ -904,9 +905,8 @@ - + - @@ -936,6 +936,7 @@ + 8 @@ -946,9 +947,8 @@ - + - @@ -978,6 +978,7 @@ + 8 @@ -988,9 +989,8 @@ - + - @@ -1020,6 +1020,7 @@ + 8 @@ -1030,9 +1031,8 @@ - + - @@ -1062,6 +1062,7 @@ + 8 @@ -1072,9 +1073,8 @@ - + - @@ -2326,6 +2326,7 @@ + 8 @@ -2336,9 +2337,8 @@ - + - @@ -2368,6 +2368,7 @@ + 8 @@ -2378,9 +2379,8 @@ - + - @@ -2865,6 +2865,7 @@ + 8 @@ -2875,9 +2876,8 @@ - + - @@ -2907,6 +2907,7 @@ + 8 @@ -2917,9 +2918,8 @@ - + - @@ -2949,6 +2949,7 @@ + 8 @@ -2959,9 +2960,8 @@ - + - @@ -2991,6 +2991,7 @@ + 8 @@ -3001,9 +3002,8 @@ - + - @@ -3033,6 +3033,7 @@ + 8 @@ -3043,9 +3044,8 @@ - + - @@ -3075,6 +3075,7 @@ + 8 @@ -3085,9 +3086,8 @@ - + - @@ -3117,6 +3117,7 @@ + 8 @@ -3127,9 +3128,8 @@ - + - @@ -4225,6 +4225,7 @@ -15 4 + Models/Core/UnitCylinder.mesh @@ -4239,7 +4240,6 @@ - @@ -4261,6 +4261,7 @@ 3 + Models/Core/UnitCylinder.mesh @@ -4271,7 +4272,6 @@ - @@ -4293,6 +4293,7 @@ 2 + Models/Core/UnitCylinder.mesh @@ -4303,7 +4304,6 @@ - @@ -4325,6 +4325,7 @@ 1 + Models/Core/UnitCylinder.mesh @@ -4335,7 +4336,6 @@ - @@ -4360,6 +4360,7 @@ 15 + Models/Core/UnitCylinder.mesh @@ -4374,7 +4375,6 @@ - @@ -4445,7 +4445,6 @@ 1 - false diff --git a/src/Game/Systems/CapturePointArrowHUDSystem.cpp b/src/Game/Systems/CapturePointArrowHUDSystem.cpp index bf6951a2..9e327a43 100644 --- a/src/Game/Systems/CapturePointArrowHUDSystem.cpp +++ b/src/Game/Systems/CapturePointArrowHUDSystem.cpp @@ -11,9 +11,9 @@ CapturePointArrowHUDSystem::CapturePointArrowHUDSystem(SystemParams params) void CapturePointArrowHUDSystem::Update(double dt) { bool loadCheck = true; - int redTeam; - int blueTeam; - int spectatorTeam; + int redTeamEnum; + int blueTeamEnum; + int spectatorTeamEnum; //Get list for all CapturePointArrowHUDComponents auto arrowHUDs = m_World->GetComponents("CapturePointArrowHUD"); @@ -35,9 +35,9 @@ void CapturePointArrowHUDSystem::Update(double dt) int currentTeam = (int)cTeam["Team"]; if (loadCheck) { - redTeam = (int)cTeam["Team"].Enum("Red"); - blueTeam = (int)cTeam["Team"].Enum("Blue"); - spectatorTeam = (int)cTeam["Team"].Enum("Spectator"); + redTeamEnum = (int)cTeam["Team"].Enum("Red"); + blueTeamEnum = (int)cTeam["Team"].Enum("Blue"); + spectatorTeamEnum = (int)cTeam["Team"].Enum("Spectator"); loadCheck = false; @@ -66,21 +66,21 @@ void CapturePointArrowHUDSystem::Update(double dt) int currentOwner = (int)capturePointEntity["Team"]["Team"]; - if(currentOwner != redTeam) { + if(currentOwner != redTeamEnum) { //This capturePoint is not owned by the red team and is therefor an eligible target for red team glm::vec3 targetPos = Transform::AbsolutePosition(capturePointEntity); redTargets.insert(std::pair(capturePointID, targetPos)); } - if(currentOwner != blueTeam) { + if(currentOwner != blueTeamEnum) { //This capturePoint is not owned by the blue team and is therefor an eligible target for blue team glm::vec3 targetPos = Transform::AbsolutePosition(capturePointEntity); blueTargets.insert(std::pair(capturePointID, targetPos)); } - if(homePointTeam == blueTeam) { + if(homePointTeam == blueTeamEnum) { //CP is the home point for blue team. homeBlue = capturePointEntity; - } else if (homePointTeam == redTeam) { + } else if (homePointTeam == redTeamEnum) { //CP is the home point for red team. homeRed = capturePointEntity; } @@ -149,14 +149,12 @@ void CapturePointArrowHUDSystem::Update(double dt) //Untill this is awailable we will just use the hardcoded value in the component. //This will also give us a position, so we wont need to loop through all capturePoints. glm::vec3 pos; - if(currentTeam == redTeam) { + if(currentTeam == redTeamEnum) { pos = m_RedTeamCurrentTarget; - } else if (currentTeam == blueTeam) { + } else if (currentTeam == blueTeamEnum) { pos = m_BlueTeamCurrentTarget; } - //pos = currentTeam == redTeam ? m_RedTeamCurrentTarget : currentTeam == blueTeam ? m_BlueTeamCurrentTarget : glm::vec3(0.f); - glm::vec3& arrowOri = arrowEntity["Transform"]["Orientation"]; glm::vec3 lookVector = glm::normalize(Transform::AbsolutePosition(arrowEntity) - pos); //Maybe should be player instead float pitch = std::asin(-lookVector.y); @@ -173,21 +171,13 @@ void CapturePointArrowHUDSystem::Update(double dt) bool CapturePointArrowHUDSystem::OnCapturePointCaptured(Events::Captured& e) { - if (!e.NextCapturePoint.HasComponent("Team")) { + if(!e.BlueTeamNextCapturePoint.Valid() || !e.RedTeamNextCapturePoint.Valid()) { return 0; } - auto cTeam = e.NextCapturePoint["Team"]; - - int redTeam = (int)cTeam["Team"].Enum("Red"); - int blueTeam = (int)cTeam["Team"].Enum("Blue"); - int spectatorTeam = (int)cTeam["Team"].Enum("Spectator"); - - if(e.TeamNumberThatCapturedCapturePoint == redTeam) { - m_RedTeamCurrentTarget = Transform::AbsolutePosition(e.NextCapturePoint); - } else if (e.TeamNumberThatCapturedCapturePoint == blueTeam) { - m_BlueTeamCurrentTarget = Transform::AbsolutePosition(e.NextCapturePoint); - } + m_RedTeamCurrentTarget = Transform::AbsolutePosition(e.RedTeamNextCapturePoint); + m_BlueTeamCurrentTarget = Transform::AbsolutePosition(e.BlueTeamNextCapturePoint); m_InitialtargetsSet = true; + return 0; } diff --git a/src/Game/Systems/CapturePointSystem.cpp b/src/Game/Systems/CapturePointSystem.cpp index 6cbb1b2f..0ff294b9 100644 --- a/src/Game/Systems/CapturePointSystem.cpp +++ b/src/Game/Systems/CapturePointSystem.cpp @@ -104,9 +104,8 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp } if (m_RecentlyCapturedNeedNextCapturePointNow) { //TODO: Next capture point for both teams - m_CapturedEvent.NextCapturePoint = m_CapturedEvent.TeamNumberThatCapturedCapturePoint == blueTeam ? - m_CapturePointNumberToEntityMap[nextPossibleCapturePoint["Blue"]] : - m_CapturePointNumberToEntityMap[nextPossibleCapturePoint["Red"]]; + m_CapturedEvent.BlueTeamNextCapturePoint = m_CapturePointNumberToEntityMap[nextPossibleCapturePoint["Blue"]]; + m_CapturedEvent.RedTeamNextCapturePoint = m_CapturePointNumberToEntityMap[nextPossibleCapturePoint["Red"]]; m_EventBroker->Publish(m_CapturedEvent); m_RecentlyCapturedNeedNextCapturePointNow = false; } From 1217b25d023ea78571744d3371dd1b2f5ce8ad1c Mon Sep 17 00:00:00 2001 From: stiffly Date: Wed, 2 Mar 2016 14:15:20 +0100 Subject: [PATCH 131/252] DashEffect will now spawn a player model behind the player that will fade out . --- .../Engine/Input/FirstPersonInputController.h | 5 +++- include/Game/Systems/PlayerMovementSystem.h | 2 ++ resources/Schema/Entities/DashEffect.xml | 18 ++++++++++++++ src/Game/Systems/PlayerMovementSystem.cpp | 24 ++++++++++++++++++- 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 resources/Schema/Entities/DashEffect.xml diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index d86af088..f28e4112 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -51,10 +51,11 @@ protected: bool m_ShiftDashing = false; bool m_ValidDoubleTap = false; - //specialabilitys + //specialabilities bool m_MovementKeyDown = false; bool m_SpecialAbilityKeyDown = false; int m_NumberOfMovementKeysDown = 0; + void spawnDashEffect(); EventRelay m_ELockMouse; bool OnLockMouse(const Events::LockMouse& e); @@ -207,6 +208,8 @@ void FirstPersonInputController::AssaultDashCheck(double dt, bool assaultDashCoolDownTimer = assaultDashCoolDownMaxTimer; m_AssaultDashDoubleTapped = true; m_AssaultDashDoubleTapDeltaTime = 0.f; + Events::DashAbility e; + m_EventBroker->Publish(e); return; } diff --git a/include/Game/Systems/PlayerMovementSystem.h b/include/Game/Systems/PlayerMovementSystem.h index 92aa1915..cdf8ee22 100644 --- a/include/Game/Systems/PlayerMovementSystem.h +++ b/include/Game/Systems/PlayerMovementSystem.h @@ -41,6 +41,8 @@ private: bool OnPlayerSpawned(Events::PlayerSpawned& e); EventRelay m_EDoubleJump; bool PlayerMovementSystem::OnDoubleJump(Events::DoubleJump & e); + EventRelay m_EDashAbility; + bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e); void updateMovementControllers(double dt); void updateVelocity(EntityWrapper player, double dt); diff --git a/resources/Schema/Entities/DashEffect.xml b/resources/Schema/Entities/DashEffect.xml new file mode 100644 index 00000000..b6bd53f7 --- /dev/null +++ b/resources/Schema/Entities/DashEffect.xml @@ -0,0 +1,18 @@ + + + + + + + 1 + + + + 0 + 1 + + + + + + diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 47612ca0..4925baa7 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -5,6 +5,7 @@ PlayerMovementSystem::PlayerMovementSystem(SystemParams params) { EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &PlayerMovementSystem::OnPlayerSpawned); EVENT_SUBSCRIBE_MEMBER(m_EDoubleJump, &PlayerMovementSystem::OnDoubleJump); + EVENT_SUBSCRIBE_MEMBER(m_EDashAbility, &PlayerMovementSystem::OnDashAbility); } PlayerMovementSystem::~PlayerMovementSystem() @@ -322,4 +323,25 @@ void PlayerMovementSystem::spawnHexagon(EntityWrapper target) EntityID hexagonEffectID = parser.MergeEntities(m_World); EntityWrapper hexagonEW = EntityWrapper(m_World, hexagonEffectID); hexagonEW["Transform"]["Position"] = (glm::vec3)target["Transform"]["Position"]; -} \ No newline at end of file +} + +bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) +{ + auto dashEffectResource = ResourceManager::Load("Schema/Entities/DashEffect.xml"); + EntityFileParser parser(dashEffectResource); + EntityID dashEffectID = parser.MergeEntities(m_World); + EntityWrapper dashEffect(m_World, dashEffectID); + auto playerModel = LocalPlayer.FirstChildByName("PlayerModel"); + auto playerEntityModel = playerModel["Model"]; + auto playerEntityAnimation = playerModel["Animation"]; + playerEntityModel.Copy(dashEffect["Model"]); + playerEntityAnimation.Copy(dashEffect["Animation"]); + dashEffect["ExplosionEffect"]["EndColor"] = (glm::vec4)playerEntityModel["Color"]; + ((glm::vec4&)dashEffect["ExplosionEffect"]["EndColor"]).w = 0.f; + dashEffect["Animation"]["Speed1"] = 0.0; + dashEffect["Animation"]["Speed2"] = 0.0; + dashEffect["Animation"]["Speed3"] = 0.0; + dashEffect["Transform"]["Position"] = (glm::vec3)LocalPlayer["Transform"]["Position"]; + dashEffect["Transform"]["Orientation"] = (glm::vec3)LocalPlayer["Transform"]["Orientation"]; + return true; +} From 95078b6a4b8e91ce381eb4b0b22b3d62a835dcce Mon Sep 17 00:00:00 2001 From: William Moberg Date: Wed, 2 Mar 2016 14:37:33 +0100 Subject: [PATCH 132/252] Fix so client doesn't override the servers respawn time with its config file. Server or single player client can still override the component with the config RespawnTime. --- resources/DefaultConfig.ini | 2 +- src/Game/Systems/PlayerSpawnSystem.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/resources/DefaultConfig.ini b/resources/DefaultConfig.ini index e99e3437..8917e3e1 100644 --- a/resources/DefaultConfig.ini +++ b/resources/DefaultConfig.ini @@ -4,7 +4,7 @@ LoadMap= ; if true -> Pool allocation is not used when calling Allocate/Free, just use regular dynamic allocation. ; if false -> Use pool allocation. DisableMemoryPool=false -RespawnTime = 8.0 +RespawnTime = -1.0 EditorEnabled=false OutOfBodyExperience=false diff --git a/src/Game/Systems/PlayerSpawnSystem.cpp b/src/Game/Systems/PlayerSpawnSystem.cpp index b2bb1ecf..6c41ddd4 100644 --- a/src/Game/Systems/PlayerSpawnSystem.cpp +++ b/src/Game/Systems/PlayerSpawnSystem.cpp @@ -10,7 +10,7 @@ PlayerSpawnSystem::PlayerSpawnSystem(SystemParams params) ConfigFile* config = ResourceManager::Load("Config.ini"); m_NetworkEnabled = config->Get("Networking.StartNetwork", false); m_ForcedRespawnTime = config->Get("Debug.RespawnTime", -1.0f); - m_DbgConfigForceRespawn = m_ForcedRespawnTime > 0; + m_DbgConfigForceRespawn = m_ForcedRespawnTime > 0 && IsServer; } void PlayerSpawnSystem::Update(double dt) @@ -26,7 +26,10 @@ void PlayerSpawnSystem::Update(double dt) // Increase timer. double& timer = (double&)modeComponent["RespawnTime"]; timer += dt; - double maxRespawnTime = m_DbgConfigForceRespawn ? m_ForcedRespawnTime : (double)modeComponent["MaxRespawnTime"]; + if (m_DbgConfigForceRespawn) { + (double&)modeComponent["MaxRespawnTime"] = m_ForcedRespawnTime; + } + double maxRespawnTime = (double)modeComponent["MaxRespawnTime"]; EntityWrapper spectatorCam = m_World->GetFirstEntityByName("SpectatorCamera"); if (spectatorCam.Valid()) { EntityWrapper HUD = spectatorCam.FirstChildByName("SpectatorHUD"); From cdbc348cfae65804caf5c4e5707423e7f23b3400 Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 2 Mar 2016 14:46:37 +0100 Subject: [PATCH 133/252] AbilityCooldownHUD should now correctly track cooldown for dash ability. --- .../Schema/Components/AbilityCooldownHUD.xsd | 2 +- resources/Schema/Entities/Player.xml | 39 ++++++++++++++++++- src/Game/Systems/AbilityCooldownHUDSystem.cpp | 8 ++-- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/resources/Schema/Components/AbilityCooldownHUD.xsd b/resources/Schema/Components/AbilityCooldownHUD.xsd index 066a9442..5bfb01a8 100644 --- a/resources/Schema/Components/AbilityCooldownHUD.xsd +++ b/resources/Schema/Components/AbilityCooldownHUD.xsd @@ -3,7 +3,7 @@ - HUD element for tracking ability cooldown + HUD element for tracking ability cooldown. If it has a sprite and fill component it will fill the sprite with chosen color depending on the cooldown.\n A child with text component named "Cooldown" \ No newline at end of file diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 28ace561..91b25bcb 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -12,6 +12,7 @@ + 52.867678870419283 @@ -122,6 +123,7 @@ Textures/HealthHUD3.png + false @@ -132,7 +134,42 @@ - + + + + + + + + + Textures/Core/White.png + false + + + + + + + + + + + + + 0.0 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + diff --git a/src/Game/Systems/AbilityCooldownHUDSystem.cpp b/src/Game/Systems/AbilityCooldownHUDSystem.cpp index 12d268c7..44180a62 100644 --- a/src/Game/Systems/AbilityCooldownHUDSystem.cpp +++ b/src/Game/Systems/AbilityCooldownHUDSystem.cpp @@ -17,10 +17,12 @@ void AbilityCooldownHUDSystem::Update(double dt) if(cooldownTextEntity.Valid()) { if(cooldownTextEntity.HasComponent("Text")) { - double abilityCD = (double)abilityEntity["DashAbility"]["CoolDownMaxTimer"]; - std::string t = (std::string&)cooldownTextEntity["Text"]["Content"] = std::to_string(abilityCD).substr(0, 3); + double maxAbilityCD = (double)abilityEntity["DashAbility"]["CoolDownMaxTimer"]; + double currentAbilityCD = (double)abilityEntity["DashAbility"]["CoolDownTimer"]; + currentAbilityCD = currentAbilityCD >= 0.0 ? currentAbilityCD : 0.0; + std::string t = (std::string&)cooldownTextEntity["Text"]["Content"] = std::to_string(currentAbilityCD).substr(0, 3); if(entity.HasComponent("Fill")) { - entity["Fill"]["Percentage"] = abilityCD/abilityCD; //TODO: current time needs to be in the component. + entity["Fill"]["Percentage"] = currentAbilityCD/maxAbilityCD; //TODO: current time needs to be in the component. } } } From 9161c11764bf0049e5f6adf27d3a10416c8f6d36 Mon Sep 17 00:00:00 2001 From: Jocke Date: Wed, 2 Mar 2016 15:31:42 +0100 Subject: [PATCH 134/252] Changed m_ETriggerTouchVector for-loop so it wont break when an item triggers the condition. This is done to update all somePickup.DecreaseThisRespawnTimer's. --- src/Game/Systems/AmmoPickupSystem.cpp | 9 ++++++--- src/Game/Systems/PickupSpawnSystem.cpp | 18 +++++++++++------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/Game/Systems/AmmoPickupSystem.cpp b/src/Game/Systems/AmmoPickupSystem.cpp index 6a24ee95..74d86f70 100644 --- a/src/Game/Systems/AmmoPickupSystem.cpp +++ b/src/Game/Systems/AmmoPickupSystem.cpp @@ -15,7 +15,8 @@ AmmoPickupSystem::AmmoPickupSystem(SystemParams params) void AmmoPickupSystem::Update(double dt) { if (IsServer) { - for (auto it = m_ETriggerTouchVector.begin(); it != m_ETriggerTouchVector.end(); ++it) { + auto it = m_ETriggerTouchVector.begin(); + while (it != m_ETriggerTouchVector.end()) { auto& somePickup = *it; somePickup.DecreaseThisRespawnTimer -= dt; if (somePickup.DecreaseThisRespawnTimer < 0.0) { @@ -36,8 +37,10 @@ void AmmoPickupSystem::Update(double dt) m_World->SetParent(newAmmoPickupEntity.ID, somePickup.parentID); //erase the current element (somePickup) - m_ETriggerTouchVector.erase(it); - break; + it = m_ETriggerTouchVector.erase(it); + } + else { + it++; } } //still touching m_PickupAtMaximum? diff --git a/src/Game/Systems/PickupSpawnSystem.cpp b/src/Game/Systems/PickupSpawnSystem.cpp index 6bfd2ee6..79e7d66b 100644 --- a/src/Game/Systems/PickupSpawnSystem.cpp +++ b/src/Game/Systems/PickupSpawnSystem.cpp @@ -12,7 +12,8 @@ PickupSpawnSystem::PickupSpawnSystem(SystemParams params) void PickupSpawnSystem::Update(double dt) { if (IsServer) { - for (auto it = m_ETriggerTouchVector.begin(); it != m_ETriggerTouchVector.end(); ++it) { + auto it = m_ETriggerTouchVector.begin(); + while (it != m_ETriggerTouchVector.end()) { auto& somePickup = *it; somePickup.DecreaseThisRespawnTimer -= dt; if (somePickup.DecreaseThisRespawnTimer < 0.0) { @@ -34,8 +35,9 @@ void PickupSpawnSystem::Update(double dt) m_World->SetParent(newHealthPickupEntity.ID, somePickup.parentID); //erase the current element (somePickup) - m_ETriggerTouchVector.erase(it); - break; + it = m_ETriggerTouchVector.erase(it); + } else { + it++; } } //still touching PickupAtMaximum? @@ -66,7 +68,8 @@ bool PickupSpawnSystem::OnTriggerTouch(Events::TriggerTouch& e) DoPickup(e.Entity, e.Trigger); return true; } -bool PickupSpawnSystem::OnTriggerLeave(Events::TriggerLeave& e) { +bool PickupSpawnSystem::OnTriggerLeave(Events::TriggerLeave& e) +{ if (!e.Trigger.HasComponent("HealthPickup")) { return false; } @@ -79,7 +82,8 @@ bool PickupSpawnSystem::OnTriggerLeave(Events::TriggerLeave& e) { } return true; } -void PickupSpawnSystem::DoPickup(EntityWrapper &player, EntityWrapper &trigger) { +void PickupSpawnSystem::DoPickup(EntityWrapper &player, EntityWrapper &trigger) +{ double healthGiven = 0.01*(double)trigger["HealthPickup"]["HealthGain"] * (double)player["Health"]["MaxHealth"]; //only the server will increase the players hp and set it in the next delta @@ -90,8 +94,8 @@ void PickupSpawnSystem::DoPickup(EntityWrapper &player, EntityWrapper &trigger) //copy position, healthgain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object) //we need to copy all values since each value can be different for each healthPickup - m_ETriggerTouchVector.push_back({ (glm::vec3)trigger["Transform"]["Position"] ,trigger["HealthPickup"]["HealthGain"], - trigger["HealthPickup"]["RespawnTimer"],trigger["HealthPickup"]["RespawnTimer"], m_World->GetParent(trigger.ID) }); + m_ETriggerTouchVector.push_back({ (glm::vec3)trigger["Transform"]["Position"], trigger["HealthPickup"]["HealthGain"], + trigger["HealthPickup"]["RespawnTimer"], trigger["HealthPickup"]["RespawnTimer"], m_World->GetParent(trigger.ID) }); //delete the healthpickup m_World->DeleteEntity(trigger.ID); From dc10661e6b8eb1ce0b69fceb5d80b9ced0d8b346 Mon Sep 17 00:00:00 2001 From: William Moberg Date: Wed, 2 Mar 2016 16:45:43 +0100 Subject: [PATCH 135/252] Respawn time now only displays numbers, centered below CPHUD. --- resources/Schema/Entities/NewMapWSpectatorCam.xml | 7 ++----- src/Game/Systems/PlayerSpawnSystem.cpp | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/resources/Schema/Entities/NewMapWSpectatorCam.xml b/resources/Schema/Entities/NewMapWSpectatorCam.xml index 5e8b6bc2..bf1b4c2b 100644 --- a/resources/Schema/Entities/NewMapWSpectatorCam.xml +++ b/resources/Schema/Entities/NewMapWSpectatorCam.xml @@ -3,7 +3,7 @@ - 3.6027407165331624 + 0.0 15 @@ -5336,12 +5336,9 @@ Fonts/DroidSans.ttf,64 - - - - + diff --git a/src/Game/Systems/PlayerSpawnSystem.cpp b/src/Game/Systems/PlayerSpawnSystem.cpp index 6c41ddd4..fbda849d 100644 --- a/src/Game/Systems/PlayerSpawnSystem.cpp +++ b/src/Game/Systems/PlayerSpawnSystem.cpp @@ -37,7 +37,7 @@ void PlayerSpawnSystem::Update(double dt) EntityWrapper respawnTimer = spectatorCam.FirstChildByName("RespawnTimer"); if (respawnTimer.Valid()) { //Update respawn time in the HUD element. - respawnTimer["Text"]["Content"] = "Time to respawn: " + std::to_string(1 + (int)(maxRespawnTime - timer)); + respawnTimer["Text"]["Content"] = std::to_string(1 + (int)(maxRespawnTime - timer)); } } } From 78835f95d8bcb57e1818491ebcf780adb1d29fc0 Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 2 Mar 2016 16:47:30 +0100 Subject: [PATCH 136/252] Removed comment --- src/Game/Systems/CapturePointSystem.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Game/Systems/CapturePointSystem.cpp b/src/Game/Systems/CapturePointSystem.cpp index 0ff294b9..0d6089c5 100644 --- a/src/Game/Systems/CapturePointSystem.cpp +++ b/src/Game/Systems/CapturePointSystem.cpp @@ -103,7 +103,6 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp } } if (m_RecentlyCapturedNeedNextCapturePointNow) { - //TODO: Next capture point for both teams m_CapturedEvent.BlueTeamNextCapturePoint = m_CapturePointNumberToEntityMap[nextPossibleCapturePoint["Blue"]]; m_CapturedEvent.RedTeamNextCapturePoint = m_CapturePointNumberToEntityMap[nextPossibleCapturePoint["Red"]]; m_EventBroker->Publish(m_CapturedEvent); From a5c086e3899c6b54520408aa860f318470878296 Mon Sep 17 00:00:00 2001 From: stiffly Date: Wed, 2 Mar 2016 16:48:38 +0100 Subject: [PATCH 137/252] Dash effect now working over network, by sending events. Similar to jump effect. --- .../Engine/Input/FirstPersonInputController.h | 14 ++++++-- include/Engine/Network/Client.h | 5 +++ include/Engine/Network/MessageType.h | 1 + include/Engine/Network/Server.h | 1 + include/Game/Events/EDashAbility.h | 6 +++- resources/Schema/Entities/DashEffect.xml | 6 ++-- src/Engine/Network/Client.cpp | 36 +++++++++++++++++-- src/Engine/Network/Server.cpp | 10 +++++- src/Game/Systems/PlayerMovementSystem.cpp | 19 ++++++---- 9 files changed, 81 insertions(+), 17 deletions(-) diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index f28e4112..efa3c38e 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -27,7 +27,7 @@ public: virtual bool OnCommand(const Events::InputCommand& e) override; virtual void Reset(); - void AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer, double& assaultDashCoolDownTimer); + void AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer, double& assaultDashCoolDownTimer, EntityWrapper player); virtual bool AssaultDashDoubleTapped() const { return m_AssaultDashDoubleTapped; } virtual bool PlayerIsDashing() const { return m_PlayerIsDashing; } @@ -41,6 +41,7 @@ protected: bool m_Crouching = false; //assault dash membervariables - needed to calculate the doubletap- and dashlogic double m_AssaultDashDoubleTapDeltaTime = 0.0; + double m_DashEffectResetTimer = 0.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; @@ -191,12 +192,19 @@ bool FirstPersonInputController::OnLockMouse(const Events::LockMou } template -void FirstPersonInputController::AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer, double& assaultDashCoolDownTimer) { +void FirstPersonInputController::AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer, double& assaultDashCoolDownTimer, EntityWrapper player) { m_AssaultDashDoubleTapDeltaTime += dt; + m_DashEffectResetTimer += dt; assaultDashCoolDownTimer -= dt; //cooldown = assaultDashCoolDownMaxTimer sec, pretend the dash lasts 0.25 sec (for friction to do its work) if (assaultDashCoolDownTimer > (assaultDashCoolDownMaxTimer - 0.25f)) { m_PlayerIsDashing = true; + if (m_DashEffectResetTimer > 0.05) { + Events::DashAbility e; + e.Player = player.ID; + m_EventBroker->Publish(e); + m_DashEffectResetTimer = 0.0; + } } else { m_PlayerIsDashing = false; } @@ -209,6 +217,7 @@ void FirstPersonInputController::AssaultDashCheck(double dt, bool m_AssaultDashDoubleTapped = true; m_AssaultDashDoubleTapDeltaTime = 0.f; Events::DashAbility e; + e.Player = player.ID; m_EventBroker->Publish(e); return; } @@ -240,6 +249,7 @@ void FirstPersonInputController::AssaultDashCheck(double dt, bool assaultDashCoolDownTimer = assaultDashCoolDownMaxTimer; Events::DashAbility e; + e.Player = player.ID; m_EventBroker->Publish(e); } diff --git a/include/Engine/Network/Client.h b/include/Engine/Network/Client.h index c407f7f8..4ee071d2 100644 --- a/include/Engine/Network/Client.h +++ b/include/Engine/Network/Client.h @@ -28,6 +28,7 @@ #include "Core/EPlayerSpawned.h" #include "Core/EAmmoPickup.h" #include "Network/ESearchForServers.h" +#include "../Game/Events/EDashAbility.h" struct ServerInfo { @@ -107,6 +108,7 @@ private: void parsePlayerDamage(Packet& packet); void parseComponentDeletion(Packet& packet); void parseDoubleJump(Packet& packet); + void parseDashEffect(Packet& packet); void parseAmmoPickup(Packet& packet); void InterpolateFields(Packet& packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType); void parseSnapshot(Packet& packet); @@ -135,6 +137,9 @@ private: EventRelay< Client, Events::SearchForServers> m_ESearchForServers; EventRelay m_EDoubleJump; bool OnDoubleJump(Events::DoubleJump & e); + EventRelay m_EDashAbility; + bool OnDashAbility(const Events::DashAbility& e); + bool OnSearchForServers(const Events::SearchForServers& e); UDPClient m_ServerlistRequest; std::vector m_Serverlist; diff --git a/include/Engine/Network/MessageType.h b/include/Engine/Network/MessageType.h index bf773618..c34f584e 100644 --- a/include/Engine/Network/MessageType.h +++ b/include/Engine/Network/MessageType.h @@ -20,6 +20,7 @@ enum class MessageType ComponentDeleted, PlayerTransform, OnDoubleJump, + OnDashEffect, ServerlistRequest, AmmoPickup, Invalid diff --git a/include/Engine/Network/Server.h b/include/Engine/Network/Server.h index 3c956ed9..7bcefc65 100644 --- a/include/Engine/Network/Server.h +++ b/include/Engine/Network/Server.h @@ -83,6 +83,7 @@ private: void parseClientPing(); void parsePing(); bool parseDoubleJump(Packet& packet); + void parseDashEffect(Packet& packet); void parseUDPConnect(Packet& packet); void parseTCPConnect(Packet& packet); void parseDisconnect(); diff --git a/include/Game/Events/EDashAbility.h b/include/Game/Events/EDashAbility.h index 62a2b935..c5078fab 100644 --- a/include/Game/Events/EDashAbility.h +++ b/include/Game/Events/EDashAbility.h @@ -2,11 +2,15 @@ #define Events_DashAbility_h__ #include "Core/Event.h" +#include "Core/EntityWrapper.h" namespace Events { -struct DashAbility : public Event { }; +struct DashAbility : public Event +{ + EntityID Player; +}; } diff --git a/resources/Schema/Entities/DashEffect.xml b/resources/Schema/Entities/DashEffect.xml index b6bd53f7..9dfdc14c 100644 --- a/resources/Schema/Entities/DashEffect.xml +++ b/resources/Schema/Entities/DashEffect.xml @@ -1,15 +1,15 @@ - + - 1 + 0.5 0 - 1 + 0.5 diff --git a/src/Engine/Network/Client.cpp b/src/Engine/Network/Client.cpp index aa87f6ff..d666e550 100644 --- a/src/Engine/Network/Client.cpp +++ b/src/Engine/Network/Client.cpp @@ -33,6 +33,7 @@ void Client::Connect(std::string address, int port) EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &Client::OnPlayerDamage); EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &Client::OnPlayerSpawned); EVENT_SUBSCRIBE_MEMBER(m_EDoubleJump, &Client::OnDoubleJump); + EVENT_SUBSCRIBE_MEMBER(m_EDashAbility, &Client::OnDashAbility); EVENT_SUBSCRIBE_MEMBER(m_ESearchForServers, &Client::OnSearchForServers); auto config = ResourceManager::Load("Config.ini"); m_Address = address; @@ -143,6 +144,9 @@ void Client::parseMessageType(Packet& packet) case MessageType::OnDoubleJump: parseDoubleJump(packet); break; + case MessageType::OnDashEffect: + parseDashEffect(packet); + break; case MessageType::AmmoPickup: parseAmmoPickup(packet); break; @@ -262,7 +266,7 @@ void Client::parseEntityDeletion(Packet & packet) if (m_ServerIDToClientID.find(entityToDelete) != m_ServerIDToClientID.end()) { EntityID localEntity = m_ServerIDToClientID.at(entityToDelete); if (m_World->ValidEntity(localEntity)) { - if (m_World->HasComponent(localEntity,"Player")) { + if (m_World->HasComponent(localEntity, "Player")) { Events::PlayerDeath e; e.Player = EntityWrapper(m_World, localEntity); m_EventBroker->Publish(e); @@ -297,8 +301,22 @@ void Client::parseDoubleJump(Packet & packet) } } + +void Client::parseDashEffect(Packet& packet) +{ + EntityID serverID = packet.ReadPrimitive(); + if (!serverClientMapsHasEntity(serverID)) { + return; + } + Events::DashAbility e; + e.Player = m_ServerIDToClientID.at(serverID); + if (e.Player != m_LocalPlayer.ID) { + m_EventBroker->Publish(e); + } +} + void Client::parseAmmoPickup(Packet & packet) -{ +{ Events::AmmoPickup e; e.AmmoGain = packet.ReadPrimitive(); e.Player = m_LocalPlayer; @@ -388,7 +406,7 @@ void Client::parseSnapshot(Packet& packet) if (m_SnapshotFilter != nullptr) { shouldApply = m_SnapshotFilter->FilterComponent(localEntity, newComponent); } - if (shouldApply) { + if (shouldApply) { ComponentWrapper currentComponent = m_World->GetComponent(localEntityID, componentType); memcpy(currentComponent.Data, newComponent.Data, componentInfo.Stride); } @@ -518,6 +536,18 @@ bool Client::OnPlayerSpawned(const Events::PlayerSpawned& e) return true; } + +bool Client::OnDashAbility(const Events::DashAbility& e) +{ + if (!clientServerMapsHasEntity(e.Player) || e.Player != m_LocalPlayer.ID) { + return false; + } + Packet packet(MessageType::OnDashEffect); + packet.WritePrimitive(m_ClientIDToServerID.at(e.Player)); + m_Reliable.Send(packet); + return true; +} + bool Client::OnSearchForServers(const Events::SearchForServers& e) { m_SearchingForServers = true; diff --git a/src/Engine/Network/Server.cpp b/src/Engine/Network/Server.cpp index 08b72304..7ba54ec4 100644 --- a/src/Engine/Network/Server.cpp +++ b/src/Engine/Network/Server.cpp @@ -141,6 +141,9 @@ void Server::parseMessageType(Packet& packet) case MessageType::OnDoubleJump: parseDoubleJump(packet); break; + case MessageType::OnDashEffect: + parseDashEffect(packet); + break; default: break; } @@ -555,6 +558,11 @@ bool Server::parseDoubleJump(Packet & packet) return true; } +void Server::parseDashEffect(Packet& packet) +{ + reliableBroadcast(packet); +} + void Server::parseOnInputCommand(Packet& packet) { PlayerID player = -1; @@ -624,7 +632,7 @@ bool Server::shouldSendToClient(EntityWrapper childEntity) } return childEntity.HasComponent("Player") || childEntity.FirstParentWithComponent("Player").Valid() || childEntity.HasComponent("CapturePoint") || childEntity.HasComponent("HealthPickup") - || childEntity.HasComponent("AmmoPickup"); + || childEntity.HasComponent("AmmoPickup")/* || childEntity.Name() == "DashEffect"*/; } PlayerID Server::GetPlayerIDFromEndpoint() diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 4925baa7..24bf6b05 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -67,7 +67,7 @@ void PlayerMovementSystem::updateMovementControllers(double dt) ComponentWrapper cPhysics = player["Physics"]; //Assault Dash Check if (player.HasComponent("DashAbility")) { - controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f, player["DashAbility"]["CoolDownMaxTimer"], player["DashAbility"]["CoolDownTimer"]); + controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f, player["DashAbility"]["CoolDownMaxTimer"], player["DashAbility"]["CoolDownTimer"], player); } wishDirection = controller->Movement() * glm::inverse(glm::quat(ori)); //this makes sure you can only dash in the 4 directions: forw,backw,left,right @@ -304,11 +304,11 @@ bool PlayerMovementSystem::OnPlayerSpawned(Events::PlayerSpawned& e) bool PlayerMovementSystem::OnDoubleJump(Events::DoubleJump & e) { // If entity does not exist, exit - if (!EntityWrapper(m_World, e.entityID).Valid()) { + if (!EntityWrapper(m_World, e.entityID).Valid()) { return false; } // If entity IsLocalPlayer, exit - if (e.entityID == m_LocalPlayer.ID) { + if (e.entityID == m_LocalPlayer.ID) { return false; } spawnHexagon(EntityWrapper(m_World, e.entityID)); @@ -316,7 +316,7 @@ bool PlayerMovementSystem::OnDoubleJump(Events::DoubleJump & e) } void PlayerMovementSystem::spawnHexagon(EntityWrapper target) -{ +{ //put a hexagon at the entitys... feet? auto hexagonEffect = ResourceManager::Load("Schema/Entities/DoubleJumpHexagon.xml"); EntityFileParser parser(hexagonEffect); @@ -327,11 +327,16 @@ void PlayerMovementSystem::spawnHexagon(EntityWrapper target) bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) { + EntityWrapper player(m_World, e.Player); + if (!player.Valid() || !IsClient) { + return false; + } + auto dashEffectResource = ResourceManager::Load("Schema/Entities/DashEffect.xml"); EntityFileParser parser(dashEffectResource); EntityID dashEffectID = parser.MergeEntities(m_World); EntityWrapper dashEffect(m_World, dashEffectID); - auto playerModel = LocalPlayer.FirstChildByName("PlayerModel"); + auto playerModel = player.FirstChildByName("PlayerModel"); auto playerEntityModel = playerModel["Model"]; auto playerEntityAnimation = playerModel["Animation"]; playerEntityModel.Copy(dashEffect["Model"]); @@ -341,7 +346,7 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) dashEffect["Animation"]["Speed1"] = 0.0; dashEffect["Animation"]["Speed2"] = 0.0; dashEffect["Animation"]["Speed3"] = 0.0; - dashEffect["Transform"]["Position"] = (glm::vec3)LocalPlayer["Transform"]["Position"]; - dashEffect["Transform"]["Orientation"] = (glm::vec3)LocalPlayer["Transform"]["Orientation"]; + dashEffect["Transform"]["Position"] = (glm::vec3)player["Transform"]["Position"]; + dashEffect["Transform"]["Orientation"] = (glm::vec3)player["Transform"]["Orientation"]; return true; } From 233a1d0990f53536065b5842088adaa7f0f6fa08 Mon Sep 17 00:00:00 2001 From: stiffly Date: Wed, 2 Mar 2016 16:56:43 +0100 Subject: [PATCH 138/252] The dash effect is now ignored on the local player, because it was annoying. Copies of yourself could be in your way. --- src/Game/Systems/PlayerMovementSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 24bf6b05..ae1d1d9b 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -328,7 +328,7 @@ void PlayerMovementSystem::spawnHexagon(EntityWrapper target) bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) { EntityWrapper player(m_World, e.Player); - if (!player.Valid() || !IsClient) { + if (!player.Valid() || !IsClient || player.ID == LocalPlayer.ID) { return false; } From 1aefa1dec6028ff1ad0290f3442e881d2ba9dc61 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Wed, 2 Mar 2016 17:06:51 +0100 Subject: [PATCH 139/252] AutoAnimationBlend now working correctly for unique nodes --- assets | 2 +- include/Engine/Rendering/BlendTree.h | 5 +- include/Engine/Rendering/Skeleton.h | 29 +- resources/Schema/Entities/AnimationTests2.xml | 254 +++++++++--------- src/Engine/Rendering/BlendTree.cpp | 4 +- src/Engine/Rendering/BoneAttachmentSystem.cpp | 13 + src/Engine/Rendering/DrawBloomPass.cpp | 2 + src/Engine/Rendering/SSAOPass.cpp | 4 + src/Engine/Rendering/Skeleton.cpp | 236 +++++----------- 9 files changed, 240 insertions(+), 309 deletions(-) diff --git a/assets b/assets index 10a61165..4e2b71f1 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 10a611659ddaadfea6a560e707d395834855a979 +Subproject commit 4e2b71f13a3026d06ccde2337c41427e73400c80 diff --git a/include/Engine/Rendering/BlendTree.h b/include/Engine/Rendering/BlendTree.h index b19fbe4f..29ad3ca9 100644 --- a/include/Engine/Rendering/BlendTree.h +++ b/include/Engine/Rendering/BlendTree.h @@ -19,6 +19,7 @@ public: Animation, }; + struct Node { @@ -27,7 +28,7 @@ public: Node* Parent = nullptr; Node* Child[2] = { nullptr, nullptr }; NodeType Type; - std::map Pose; + std::map Pose; //std::vector Pose; double Weight = 0.0; @@ -85,7 +86,7 @@ private: BlendTree::Node* FillTreeByName(Node* parentNode, std::string name, EntityWrapper parentEntity); std::vector FindNodesByName(std::string name); - void Blend(std::map& pose); + void Blend(std::map& pose); }; #endif diff --git a/include/Engine/Rendering/Skeleton.h b/include/Engine/Rendering/Skeleton.h index e812bf12..08e348ab 100644 --- a/include/Engine/Rendering/Skeleton.h +++ b/include/Engine/Rendering/Skeleton.h @@ -50,11 +50,16 @@ public: std::map> JointAnimations; }; + struct PoseData { + glm::vec3 Translation; + glm::quat Orientation; + glm::vec3 Scale; + }; + Skeleton() { } ~Skeleton(); Bone* RootBone; - std::map Bones; std::unordered_map> BlendTrees; @@ -65,20 +70,20 @@ public: int GetBoneID(std::string name); const Animation* GetAnimation(std::string name); - std::map GetFrameBones(const Animation* animation, double time, bool additive, bool noRootMotion = false); - glm::mat4 GetBoneTransform(const Bone* bone, const Animation* animation, float time, glm::mat4 childMatrix); - std::map BlendPoses(const std::map& pose1, const std::map& pose2, double weight); - std::map OverridePose(const std::map& overridePose, const std::map& targetPose); - std::map BlendPoseAdditive(const std::map& additivePose, const std::map& targetPose); - void GetFinalPose(std::map& boneMatrices, std::vector& finalPose, std::map& boneTransforms); + std::map GetFrameBones(const Animation* animation, double time, bool additive, bool noRootMotion = false); + + std::map BlendPoses(const std::map& pose1, const std::map& pose2, double weight); + std::map OverridePose(const std::map& overridePose, const std::map& targetPose); + std::map BlendPoseAdditive(const std::map& additivePose, const std::map& targetPose); + void GetFinalPose(std::map& boneMatrices, std::vector& finalPose, std::map& boneTransforms); std::map Animations; private: - glm::mat4 GetAdditiveBonePose(const Bone* bone, const Animation* animation, double time); - glm::mat4 GetBonePose(const Bone* bone, const Animation* animation, double time, bool noRootMotion); - void AccumulateFinalPose(std::map& boneMatrices, std::map& boneTransforms, const Bone* bone, glm::mat4 parentMatrix); - void AdditiveBoneTransforms(const Animation* animation, double time, std::map& boneMatrices, const Bone* bone); - void AccumulateBoneTransforms(bool noRootMotion, const Animation* animation, double time, std::map& boneMatrices, const Bone* bone, glm::mat4 parentMatrix); + Skeleton::PoseData GetAdditiveBonePose(const Bone* bone, const Animation* animation, double time); + + void AccumulateFinalPose(std::map& boneMatrices, std::map& poseDatas, std::map& boneTransforms, const Bone* bone, glm::mat4 parentMatrix); + void AdditiveBoneTransforms(const Animation* animation, double time, std::map& boneMatrices, const Bone* bone); + void AccumulateBoneTransforms(bool noRootMotion, const Animation* animation, double time, std::map& boneMatrices, const Bone* bone); std::map m_BonesByName; diff --git a/resources/Schema/Entities/AnimationTests2.xml b/resources/Schema/Entities/AnimationTests2.xml index fa2a8463..aaa6de48 100644 --- a/resources/Schema/Entities/AnimationTests2.xml +++ b/resources/Schema/Entities/AnimationTests2.xml @@ -66,11 +66,12 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh + - + - + @@ -90,7 +91,7 @@ AimRifleA - + false true @@ -131,7 +132,7 @@ ShootFastRifleU - + 1 @@ -142,7 +143,7 @@ ShootRifleU - + 1 @@ -155,8 +156,8 @@ ReloadSwitchU - - false + + 1 @@ -169,7 +170,7 @@ StandCrouchBlend Jump - 0.48000049591064453 + 0 @@ -198,7 +199,7 @@ CrouchWalkF - + 1 @@ -219,7 +220,7 @@ CrouchStrafeLeftF - + 1 @@ -230,7 +231,7 @@ CrouchStrafeRightF - + 1 @@ -246,7 +247,7 @@ RunWalkBlend StrafeBlend - 0 + 1 @@ -265,7 +266,8 @@ RunF - + + 1 @@ -275,7 +277,7 @@ WalkF - + 1 @@ -289,7 +291,7 @@ Left Right - 0 + 1 @@ -298,7 +300,7 @@ StrafeLeftF - + 1 @@ -309,7 +311,7 @@ StrafeRightF - + 1 @@ -326,8 +328,8 @@ JumpF - - false + + 1 @@ -352,13 +354,13 @@ Models/Core/UnitCube.mesh - + true - + - + @@ -372,12 +374,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -391,12 +393,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -410,12 +412,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -429,12 +431,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -448,12 +450,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -467,12 +469,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -486,12 +488,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -505,12 +507,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -524,12 +526,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -543,12 +545,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -562,12 +564,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -581,12 +583,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -600,12 +602,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -619,12 +621,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -638,12 +640,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -657,12 +659,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -676,12 +678,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -695,12 +697,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -714,12 +716,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -733,12 +735,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -752,12 +754,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -771,12 +773,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -790,12 +792,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -809,12 +811,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -828,12 +830,12 @@ Models/Core/UnitCube.mesh - + - - - + + + @@ -847,12 +849,12 @@ Models/Core/UnitCube.mesh - + - - - + + + diff --git a/src/Engine/Rendering/BlendTree.cpp b/src/Engine/Rendering/BlendTree.cpp index 8ef67f0f..cb7ffa69 100644 --- a/src/Engine/Rendering/BlendTree.cpp +++ b/src/Engine/Rendering/BlendTree.cpp @@ -238,7 +238,7 @@ BlendTree::AutoBlendInfo BlendTree::AutoBlendStep(AutoBlendInfo blendInfo) return blendInfo; } -void BlendTree::Blend(std::map& pose) +void BlendTree::Blend(std::map& pose) { Node* currentNode; Node* start = m_Root; @@ -301,7 +301,7 @@ std::vector BlendTree::AccumulateFinalPose() return finalPose; } - std::map pose; + std::map pose; Blend(pose); m_Skeleton->GetFinalPose(pose, finalPose, m_FinalBoneTransforms); diff --git a/src/Engine/Rendering/BoneAttachmentSystem.cpp b/src/Engine/Rendering/BoneAttachmentSystem.cpp index 43dc8634..191fb3bd 100644 --- a/src/Engine/Rendering/BoneAttachmentSystem.cpp +++ b/src/Engine/Rendering/BoneAttachmentSystem.cpp @@ -50,6 +50,19 @@ void BoneAttachmentSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapp glm::vec4 perspective; glm::decompose(boneTransform, scale, rotation, translation, skew, perspective); + float lowRange = 0.98f; + float highRange = 1.02f; + if(scale.x < lowRange || scale.y < lowRange || scale.z < lowRange || + scale.x > highRange || scale.y > highRange || scale.z > highRange) { + if (entity.HasComponent("Model")) { + (glm::vec4&)entity["Model"]["Color"] = glm::vec4(1, 0, 0, 1); + } + } else { + if (entity.HasComponent("Model")) { + (glm::vec4&)entity["Model"]["Color"] = glm::vec4(0, 1, 0, 1); + } + } + glm::vec3 angles = glm::vec3(-glm::pitch(rotation), -glm::yaw(rotation), -glm::roll(rotation)); if ((bool)entity["BoneAttachment"]["InheritPosition"]) { diff --git a/src/Engine/Rendering/DrawBloomPass.cpp b/src/Engine/Rendering/DrawBloomPass.cpp index 12777941..73f73cc4 100644 --- a/src/Engine/Rendering/DrawBloomPass.cpp +++ b/src/Engine/Rendering/DrawBloomPass.cpp @@ -45,6 +45,7 @@ void DrawBloomPass::InitializeShaderPrograms() m_GaussianProgram_horiz->AddShader(std::shared_ptr(new VertexShader("Shaders/Gaussian_horiz.vert.glsl"))); m_GaussianProgram_horiz->AddShader(std::shared_ptr(new FragmentShader("Shaders/Gaussian_horiz.frag.glsl"))); m_GaussianProgram_horiz->Compile(); + m_GaussianProgram_horiz->BindFragDataLocation(0, "fragmentColor"); m_GaussianProgram_horiz->Link(); } @@ -53,6 +54,7 @@ void DrawBloomPass::InitializeShaderPrograms() m_GaussianProgram_vert->AddShader(std::shared_ptr(new VertexShader("Shaders/Gaussian_vert.vert.glsl"))); m_GaussianProgram_vert->AddShader(std::shared_ptr(new FragmentShader("Shaders/Gaussian_vert.frag.glsl"))); m_GaussianProgram_vert->Compile(); + m_GaussianProgram_vert->BindFragDataLocation(0, "fragmentColor"); m_GaussianProgram_vert->Link(); } } diff --git a/src/Engine/Rendering/SSAOPass.cpp b/src/Engine/Rendering/SSAOPass.cpp index 9992db70..3b11535f 100644 --- a/src/Engine/Rendering/SSAOPass.cpp +++ b/src/Engine/Rendering/SSAOPass.cpp @@ -56,6 +56,7 @@ void SSAOPass::InitializeShaderProgram() m_SSAOProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/SSAO.vert.glsl"))); m_SSAOProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/SSAO.frag.glsl"))); m_SSAOProgram->Compile(); + m_SSAOProgram->BindFragDataLocation(0, "AO"); m_SSAOProgram->Link(); } @@ -64,6 +65,7 @@ void SSAOPass::InitializeShaderProgram() m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/SSAO.vert.glsl"))); m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/SSAOViewSpaceZ.frag.glsl"))); m_SSAOViewSpaceZProgram->Compile(); + m_SSAOViewSpaceZProgram->BindFragDataLocation(0, "depthLinear"); m_SSAOViewSpaceZProgram->Link(); } @@ -72,6 +74,7 @@ void SSAOPass::InitializeShaderProgram() m_GaussianProgram_horiz->AddShader(std::shared_ptr(new VertexShader("Shaders/Gaussian_horiz.vert.glsl"))); m_GaussianProgram_horiz->AddShader(std::shared_ptr(new FragmentShader("Shaders/Gaussian_horiz.frag.glsl"))); m_GaussianProgram_horiz->Compile(); + m_GaussianProgram_horiz->BindFragDataLocation(0, "fragmentColor"); m_GaussianProgram_horiz->Link(); } @@ -80,6 +83,7 @@ void SSAOPass::InitializeShaderProgram() m_GaussianProgram_vert->AddShader(std::shared_ptr(new VertexShader("Shaders/Gaussian_vert.vert.glsl"))); m_GaussianProgram_vert->AddShader(std::shared_ptr(new FragmentShader("Shaders/Gaussian_vert.frag.glsl"))); m_GaussianProgram_vert->Compile(); + m_GaussianProgram_vert->BindFragDataLocation(0, "fragmentColor"); m_GaussianProgram_vert->Link(); } } diff --git a/src/Engine/Rendering/Skeleton.cpp b/src/Engine/Rendering/Skeleton.cpp index b6fea0bb..c9ae2732 100644 --- a/src/Engine/Rendering/Skeleton.cpp +++ b/src/Engine/Rendering/Skeleton.cpp @@ -1,20 +1,26 @@ #include "Rendering/Skeleton.h" -std::map Skeleton::GetFrameBones(const Animation* animation, double time, bool additive, bool noRootMotion /*= false*/) +std::map Skeleton::GetFrameBones(const Animation* animation, double time, bool additive, bool noRootMotion /*= false*/) { if (animation == nullptr) { - std::map finalMatrices; + std::map finalMatrices; for (auto& b : Bones) { - finalMatrices[b.second->ID] = glm::mat4(1); + PoseData poseData; + poseData.Translation = glm::vec3(0); + poseData.Orientation = glm::quat(); + poseData.Scale = glm::vec3(1); + + + finalMatrices[b.second->ID] = poseData; } return finalMatrices; } - std::map frameBones; + std::map frameBones; if(!additive) { - AccumulateBoneTransforms(true, animation, time, frameBones, RootBone, glm::mat4(1)); + AccumulateBoneTransforms(true, animation, time, frameBones, RootBone); } else { AdditiveBoneTransforms(animation, time, frameBones, RootBone); } @@ -22,11 +28,10 @@ std::map Skeleton::GetFrameBones(const Animation* animation, dou return frameBones; } -void Skeleton::AccumulateBoneTransforms(bool noRootMotion, const Animation* animation, double time, std::map& boneMatrices, const Bone* bone, glm::mat4 parentMatrix) +void Skeleton::AccumulateBoneTransforms(bool noRootMotion, const Animation* animation, double time, std::map& boneMatrices, const Bone* bone) { - glm::mat4 boneMatrix; + PoseData poseData; - if (animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) { std::vector boneKeyFrames = animation->JointAnimations.at(bone->ID); @@ -66,37 +71,38 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, const Animation* anim position.z = 0; } - boneMatrix = (glm::translate(position) * glm::toMat4(rotation) * glm::scale(scale)); - boneMatrices[bone->ID] = boneMatrix;// *bone->OffsetMatrix; + poseData.Translation = position; + poseData.Orientation = rotation; + poseData.Scale = scale; + boneMatrices[bone->ID] = poseData; } else { // 1 keyframes for the current bone currentFrame = boneKeyFrames.at(0); - boneMatrix = (glm::translate(currentFrame.BoneProperties.Position) * glm::toMat4(glm::normalize(currentFrame.BoneProperties.Rotation)) * glm::scale(currentFrame.BoneProperties.Scale)); - boneMatrices[bone->ID] = boneMatrix;// *bone->OffsetMatrix; - } - } else { // 0 keyframes for the current bone - if (bone->Parent) { - //boneMatrix = parentMatrix * (glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix); - //boneMatrices[bone->ID] = boneMatrix *bone->OffsetMatrix; - } else { - //boneMatrix = glm::inverse(bone->OffsetMatrix); - //boneMatrices[bone->ID] = parentMatrix; + poseData.Translation = currentFrame.BoneProperties.Position; + poseData.Orientation = currentFrame.BoneProperties.Rotation; + poseData.Scale = currentFrame.BoneProperties.Scale; + boneMatrices[bone->ID] = poseData; } } for (auto &child : bone->Children) { - AccumulateBoneTransforms(noRootMotion, animation, time, boneMatrices, child, boneMatrix); + AccumulateBoneTransforms(noRootMotion, animation, time, boneMatrices, child); } } -void Skeleton::AdditiveBoneTransforms(const Animation* animation, double time, std::map& boneMatrices, const Bone* bone) +void Skeleton::AdditiveBoneTransforms(const Animation* animation, double time, std::map& boneMatrices, const Bone* bone) { if (animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) { - glm::mat4 refPose = GetAdditiveBonePose(bone, animation, 0.0); - glm::mat4 srcPose = GetAdditiveBonePose(bone, animation, time + 1.0/60.0); - glm::mat4 boneMatrix = srcPose * glm::inverse(refPose); - boneMatrices[bone->ID] = boneMatrix; + PoseData refPose = GetAdditiveBonePose(bone, animation, 0.0); + PoseData srcPose = GetAdditiveBonePose(bone, animation, time + 1.0/60.0); + + PoseData finalPose; + finalPose.Translation = srcPose.Translation - refPose.Translation; + finalPose.Orientation = srcPose.Orientation * glm::inverse(refPose.Orientation); + finalPose.Scale = srcPose.Scale - refPose.Scale; + + boneMatrices[bone->ID] = finalPose; } for (auto &child : bone->Children) { @@ -104,7 +110,7 @@ void Skeleton::AdditiveBoneTransforms(const Animation* animation, double time, s } } -glm::mat4 Skeleton::GetAdditiveBonePose(const Bone* bone, const Animation* animation, double time) +Skeleton::PoseData Skeleton::GetAdditiveBonePose(const Bone* bone, const Animation* animation, double time) { glm::vec3 position = glm::vec3(0); glm::quat rotation = glm::quat(); @@ -152,141 +158,32 @@ glm::mat4 Skeleton::GetAdditiveBonePose(const Bone* bone, const Animation* anima } } - return (glm::translate(position) * glm::toMat4(rotation) * glm::scale(scale));; + PoseData finalPose; + finalPose.Translation = position; + finalPose.Orientation = rotation; + finalPose.Scale = scale; + + return finalPose; } - -glm::mat4 Skeleton::GetBonePose(const Bone* bone, const Animation* animation, double time, bool noRootMotion) +std::map Skeleton::BlendPoses(const std::map& pose1, const std::map& pose2, double weight) { - glm::mat4 boneMatrix; + std::map finalPose; - if (animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) { - std::vector boneKeyFrames = animation->JointAnimations.at(bone->ID); - - Animation::Keyframe currentFrame; - Animation::Keyframe nextFrame; - - if (boneKeyFrames.size() > 1) { // 2+ keyframes for the current bone - for (int index = boneKeyFrames.size()-1; index >= 0; index--) { // find the bone keyframes that surrounds the current frame - if (time >= boneKeyFrames.at(index).Time) { - currentFrame = boneKeyFrames.at(index); - nextFrame = boneKeyFrames.at((index + 1) % boneKeyFrames.size()); - break; - } - } - - float progress; - - if (nextFrame.Index == 0) { - nextFrame = currentFrame; - progress = (time - currentFrame.Time) / (animation->Duration - currentFrame.Time); - } else { - progress = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time); - - } - - - if (progress > 1.0f || progress < 0.0f) { - progress = glm::clamp(progress, 0.0f, 1.0f); - } - Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties; - Animation::Keyframe::BoneProperty nextBoneProperty = nextFrame.BoneProperties; - - glm::vec3 position = currentBoneProperty.Position * (1.f - progress) + nextBoneProperty.Position * progress; - glm::quat rotation = glm::slerp(currentBoneProperty.Rotation, nextBoneProperty.Rotation, progress); - glm::vec3 scale = currentBoneProperty.Scale * (1.f - progress) + nextBoneProperty.Scale * progress; - - // Flag for no root motion - if (bone == RootBone && noRootMotion) { - position.x = 0; - position.z = 0; - } - - boneMatrix = (glm::translate(position) * glm::toMat4(rotation) * glm::scale(scale)); - - } else { // 1 keyframes for the current bone - currentFrame = boneKeyFrames.at(0); - boneMatrix = (glm::translate(currentFrame.BoneProperties.Position) * glm::toMat4(currentFrame.BoneProperties.Rotation) * glm::scale(currentFrame.BoneProperties.Scale)); - } - } //else { // 0 keyframes for the current bone - - // } - - return boneMatrix; -} - -glm::mat4 Skeleton::GetBoneTransform(const Bone* bone, const Animation* animation, float time, glm::mat4 childMatrix) -{ - glm::mat4 boneMatrix; - - Animation::Keyframe currentFrame; - Animation::Keyframe nextFrame; - - if (animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) { - std::vector boneKeyFrames = animation->JointAnimations.at(bone->ID); - - if (boneKeyFrames.size() > 1) { // 2+ keyframes for the current bone - for (int index = boneKeyFrames.size()-1; index >= 0; index--) { // find the bone keyframes that surrounds the current frame - if (time >= boneKeyFrames.at(index).Time) { - currentFrame = boneKeyFrames.at(index); - nextFrame = boneKeyFrames.at((index + 1) % boneKeyFrames.size()); - break; - } - } - - float progress; - - if (nextFrame.Index == 0) { - nextFrame = currentFrame; - progress = (time - currentFrame.Time) / (animation->Duration - currentFrame.Time); - } else { - progress = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time); - } - - if (progress > 1.0f || progress < 0.0f) { - //LOG_INFO("Progress %f", progress); - progress = glm::clamp(progress, 0.0f, 1.0f); - } - Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties; - Animation::Keyframe::BoneProperty nextBoneProperty = nextFrame.BoneProperties; - - glm::vec3 positionInterp = currentBoneProperty.Position * (1.f - progress) + nextBoneProperty.Position * progress; - glm::quat rotationInterp = glm::slerp(currentBoneProperty.Rotation, nextBoneProperty.Rotation, progress); - glm::vec3 scaleInterp = currentBoneProperty.Scale * (1.f - progress) + nextBoneProperty.Scale * progress; - - boneMatrix = (glm::translate(positionInterp) * glm::toMat4(rotationInterp) * glm::scale(scaleInterp)) * childMatrix; - - } else { // 1 keyframes for the current bone - currentFrame = boneKeyFrames.at(0); - boneMatrix = (glm::translate(currentFrame.BoneProperties.Position) * glm::toMat4(currentFrame.BoneProperties.Rotation) * glm::scale(currentFrame.BoneProperties.Scale)) * childMatrix; - - } - } else { // 0 keyframes for the current bone - if (bone->Parent) { - boneMatrix = bone->Parent->OffsetMatrix * glm::inverse(bone->OffsetMatrix) * childMatrix; - } else { - boneMatrix = glm::inverse(bone->OffsetMatrix) * childMatrix; - } - } - - if (bone->Parent) { - return GetBoneTransform(bone->Parent, animation, time, boneMatrix); - } else { - return boneMatrix; - } -} - -std::map Skeleton::BlendPoses(const std::map& pose1, const std::map& pose2, double weight) -{ - std::map finalPose; + float weight1 = (float)(1.0 - weight); + float weight2 = (float)(weight); for (auto& b : Bones) { int boneID = b.second->ID; - glm::mat4 blendedPose = glm::mat4(0); + PoseData blendedPose; + blendedPose.Translation = glm::vec3(0); + blendedPose.Orientation = glm::quat(); + blendedPose.Scale = glm::vec3(1); if(pose1.find(boneID) != pose1.end() && pose2.find(boneID) != pose2.end()) { - blendedPose += pose1.at(boneID) * (float)(1.0 - weight); - blendedPose += pose2.at(boneID) * (float)weight; + blendedPose.Translation = pose1.at(boneID).Translation * weight1 + pose2.at(boneID).Translation * weight2; + blendedPose.Orientation = glm::slerp(pose1.at(boneID).Orientation, pose2.at(boneID).Orientation, weight2); + blendedPose.Scale = pose1.at(boneID).Scale * weight1 + pose2.at(boneID).Scale * weight2; finalPose[boneID] = blendedPose; } else if(pose1.find(boneID) != pose1.end()) { finalPose[boneID] = pose1.at(boneID); @@ -298,9 +195,9 @@ std::map Skeleton::BlendPoses(const std::map& po return finalPose; } -std::map Skeleton::OverridePose(const std::map& overridePose, const std::map& targetPose) +std::map Skeleton::OverridePose(const std::map& overridePose, const std::map& targetPose) { - std::map finalPose; + std::map finalPose; for (auto& b : Bones) { int boneID = b.second->ID; @@ -313,18 +210,22 @@ std::map Skeleton::OverridePose(const std::map& return finalPose; } -std::map Skeleton::BlendPoseAdditive(const std::map& additivePose, const std::map& targetPose) +std::map Skeleton::BlendPoseAdditive(const std::map& additivePose, const std::map& targetPose) { - std::map finalPose; + std::map finalPose; for (auto& b : Bones) { int boneID = b.second->ID; - glm::mat4 blendedPose = glm::mat4(1); + PoseData blendedPose; + blendedPose.Translation = glm::vec3(0); + blendedPose.Orientation = glm::quat(); + blendedPose.Scale = glm::vec3(1); if (additivePose.find(boneID) != additivePose.end() && targetPose.find(boneID) != targetPose.end()) { - blendedPose = additivePose.at(boneID) * targetPose.at(boneID); + blendedPose.Translation = additivePose.at(boneID).Translation + targetPose.at(boneID).Translation; + blendedPose.Orientation = additivePose.at(boneID).Orientation * targetPose.at(boneID).Orientation; + blendedPose.Scale = additivePose.at(boneID).Scale + targetPose.at(boneID).Scale; finalPose[boneID] = blendedPose; - } else if (additivePose.find(boneID) != additivePose.end()) { finalPose[boneID] = additivePose.at(boneID); } else if (targetPose.find(boneID) != targetPose.end()) { @@ -335,9 +236,12 @@ std::map Skeleton::BlendPoseAdditive(const std::map& boneMatrices, std::vector& finalPose, std::map& boneTransforms) +void Skeleton::GetFinalPose(std::map& poseDatas, std::vector& finalPose, std::map& boneTransforms) { - AccumulateFinalPose(boneMatrices, boneTransforms, RootBone, glm::mat4(1)); + + std::map boneMatrices; + + AccumulateFinalPose(boneMatrices, poseDatas, boneTransforms, RootBone, glm::mat4(1)); for(auto& b : boneMatrices) { finalPose.push_back(b.second); @@ -345,12 +249,12 @@ void Skeleton::GetFinalPose(std::map& boneMatrices, std::vector< } -void Skeleton::AccumulateFinalPose(std::map& boneMatrices, std::map& boneTransforms, const Bone* bone, glm::mat4 parentMatrix) +void Skeleton::AccumulateFinalPose(std::map& boneMatrices, std::map& poseDatas, std::map& boneTransforms, const Bone* bone, glm::mat4 parentMatrix) { glm::mat4 boneMatrix; - if (boneMatrices.find(bone->ID) != boneMatrices.end()) { - boneMatrix = parentMatrix * boneMatrices.at(bone->ID); + if (poseDatas.find(bone->ID) != poseDatas.end()) { + boneMatrix = parentMatrix * (glm::translate(poseDatas.at(bone->ID).Translation) * glm::mat4(poseDatas.at(bone->ID).Orientation) * glm::scale(poseDatas.at(bone->ID).Scale)); boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix; } else { if (bone->Parent) { @@ -365,7 +269,7 @@ void Skeleton::AccumulateFinalPose(std::map& boneMatrices, std:: boneTransforms[bone->ID] = boneMatrix; for (auto &child : bone->Children) { - AccumulateFinalPose(boneMatrices, boneTransforms, child, boneMatrix); + AccumulateFinalPose(boneMatrices, poseDatas, boneTransforms, child, boneMatrix); } } From 53c520123a7700d7284e5fe13d0bafd50c71102a Mon Sep 17 00:00:00 2001 From: William Moberg Date: Wed, 2 Mar 2016 17:06:53 +0100 Subject: [PATCH 140/252] Uncommented code. --- src/Engine/Editor/EditorSystem.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Engine/Editor/EditorSystem.cpp b/src/Engine/Editor/EditorSystem.cpp index 47547b8f..b0929df9 100644 --- a/src/Engine/Editor/EditorSystem.cpp +++ b/src/Engine/Editor/EditorSystem.cpp @@ -258,17 +258,17 @@ EntityWrapper EditorSystem::importEntity(EntityWrapper parent, boost::filesystem return EntityWrapper::Invalid; } - //try { + try { auto entityFile = ResourceManager::Load(filePath.string()); EntityFilePreprocessor fpp(entityFile); fpp.RegisterComponents(parent.World); EntityFileParser fp(entityFile); EntityID newEntity = fp.MergeEntities(parent.World, parent.ID); return EntityWrapper(parent.World, newEntity); - /*} catch (const std::exception& e) { + } catch (const std::exception& e) { LOG_ERROR("Failed to import entity \"%s\": \"%s\"", filePath.string().c_str(), e.what()); return EntityWrapper::Invalid; - }*/ + } } void EditorSystem::setWidgetMode(EditorGUI::WidgetMode mode) From d8a0e69ff05b361974ba6db4ecc7e9ac4f0cecd5 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Wed, 2 Mar 2016 17:11:18 +0100 Subject: [PATCH 141/252] fixup! AutoAnimationBlend now working correctly for unique nodes, Commited debug code --- src/Engine/Rendering/BoneAttachmentSystem.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/Engine/Rendering/BoneAttachmentSystem.cpp b/src/Engine/Rendering/BoneAttachmentSystem.cpp index 191fb3bd..43dc8634 100644 --- a/src/Engine/Rendering/BoneAttachmentSystem.cpp +++ b/src/Engine/Rendering/BoneAttachmentSystem.cpp @@ -50,19 +50,6 @@ void BoneAttachmentSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapp glm::vec4 perspective; glm::decompose(boneTransform, scale, rotation, translation, skew, perspective); - float lowRange = 0.98f; - float highRange = 1.02f; - if(scale.x < lowRange || scale.y < lowRange || scale.z < lowRange || - scale.x > highRange || scale.y > highRange || scale.z > highRange) { - if (entity.HasComponent("Model")) { - (glm::vec4&)entity["Model"]["Color"] = glm::vec4(1, 0, 0, 1); - } - } else { - if (entity.HasComponent("Model")) { - (glm::vec4&)entity["Model"]["Color"] = glm::vec4(0, 1, 0, 1); - } - } - glm::vec3 angles = glm::vec3(-glm::pitch(rotation), -glm::yaw(rotation), -glm::roll(rotation)); if ((bool)entity["BoneAttachment"]["InheritPosition"]) { From a9a19193ad18c4be8149c08651988d0bd2ea2dcc Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 2 Mar 2016 17:21:15 +0100 Subject: [PATCH 142/252] Component for Boost icons --- resources/Schema/Components.xsd | 1 + resources/Schema/Components/BoostIconsHUD.xml | 2 ++ resources/Schema/Components/BoostIconsHUD.xsd | 10 ++++++++++ resources/Schema/Types/Entity.xsd | 1 + 4 files changed, 14 insertions(+) create mode 100644 resources/Schema/Components/BoostIconsHUD.xml create mode 100644 resources/Schema/Components/BoostIconsHUD.xsd diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index a75de84e..f0fb52d3 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -56,4 +56,5 @@ + \ No newline at end of file diff --git a/resources/Schema/Components/BoostIconsHUD.xml b/resources/Schema/Components/BoostIconsHUD.xml new file mode 100644 index 00000000..e25d9611 --- /dev/null +++ b/resources/Schema/Components/BoostIconsHUD.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/resources/Schema/Components/BoostIconsHUD.xsd b/resources/Schema/Components/BoostIconsHUD.xsd new file mode 100644 index 00000000..c5fe2e5d --- /dev/null +++ b/resources/Schema/Components/BoostIconsHUD.xsd @@ -0,0 +1,10 @@ + + + + + + + Origin for the 3 boost states. Create 3 children with Sprite and Fill components, name them "Sprint", "Defender", "Assault" + + + \ No newline at end of file diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index 61d8e520..94183c75 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -53,6 +53,7 @@ + From 7d15313209e7ef79893828f22616a8c146fb4a09 Mon Sep 17 00:00:00 2001 From: antc13 Date: Wed, 2 Mar 2016 17:22:44 +0100 Subject: [PATCH 143/252] Added a FloatingEffectSystem to the game. Pickups now move up and down, if so desired. --- include/Game/Systems/FloatingEffectSystem.h | 20 +++ resources/Schema/Components.xsd | 1 + .../Schema/Components/FloatingEffect.xml | 7 + .../Schema/Components/FloatingEffect.xsd | 17 ++ resources/Schema/Entities/NewMap2version2.xml | 98 ++++++------ .../Schema/Entities/NewMap2version3NEW.xml | 148 ++++++++++++++---- src/Game/Game.cpp | 2 + 7 files changed, 210 insertions(+), 83 deletions(-) create mode 100644 include/Game/Systems/FloatingEffectSystem.h create mode 100644 resources/Schema/Components/FloatingEffect.xml create mode 100644 resources/Schema/Components/FloatingEffect.xsd diff --git a/include/Game/Systems/FloatingEffectSystem.h b/include/Game/Systems/FloatingEffectSystem.h new file mode 100644 index 00000000..2462e029 --- /dev/null +++ b/include/Game/Systems/FloatingEffectSystem.h @@ -0,0 +1,20 @@ +#include "Common.h" +#include "Core/System.h" + +class FloatingEffectSystem : public PureSystem +{ +public: + FloatingEffectSystem(SystemParams params) + : System(params) + , PureSystem("FloatingEffect") + { } + + virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt) override + { + ComponentWrapper& transform = m_World->GetComponent(component.EntityID, "Transform"); + (double&)component["Time"] += dt; + //(double)component["Amplitude"] * glm::sin((glm::two_pi() / (double)component["Period"]) * (double)component["Time"]); + (glm::vec3&)transform["Position"] = (float)(double)component["Amplitude"] * glm::sin((glm::two_pi() / (float)(double)component["Period"]) * (float)(double)component["Time"]) * (glm::vec3)component["Axis"]; + + } +}; \ No newline at end of file diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index a75de84e..fccfd3d0 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -56,4 +56,5 @@ + \ No newline at end of file diff --git a/resources/Schema/Components/FloatingEffect.xml b/resources/Schema/Components/FloatingEffect.xml new file mode 100644 index 00000000..661e4ae4 --- /dev/null +++ b/resources/Schema/Components/FloatingEffect.xml @@ -0,0 +1,7 @@ + + + 1 + 1 + + + \ No newline at end of file diff --git a/resources/Schema/Components/FloatingEffect.xsd b/resources/Schema/Components/FloatingEffect.xsd new file mode 100644 index 00000000..a71006f5 --- /dev/null +++ b/resources/Schema/Components/FloatingEffect.xsd @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/Schema/Entities/NewMap2version2.xml b/resources/Schema/Entities/NewMap2version2.xml index fcb81666..8089073f 100644 --- a/resources/Schema/Entities/NewMap2version2.xml +++ b/resources/Schema/Entities/NewMap2version2.xml @@ -804,11 +804,11 @@ - + 2 - + @@ -825,7 +825,7 @@ - + @@ -851,11 +851,11 @@ - + 2 - + @@ -872,7 +872,7 @@ - + @@ -898,11 +898,11 @@ - + 2 - + @@ -919,7 +919,7 @@ - + @@ -945,11 +945,11 @@ - + 2 - + @@ -966,7 +966,7 @@ - + @@ -992,11 +992,11 @@ - + 2 - + @@ -1013,7 +1013,7 @@ - + @@ -1039,11 +1039,11 @@ - + 2 - + @@ -1060,7 +1060,7 @@ - + @@ -1086,11 +1086,11 @@ - + 2 - + @@ -1107,7 +1107,7 @@ - + @@ -2242,7 +2242,7 @@ Models/Props/Stones/AssaultHolder.mesh - + @@ -2355,11 +2355,11 @@ - + 2 - + @@ -2376,7 +2376,7 @@ - + @@ -2402,11 +2402,11 @@ - + 2 - + @@ -2423,7 +2423,7 @@ - + @@ -2904,11 +2904,11 @@ - + 2 - + @@ -2925,7 +2925,7 @@ - + @@ -2951,11 +2951,11 @@ - + 2 - + @@ -2972,7 +2972,7 @@ - + @@ -2998,11 +2998,11 @@ - + 2 - + @@ -3019,7 +3019,7 @@ - + @@ -3045,11 +3045,11 @@ - + 2 - + @@ -3066,7 +3066,7 @@ - + @@ -3092,11 +3092,11 @@ - + 2 - + @@ -3113,7 +3113,7 @@ - + @@ -3139,11 +3139,11 @@ - + 2 - + @@ -3160,7 +3160,7 @@ - + @@ -3186,11 +3186,11 @@ - + 2 - + @@ -3207,7 +3207,7 @@ - + diff --git a/resources/Schema/Entities/NewMap2version3NEW.xml b/resources/Schema/Entities/NewMap2version3NEW.xml index 5b224de3..61e7b740 100644 --- a/resources/Schema/Entities/NewMap2version3NEW.xml +++ b/resources/Schema/Entities/NewMap2version3NEW.xml @@ -802,8 +802,13 @@ + + + + 2 + - + @@ -821,7 +826,7 @@ - + @@ -844,8 +849,13 @@ + + + + 2 + - + @@ -863,7 +873,7 @@ - + @@ -886,8 +896,13 @@ + + + + 2 + - + @@ -905,7 +920,7 @@ - + @@ -928,8 +943,13 @@ + + + + 2 + - + @@ -947,7 +967,7 @@ - + @@ -970,8 +990,13 @@ + + + + 2 + - + @@ -989,7 +1014,7 @@ - + @@ -1012,8 +1037,13 @@ + + + + 2 + - + @@ -1031,7 +1061,7 @@ - + @@ -1054,8 +1084,13 @@ + + + + 2 + - + @@ -1073,7 +1108,7 @@ - + @@ -2318,8 +2353,13 @@ + + + + 2 + - + @@ -2337,7 +2377,7 @@ - + @@ -2360,8 +2400,13 @@ + + + + 2 + - + @@ -2379,7 +2424,7 @@ - + @@ -2857,8 +2902,13 @@ + + + + 2 + - + @@ -2876,7 +2926,7 @@ - + @@ -2899,8 +2949,13 @@ + + + + 2 + - + @@ -2918,7 +2973,7 @@ - + @@ -2941,8 +2996,13 @@ + + + + 2 + - + @@ -2960,7 +3020,7 @@ - + @@ -2983,8 +3043,13 @@ + + + + 2 + - + @@ -3002,7 +3067,7 @@ - + @@ -3025,8 +3090,13 @@ + + + + 2 + - + @@ -3044,7 +3114,7 @@ - + @@ -3067,8 +3137,13 @@ + + + + 2 + - + @@ -3086,7 +3161,7 @@ - + @@ -3109,8 +3184,13 @@ + + + + 2 + - + @@ -3128,7 +3208,7 @@ - + @@ -4222,7 +4302,7 @@ - -15 + -15 4 @@ -4444,7 +4524,7 @@ - 1 + 0.40000000596046448 diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 8c6e653e..b4c1a71d 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -10,6 +10,7 @@ #include "Systems/SpawnerSystem.h" #include "Systems/PlayerSpawnSystem.h" #include "Systems/PlayerDeathSystem.h" +#include "Systems/FloatingEffectSystem.h" #include "Core/EntityFileWriter.h" #include "Game/Systems/CapturePointSystem.h" #include "Game/Systems/CapturePointHUDSystem.h" @@ -120,6 +121,7 @@ Game::Game(int argc, char* argv[]) ++updateOrderLevel; m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); + m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); From 8b66d29adcb75311b27c4c98480f4dcf3145a406 Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 2 Mar 2016 17:32:45 +0100 Subject: [PATCH 144/252] Skeleton system for Boost icons --- include/Game/Systems/BoostIconsHUDSystem.h | 17 +++++++++++++++++ src/Game/Game.cpp | 2 ++ src/Game/Systems/BoostIconsHUDSystem.cpp | 6 ++++++ 3 files changed, 25 insertions(+) create mode 100644 include/Game/Systems/BoostIconsHUDSystem.h create mode 100644 src/Game/Systems/BoostIconsHUDSystem.cpp diff --git a/include/Game/Systems/BoostIconsHUDSystem.h b/include/Game/Systems/BoostIconsHUDSystem.h new file mode 100644 index 00000000..fbcdfc16 --- /dev/null +++ b/include/Game/Systems/BoostIconsHUDSystem.h @@ -0,0 +1,17 @@ +#ifndef BoostIconsHUDSystem_h__ +#define BoostIconsHUDSystem_h__ + +#include "../../Engine/Core/System.h" +#include "../../Engine/GLM.h" + +class BoostIconsHUDSystem : public ImpureSystem +{ +public: + BoostIconsHUDSystem(SystemParams params) + : System(params) + { } + + virtual void Update(double dt) override; +}; + +#endif \ No newline at end of file diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 8c6e653e..c3f1e439 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -28,6 +28,7 @@ #include "Game/Systems/CapturePointArrowHUDSystem.h" #include "Game/Systems/KillFeedSystem.h" #include "Game/Systems/BoostSystem.h" +#include "Game/Systems/BoostIconsHUDSystem.h" #include "GUI/ButtonSystem.h" #include "GUI/MainMenuSystem.h" @@ -146,6 +147,7 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer); m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer); + m_SystemPipeline->AddSystem(updateOrderLevel); // Populate Octree with collidables ++updateOrderLevel; m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeCollision, "Collidable"); diff --git a/src/Game/Systems/BoostIconsHUDSystem.cpp b/src/Game/Systems/BoostIconsHUDSystem.cpp new file mode 100644 index 00000000..6d181233 --- /dev/null +++ b/src/Game/Systems/BoostIconsHUDSystem.cpp @@ -0,0 +1,6 @@ +#include "Game/Systems/BoostIconsHUDSystem.h" + +void BoostIconsHUDSystem::Update(double dt) +{ + //Logic here +} From 267c007291997ff11271364d707e5937f4d0945d Mon Sep 17 00:00:00 2001 From: stiffly Date: Wed, 2 Mar 2016 17:39:27 +0100 Subject: [PATCH 145/252] Removed unnecessary comments, variables and functions. --- include/Engine/Input/FirstPersonInputController.h | 11 +++++------ src/Engine/Network/Server.cpp | 2 +- src/Game/Systems/PlayerMovementSystem.cpp | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index efa3c38e..7ed85c84 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -27,7 +27,7 @@ public: virtual bool OnCommand(const Events::InputCommand& e) override; virtual void Reset(); - void AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer, double& assaultDashCoolDownTimer, EntityWrapper player); + void AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer, double& assaultDashCoolDownTimer, EntityID playerID); virtual bool AssaultDashDoubleTapped() const { return m_AssaultDashDoubleTapped; } virtual bool PlayerIsDashing() const { return m_PlayerIsDashing; } @@ -56,7 +56,6 @@ protected: bool m_MovementKeyDown = false; bool m_SpecialAbilityKeyDown = false; int m_NumberOfMovementKeysDown = 0; - void spawnDashEffect(); EventRelay m_ELockMouse; bool OnLockMouse(const Events::LockMouse& e); @@ -192,7 +191,7 @@ bool FirstPersonInputController::OnLockMouse(const Events::LockMou } template -void FirstPersonInputController::AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer, double& assaultDashCoolDownTimer, EntityWrapper player) { +void FirstPersonInputController::AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer, double& assaultDashCoolDownTimer, EntityID playerID) { m_AssaultDashDoubleTapDeltaTime += dt; m_DashEffectResetTimer += dt; assaultDashCoolDownTimer -= dt; @@ -201,7 +200,7 @@ void FirstPersonInputController::AssaultDashCheck(double dt, bool m_PlayerIsDashing = true; if (m_DashEffectResetTimer > 0.05) { Events::DashAbility e; - e.Player = player.ID; + e.Player = playerID; m_EventBroker->Publish(e); m_DashEffectResetTimer = 0.0; } @@ -217,7 +216,7 @@ void FirstPersonInputController::AssaultDashCheck(double dt, bool m_AssaultDashDoubleTapped = true; m_AssaultDashDoubleTapDeltaTime = 0.f; Events::DashAbility e; - e.Player = player.ID; + e.Player = playerID; m_EventBroker->Publish(e); return; } @@ -249,7 +248,7 @@ void FirstPersonInputController::AssaultDashCheck(double dt, bool assaultDashCoolDownTimer = assaultDashCoolDownMaxTimer; Events::DashAbility e; - e.Player = player.ID; + e.Player = playerID; m_EventBroker->Publish(e); } diff --git a/src/Engine/Network/Server.cpp b/src/Engine/Network/Server.cpp index 7ba54ec4..68c00fbe 100644 --- a/src/Engine/Network/Server.cpp +++ b/src/Engine/Network/Server.cpp @@ -632,7 +632,7 @@ bool Server::shouldSendToClient(EntityWrapper childEntity) } return childEntity.HasComponent("Player") || childEntity.FirstParentWithComponent("Player").Valid() || childEntity.HasComponent("CapturePoint") || childEntity.HasComponent("HealthPickup") - || childEntity.HasComponent("AmmoPickup")/* || childEntity.Name() == "DashEffect"*/; + || childEntity.HasComponent("AmmoPickup"); } PlayerID Server::GetPlayerIDFromEndpoint() diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 1332ca82..9afc9c8c 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -73,7 +73,7 @@ void PlayerMovementSystem::updateMovementControllers(double dt) ComponentWrapper cPhysics = player["Physics"]; //Assault Dash Check if (player.HasComponent("DashAbility")) { - controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f, player["DashAbility"]["CoolDownMaxTimer"], player["DashAbility"]["CoolDownTimer"], player); + controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f, player["DashAbility"]["CoolDownMaxTimer"], player["DashAbility"]["CoolDownTimer"], player.ID); } wishDirection = controller->Movement() * glm::inverse(glm::quat(ori)); //this makes sure you can only dash in the 4 directions: forw,backw,left,right From e56f203f7cfb8bcfa4018e2696dbcc1e1c0a98e0 Mon Sep 17 00:00:00 2001 From: antc13 Date: Wed, 2 Mar 2016 17:42:11 +0100 Subject: [PATCH 146/252] Removed unnecessary comment & added FloatingEffect to Schema/Types/Entity.xsd --- include/Game/Systems/FloatingEffectSystem.h | 1 - resources/Schema/Types/Entity.xsd | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/include/Game/Systems/FloatingEffectSystem.h b/include/Game/Systems/FloatingEffectSystem.h index 2462e029..56931001 100644 --- a/include/Game/Systems/FloatingEffectSystem.h +++ b/include/Game/Systems/FloatingEffectSystem.h @@ -13,7 +13,6 @@ public: { ComponentWrapper& transform = m_World->GetComponent(component.EntityID, "Transform"); (double&)component["Time"] += dt; - //(double)component["Amplitude"] * glm::sin((glm::two_pi() / (double)component["Period"]) * (double)component["Time"]); (glm::vec3&)transform["Position"] = (float)(double)component["Amplitude"] * glm::sin((glm::two_pi() / (float)(double)component["Period"]) * (float)(double)component["Time"]) * (glm::vec3)component["Axis"]; } diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index 61d8e520..e2ab39e5 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -53,6 +53,7 @@ + From e9bbb5ed2a4adc2116764eaac835e98bee58803d Mon Sep 17 00:00:00 2001 From: viktorljung Date: Wed, 2 Mar 2016 17:42:55 +0100 Subject: [PATCH 147/252] Fixed BlendTree crash when animation nodes are null --- src/Engine/Rendering/BlendTree.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/Engine/Rendering/BlendTree.cpp b/src/Engine/Rendering/BlendTree.cpp index cb7ffa69..8b044134 100644 --- a/src/Engine/Rendering/BlendTree.cpp +++ b/src/Engine/Rendering/BlendTree.cpp @@ -142,9 +142,13 @@ BlendTree::Node* BlendTree::FillTreeByName(Node* parentNode, std::string name, E } else if (node->Weight == 0.f) { node->Child[1] = FillTreeByName(node, (std::string)childEntity["Blend"]["Pose2"], childEntity); }*/ + + if(node->Child[0] == nullptr && node->Child[1] == nullptr) { + return nullptr; + } else { + return node; + } - - return node; } else if (childEntity.HasComponent("BlendOverride")) { Node* node = new Node(); node->Entity = childEntity; @@ -153,7 +157,12 @@ BlendTree::Node* BlendTree::FillTreeByName(Node* parentNode, std::string name, E node->Type = NodeType::Override; node->Child[0] = FillTreeByName(node, (std::string)childEntity["BlendOverride"]["Master"], childEntity); node->Child[1] = FillTreeByName(node, (std::string)childEntity["BlendOverride"]["Slave"], childEntity); - return node; + + if (node->Child[0] == nullptr && node->Child[1] == nullptr) { + return nullptr; + } else { + return node; + } } else if (childEntity.HasComponent("BlendAdditive")) { Node* node = new Node(); node->Entity = childEntity; @@ -162,7 +171,12 @@ BlendTree::Node* BlendTree::FillTreeByName(Node* parentNode, std::string name, E node->Type = NodeType::Additive; node->Child[0] = FillTreeByName(node, (std::string)childEntity["BlendAdditive"]["Adder"], childEntity); node->Child[1] = FillTreeByName(node, (std::string)childEntity["BlendAdditive"]["Receiver"], childEntity); - return node; + + if(node->Child[0] == nullptr && node->Child[1] == nullptr) { + return nullptr; + } else { + return node; + } } @@ -252,7 +266,6 @@ void BlendTree::Blend(std::map& pose) if(currentNode->Pose.size() == 0) { if (currentNode->Child[0] != nullptr && currentNode->Child[1] != nullptr) { if (currentNode->Child[0]->Pose.size() != 0 && currentNode->Child[1]->Pose.size() != 0) { - switch (currentNode->Type) { case BlendTree::NodeType::Additive: currentNode->Pose = m_Skeleton->BlendPoseAdditive(currentNode->Child[0]->Pose, currentNode->Child[1]->Pose); From 3094dd301bd4415b97892574ef3e4da1fd70f124 Mon Sep 17 00:00:00 2001 From: antc13 Date: Wed, 2 Mar 2016 17:47:22 +0100 Subject: [PATCH 148/252] Added a default value to Position in FloatingEffect.xml --- resources/Schema/Components/FloatingEffect.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/Schema/Components/FloatingEffect.xml b/resources/Schema/Components/FloatingEffect.xml index 661e4ae4..f1fd237a 100644 --- a/resources/Schema/Components/FloatingEffect.xml +++ b/resources/Schema/Components/FloatingEffect.xml @@ -4,4 +4,5 @@ 1 + \ No newline at end of file From 7af17049e9489a0df32418da8dfe994c75c862dc Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 2 Mar 2016 18:13:09 +0100 Subject: [PATCH 149/252] BoostIcons should now track correctly --- include/Game/Systems/BoostIconsHUDSystem.h | 6 ++-- src/Game/Systems/BoostIconsHUDSystem.cpp | 40 ++++++++++++++++++++-- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/include/Game/Systems/BoostIconsHUDSystem.h b/include/Game/Systems/BoostIconsHUDSystem.h index fbcdfc16..d8de777d 100644 --- a/include/Game/Systems/BoostIconsHUDSystem.h +++ b/include/Game/Systems/BoostIconsHUDSystem.h @@ -4,14 +4,16 @@ #include "../../Engine/Core/System.h" #include "../../Engine/GLM.h" -class BoostIconsHUDSystem : public ImpureSystem +class BoostIconsHUDSystem : public PureSystem { public: BoostIconsHUDSystem(SystemParams params) : System(params) + , PureSystem("BoostIconsHUD") { } - virtual void Update(double dt) override; + virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) override; + }; #endif \ No newline at end of file diff --git a/src/Game/Systems/BoostIconsHUDSystem.cpp b/src/Game/Systems/BoostIconsHUDSystem.cpp index 6d181233..f83278ff 100644 --- a/src/Game/Systems/BoostIconsHUDSystem.cpp +++ b/src/Game/Systems/BoostIconsHUDSystem.cpp @@ -1,6 +1,42 @@ #include "Game/Systems/BoostIconsHUDSystem.h" -void BoostIconsHUDSystem::Update(double dt) +void BoostIconsHUDSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) { - //Logic here + EntityWrapper assaultEntity = entity.FirstChildByName("Assault"); + EntityWrapper defenderEntity = entity.FirstChildByName("Defender"); + EntityWrapper sniperEntity = entity.FirstChildByName("Sniper"); + + if(assaultEntity.Valid()) { + if (assaultEntity.HasComponent("Fill")) { + EntityWrapper parentWithAssaultBoost = assaultEntity.FirstParentWithComponent("BoostAssault"); + if (parentWithAssaultBoost.Valid()) { + (double&)assaultEntity["Fill"]["Percentage"] = 1.0; + } else { + (double&)assaultEntity["Fill"]["Percentage"] = 0.0; + } + } + } + + if (defenderEntity.Valid()) { + if (defenderEntity.HasComponent("Fill")) { + EntityWrapper parentWithAssaultBoost = defenderEntity.FirstParentWithComponent("BoostDefender"); + if (parentWithAssaultBoost.Valid()) { + (double&)defenderEntity["Fill"]["Percentage"] = 1.0; + } else { + (double&)defenderEntity["Fill"]["Percentage"] = 0.0; + } + } + } + + if (sniperEntity.Valid()) { + if (sniperEntity.HasComponent("Fill")) { + EntityWrapper parentWithAssaultBoost = sniperEntity.FirstParentWithComponent("BoostSniper"); + if (parentWithAssaultBoost.Valid()) { + (double&)sniperEntity["Fill"]["Percentage"] = 1.0; + } else { + (double&)sniperEntity["Fill"]["Percentage"] = 0.0; + } + } + } } + From 62c8196ad4395bce57e7071e22230552359882d6 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 2 Mar 2016 18:38:49 +0100 Subject: [PATCH 150/252] Created World::Merge which will merge a world into another one --- include/Engine/Core/World.h | 8 ++++++-- src/Engine/Core/World.cpp | 39 ++++++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/include/Engine/Core/World.h b/include/Engine/Core/World.h index d8e2c7ba..28c96303 100644 --- a/include/Engine/Core/World.h +++ b/include/Engine/Core/World.h @@ -19,13 +19,13 @@ public: World(const World& other); // Create empty entity - EntityID CreateEntity(EntityID parent = 0); + EntityID CreateEntity(EntityID parent = EntityID_Invalid); // Delete entity and all components within void DeleteEntity(EntityID entity); // Check if an entity exists bool ValidEntity(EntityID entity) const; // Register a component type and allocate space for it - void RegisterComponent(ComponentInfo& ci); + void RegisterComponent(const ComponentInfo& ci); // Attach a component to an entity and fill it with default values ComponentWrapper AttachComponent(EntityID entity, const std::string& componentType); // Check if an entity has a component @@ -53,6 +53,10 @@ public: // Get the first entity in the world with the name. EntityWrapper GetFirstEntityByName(const std::string& name); + // Merge another world into this one + // Returns a map that maps entities from the other world to their copies in this one + std::unordered_map Merge(World& other); + private: EventBroker* m_EventBroker = nullptr; EntityID m_CurrentEntityID = 0; diff --git a/src/Engine/Core/World.cpp b/src/Engine/Core/World.cpp index 65bc60d2..96c4660d 100644 --- a/src/Engine/Core/World.cpp +++ b/src/Engine/Core/World.cpp @@ -45,7 +45,7 @@ bool World::ValidEntity(EntityID entity) const return m_EntityParents.find(entity) != m_EntityParents.end(); } -void World::RegisterComponent(ComponentInfo& ci) +void World::RegisterComponent(const ComponentInfo& ci) { if (m_ComponentPools.find(ci.Name) == m_ComponentPools.end()) { m_ComponentPools[ci.Name] = new ComponentPool(ci); @@ -169,6 +169,43 @@ EntityWrapper World::GetFirstEntityByName(const std::string& name) return EntityWrapper::Invalid; } +std::unordered_map World::Merge(World& other) +{ + std::unordered_map oldToNew; + + // Create new entities + for (auto& kv : other.m_EntityParents) { + EntityID entity = kv.first; + + EntityID newEntity = CreateEntity(); + SetName(newEntity, other.GetName(entity)); + oldToNew[entity] = newEntity; + } + // Fix relationships + for (auto& kv : other.m_EntityParents) { + EntityID entity = kv.first; + EntityID parent = kv.second; + SetParent(oldToNew.at(entity), oldToNew.at(parent)); + } + + // Transfer components + for (auto& kv : other.m_ComponentPools) { + auto& componentType = kv.first; + ComponentPool* pool = kv.second; + // Register pool if it's not present in world + if (m_ComponentPools.count(componentType) == 0) { + RegisterComponent(pool->ComponentInfo()); + } + // Copy components + for (auto component : *pool) { + ComponentWrapper newComponent = AttachComponent(oldToNew.at(component.EntityID), componentType); + component.Copy(newComponent); + } + } + + return oldToNew; +} + EntityID World::generateEntityID() { // TODO: Make EntityID generation smarter From 26d6546d795b0a840b06e1c423180205a4e942e0 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 2 Mar 2016 18:42:11 +0100 Subject: [PATCH 151/252] Renamed EntityFile to EntityXMLFile to be able to separate file parsing from entity creation --- .../Core/{EntityFile.h => EntityXMLFile.h} | 6 ++--- ...tityFileParser.h => EntityXMLFileParser.h} | 8 +++--- ...rocessor.h => EntityXMLFilePreprocessor.h} | 8 +++--- ...tityFileWriter.h => EntityXMLFileWriter.h} | 6 ++--- include/Engine/Editor/EditorSystem.h | 6 ++--- include/Game/Game.h | 6 ++--- include/Game/Systems/AmmoPickupSystem.h | 2 +- include/Game/Systems/BoostSystem.h | 2 +- include/Game/Systems/DamageIndicatorSystem.h | 2 +- include/Game/Systems/PickupSpawnSystem.h | 2 +- include/Game/Systems/PlayerDeathSystem.h | 4 +-- include/Game/Systems/PlayerMovementSystem.h | 4 +-- include/Game/Systems/SpawnerSystem.h | 2 +- include/Game/Systems/Weapon/WeaponSystem.h | 4 +-- .../{EntityFile.cpp => EntityXMLFile.cpp} | 18 ++++++------- ...FileParser.cpp => EntityXMLFileParser.cpp} | 26 +++++++++---------- ...ssor.cpp => EntityXMLFilePreprocessor.cpp} | 24 ++++++++--------- ...FileWriter.cpp => EntityXMLFileWriter.cpp} | 10 +++---- src/Engine/Editor/EditorSystem.cpp | 8 +++--- src/Game/Game.cpp | 10 +++---- src/Game/Systems/AmmoPickupSystem.cpp | 4 +-- src/Game/Systems/BoostSystem.cpp | 4 +-- src/Game/Systems/DamageIndicatorSystem.cpp | 10 +++---- src/Game/Systems/PickupSpawnSystem.cpp | 4 +-- src/Game/Systems/PlayerDeathSystem.cpp | 4 +-- src/Game/Systems/PlayerMovementSystem.cpp | 8 +++--- src/Game/Systems/SpawnerSystem.cpp | 4 +-- src/Tests/CapturePointTest.cpp | 10 +++---- src/Tests/CapturePointTest.h | 8 +++--- src/Tests/HealthSystemTest.cpp | 8 +++--- src/Tests/HealthSystemTest.h | 2 +- src/Tests/PickupSpawnTest.cpp | 8 +++--- src/Tests/PickupSpawnTest.h | 10 +++---- 33 files changed, 121 insertions(+), 121 deletions(-) rename include/Engine/Core/{EntityFile.h => EntityXMLFile.h} (98%) rename include/Engine/Core/{EntityFileParser.h => EntityXMLFileParser.h} (86%) rename include/Engine/Core/{EntityFilePreprocessor.h => EntityXMLFilePreprocessor.h} (87%) rename include/Engine/Core/{EntityFileWriter.h => EntityXMLFileWriter.h} (92%) rename src/Engine/Core/{EntityFile.cpp => EntityXMLFile.cpp} (94%) rename src/Engine/Core/{EntityFileParser.cpp => EntityXMLFileParser.cpp} (59%) rename src/Engine/Core/{EntityFilePreprocessor.cpp => EntityXMLFilePreprocessor.cpp} (93%) rename src/Engine/Core/{EntityFileWriter.cpp => EntityXMLFileWriter.cpp} (94%) diff --git a/include/Engine/Core/EntityFile.h b/include/Engine/Core/EntityXMLFile.h similarity index 98% rename from include/Engine/Core/EntityFile.h rename to include/Engine/Core/EntityXMLFile.h index 538e9047..6dcc74c5 100644 --- a/include/Engine/Core/EntityFile.h +++ b/include/Engine/Core/EntityXMLFile.h @@ -134,13 +134,13 @@ private: } }; -class EntityFile : public Resource +class EntityXMLFile : public Resource { friend class ResourceManager; friend class EntityFileSAXHandler; private: - EntityFile(boost::filesystem::path path); - ~EntityFile(); + EntityXMLFile(boost::filesystem::path path); + ~EntityXMLFile(); public: static unsigned int GetTypeStride(std::string typeName); diff --git a/include/Engine/Core/EntityFileParser.h b/include/Engine/Core/EntityXMLFileParser.h similarity index 86% rename from include/Engine/Core/EntityFileParser.h rename to include/Engine/Core/EntityXMLFileParser.h index b4eee5b2..c058640f 100644 --- a/include/Engine/Core/EntityFileParser.h +++ b/include/Engine/Core/EntityXMLFileParser.h @@ -1,18 +1,18 @@ #ifndef EntityFileParser_h__ #define EntityFileParser_h__ -#include "EntityFile.h" +#include "EntityXMLFile.h" #include "World.h" -class EntityFileParser +class EntityXMLFileParser { public: - EntityFileParser(const EntityFile* entityFile); + EntityXMLFileParser(const EntityXMLFile* entityFile); EntityID MergeEntities(World* world, EntityID baseParent = EntityID_Invalid); private: - const EntityFile* m_EntityFile; + const EntityXMLFile* m_EntityFile; EntityFileHandler m_Handler; World* m_World = nullptr; EntityID m_FirstEntity = EntityID_Invalid; diff --git a/include/Engine/Core/EntityFilePreprocessor.h b/include/Engine/Core/EntityXMLFilePreprocessor.h similarity index 87% rename from include/Engine/Core/EntityFilePreprocessor.h rename to include/Engine/Core/EntityXMLFilePreprocessor.h index b46bd383..45880835 100644 --- a/include/Engine/Core/EntityFilePreprocessor.h +++ b/include/Engine/Core/EntityXMLFilePreprocessor.h @@ -17,17 +17,17 @@ #include "Util/XercesString.h" #include "ResourceManager.h" #include "World.h" -#include "EntityFile.h" +#include "EntityXMLFile.h" -class EntityFilePreprocessor +class EntityXMLFilePreprocessor { public: - EntityFilePreprocessor(const EntityFile* entityFile); + EntityXMLFilePreprocessor(const EntityXMLFile* entityFile); void RegisterComponents(World* world); private: - const EntityFile* m_EntityFile; + const EntityXMLFile* m_EntityFile; std::map m_ComponentCounts; std::map m_ComponentInfo; diff --git a/include/Engine/Core/EntityFileWriter.h b/include/Engine/Core/EntityXMLFileWriter.h similarity index 92% rename from include/Engine/Core/EntityFileWriter.h rename to include/Engine/Core/EntityXMLFileWriter.h index b75bc145..9b100670 100644 --- a/include/Engine/Core/EntityFileWriter.h +++ b/include/Engine/Core/EntityXMLFileWriter.h @@ -8,13 +8,13 @@ #include #include "Util/XercesString.h" -#include "EntityFile.h" +#include "EntityXMLFile.h" #include "World.h" -class EntityFileWriter +class EntityXMLFileWriter { public: - EntityFileWriter(boost::filesystem::path file) + EntityXMLFileWriter(boost::filesystem::path file) : m_FilePath(file) { using namespace xercesc; diff --git a/include/Engine/Editor/EditorSystem.h b/include/Engine/Editor/EditorSystem.h index 06ee53b6..b565367a 100644 --- a/include/Engine/Editor/EditorSystem.h +++ b/include/Engine/Editor/EditorSystem.h @@ -5,9 +5,9 @@ #include "../Core/World.h" #include "../Core/SystemPipeline.h" #include "../Core/ResourceManager.h" -#include "../Core/EntityFilePreprocessor.h" -#include "../Core/EntityFileParser.h" -#include "../Core/EntityFileWriter.h" +#include "../Core/EntityXMLFilePreprocessor.h" +#include "../Core/EntityXMLFileParser.h" +#include "../Core/EntityXMLFileWriter.h" #include "../Core/EMousePress.h" #include "../Input/EInputCommand.h" #include "EditorGUI.h" diff --git a/include/Game/Game.h b/include/Game/Game.h index 06fd4703..4d173b48 100644 --- a/include/Game/Game.h +++ b/include/Game/Game.h @@ -13,13 +13,13 @@ #include "Input/KeyboardInputHandler.h" #include "Input/MouseInputHandler.h" #include "Core/EKeyDown.h" -#include "Core/EntityFilePreprocessor.h" +#include "Core/EntityXMLFilePreprocessor.h" #include "Core/SystemPipeline.h" #include "Systems/ExplosionEffectSystem.h" #include "Editor/EditorSystem.h" -#include "Core/EntityFile.h" +#include "Core/EntityXMLFile.h" #include "Rendering/RenderSystem.h" -#include "Core/EntityFileParser.h" +#include "Core/EntityXMLFileParser.h" #include "Core/Octree.h" #include "Rendering/Font.h" #include "Systems/InterpolationSystem.h" diff --git a/include/Game/Systems/AmmoPickupSystem.h b/include/Game/Systems/AmmoPickupSystem.h index 7917e765..8e5c4f1d 100644 --- a/include/Game/Systems/AmmoPickupSystem.h +++ b/include/Game/Systems/AmmoPickupSystem.h @@ -4,7 +4,7 @@ #include "Core/System.h" #include "Core/Transform.h" #include "Core/ResourceManager.h" -#include "Core/EntityFileParser.h" +#include "Core/EntityXMLFileParser.h" #include "Core/EPickupSpawned.h" #include "Core/EAmmoPickup.h" #include "Engine/Collision/ETrigger.h" diff --git a/include/Game/Systems/BoostSystem.h b/include/Game/Systems/BoostSystem.h index f82707ab..525918a4 100644 --- a/include/Game/Systems/BoostSystem.h +++ b/include/Game/Systems/BoostSystem.h @@ -3,7 +3,7 @@ #include "Core/System.h" #include "Core/ResourceManager.h" -#include "Core/EntityFileParser.h" +#include "Core/EntityXMLFileParser.h" #include "Core/EPlayerDamage.h" #include "Common.h" diff --git a/include/Game/Systems/DamageIndicatorSystem.h b/include/Game/Systems/DamageIndicatorSystem.h index ae9ba195..935089fa 100644 --- a/include/Game/Systems/DamageIndicatorSystem.h +++ b/include/Game/Systems/DamageIndicatorSystem.h @@ -4,7 +4,7 @@ #include "Core/System.h" #include "Core/Transform.h" #include "Core/ResourceManager.h" -#include "Core/EntityFileParser.h" +#include "Core/EntityXMLFileParser.h" #include "Core/EPlayerDamage.h" #include "Common.h" #include diff --git a/include/Game/Systems/PickupSpawnSystem.h b/include/Game/Systems/PickupSpawnSystem.h index be99141c..1151b487 100644 --- a/include/Game/Systems/PickupSpawnSystem.h +++ b/include/Game/Systems/PickupSpawnSystem.h @@ -4,7 +4,7 @@ #include "Core/System.h" #include "Core/Transform.h" #include "Core/ResourceManager.h" -#include "Core/EntityFileParser.h" +#include "Core/EntityXMLFileParser.h" #include "Core/EPickupSpawned.h" #include "Core/EPlayerHealthPickup.h" #include "Engine/Collision/ETrigger.h" diff --git a/include/Game/Systems/PlayerDeathSystem.h b/include/Game/Systems/PlayerDeathSystem.h index f32e32df..96ed2ab5 100644 --- a/include/Game/Systems/PlayerDeathSystem.h +++ b/include/Game/Systems/PlayerDeathSystem.h @@ -7,8 +7,8 @@ #include "Rendering/ESetCamera.h" #include "Core/ConfigFile.h" -#include "Core/EntityFile.h" -#include "Core/EntityFileParser.h" +#include "Core/EntityXMLFile.h" +#include "Core/EntityXMLFileParser.h" #include "Core/EPlayerDeath.h" #include "Core/EEntityDeleted.h" diff --git a/include/Game/Systems/PlayerMovementSystem.h b/include/Game/Systems/PlayerMovementSystem.h index cdf8ee22..8b6e4e54 100644 --- a/include/Game/Systems/PlayerMovementSystem.h +++ b/include/Game/Systems/PlayerMovementSystem.h @@ -7,8 +7,8 @@ #include "Events/EDoubleJump.h" #include "../Engine/Sound/EPlaySoundOnEntity.h" -#include "Core/EntityFile.h" -#include "Core/EntityFileParser.h" +#include "Core/EntityXMLFile.h" +#include "Core/EntityXMLFileParser.h" class PlayerMovementSystem : public ImpureSystem { diff --git a/include/Game/Systems/SpawnerSystem.h b/include/Game/Systems/SpawnerSystem.h index e4a44738..10817ef0 100644 --- a/include/Game/Systems/SpawnerSystem.h +++ b/include/Game/Systems/SpawnerSystem.h @@ -8,7 +8,7 @@ #include "Events/ESpawnerSpawn.h" #include "Core/Transform.h" #include "Core/ResourceManager.h" -#include "Core/EntityFileParser.h" +#include "Core/EntityXMLFileParser.h" class SpawnerSystem : public System { diff --git a/include/Game/Systems/Weapon/WeaponSystem.h b/include/Game/Systems/Weapon/WeaponSystem.h index b8278bc4..f6543ffb 100644 --- a/include/Game/Systems/Weapon/WeaponSystem.h +++ b/include/Game/Systems/Weapon/WeaponSystem.h @@ -9,8 +9,8 @@ #include "Core/EShoot.h" #include "Core/EPlayerSpawned.h" #include "Input/EInputCommand.h" -#include "Core/EntityFile.h" -#include "Core/EntityFileParser.h" +#include "Core/EntityXMLFile.h" +#include "Core/EntityXMLFileParser.h" #include "Core/Octree.h" #include "Collision/EntityAABB.h" #include "Systems/SpawnerSystem.h" diff --git a/src/Engine/Core/EntityFile.cpp b/src/Engine/Core/EntityXMLFile.cpp similarity index 94% rename from src/Engine/Core/EntityFile.cpp rename to src/Engine/Core/EntityXMLFile.cpp index 3987b092..b32d952d 100644 --- a/src/Engine/Core/EntityFile.cpp +++ b/src/Engine/Core/EntityXMLFile.cpp @@ -1,6 +1,6 @@ -#include "Core/EntityFile.h" +#include "Core/EntityXMLFile.h" -EntityFile::EntityFile(boost::filesystem::path path) +EntityXMLFile::EntityXMLFile(boost::filesystem::path path) : m_FilePath(path) { using namespace xercesc; @@ -9,14 +9,14 @@ EntityFile::EntityFile(boost::filesystem::path path) m_SAX2XMLReader = XMLReaderFactory::createXMLReader(XMLPlatformUtils::fgMemoryManager, m_GrammarPool); } -EntityFile::~EntityFile() +EntityXMLFile::~EntityXMLFile() { delete m_SAX2XMLReader; delete m_GrammarPool; xercesc::XMLPlatformUtils::Terminate(); } -void EntityFile::Parse(const EntityFileHandler* handler) const +void EntityXMLFile::Parse(const EntityFileHandler* handler) const { using namespace xercesc; @@ -28,7 +28,7 @@ void EntityFile::Parse(const EntityFileHandler* handler) const m_SAX2XMLReader->parse(m_FilePath.string().c_str()); } -void EntityFile::setReaderFeatures(xercesc::SAX2XMLReader* reader) +void EntityXMLFile::setReaderFeatures(xercesc::SAX2XMLReader* reader) { using namespace xercesc; reader->setFeature(XMLUni::fgXercesCacheGrammarFromParse, true); @@ -41,7 +41,7 @@ void EntityFile::setReaderFeatures(xercesc::SAX2XMLReader* reader) reader->setFeature(XMLUni::fgXercesIdentityConstraintChecking, true); } -unsigned int EntityFile::GetTypeStride(std::string typeName) +unsigned int EntityXMLFile::GetTypeStride(std::string typeName) { std::map typeStrides{ { "bool", sizeof(bool) }, @@ -59,7 +59,7 @@ unsigned int EntityFile::GetTypeStride(std::string typeName) return (it != typeStrides.end()) ? it->second : 0; } -void EntityFile::WriteAttributeData(char* outData, const ComponentInfo::Field_t& field, const std::map& attributes) +void EntityXMLFile::WriteAttributeData(char* outData, const ComponentInfo::Field_t& field, const std::map& attributes) { if (field.Type == "Vector") { glm::vec3 vec; @@ -86,7 +86,7 @@ void EntityFile::WriteAttributeData(char* outData, const ComponentInfo::Field_t& } } -void EntityFile::WriteValueData(char* outData, const ComponentInfo::Field_t& field, const char* valueData) +void EntityXMLFile::WriteValueData(char* outData, const ComponentInfo::Field_t& field, const char* valueData) { // Catch and ignore casting errors so whitespace around string enums won't mess anything up try { @@ -243,7 +243,7 @@ void EntityFileSAXHandler::onStartEntityRef(const xercesc::Attributes& attrs) std::string path = XS::ToString(attrs.getValue(XS::ToXMLCh("file"))); xercesc::SAX2XMLReader* reader = xercesc::XMLReaderFactory::createXMLReader(); - EntityFile::setReaderFeatures(reader); + EntityXMLFile::setReaderFeatures(reader); reader->setContentHandler(this); reader->setErrorHandler(this); reader->parse(path.c_str()); diff --git a/src/Engine/Core/EntityFileParser.cpp b/src/Engine/Core/EntityXMLFileParser.cpp similarity index 59% rename from src/Engine/Core/EntityFileParser.cpp rename to src/Engine/Core/EntityXMLFileParser.cpp index 2beaac14..9c79775c 100644 --- a/src/Engine/Core/EntityFileParser.cpp +++ b/src/Engine/Core/EntityXMLFileParser.cpp @@ -1,15 +1,15 @@ -#include "Core/EntityFileParser.h" +#include "Core/EntityXMLFileParser.h" -EntityFileParser::EntityFileParser(const EntityFile* entityFile) +EntityXMLFileParser::EntityXMLFileParser(const EntityXMLFile* entityFile) : m_EntityFile(entityFile) { - m_Handler.SetStartEntityCallback(std::bind(&EntityFileParser::onStartEntity, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); - m_Handler.SetStartComponentCallback(std::bind(&EntityFileParser::onStartComponent, this, std::placeholders::_1, std::placeholders::_2)); - m_Handler.SetStartFieldCallback(std::bind(&EntityFileParser::onStartComponentField, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)); - m_Handler.SetStartFieldDataCallback(std::bind(&EntityFileParser::onFieldData, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)); + m_Handler.SetStartEntityCallback(std::bind(&EntityXMLFileParser::onStartEntity, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); + m_Handler.SetStartComponentCallback(std::bind(&EntityXMLFileParser::onStartComponent, this, std::placeholders::_1, std::placeholders::_2)); + m_Handler.SetStartFieldCallback(std::bind(&EntityXMLFileParser::onStartComponentField, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)); + m_Handler.SetStartFieldDataCallback(std::bind(&EntityXMLFileParser::onFieldData, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)); } -EntityID EntityFileParser::MergeEntities(World* world, EntityID baseParent /*= EntityID_Invalid */) +EntityID EntityXMLFileParser::MergeEntities(World* world, EntityID baseParent /*= EntityID_Invalid */) { m_World = world; m_EntityIDMapper[0] = baseParent; @@ -17,7 +17,7 @@ EntityID EntityFileParser::MergeEntities(World* world, EntityID baseParent /*= E return m_FirstEntity; } -void EntityFileParser::onStartEntity(EntityID entity, EntityID parent, const std::string& name) +void EntityXMLFileParser::onStartEntity(EntityID entity, EntityID parent, const std::string& name) { EntityID realParent = m_EntityIDMapper.at(parent); EntityID realEntity = m_World->CreateEntity(realParent); @@ -31,7 +31,7 @@ void EntityFileParser::onStartEntity(EntityID entity, EntityID parent, const std //LOG_DEBUG("Created entity #%i (%i) with parent %i (%i)", entity, realEntity, parent, realParent); } -void EntityFileParser::onStartComponent(EntityID entity, const std::string& component) +void EntityXMLFileParser::onStartComponent(EntityID entity, const std::string& component) { if (m_World->GetComponentPools().count(component) != 0) { EntityID realEntity = m_EntityIDMapper.at(entity); @@ -42,7 +42,7 @@ void EntityFileParser::onStartComponent(EntityID entity, const std::string& comp //LOG_DEBUG("Attached component of type \"%s\" to entity #%i (%i)", component.c_str(), entity, realEntity); } -void EntityFileParser::onStartComponentField(EntityID entity, const std::string& componentType, const std::string& fieldName, const std::map& attributes) +void EntityXMLFileParser::onStartComponentField(EntityID entity, const std::string& componentType, const std::string& fieldName, const std::map& attributes) { if (m_World->GetComponentPools().count(componentType) == 0) { return; @@ -63,10 +63,10 @@ void EntityFileParser::onStartComponentField(EntityID entity, const std::string& //} char* data = component.Data + field.Offset; - EntityFile::WriteAttributeData(data, field, attributes); + EntityXMLFile::WriteAttributeData(data, field, attributes); } -void EntityFileParser::onFieldData(EntityID entity, const std::string& componentType, const std::string& fieldName, const char* fieldData) +void EntityXMLFileParser::onFieldData(EntityID entity, const std::string& componentType, const std::string& fieldName, const char* fieldData) { if (m_World->GetComponentPools().count(componentType) == 0) { return; @@ -80,5 +80,5 @@ void EntityFileParser::onFieldData(EntityID entity, const std::string& component auto& field = fieldIt->second; char* data = component.Data + field.Offset; - EntityFile::WriteValueData(data, field, fieldData); + EntityXMLFile::WriteValueData(data, field, fieldData); } diff --git a/src/Engine/Core/EntityFilePreprocessor.cpp b/src/Engine/Core/EntityXMLFilePreprocessor.cpp similarity index 93% rename from src/Engine/Core/EntityFilePreprocessor.cpp rename to src/Engine/Core/EntityXMLFilePreprocessor.cpp index 592daedb..9695509d 100644 --- a/src/Engine/Core/EntityFilePreprocessor.cpp +++ b/src/Engine/Core/EntityXMLFilePreprocessor.cpp @@ -1,10 +1,10 @@ -#include "Core/EntityFilePreprocessor.h" +#include "Core/EntityXMLFilePreprocessor.h" -EntityFilePreprocessor::EntityFilePreprocessor(const EntityFile* entityFile) +EntityXMLFilePreprocessor::EntityXMLFilePreprocessor(const EntityXMLFile* entityFile) : m_EntityFile(entityFile) { EntityFileHandler handler; - handler.SetStartComponentCallback(std::bind(&EntityFilePreprocessor::onStartComponent, this, std::placeholders::_1, std::placeholders::_2)); + handler.SetStartComponentCallback(std::bind(&EntityXMLFilePreprocessor::onStartComponent, this, std::placeholders::_1, std::placeholders::_2)); m_EntityFile->Parse(&handler); //LOG_DEBUG("___ COMPONENT DEFINITIONS ___"); @@ -28,20 +28,20 @@ EntityFilePreprocessor::EntityFilePreprocessor(const EntityFile* entityFile) parseDefaults(); } -void EntityFilePreprocessor::RegisterComponents(World* world) +void EntityXMLFilePreprocessor::RegisterComponents(World* world) { for (auto& kv : m_ComponentInfo) { world->RegisterComponent(kv.second); } } -void EntityFilePreprocessor::onStartComponent(EntityID entity, std::string type) +void EntityXMLFilePreprocessor::onStartComponent(EntityID entity, std::string type) { //LOG_DEBUG("Component: %s", type.c_str()); m_ComponentCounts[type]++; } -void EntityFilePreprocessor::parseComponentInfo() +void EntityXMLFilePreprocessor::parseComponentInfo() { using namespace xercesc; EntityFileXMLErrorHandler errorHandler; @@ -141,9 +141,9 @@ void EntityFilePreprocessor::parseComponentInfo() std::string baseType = XS::ToString(elementDeclaration->getTypeDefinition()->getBaseType()->getName()); std::string effectiveType = type; - unsigned int stride = EntityFile::GetTypeStride(type); + unsigned int stride = EntityXMLFile::GetTypeStride(type); if (stride == 0) { - stride = EntityFile::GetTypeStride(baseType); + stride = EntityXMLFile::GetTypeStride(baseType); if (stride == 0) { LOG_WARNING("Field \"%s\" in component \"%s\" uses unexpected field type \"%s\" with base type \"%s\". Skipping.", name.c_str(), compInfo.Name.c_str(), type.c_str(), baseType.c_str()); continue; @@ -196,7 +196,7 @@ void EntityFilePreprocessor::parseComponentInfo() } } -void EntityFilePreprocessor::parseDefaults() +void EntityXMLFilePreprocessor::parseDefaults() { using namespace xercesc; @@ -261,7 +261,7 @@ void EntityFilePreprocessor::parseDefaults() auto attribItem = attributeMap->item(i); attributes[XS::ToString(attribItem->getNodeName())] = XS::ToString(attribItem->getNodeValue()); } - EntityFile::WriteAttributeData(data, field, attributes); + EntityXMLFile::WriteAttributeData(data, field, attributes); } auto childNode = fieldElement->getFirstChild(); @@ -278,14 +278,14 @@ void EntityFilePreprocessor::parseDefaults() // Handle potential field values if (childNode->getNodeType() == DOMNode::TEXT_NODE) { char* cstrValue = XMLString::transcode(childNode->getNodeValue()); - EntityFile::WriteValueData(data, field, cstrValue); + EntityXMLFile::WriteValueData(data, field, cstrValue); XMLString::release(&cstrValue); } } } } -std::string EntityFilePreprocessor::parseAnnotationXML(const XMLCh* xml) +std::string EntityXMLFilePreprocessor::parseAnnotationXML(const XMLCh* xml) { using namespace xercesc; diff --git a/src/Engine/Core/EntityFileWriter.cpp b/src/Engine/Core/EntityXMLFileWriter.cpp similarity index 94% rename from src/Engine/Core/EntityFileWriter.cpp rename to src/Engine/Core/EntityXMLFileWriter.cpp index 06a3c4ca..a98d3fbd 100644 --- a/src/Engine/Core/EntityFileWriter.cpp +++ b/src/Engine/Core/EntityXMLFileWriter.cpp @@ -1,13 +1,13 @@ -#include "Core/EntityFileWriter.h" +#include "Core/EntityXMLFileWriter.h" #define X(str) XS::ToXMLCh(str) -void EntityFileWriter::WriteWorld(World* world) +void EntityXMLFileWriter::WriteWorld(World* world) { WriteEntity(world, 0); } -void EntityFileWriter::WriteEntity(World* world, EntityID entity) +void EntityXMLFileWriter::WriteEntity(World* world, EntityID entity) { using namespace xercesc; DOMDocument* doc = m_DOMImplementation->createDocument(nullptr, X("Entity"), nullptr); @@ -41,7 +41,7 @@ void EntityFileWriter::WriteEntity(World* world, EntityID entity) doc->release(); } -void EntityFileWriter::appendEntityChildren(xercesc::DOMElement* parentElement, const World* world, EntityID entity) +void EntityXMLFileWriter::appendEntityChildren(xercesc::DOMElement* parentElement, const World* world, EntityID entity) { using namespace xercesc; DOMDocument* doc = parentElement->getOwnerDocument(); @@ -67,7 +67,7 @@ void EntityFileWriter::appendEntityChildren(xercesc::DOMElement* parentElement, } } -void EntityFileWriter::appentEntityComponents(xercesc::DOMElement* parentElement, const World* world, EntityID entity) +void EntityXMLFileWriter::appentEntityComponents(xercesc::DOMElement* parentElement, const World* world, EntityID entity) { using namespace xercesc; DOMDocument* doc = parentElement->getOwnerDocument(); diff --git a/src/Engine/Editor/EditorSystem.cpp b/src/Engine/Editor/EditorSystem.cpp index b0929df9..3e664161 100644 --- a/src/Engine/Editor/EditorSystem.cpp +++ b/src/Engine/Editor/EditorSystem.cpp @@ -129,7 +129,7 @@ void EditorSystem::OnEntitySelected(EntityWrapper entity) void EditorSystem::OnEntitySave(EntityWrapper entity, boost::filesystem::path filePath) { - EntityFileWriter writer(filePath); + EntityXMLFileWriter writer(filePath); writer.WriteEntity(entity.World, entity.ID); } @@ -259,10 +259,10 @@ EntityWrapper EditorSystem::importEntity(EntityWrapper parent, boost::filesystem } try { - auto entityFile = ResourceManager::Load(filePath.string()); - EntityFilePreprocessor fpp(entityFile); + auto entityFile = ResourceManager::Load(filePath.string()); + EntityXMLFilePreprocessor fpp(entityFile); fpp.RegisterComponents(parent.World); - EntityFileParser fp(entityFile); + EntityXMLFileParser fp(entityFile); EntityID newEntity = fp.MergeEntities(parent.World, parent.ID); return EntityWrapper(parent.World, newEntity); } catch (const std::exception& e) { diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index b4c1a71d..9c9228b9 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -11,7 +11,7 @@ #include "Systems/PlayerSpawnSystem.h" #include "Systems/PlayerDeathSystem.h" #include "Systems/FloatingEffectSystem.h" -#include "Core/EntityFileWriter.h" +#include "Core/EntityXMLFileWriter.h" #include "Game/Systems/CapturePointSystem.h" #include "Game/Systems/CapturePointHUDSystem.h" #include "Game/Systems/PickupSpawnSystem.h" @@ -44,7 +44,7 @@ Game::Game(int argc, char* argv[]) ResourceManager::RegisterType("Texture"); ResourceManager::RegisterType("Png"); ResourceManager::RegisterType("ShaderProgram"); - ResourceManager::RegisterType("EntityFile"); + ResourceManager::RegisterType("EntityFile"); ResourceManager::RegisterType("FontFile"); m_Config = ResourceManager::Load("Config.ini"); @@ -80,10 +80,10 @@ Game::Game(int argc, char* argv[]) m_World = new World(m_EventBroker); std::string mapToLoad = m_Config->Get("Debug.LoadMap", ""); if (!mapToLoad.empty()) { - auto file = ResourceManager::Load(mapToLoad); - EntityFilePreprocessor fpp(file); + auto file = ResourceManager::Load(mapToLoad); + EntityXMLFilePreprocessor fpp(file); fpp.RegisterComponents(m_World); - EntityFileParser fp(file); + EntityXMLFileParser fp(file); fp.MergeEntities(m_World); } diff --git a/src/Game/Systems/AmmoPickupSystem.cpp b/src/Game/Systems/AmmoPickupSystem.cpp index 74d86f70..e3051efe 100644 --- a/src/Game/Systems/AmmoPickupSystem.cpp +++ b/src/Game/Systems/AmmoPickupSystem.cpp @@ -20,8 +20,8 @@ void AmmoPickupSystem::Update(double dt) auto& somePickup = *it; somePickup.DecreaseThisRespawnTimer -= dt; if (somePickup.DecreaseThisRespawnTimer < 0.0) { - auto entityFile = ResourceManager::Load("Schema/Entities/AmmoPickup.xml"); - EntityFileParser parser(entityFile); + auto entityFile = ResourceManager::Load("Schema/Entities/AmmoPickup.xml"); + EntityXMLFileParser parser(entityFile); EntityID ammoPickupID = parser.MergeEntities(m_World); //let the world know a pickup has spawned diff --git a/src/Game/Systems/BoostSystem.cpp b/src/Game/Systems/BoostSystem.cpp index 9e4d6968..7f335d1f 100644 --- a/src/Game/Systems/BoostSystem.cpp +++ b/src/Game/Systems/BoostSystem.cpp @@ -38,8 +38,8 @@ bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e) m_World->DeleteEntity(playerBoostAssaultEntity.ID); } //load boost XML file, set it entity parented with the victim player - auto entityFile = ResourceManager::Load(classXML); - EntityFileParser parser(entityFile); + auto entityFile = ResourceManager::Load(classXML); + EntityXMLFileParser parser(entityFile); EntityID boostAssaultEntity = parser.MergeEntities(m_World); m_World->SetName(boostAssaultEntity, className); m_World->SetParent(boostAssaultEntity, e.Victim.ID); diff --git a/src/Game/Systems/DamageIndicatorSystem.cpp b/src/Game/Systems/DamageIndicatorSystem.cpp index ca26052d..55a1046c 100644 --- a/src/Game/Systems/DamageIndicatorSystem.cpp +++ b/src/Game/Systems/DamageIndicatorSystem.cpp @@ -9,7 +9,7 @@ DamageIndicatorSystem::DamageIndicatorSystem(SystemParams params) //load texture to cache auto texture = CommonFunctions::LoadTexture("Textures/DamageIndicator.png", false); - auto entityFile = ResourceManager::Load("Schema/Entities/DamageIndicator.xml"); + auto entityFile = ResourceManager::Load("Schema/Entities/DamageIndicator.xml"); } void DamageIndicatorSystem::Update(double dt) { @@ -49,8 +49,8 @@ bool DamageIndicatorSystem::OnPlayerDamage(Events::PlayerDamage& e) float angleBetweenVectors = CalculateAngle(e.Victim, inflictorPos); //load & set the "2d" sprite - auto entityFile = ResourceManager::Load("Schema/Entities/DamageIndicator.xml"); - EntityFileParser parser(entityFile); + auto entityFile = ResourceManager::Load("Schema/Entities/DamageIndicator.xml"); + EntityXMLFileParser parser(entityFile); EntityID spriteID = parser.MergeEntities(m_World); m_World->SetParent(spriteID, m_CurrentCamera); auto spriteWrapper = EntityWrapper(m_World, spriteID); @@ -127,8 +127,8 @@ glm::vec3 DamageIndicatorSystem::DamageIndicatorTest(EntityWrapper player) { auto inflictorPos = glm::vec3(currentPos.x + testVar*6.0f, currentPos.y, currentPos.z + testVar2*6.0f); //load the explosioneffect XML - auto deathEffect = ResourceManager::Load("Schema/Entities/PlayerDeathExplosionWithCamera.xml"); - EntityFileParser parser(deathEffect); + auto deathEffect = ResourceManager::Load("Schema/Entities/PlayerDeathExplosionWithCamera.xml"); + EntityXMLFileParser parser(deathEffect); EntityID deathEffectID = parser.MergeEntities(m_World); EntityWrapper deathEffectEW = EntityWrapper(m_World, deathEffectID); diff --git a/src/Game/Systems/PickupSpawnSystem.cpp b/src/Game/Systems/PickupSpawnSystem.cpp index 79e7d66b..9d1ce5b6 100644 --- a/src/Game/Systems/PickupSpawnSystem.cpp +++ b/src/Game/Systems/PickupSpawnSystem.cpp @@ -18,8 +18,8 @@ void PickupSpawnSystem::Update(double dt) somePickup.DecreaseThisRespawnTimer -= dt; if (somePickup.DecreaseThisRespawnTimer < 0.0) { //spawn the new healthPickup - auto entityFile = ResourceManager::Load("Schema/Entities/HealthPickup.xml"); - EntityFileParser parser(entityFile); + auto entityFile = ResourceManager::Load("Schema/Entities/HealthPickup.xml"); + EntityXMLFileParser parser(entityFile); EntityID healthPickupID = parser.MergeEntities(m_World); //let the world know a pickup has spawned (graphics effects, etc) diff --git a/src/Game/Systems/PlayerDeathSystem.cpp b/src/Game/Systems/PlayerDeathSystem.cpp index 0f05da57..1a491580 100644 --- a/src/Game/Systems/PlayerDeathSystem.cpp +++ b/src/Game/Systems/PlayerDeathSystem.cpp @@ -28,8 +28,8 @@ bool PlayerDeathSystem::OnPlayerDeath(Events::PlayerDeath& e) void PlayerDeathSystem::createDeathEffect(EntityWrapper player) { //load the explosioneffect XML - auto deathEffect = ResourceManager::Load("Schema/Entities/PlayerDeathExplosionWithCamera.xml"); - EntityFileParser parser(deathEffect); + auto deathEffect = ResourceManager::Load("Schema/Entities/PlayerDeathExplosionWithCamera.xml"); + EntityXMLFileParser parser(deathEffect); EntityID deathEffectID = parser.MergeEntities(m_World); EntityWrapper deathEffectEW = EntityWrapper(m_World, deathEffectID); diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 9afc9c8c..5a687b84 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -328,8 +328,8 @@ bool PlayerMovementSystem::OnDoubleJump(Events::DoubleJump & e) void PlayerMovementSystem::spawnHexagon(EntityWrapper target) { //put a hexagon at the entitys... feet? - auto hexagonEffect = ResourceManager::Load("Schema/Entities/DoubleJumpHexagon.xml"); - EntityFileParser parser(hexagonEffect); + auto hexagonEffect = ResourceManager::Load("Schema/Entities/DoubleJumpHexagon.xml"); + EntityXMLFileParser parser(hexagonEffect); EntityID hexagonEffectID = parser.MergeEntities(m_World); EntityWrapper hexagonEW = EntityWrapper(m_World, hexagonEffectID); hexagonEW["Transform"]["Position"] = (glm::vec3)target["Transform"]["Position"]; @@ -342,8 +342,8 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) return false; } - auto dashEffectResource = ResourceManager::Load("Schema/Entities/DashEffect.xml"); - EntityFileParser parser(dashEffectResource); + auto dashEffectResource = ResourceManager::Load("Schema/Entities/DashEffect.xml"); + EntityXMLFileParser parser(dashEffectResource); EntityID dashEffectID = parser.MergeEntities(m_World); EntityWrapper dashEffect(m_World, dashEffectID); auto playerModel = player.FirstChildByName("PlayerModel"); diff --git a/src/Game/Systems/SpawnerSystem.cpp b/src/Game/Systems/SpawnerSystem.cpp index 6500460f..b16f7dfe 100644 --- a/src/Game/Systems/SpawnerSystem.cpp +++ b/src/Game/Systems/SpawnerSystem.cpp @@ -17,11 +17,11 @@ EntityWrapper SpawnerSystem::Spawn(EntityWrapper spawner, EntityWrapper parent / // Load the entity file and parse it const std::string& entityFilePath = spawner["Spawner"]["EntityFile"]; - auto entityFile = ResourceManager::Load(entityFilePath); + auto entityFile = ResourceManager::Load(entityFilePath); if (entityFile == nullptr) { return EntityWrapper::Invalid; } - EntityFileParser parser(entityFile); + EntityXMLFileParser parser(entityFile); EntityWrapper spawnedEntity(world, parser.MergeEntities(world, parent.ID)); //If the spawned entity is collideable, then we must not spawn it where it collides with something that diff --git a/src/Tests/CapturePointTest.cpp b/src/Tests/CapturePointTest.cpp index 8a9baf40..8fb7869c 100644 --- a/src/Tests/CapturePointTest.cpp +++ b/src/Tests/CapturePointTest.cpp @@ -7,7 +7,7 @@ using boost::unit_test_framework::test_case; #include "Collision/TriggerSystem.h" #include "Collision/CollisionSystem.h" -#include "Core/EntityFileWriter.h" +#include "Core/EntityXMLFileWriter.h" #include "Game/Systems/CapturePointSystem.h" BOOST_AUTO_TEST_SUITE(CapturePointTestSuite) @@ -82,7 +82,7 @@ bool CapturePointTest::CapturePoint_Game_Loop_OneHundredTimes() { CapturePointTest::CapturePointTest(int runTestNumber) { ResourceManager::RegisterType("ConfigFile"); - ResourceManager::RegisterType("EntityFile"); + ResourceManager::RegisterType("EntityFile"); m_Config = ResourceManager::Load("Config.ini"); LOG_LEVEL = static_cast<_LOG_LEVEL>(m_Config->Get("Debug.LogLevel", 1)); @@ -99,10 +99,10 @@ CapturePointTest::CapturePointTest(int runTestNumber) m_SystemPipeline->AddSystem(1); //must register components (Components.xsd), else you cant create entities. Easiest done by loading a test xsd file - auto file = ResourceManager::Load("Schema/Entities/TeamTest.xml"); - EntityFilePreprocessor fpp(file); + auto file = ResourceManager::Load("Schema/Entities/TeamTest.xml"); + EntityXMLFilePreprocessor fpp(file); fpp.RegisterComponents(m_World); - EntityFileParser fp(file); + EntityXMLFileParser fp(file); fp.MergeEntities(m_World); EntityID playerID = m_World->CreateEntity(); diff --git a/src/Tests/CapturePointTest.h b/src/Tests/CapturePointTest.h index 54bdc55c..1046f714 100644 --- a/src/Tests/CapturePointTest.h +++ b/src/Tests/CapturePointTest.h @@ -9,12 +9,12 @@ #include "Input/KeyboardInputHandler.h" #include "Input/MouseInputHandler.h" #include "Core/EKeyDown.h" -#include "Core/EntityFile.h" +#include "Core/EntityXMLFile.h" #include "Core/SystemPipeline.h" -#include "Core/EntityFilePreprocessor.h" -#include "Core/EntityFileParser.h" -#include "Core/EntityFileWriter.h" +#include "Core/EntityXMLFilePreprocessor.h" +#include "Core/EntityXMLFileParser.h" +#include "Core/EntityXMLFileWriter.h" #include "Engine/Collision/ETrigger.h" diff --git a/src/Tests/HealthSystemTest.cpp b/src/Tests/HealthSystemTest.cpp index bf2650a3..0a8758ae 100644 --- a/src/Tests/HealthSystemTest.cpp +++ b/src/Tests/HealthSystemTest.cpp @@ -30,7 +30,7 @@ BOOST_AUTO_TEST_SUITE_END() GameHealthSystemTest::GameHealthSystemTest() { ResourceManager::RegisterType("ConfigFile"); - ResourceManager::RegisterType("EntityFile"); + ResourceManager::RegisterType("EntityFile"); m_Config = ResourceManager::Load("Config.ini"); LOG_LEVEL = static_cast<_LOG_LEVEL>(m_Config->Get("Debug.LogLevel", 1)); @@ -41,10 +41,10 @@ GameHealthSystemTest::GameHealthSystemTest() // Create a world m_World = new World(); - auto file = ResourceManager::Load("Schema/Entities/TeamTest.xml"); - EntityFilePreprocessor fpp(file); + auto file = ResourceManager::Load("Schema/Entities/TeamTest.xml"); + EntityXMLFilePreprocessor fpp(file); fpp.RegisterComponents(m_World); - EntityFileParser fp(file); + EntityXMLFileParser fp(file); fp.MergeEntities(m_World); // Create system pipeline diff --git a/src/Tests/HealthSystemTest.h b/src/Tests/HealthSystemTest.h index 275558d2..787a2d0e 100644 --- a/src/Tests/HealthSystemTest.h +++ b/src/Tests/HealthSystemTest.h @@ -11,7 +11,7 @@ #include "Input/KeyboardInputHandler.h" #include "Input/MouseInputHandler.h" #include "Core/EKeyDown.h" -#include "Core/EntityFile.h" +#include "Core/EntityXMLFile.h" #include "Core/SystemPipeline.h" #include "Editor/EditorSystem.h" diff --git a/src/Tests/PickupSpawnTest.cpp b/src/Tests/PickupSpawnTest.cpp index 4acd897e..0af72883 100644 --- a/src/Tests/PickupSpawnTest.cpp +++ b/src/Tests/PickupSpawnTest.cpp @@ -30,7 +30,7 @@ BOOST_AUTO_TEST_SUITE_END() PickupSpawnTest::PickupSpawnTest(int runTestNumber) { ResourceManager::RegisterType("ConfigFile"); - ResourceManager::RegisterType("EntityFile"); + ResourceManager::RegisterType("EntityFile"); m_Config = ResourceManager::Load("Config.ini"); LOG_LEVEL = static_cast<_LOG_LEVEL>(m_Config->Get("Debug.LogLevel", 1)); @@ -44,10 +44,10 @@ PickupSpawnTest::PickupSpawnTest(int runTestNumber) m_SystemPipeline->AddSystem(1); //must register components (Components.xsd), else you cant create entities. Easiest done by loading a test xsd file - auto file = ResourceManager::Load("Schema/Entities/HealthPickup.xml"); - EntityFilePreprocessor fpp(file); + auto file = ResourceManager::Load("Schema/Entities/HealthPickup.xml"); + EntityXMLFilePreprocessor fpp(file); fpp.RegisterComponents(m_World); - EntityFileParser fp(file); + EntityXMLFileParser fp(file); //connect the healthpickup to the world m_HealthPickupID = fp.MergeEntities(m_World); diff --git a/src/Tests/PickupSpawnTest.h b/src/Tests/PickupSpawnTest.h index b9d5483a..372b07cd 100644 --- a/src/Tests/PickupSpawnTest.h +++ b/src/Tests/PickupSpawnTest.h @@ -9,12 +9,12 @@ #include "Input/KeyboardInputHandler.h" #include "Input/MouseInputHandler.h" #include "Core/EKeyDown.h" -#include "Core/EntityFile.h" +#include "Core/EntityXMLFile.h" #include "Core/SystemPipeline.h" -#include "Core/EntityFilePreprocessor.h" -#include "Core/EntityFileParser.h" -#include "Core/EntityFileWriter.h" +#include "Core/EntityXMLFilePreprocessor.h" +#include "Core/EntityXMLFileParser.h" +#include "Core/EntityXMLFileWriter.h" #include "Engine/Collision/ETrigger.h" @@ -29,7 +29,7 @@ //#include #include "Collision/TriggerSystem.h" #include "Collision/CollisionSystem.h" -#include "Core/EntityFileWriter.h" +#include "Core/EntityXMLFileWriter.h" #include "Game/Systems/HealthSystem.h" #include "Game/Systems/PickupSpawnSystem.h" From 0c0f2d7e50d8d14a395b95b1452571a89f59ba9c Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 2 Mar 2016 18:56:22 +0100 Subject: [PATCH 152/252] fixup! Renamed EntityFile to EntityXMLFile to be able to separate file parsing from entity creation --- include/Engine/Core/EntityXMLFile.h | 4 ++-- include/Engine/Core/EntityXMLFileParser.h | 4 ++-- include/Engine/Core/EntityXMLFilePreprocessor.h | 4 ++-- include/Engine/Core/EntityXMLFileWriter.h | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/Engine/Core/EntityXMLFile.h b/include/Engine/Core/EntityXMLFile.h index 6dcc74c5..6f24154d 100644 --- a/include/Engine/Core/EntityXMLFile.h +++ b/include/Engine/Core/EntityXMLFile.h @@ -1,5 +1,5 @@ -#ifndef EntityFile_h__ -#define EntityFile_h__ +#ifndef EntityXMLFile_h__ +#define EntityXMLFile_h__ #include #include diff --git a/include/Engine/Core/EntityXMLFileParser.h b/include/Engine/Core/EntityXMLFileParser.h index c058640f..984f9e46 100644 --- a/include/Engine/Core/EntityXMLFileParser.h +++ b/include/Engine/Core/EntityXMLFileParser.h @@ -1,5 +1,5 @@ -#ifndef EntityFileParser_h__ -#define EntityFileParser_h__ +#ifndef EntityXMLFileParser_h__ +#define EntityXMLFileParser_h__ #include "EntityXMLFile.h" #include "World.h" diff --git a/include/Engine/Core/EntityXMLFilePreprocessor.h b/include/Engine/Core/EntityXMLFilePreprocessor.h index 45880835..e102ef79 100644 --- a/include/Engine/Core/EntityXMLFilePreprocessor.h +++ b/include/Engine/Core/EntityXMLFilePreprocessor.h @@ -1,5 +1,5 @@ -#ifndef EntityFilePreprocessor_h__ -#define EntityFilePreprocessor_h__ +#ifndef EntityXMLFilePreprocessor_h__ +#define EntityXMLFilePreprocessor_h__ #include #include diff --git a/include/Engine/Core/EntityXMLFileWriter.h b/include/Engine/Core/EntityXMLFileWriter.h index 9b100670..da073a73 100644 --- a/include/Engine/Core/EntityXMLFileWriter.h +++ b/include/Engine/Core/EntityXMLFileWriter.h @@ -1,5 +1,5 @@ -#ifndef EntityFileWriter_h__ -#define EntityFileWriter_h__ +#ifndef EntityXMLFileWriter_h__ +#define EntityXMLFileWriter_h__ #include #include From fb9914d08a821d800641f7138ad9f3ca2824fe26 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 2 Mar 2016 19:48:20 +0100 Subject: [PATCH 153/252] Fixed AMD shader compilation error --- resources/Shaders/ForwardPlusSplatMapRGBShieldCheck.frag.glsl | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/Shaders/ForwardPlusSplatMapRGBShieldCheck.frag.glsl b/resources/Shaders/ForwardPlusSplatMapRGBShieldCheck.frag.glsl index fa3af6ac..d61726fe 100644 --- a/resources/Shaders/ForwardPlusSplatMapRGBShieldCheck.frag.glsl +++ b/resources/Shaders/ForwardPlusSplatMapRGBShieldCheck.frag.glsl @@ -40,7 +40,6 @@ layout (binding = 10) uniform sampler2D SpecularMapTexture3; layout (binding = 11) uniform sampler2D GlowMapTexture1; layout (binding = 12) uniform sampler2D GlowMapTexture2; layout (binding = 13) uniform sampler2D GlowMapTexture3; -layout (binding = 13) uniform sampler2D GlowMapTexture3; layout (binding = 31) uniform samplerCube ShieldBuffer; #define TILE_SIZE 16 From 618e96da9084fa4d452ad1b9c1bacc9eea6b58f5 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 2 Mar 2016 19:49:54 +0100 Subject: [PATCH 154/252] "Fixed" this crash in debug. The attachment vector is sometimes empty! @Tleety --- src/Engine/Rendering/FrameBuffer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Engine/Rendering/FrameBuffer.cpp b/src/Engine/Rendering/FrameBuffer.cpp index 9ba0d2d8..da438e7a 100644 --- a/src/Engine/Rendering/FrameBuffer.cpp +++ b/src/Engine/Rendering/FrameBuffer.cpp @@ -70,7 +70,7 @@ void FrameBuffer::Generate() } GLERROR("3"); - GLenum* bufferTextures = &attachments[0]; + GLenum* bufferTextures = attachments.data(); glDrawBuffers(attachments.size(), bufferTextures); if (GLERROR("GLBufferAttachement error")) { printf(": AttachmentSize %i", attachments.size()); From 44b4a597d43e2058025caadce3e880f7a947c737 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 2 Mar 2016 19:50:52 +0100 Subject: [PATCH 155/252] fixup! Created World::Merge which will merge a world into another one --- include/Engine/Core/World.h | 2 +- src/Engine/Core/World.cpp | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/Engine/Core/World.h b/include/Engine/Core/World.h index 28c96303..9ae38021 100644 --- a/include/Engine/Core/World.h +++ b/include/Engine/Core/World.h @@ -55,7 +55,7 @@ public: // Merge another world into this one // Returns a map that maps entities from the other world to their copies in this one - std::unordered_map Merge(World& other); + std::unordered_map Merge(const World* other); private: EventBroker* m_EventBroker = nullptr; diff --git a/src/Engine/Core/World.cpp b/src/Engine/Core/World.cpp index 96c4660d..0952a53b 100644 --- a/src/Engine/Core/World.cpp +++ b/src/Engine/Core/World.cpp @@ -169,27 +169,29 @@ EntityWrapper World::GetFirstEntityByName(const std::string& name) return EntityWrapper::Invalid; } -std::unordered_map World::Merge(World& other) +std::unordered_map World::Merge(const World* other) { std::unordered_map oldToNew; // Create new entities - for (auto& kv : other.m_EntityParents) { + for (auto& kv : other->m_EntityParents) { EntityID entity = kv.first; EntityID newEntity = CreateEntity(); - SetName(newEntity, other.GetName(entity)); + SetName(newEntity, other->GetName(entity)); oldToNew[entity] = newEntity; } // Fix relationships - for (auto& kv : other.m_EntityParents) { + for (auto& kv : other->m_EntityParents) { EntityID entity = kv.first; EntityID parent = kv.second; - SetParent(oldToNew.at(entity), oldToNew.at(parent)); + if (parent != EntityID_Invalid) { + SetParent(oldToNew.at(entity), oldToNew.at(parent)); + } } // Transfer components - for (auto& kv : other.m_ComponentPools) { + for (auto& kv : other->m_ComponentPools) { auto& componentType = kv.first; ComponentPool* pool = kv.second; // Register pool if it's not present in world From 069583e09f29d695240f8f1423aeb48925f788eb Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 2 Mar 2016 19:52:11 +0100 Subject: [PATCH 156/252] Created EntityFile which loads an EntityXMLFile into a temporary world to be merged with another world when you want to create a copy of the entity loaded from disk. This allows us to free EntityXMLFile once it's loaded into an EntityFile. --- include/Engine/Core/EntityFile.h | 21 +++++++++++++++++++++ src/Engine/Core/EntityFile.cpp | 22 ++++++++++++++++++++++ src/Game/Game.cpp | 4 +++- 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 include/Engine/Core/EntityFile.h create mode 100644 src/Engine/Core/EntityFile.cpp diff --git a/include/Engine/Core/EntityFile.h b/include/Engine/Core/EntityFile.h new file mode 100644 index 00000000..fae39c51 --- /dev/null +++ b/include/Engine/Core/EntityFile.h @@ -0,0 +1,21 @@ +#ifndef EntityFile_h__ +#define EntityFile_h__ + +#include "World.h" +#include "EntityXMLFile.h" +#include "EntityXMLFilePreprocessor.h" +#include "EntityXMLFileParser.h" +#include "EntityWrapper.h" + +class EntityFile : private World, public Resource +{ +public: + EntityFile(std::string path); + + EntityWrapper MergeInto(World* other); + +private: + EntityID m_RootEntity = EntityID_Invalid; +}; + +#endif \ No newline at end of file diff --git a/src/Engine/Core/EntityFile.cpp b/src/Engine/Core/EntityFile.cpp new file mode 100644 index 00000000..090bbbd8 --- /dev/null +++ b/src/Engine/Core/EntityFile.cpp @@ -0,0 +1,22 @@ +#include "Core/EntityFile.h" + +EntityFile::EntityFile(std::string path) +{ + EntityXMLFile* xml = ResourceManager::Load(path); + + EntityXMLFilePreprocessor preprocessor(xml); + preprocessor.RegisterComponents(this); + + EntityXMLFileParser parser(xml); + m_RootEntity = parser.MergeEntities(this); + + if (m_RootEntity == EntityID_Invalid) { + throw Resource::FailedLoadingException("Failed to merge entities; root entity is invalid"); + } +} + +EntityWrapper EntityFile::MergeInto(World* other) +{ + auto mapping = other->Merge(this); + return EntityWrapper(other, mapping.at(m_RootEntity)); +} \ No newline at end of file diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 9c9228b9..1a672f25 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -11,6 +11,7 @@ #include "Systems/PlayerSpawnSystem.h" #include "Systems/PlayerDeathSystem.h" #include "Systems/FloatingEffectSystem.h" +#include "Core/EntityFile.h" #include "Core/EntityXMLFileWriter.h" #include "Game/Systems/CapturePointSystem.h" #include "Game/Systems/CapturePointHUDSystem.h" @@ -44,7 +45,8 @@ Game::Game(int argc, char* argv[]) ResourceManager::RegisterType("Texture"); ResourceManager::RegisterType("Png"); ResourceManager::RegisterType("ShaderProgram"); - ResourceManager::RegisterType("EntityFile"); + ResourceManager::RegisterType("EntityFile"); + ResourceManager::RegisterType("EntityXMLFile"); ResourceManager::RegisterType("FontFile"); m_Config = ResourceManager::Load("Config.ini"); From 5923d2d7a72512137ae789755fc15fcd41334e8b Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 2 Mar 2016 19:52:34 +0100 Subject: [PATCH 157/252] Made SpawnerSystem utilize the new EntityFile for spawning instead --- include/Game/Systems/SpawnerSystem.h | 3 +-- src/Game/Systems/SpawnerSystem.cpp | 14 ++++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/Game/Systems/SpawnerSystem.h b/include/Game/Systems/SpawnerSystem.h index 10817ef0..f36f7259 100644 --- a/include/Game/Systems/SpawnerSystem.h +++ b/include/Game/Systems/SpawnerSystem.h @@ -7,8 +7,7 @@ #include "Core/System.h" #include "Events/ESpawnerSpawn.h" #include "Core/Transform.h" -#include "Core/ResourceManager.h" -#include "Core/EntityXMLFileParser.h" +#include "Core/EntityFile.h" class SpawnerSystem : public System { diff --git a/src/Game/Systems/SpawnerSystem.cpp b/src/Game/Systems/SpawnerSystem.cpp index b16f7dfe..282c958b 100644 --- a/src/Game/Systems/SpawnerSystem.cpp +++ b/src/Game/Systems/SpawnerSystem.cpp @@ -17,15 +17,17 @@ EntityWrapper SpawnerSystem::Spawn(EntityWrapper spawner, EntityWrapper parent / // Load the entity file and parse it const std::string& entityFilePath = spawner["Spawner"]["EntityFile"]; - auto entityFile = ResourceManager::Load(entityFilePath); - if (entityFile == nullptr) { + EntityWrapper spawnedEntity; + try { + auto entityFile = ResourceManager::Load(entityFilePath); + spawnedEntity = entityFile->MergeInto(world); + world->SetParent(spawnedEntity.ID, parent.ID); + } catch (const Resource::FailedLoadingException& e) { return EntityWrapper::Invalid; } - EntityXMLFileParser parser(entityFile); - EntityWrapper spawnedEntity(world, parser.MergeEntities(world, parent.ID)); - //If the spawned entity is collideable, then we must not spawn it where it collides with something that - //has a dontCollideComponent attached. + // If the spawned entity is collidable, then we must not spawn it where it collides with something that + // has a dontCollideComponent attached. bool spawnOnCollidable = dontCollideComponent.empty() || !spawnedEntity.HasComponent("Collidable"); if (!spawnOnCollidable) { boost::optional optBox = Collision::EntityAbsoluteAABB(spawnedEntity); From 3ef15dcb8108da3d9ec5d187bd674b85b6aeb6a1 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 2 Mar 2016 20:01:18 +0100 Subject: [PATCH 158/252] EntityFile now releases EntityXMLFile after processing. --- src/Engine/Core/EntityFile.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Engine/Core/EntityFile.cpp b/src/Engine/Core/EntityFile.cpp index 090bbbd8..997b9c46 100644 --- a/src/Engine/Core/EntityFile.cpp +++ b/src/Engine/Core/EntityFile.cpp @@ -11,8 +11,11 @@ EntityFile::EntityFile(std::string path) m_RootEntity = parser.MergeEntities(this); if (m_RootEntity == EntityID_Invalid) { + ResourceManager::Release("EntityXMLFile", path); throw Resource::FailedLoadingException("Failed to merge entities; root entity is invalid"); } + + ResourceManager::Release("EntityXMLFile", path); } EntityWrapper EntityFile::MergeInto(World* other) From 7624c6ee0a739a81dfcbf65e00bdbc2316f8c264 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 2 Mar 2016 20:12:59 +0100 Subject: [PATCH 159/252] Updated all uses of EntityXMLFile to use the new EntityFile to load entities into a world. --- include/Engine/Core/EntityXMLFileParser.h | 3 ++- include/Engine/Core/EntityXMLFilePreprocessor.h | 3 ++- include/Engine/Editor/EditorSystem.h | 3 +-- include/Game/Systems/AmmoPickupSystem.h | 2 +- include/Game/Systems/BoostSystem.h | 2 +- include/Game/Systems/DamageIndicatorSystem.h | 2 +- include/Game/Systems/PickupSpawnSystem.h | 2 +- include/Game/Systems/PlayerDeathSystem.h | 5 +---- include/Game/Systems/PlayerMovementSystem.h | 4 +--- src/Engine/Editor/EditorSystem.cpp | 11 +++++------ src/Game/Game.cpp | 7 ++----- src/Game/Systems/AmmoPickupSystem.cpp | 9 ++++----- src/Game/Systems/BoostSystem.cpp | 9 ++++----- src/Game/Systems/DamageIndicatorSystem.cpp | 12 +++++------- src/Game/Systems/PickupSpawnSystem.cpp | 9 ++++----- src/Game/Systems/PlayerDeathSystem.cpp | 6 ++---- src/Game/Systems/PlayerMovementSystem.cpp | 12 ++++-------- 17 files changed, 41 insertions(+), 60 deletions(-) diff --git a/include/Engine/Core/EntityXMLFileParser.h b/include/Engine/Core/EntityXMLFileParser.h index 984f9e46..4bc2fab9 100644 --- a/include/Engine/Core/EntityXMLFileParser.h +++ b/include/Engine/Core/EntityXMLFileParser.h @@ -6,12 +6,13 @@ class EntityXMLFileParser { + friend class EntityFile; public: EntityXMLFileParser(const EntityXMLFile* entityFile); +private: EntityID MergeEntities(World* world, EntityID baseParent = EntityID_Invalid); -private: const EntityXMLFile* m_EntityFile; EntityFileHandler m_Handler; World* m_World = nullptr; diff --git a/include/Engine/Core/EntityXMLFilePreprocessor.h b/include/Engine/Core/EntityXMLFilePreprocessor.h index e102ef79..4f969291 100644 --- a/include/Engine/Core/EntityXMLFilePreprocessor.h +++ b/include/Engine/Core/EntityXMLFilePreprocessor.h @@ -21,12 +21,13 @@ class EntityXMLFilePreprocessor { + friend class EntityFile; public: EntityXMLFilePreprocessor(const EntityXMLFile* entityFile); +private: void RegisterComponents(World* world); -private: const EntityXMLFile* m_EntityFile; std::map m_ComponentCounts; std::map m_ComponentInfo; diff --git a/include/Engine/Editor/EditorSystem.h b/include/Engine/Editor/EditorSystem.h index b565367a..655ac9b9 100644 --- a/include/Engine/Editor/EditorSystem.h +++ b/include/Engine/Editor/EditorSystem.h @@ -5,8 +5,7 @@ #include "../Core/World.h" #include "../Core/SystemPipeline.h" #include "../Core/ResourceManager.h" -#include "../Core/EntityXMLFilePreprocessor.h" -#include "../Core/EntityXMLFileParser.h" +#include "../Core/EntityFile.h" #include "../Core/EntityXMLFileWriter.h" #include "../Core/EMousePress.h" #include "../Input/EInputCommand.h" diff --git a/include/Game/Systems/AmmoPickupSystem.h b/include/Game/Systems/AmmoPickupSystem.h index 8e5c4f1d..70c5630f 100644 --- a/include/Game/Systems/AmmoPickupSystem.h +++ b/include/Game/Systems/AmmoPickupSystem.h @@ -4,7 +4,7 @@ #include "Core/System.h" #include "Core/Transform.h" #include "Core/ResourceManager.h" -#include "Core/EntityXMLFileParser.h" +#include "Core/EntityFile.h" #include "Core/EPickupSpawned.h" #include "Core/EAmmoPickup.h" #include "Engine/Collision/ETrigger.h" diff --git a/include/Game/Systems/BoostSystem.h b/include/Game/Systems/BoostSystem.h index 525918a4..f02e9472 100644 --- a/include/Game/Systems/BoostSystem.h +++ b/include/Game/Systems/BoostSystem.h @@ -3,7 +3,7 @@ #include "Core/System.h" #include "Core/ResourceManager.h" -#include "Core/EntityXMLFileParser.h" +#include "Core/EntityFile.h" #include "Core/EPlayerDamage.h" #include "Common.h" diff --git a/include/Game/Systems/DamageIndicatorSystem.h b/include/Game/Systems/DamageIndicatorSystem.h index 935089fa..9c88ba78 100644 --- a/include/Game/Systems/DamageIndicatorSystem.h +++ b/include/Game/Systems/DamageIndicatorSystem.h @@ -4,7 +4,7 @@ #include "Core/System.h" #include "Core/Transform.h" #include "Core/ResourceManager.h" -#include "Core/EntityXMLFileParser.h" +#include "Core/EntityFile.h" #include "Core/EPlayerDamage.h" #include "Common.h" #include diff --git a/include/Game/Systems/PickupSpawnSystem.h b/include/Game/Systems/PickupSpawnSystem.h index 1151b487..b72b8b25 100644 --- a/include/Game/Systems/PickupSpawnSystem.h +++ b/include/Game/Systems/PickupSpawnSystem.h @@ -4,7 +4,7 @@ #include "Core/System.h" #include "Core/Transform.h" #include "Core/ResourceManager.h" -#include "Core/EntityXMLFileParser.h" +#include "Core/EntityFile.h" #include "Core/EPickupSpawned.h" #include "Core/EPlayerHealthPickup.h" #include "Engine/Collision/ETrigger.h" diff --git a/include/Game/Systems/PlayerDeathSystem.h b/include/Game/Systems/PlayerDeathSystem.h index 96ed2ab5..e4f96114 100644 --- a/include/Game/Systems/PlayerDeathSystem.h +++ b/include/Game/Systems/PlayerDeathSystem.h @@ -6,10 +6,7 @@ #include "GLM.h" #include "Rendering/ESetCamera.h" #include "Core/ConfigFile.h" - -#include "Core/EntityXMLFile.h" -#include "Core/EntityXMLFileParser.h" - +#include "Core/EntityFile.h" #include "Core/EPlayerDeath.h" #include "Core/EEntityDeleted.h" diff --git a/include/Game/Systems/PlayerMovementSystem.h b/include/Game/Systems/PlayerMovementSystem.h index 8b6e4e54..bf7b4718 100644 --- a/include/Game/Systems/PlayerMovementSystem.h +++ b/include/Game/Systems/PlayerMovementSystem.h @@ -6,9 +6,7 @@ #include #include "Events/EDoubleJump.h" #include "../Engine/Sound/EPlaySoundOnEntity.h" - -#include "Core/EntityXMLFile.h" -#include "Core/EntityXMLFileParser.h" +#include "Core/EntityFile.h" class PlayerMovementSystem : public ImpureSystem { diff --git a/src/Engine/Editor/EditorSystem.cpp b/src/Engine/Editor/EditorSystem.cpp index 3e664161..62ddba88 100644 --- a/src/Engine/Editor/EditorSystem.cpp +++ b/src/Engine/Editor/EditorSystem.cpp @@ -2,6 +2,7 @@ #include "Core/UniformScaleSystem.h" #include "Editor/EditorRenderSystem.h" #include "Editor/EditorWidgetSystem.h" +#include "Core/EntityFile.h" EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame* renderFrame) : System(params) @@ -259,12 +260,10 @@ EntityWrapper EditorSystem::importEntity(EntityWrapper parent, boost::filesystem } try { - auto entityFile = ResourceManager::Load(filePath.string()); - EntityXMLFilePreprocessor fpp(entityFile); - fpp.RegisterComponents(parent.World); - EntityXMLFileParser fp(entityFile); - EntityID newEntity = fp.MergeEntities(parent.World, parent.ID); - return EntityWrapper(parent.World, newEntity); + auto entityFile = ResourceManager::Load(filePath.string()); + EntityWrapper newEntity = entityFile->MergeInto(parent.World); + parent.World->SetParent(newEntity.ID, parent.ID); + return newEntity; } catch (const std::exception& e) { LOG_ERROR("Failed to import entity \"%s\": \"%s\"", filePath.string().c_str(), e.what()); return EntityWrapper::Invalid; diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 1a672f25..5e82dc2e 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -82,11 +82,8 @@ Game::Game(int argc, char* argv[]) m_World = new World(m_EventBroker); std::string mapToLoad = m_Config->Get("Debug.LoadMap", ""); if (!mapToLoad.empty()) { - auto file = ResourceManager::Load(mapToLoad); - EntityXMLFilePreprocessor fpp(file); - fpp.RegisterComponents(m_World); - EntityXMLFileParser fp(file); - fp.MergeEntities(m_World); + auto file = ResourceManager::Load(mapToLoad); + file->MergeInto(m_World); } // Create the sound manager diff --git a/src/Game/Systems/AmmoPickupSystem.cpp b/src/Game/Systems/AmmoPickupSystem.cpp index e3051efe..062efe94 100644 --- a/src/Game/Systems/AmmoPickupSystem.cpp +++ b/src/Game/Systems/AmmoPickupSystem.cpp @@ -20,17 +20,16 @@ void AmmoPickupSystem::Update(double dt) auto& somePickup = *it; somePickup.DecreaseThisRespawnTimer -= dt; if (somePickup.DecreaseThisRespawnTimer < 0.0) { - auto entityFile = ResourceManager::Load("Schema/Entities/AmmoPickup.xml"); - EntityXMLFileParser parser(entityFile); - EntityID ammoPickupID = parser.MergeEntities(m_World); + auto entityFile = ResourceManager::Load("Schema/Entities/AmmoPickup.xml"); + EntityWrapper ammoPickup = entityFile->MergeInto(m_World); //let the world know a pickup has spawned Events::PickupSpawned ePickupSpawned; - ePickupSpawned.Pickup = EntityWrapper(m_World, ammoPickupID); + ePickupSpawned.Pickup = ammoPickup; m_EventBroker->Publish(ePickupSpawned); //copy values from the old entity to the new entity - auto& newAmmoPickupEntity = EntityWrapper(m_World, ammoPickupID); + auto& newAmmoPickupEntity = ammoPickup; newAmmoPickupEntity["Transform"]["Position"] = somePickup.Pos; newAmmoPickupEntity["AmmoPickup"]["AmmoGain"] = somePickup.AmmoGain; newAmmoPickupEntity["AmmoPickup"]["RespawnTimer"] = somePickup.RespawnTimer; diff --git a/src/Game/Systems/BoostSystem.cpp b/src/Game/Systems/BoostSystem.cpp index 7f335d1f..c79576e4 100644 --- a/src/Game/Systems/BoostSystem.cpp +++ b/src/Game/Systems/BoostSystem.cpp @@ -38,11 +38,10 @@ bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e) m_World->DeleteEntity(playerBoostAssaultEntity.ID); } //load boost XML file, set it entity parented with the victim player - auto entityFile = ResourceManager::Load(classXML); - EntityXMLFileParser parser(entityFile); - EntityID boostAssaultEntity = parser.MergeEntities(m_World); - m_World->SetName(boostAssaultEntity, className); - m_World->SetParent(boostAssaultEntity, e.Victim.ID); + auto entityFile = ResourceManager::Load(classXML); + EntityWrapper boostAssaultEntity = entityFile->MergeInto(m_World); + m_World->SetName(boostAssaultEntity.ID, className); + m_World->SetParent(boostAssaultEntity.ID, e.Victim.ID); return true; } diff --git a/src/Game/Systems/DamageIndicatorSystem.cpp b/src/Game/Systems/DamageIndicatorSystem.cpp index 55a1046c..e68f741d 100644 --- a/src/Game/Systems/DamageIndicatorSystem.cpp +++ b/src/Game/Systems/DamageIndicatorSystem.cpp @@ -49,16 +49,14 @@ bool DamageIndicatorSystem::OnPlayerDamage(Events::PlayerDamage& e) float angleBetweenVectors = CalculateAngle(e.Victim, inflictorPos); //load & set the "2d" sprite - auto entityFile = ResourceManager::Load("Schema/Entities/DamageIndicator.xml"); - EntityXMLFileParser parser(entityFile); - EntityID spriteID = parser.MergeEntities(m_World); - m_World->SetParent(spriteID, m_CurrentCamera); - auto spriteWrapper = EntityWrapper(m_World, spriteID); + auto entityFile = ResourceManager::Load("Schema/Entities/DamageIndicator.xml"); + EntityWrapper sprite = entityFile->MergeInto(m_World); + m_World->SetParent(sprite.ID, m_CurrentCamera); //simply set the rotation z-wise to the angleBetweenVectors - spriteWrapper["Transform"]["Orientation"] = glm::vec3(0, 0, angleBetweenVectors); + sprite["Transform"]["Orientation"] = glm::vec3(0, 0, angleBetweenVectors); if (!IsServer) { - updateDamageIndicatorVector.emplace_back(spriteWrapper, inflictorPos); + updateDamageIndicatorVector.emplace_back(sprite, inflictorPos); } return true; diff --git a/src/Game/Systems/PickupSpawnSystem.cpp b/src/Game/Systems/PickupSpawnSystem.cpp index 9d1ce5b6..99da931f 100644 --- a/src/Game/Systems/PickupSpawnSystem.cpp +++ b/src/Game/Systems/PickupSpawnSystem.cpp @@ -18,17 +18,16 @@ void PickupSpawnSystem::Update(double dt) somePickup.DecreaseThisRespawnTimer -= dt; if (somePickup.DecreaseThisRespawnTimer < 0.0) { //spawn the new healthPickup - auto entityFile = ResourceManager::Load("Schema/Entities/HealthPickup.xml"); - EntityXMLFileParser parser(entityFile); - EntityID healthPickupID = parser.MergeEntities(m_World); + auto entityFile = ResourceManager::Load("Schema/Entities/HealthPickup.xml"); + EntityWrapper healthPickup = entityFile->MergeInto(m_World); //let the world know a pickup has spawned (graphics effects, etc) Events::PickupSpawned ePickupSpawned; - ePickupSpawned.Pickup = EntityWrapper(m_World, healthPickupID); + ePickupSpawned.Pickup = healthPickup; m_EventBroker->Publish(ePickupSpawned); //copy values from the old entity to the new entity - auto& newHealthPickupEntity = EntityWrapper(m_World, healthPickupID); + auto& newHealthPickupEntity = healthPickup; newHealthPickupEntity["Transform"]["Position"] = somePickup.Pos; newHealthPickupEntity["HealthPickup"]["HealthGain"] = somePickup.HealthGain; newHealthPickupEntity["HealthPickup"]["RespawnTimer"] = somePickup.RespawnTimer; diff --git a/src/Game/Systems/PlayerDeathSystem.cpp b/src/Game/Systems/PlayerDeathSystem.cpp index 1a491580..cbf0927f 100644 --- a/src/Game/Systems/PlayerDeathSystem.cpp +++ b/src/Game/Systems/PlayerDeathSystem.cpp @@ -28,10 +28,8 @@ bool PlayerDeathSystem::OnPlayerDeath(Events::PlayerDeath& e) void PlayerDeathSystem::createDeathEffect(EntityWrapper player) { //load the explosioneffect XML - auto deathEffect = ResourceManager::Load("Schema/Entities/PlayerDeathExplosionWithCamera.xml"); - EntityXMLFileParser parser(deathEffect); - EntityID deathEffectID = parser.MergeEntities(m_World); - EntityWrapper deathEffectEW = EntityWrapper(m_World, deathEffectID); + auto entityFile = ResourceManager::Load("Schema/Entities/PlayerDeathExplosionWithCamera.xml"); + EntityWrapper deathEffectEW = entityFile->MergeInto(m_World); //components that we need from player auto playerModel = player.FirstChildByName("PlayerModel"); diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 5a687b84..802b5048 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -328,10 +328,8 @@ bool PlayerMovementSystem::OnDoubleJump(Events::DoubleJump & e) void PlayerMovementSystem::spawnHexagon(EntityWrapper target) { //put a hexagon at the entitys... feet? - auto hexagonEffect = ResourceManager::Load("Schema/Entities/DoubleJumpHexagon.xml"); - EntityXMLFileParser parser(hexagonEffect); - EntityID hexagonEffectID = parser.MergeEntities(m_World); - EntityWrapper hexagonEW = EntityWrapper(m_World, hexagonEffectID); + auto entityFile = ResourceManager::Load("Schema/Entities/DoubleJumpHexagon.xml"); + EntityWrapper hexagonEW = entityFile->MergeInto(m_World); hexagonEW["Transform"]["Position"] = (glm::vec3)target["Transform"]["Position"]; } @@ -342,10 +340,8 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) return false; } - auto dashEffectResource = ResourceManager::Load("Schema/Entities/DashEffect.xml"); - EntityXMLFileParser parser(dashEffectResource); - EntityID dashEffectID = parser.MergeEntities(m_World); - EntityWrapper dashEffect(m_World, dashEffectID); + auto entityFile = ResourceManager::Load("Schema/Entities/DashEffect.xml"); + EntityWrapper dashEffect = entityFile->MergeInto(m_World); auto playerModel = player.FirstChildByName("PlayerModel"); auto playerEntityModel = playerModel["Model"]; auto playerEntityAnimation = playerModel["Animation"]; From 9a668ed7d7f298bfed7fa21114199ef88f3e0da5 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Wed, 2 Mar 2016 20:16:03 +0100 Subject: [PATCH 160/252] Now here's the real fix for the lag when loading entity files: CONSOLE SPAM --- include/Engine/Core/MemoryPool.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/Engine/Core/MemoryPool.h b/include/Engine/Core/MemoryPool.h index 053e75aa..da4af84e 100644 --- a/include/Engine/Core/MemoryPool.h +++ b/include/Engine/Core/MemoryPool.h @@ -118,9 +118,6 @@ public: else { m_ExtraMemory.push_back((char*)malloc(m_Stride)); //We should preferably not enter here to avoid performance issues. Set more numMaxElements in constructor instead. - if (!DisableMemoryPool::Value) { - LOG_DEBUG("Allocated slots exceed Pool size, extra memory allocated dynamically. Pool size: %u, dynamic size: %u.", m_NumSlots, m_ExtraMemory.size()); - } return m_ExtraMemory.back(); } } From 8b81ba9019b566ccca5315a5c6cea3b14f7cb15d Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 2 Mar 2016 21:40:20 +0100 Subject: [PATCH 161/252] Some small fixes, also added new UI elements to Player --- resources/Schema/Components/Text.xml | 2 +- resources/Schema/Entities/Player.xml | 93 ++++++++++++++++++++++++++-- 2 files changed, 89 insertions(+), 6 deletions(-) diff --git a/resources/Schema/Components/Text.xml b/resources/Schema/Components/Text.xml index d38d3961..cda29b86 100644 --- a/resources/Schema/Components/Text.xml +++ b/resources/Schema/Components/Text.xml @@ -1,7 +1,7 @@ - + Fonts/DroidSans.ttf,64 true
diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 28ace561..9fb563f8 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -132,7 +132,70 @@ - + + + + + + + + + + + + + + Textures/Core/White.png + false + + + + + + + + + + + + + + + + + Textures/Core/White.png + false + + + + + + + + + + + + + + + + + Textures/Core/White.png + false + + + + + + + + + + + + + @@ -196,7 +259,6 @@ 3 - 0.80222018197612788 @@ -231,6 +293,7 @@ 4 + 1 @@ -286,7 +349,7 @@ Textures/Core/UnitHexagon.png - + @@ -297,7 +360,8 @@ - + 1 + Textures/Core/UnitHexagon_Rotated.png @@ -306,7 +370,7 @@ - + @@ -369,6 +433,25 @@ + + + + + Models/Widgets/Arrows/Arrow9.mesh + + + + + + + + + + + + + + From 2d438060ddc5e396aa96b9c94e8ab60839c51911 Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 2 Mar 2016 22:08:23 +0100 Subject: [PATCH 162/252] Player arrow change --- resources/Schema/Entities/Player.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 9fb563f8..34692605 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -100,12 +100,12 @@ 1 - 100/100 Fonts/DroidSans.ttf,64 + @@ -437,7 +437,7 @@ - Models/Widgets/Arrows/Arrow9.mesh + Models/Widgets/Arrows/Arrow5.mesh @@ -447,7 +447,7 @@ - + From 9c9d1eede614ef8e7d3c6d25ad00499297e2acd4 Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 2 Mar 2016 22:34:03 +0100 Subject: [PATCH 163/252] Components for ScoreScreen Added --- resources/Schema/Components.xsd | 1 + resources/Schema/Components/ScoreScreen.xml | 3 +++ resources/Schema/Components/ScoreScreen.xsd | 10 ++++++++++ resources/Schema/Types/Entity.xsd | 1 + 4 files changed, 15 insertions(+) create mode 100644 resources/Schema/Components/ScoreScreen.xml create mode 100644 resources/Schema/Components/ScoreScreen.xsd diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index fccfd3d0..e559db09 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -57,4 +57,5 @@ + \ No newline at end of file diff --git a/resources/Schema/Components/ScoreScreen.xml b/resources/Schema/Components/ScoreScreen.xml new file mode 100644 index 00000000..646002c4 --- /dev/null +++ b/resources/Schema/Components/ScoreScreen.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/resources/Schema/Components/ScoreScreen.xsd b/resources/Schema/Components/ScoreScreen.xsd new file mode 100644 index 00000000..387140f2 --- /dev/null +++ b/resources/Schema/Components/ScoreScreen.xsd @@ -0,0 +1,10 @@ + + + + + + + The screen where player scores will be shown. + + + \ No newline at end of file diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index d543a7f4..1da5e628 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -60,6 +60,7 @@ + From b431a875f75c741b0ecd5576b1819a2331ae5a85 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Tue, 1 Mar 2016 13:26:50 +0100 Subject: [PATCH 164/252] New weapon behaviours --- .../Systems/Weapon/DefenderWeaponBehaviour.h | 12 +-- .../Systems/Weapon/SidearmWeaponBehaviour.h | 32 ++++++++ include/Game/Systems/Weapon/WeaponBehaviour.h | 74 ++++++++++++------- resources/Schema/Components.xsd | 1 + .../Schema/Components/DefenderWeapon.xsd | 12 +++ resources/Schema/Components/SidearmWeapon.xml | 14 ++++ resources/Schema/Components/SidearmWeapon.xsd | 48 ++++++++++++ resources/Schema/Entities/Player.xml | 8 +- resources/Schema/Types/Entity.xsd | 1 + src/Engine/Rendering/Renderer.cpp | 2 +- .../Weapon/DefenderWeaponBehaviour.cpp | 24 +++--- .../Systems/Weapon/SidearmWeaponBehaviour.cpp | 58 +++++++++++++++ 12 files changed, 232 insertions(+), 54 deletions(-) create mode 100644 include/Game/Systems/Weapon/SidearmWeaponBehaviour.h create mode 100644 resources/Schema/Components/SidearmWeapon.xml create mode 100644 resources/Schema/Components/SidearmWeapon.xsd create mode 100644 src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp diff --git a/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h b/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h index 5ca13d3e..986d8586 100644 --- a/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h +++ b/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h @@ -15,10 +15,10 @@ public: } void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cWeapon, double dt) override; - void UpdateWeapon(WeaponInfo& wi, double dt) override; - void OnPrimaryFire(WeaponInfo& wi) override; - void OnCeasePrimaryFire(WeaponInfo& wi) override; - bool OnInputCommand(WeaponInfo& wi, const Events::InputCommand& e) override; + void UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& wi, double dt) override; + void OnPrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) override; + void OnCeasePrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) override; + bool OnInputCommand(ComponentWrapper cWeapon, WeaponInfo& wi, const Events::InputCommand& e) override; private: std::random_device m_RandomDevice; @@ -29,8 +29,8 @@ private: bool OnSetCamera(const Events::SetCamera& e); // Weapon functions - void fireShell(WeaponInfo& wi); - void dealDamage(WeaponInfo& wi, glm::vec3 direction, double damage); + void fireShell(ComponentWrapper cWeapon, WeaponInfo& wi); + void dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi, glm::vec3 direction, double damage); // Utility float traceRayDistance(glm::vec3 origin, glm::vec3 direction); diff --git a/include/Game/Systems/Weapon/SidearmWeaponBehaviour.h b/include/Game/Systems/Weapon/SidearmWeaponBehaviour.h new file mode 100644 index 00000000..787c3c61 --- /dev/null +++ b/include/Game/Systems/Weapon/SidearmWeaponBehaviour.h @@ -0,0 +1,32 @@ +#include "WeaponBehaviour.h" +#include "Collision/Collision.h" +#include "Core/EPlayerDamage.h" + +class SidearmWeaponBehaviour : public WeaponBehaviour +{ +public: + SidearmWeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree* collisionOctree) + : System(systemParams) + , WeaponBehaviour(systemParams, "SidearmWeapon", renderer, collisionOctree) + , m_RandomEngine(m_RandomDevice()) + { } + + void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cWeapon, double dt) override; + void UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& wi, double dt) override; + void OnPrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) override; + void OnCeasePrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) override; + void OnHolster(ComponentWrapper cWeapon, WeaponInfo& wi) override; + +private: + std::random_device m_RandomDevice; + std::mt19937 m_RandomEngine; + EntityWrapper m_CurrentCamera; + + // Weapon functions + void fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi); + //void dealDamage(WeaponInfo& wi, glm::vec3 direction, double damage); + + // Utility + bool canFire(ComponentWrapper cWeapon); + //float traceRayDistance(glm::vec3 origin, glm::vec3 direction); +}; \ No newline at end of file diff --git a/include/Game/Systems/Weapon/WeaponBehaviour.h b/include/Game/Systems/Weapon/WeaponBehaviour.h index f23269df..2ab53e0e 100644 --- a/include/Game/Systems/Weapon/WeaponBehaviour.h +++ b/include/Game/Systems/Weapon/WeaponBehaviour.h @@ -24,36 +24,35 @@ public: } virtual ~WeaponBehaviour() = default; - virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt) override + virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cWeapon, double dt) override { auto weapon = getActiveWeapon(entity); if (!weapon) { return; } else { - UpdateWeapon(*weapon, dt); + UpdateWeapon(cWeapon, *weapon, dt); } } protected: struct WeaponInfo { - std::string WeaponComponent; EntityWrapper Player; EntityWrapper WeaponEntity; EntityWrapper FirstPersonEntity; EntityWrapper ThirdPersonEntity; - ComponentWrapper GetComponent() { return WeaponEntity[WeaponComponent]; } }; IRenderer* m_Renderer; Octree* m_CollisionOctree; std::unordered_map m_ActiveWeapons; - virtual void UpdateWeapon(WeaponInfo& wi, double dt) { } - virtual void OnPrimaryFire(WeaponInfo& wi) { } - virtual void OnCeasePrimaryFire(WeaponInfo& wi) { } - virtual void OnReload(WeaponInfo& wi) { } - virtual bool OnInputCommand(WeaponInfo& wi, const Events::InputCommand& e) { return false; } + virtual void UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& wi, double dt) { } + virtual void OnPrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) { } + virtual void OnCeasePrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) { } + virtual void OnReload(ComponentWrapper cWeapon, WeaponInfo& wi) { } + virtual void OnHolster(ComponentWrapper cWeapon, WeaponInfo& wi) { } + virtual bool OnInputCommand(ComponentWrapper cWeapon, WeaponInfo& wi, const Events::InputCommand& e) { return false; } private: EventRelay m_EInputCommand; @@ -70,15 +69,19 @@ private: } // Make sure the player has this weapon - auto weapon = getWeaponComponent(player); - if (!weapon) { + auto cWeapon = getWeaponComponent(player); + if (!cWeapon) { return false; } // Weapon selection if (e.Command == "SelectWeapon") { - if (static_cast(e.Value) == static_cast((*weapon)["Slot"])) { - selectWeapon(player); + if (e.Value > 0) { + if (static_cast(e.Value) == static_cast((*cWeapon)["Slot"])) { + selectWeapon(player); + } else { + holsterWeapon(*cWeapon, player); + } } } @@ -91,18 +94,18 @@ private: // Fire if (e.Command == "PrimaryFire") { if (e.Value > 0) { - OnPrimaryFire(*activeWeapon); + OnPrimaryFire(*cWeapon, *activeWeapon); } else { - OnCeasePrimaryFire(*activeWeapon); + OnCeasePrimaryFire(*cWeapon, *activeWeapon); } } // Reload if (e.Command == "Reload" && e.Value != 0) { - OnReload(*activeWeapon); + OnReload(*cWeapon, *activeWeapon); } - return OnInputCommand(*activeWeapon, e); + return OnInputCommand(*cWeapon, *activeWeapon, e); } boost::optional getWeaponComponent(EntityWrapper player) @@ -131,6 +134,11 @@ private: void selectWeapon(EntityWrapper player) { + // Don't reselect weapon if it's already active + if (getActiveWeapon(player)) { + return; + } + // Find the weapon attachments matching the weapon type std::vector weaponAttachments = player.ChildrenWithComponent("WeaponAttachment"); EntityWrapper firstPersonAttachment; @@ -152,14 +160,6 @@ private: return; } - // Purge other weapon entities - for (auto& attachment : weaponAttachments) { - //if (attachment == firstPersonAttachment || attachment == thirdPersonAttachment) { - // continue; - //} - attachment.DeleteChildren(); - } - // Spawn the weapon(s) EntityWrapper firstPersonWeapon; EntityWrapper thirdPersonWeapon; @@ -170,12 +170,34 @@ private: thirdPersonWeapon = SpawnerSystem::Spawn(thirdPersonAttachment, thirdPersonAttachment); } - m_ActiveWeapons[player].WeaponComponent = m_ComponentType; m_ActiveWeapons[player].Player = player; m_ActiveWeapons[player].WeaponEntity = player; m_ActiveWeapons[player].FirstPersonEntity = firstPersonWeapon; m_ActiveWeapons[player].ThirdPersonEntity = thirdPersonWeapon; } + + void holsterWeapon(ComponentWrapper cWeapon, EntityWrapper player) + { + auto activeWeapon = getActiveWeapon(player); + if (!activeWeapon) { + return; + } + WeaponInfo& wi = *activeWeapon; + + // Send holster event + OnHolster(cWeapon, wi); + + // Delete weapon entities + if (wi.FirstPersonEntity.Valid()) { + m_World->DeleteEntity(wi.FirstPersonEntity.ID); + } + if (wi.ThirdPersonEntity.Valid()) { + m_World->DeleteEntity(wi.ThirdPersonEntity.ID); + } + + // Make weapon inactive + m_ActiveWeapons.erase(player); + } }; #endif diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index 0c8886f3..711f4999 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -54,6 +54,7 @@ + diff --git a/resources/Schema/Components/DefenderWeapon.xsd b/resources/Schema/Components/DefenderWeapon.xsd index 3fe5a64a..0ec61964 100755 --- a/resources/Schema/Components/DefenderWeapon.xsd +++ b/resources/Schema/Components/DefenderWeapon.xsd @@ -4,6 +4,18 @@ + + + + + + + + + + + + diff --git a/resources/Schema/Components/SidearmWeapon.xml b/resources/Schema/Components/SidearmWeapon.xml new file mode 100644 index 00000000..b63706b6 --- /dev/null +++ b/resources/Schema/Components/SidearmWeapon.xml @@ -0,0 +1,14 @@ + + + 16 + 16 + 20 + 120 + 0.01 + 0.5 + + false + 0 + false + 0 + \ No newline at end of file diff --git a/resources/Schema/Components/SidearmWeapon.xsd b/resources/Schema/Components/SidearmWeapon.xsd new file mode 100644 index 00000000..844b449f --- /dev/null +++ b/resources/Schema/Components/SidearmWeapon.xsd @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + Ammo currently loaded into the magazine + + + Max number of rounds in a magazine + + + Damage dealt if all shotgun pellets hit + + + Rate of fire in rounds per minute + + + View punch in radians for each shell fired + + + Time it takes to load ONE SHELL into the weapon in seconds + + + + + + + + + + diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 34692605..d157c99e 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -6,11 +6,6 @@ - - - - - 52.867678870419283 @@ -488,9 +483,10 @@ AssaultWeapon - Schema/Entities/AssaultWeaponView.xml + Schema/Entities/SidearmWeaponView.xml + SidearmWeapon diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index 57445a15..f9870a51 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -52,6 +52,7 @@ + diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index 3ce985b6..7e11f3b2 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -17,7 +17,7 @@ void Renderer::Initialize() m_TextPass->Initialize(); /* m_ScreenQuad = ResourceManager::Load("Models/Core/ScreenQuad.obj"); - m_UnitQuad = ResourceManager::Load("Models/Core/UnitQuad.obj"); + m_UnitQuad = ResourceManager::Load(sModels/Core/UnitQuad.obj"); m_UnitSphere = ResourceManager::Load("Models/Core/UnitSphere.obj");*/ m_ImGuiRenderPass = new ImGuiRenderPass(this, m_EventBroker); diff --git a/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp b/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp index 028bd10c..0a179b4c 100644 --- a/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp @@ -6,36 +6,32 @@ void DefenderWeaponBehaviour::UpdateComponent(EntityWrapper& entity, ComponentWr WeaponBehaviour::UpdateComponent(entity, cWeapon, dt); } -void DefenderWeaponBehaviour::UpdateWeapon(WeaponInfo& wi, double dt) +void DefenderWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& wi, double dt) { - ComponentWrapper cWeapon = wi.GetComponent(); - bool isFiring = cWeapon["IsFiring"]; bool cooldownPassed = (double)cWeapon["TimeSinceLastFire"] >= (60.0 / (double)cWeapon["RPM"]); bool isNotShielding = wi.Player.ChildrenWithComponent("Shield").size() == 0; if (isFiring && cooldownPassed && isNotShielding) { - fireShell(wi); + fireShell(cWeapon, wi); } } -void DefenderWeaponBehaviour::OnPrimaryFire(WeaponInfo& wi) +void DefenderWeaponBehaviour::OnPrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) { - ComponentWrapper cWeapon = wi.GetComponent(); cWeapon["IsFiring"] = true; bool cooldownPassed = (double)cWeapon["TimeSinceLastFire"] >= (60.0 / (double)cWeapon["RPM"]); bool isNotShielding = wi.Player.ChildrenWithComponent("Shield").size() == 0; if (cooldownPassed && isNotShielding) { - fireShell(wi); + fireShell(cWeapon, wi); } } -void DefenderWeaponBehaviour::OnCeasePrimaryFire(WeaponInfo& wi) +void DefenderWeaponBehaviour::OnCeasePrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) { - ComponentWrapper cWeapon = wi.GetComponent(); cWeapon["IsFiring"] = false; } -bool DefenderWeaponBehaviour::OnInputCommand(WeaponInfo& wi, const Events::InputCommand& e) +bool DefenderWeaponBehaviour::OnInputCommand(ComponentWrapper cWeapon, WeaponInfo& wi, const Events::InputCommand& e) { if (e.Command == "SpecialAbility" && IsServer) { EntityWrapper attachment = wi.Player.FirstChildByName("ShieldAttachment"); @@ -57,10 +53,8 @@ bool DefenderWeaponBehaviour::OnSetCamera(const Events::SetCamera& e) return true; } -void DefenderWeaponBehaviour::fireShell(WeaponInfo& wi) +void DefenderWeaponBehaviour::fireShell(ComponentWrapper cWeapon, WeaponInfo& wi) { - ComponentWrapper cWeapon = wi.GetComponent(); - cWeapon["TimeSinceLastFire"] = 0.0; int numPellets = cWeapon["NumPellets"]; float spreadAngle = cWeapon["SpreadAngle"]; @@ -95,13 +89,13 @@ void DefenderWeaponBehaviour::fireShell(WeaponInfo& wi) orientation.x += angles.x; orientation.y += angles.y; glm::vec3 trajectory = direction * distance; - dealDamage(wi, direction, pelletDamage); + dealDamage(cWeapon, wi, direction, pelletDamage); } } } -void DefenderWeaponBehaviour::dealDamage(WeaponInfo& wi, glm::vec3 direction, double damage) +void DefenderWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi, glm::vec3 direction, double damage) { // Only deal damage client side if (!IsClient) { diff --git a/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp b/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp new file mode 100644 index 00000000..8c3906af --- /dev/null +++ b/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp @@ -0,0 +1,58 @@ +#include "Systems/Weapon/SidearmWeaponBehaviour.h" + +void SidearmWeaponBehaviour::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cWeapon, double dt) +{ + double& cooldown = cWeapon["FireCooldown"]; + if (cooldown > 0) { + cooldown -= dt; + if (cooldown < 0) { + cooldown = 0; + } + } + WeaponBehaviour::UpdateComponent(entity, cWeapon, dt); +} + +void SidearmWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& wi, double dt) +{ + if (canFire(cWeapon)) { + fireBullet(cWeapon, wi); + } +} + +void SidearmWeaponBehaviour::OnPrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) +{ + cWeapon["TriggerHeld"] = true; + if (canFire(cWeapon)) { + fireBullet(cWeapon, wi); + } +} + +void SidearmWeaponBehaviour::OnCeasePrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) +{ + cWeapon["TriggerHeld"] = false; +} + +void SidearmWeaponBehaviour::OnHolster(ComponentWrapper cWeapon, WeaponInfo& wi) +{ + // Make sure the trigger is released if weapon is holstered while firing + cWeapon["TriggerHeld"] = false; + + // Cancel any reload + cWeapon["IsReloading"] = false; + cWeapon["ReloadTimer"] = 0.0; + + LOG_DEBUG("HOLSTER"); +} + +void SidearmWeaponBehaviour::fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi) +{ + +} + +bool SidearmWeaponBehaviour::canFire(ComponentWrapper cWeapon) +{ + bool triggerHeld = cWeapon["TriggerHeld"]; + double& cooldown = cWeapon["FireCooldown"]; + // TODO: Ammo checks + return triggerHeld && cooldown <= 0.0; +} \ No newline at end of file From 6f8023b285d260f68efd9ac615b702721e8ae0b4 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Tue, 1 Mar 2016 16:35:30 +0100 Subject: [PATCH 165/252] HACK: Added Activate button for spawners in editor. Right now it includes the event from Game, but SpawnerSystem should probably be moved to Engine. --- include/Engine/Editor/EditorGUI.h | 1 + src/Engine/Editor/EditorGUI.cpp | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/include/Engine/Editor/EditorGUI.h b/include/Engine/Editor/EditorGUI.h index 57574e66..807bfc8b 100644 --- a/include/Engine/Editor/EditorGUI.h +++ b/include/Engine/Editor/EditorGUI.h @@ -22,6 +22,7 @@ #include "../Core/ELockMouse.h" #include "../Core/EFileDropped.h" #include "../Rendering/Texture.h" +#include "Game/Events/ESpawnerSpawn.h" class EditorGUI { diff --git a/src/Engine/Editor/EditorGUI.cpp b/src/Engine/Editor/EditorGUI.cpp index 8ce15d0a..a1ceafd0 100644 --- a/src/Engine/Editor/EditorGUI.cpp +++ b/src/Engine/Editor/EditorGUI.cpp @@ -338,6 +338,15 @@ bool EditorGUI::drawComponentNode(EntityWrapper entity, const ComponentInfo& ci) } } + if (ci.Name == "Spawner") { + if (ImGui::Button("Activate")) { + Events::SpawnerSpawn e; + e.Spawner = entity; + e.Parent = entity; + m_EventBroker->Publish(e); + } + } + return true; } From afd0e69a8a9a0c2050429277b77ab85308731f21 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Tue, 1 Mar 2016 16:35:54 +0100 Subject: [PATCH 166/252] Updated Player.xml for multiple weapons --- .../Schema/Entities/DefenderWeaponView.xml | 8 ++--- resources/Schema/Entities/Player.xml | 30 ++++++++++++++----- .../Schema/Entities/SidearmWeaponView.xml | 27 +++++++++++++++++ .../Schema/Entities/SidearmWeaponWorld.xml | 27 +++++++++++++++++ src/Game/Game.cpp | 2 ++ 5 files changed, 81 insertions(+), 13 deletions(-) create mode 100644 resources/Schema/Entities/SidearmWeaponView.xml create mode 100644 resources/Schema/Entities/SidearmWeaponWorld.xml diff --git a/resources/Schema/Entities/DefenderWeaponView.xml b/resources/Schema/Entities/DefenderWeaponView.xml index f6b6e89d..b65194f9 100755 --- a/resources/Schema/Entities/DefenderWeaponView.xml +++ b/resources/Schema/Entities/DefenderWeaponView.xml @@ -1,16 +1,12 @@ - + - - R_Arm_Weapon_Joint - - Models/Weapons/Blue/DefenderGunBlue.mesh - + diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index d157c99e..394f4622 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -11,6 +11,7 @@ 52.867678870419283 + @@ -453,7 +454,7 @@ Idle - 1.9408570429715581 + 0.022133545026491674 1 @@ -467,26 +468,38 @@ + + R_Arm_Weapon_Joint + DefenderWeapon Schema/Entities/DefenderWeaponView.xml - + + + + + + R_Arm_Weapon_Joint + AssaultWeapon + SidearmWeapon Schema/Entities/SidearmWeaponView.xml - - SidearmWeapon + + + + @@ -515,7 +528,7 @@ Idle - 1.5631122524686134 + 0.13373697879978863 1 @@ -550,14 +563,17 @@ + + R_Arm_Weapon_Joint + - AssaultWeapon + SidearmWeapon - Schema/Entities/AssaultWeaponWorld.xml + Schema/Entities/SidearmWeaponWorld.xml diff --git a/resources/Schema/Entities/SidearmWeaponView.xml b/resources/Schema/Entities/SidearmWeaponView.xml new file mode 100644 index 00000000..68d29676 --- /dev/null +++ b/resources/Schema/Entities/SidearmWeaponView.xml @@ -0,0 +1,27 @@ + + + + + + Models/Weapons/SecondaryWeapon.mesh + + + + + + + + + + + Schema/Entities/RayBlue.xml + + + + + + + + + + diff --git a/resources/Schema/Entities/SidearmWeaponWorld.xml b/resources/Schema/Entities/SidearmWeaponWorld.xml new file mode 100644 index 00000000..21cb26a7 --- /dev/null +++ b/resources/Schema/Entities/SidearmWeaponWorld.xml @@ -0,0 +1,27 @@ + + + + + + Models/Weapons/SecondaryWeapon.mesh + + + + + + + + + + + Schema/Entities/RayBlue.xml + + + + + + + + + + diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 21f5c901..7607efec 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -19,6 +19,7 @@ #include "Game/Systems/AmmoPickupSystem.h" #include "Game/Systems/DamageIndicatorSystem.h" #include "Game/Systems/Weapon/DefenderWeaponBehaviour.h" +#include "Game/Systems/Weapon/SidearmWeaponBehaviour.h" #include "Rendering/AnimationSystem.h" #include "Game/Systems/HealthHUDSystem.h" #include "Rendering/BoneAttachmentSystem.h" @@ -128,6 +129,7 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer, m_OctreeCollision); + m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer, m_OctreeCollision); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); From 050ce57e24a09aa8e87b4a40604d08d9b0f7e4f0 Mon Sep 17 00:00:00 2001 From: Tleety Date: Thu, 3 Mar 2016 00:32:07 +0100 Subject: [PATCH 167/252] Fixed AbilityUI for player and changed so the AbilityCooldown system wont need a child with text, instead just write if it has one. --- resources/Schema/Entities/Player.xml | 105 ++++++++++++------ src/Game/Systems/AbilityCooldownHUDSystem.cpp | 14 ++- 2 files changed, 79 insertions(+), 40 deletions(-) diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 34692605..c93989d8 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -12,6 +12,9 @@ + + 3 + 52.867678870419283 @@ -70,8 +73,8 @@ Textures/Weapons/Crosshair/SmallThickHoleDot.png - false + false @@ -94,42 +97,22 @@ - - - - 1 - - - - 100/100 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - 1 + Textures/HealthHUD3.png - - + @@ -146,8 +129,8 @@ Textures/Core/White.png - false + false @@ -164,8 +147,8 @@ Textures/Core/White.png - false + false @@ -182,8 +165,8 @@ Textures/Core/White.png - false + false @@ -195,8 +178,62 @@ + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + 0.0 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + 1 + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + @@ -233,8 +270,8 @@ - + @@ -267,8 +304,8 @@ - + @@ -302,8 +339,8 @@ - + @@ -336,8 +373,8 @@ - + @@ -369,8 +406,8 @@ - + @@ -446,8 +483,8 @@ + - @@ -605,8 +642,8 @@ - + @@ -615,8 +652,8 @@ Textures/Icons/Arrow.png - false + false diff --git a/src/Game/Systems/AbilityCooldownHUDSystem.cpp b/src/Game/Systems/AbilityCooldownHUDSystem.cpp index 44180a62..7226019f 100644 --- a/src/Game/Systems/AbilityCooldownHUDSystem.cpp +++ b/src/Game/Systems/AbilityCooldownHUDSystem.cpp @@ -14,17 +14,19 @@ void AbilityCooldownHUDSystem::Update(double dt) if (!abilityEntity.Valid()) return; EntityWrapper cooldownTextEntity = entity.FirstChildByName("Cooldown"); + + double maxAbilityCD = (double)abilityEntity["DashAbility"]["CoolDownMaxTimer"]; + double currentAbilityCD = (double)abilityEntity["DashAbility"]["CoolDownTimer"]; + if(cooldownTextEntity.Valid()) { if(cooldownTextEntity.HasComponent("Text")) { - double maxAbilityCD = (double)abilityEntity["DashAbility"]["CoolDownMaxTimer"]; - double currentAbilityCD = (double)abilityEntity["DashAbility"]["CoolDownTimer"]; - currentAbilityCD = currentAbilityCD >= 0.0 ? currentAbilityCD : 0.0; std::string t = (std::string&)cooldownTextEntity["Text"]["Content"] = std::to_string(currentAbilityCD).substr(0, 3); - if(entity.HasComponent("Fill")) { - entity["Fill"]["Percentage"] = currentAbilityCD/maxAbilityCD; //TODO: current time needs to be in the component. - } } } + if (entity.HasComponent("Fill")) { + currentAbilityCD = currentAbilityCD >= 0.0 ? currentAbilityCD : 0.0; + entity["Fill"]["Percentage"] = currentAbilityCD/maxAbilityCD; + } } } From d74ae4e4119aadc0525ed566e74252030c27cdfa Mon Sep 17 00:00:00 2001 From: Tleety Date: Thu, 3 Mar 2016 00:55:44 +0100 Subject: [PATCH 168/252] Some fixes to the Player and map, added skeleton system for the ScoreScreen --- include/Game/Systems/ScoreScreenSystem.h | 18 + .../{NewMap2version3NEW.xml => CP_Rocky.xml} | 1506 +++++++++-------- resources/Schema/Entities/Player.xml | 11 + src/Game/Systems/AbilityCooldownHUDSystem.cpp | 3 +- src/Game/Systems/ScoreScreenSystem.cpp | 6 + 5 files changed, 802 insertions(+), 742 deletions(-) create mode 100644 include/Game/Systems/ScoreScreenSystem.h rename resources/Schema/Entities/{NewMap2version3NEW.xml => CP_Rocky.xml} (97%) create mode 100644 src/Game/Systems/ScoreScreenSystem.cpp diff --git a/include/Game/Systems/ScoreScreenSystem.h b/include/Game/Systems/ScoreScreenSystem.h new file mode 100644 index 00000000..691aa791 --- /dev/null +++ b/include/Game/Systems/ScoreScreenSystem.h @@ -0,0 +1,18 @@ +#ifndef ScoreScreenSystem_h__ +#define ScoreScreenSystem_h__ + +#include "../../Engine/Core/System.h" +#include "../../Engine/GLM.h" + +class ScoreScreenSystem : public PureSystem +{ +public: + ScoreScreenSystem(SystemParams params) + : System(params) + , PureSystem("ScoreScreen") + { } + + virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) override; +}; + +#endif \ No newline at end of file diff --git a/resources/Schema/Entities/NewMap2version3NEW.xml b/resources/Schema/Entities/CP_Rocky.xml similarity index 97% rename from resources/Schema/Entities/NewMap2version3NEW.xml rename to resources/Schema/Entities/CP_Rocky.xml index 61e7b740..8617886f 100644 --- a/resources/Schema/Entities/NewMap2version3NEW.xml +++ b/resources/Schema/Entities/CP_Rocky.xml @@ -29,6 +29,18 @@ + + + + + Models/Props/Walls/SciFiWallBig.mesh + + + + + + + @@ -70,18 +82,6 @@ - - - - - Models/Props/Walls/SciFiWallBig.mesh - - - - - - - @@ -114,6 +114,30 @@ + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + + + + + @@ -369,8 +393,8 @@ - + @@ -384,8 +408,8 @@ - + @@ -399,8 +423,8 @@ - + @@ -414,8 +438,8 @@ - + @@ -456,8 +480,8 @@ - + @@ -471,8 +495,8 @@ - + @@ -485,8 +509,8 @@ - + @@ -514,8 +538,8 @@ - + @@ -543,8 +567,8 @@ - + @@ -584,8 +608,8 @@ - + @@ -634,8 +658,8 @@ - + @@ -649,8 +673,8 @@ - + @@ -664,8 +688,8 @@ - + @@ -707,8 +731,8 @@ - + @@ -760,8 +784,8 @@ - + @@ -775,8 +799,8 @@ - + @@ -795,20 +819,20 @@ - + - - 2 + + - + @@ -825,8 +849,8 @@ + - @@ -842,20 +866,20 @@ - + - - 2 + + - + @@ -872,8 +896,8 @@ + - @@ -889,20 +913,20 @@ - + - - 2 + + - + @@ -919,8 +943,8 @@ + - @@ -936,20 +960,20 @@ - + - - 2 + + - + @@ -966,8 +990,8 @@ + - @@ -983,20 +1007,20 @@ - + - - 2 + + - + @@ -1013,8 +1037,8 @@ + - @@ -1030,20 +1054,20 @@ - + - - 2 + + - + @@ -1060,8 +1084,8 @@ + - @@ -1077,20 +1101,20 @@ - + - - 2 + + - + @@ -1107,8 +1131,8 @@ + - @@ -1170,8 +1194,8 @@ - + @@ -1317,8 +1341,8 @@ - + @@ -1396,8 +1420,8 @@ - + @@ -1424,8 +1448,8 @@ - + @@ -1489,8 +1513,8 @@ - + @@ -1554,8 +1578,8 @@ - + @@ -1722,8 +1746,8 @@ - + @@ -1736,8 +1760,8 @@ - + @@ -1836,8 +1860,8 @@ - + @@ -2020,8 +2044,8 @@ - + @@ -2104,8 +2128,8 @@ - + @@ -2128,8 +2152,8 @@ - + @@ -2142,8 +2166,8 @@ - + @@ -2156,8 +2180,8 @@ - + @@ -2346,20 +2370,20 @@ - + - - 2 + + - + @@ -2376,8 +2400,8 @@ + - @@ -2393,20 +2417,20 @@ - + - - 2 + + - + @@ -2423,8 +2447,8 @@ + - @@ -2474,8 +2498,8 @@ - + @@ -2536,8 +2560,8 @@ - + @@ -2551,8 +2575,8 @@ - + @@ -2598,8 +2622,8 @@ - + @@ -2612,8 +2636,8 @@ - + @@ -2626,8 +2650,8 @@ - + @@ -2640,8 +2664,8 @@ - + @@ -2670,6 +2694,328 @@ + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + @@ -2684,8 +3030,8 @@ - + @@ -2734,8 +3080,8 @@ - + @@ -2749,8 +3095,8 @@ - + @@ -2764,8 +3110,8 @@ - + @@ -2807,8 +3153,8 @@ - + @@ -2860,8 +3206,8 @@ - + @@ -2875,8 +3221,8 @@ - + @@ -2895,20 +3241,20 @@ - + - - 2 + + - + @@ -2925,8 +3271,8 @@ + - @@ -2942,20 +3288,20 @@ - + - - 2 + + - + @@ -2972,8 +3318,8 @@ + - @@ -2989,20 +3335,20 @@ - + - - 2 + + - + @@ -3019,8 +3365,8 @@ + - @@ -3036,20 +3382,20 @@ - + - - 2 + + - + @@ -3066,8 +3412,8 @@ + - @@ -3083,20 +3429,20 @@ - + - - 2 + + - + @@ -3113,8 +3459,8 @@ + - @@ -3130,20 +3476,20 @@ - + - - 2 + + - + @@ -3160,8 +3506,8 @@ + - @@ -3177,20 +3523,20 @@ - + - - 2 + + - + @@ -3207,8 +3553,8 @@ + - @@ -3224,6 +3570,180 @@ + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + @@ -3270,8 +3790,8 @@ - + @@ -3356,46 +3876,6 @@ - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - @@ -3409,20 +3889,6 @@ - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - @@ -3436,19 +3902,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - @@ -3462,19 +3915,6 @@ - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - @@ -3488,48 +3928,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - @@ -3542,19 +3940,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - @@ -3568,19 +3953,6 @@ - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - @@ -3589,21 +3961,8 @@ - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - + @@ -3621,19 +3980,6 @@ - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - @@ -3654,8 +4000,8 @@ - + @@ -3669,6 +4015,20 @@ + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + @@ -3822,22 +4182,8 @@ - - - - - - - - - - Models/Props/Bridges/SciFiBridge1Blue.mesh - - - - - + @@ -3877,240 +4223,6 @@ - - - - - - - - - - Models/Props/Flora/SpecialRoot.mesh - - - - - - - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - @@ -4120,100 +4232,12 @@ - + - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - @@ -4228,22 +4252,8 @@ - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - + @@ -4256,8 +4266,22 @@ - + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + @@ -4299,10 +4323,10 @@ + -15 - -15 4 @@ -4435,10 +4459,10 @@ + 15 - 15 @@ -4462,6 +4486,76 @@ + + + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + @@ -4482,7 +4576,7 @@ 10 - + @@ -4493,7 +4587,7 @@ 10 - + @@ -4616,76 +4710,6 @@ - - - - - Schema/Entities/Player.xml - - - - - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index c93989d8..b7699132 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -107,6 +107,7 @@ Textures/HealthHUD3.png + false @@ -249,6 +250,7 @@ Textures/Core/UnitHexagon.png + false @@ -267,6 +269,7 @@ Textures/Core/UnitHexagon_Rotated.png + false @@ -283,6 +286,7 @@ Textures/Core/UnitHexagon.png + false @@ -301,6 +305,7 @@ Textures/Core/UnitHexagon_Rotated.png + false @@ -317,6 +322,7 @@ Textures/Core/UnitHexagon.png + false @@ -336,6 +342,7 @@ Textures/Core/UnitHexagon_Rotated.png + false @@ -352,6 +359,7 @@ Textures/Core/UnitHexagon.png + false @@ -370,6 +378,7 @@ Textures/Core/UnitHexagon_Rotated.png + false @@ -386,6 +395,7 @@ Textures/Core/UnitHexagon.png + false @@ -403,6 +413,7 @@ Textures/Core/UnitHexagon_Rotated.png + false diff --git a/src/Game/Systems/AbilityCooldownHUDSystem.cpp b/src/Game/Systems/AbilityCooldownHUDSystem.cpp index 7226019f..ccb12a97 100644 --- a/src/Game/Systems/AbilityCooldownHUDSystem.cpp +++ b/src/Game/Systems/AbilityCooldownHUDSystem.cpp @@ -18,6 +18,8 @@ void AbilityCooldownHUDSystem::Update(double dt) double maxAbilityCD = (double)abilityEntity["DashAbility"]["CoolDownMaxTimer"]; double currentAbilityCD = (double)abilityEntity["DashAbility"]["CoolDownTimer"]; + currentAbilityCD = currentAbilityCD >= 0.0 ? currentAbilityCD : 0.0; + if(cooldownTextEntity.Valid()) { if(cooldownTextEntity.HasComponent("Text")) { @@ -25,7 +27,6 @@ void AbilityCooldownHUDSystem::Update(double dt) } } if (entity.HasComponent("Fill")) { - currentAbilityCD = currentAbilityCD >= 0.0 ? currentAbilityCD : 0.0; entity["Fill"]["Percentage"] = currentAbilityCD/maxAbilityCD; } } diff --git a/src/Game/Systems/ScoreScreenSystem.cpp b/src/Game/Systems/ScoreScreenSystem.cpp new file mode 100644 index 00000000..8fa4dd73 --- /dev/null +++ b/src/Game/Systems/ScoreScreenSystem.cpp @@ -0,0 +1,6 @@ +#include "Game/Systems/ScoreScreenSystem.h" + +void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) +{ + //Logic here +} From 047a119e3f33e219af196b9900379dd7dd7e4858 Mon Sep 17 00:00:00 2001 From: Tleety Date: Thu, 3 Mar 2016 01:04:24 +0100 Subject: [PATCH 169/252] ScoreScreenSystem things --- include/Game/Systems/ScoreScreenSystem.h | 16 ++++++++++------ src/Game/Systems/ScoreScreenSystem.cpp | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/include/Game/Systems/ScoreScreenSystem.h b/include/Game/Systems/ScoreScreenSystem.h index 691aa791..b65d9465 100644 --- a/include/Game/Systems/ScoreScreenSystem.h +++ b/include/Game/Systems/ScoreScreenSystem.h @@ -1,18 +1,22 @@ #ifndef ScoreScreenSystem_h__ #define ScoreScreenSystem_h__ -#include "../../Engine/Core/System.h" -#include "../../Engine/GLM.h" +#include "Core/System.h" +#include "Core/EPlayerDeath.h" +#include "Core/EPlayerSpawned.h" +#include "GLM.h" class ScoreScreenSystem : public PureSystem { public: - ScoreScreenSystem(SystemParams params) - : System(params) - , PureSystem("ScoreScreen") - { } + ScoreScreenSystem(SystemParams params); virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) override; + + EventRelay m_EPlayerDeath; + void OnPlayerDeath(const Events::PlayerDeath& e); + EventRelay m_EPlayerSpawned; + void OnPlayerSpawn(const Events::PlayerSpawned& e); }; #endif \ No newline at end of file diff --git a/src/Game/Systems/ScoreScreenSystem.cpp b/src/Game/Systems/ScoreScreenSystem.cpp index 8fa4dd73..37dccb20 100644 --- a/src/Game/Systems/ScoreScreenSystem.cpp +++ b/src/Game/Systems/ScoreScreenSystem.cpp @@ -1,6 +1,25 @@ #include "Game/Systems/ScoreScreenSystem.h" + +ScoreScreenSystem::ScoreScreenSystem(SystemParams params) + : System(params) + , PureSystem("ScoreScreen") +{ + EVENT_SUBSCRIBE_MEMBER(m_EPlayerDeath, &ScoreScreenSystem::OnPlayerDeath); + EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &ScoreScreenSystem::OnPlayerSpawn); +} + void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) { //Logic here } + +void ScoreScreenSystem::OnPlayerDeath(const Events::PlayerDeath& e) +{ + //When player die, add it to his score, and when possible the player who killed him. +} + +void ScoreScreenSystem::OnPlayerSpawn(const Events::PlayerSpawned& e) +{ + //When a player spawn, add a new entry to the score screen. +} From 13546aa3fc3e24a0744f12e89aa1e2191f13a334 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Tue, 1 Mar 2016 22:37:19 +0100 Subject: [PATCH 170/252] DefenderWeapon and SidearmWeapon --- .../Systems/Weapon/DefenderWeaponBehaviour.h | 12 +-- .../Systems/Weapon/SidearmWeaponBehaviour.h | 3 +- include/Game/Systems/Weapon/WeaponBehaviour.h | 57 +++++++++-- .../Schema/Components/DefenderWeapon.xml | 6 +- .../Schema/Components/DefenderWeapon.xsd | 6 +- resources/Schema/Components/SidearmWeapon.xml | 4 +- resources/Schema/Components/SidearmWeapon.xsd | 6 +- resources/Schema/Entities/Player.xml | 14 +-- resources/Schema/Entities/Ray2Red | 18 ++++ resources/Schema/Entities/Ray2Red.xml | 43 ++++++++ .../Schema/Entities/SidearmWeaponView.xml | 63 +++++++++++- src/Engine/Editor/EditorGUI.cpp | 52 ++++++++-- .../Weapon/DefenderWeaponBehaviour.cpp | 98 ++++++++++++++----- .../Systems/Weapon/SidearmWeaponBehaviour.cpp | 23 ++++- 14 files changed, 340 insertions(+), 65 deletions(-) create mode 100644 resources/Schema/Entities/Ray2Red create mode 100644 resources/Schema/Entities/Ray2Red.xml diff --git a/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h b/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h index 986d8586..c1e132b1 100644 --- a/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h +++ b/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h @@ -1,7 +1,6 @@ #include "WeaponBehaviour.h" #include "Collision/Collision.h" #include "Core/EPlayerDamage.h" -#include "Rendering/ESetCamera.h" class DefenderWeaponBehaviour : public WeaponBehaviour { @@ -10,29 +9,24 @@ public: : System(systemParams) , WeaponBehaviour(systemParams, "DefenderWeapon", renderer, collisionOctree) , m_RandomEngine(m_RandomDevice()) - { - EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &DefenderWeaponBehaviour::OnSetCamera); - } + { } void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cWeapon, double dt) override; void UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& wi, double dt) override; void OnPrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) override; void OnCeasePrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) override; + void OnReload(ComponentWrapper cWeapon, WeaponInfo& wi) override; bool OnInputCommand(ComponentWrapper cWeapon, WeaponInfo& wi, const Events::InputCommand& e) override; private: std::random_device m_RandomDevice; std::mt19937 m_RandomEngine; - EntityWrapper m_CurrentCamera; - - EventRelay m_ESetCamera; - bool OnSetCamera(const Events::SetCamera& e); // Weapon functions void fireShell(ComponentWrapper cWeapon, WeaponInfo& wi); void dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi, glm::vec3 direction, double damage); + bool canFire(ComponentWrapper cWeapon, WeaponInfo& wi); // Utility - float traceRayDistance(glm::vec3 origin, glm::vec3 direction); Camera cameraFromEntity(EntityWrapper camera); }; \ No newline at end of file diff --git a/include/Game/Systems/Weapon/SidearmWeaponBehaviour.h b/include/Game/Systems/Weapon/SidearmWeaponBehaviour.h index 787c3c61..d221b8bb 100644 --- a/include/Game/Systems/Weapon/SidearmWeaponBehaviour.h +++ b/include/Game/Systems/Weapon/SidearmWeaponBehaviour.h @@ -15,12 +15,12 @@ public: void UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& wi, double dt) override; void OnPrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) override; void OnCeasePrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) override; + void OnEquip(ComponentWrapper cWeapon, WeaponInfo& wi) override; void OnHolster(ComponentWrapper cWeapon, WeaponInfo& wi) override; private: std::random_device m_RandomDevice; std::mt19937 m_RandomEngine; - EntityWrapper m_CurrentCamera; // Weapon functions void fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi); @@ -28,5 +28,6 @@ private: // Utility bool canFire(ComponentWrapper cWeapon); + bool playerInFirstPerson(EntityWrapper player); //float traceRayDistance(glm::vec3 origin, glm::vec3 direction); }; \ No newline at end of file diff --git a/include/Game/Systems/Weapon/WeaponBehaviour.h b/include/Game/Systems/Weapon/WeaponBehaviour.h index 2ab53e0e..e0783bd2 100644 --- a/include/Game/Systems/Weapon/WeaponBehaviour.h +++ b/include/Game/Systems/Weapon/WeaponBehaviour.h @@ -7,6 +7,7 @@ #include "Collision/EntityAABB.h" #include "Input/EInputCommand.h" #include "Systems/SpawnerSystem.h" +#include "Rendering/ESetCamera.h" template class WeaponBehaviour : public PureSystem @@ -21,6 +22,7 @@ public: , m_CollisionOctree(collisionOctree) { EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &WeaponBehaviour::_OnInputCommand) + EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &WeaponBehaviour::_OnSetCamera) } virtual ~WeaponBehaviour() = default; @@ -44,6 +46,7 @@ protected: }; IRenderer* m_Renderer; + EntityWrapper m_CurrentCamera; Octree* m_CollisionOctree; std::unordered_map m_ActiveWeapons; @@ -51,10 +54,49 @@ protected: virtual void OnPrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) { } virtual void OnCeasePrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) { } virtual void OnReload(ComponentWrapper cWeapon, WeaponInfo& wi) { } + virtual void OnEquip(ComponentWrapper cWeapon, WeaponInfo& wi) { } virtual void OnHolster(ComponentWrapper cWeapon, WeaponInfo& wi) { } virtual bool OnInputCommand(ComponentWrapper cWeapon, WeaponInfo& wi, const Events::InputCommand& e) { return false; } + bool isPlayerInFirstPerson(EntityWrapper player) + { + if (!m_CurrentCamera.Valid()) { + return false; + } else { + return m_CurrentCamera == player || m_CurrentCamera.IsChildOf(player); + } + } + + // Returns wi.FirstPersonEntity or wi.ThirdPersonEntity depending on + // if the player is in first person mode or not. + EntityWrapper getRelevantWeaponModelEntity(WeaponInfo& wi) + { + if (isPlayerInFirstPerson(wi.Player)) { + return wi.FirstPersonEntity; + } else { + return wi.ThirdPersonEntity; + } + } + + float traceRayDistance(glm::vec3 origin, glm::vec3 direction) + { + float distance; + glm::vec3 pos; + auto entity = Collision::EntityFirstHitByRay(Ray(origin, direction), m_CollisionOctree, distance, pos); + if (entity) { + return distance; + } else { + return 100.f; + } + } + private: + EventRelay m_ESetCamera; + bool _OnSetCamera(const Events::SetCamera& e) + { + m_CurrentCamera = e.CameraEntity; + return true; + } EventRelay m_EInputCommand; bool _OnInputCommand(const Events::InputCommand& e) { @@ -78,7 +120,7 @@ private: if (e.Command == "SelectWeapon") { if (e.Value > 0) { if (static_cast(e.Value) == static_cast((*cWeapon)["Slot"])) { - selectWeapon(player); + selectWeapon(*cWeapon, player); } else { holsterWeapon(*cWeapon, player); } @@ -132,7 +174,7 @@ private: return activeWeapon; } - void selectWeapon(EntityWrapper player) + void selectWeapon(ComponentWrapper cWeapon, EntityWrapper player) { // Don't reselect weapon if it's already active if (getActiveWeapon(player)) { @@ -170,10 +212,13 @@ private: thirdPersonWeapon = SpawnerSystem::Spawn(thirdPersonAttachment, thirdPersonAttachment); } - m_ActiveWeapons[player].Player = player; - m_ActiveWeapons[player].WeaponEntity = player; - m_ActiveWeapons[player].FirstPersonEntity = firstPersonWeapon; - m_ActiveWeapons[player].ThirdPersonEntity = thirdPersonWeapon; + WeaponInfo& wi = m_ActiveWeapons[player]; + wi.Player = player; + wi.WeaponEntity = player; + wi.FirstPersonEntity = firstPersonWeapon; + wi.ThirdPersonEntity = thirdPersonWeapon; + + OnEquip(cWeapon, wi); } void holsterWeapon(ComponentWrapper cWeapon, EntityWrapper player) diff --git a/resources/Schema/Components/DefenderWeapon.xml b/resources/Schema/Components/DefenderWeapon.xml index 998f3bde..1b336fc4 100755 --- a/resources/Schema/Components/DefenderWeapon.xml +++ b/resources/Schema/Components/DefenderWeapon.xml @@ -11,6 +11,8 @@ 0.01 0.5 - false - 0 + false + 0 + false + 0 \ No newline at end of file diff --git a/resources/Schema/Components/DefenderWeapon.xsd b/resources/Schema/Components/DefenderWeapon.xsd index 0ec61964..c1b98e2f 100755 --- a/resources/Schema/Components/DefenderWeapon.xsd +++ b/resources/Schema/Components/DefenderWeapon.xsd @@ -48,8 +48,10 @@ Time it takes to load ONE SHELL into the weapon in seconds - - + + + + diff --git a/resources/Schema/Components/SidearmWeapon.xml b/resources/Schema/Components/SidearmWeapon.xml index b63706b6..1d503ecc 100644 --- a/resources/Schema/Components/SidearmWeapon.xml +++ b/resources/Schema/Components/SidearmWeapon.xml @@ -3,9 +3,11 @@ 16 16 20 - 120 + 500 + false 0.01 0.5 + 0.5 false 0 diff --git a/resources/Schema/Components/SidearmWeapon.xsd b/resources/Schema/Components/SidearmWeapon.xsd index 844b449f..bafb9de2 100644 --- a/resources/Schema/Components/SidearmWeapon.xsd +++ b/resources/Schema/Components/SidearmWeapon.xsd @@ -23,7 +23,7 @@ Ammo currently loaded into the magazine - Max number of rounds in a magazine + Max number of rounds in a magazine Damage dealt if all shotgun pellets hit @@ -31,12 +31,16 @@ Rate of fire in rounds per minute + View punch in radians for each shell fired Time it takes to load ONE SHELL into the weapon in seconds + + Time it takes from selecting the weapon until it's ready to fire + diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 394f4622..5c5efc07 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -8,7 +8,7 @@ - 52.867678870419283 + 102.85760837900634 @@ -454,7 +454,7 @@ Idle - 0.022133545026491674 + 1.8348644854054612 1 @@ -478,8 +478,8 @@ Schema/Entities/DefenderWeaponView.xml - - + + @@ -497,8 +497,8 @@ Schema/Entities/SidearmWeaponView.xml - - + + @@ -528,7 +528,7 @@ Idle - 0.13373697879978863 + 0.013134522267137072 1 diff --git a/resources/Schema/Entities/Ray2Red b/resources/Schema/Entities/Ray2Red new file mode 100644 index 00000000..813443b2 --- /dev/null +++ b/resources/Schema/Entities/Ray2Red @@ -0,0 +1,18 @@ + + + + + + Textures/Effects/Ray.png + + + + + + + + + + + + diff --git a/resources/Schema/Entities/Ray2Red.xml b/resources/Schema/Entities/Ray2Red.xml new file mode 100644 index 00000000..6c7c3248 --- /dev/null +++ b/resources/Schema/Entities/Ray2Red.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + Textures/Effects/Ray.png + + + + + + + + + + + + + + + Textures/Effects/Ray.png + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/SidearmWeaponView.xml b/resources/Schema/Entities/SidearmWeaponView.xml index 68d29676..f01ffdf7 100644 --- a/resources/Schema/Entities/SidearmWeaponView.xml +++ b/resources/Schema/Entities/SidearmWeaponView.xml @@ -14,7 +14,7 @@ - Schema/Entities/RayBlue.xml + Schema/Entities/Ray2Red.xml @@ -22,6 +22,67 @@ + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + + + + 16 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + 8 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + diff --git a/src/Engine/Editor/EditorGUI.cpp b/src/Engine/Editor/EditorGUI.cpp index a1ceafd0..4e7c8ab6 100644 --- a/src/Engine/Editor/EditorGUI.cpp +++ b/src/Engine/Editor/EditorGUI.cpp @@ -390,14 +390,52 @@ bool EditorGUI::drawComponentField_Vector(ComponentWrapper &c, const ComponentIn // Limit scale values to a minimum of 0 return ImGui::DragFloat3("", glm::value_ptr(val), 0.1f, 0.f, std::numeric_limits::max()); } else if (field.Name == "Orientation") { - // Make orentations have a period of 2*Pi - glm::vec3 tempVal = glm::fmod(val, glm::vec3(glm::two_pi())); - if (ImGui::SliderFloat3("", glm::value_ptr(tempVal), 0.f, glm::two_pi())) { - val = tempVal; - return true; - } else { - return false; + //glm::vec3 tempVal = val; + glm::vec3 originalVal = val; + + ImVec2 cursorPos = ImGui::GetCursorScreenPos(); + glm::tvec3 isSnapping(false, false, false); + bool changed = ImGui::DragFloat3("", glm::value_ptr(val), 0.066666f); + if (changed) { + // Make orentations have a period of 2*Pi + val = glm::fmod(val, glm::vec3(glm::two_pi())); + for (int i = 0; i < 3; i++) { + if (val[i] < 0) { + val[i] += glm::two_pi(); + } + } } + + // Snap to angle + //float snapRange = glm::pi() / 15.f; + //float snapAngle = glm::quarter_pi(); + //glm::vec3 snap = glm::fmod(val, glm::vec3(snapAngle)); + //for (int i = 0; i < 3; i++) { + // isSnapping[i] = glm::abs(snap[i] - (snapRange / 2.f)) < snapRange; + //} + //if (changed && ImGui::IsMouseDown(0)) { + // glm::vec3 change = val - originalVal; + // for (int i = 0; i < 3; i++) { + // if (isSnapping[i] && glm::abs(change[i]) < snapRange) { + // val[i] -= snap[i] - snapRange; + // } + // } + //} + + // Draw snapping outline + float width = ImGui::CalcItemWidth() / 3.f;; + float spacing = GImGui->Style.ItemInnerSpacing.x; + for (int i = 0; i < 3; i++) { + if (isSnapping[i]) { + ImVec2 pos = cursorPos + ImVec2(i * (width + spacing), 0.f); + ImRect bb(pos - ImVec2(1, 1), pos + ImVec2(width, 17)); + auto window = ImGui::GetCurrentWindow(); + const ImU32 col = window->Color(ImGuiCol_HeaderActive); + window->DrawList->AddRect(bb.Min, bb.Max, col, 3.f); + } + } + + return changed; } else { return ImGui::DragFloat3("", glm::value_ptr(val), 0.1f, std::numeric_limits::lowest(), std::numeric_limits::max()); } diff --git a/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp b/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp index 0a179b4c..4c0f9673 100644 --- a/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp @@ -2,33 +2,73 @@ void DefenderWeaponBehaviour::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cWeapon, double dt) { - (double&)cWeapon["TimeSinceLastFire"] += dt; + double& fireCooldown = cWeapon["FireCooldown"]; + fireCooldown = glm::max(0.0, fireCooldown - dt); + WeaponBehaviour::UpdateComponent(entity, cWeapon, dt); } void DefenderWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& wi, double dt) { - bool isFiring = cWeapon["IsFiring"]; - bool cooldownPassed = (double)cWeapon["TimeSinceLastFire"] >= (60.0 / (double)cWeapon["RPM"]); - bool isNotShielding = wi.Player.ChildrenWithComponent("Shield").size() == 0; - if (isFiring && cooldownPassed && isNotShielding) { + double& reloadTimer = cWeapon["ReloadTimer"]; + reloadTimer = glm::max(0.0, reloadTimer - dt); + + double reloadTime = cWeapon["ReloadTime"]; + bool& isReloading = cWeapon["IsReloading"]; + if (isReloading && reloadTimer <= 0.0) { + int& magAmmo = cWeapon["MagazineAmmo"]; + int& magSize = cWeapon["MagazineSize"]; + int& ammo = cWeapon["Ammo"]; + if (magAmmo < magSize && ammo > 0) { + ammo -= 1; + magAmmo += 1; + reloadTimer = reloadTime; + } else { + isReloading = false; + } + } + + if (canFire(cWeapon, wi)) { fireShell(cWeapon, wi); } } void DefenderWeaponBehaviour::OnPrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) { - cWeapon["IsFiring"] = true; - bool cooldownPassed = (double)cWeapon["TimeSinceLastFire"] >= (60.0 / (double)cWeapon["RPM"]); - bool isNotShielding = wi.Player.ChildrenWithComponent("Shield").size() == 0; - if (cooldownPassed && isNotShielding) { + cWeapon["TriggerHeld"] = true; + if (canFire(cWeapon, wi)) { fireShell(cWeapon, wi); } } void DefenderWeaponBehaviour::OnCeasePrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) { - cWeapon["IsFiring"] = false; + cWeapon["TriggerHeld"] = false; +} + +void DefenderWeaponBehaviour::OnReload(ComponentWrapper cWeapon, WeaponInfo& wi) +{ + bool& isReloading = cWeapon["IsReloading"]; + if (isReloading) { + return; + } + + int& magAmmo = cWeapon["MagazineAmmo"]; + int& magSize = cWeapon["MagazineSize"]; + if (magAmmo >= magSize) { + return; + } + int& ammo = cWeapon["Ammo"]; + if (ammo <= 0) { + return; + } + + double reloadTime = cWeapon["ReloadTime"]; + double& reloadTimer = cWeapon["ReloadTimer"]; + + // Start reload + isReloading = true; + reloadTimer = reloadTime; } bool DefenderWeaponBehaviour::OnInputCommand(ComponentWrapper cWeapon, WeaponInfo& wi, const Events::InputCommand& e) @@ -47,15 +87,23 @@ bool DefenderWeaponBehaviour::OnInputCommand(ComponentWrapper cWeapon, WeaponInf return false; } -bool DefenderWeaponBehaviour::OnSetCamera(const Events::SetCamera& e) -{ - m_CurrentCamera = e.CameraEntity; - return true; -} - void DefenderWeaponBehaviour::fireShell(ComponentWrapper cWeapon, WeaponInfo& wi) { - cWeapon["TimeSinceLastFire"] = 0.0; + cWeapon["FireCooldown"] = 60.0 / (double)cWeapon["RPM"]; + + // Stop reloading + bool& isReloading = cWeapon["IsReloading"]; + isReloading = false; + + // Ammo + int& magAmmo = cWeapon["MagazineAmmo"]; + if (magAmmo <= 0) { + OnReload(cWeapon, wi); + return; + } else { + magAmmo -= 1; + } + int numPellets = cWeapon["NumPellets"]; float spreadAngle = cWeapon["SpreadAngle"]; std::uniform_real_distribution randomSpreadAngle(-spreadAngle, spreadAngle); @@ -92,7 +140,6 @@ void DefenderWeaponBehaviour::fireShell(ComponentWrapper cWeapon, WeaponInfo& wi dealDamage(cWeapon, wi, direction, pelletDamage); } } - } void DefenderWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi, glm::vec3 direction, double damage) @@ -154,16 +201,13 @@ void DefenderWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& w LOG_DEBUG("Damage: %f", damage); } -float DefenderWeaponBehaviour::traceRayDistance(glm::vec3 origin, glm::vec3 direction) +bool DefenderWeaponBehaviour::canFire(ComponentWrapper cWeapon, WeaponInfo& wi) { - float distance; - glm::vec3 pos; - auto entity = Collision::EntityFirstHitByRay(Ray(origin, direction), m_CollisionOctree, distance, pos); - if (entity) { - return distance; - } else { - return 100.f; - } + bool triggerHeld = cWeapon["TriggerHeld"]; + bool cooldownPassed = (double)cWeapon["FireCooldown"] <= 0.0; + bool isNotShielding = wi.Player.ChildrenWithComponent("Shield").size() == 0; + // TODO: Ammo checks + return triggerHeld && cooldownPassed && isNotShielding; } Camera DefenderWeaponBehaviour::cameraFromEntity(EntityWrapper camera) diff --git a/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp b/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp index 8c3906af..9a3ed6ab 100644 --- a/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp @@ -14,7 +14,7 @@ void SidearmWeaponBehaviour::UpdateComponent(EntityWrapper& entity, ComponentWra void SidearmWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& wi, double dt) { - if (canFire(cWeapon)) { + if ((bool)cWeapon["Automatic"] && canFire(cWeapon)) { fireBullet(cWeapon, wi); } } @@ -32,6 +32,11 @@ void SidearmWeaponBehaviour::OnCeasePrimaryFire(ComponentWrapper cWeapon, Weapon cWeapon["TriggerHeld"] = false; } +void SidearmWeaponBehaviour::OnEquip(ComponentWrapper cWeapon, WeaponInfo& wi) +{ + cWeapon["FireCooldown"] = (double)cWeapon["EquipTime"]; +} + void SidearmWeaponBehaviour::OnHolster(ComponentWrapper cWeapon, WeaponInfo& wi) { // Make sure the trigger is released if weapon is holstered while firing @@ -46,7 +51,23 @@ void SidearmWeaponBehaviour::OnHolster(ComponentWrapper cWeapon, WeaponInfo& wi) void SidearmWeaponBehaviour::fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi) { + cWeapon["FireCooldown"] = 60.0 / (double)cWeapon["RPM"]; + // Get weapon model based on current person + EntityWrapper weaponModelEntity = getRelevantWeaponModelEntity(wi); + if (!weaponModelEntity.Valid()) { + return; + } + + // Tracer + EntityWrapper tracerSpawner = weaponModelEntity.FirstChildByName("WeaponMuzzle"); + if (tracerSpawner.Valid()) { + glm::vec3 origin = Transform::AbsolutePosition(tracerSpawner); + glm::vec3 direction = Transform::AbsoluteOrientation(tracerSpawner) * glm::vec3(0, 0, -1); + float distance = traceRayDistance(origin, direction); + EntityWrapper ray = SpawnerSystem::Spawn(tracerSpawner); + ((glm::vec3&)ray["Transform"]["Scale"]).z = (distance / 100.f); + } } bool SidearmWeaponBehaviour::canFire(ComponentWrapper cWeapon) From 40c66f76ae6e69d843a63c39d90ca6aa23b2a31f Mon Sep 17 00:00:00 2001 From: Tleety Date: Thu, 3 Mar 2016 01:28:43 +0100 Subject: [PATCH 171/252] A component for tracking score for players. --- resources/Schema/Components.xsd | 1 + resources/Schema/Components/ScoreIdentity.xml | 3 +++ resources/Schema/Components/ScoreIdentity.xsd | 20 +++++++++++++++++++ resources/Schema/Types/Entity.xsd | 1 + 4 files changed, 25 insertions(+) create mode 100644 resources/Schema/Components/ScoreIdentity.xml create mode 100644 resources/Schema/Components/ScoreIdentity.xsd diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index d1572252..48f3ca04 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -60,4 +60,5 @@ + \ No newline at end of file diff --git a/resources/Schema/Components/ScoreIdentity.xml b/resources/Schema/Components/ScoreIdentity.xml new file mode 100644 index 00000000..95478277 --- /dev/null +++ b/resources/Schema/Components/ScoreIdentity.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/resources/Schema/Components/ScoreIdentity.xsd b/resources/Schema/Components/ScoreIdentity.xsd new file mode 100644 index 00000000..9ed69918 --- /dev/null +++ b/resources/Schema/Components/ScoreIdentity.xsd @@ -0,0 +1,20 @@ + + + + + A component tracking data for the score of a player. + + + The Kills per death score. + + + The amount of kills. + + + The amount of deaths. + + + Ping of a player. + + + \ No newline at end of file diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index 126276f6..9f364e11 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -63,6 +63,7 @@ + From 0e8b97dbbade6bb39c6f2b8af6c1cfc43ce67cde Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 3 Mar 2016 01:35:32 +0100 Subject: [PATCH 172/252] Made AmmunitionHUD into TextFieldReader which reads any component field on a parent and updates a Text component with the value! --- include/Engine/Core/EntityWrapper.h | 1 + include/Game/Systems/AmmunitionHUDSystem.h | 17 ---- include/Game/Systems/TextFieldReader.h | 19 +++++ resources/Schema/Components.xsd | 2 +- resources/Schema/Components/AmmunitionHUD.xml | 3 - resources/Schema/Components/AmmunitionHUD.xsd | 10 --- .../Schema/Components/TextFieldReader.xml | 6 ++ .../Schema/Components/TextFieldReader.xsd | 21 +++++ .../Schema/Entities/DefenderWeaponView.xml | 15 +++- resources/Schema/Entities/Player.xml | 82 +++++++++---------- .../Schema/Entities/SidearmWeaponView.xml | 13 ++- resources/Schema/Types/Entity.xsd | 2 +- src/Engine/Core/EntityWrapper.cpp | 12 +++ src/Game/Game.cpp | 6 +- src/Game/Systems/AmmunitionHUDSystem.cpp | 36 -------- src/Game/Systems/TextFieldReader.cpp | 46 +++++++++++ 16 files changed, 174 insertions(+), 117 deletions(-) delete mode 100644 include/Game/Systems/AmmunitionHUDSystem.h create mode 100644 include/Game/Systems/TextFieldReader.h delete mode 100644 resources/Schema/Components/AmmunitionHUD.xml delete mode 100644 resources/Schema/Components/AmmunitionHUD.xsd create mode 100644 resources/Schema/Components/TextFieldReader.xml create mode 100644 resources/Schema/Components/TextFieldReader.xsd delete mode 100644 src/Game/Systems/AmmunitionHUDSystem.cpp create mode 100644 src/Game/Systems/TextFieldReader.cpp diff --git a/include/Engine/Core/EntityWrapper.h b/include/Engine/Core/EntityWrapper.h index 8ece8e59..12029720 100644 --- a/include/Engine/Core/EntityWrapper.h +++ b/include/Engine/Core/EntityWrapper.h @@ -27,6 +27,7 @@ struct EntityWrapper bool HasComponent(const std::string& componentType); void AttachComponent(const char* componentName); EntityWrapper Parent(); + EntityWrapper FirstParentByName(const std::string& parentEntityName); EntityWrapper FirstChildByName(const std::string& name); EntityWrapper FirstParentWithComponent(const std::string& componentType); EntityWrapper Clone(EntityWrapper parent = EntityWrapper::Invalid); diff --git a/include/Game/Systems/AmmunitionHUDSystem.h b/include/Game/Systems/AmmunitionHUDSystem.h deleted file mode 100644 index b22a85b5..00000000 --- a/include/Game/Systems/AmmunitionHUDSystem.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef AmmunitionHUDSystem_h__ -#define AmmunitionHUDSystem_h__ - -#include "../../Engine/Core/System.h" -#include "../../Engine/GLM.h" - -class AmmunitionHUDSystem : public ImpureSystem -{ -public: - AmmunitionHUDSystem(SystemParams params) - : System(params) - { } - - virtual void Update(double dt) override; -}; - -#endif \ No newline at end of file diff --git a/include/Game/Systems/TextFieldReader.h b/include/Game/Systems/TextFieldReader.h new file mode 100644 index 00000000..1ea8e966 --- /dev/null +++ b/include/Game/Systems/TextFieldReader.h @@ -0,0 +1,19 @@ +#ifndef AmmunitionHUDSystem_h__ +#define AmmunitionHUDSystem_h__ + +#include +#include "../../Engine/Core/System.h" +#include "../../Engine/GLM.h" + +class TextFieldReader : public PureSystem +{ +public: + TextFieldReader(SystemParams params) + : System(params) + , PureSystem("TextFieldReader") + { } + + virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cTextFieldReader, double dt) override; +}; + +#endif \ No newline at end of file diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index 711f4999..ee8bc31d 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -45,7 +45,7 @@ - + diff --git a/resources/Schema/Components/AmmunitionHUD.xml b/resources/Schema/Components/AmmunitionHUD.xml deleted file mode 100644 index 63b86150..00000000 --- a/resources/Schema/Components/AmmunitionHUD.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/resources/Schema/Components/AmmunitionHUD.xsd b/resources/Schema/Components/AmmunitionHUD.xsd deleted file mode 100644 index 1a48d8d1..00000000 --- a/resources/Schema/Components/AmmunitionHUD.xsd +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - Hud element for tracking ammunition from parent with AssaultWeapon component. Child with the name "MagazineAmmo" tracks clip ammunition. Child with the name "Ammo" tracks ammo. - - - \ No newline at end of file diff --git a/resources/Schema/Components/TextFieldReader.xml b/resources/Schema/Components/TextFieldReader.xml new file mode 100644 index 00000000..52430804 --- /dev/null +++ b/resources/Schema/Components/TextFieldReader.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/resources/Schema/Components/TextFieldReader.xsd b/resources/Schema/Components/TextFieldReader.xsd new file mode 100644 index 00000000..7c77890d --- /dev/null +++ b/resources/Schema/Components/TextFieldReader.xsd @@ -0,0 +1,21 @@ + + + + + + Reads a value from a specific field of a compoent of parent entity and writes it to the Text component on this entity. + + + + The name of the parent entity to read the component field from. Leave empty to read from this entity. + + + The component type to read the field value from. + + + The field name to read the value from. + + + + + \ No newline at end of file diff --git a/resources/Schema/Entities/DefenderWeaponView.xml b/resources/Schema/Entities/DefenderWeaponView.xml index b65194f9..0886ac67 100755 --- a/resources/Schema/Entities/DefenderWeaponView.xml +++ b/resources/Schema/Entities/DefenderWeaponView.xml @@ -33,7 +33,6 @@ - @@ -61,8 +60,13 @@ + + Player + DefenderWeapon + MagazineAmmo + - 32 + 0 Fonts/DroidSans.ttf,64 @@ -74,8 +78,13 @@ + + Player + DefenderWeapon + Ammo + - 360 + 0 Fonts/DroidSans.ttf,64 diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 5c5efc07..e0230582 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -7,9 +7,7 @@ - - 102.85760837900634 - + @@ -26,7 +24,7 @@ - + @@ -66,8 +64,8 @@ Textures/Weapons/Crosshair/SmallThickHoleDot.png - false + false @@ -90,42 +88,22 @@ - - - - 1 - - - - 100/100 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - 1 + Textures/HealthHUD3.png - - + @@ -142,8 +120,8 @@ Textures/Core/White.png - false + false @@ -160,8 +138,8 @@ Textures/Core/White.png - false + false @@ -178,8 +156,8 @@ Textures/Core/White.png - false + false @@ -193,6 +171,26 @@ + + + + 1 + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + @@ -229,8 +227,8 @@ - + @@ -263,8 +261,8 @@ - + @@ -298,8 +296,8 @@ - + @@ -332,8 +330,8 @@ - + @@ -365,8 +363,8 @@ - + @@ -442,8 +440,8 @@ - + @@ -490,9 +488,8 @@ R_Arm_Weapon_Joint - AssaultWeapon - SidearmWeapon + Schema/Entities/SidearmWeaponView.xml @@ -575,7 +572,10 @@ Schema/Entities/SidearmWeaponWorld.xml - + + + + @@ -617,8 +617,8 @@ - + @@ -627,8 +627,8 @@ Textures/Icons/Arrow.png - false + false diff --git a/resources/Schema/Entities/SidearmWeaponView.xml b/resources/Schema/Entities/SidearmWeaponView.xml index f01ffdf7..d3dcda66 100644 --- a/resources/Schema/Entities/SidearmWeaponView.xml +++ b/resources/Schema/Entities/SidearmWeaponView.xml @@ -24,7 +24,11 @@ - + + + + + @@ -52,6 +56,11 @@ + + Player + SidearmWeapon + MagazineAmmo + 16 Fonts/DroidSans.ttf,64 @@ -73,8 +82,8 @@ - + diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index f9870a51..b4ceb6d2 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -43,7 +43,7 @@ - + diff --git a/src/Engine/Core/EntityWrapper.cpp b/src/Engine/Core/EntityWrapper.cpp index b3bef55a..3c217353 100644 --- a/src/Engine/Core/EntityWrapper.cpp +++ b/src/Engine/Core/EntityWrapper.cpp @@ -34,6 +34,18 @@ EntityWrapper EntityWrapper::Parent() } } +EntityWrapper EntityWrapper::FirstParentByName(const std::string& parentEntityName) +{ + EntityWrapper entity = *this; + while (entity.Parent().Valid()) { + entity = entity.Parent(); + if (entity.Name() == parentEntityName) { + return entity; + } + } + return EntityWrapper::Invalid; +} + EntityWrapper EntityWrapper::FirstChildByName(const std::string& name) { return firstChildByNameRecursive(name, this->ID); diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 7607efec..10107ab1 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -27,7 +27,7 @@ #include "../Engine/Core/UniformScaleSystem.h" #include "Rendering/AnimationSystem.h" #include "Network/MultiplayerSnapshotFilter.h" -#include "Game/Systems/AmmunitionHUDSystem.h" +#include "Game/Systems/TextFieldReader.h" #include "Game/Systems/CapturePointArrowHUDSystem.h" #include "Game/Systems/KillFeedSystem.h" #include "Game/Systems/BoostSystem.h" @@ -136,7 +136,7 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); - m_SystemPipeline->AddSystem(updateOrderLevel); + m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); @@ -145,7 +145,7 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); - m_SystemPipeline->AddSystem(updateOrderLevel); + m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer); diff --git a/src/Game/Systems/AmmunitionHUDSystem.cpp b/src/Game/Systems/AmmunitionHUDSystem.cpp deleted file mode 100644 index c9d87072..00000000 --- a/src/Game/Systems/AmmunitionHUDSystem.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "Game/Systems/AmmunitionHUDSystem.h" - -void AmmunitionHUDSystem::Update(double dt) -{ - //Hud element for tracking ammunition from parent with AssaultWeapon component.Child with the name "MagazineAmmo" tracks clip ammunition.Child with the name "Ammo" tracks ammo. - - auto ammunitionHUDs = m_World->GetComponents("AmmunitionHUD"); - if (ammunitionHUDs == nullptr) { - return; - } - - for (auto& ammunitionHUDComponent : *ammunitionHUDs) { - EntityWrapper entity = EntityWrapper(m_World, ammunitionHUDComponent.EntityID); - - EntityWrapper playerEntity = entity.FirstParentWithComponent("AssaultWeapon"); - - if (!playerEntity.Valid()) { - return; - } - - - EntityWrapper magazineAmmo = entity.FirstChildByName("MagazineAmmo"); - if(magazineAmmo.Valid()) { - if(magazineAmmo.HasComponent("Text")) { - (std::string&)magazineAmmo["Text"]["Content"] = std::to_string((int)playerEntity["AssaultWeapon"]["MagazineAmmo"]); - } - } - - EntityWrapper ammo = entity.FirstChildByName("Ammo"); - if (ammo.Valid()) { - if (ammo.HasComponent("Text")) { - (std::string&)ammo["Text"]["Content"] = std::to_string((int)playerEntity["AssaultWeapon"]["Ammo"]); - } - } - } -} diff --git a/src/Game/Systems/TextFieldReader.cpp b/src/Game/Systems/TextFieldReader.cpp new file mode 100644 index 00000000..8712a61f --- /dev/null +++ b/src/Game/Systems/TextFieldReader.cpp @@ -0,0 +1,46 @@ +#include "Game/Systems/TextFieldReader.h" + +void TextFieldReader::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cAmmunitionHUD, double dt) +{ + if (!entity.HasComponent("Text")) { + return; + } + + // Find the entity to read from + const std::string& parentEntityName = cAmmunitionHUD["ParentEntityName"]; + EntityWrapper readEntity = entity; + if (!parentEntityName.empty()) { + readEntity = entity.FirstParentByName(parentEntityName); + if (!readEntity.Valid()) { + return; + } + } + + // Find the component to read from + const std::string& componentType = cAmmunitionHUD["ComponentType"]; + if (componentType.empty() || !readEntity.HasComponent(componentType)) { + return; + } + ComponentWrapper component = readEntity[componentType]; + + // Find the field to read from + const std::string& fieldName = cAmmunitionHUD["Field"]; + if (fieldName.empty() || component.Info.Fields.count(fieldName) == 0) { + return; + } + const ComponentInfo::Field_t& field = component.Info.Fields.at(fieldName); + + std::string& text = entity["Text"]["Content"]; + + if (field.Type == "int") { + text = boost::lexical_cast((const int&)component[fieldName]); + } else if (field.Type == "float") { + text = boost::lexical_cast((const float&)component[fieldName]); + } else if (field.Type == "double") { + text = boost::lexical_cast((const double&)component[fieldName]); + } else if (field.Type == "bool") { + text = boost::lexical_cast((const bool&)component[fieldName]); + } else if (field.Type == "string") { + text = (const std::string&)component[fieldName]; + } +} From 362378536e9438b5c311dfddf31e24b6ecca5dbc Mon Sep 17 00:00:00 2001 From: viktorljung Date: Thu, 3 Mar 2016 01:39:12 +0100 Subject: [PATCH 173/252] Switching rooms --- include/Engine/Rendering/AnimationSystem.h | 3 + include/Engine/Rendering/AutoBlendQueue.h | 27 + include/Engine/Rendering/BlendTree.h | 3 + .../Engine/Rendering/EAutoAnimationBlend.h | 7 +- resources/Schema/Entities/AnimationTests2.xml | 1040 ++++++----------- resources/Schema/Entities/BlendTreeTest.xml | 557 +++++++++ resources/Schema/Entities/ble | 145 +++ src/Engine/Rendering/AnimationSystem.cpp | 294 ++++- src/Engine/Rendering/AutoBlendQueue.cpp | 0 src/Engine/Rendering/BlendTree.cpp | 15 + 10 files changed, 1375 insertions(+), 716 deletions(-) create mode 100644 include/Engine/Rendering/AutoBlendQueue.h create mode 100644 resources/Schema/Entities/BlendTreeTest.xml create mode 100644 resources/Schema/Entities/ble create mode 100644 src/Engine/Rendering/AutoBlendQueue.cpp diff --git a/include/Engine/Rendering/AnimationSystem.h b/include/Engine/Rendering/AnimationSystem.h index 1ea076fd..fd53022f 100644 --- a/include/Engine/Rendering/AnimationSystem.h +++ b/include/Engine/Rendering/AnimationSystem.h @@ -57,10 +57,13 @@ private: EntityWrapper RootNode = EntityWrapper::Invalid; double Duration; double CurrentTime = 0.0; + double Delay = 0.0; BlendTree::AutoBlendInfo BlendInfo; }; + std::list m_AutoBlendJobs; + std::unordered_map m_QueuedAutoBlendJobs; std::list m_BlendJobs; std::list m_QueuedBlendJobs; diff --git a/include/Engine/Rendering/AutoBlendQueue.h b/include/Engine/Rendering/AutoBlendQueue.h new file mode 100644 index 00000000..12dd249e --- /dev/null +++ b/include/Engine/Rendering/AutoBlendQueue.h @@ -0,0 +1,27 @@ +#ifndef AutoBlendQueue_h__ +#define AutoBlendQueue_h__ + +#include "../Core/ResourceManager.h" +#include "Skeleton.h" +#include "Model.h" +#include "BlendTree.h" + +class AutoBlendQueue +{ +public: + struct AutoBlendJob + { + EntityWrapper RootNode = EntityWrapper::Invalid; + double Duration; + double CurrentTime = 0.0; + double Delay = 0.0; + BlendTree::AutoBlendInfo BlendInfo; + }; + +private: + std::map m_BlendQueue; + + +}; + +#endif diff --git a/include/Engine/Rendering/BlendTree.h b/include/Engine/Rendering/BlendTree.h index 29ad3ca9..5605707a 100644 --- a/include/Engine/Rendering/BlendTree.h +++ b/include/Engine/Rendering/BlendTree.h @@ -60,9 +60,12 @@ public: { std::string NodeName; double progress; + bool Restart; + double AnimationSpeed; std::unordered_map StartWeights; }; + BlendTree(EntityWrapper ModelEntity, Skeleton* skeleton); ~BlendTree(); diff --git a/include/Engine/Rendering/EAutoAnimationBlend.h b/include/Engine/Rendering/EAutoAnimationBlend.h index b148664f..edd8e0bc 100644 --- a/include/Engine/Rendering/EAutoAnimationBlend.h +++ b/include/Engine/Rendering/EAutoAnimationBlend.h @@ -11,7 +11,12 @@ struct AutoAnimationBlend : Event { EntityWrapper RootNode = EntityWrapper::Invalid; std::string NodeName; - double Duration; + double Duration = 0.0; + double Delay = 0.0; + + + double AnimationSpeed = 1.0; + bool Restart = false; EntityWrapper AnimationEntity = EntityWrapper::Invalid; }; diff --git a/resources/Schema/Entities/AnimationTests2.xml b/resources/Schema/Entities/AnimationTests2.xml index aaa6de48..b5b46c85 100644 --- a/resources/Schema/Entities/AnimationTests2.xml +++ b/resources/Schema/Entities/AnimationTests2.xml @@ -3,7 +3,7 @@ - 0.40000000596046448 + 0.30000001192092896 3 @@ -21,7 +21,7 @@ - 0.80000001192092896 + 0 Models/Widgets/Lights/DirectionalLightWidget.mesh @@ -33,15 +33,15 @@ - + 8 - 0.20000000298023224 + 0.60000002384185791 - + @@ -49,12 +49,12 @@ - Aim + AimBlend FinalBlend 5 - Models/Characters/Defender/DefenderRed.mesh + Models/Characters/Assault/AssaultBlue.mesh @@ -66,110 +66,65 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - + - + - + - - 3 - - - - - - - - - - - AimRifleA - - false - true - + + AimPrimary + AimSecondary + 0 + - + + + + + AimRifleA + + false + true + + + + + + + + + AimSecWepA + + false + true + + + + + + - WeaponBlend + ReloadSwitchBlend MovementBlend - - - - ShootBlend - Reload - 0 - - - - - - - - ShootFast - ShootSlow - 1 - - - - - - - - ShootFastRifleU - - 1 - - - - - - - - - ShootRifleU - - 1 - - - - - - - - - - - ReloadSwitchU - - 1 - - - - - - - StandCrouchBlend - Jump + JumpDashBlend 0 @@ -185,100 +140,156 @@ - + - Walk - StrafeBlend - 1 + MovementBlend + Idle + 0 - + + + + RunWalkBlend + StrafeLRBlend + 0 + + + + + + + + Walk + Run + 1 + + + + + + + + WalkF + + + + + + + + + RunF + + 1 + + + + + + + + + + + Left + Right + 0 + + + + + + + + StrafeLeftF + + + + + + + + + StrafeRightF + + + + + + + + + + - CrouchWalkF - + IdleF + 1 - - - - Left - Right - 1 - - - - - - - - CrouchStrafeLeftF - - 1 - - - - - - - - - CrouchStrafeRightF - - 1 - - - - - - - - + - RunWalkBlend - StrafeBlend - 1 + MovementBlend + Idle - + - Run - Walk + Walk + StrafeLRBlend 0 - + - - RunF - - 1 - + + Left + Right + 0 + - + + + + + CrouchStrafeLeftF + + + + + + + + + CrouchStrafeRightF + + + + + + - WalkF - - 1 + CrouchWalkF @@ -286,33 +297,110 @@ - + + + + CrouchF + + 1 + + + + + + + + + + + + + Jump + DashBlend + 1 + + + + + + + + JumpF + + + + + + + + + + DashFBBlend + DashLRBlend + 0 + + + + + - Left - Right + DashForward + DashBackward 1 - + - StrafeLeftF - - 1 + DashForwardF + false - + - StrafeRightF - - 1 + DashBackwardF + + false + + + + + + + + + + + DashLeft + DashRight + 0 + + + + + + + + DashLeftF + + false + + + + + + + + + DashRightF + false @@ -324,543 +412,106 @@ - + + + + + + ReloadSwitch + WeaponActionBlend + 1 + + + + + - JumpF - + ReloadSwitchU + 1 + + + + IdleBlend + ShootBlend + 1 + + + + + + + + IdlePrimary + IdleSecondary + + + + + + + + IdleAssaultRifleU + + + + + + + + + IdleSecWepU + + + + + + + + + + + ShootPrimary + ShootSecondary + 0 + + + + + + + + ShootFastRifleU + + 1 + + + + + + + + + ShootSecWepFastU + + + + + + + + + - - - - - - - - - - - R_Arm_Weapon_Joint - - - - Models/Core/UnitCube.mesh - - true - - - - - - - - - - - - - R_Hand - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - R_Arm - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - R_Shoulder - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - Neck - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - Spine_3 - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - Spine_2 - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - Spine_1 - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - Hip - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - L_Leg_Top - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - L_Leg_Bottom - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - L_Foot - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - L_Toe - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - L_Shoulder - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - L_Arm - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - L_Hand - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - L_Shoulder_Armor_Joint - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - Chin - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - Head - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - Perietal - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - L_Elbow - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - R_Leg_Bottom - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - R_Elbow - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - R_Leg_Top - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - R_Foot - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - R_Toe - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - R_Shoulder_Armor_Joint - - true - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - @@ -874,6 +525,31 @@ + + + + + 8 + 0.60000002384185791 + + + + + + + + + + + 8 + 0.80000001192092896 + + + + + + + diff --git a/resources/Schema/Entities/BlendTreeTest.xml b/resources/Schema/Entities/BlendTreeTest.xml new file mode 100644 index 00000000..3457fc5e --- /dev/null +++ b/resources/Schema/Entities/BlendTreeTest.xml @@ -0,0 +1,557 @@ + + + + + + 0.30000001192092896 + 3 + + + + + + + + + + + + + + + + + 0 + + + Models/Widgets/Lights/DirectionalLightWidget.mesh + + + + + + + + + + + + + 8 + 0.60000002384185791 + + + + + + + + + + + AimBlend + FinalBlend + + + 5 + Models/Characters/Assault/AssaultBlue.mesh + + + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + + + + + AimPrimary + AimSecondary + 0 + + + + + + + + AimRifleA + + false + true + + + + + + + + + AimSecWepA + + false + true + + + + + + + + + + + ReloadSwitchBlend + MovementBlend + + + + + + + + StandCrouchBlend + JumpDashBlend + 0 + + + + + + + + StandMovement + CrouchMovement + 0 + + + + + + + + MovementBlend + Idle + 0 + + + + + + + + RunWalkBlend + StrafeLRBlend + 0 + + + + + + + + Walk + Run + 1 + + + + + + + + WalkF + + + + + + + + + RunF + + 1 + + + + + + + + + + + Left + Right + 0 + + + + + + + + StrafeLeftF + + + + + + + + + StrafeRightF + + + + + + + + + + + + + IdleF + + 1 + + + + + + + + + + + MovementBlend + Idle + + + + + + + + Walk + StrafeLRBlend + 0 + + + + + + + + Left + Right + 0 + + + + + + + + CrouchStrafeLeftF + + + + + + + + + CrouchStrafeRightF + + + + + + + + + + + CrouchWalkF + + + + + + + + + + + CrouchF + + 1 + + + + + + + + + + + + + Jump + DashBlend + 1 + + + + + + + + JumpF + + + + + + + + + + DashFBBlend + DashLRBlend + 0 + + + + + + + + DashForward + DashBackward + 1 + + + + + + + + DashForwardF + false + + + + + + + + + DashBackwardF + + false + + + + + + + + + + + DashLeft + DashRight + 0 + + + + + + + + DashLeftF + + false + + + + + + + + + DashRightF + false + + + + + + + + + + + + + + + + + ReloadSwitch + WeaponActionBlend + 1 + + + + + + + + ReloadSwitchU + + 1 + + + + + + + + + IdleBlend + ShootBlend + 1 + + + + + + + + IdlePrimary + IdleSecondary + + + + + + + + IdleAssaultRifleU + + + + + + + + + IdleSecWepU + + + + + + + + + + + ShootPrimary + ShootSecondary + 0 + + + + + + + + ShootFastRifleU + + 1 + + + + + + + + + ShootSecWepFastU + + + + + + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + + + + + + + + + + + 8 + 0.60000002384185791 + + + + + + + + + + + 8 + 0.80000001192092896 + + + + + + + + + + + + diff --git a/resources/Schema/Entities/ble b/resources/Schema/Entities/ble new file mode 100644 index 00000000..6518ee5b --- /dev/null +++ b/resources/Schema/Entities/ble @@ -0,0 +1,145 @@ + + + + + + 0.30000001192092896 + 3 + + + + + + + + + + + + + + + + + 0 + + + Models/Widgets/Lights/DirectionalLightWidget.mesh + + + + + + + + + + + + + 8 + 0.60000002384185791 + + + + + + + + + + + + + + + 5 + Models/Characters/Defender/DefenderBlue.mesh + + + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + + + AimPrimary + AimSecondary + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + + + + + + + + + + + 8 + 0.60000002384185791 + + + + + + + + + + + 8 + 0.80000001192092896 + + + + + + + + + + + + diff --git a/src/Engine/Rendering/AnimationSystem.cpp b/src/Engine/Rendering/AnimationSystem.cpp index 11a21881..4e7f15f6 100644 --- a/src/Engine/Rendering/AnimationSystem.cpp +++ b/src/Engine/Rendering/AnimationSystem.cpp @@ -92,9 +92,30 @@ void AnimationSystem::UpdateAnimations(double dt) double animationSpeed = (double)animationC["Speed"]; if (animationSpeed != 0.0) { + double nextTime = (double)animationC["Time"] + animationSpeed * dt; + //Pre animation end blend + if (m_QueuedAutoBlendJobs.find(entity) != m_QueuedAutoBlendJobs.end()) { + if (glm::sign(m_QueuedAutoBlendJobs.at(entity).Delay) < 0) { + if (!(bool)animationC["Loop"]) { + if (nextTime > animation->Duration + m_QueuedAutoBlendJobs.at(entity).Delay && glm::sign(animationSpeed) > 0) { + AnimationComplete(entity); + } else if (nextTime < 0 - m_QueuedAutoBlendJobs.at(entity).Delay && glm::sign(animationSpeed) < 0) { + AnimationComplete(entity); + } + } else { + if (nextTime > animation->Duration + m_QueuedAutoBlendJobs.at(entity).Delay && glm::sign(animationSpeed) > 0) { + AnimationComplete(entity); + } else if (nextTime < 0 - m_QueuedAutoBlendJobs.at(entity).Delay && glm::sign(animationSpeed) < 0) { + AnimationComplete(entity); + } + } + } + } + + if (!(bool)animationC["Loop"]) { if (nextTime > animation->Duration) { nextTime = animation->Duration; @@ -119,6 +140,7 @@ void AnimationSystem::UpdateAnimations(double dt) e.Entity = entity; e.Name = (std::string)animationC["AnimationName"]; m_EventBroker->Publish(e); + AnimationComplete(entity); while (nextTime > animation->Duration) { nextTime -= animation->Duration; @@ -128,13 +150,12 @@ void AnimationSystem::UpdateAnimations(double dt) e.Entity = entity; e.Name = (std::string)animationC["AnimationName"]; m_EventBroker->Publish(e); - + AnimationComplete(entity); while (nextTime < 0) { nextTime += animation->Duration; } } } - (double&)animationC["Time"] = nextTime; } } @@ -143,7 +164,7 @@ void AnimationSystem::UpdateAnimations(double dt) void AnimationSystem::UpdateWeights(double dt) { - /* for (auto it = m_BlendJobs.begin(); it != m_BlendJobs.end(); it++) { + for (auto it = m_BlendJobs.begin(); it != m_BlendJobs.end();) { if (!it->BlendEntity.Valid()) { it = m_BlendJobs.erase(it); continue; @@ -161,7 +182,9 @@ void AnimationSystem::UpdateWeights(double dt) it = m_BlendJobs.erase(it); } } - }*/ + + ++it; + } for (auto it = m_AutoBlendJobs.begin(); it != m_AutoBlendJobs.end();) { @@ -214,7 +237,7 @@ void AnimationSystem::UpdateWeights(double dt) void AnimationSystem::AnimationComplete(EntityWrapper animationEntity) { - for (auto it = m_QueuedBlendJobs.begin(); it != m_QueuedBlendJobs.end(); it++) { + for (auto it = m_QueuedBlendJobs.begin(); it != m_QueuedBlendJobs.end();) { if (!it->BlendEntity.Valid() || !it->AnimationEntity.Valid()) { it = m_QueuedBlendJobs.erase(it); continue; @@ -229,10 +252,28 @@ void AnimationSystem::AnimationComplete(EntityWrapper animationEntity) bj.CurrentTime = 0.0; m_BlendJobs.push_back(bj); it = m_QueuedBlendJobs.erase(it); + continue; } + ++it; } + + if (m_QueuedAutoBlendJobs.find(animationEntity) != m_QueuedAutoBlendJobs.end()) { + AutoBlendJob abj = m_QueuedAutoBlendJobs.at(animationEntity); + + if (!abj.RootNode.Valid() || !animationEntity.Valid()) { + m_QueuedAutoBlendJobs.erase(animationEntity); + } else { + m_AutoBlendJobs.push_back(abj); + m_QueuedAutoBlendJobs.erase(animationEntity); + } + + + + } + + } bool AnimationSystem::OnAnimationBlend(Events::AnimationBlend& e) @@ -256,17 +297,16 @@ bool AnimationSystem::OnAnimationBlend(Events::AnimationBlend& e) m_QueuedBlendJobs.push_back(qbj); return true; } + } else { + BlendJob bj; + bj.BlendEntity = e.BlendEntity; + bj.StartWeight = (double)e.BlendEntity["Blend"]["Weight"]; + bj.GoalWeight = e.GoalWeight; + bj.Duration = e.Duration; + bj.CurrentTime = 0.0; + m_BlendJobs.push_back(bj); + return true; } - - BlendJob bj; - bj.BlendEntity = e.BlendEntity; - bj.StartWeight = (double)e.BlendEntity["Blend"]["Weight"]; - bj.GoalWeight = e.GoalWeight; - bj.Duration = e.Duration; - bj.CurrentTime = 0.0; - m_BlendJobs.push_back(bj); - - return true; } @@ -280,18 +320,39 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e) return false; } - AutoBlendJob abj; - abj.RootNode = e.RootNode; - abj.CurrentTime = 0.0; - abj.Duration = e.Duration; + if (e.AnimationEntity.Valid()) { + AutoBlendJob abj; + abj.RootNode = e.RootNode; + abj.CurrentTime = 0.0; + abj.Duration = e.Duration; + abj.Delay = e.Delay; - BlendTree::AutoBlendInfo abInfo; - abInfo.NodeName = e.NodeName; - abInfo.progress = 0.0; - - abj.BlendInfo = abInfo; + BlendTree::AutoBlendInfo abInfo; + abInfo.NodeName = e.NodeName; + abInfo.progress = 0.0; + abInfo.Restart = e.Restart; + abInfo.AnimationSpeed = e.AnimationSpeed; + abj.BlendInfo = abInfo; - m_AutoBlendJobs.push_back(abj); + m_QueuedAutoBlendJobs[e.AnimationEntity] = abj; + return true; + } else { + AutoBlendJob abj; + abj.RootNode = e.RootNode; + abj.CurrentTime = 0.0; + abj.Duration = e.Duration; + + BlendTree::AutoBlendInfo abInfo; + abInfo.NodeName = e.NodeName; + abInfo.progress = 0.0; + abInfo.Restart = e.Restart; + abInfo.AnimationSpeed = e.AnimationSpeed; + + abj.BlendInfo = abInfo; + + m_AutoBlendJobs.push_back(abj); + return true; + } } @@ -301,8 +362,6 @@ bool AnimationSystem::OnInputCommand(const Events::InputCommand& e) if (e.Value == 1.f) { if (e.Command == "BlendTest0") { - - auto blendComponents = m_World->GetComponents("BlendAdditive"); if (blendComponents == nullptr) { @@ -314,11 +373,12 @@ bool AnimationSystem::OnInputCommand(const Events::InputCommand& e) EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); if (entity.Name() == "Assault") { - Events::AutoAnimationBlend aeb; aeb.Duration = m_BlendTime1; aeb.NodeName = m_AnimationName1; aeb.RootNode = entity; + aeb.Restart = true; + m_EventBroker->Publish(aeb); } @@ -338,15 +398,183 @@ bool AnimationSystem::OnInputCommand(const Events::InputCommand& e) if (entity.Name() == "Assault") { - Events::AutoAnimationBlend aeb; - aeb.Duration = m_BlendTime2; - aeb.NodeName = m_AnimationName2; - aeb.RootNode = entity; - m_EventBroker->Publish(aeb); + { + Events::AutoAnimationBlend aeb; + aeb.Duration = m_BlendTime2; + aeb.NodeName = m_AnimationName2; + aeb.RootNode = entity; + aeb.Restart = true; + m_EventBroker->Publish(aeb); + } + + { + Events::AutoAnimationBlend aeb; + aeb.Duration = m_BlendTime2; + aeb.NodeName = "Run"; + aeb.RootNode = entity; + aeb.Restart = true; + aeb.AnimationEntity = entity.FirstChildByName("DashLeft"); + m_EventBroker->Publish(aeb); + } } } } + + + if(e.Command == "DashForward") { + auto blendComponents = m_World->GetComponents("BlendAdditive"); + + if (blendComponents == nullptr) { + return false; + } + for (auto& bc : *blendComponents) { + EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); + + if (entity.Name() == "Assault") { + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.1; + aeb.NodeName = "DashForward"; + aeb.RootNode = entity; + aeb.Restart = true; + m_EventBroker->Publish(aeb); + } + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.3; + aeb.NodeName = "Run"; + aeb.RootNode = entity; + aeb.Restart = true; + aeb.Delay = 0; + aeb.AnimationEntity = entity.FirstChildByName("DashForward"); + m_EventBroker->Publish(aeb); + } + } + } + + } else if (e.Command == "DashBackward") { + auto blendComponents = m_World->GetComponents("BlendAdditive"); + + if (blendComponents == nullptr) { + return false; + } + for (auto& bc : *blendComponents) { + EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); + + if (entity.Name() == "Assault") { + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.1; + aeb.NodeName = "DashBackward"; + aeb.RootNode = entity; + aeb.Restart = true; + m_EventBroker->Publish(aeb); + } + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.3; + aeb.NodeName = "Run"; + aeb.RootNode = entity; + aeb.Restart = true; + aeb.Delay = -0.3; + aeb.AnimationEntity = entity.FirstChildByName("DashBackward"); + m_EventBroker->Publish(aeb); + } + } + } + } else if (e.Command == "DashLeft") { + auto blendComponents = m_World->GetComponents("BlendAdditive"); + + if (blendComponents == nullptr) { + return false; + } + for (auto& bc : *blendComponents) { + EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); + + if (entity.Name() == "Assault") { + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.1; + aeb.NodeName = "DashLeft"; + aeb.RootNode = entity; + aeb.Restart = true; + m_EventBroker->Publish(aeb); + } + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.3; + aeb.NodeName = "Run"; + aeb.RootNode = entity; + aeb.Restart = true; + aeb.Delay = -0.3; + aeb.AnimationEntity = entity.FirstChildByName("DashLeft"); + m_EventBroker->Publish(aeb); + } + } + } + } else if (e.Command == "DashRight") { + auto blendComponents = m_World->GetComponents("BlendAdditive"); + + if (blendComponents == nullptr) { + return false; + } + for (auto& bc : *blendComponents) { + EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); + + if (entity.Name() == "Assault") { + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.1; + aeb.NodeName = "DashRight"; + aeb.RootNode = entity; + aeb.Restart = true; + m_EventBroker->Publish(aeb); + } + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.3; + aeb.NodeName = "Run"; + aeb.RootNode = entity; + aeb.Restart = true; + aeb.AnimationEntity = entity.FirstChildByName("DashRight"); + aeb.Delay = -0.3; + m_EventBroker->Publish(aeb); + } + } + } + } else if (e.Command == "Jump") { + auto blendComponents = m_World->GetComponents("BlendAdditive"); + + if (blendComponents == nullptr) { + return false; + } + for (auto& bc : *blendComponents) { + EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); + + if (entity.Name() == "Assault") { + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.35; + aeb.NodeName = "Jump"; + aeb.RootNode = entity; + aeb.Restart = true; + m_EventBroker->Publish(aeb); + } + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.35; + aeb.NodeName = "Run"; + aeb.RootNode = entity; + aeb.Restart = false; + aeb.AnimationEntity = entity.FirstChildByName("Jump"); + m_EventBroker->Publish(aeb); + } + } + } + } + + } } diff --git a/src/Engine/Rendering/AutoBlendQueue.cpp b/src/Engine/Rendering/AutoBlendQueue.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/Engine/Rendering/BlendTree.cpp b/src/Engine/Rendering/BlendTree.cpp index 8b044134..f7381d4d 100644 --- a/src/Engine/Rendering/BlendTree.cpp +++ b/src/Engine/Rendering/BlendTree.cpp @@ -207,6 +207,21 @@ BlendTree::AutoBlendInfo BlendTree::AutoBlendStep(AutoBlendInfo blendInfo) { std::vector goalNodes = FindNodesByName(blendInfo.NodeName); + if (blendInfo.Restart) { + for (auto it = goalNodes.begin(); it != goalNodes.end(); it++) { + EntityWrapper entity = (*it)->Entity; + + if (entity.Valid()) { + if (entity.HasComponent("Animation")) { + (double&)entity["Animation"]["Time"] = 0.0; + (double&)entity["Animation"]["Speed"] = blendInfo.AnimationSpeed; + } + } + } + blendInfo.Restart = false; + } + + if(goalNodes.size() == 0) { return blendInfo; } else if(goalNodes.size() == 1) { From 7ea26d10eeca755564d52ad6cf736981b596bb3c Mon Sep 17 00:00:00 2001 From: FakeShemp Date: Thu, 3 Mar 2016 03:28:21 +0100 Subject: [PATCH 174/252] Rewritten. Works as a charm now. --- .../Engine/Rendering/DirectionalLightJob.h | 7 +- include/Engine/Rendering/DrawFinalPass.h | 2 +- include/Engine/Rendering/Renderer.h | 4 +- include/Engine/Rendering/ShadowPass.h | 13 +- include/Engine/Rendering/ShadowPassState.h | 4 +- resources/Shaders/ForwardPlus.frag.glsl | 135 ++++++++------- .../Shaders/ForwardPlusShieldCheck.frag.glsl | 2 + .../Shaders/ForwardPlusSkinned.vert.glsl | 10 +- .../Shaders/ForwardPlusSplatMap.frag.glsl | 3 + .../Shaders/ForwardPlusSplatMapRGB.frag.glsl | 1 + resources/Shaders/Shadow.frag.glsl | 4 +- src/Engine/Editor/EditorRenderSystem.cpp | 2 +- src/Engine/Editor/EditorSystem.cpp | 5 +- src/Engine/Rendering/DrawFinalPass.cpp | 16 +- src/Engine/Rendering/FrameBuffer.cpp | 32 ++-- src/Engine/Rendering/RenderSystem.cpp | 2 +- src/Engine/Rendering/Renderer.cpp | 16 +- src/Engine/Rendering/ShadowPass.cpp | 157 +++++++++--------- src/Engine/Rendering/ShadowPassState.cpp | 8 +- 19 files changed, 224 insertions(+), 199 deletions(-) diff --git a/include/Engine/Rendering/DirectionalLightJob.h b/include/Engine/Rendering/DirectionalLightJob.h index 96b2ec9c..5f104ca5 100644 --- a/include/Engine/Rendering/DirectionalLightJob.h +++ b/include/Engine/Rendering/DirectionalLightJob.h @@ -15,17 +15,16 @@ struct DirectionalLightJob : RenderJob DirectionalLightJob(ComponentWrapper transformComponent, ComponentWrapper directionalLightComponent, World* m_World) : RenderJob() { - Orientation = Transform::AbsoluteOrientation(m_World, transformComponent.EntityID); - Direction = glm::vec4(0,0,-1,0) * glm::inverse(Orientation); + + Direction = glm::vec4(0,0,-1,0) * glm::inverse(Transform::AbsoluteOrientation(m_World, transformComponent.EntityID)); + //Direction = glm::vec4((glm::vec3)directionalLightComponent["Direction"], 0.f); Color = (glm::vec4)directionalLightComponent["Color"]; Intensity = (double)directionalLightComponent["Intensity"]; }; - glm::quat Orientation; glm::vec4 Direction; glm::vec4 Color; float Intensity; - bool TextureAlphaShadows = false; void CalculateHash() override { diff --git a/include/Engine/Rendering/DrawFinalPass.h b/include/Engine/Rendering/DrawFinalPass.h index 82ae216d..c5b937c6 100644 --- a/include/Engine/Rendering/DrawFinalPass.h +++ b/include/Engine/Rendering/DrawFinalPass.h @@ -64,9 +64,9 @@ private: const IRenderer* m_Renderer; const LightCullingPass* m_LightCullingPass; - const ShadowPass* m_ShadowPass; const CubeMapPass* m_CubeMapPass; const SSAOPass* m_SSAOPass; + const ShadowPass* m_ShadowPass; ShaderProgram* m_ForwardPlusProgram; ShaderProgram* m_ExplosionEffectProgram; diff --git a/include/Engine/Rendering/Renderer.h b/include/Engine/Rendering/Renderer.h index 75517442..fd3b215e 100644 --- a/include/Engine/Rendering/Renderer.h +++ b/include/Engine/Rendering/Renderer.h @@ -24,9 +24,9 @@ #include "../Core/Transform.h" #include "imgui/imgui.h" #include "TextPass.h" -#include "ShadowPass.h" #include "Util/CommonFunctions.h" #include "Core/PerformanceTimer.h" +#include "ShadowPass.h" class Renderer : public IRenderer { @@ -74,9 +74,9 @@ private: DrawScreenQuadPass* m_DrawScreenQuadPass; DrawBloomPass* m_DrawBloomPass; DrawColorCorrectionPass* m_DrawColorCorrectionPass; - ShadowPass* m_ShadowPass; SSAOPass* m_SSAOPass; CubeMapPass* m_CubeMapPass; + ShadowPass* m_ShadowPass; //----------------------Functions----------------------// void InitializeWindow(); diff --git a/include/Engine/Rendering/ShadowPass.h b/include/Engine/Rendering/ShadowPass.h index 372ba6f2..6db8a624 100644 --- a/include/Engine/Rendering/ShadowPass.h +++ b/include/Engine/Rendering/ShadowPass.h @@ -1,5 +1,5 @@ -#ifndef ShadowPass_h_ -#define ShadowPass_h_ +#ifndef ShadowPass_h__ +#define ShadowPass_h__ #include "IRenderer.h" #include "FrameBuffer.h" @@ -38,6 +38,8 @@ public: void ClearBuffer(); void Draw(RenderScene& scene); + void DebugGUI(); + GLuint DepthMap() const { return m_DepthMap; } std::array LightP() const { return m_LightProjection; } std::array LightV() const { return m_LightView; } @@ -62,7 +64,6 @@ private: GLuint m_DepthMap; FrameBuffer m_DepthBuffer; ShaderProgram* m_ShadowProgram; - //ShaderProgram* m_TransparentShadowProgram; std::array m_LightProjection; std::array m_LightView; @@ -71,8 +72,12 @@ private: GLuint m_ResolutionSizeWidth = 1024 * 2; GLuint m_ResolutionSizeHeight = 1024 * 2; + bool m_TransparentObjects = false; + bool m_TexturedShadows = false; + bool m_EnableShadows = true; + int m_CurrentNrOfSplits = 4; - float m_SplitWeight = 0.91f; + float m_SplitWeight = 0.962f; std::array m_shadowFrusta; diff --git a/include/Engine/Rendering/ShadowPassState.h b/include/Engine/Rendering/ShadowPassState.h index ec08a77c..f881b48e 100644 --- a/include/Engine/Rendering/ShadowPassState.h +++ b/include/Engine/Rendering/ShadowPassState.h @@ -6,8 +6,8 @@ class ShadowPassState : public RenderState { public: - ShadowPassState(GLuint frameBuffer); - ~ShadowPassState(); + ShadowPassState(GLuint frameBuffer); + ~ShadowPassState(); private: }; diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index baf1baf1..f7ddd00c 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -1,7 +1,7 @@ #version 430 -#define MAX_SPLITS 4 #define MIN_AMBIENT_LIGHT 0.3 +#define MAX_SPLITS 4 uniform mat4 M; uniform mat4 V; @@ -12,22 +12,22 @@ uniform vec2 ScreenDimensions; uniform vec4 FillColor; uniform vec4 AmbientColor; uniform float FillPercentage; -uniform float FarDistance[MAX_SPLITS]; uniform float GlowIntensity = 10; uniform vec3 CameraPosition; uniform int SSAOQuality; +uniform float FarDistance[MAX_SPLITS]; uniform vec2 DiffuseUVRepeat; uniform vec2 NormalUVRepeat; uniform vec2 SpecularUVRepeat; uniform vec2 GlowUVRepeat; layout (binding = 0) uniform sampler2D AOTexture; -layout (binding = 6) uniform sampler2DArrayShadow DepthMap; layout (binding = 1) uniform sampler2D DiffuseTexture; layout (binding = 2) uniform sampler2D NormalMapTexture; layout (binding = 3) uniform sampler2D SpecularMapTexture; layout (binding = 4) uniform sampler2D GlowMapTexture; layout (binding = 5) uniform samplerCube CubeMap; +layout (binding = 13) uniform sampler2DArrayShadow DepthMap; #define TILE_SIZE 16 @@ -62,7 +62,6 @@ layout (std430, binding = 4) buffer LightIndexBuffer float LightIndex[]; }; - in VertexData{ vec3 Position; vec3 Normal; @@ -155,6 +154,62 @@ float Random(vec3 seed, int i) return fract(sin(dot_product) * 43758.5453); } +int getShadowIndex(float far_distance[1]) +{ + return 0; +} + +int getShadowIndex(float far_distance[2]) +{ + float depth = gl_FragCoord.z / gl_FragCoord.w; + + int index = 1; + if ( depth < far_distance[0] ) + { + index = 0; + } + + return index; +} + +int getShadowIndex(float far_distance[3]) +{ + float depth = gl_FragCoord.z / gl_FragCoord.w; + + int index = 2; + if ( depth < far_distance[0] ) + { + index = 0; + } + else if ( depth < far_distance[1] && depth > far_distance[0] ) + { + index = 1; + } + + return index; +} + +int getShadowIndex(float far_distance[4]) +{ + float depth = gl_FragCoord.z / gl_FragCoord.w; + + int index = 3; + if ( depth < far_distance[0] ) + { + index = 0; + } + else if ( depth < far_distance[1] && depth > far_distance[0] ) + { + index = 1; + } + else if ( depth < far_distance[2] && depth > far_distance[1] ) + { + index = 2; + } + + return index; +} + // Standard hardware-calculated PCF method float PCFShadow(sampler2DArrayShadow depth_texture_array, vec3 projection_coords, int layer_index) { @@ -237,62 +292,6 @@ float CalcShadowValue(vec4 light_space_pos, vec3 normal, vec3 light_dir, sampler shadowMapDepth = SoftwarePCF(depth_texture_array, projCoords, layer_index, bias); return shadowMapDepth; -} - -int getShadowIndex(float far_distance[1]) -{ - return 0; -} - -int getShadowIndex(float far_distance[2]) -{ - float depth = gl_FragCoord.z / gl_FragCoord.w; - - int index = 1; - if ( depth < far_distance[0] ) - { - index = 0; - } - - return index; -} - -int getShadowIndex(float far_distance[3]) -{ - float depth = gl_FragCoord.z / gl_FragCoord.w; - - int index = 2; - if ( depth < far_distance[0] ) - { - index = 0; - } - else if ( depth < far_distance[1] && depth > far_distance[0] ) - { - index = 1; - } - - return index; -} - -int getShadowIndex(float far_distance[4]) -{ - float depth = gl_FragCoord.z / gl_FragCoord.w; - - int index = 3; - if ( depth < far_distance[0] ) - { - index = 0; - } - else if ( depth < far_distance[1] && depth > far_distance[0] ) - { - index = 1; - } - else if ( depth < far_distance[2] && depth > far_distance[1] ) - { - index = 2; - } - - return index; } void main() @@ -322,14 +321,14 @@ void main() int start = int(LightGrids.Data[currentTile].Start); int amount = int(LightGrids.Data[currentTile].Amount); - - float shadowFactor = 0.0; + float shadowFactor = 0.0; + for(int i = start; i < start + amount; i++) { int l = int(LightIndex[i]); LightSource light = LightSources.List[l]; - + LightResult light_result; //These if statements should be removed. if(light.Type == 1) { // point @@ -342,17 +341,17 @@ void main() totalLighting.Diffuse += vec4(light_result.Diffuse.rgb * ao, light_result.Diffuse.a); totalLighting.Specular += vec4(light_result.Specular.rgb * ao, light_result.Specular.a); } - + totalLighting.Diffuse *= vec4(min(vec3(shadowFactor) + AmbientColor.xyz, vec3(1.0)), 1.0); totalLighting.Specular *= vec4(min(vec3(shadowFactor) + AmbientColor.xyz, vec3(1.0)), 1.0); - - //LightResult getInformation; - + vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); - color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); + color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0; vec4 reflectionTotal = reflectionColor * (1-specularTexel.a) * color_result.a; color_result = color_result * clamp(1/specularTexel.a, 0, 1) + reflectionTotal; + //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; diff --git a/resources/Shaders/ForwardPlusShieldCheck.frag.glsl b/resources/Shaders/ForwardPlusShieldCheck.frag.glsl index 35db495b..8c7dce04 100644 --- a/resources/Shaders/ForwardPlusShieldCheck.frag.glsl +++ b/resources/Shaders/ForwardPlusShieldCheck.frag.glsl @@ -1,6 +1,7 @@ #version 430 #define MIN_AMBIENT_LIGHT 0.3 +#define MAX_SPLITS 4 uniform mat4 M; uniform mat4 V; @@ -69,6 +70,7 @@ in VertexData{ vec2 TextureCoordinate; vec4 ExplosionColor; float ExplosionPercentageElapsed; + vec4 PositionLightSpace[MAX_SPLITS]; }Input; out vec4 sceneColor; diff --git a/resources/Shaders/ForwardPlusSkinned.vert.glsl b/resources/Shaders/ForwardPlusSkinned.vert.glsl index 83db983b..12b3c406 100644 --- a/resources/Shaders/ForwardPlusSkinned.vert.glsl +++ b/resources/Shaders/ForwardPlusSkinned.vert.glsl @@ -1,9 +1,13 @@ #version 430 +#define MAX_SPLITS 4 + uniform mat4 M; uniform mat4 V; uniform mat4 P; uniform mat4 Bones[100]; +uniform mat4 LightV[MAX_SPLITS]; +uniform mat4 LightP[MAX_SPLITS]; layout(location = 0) in vec3 Position; layout(location = 1) in vec3 Normal; @@ -44,5 +48,9 @@ void main() Output.BiTangent = vec3(M * vec4(BiTangent, 0.0)); Output.ExplosionColor = vec4(1.0); Output.ExplosionPercentageElapsed = 0.0; - Output.PositionLightSpace = boneTransform * vec4(Position, 1.0); + + for(int i = 0; i < MAX_SPLITS; i++) + { + Output.PositionLightSpace[i] = LightP[i] * LightV[i] * M * boneTransform * vec4(Position, 1.0); + } } \ No newline at end of file diff --git a/resources/Shaders/ForwardPlusSplatMap.frag.glsl b/resources/Shaders/ForwardPlusSplatMap.frag.glsl index 239c51b5..655f5502 100644 --- a/resources/Shaders/ForwardPlusSplatMap.frag.glsl +++ b/resources/Shaders/ForwardPlusSplatMap.frag.glsl @@ -1,5 +1,7 @@ #version 430 +#define MAX_SPLITS 4 + uniform mat4 M; uniform mat4 V; uniform mat4 P; @@ -95,6 +97,7 @@ in VertexData{ vec2 TextureCoordinate; vec4 ExplosionColor; float ExplosionPercentageElapsed; + vec4 PositionLightSpace[MAX_SPLITS]; }Input; out vec4 sceneColor; diff --git a/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl b/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl index 87349c5d..f933a605 100644 --- a/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl +++ b/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl @@ -1,6 +1,7 @@ #version 430 #define MIN_AMBIENT_LIGHT 0.3 +#define MAX_SPLITS 4 uniform mat4 M; uniform mat4 V; diff --git a/resources/Shaders/Shadow.frag.glsl b/resources/Shaders/Shadow.frag.glsl index a03e17c7..c7d153c3 100644 --- a/resources/Shaders/Shadow.frag.glsl +++ b/resources/Shaders/Shadow.frag.glsl @@ -19,6 +19,4 @@ void main() { discard; } -} - - +} \ No newline at end of file diff --git a/src/Engine/Editor/EditorRenderSystem.cpp b/src/Engine/Editor/EditorRenderSystem.cpp index a829bc6a..f5fcc1a1 100644 --- a/src/Engine/Editor/EditorRenderSystem.cpp +++ b/src/Engine/Editor/EditorRenderSystem.cpp @@ -7,7 +7,7 @@ EditorRenderSystem::EditorRenderSystem(SystemParams params, IRenderer* renderer, { EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &EditorRenderSystem::OnSetCamera); auto resolution = Rectangle::Rectangle(1280, 720); - m_EditorCamera = new Camera((float)resolution.Width / resolution.Height, glm::radians(45.f), 0.01f, 500.f); + m_EditorCamera = new Camera((float)resolution.Width / resolution.Height, glm::radians(45.f), 0.01f, 5000.f); } void EditorRenderSystem::Update(double dt) diff --git a/src/Engine/Editor/EditorSystem.cpp b/src/Engine/Editor/EditorSystem.cpp index 0aefac9d..4bee1427 100644 --- a/src/Engine/Editor/EditorSystem.cpp +++ b/src/Engine/Editor/EditorSystem.cpp @@ -17,10 +17,7 @@ EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame m_EditorCamera = importEntity(EntityWrapper(m_EditorWorld, EntityID_Invalid), "Schema/Entities/Empty.xml"); m_ActualCamera = m_EditorCamera; m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Transform"); - auto cCamera = m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Camera"); - // TOBIAS TVINGADE MIG ATT HÅRDKODA - (double&)cCamera["FarClip"] = 400.0; - + m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Camera"); m_EditorCameraInputController = new EditorCameraInputController(m_EventBroker, -1); m_EditorGUI = new EditorGUI(m_World, m_EventBroker); diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 6152134a..510c665e 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -4,10 +4,10 @@ DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCulling , m_LightCullingPass(lightCullingPass) , m_CubeMapPass(cubeMapPass) , m_SSAOPass(ssaoPass) + , m_ShadowPass(shadowPass) { //TODO: Make sure that uniforms are not sent into shader if not needed. m_ShieldPixelRate = 8; - m_ShadowPass = shadowPass; InitializeTextures(); InitializeShaderPrograms(); InitializeFrameBuffers(); @@ -343,7 +343,8 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, m_SSAOPass->SSAOTexture()); - glActiveTexture(GL_TEXTURE6); + + glActiveTexture(GL_TEXTURE13); if (m_ShadowPass->DepthMap() != NULL) { glBindTexture(GL_TEXTURE_2D_ARRAY, m_ShadowPass->DepthMap()); } @@ -1091,10 +1092,10 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptrGlowIntensity); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightP"), MAX_SPLITS, GL_FALSE, glm::value_ptr(*m_ShadowPass->LightP().data())); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightV"), MAX_SPLITS, GL_FALSE, glm::value_ptr(*m_ShadowPass->LightV().data())); glUniform1fv(glGetUniformLocation(shaderHandle, "FarDistance"), MAX_SPLITS, m_ShadowPass->FarDistance().data()); - GLERROR("END"); } @@ -1133,12 +1134,10 @@ void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptrGlowIntensity); - glUniform1f(Location_GlowIntensity, job->GlowIntensity); - - //Shadow - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightP"), MAX_SPLITS, GL_FALSE, glm::value_ptr(*m_ShadowPass->LightP().data())); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightV"), MAX_SPLITS, GL_FALSE, glm::value_ptr(*m_ShadowPass->LightV().data())); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightP"), MAX_SPLITS, GL_FALSE, glm::value_ptr(*m_ShadowPass->LightP().data())); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightV"), MAX_SPLITS, GL_FALSE, glm::value_ptr(*m_ShadowPass->LightV().data())); glUniform1fv(glGetUniformLocation(shaderHandle, "FarDistance"), MAX_SPLITS, m_ShadowPass->FarDistance().data()); GLERROR("END"); @@ -1309,7 +1308,6 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptrm_Texture); glUniform2fv(glGetUniformLocation(shaderHandle, "GlowUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f))); } - break; } case RawModel::MaterialType::SplatMapping: diff --git a/src/Engine/Rendering/FrameBuffer.cpp b/src/Engine/Rendering/FrameBuffer.cpp index 903eb2a0..c08d4dc4 100644 --- a/src/Engine/Rendering/FrameBuffer.cpp +++ b/src/Engine/Rendering/FrameBuffer.cpp @@ -16,6 +16,7 @@ Texture2D::~Texture2D() } } + RenderBuffer::~RenderBuffer() { if (m_ResourceHandle != 0) { @@ -51,7 +52,6 @@ void FrameBuffer::Generate() switch ((*it)->m_ResourceType) { case GL_TEXTURE_2D: glFramebufferTexture2D(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle, 0); - attachments.push_back((*it)->m_Attachment); GLERROR("FrameBuffer generate: glFramebufferTexture2D"); break; case GL_RENDERBUFFER: @@ -60,13 +60,13 @@ void FrameBuffer::Generate() break; case GL_TEXTURE_2D_ARRAY: glFramebufferTexture(GL_FRAMEBUFFER, (*it)->m_Attachment, *(*it)->m_ResourceHandle, 0); - attachments.push_back((*it)->m_Attachment); - GLERROR("FrameBuffer generate: GL_TEXTURE_2D_ARRAY"); + GLERROR("FrameBuffer generate: glFramebufferTexture2DArray"); break; } GLERROR("2"); - if ((*it)->m_Attachment != GL_DEPTH_ATTACHMENT && (*it)->m_Attachment != GL_STENCIL_ATTACHMENT && (*it)->m_Attachment != GL_DEPTH_STENCIL_ATTACHMENT) { + // Need GL_DEPTH_ATTACHMENT for shadows + if (/*(*it)->m_Attachment != GL_DEPTH_ATTACHMENT &&*/ (*it)->m_Attachment != GL_STENCIL_ATTACHMENT && (*it)->m_Attachment != GL_DEPTH_STENCIL_ATTACHMENT) { attachments.push_back((*it)->m_Attachment); } GLERROR("Attachment"); @@ -74,19 +74,19 @@ void FrameBuffer::Generate() } GLERROR("3"); - GLenum* bufferTextures = &attachments[0]; - glDrawBuffers(attachments.size(), bufferTextures); - if (GLERROR("GLBufferAttachement error")) { - printf(": AttachmentSize %i", attachments.size()); - } + GLenum* bufferTextures = &attachments[0]; + glDrawBuffers(attachments.size(), bufferTextures); + if (GLERROR("GLBufferAttachement error")) { + printf(": AttachmentSize %i", attachments.size()); + } + + if (GLenum frameBufferStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { + GLERROR("Framebuffer incomplete"); + //LOG_ERROR("FrameBuffer incomplete: 0x%x\n", frameBufferStatus); + exit(EXIT_FAILURE); + } + GLERROR("END"); - if (GLenum frameBufferStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { - GLERROR("Framebuffer incomplete"); - //LOG_ERROR("FrameBuffer incomplete: 0x%x\n", frameBufferStatus); - exit(EXIT_FAILURE); - } - GLERROR("END"); - } } void FrameBuffer::Bind() diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index 5de7bb51..a1f00c88 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -12,7 +12,7 @@ RenderSystem::RenderSystem(SystemParams params, const IRenderer* renderer, Rende EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &RenderSystem::OnInputCommand); EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &RenderSystem::OnPlayerSpawned); - m_Camera = new Camera((float)m_Renderer->Resolution().Width / m_Renderer->Resolution().Height, glm::radians(45.f), 0.01f, 300.f); + m_Camera = new Camera((float)m_Renderer->Resolution().Width / m_Renderer->Resolution().Height, glm::radians(45.f), 0.01f, 5000.f); } RenderSystem::~RenderSystem() diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index 748caec2..b9a6aa05 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -86,6 +86,11 @@ void Renderer::InitializeShaders() { m_BasicForwardProgram = ResourceManager::Load("#m_BasicForwardProgram"); m_ExplosionEffectProgram = ResourceManager::Load("#ExplosionEffectProgram"); + //m_ExplosionEffectProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/ExplosionEffect.vert.glsl"))); + //m_ExplosionEffectProgram->AddShader(std::shared_ptr(new GeometryShader("Shaders/ExplosionEffect.geom.glsl"))); + //m_ExplosionEffectProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/ExplosionEffect.frag.glsl"))); + //m_ExplosionEffectProgram->Compile(); + //m_ExplosionEffectProgram->Link(); } void Renderer::InputUpdate(double dt) @@ -127,8 +132,9 @@ void Renderer::Draw(RenderFrame& frame) m_PickingPass->ClearPicking(); m_DrawFinalPass->ClearBuffer(); m_DrawBloomPass->ClearBuffer(); - m_ShadowPass->ClearBuffer(); m_SSAOPass->ClearBuffer(); + m_ShadowPass->ClearBuffer(); + m_ShadowPass->DebugGUI(); PerformanceTimer::StopTimer("Renderer-ClearBuffers"); GLERROR("ClearBuffers"); for (auto scene : frame.RenderScenes) { @@ -144,7 +150,9 @@ void Renderer::Draw(RenderFrame& frame) PerformanceTimer::StartTimer("Renderer-Depth"); SortRenderJobsByDepth(*scene); GLERROR("SortByDepth"); - m_ShadowPass->Draw(*scene); + PerformanceTimer::StartTimerAndStopPrevious("Draw shadow maps"); + m_ShadowPass->Draw(*scene); + GLERROR("Draw shadow maps"); PerformanceTimer::StartTimerAndStopPrevious("Renderer-Generate Frustrums"); m_LightCullingPass->GenerateNewFrustum(*scene); GLERROR("Generate frustums"); @@ -187,7 +195,7 @@ void Renderer::Draw(RenderFrame& frame) } if (m_DebugTextureToDraw == 4) { m_DrawScreenQuadPass->Draw(m_PickingPass->PickingTexture()); - } + } if (m_DebugTextureToDraw == 5) { m_DrawScreenQuadPass->Draw(m_SSAOPass->SSAOTexture()); } @@ -239,9 +247,9 @@ void Renderer::InitializeRenderPasses() { m_PickingPass = new PickingPass(this, m_EventBroker); m_LightCullingPass = new LightCullingPass(this); - m_ShadowPass = new ShadowPass(this); m_CubeMapPass = new CubeMapPass(this); m_SSAOPass = new SSAOPass(this, m_Config); + m_ShadowPass = new ShadowPass(this); m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass, m_SSAOPass, m_ShadowPass); m_DrawScreenQuadPass = new DrawScreenQuadPass(this); m_DrawBloomPass = new DrawBloomPass(this, m_Config); diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp index d7741dff..daf63ef2 100644 --- a/src/Engine/Rendering/ShadowPass.cpp +++ b/src/Engine/Rendering/ShadowPass.cpp @@ -1,6 +1,5 @@ #include "Rendering/ShadowPass.h" - ShadowPass::ShadowPass(IRenderer * renderer, int shadow_res_x, int shadow_res_y) { m_Renderer = renderer; @@ -24,6 +23,15 @@ ShadowPass::~ShadowPass() } +void ShadowPass::DebugGUI() +{ + ImGui::Checkbox("EnableShadows", &m_EnableShadows); + ImGui::DragFloat2("ShadowMapNearFar", m_NearFarPlane, 1.f, -1000.f, 1000.f); + ImGui::DragFloat("ShadowClippingWeight", &m_SplitWeight, 0.001f, 0.f, 1.f); + ImGui::Checkbox("ShadowTransparentObjects", &m_TransparentObjects); + ImGui::Checkbox("ShadowOnTextureAlphas", &m_TexturedShadows); +} + void ShadowPass::InitializeCameras(RenderScene & scene) { for (int i = 0; i < m_CurrentNrOfSplits; i++) { @@ -198,101 +206,100 @@ void ShadowPass::RadiusToLightspace(ShadowFrustum& frustum) void ShadowPass::Draw(RenderScene & scene) { - ImGui::DragFloat2("ShadowMapNearFar", m_NearFarPlane, 1.f, -1000.f, 1000.f); - ImGui::DragFloat("ShadowClippingWeight", &m_SplitWeight, 0.001f, 0.f, 1.f); + if (m_EnableShadows) { + InitializeCameras(scene); + UpdateSplitDist(m_shadowFrusta, scene.Camera->NearClip(), scene.Camera->FarClip()); - InitializeCameras(scene); - UpdateSplitDist(m_shadowFrusta, scene.Camera->NearClip(), scene.Camera->FarClip()); + ShadowPassState* state = new ShadowPassState(m_DepthBuffer.GetHandle()); - ShadowPassState* state = new ShadowPassState(m_DepthBuffer.GetHandle()); + m_ShadowProgram->Bind(); + GLuint shaderHandle = m_ShadowProgram->GetHandle(); + glViewport(0, 0, m_ResolutionSizeWidth, m_ResolutionSizeHeight); - m_ShadowProgram->Bind(); - GLuint shaderHandle = m_ShadowProgram->GetHandle(); - glViewport(0, 0, m_ResolutionSizeWidth, m_ResolutionSizeHeight); + for (int i = 0; i < m_CurrentNrOfSplits; i++) { + UpdateFrustumPoints(m_shadowFrusta[i], scene.Camera->Position(), scene.Camera->Forward()); - for (int i = 0; i < m_CurrentNrOfSplits; i++) { - UpdateFrustumPoints(m_shadowFrusta[i], scene.Camera->Position(), scene.Camera->Forward()); + glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_DepthMap, 0, i); - glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_DepthMap, 0, i); + for (auto &job : scene.Jobs.DirectionalLight) { + auto directionalLightJob = std::dynamic_pointer_cast(job); - for (auto &job : scene.Jobs.DirectionalLight) { - auto directionalLightJob = std::dynamic_pointer_cast(job); + if (directionalLightJob) { + m_LightView[i] = glm::lookAt(glm::vec3(-directionalLightJob->Direction) + m_shadowFrusta[i].MiddlePoint, m_shadowFrusta[i].MiddlePoint, glm::vec3(0.f, 1.f, 0.f)); - if (directionalLightJob) { - m_LightView[i] = glm::lookAt(glm::vec3(-directionalLightJob->Direction) + m_shadowFrusta[i].MiddlePoint, m_shadowFrusta[i].MiddlePoint, glm::vec3(0.f, 1.f, 0.f)); + PointsToLightspace(m_shadowFrusta[i], m_LightView[i]); + //FindRadius(m_shadowFrusta[i]); + //RadiusToLightspace(m_shadowFrusta[i]); + m_LightProjection[i] = glm::ortho(m_shadowFrusta[i].LRBT[LEFT], m_shadowFrusta[i].LRBT[RIGHT], m_shadowFrusta[i].LRBT[BOTTOM], m_shadowFrusta[i].LRBT[TOP], m_NearFarPlane[NEAR], m_NearFarPlane[FAR]); - PointsToLightspace(m_shadowFrusta[i], m_LightView[i]); - //FindRadius(m_shadowFrusta[i]); - //RadiusToLightspace(m_shadowFrusta[i]); - m_LightProjection[i] = glm::ortho(m_shadowFrusta[i].LRBT[LEFT], m_shadowFrusta[i].LRBT[RIGHT], m_shadowFrusta[i].LRBT[BOTTOM], m_shadowFrusta[i].LRBT[TOP], m_NearFarPlane[NEAR], m_NearFarPlane[FAR]); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection[i])); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView[i])); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection[i])); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView[i])); + GLERROR("ShadowLight ERROR"); - GLERROR("ShadowLight ERROR"); + for (auto &objectJob : scene.Jobs.OpaqueObjects) { + if (!std::dynamic_pointer_cast(objectJob)) { + auto modelJob = std::dynamic_pointer_cast(objectJob); - for (auto &objectJob : scene.Jobs.OpaqueObjects) { - if (!std::dynamic_pointer_cast(objectJob)) - { - auto modelJob = std::dynamic_pointer_cast(objectJob); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); + glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), 1.f); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); + 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))); - 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("Shadow Draw ERROR"); + GLERROR("Shadow Draw ERROR"); + } } - } + if (m_TransparentObjects) { + state->CullFace(GL_BACK); + for (auto &objectJob : scene.Jobs.TransparentObjects) { + if (!std::dynamic_pointer_cast(objectJob)) { + auto modelJob = std::dynamic_pointer_cast(objectJob); - state->CullFace(GL_BACK); - for (auto &objectJob : scene.Jobs.TransparentObjects) { - if (!std::dynamic_pointer_cast(objectJob)) - { - auto modelJob = std::dynamic_pointer_cast(objectJob); + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); + glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), modelJob->Color.a); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); - glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), modelJob->Color.a); - - if (directionalLightJob->TextureAlphaShadows) { - switch (modelJob->Type) { - case RawModel::MaterialType::SingleTextures: - case RawModel::MaterialType::Basic: - { - glActiveTexture(GL_TEXTURE24); - if (modelJob->DiffuseTexture.size() > 0 && modelJob->DiffuseTexture[0]->Texture != nullptr) { - glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture[0]->Texture->m_Texture); - glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(modelJob->DiffuseTexture[0]->UVRepeat)); + if (m_TexturedShadows) { + switch (modelJob->Type) { + case RawModel::MaterialType::SingleTextures: + case RawModel::MaterialType::Basic: + { + glActiveTexture(GL_TEXTURE24); + if (modelJob->DiffuseTexture.size() > 0 && modelJob->DiffuseTexture[0]->Texture != nullptr) { + glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture[0]->Texture->m_Texture); + glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(modelJob->DiffuseTexture[0]->UVRepeat)); + } + else { + glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); + glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f))); + } + break; + } + case RawModel::MaterialType::SplatMapping: + { + glActiveTexture(GL_TEXTURE24); + glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); + glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f))); + break; + } + } } - else { - glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); - glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f))); - } - break; - } - case RawModel::MaterialType::SplatMapping: - { - glActiveTexture(GL_TEXTURE24); - glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); - glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f))); - break; - } + + 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("Shadow Draw ERROR"); } } - - 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("Shadow Draw ERROR"); + state->CullFace(GL_FRONT); } } - state->CullFace(GL_FRONT); } } + glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); + m_DepthBuffer.Unbind(); + delete state; } - glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); - m_DepthBuffer.Unbind(); - delete state; -} +} \ No newline at end of file diff --git a/src/Engine/Rendering/ShadowPassState.cpp b/src/Engine/Rendering/ShadowPassState.cpp index ef789487..2211e3ab 100644 --- a/src/Engine/Rendering/ShadowPassState.cpp +++ b/src/Engine/Rendering/ShadowPassState.cpp @@ -2,10 +2,10 @@ ShadowPassState::ShadowPassState(GLuint frameBuffer) { - BindFramebuffer(frameBuffer); - Enable(GL_DEPTH_TEST); - Enable(GL_CULL_FACE); - Disable(GL_BLEND); + BindFramebuffer(frameBuffer); + Enable(GL_DEPTH_TEST); + Enable(GL_CULL_FACE); + Disable(GL_BLEND); Disable(GL_TEXTURE_2D); CullFace(GL_FRONT); ClearColor(glm::vec4(0.f, 0.f, 0.f, 0.f)); From 9d4441852c5d27d727c17f761679d9ce08028e0f Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 3 Mar 2016 03:39:00 +0100 Subject: [PATCH 175/252] DefenderWeapon view punch and crosshair travel with return --- assets | 2 +- .../Systems/Weapon/DefenderWeaponBehaviour.h | 2 + .../Schema/Components/DefenderWeapon.xml | 5 +- .../Schema/Components/DefenderWeapon.xsd | 7 +++ resources/Schema/Entities/MovementTest.xml | 12 ++-- resources/Schema/Entities/Player.xml | 13 ++-- .../Weapon/DefenderWeaponBehaviour.cpp | 59 ++++++++++++++++++- .../Systems/Weapon/SidearmWeaponBehaviour.cpp | 2 - 8 files changed, 83 insertions(+), 19 deletions(-) diff --git a/assets b/assets index 72530423..b8baf48e 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 72530423ad3744341f42cbfdcba18295a2cfac90 +Subproject commit b8baf48e5ee88ddb7d9bd818e31e3a52d96daec5 diff --git a/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h b/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h index c1e132b1..77d579f8 100644 --- a/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h +++ b/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h @@ -1,6 +1,7 @@ #include "WeaponBehaviour.h" #include "Collision/Collision.h" #include "Core/EPlayerDamage.h" +#include "Sound/EPlaySoundOnEntity.h" class DefenderWeaponBehaviour : public WeaponBehaviour { @@ -16,6 +17,7 @@ public: void OnPrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) override; void OnCeasePrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) override; void OnReload(ComponentWrapper cWeapon, WeaponInfo& wi) override; + void OnHolster(ComponentWrapper cWeapon, WeaponInfo& wi) override; bool OnInputCommand(ComponentWrapper cWeapon, WeaponInfo& wi, const Events::InputCommand& e) override; private: diff --git a/resources/Schema/Components/DefenderWeapon.xml b/resources/Schema/Components/DefenderWeapon.xml index 1b336fc4..68b87759 100755 --- a/resources/Schema/Components/DefenderWeapon.xml +++ b/resources/Schema/Components/DefenderWeapon.xml @@ -6,13 +6,16 @@ 64 90 0.174533 + 0.174533 10 120 - 0.01 + 0.03 + 0.2 0.5 false 0 false 0 + 0 \ No newline at end of file diff --git a/resources/Schema/Components/DefenderWeapon.xsd b/resources/Schema/Components/DefenderWeapon.xsd index c1b98e2f..d2b503f8 100755 --- a/resources/Schema/Components/DefenderWeapon.xsd +++ b/resources/Schema/Components/DefenderWeapon.xsd @@ -37,6 +37,9 @@ Spread angle in radians + + Maximum vertical aim travel angle in radians + Rate of fire in rounds per minute @@ -44,6 +47,9 @@ View punch in radians for each shell fired + + The speed in radians per second the view returns to its original position after being punched + Time it takes to load ONE SHELL into the weapon in seconds @@ -52,6 +58,7 @@ + diff --git a/resources/Schema/Entities/MovementTest.xml b/resources/Schema/Entities/MovementTest.xml index 41474568..3429194a 100644 --- a/resources/Schema/Entities/MovementTest.xml +++ b/resources/Schema/Entities/MovementTest.xml @@ -26,7 +26,7 @@ - Models/Characters/Assault/AssaultTPose.mesh + Models/Characters/Assault/AssaultRed.mesh @@ -39,7 +39,7 @@ - Models/Characters/Assault/AssaultTPose.mesh + Models/Characters/Assault/AssaultRed.mesh @@ -94,11 +94,11 @@ - Models/Characters/Assault/AssaultTPose.mesh + Models/Characters/Assault/AssaultBlue.mesh - + @@ -107,11 +107,11 @@ - Models/Characters/Assault/AssaultTPose.mesh + Models/Characters/Assault/AssaultBlue.mesh - + diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index e0230582..1ee9d5d3 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -458,7 +458,7 @@ - Models/Characters/Assault/FirstPerson.mesh + Models/Characters/Assault/Test/FirstPerson.mesh @@ -524,8 +524,7 @@ - Idle - 0.013134522267137072 + IdleF 1 @@ -537,8 +536,8 @@ - Models/Characters/Assault/AssaultAnimations.mesh - + Models/Characters/Assault/AssaultBlue.mesh + @@ -573,8 +572,8 @@ Schema/Entities/SidearmWeaponWorld.xml - - + + diff --git a/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp b/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp index 4c0f9673..50d5889d 100644 --- a/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp @@ -10,9 +10,11 @@ void DefenderWeaponBehaviour::UpdateComponent(EntityWrapper& entity, ComponentWr void DefenderWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& wi, double dt) { + // Decrement reload timer double& reloadTimer = cWeapon["ReloadTimer"]; reloadTimer = glm::max(0.0, reloadTimer - dt); + // Handle reloading double reloadTime = cWeapon["ReloadTime"]; bool& isReloading = cWeapon["IsReloading"]; if (isReloading && reloadTimer <= 0.0) { @@ -23,11 +25,31 @@ void DefenderWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& ammo -= 1; magAmmo += 1; reloadTimer = reloadTime; + Events::PlaySoundOnEntity e; + e.EmitterID = wi.Player.ID; + e.FilePath = "Audio/weapon/Zoom.wav"; + m_EventBroker->Publish(e); } else { isReloading = false; } } + // Restore view angle + if (IsClient) { + float& currentTravel = cWeapon["CurrentTravel"]; + float& returnSpeed = cWeapon["ViewReturnSpeed"]; + if (currentTravel > 0) { + float change = returnSpeed * dt; + currentTravel = glm::max(0.f, currentTravel - change); + EntityWrapper camera = wi.Player.FirstChildByName("Camera"); + if (camera.Valid()) { + glm::vec3& cameraOrientation = camera["Transform"]["Orientation"]; + cameraOrientation.x -= change; + } + } + } + + // Fire if we're able to fire if (canFire(cWeapon, wi)) { fireShell(cWeapon, wi); } @@ -71,6 +93,16 @@ void DefenderWeaponBehaviour::OnReload(ComponentWrapper cWeapon, WeaponInfo& wi) reloadTimer = reloadTime; } +void DefenderWeaponBehaviour::OnHolster(ComponentWrapper cWeapon, WeaponInfo& wi) +{ + // Make sure the trigger is released if weapon is holstered while firing + cWeapon["TriggerHeld"] = false; + + // Cancel any reload + cWeapon["IsReloading"] = false; + cWeapon["ReloadTimer"] = 0.0; +} + bool DefenderWeaponBehaviour::OnInputCommand(ComponentWrapper cWeapon, WeaponInfo& wi, const Events::InputCommand& e) { if (e.Command == "SpecialAbility" && IsServer) { @@ -114,11 +146,29 @@ void DefenderWeaponBehaviour::fireShell(ComponentWrapper cWeapon, WeaponInfo& wi std::vector pelletAngles; for (int i = 0; i < numPellets; i++) { pelletAngles.push_back(glm::vec2(randomSpreadAngle(m_RandomEngine), randomSpreadAngle(m_RandomEngine))); - LOG_DEBUG("%f %f", pelletAngles[i].x, pelletAngles[i].y); } double pelletDamage = (double)cWeapon["BaseDamage"] / numPellets; + // View punch + if (IsClient) { + EntityWrapper camera = wi.Player.FirstChildByName("Camera"); + if (camera.Valid()) { + glm::vec3& cameraOrientation = camera["Transform"]["Orientation"]; + float viewPunch = cWeapon["ViewPunch"]; + float maxTravelAngle = cWeapon["MaxTravelAngle"]; + float& currentTravel = cWeapon["CurrentTravel"]; + if (currentTravel < maxTravelAngle) { + float change = viewPunch; + if (currentTravel + change > maxTravelAngle) { + change = maxTravelAngle - currentTravel; + } + cameraOrientation.x += change; + currentTravel += change; + } + } + } + // Tracers EntityWrapper weaponModelEntity; if (wi.Player == LocalPlayer) { @@ -140,6 +190,12 @@ void DefenderWeaponBehaviour::fireShell(ComponentWrapper cWeapon, WeaponInfo& wi dealDamage(cWeapon, wi, direction, pelletDamage); } } + + // Sound + Events::PlaySoundOnEntity e; + e.EmitterID = wi.Player.ID; + e.FilePath = "Audio/weapon/Blast.wav"; + m_EventBroker->Publish(e); } void DefenderWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi, glm::vec3 direction, double damage) @@ -206,7 +262,6 @@ bool DefenderWeaponBehaviour::canFire(ComponentWrapper cWeapon, WeaponInfo& wi) bool triggerHeld = cWeapon["TriggerHeld"]; bool cooldownPassed = (double)cWeapon["FireCooldown"] <= 0.0; bool isNotShielding = wi.Player.ChildrenWithComponent("Shield").size() == 0; - // TODO: Ammo checks return triggerHeld && cooldownPassed && isNotShielding; } diff --git a/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp b/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp index 9a3ed6ab..d32b7d7e 100644 --- a/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/SidearmWeaponBehaviour.cpp @@ -45,8 +45,6 @@ void SidearmWeaponBehaviour::OnHolster(ComponentWrapper cWeapon, WeaponInfo& wi) // Cancel any reload cWeapon["IsReloading"] = false; cWeapon["ReloadTimer"] = 0.0; - - LOG_DEBUG("HOLSTER"); } void SidearmWeaponBehaviour::fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi) From 27d3ec4118e3d8508ba46633e49ee96ec2b37947 Mon Sep 17 00:00:00 2001 From: Tleety Date: Thu, 3 Mar 2016 09:49:20 +0100 Subject: [PATCH 176/252] Added some fields in score components to track more data. Added some logic to the ScoreSystem class --- include/Game/Systems/ScoreScreenSystem.h | 15 +++++- resources/Schema/Components/ScoreIdentity.xml | 7 +++ resources/Schema/Components/ScoreIdentity.xsd | 6 +++ resources/Schema/Components/ScoreScreen.xml | 2 + resources/Schema/Components/ScoreScreen.xsd | 11 +++-- src/Game/Systems/ScoreScreenSystem.cpp | 47 ++++++++++++++++++- 6 files changed, 81 insertions(+), 7 deletions(-) diff --git a/include/Game/Systems/ScoreScreenSystem.h b/include/Game/Systems/ScoreScreenSystem.h index b65d9465..ec95d6a2 100644 --- a/include/Game/Systems/ScoreScreenSystem.h +++ b/include/Game/Systems/ScoreScreenSystem.h @@ -14,9 +14,20 @@ public: virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) override; EventRelay m_EPlayerDeath; - void OnPlayerDeath(const Events::PlayerDeath& e); + bool OnPlayerDeath(const Events::PlayerDeath& e); EventRelay m_EPlayerSpawned; - void OnPlayerSpawn(const Events::PlayerSpawned& e); + bool OnPlayerSpawn(const Events::PlayerSpawned& e); + +private: + struct PlayerData { + int ID = -1; + std::string Name = ""; + int Team = -1; + EntityWrapper Player = EntityWrapper::Invalid; + }; + + int m_PlayerCounter = 0; + std::unordered_map m_PlayerIdentities; }; #endif \ No newline at end of file diff --git a/resources/Schema/Components/ScoreIdentity.xml b/resources/Schema/Components/ScoreIdentity.xml index 95478277..a4aa0639 100644 --- a/resources/Schema/Components/ScoreIdentity.xml +++ b/resources/Schema/Components/ScoreIdentity.xml @@ -1,3 +1,10 @@ + + -1 + 0.0 + 0 + 0 + 0 + true \ No newline at end of file diff --git a/resources/Schema/Components/ScoreIdentity.xsd b/resources/Schema/Components/ScoreIdentity.xsd index 9ed69918..5ab80c22 100644 --- a/resources/Schema/Components/ScoreIdentity.xsd +++ b/resources/Schema/Components/ScoreIdentity.xsd @@ -4,6 +4,9 @@ A component tracking data for the score of a player. + + A unique id for tracking identities + The Kills per death score. @@ -16,5 +19,8 @@ Ping of a player. + + If the player is currently connected or not + \ No newline at end of file diff --git a/resources/Schema/Components/ScoreScreen.xml b/resources/Schema/Components/ScoreScreen.xml index 646002c4..65d84aa6 100644 --- a/resources/Schema/Components/ScoreScreen.xml +++ b/resources/Schema/Components/ScoreScreen.xml @@ -1,3 +1,5 @@ + 0 + 0 \ No newline at end of file diff --git a/resources/Schema/Components/ScoreScreen.xsd b/resources/Schema/Components/ScoreScreen.xsd index 387140f2..d07b4a19 100644 --- a/resources/Schema/Components/ScoreScreen.xsd +++ b/resources/Schema/Components/ScoreScreen.xsd @@ -1,10 +1,13 @@ - - - The screen where player scores will be shown. - + The screen where player scores will be shown. + + The amount of score identities this scoreboard hold + + + Where the next scoreIdentity should be placed. + \ No newline at end of file diff --git a/src/Game/Systems/ScoreScreenSystem.cpp b/src/Game/Systems/ScoreScreenSystem.cpp index 37dccb20..c66bdb2d 100644 --- a/src/Game/Systems/ScoreScreenSystem.cpp +++ b/src/Game/Systems/ScoreScreenSystem.cpp @@ -11,7 +11,30 @@ ScoreScreenSystem::ScoreScreenSystem(SystemParams params) void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) { - //Logic here + if(!entity.Valid() || !entity.HasComponent("ScoreScreen")){ + return; + } + + auto children = entity.ChildrenWithComponent("ScoreIdentity"); + + for (auto it = m_PlayerIdentities.begin(); it != m_PlayerIdentities.end(); ++it) { + bool found = false; + for (auto child : children) { + std::string name = (std::string)child["ScoreIdentity"]["Name"]; + if (it->first == name) { + found = true; + break; + } + } + if(found == false) { + //There is no entry for this player, create one. + + } + } + //For each scoreboard, go through children and see if they have all of the ones needed. + //Also need to take into account the order so they dont flicker. + //If they do not have all children we need to add them. + //Just add a new component to the scorescreen entity, the "ScoreIdentity" component. } void ScoreScreenSystem::OnPlayerDeath(const Events::PlayerDeath& e) @@ -22,4 +45,26 @@ void ScoreScreenSystem::OnPlayerDeath(const Events::PlayerDeath& e) void ScoreScreenSystem::OnPlayerSpawn(const Events::PlayerSpawned& e) { //When a player spawn, add a new entry to the score screen. + if(!e.Player.Valid()) { + return; + } + EntityWrapper entity = e.Player; + + std::unordered_map::const_iterator got; + got = m_PlayerIdentities.find(e.PlayerName); + if (got == m_PlayerIdentities.end()) { + PlayerData data; + data.ID = m_PlayerCounter; + data.Name = e.PlayerName; + data.Player = e.Player; + if(!entity.HasComponent("Team")) { + return; + } + data.Team = (int)entity["Team"]["Team"]; + + std::pair list (data.Name, data); + m_PlayerIdentities.insert(list); + m_PlayerCounter++; + } + } From ff6e2167d4d4a81b21443f1439dd8907bd915421 Mon Sep 17 00:00:00 2001 From: Tleety Date: Thu, 3 Mar 2016 11:25:06 +0100 Subject: [PATCH 177/252] Some new events and changes to ScoreSystem --- include/Engine/Network/EPlayerConnected.h | 17 + include/Engine/Network/Server.h | 1 + include/Game/Systems/ScoreScreenSystem.h | 8 + resources/Schema/Components/ScoreIdentity.xsd | 44 +- resources/Schema/Components/ScoreScreen.xsd | 16 +- resources/Schema/Entities/CP_Rocky.xml | 2105 ++++++++--------- resources/Schema/Entities/ScoreIdentity.xml | 98 + src/Engine/Network/Server.cpp | 5 + src/Game/Game.cpp | 2 + src/Game/Systems/ScoreScreenSystem.cpp | 39 +- 10 files changed, 1251 insertions(+), 1084 deletions(-) create mode 100644 include/Engine/Network/EPlayerConnected.h create mode 100644 resources/Schema/Entities/ScoreIdentity.xml diff --git a/include/Engine/Network/EPlayerConnected.h b/include/Engine/Network/EPlayerConnected.h new file mode 100644 index 00000000..8c12dd3d --- /dev/null +++ b/include/Engine/Network/EPlayerConnected.h @@ -0,0 +1,17 @@ +#ifndef Events_PlayerConnected +#define Events_PlayerConnected + +#include "Core/EventBroker.h" + +namespace Events +{ + +struct PlayerConnected : public Event +{ + std::string PlayerName = ""; + int PlayerID = -1; +}; + +} +#endif // !Events_PlayerConnected + diff --git a/include/Engine/Network/Server.h b/include/Engine/Network/Server.h index 7bcefc65..6ccbb4bd 100644 --- a/include/Engine/Network/Server.h +++ b/include/Engine/Network/Server.h @@ -21,6 +21,7 @@ #include "Core/EEntityDeleted.h" #include "Core/EComponentDeleted.h" #include "Core/EAmmoPickup.h" +#include "Network/EPlayerConnected.h" class Server : public Network { diff --git a/include/Game/Systems/ScoreScreenSystem.h b/include/Game/Systems/ScoreScreenSystem.h index ec95d6a2..7f7c4064 100644 --- a/include/Game/Systems/ScoreScreenSystem.h +++ b/include/Game/Systems/ScoreScreenSystem.h @@ -2,8 +2,12 @@ #define ScoreScreenSystem_h__ #include "Core/System.h" +#include "Core/ResourceManager.h" +#include "Core/EntityFile.h" #include "Core/EPlayerDeath.h" #include "Core/EPlayerSpawned.h" +#include "Network/EPlayerConnected.h" +#include "Network/EPlayerDisconnected.h" #include "GLM.h" class ScoreScreenSystem : public PureSystem @@ -17,6 +21,10 @@ public: bool OnPlayerDeath(const Events::PlayerDeath& e); EventRelay m_EPlayerSpawned; bool OnPlayerSpawn(const Events::PlayerSpawned& e); + EventRelay m_EPlayerConnected; + bool OnPlayerConnected(const Events::PlayerConnected& e); + EventRelay m_EPlayerDisconnected; + bool OnPlayerDisconnected(const Events::PlayerDisconnected& e); private: struct PlayerData { diff --git a/resources/Schema/Components/ScoreIdentity.xsd b/resources/Schema/Components/ScoreIdentity.xsd index 5ab80c22..d1a85bee 100644 --- a/resources/Schema/Components/ScoreIdentity.xsd +++ b/resources/Schema/Components/ScoreIdentity.xsd @@ -3,24 +3,30 @@ A component tracking data for the score of a player. - - - A unique id for tracking identities - - - The Kills per death score. - - - The amount of kills. - - - The amount of deaths. - - - Ping of a player. - - - If the player is currently connected or not - + + + + A name for tracking score identities, this should be unique. + + + An id for tracking identities + + + The Kills per death score. + + + The amount of kills. + + + The amount of deaths. + + + Ping of a player. + + + If the player is currently connected or not + + + \ No newline at end of file diff --git a/resources/Schema/Components/ScoreScreen.xsd b/resources/Schema/Components/ScoreScreen.xsd index d07b4a19..c8d3fa59 100644 --- a/resources/Schema/Components/ScoreScreen.xsd +++ b/resources/Schema/Components/ScoreScreen.xsd @@ -3,11 +3,15 @@ The screen where player scores will be shown. - - The amount of score identities this scoreboard hold - - - Where the next scoreIdentity should be placed. - + + + + The amount of score identities this scoreboard hold + + + Where the next scoreIdentity should be placed. + + + \ No newline at end of file diff --git a/resources/Schema/Entities/CP_Rocky.xml b/resources/Schema/Entities/CP_Rocky.xml index 8617886f..0adcbe6e 100644 --- a/resources/Schema/Entities/CP_Rocky.xml +++ b/resources/Schema/Entities/CP_Rocky.xml @@ -29,6 +29,26 @@ + + + + + Models/Props/Walls/SciFiWallSmall1.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall2.mesh + + + + + @@ -62,26 +82,6 @@ - - - - - Models/Props/Walls/SciFiWallSmall1.mesh - - - - - - - - - - Models/Props/Walls/SciFiWallSmall2.mesh - - - - - @@ -116,7 +116,6 @@ - Models/Core/UnitCube.mesh @@ -132,8 +131,8 @@ - - + + @@ -599,6 +598,36 @@ + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + @@ -775,36 +804,6 @@ - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - @@ -828,11 +827,11 @@ 2 - + - + @@ -849,7 +848,7 @@ - + @@ -875,11 +874,11 @@ 2 - + - + @@ -896,7 +895,7 @@ - + @@ -922,11 +921,11 @@ 2 - + - + @@ -943,7 +942,7 @@ - + @@ -969,11 +968,11 @@ 2 - + - + @@ -990,7 +989,7 @@ - + @@ -1016,11 +1015,11 @@ 2 - + - + @@ -1037,7 +1036,7 @@ - + @@ -1063,11 +1062,11 @@ 2 - + - + @@ -1084,7 +1083,7 @@ - + @@ -1110,11 +1109,11 @@ 2 - + - + @@ -1131,7 +1130,7 @@ - + @@ -2379,11 +2378,11 @@ 2 - + - + @@ -2400,7 +2399,7 @@ - + @@ -2426,11 +2425,11 @@ 2 - + - + @@ -2447,7 +2446,7 @@ - + @@ -2694,6 +2693,679 @@ + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + @@ -3234,147 +3906,6 @@ - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - 2 - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - 2 - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - 2 - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - @@ -3391,11 +3922,11 @@ 2 - + - + @@ -3412,7 +3943,7 @@ - + @@ -3428,55 +3959,8 @@ Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - 2 - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - + + @@ -3485,11 +3969,11 @@ 2 - + - + @@ -3506,7 +3990,7 @@ - + @@ -3532,11 +4016,11 @@ 2 - + - + @@ -3553,7 +4037,195 @@ - + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + @@ -3565,679 +4237,6 @@ - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridge1Blue.mesh - - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridge1Blue.mesh - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridge1Blue.mesh - - - - - - - - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - - - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - - Models/Core/UnitPlane.mesh - - true - - - - - - - - - @@ -4486,6 +4485,76 @@ + + + + + Schema/Entities/PlayerRed.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + @@ -4510,7 +4579,7 @@ false - + @@ -4523,7 +4592,7 @@ false - + @@ -4561,37 +4630,6 @@ - - - - 1 - - - - - - - - - 10 - - - - - - - - - - - 10 - - - - - - - @@ -4603,14 +4641,34 @@ + + + + 1 + + + + + - + 10 - + + + + + + + + + 10 + + + @@ -4629,81 +4687,22 @@ - 10 - + - - - - - - - Schema/Entities/PlayerRed.xml - - - - - - - - - - - - + - - - Models/Characters/Assault/AssaultTPose.mesh - false - + + + 10 + - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - + diff --git a/resources/Schema/Entities/ScoreIdentity.xml b/resources/Schema/Entities/ScoreIdentity.xml new file mode 100644 index 00000000..7d1e2437 --- /dev/null +++ b/resources/Schema/Entities/ScoreIdentity.xml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + Simon needs to push shit shit so i can write text from Component + Fonts/DroidSans.ttf,64 + + + + + + + + + + + ID + Fonts/DroidSans.ttf,64 + + + + + + + + + + + DickButt + Fonts/DroidSans.ttf,64 + + + + + + + + + + + 5 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + 12 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + 0.42 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + 84 + Fonts/DroidSans.ttf,64 + + + + + + + + + + diff --git a/src/Engine/Network/Server.cpp b/src/Engine/Network/Server.cpp index 68c00fbe..71889379 100644 --- a/src/Engine/Network/Server.cpp +++ b/src/Engine/Network/Server.cpp @@ -363,6 +363,11 @@ void Server::parseTCPConnect(Packet & packet) m_ConnectedPlayers.at(playerID).TCPAddress = m_Address; m_ConnectedPlayers.at(playerID).TCPPort = m_Port; + Events::PlayerConnected e; + e.PlayerID = playerID; + e.PlayerName = m_ConnectedPlayers.at(playerID).Name; + m_EventBroker->Publish(e); + LOG_INFO("parseTCPConnect: Spectator \"%s\" connected on IP: %s", m_ConnectedPlayers.at(playerID).Name.c_str(), m_ConnectedPlayers.at(playerID).TCPAddress.to_string().c_str()); diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index ab4b9652..e2055574 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -32,6 +32,7 @@ #include "Game/Systems/KillFeedSystem.h" #include "Game/Systems/BoostSystem.h" #include "Game/Systems/BoostIconsHUDSystem.h" +#include "Game/Systems/ScoreScreenSystem.h" #include "GUI/ButtonSystem.h" #include "GUI/MainMenuSystem.h" @@ -151,6 +152,7 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer); m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer); m_SystemPipeline->AddSystem(updateOrderLevel); + m_SystemPipeline->AddSystem(updateOrderLevel); // Populate Octree with collidables ++updateOrderLevel; m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeCollision, "Collidable"); diff --git a/src/Game/Systems/ScoreScreenSystem.cpp b/src/Game/Systems/ScoreScreenSystem.cpp index c66bdb2d..01a03b52 100644 --- a/src/Game/Systems/ScoreScreenSystem.cpp +++ b/src/Game/Systems/ScoreScreenSystem.cpp @@ -7,11 +7,14 @@ ScoreScreenSystem::ScoreScreenSystem(SystemParams params) { EVENT_SUBSCRIBE_MEMBER(m_EPlayerDeath, &ScoreScreenSystem::OnPlayerDeath); EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &ScoreScreenSystem::OnPlayerSpawn); + EVENT_SUBSCRIBE_MEMBER(m_EPlayerConnected, &ScoreScreenSystem::OnPlayerConnected); + EVENT_SUBSCRIBE_MEMBER(m_EPlayerDisconnected, &ScoreScreenSystem::OnPlayerDisconnected); } void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) { - if(!entity.Valid() || !entity.HasComponent("ScoreScreen")){ + //TODO: Check team al + if(!entity.HasComponent("ScoreScreen")){ return; } @@ -28,7 +31,20 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& } if(found == false) { //There is no entry for this player, create one. + auto entityFile = ResourceManager::Load("Schema/Entities/ScoreIdentity.xml"); + EntityWrapper scoreIdentity = entityFile->MergeInto(m_World); + auto cScoreIdentity = scoreIdentity["ScoreIdentity"]; + auto data = it->second; + std::printf("\n\n"); + std::printf(data.Name.c_str()); + std::printf("\n\n"); + (std::string&)cScoreIdentity["Name"] = data.Name; + (int&)cScoreIdentity["ID"] = data.ID; + (int&)cScoreIdentity["Ping"] = 1337; + + m_World->SetName(scoreIdentity.ID, data.Name); + m_World->SetParent(scoreIdentity.ID, entity.ID); } } //For each scoreboard, go through children and see if they have all of the ones needed. @@ -37,16 +53,17 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& //Just add a new component to the scorescreen entity, the "ScoreIdentity" component. } -void ScoreScreenSystem::OnPlayerDeath(const Events::PlayerDeath& e) +bool ScoreScreenSystem::OnPlayerDeath(const Events::PlayerDeath& e) { //When player die, add it to his score, and when possible the player who killed him. + return 0; } -void ScoreScreenSystem::OnPlayerSpawn(const Events::PlayerSpawned& e) +bool ScoreScreenSystem::OnPlayerSpawn(const Events::PlayerSpawned& e) { //When a player spawn, add a new entry to the score screen. if(!e.Player.Valid()) { - return; + return 0; } EntityWrapper entity = e.Player; @@ -58,7 +75,7 @@ void ScoreScreenSystem::OnPlayerSpawn(const Events::PlayerSpawned& e) data.Name = e.PlayerName; data.Player = e.Player; if(!entity.HasComponent("Team")) { - return; + return 0; } data.Team = (int)entity["Team"]["Team"]; @@ -66,5 +83,15 @@ void ScoreScreenSystem::OnPlayerSpawn(const Events::PlayerSpawned& e) m_PlayerIdentities.insert(list); m_PlayerCounter++; } - + return 0; +} + +bool ScoreScreenSystem::OnPlayerConnected(const Events::PlayerConnected& e) +{ + return 0; +} + +bool ScoreScreenSystem::OnPlayerDisconnected(const Events::PlayerDisconnected& e) +{ + return 0; } From cb7beae28c6164977f42b8b10e6298c848cdf2f1 Mon Sep 17 00:00:00 2001 From: Jocke Date: Thu, 3 Mar 2016 11:39:00 +0100 Subject: [PATCH 178/252] Only do physics and collision calculations on the clients side, and only for their own entity. --- src/Engine/Collision/CollisionSystem.cpp | 166 +++++++++++----------- src/Game/Systems/PlayerMovementSystem.cpp | 11 +- 2 files changed, 87 insertions(+), 90 deletions(-) diff --git a/src/Engine/Collision/CollisionSystem.cpp b/src/Engine/Collision/CollisionSystem.cpp index 95609ea6..53cabfac 100644 --- a/src/Engine/Collision/CollisionSystem.cpp +++ b/src/Engine/Collision/CollisionSystem.cpp @@ -17,105 +17,107 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c EntityAABB& boxA = *boundingBox; bool everHitTheGround = false; - auto prevPosIt = m_PrevPositions.find(entity); - if (prevPosIt != m_PrevPositions.end()) { - glm::vec3 size = boxA.Size(); - float diameter = std::min(size.x, size.z); - glm::vec3 prevOrigin = prevPosIt->second; - glm::vec3 toCurrentPos = boxA.Origin() - prevOrigin; - float rayLength = glm::length(toCurrentPos) + 0.5f*diameter; - //If the entity has moved farther than the size of its box, we need to handle it specially. - if (rayLength > diameter) { - Ray ray(prevOrigin, toCurrentPos); - m_OctreeResult.clear(); - m_Octree->ObjectsPossiblyHitByRay(ray, m_OctreeResult); - for (auto& boxB : m_OctreeResult) { - if (boxA.Entity == boxB.Entity) { - continue; - } - bool hit; - float dist; - if (boxB.Entity.HasComponent("Model")) { - RawModel* model; - std::string res = (std::string)boxB.Entity["Model"]["Resource"]; - try { - model = ResourceManager::Load(res); - } catch (const std::exception&) { + if (entity == LocalPlayer) { + auto prevPosIt = m_PrevPositions.find(entity); + if (prevPosIt != m_PrevPositions.end()) { + glm::vec3 size = boxA.Size(); + float diameter = std::min(size.x, size.z); + glm::vec3 prevOrigin = prevPosIt->second; + glm::vec3 toCurrentPos = boxA.Origin() - prevOrigin; + float rayLength = glm::length(toCurrentPos) + 0.5f*diameter; + //If the entity has moved farther than the size of its box, we need to handle it specially. + if (rayLength > diameter) { + Ray ray(prevOrigin, toCurrentPos); + m_OctreeResult.clear(); + m_Octree->ObjectsPossiblyHitByRay(ray, m_OctreeResult); + for (auto& boxB : m_OctreeResult) { + if (boxA.Entity == boxB.Entity) { continue; } - float u, v; - hit = Collision::RayVsModel(ray, model->Vertices(), model->m_Indices, Transform::ModelMatrix(boxB.Entity), dist, u, v); - } else { - hit = Collision::RayVsAABB(ray, boxB, dist); - } - if (hit && dist < rayLength) { - //Set the entity to where it was colliding, minus the maximum box size. - //TODO: Perhaps this should be done slightly more properly. - glm::vec3 newOriginPos = ray.Origin() + (dist - 0.707107f*diameter) * ray.Direction(); - glm::vec3 resolve = newOriginPos - boxA.Origin(); - (glm::vec3&)cTransform["Position"] += resolve; - boxA = *Collision::EntityAbsoluteAABB(entity); - if (resolve.y > 0) { - everHitTheGround = true; - (bool)cPhysics["IsOnGround"] = true; - ((glm::vec3&)cPhysics["Velocity"]).y = 0.f; + bool hit; + float dist; + if (boxB.Entity.HasComponent("Model")) { + RawModel* model; + std::string res = (std::string)boxB.Entity["Model"]["Resource"]; + try { + model = ResourceManager::Load(res); + } catch (const std::exception&) { + continue; + } + float u, v; + hit = Collision::RayVsModel(ray, model->Vertices(), model->m_Indices, Transform::ModelMatrix(boxB.Entity), dist, u, v); + } else { + hit = Collision::RayVsAABB(ray, boxB, dist); + } + if (hit && dist < rayLength) { + //Set the entity to where it was colliding, minus the maximum box size. + //TODO: Perhaps this should be done slightly more properly. + glm::vec3 newOriginPos = ray.Origin() + (dist - 0.707107f*diameter) * ray.Direction(); + glm::vec3 resolve = newOriginPos - boxA.Origin(); + (glm::vec3&)cTransform["Position"] += resolve; + boxA = *Collision::EntityAbsoluteAABB(entity); + if (resolve.y > 0) { + everHitTheGround = true; + (bool)cPhysics["IsOnGround"] = true; + ((glm::vec3&)cPhysics["Velocity"]).y = 0.f; + } + break; } - break; } } } - } - // Collide against octree items - m_OctreeResult.clear(); - m_Octree->ObjectsInSameRegion(*boundingBox, m_OctreeResult); - for (auto& boxB : m_OctreeResult) { - glm::vec3 resolutionVector; - if (boxA.Entity == boxB.Entity) { - continue; - } - - if (boxB.Entity.HasComponent("Model") && Collision::AABBVsAABB(boxA, boxB)) { - //Here we know boxB is a entity with Collideable, AABB, and Model. - RawModel* model; - try { - model = ResourceManager::Load(boxB.Entity["Model"]["Resource"]); - } catch (const std::exception&) { + // Collide against octree items + m_OctreeResult.clear(); + m_Octree->ObjectsInSameRegion(*boundingBox, m_OctreeResult); + for (auto& boxB : m_OctreeResult) { + glm::vec3 resolutionVector; + if (boxA.Entity == boxB.Entity) { continue; } - glm::mat4 modelMatrix = Transform::ModelMatrix(boxB.Entity); + if (boxB.Entity.HasComponent("Model") && Collision::AABBVsAABB(boxA, boxB)) { + //Here we know boxB is a entity with Collideable, AABB, and Model. + RawModel* model; + try { + model = ResourceManager::Load(boxB.Entity["Model"]["Resource"]); + } catch (const std::exception&) { + continue; + } - glm::vec3 inOutVelocity = (glm::vec3)cPhysics["Velocity"]; - bool notMovingxz = glm::all(glm::lessThan(glm::abs(glm::vec2(inOutVelocity.x, inOutVelocity.z)), glm::vec2(0.01f))) && prevPosIt != m_PrevPositions.end(); - bool isOnGround = (bool)cPhysics["IsOnGround"]; - float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"]; - if (Collision::AABBvsTriangles(boxA, model->Vertices(), model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) { - //Move the position to previous position if it is not moving in the xz-plane, else resolve with the resolution vector. - (glm::vec3&)cTransform["Position"] += notMovingxz ? prevPosIt->second - boxA.Origin() : resolutionVector; + glm::mat4 modelMatrix = Transform::ModelMatrix(boxB.Entity); + + glm::vec3 inOutVelocity = (glm::vec3)cPhysics["Velocity"]; + bool notMovingxz = glm::all(glm::lessThan(glm::abs(glm::vec2(inOutVelocity.x, inOutVelocity.z)), glm::vec2(0.01f))) && prevPosIt != m_PrevPositions.end(); + bool isOnGround = (bool)cPhysics["IsOnGround"]; + float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"]; + if (Collision::AABBvsTriangles(boxA, model->Vertices(), model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) { + //Move the position to previous position if it is not moving in the xz-plane, else resolve with the resolution vector. + (glm::vec3&)cTransform["Position"] += notMovingxz ? prevPosIt->second - boxA.Origin() : resolutionVector; + boxA = *Collision::EntityAbsoluteAABB(entity); + cPhysics["Velocity"] = inOutVelocity; + if (isOnGround) { + everHitTheGround = true; + (bool)cPhysics["IsOnGround"] = true; + } + } + } else if (Collision::AABBVsAABB(boxA, boxB, resolutionVector)) { + //Enter here if boxB has no Model. + (glm::vec3&)cTransform["Position"] += resolutionVector; boxA = *Collision::EntityAbsoluteAABB(entity); - cPhysics["Velocity"] = inOutVelocity; - if (isOnGround) { + if (resolutionVector.y > 0) { everHitTheGround = true; (bool)cPhysics["IsOnGround"] = true; + ((glm::vec3&)cPhysics["Velocity"]).y = 0.f; } } - } else if (Collision::AABBVsAABB(boxA, boxB, resolutionVector)) { - //Enter here if boxB has no Model. - (glm::vec3&)cTransform["Position"] += resolutionVector; - boxA = *Collision::EntityAbsoluteAABB(entity); - if (resolutionVector.y > 0) { - everHitTheGround = true; - (bool)cPhysics["IsOnGround"] = true; - ((glm::vec3&)cPhysics["Velocity"]).y = 0.f; - } } - } - //This should apply air friction and such, iff zero models were hit. - if (!everHitTheGround) { - (bool)cPhysics["IsOnGround"] = false; - } + //This should apply air friction and such, iff zero models were hit. + if (!everHitTheGround) { + (bool)cPhysics["IsOnGround"] = false; + } - m_PrevPositions[entity] = boxA.Origin(); + m_PrevPositions[entity] = boxA.Origin(); + } } diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 9afc9c8c..be85fddb 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -18,14 +18,9 @@ PlayerMovementSystem::~PlayerMovementSystem() void PlayerMovementSystem::Update(double dt) { updateMovementControllers(dt); - if (IsServer) { - for (auto& kv : m_PlayerInputControllers) { - updateVelocity(kv.first, dt); - } - } else { - if (LocalPlayer.Valid()) { - updateVelocity(LocalPlayer, dt); - } + // Only do physics calculations on client and only for themselves. + if (!IsServer && LocalPlayer.Valid()) { + updateVelocity(LocalPlayer, dt); } } From c8aeae2c9640290a8bcba80784945025406f785d Mon Sep 17 00:00:00 2001 From: Tleety Date: Thu, 3 Mar 2016 12:58:35 +0100 Subject: [PATCH 179/252] WIP --- include/Game/Systems/ScoreScreenSystem.h | 4 +- resources/Schema/Entities/CP_Rocky.xml | 1141 ++++++++++---------- src/Game/Systems/CapturePointHUDSystem.cpp | 6 +- src/Game/Systems/ScoreScreenSystem.cpp | 70 +- 4 files changed, 636 insertions(+), 585 deletions(-) diff --git a/include/Game/Systems/ScoreScreenSystem.h b/include/Game/Systems/ScoreScreenSystem.h index 7f7c4064..a33d4684 100644 --- a/include/Game/Systems/ScoreScreenSystem.h +++ b/include/Game/Systems/ScoreScreenSystem.h @@ -30,12 +30,12 @@ private: struct PlayerData { int ID = -1; std::string Name = ""; - int Team = -1; + int Team = 1; EntityWrapper Player = EntityWrapper::Invalid; }; int m_PlayerCounter = 0; - std::unordered_map m_PlayerIdentities; + std::unordered_map m_PlayerIdentities; }; #endif \ No newline at end of file diff --git a/resources/Schema/Entities/CP_Rocky.xml b/resources/Schema/Entities/CP_Rocky.xml index 0adcbe6e..a6f6302d 100644 --- a/resources/Schema/Entities/CP_Rocky.xml +++ b/resources/Schema/Entities/CP_Rocky.xml @@ -29,6 +29,16 @@ + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + @@ -72,16 +82,6 @@ - - - - - Models/Props/Walls/SciFiWallMedium.mesh - - - - - @@ -127,11 +127,42 @@ - + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -765,6 +796,19 @@ + + + + + 2 + 1 + + + + + + + @@ -789,19 +833,6 @@ - - - - - 2 - 1 - - - - - - - @@ -827,11 +858,11 @@ 2 - + - + @@ -848,7 +879,7 @@ - + @@ -874,11 +905,11 @@ 2 - + - + @@ -895,7 +926,7 @@ - + @@ -921,11 +952,11 @@ 2 - + - + @@ -942,7 +973,7 @@ - + @@ -968,11 +999,11 @@ 2 - + - + @@ -989,7 +1020,7 @@ - + @@ -1015,11 +1046,11 @@ 2 - + - + @@ -1036,7 +1067,7 @@ - + @@ -1062,11 +1093,11 @@ 2 - + - + @@ -1083,7 +1114,7 @@ - + @@ -1109,11 +1140,11 @@ 2 - + - + @@ -1130,7 +1161,7 @@ - + @@ -2378,11 +2409,11 @@ 2 - + - + @@ -2399,7 +2430,7 @@ - + @@ -2425,11 +2456,11 @@ 2 - + - + @@ -2446,7 +2477,7 @@ - + @@ -2693,6 +2724,41 @@ + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + @@ -3138,6 +3204,94 @@ + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + @@ -3351,26 +3505,24 @@ - - - - Models/Core/UnitPlane.mesh - - true - - - - - - - - - + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + @@ -3384,45 +3536,6 @@ - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - @@ -3440,36 +3553,11 @@ - Models/Props/Walls/MediumWall1.mesh + Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - + + @@ -3500,6 +3588,45 @@ + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + @@ -3518,11 +3645,23 @@ - Models/Props/Walls/MediumWall2.mesh + Models/Props/Walls/SmallWall3.mesh - - + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + @@ -3534,8 +3673,21 @@ Models/Props/Walls/MediumWall2.mesh - - + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + @@ -3552,19 +3704,6 @@ - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - @@ -3580,169 +3719,11 @@ - - - - - - - - - - Models/Props/Flora/SpecialRoot.mesh - - - - - - - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2 - - - - - - - - - @@ -3758,21 +3739,6 @@ - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - @@ -3801,6 +3767,71 @@ + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + @@ -3815,6 +3846,21 @@ + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + @@ -3830,6 +3876,19 @@ + + + + + 2 + 1 + + + + + + + @@ -3854,19 +3913,6 @@ - - - - - 2 - 1 - - - - - - - @@ -3884,21 +3930,6 @@ - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - @@ -3912,9 +3943,9 @@ Models/Props/PickUps/PickUpHolder.mesh - - - + + + @@ -3922,58 +3953,11 @@ 2 - + - - - - - - - - - - 8 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - 2 - - - - - + @@ -3989,8 +3973,8 @@ Models/Props/PickUps/HealthPickUp.mesh - - + + @@ -4016,11 +4000,11 @@ 2 - + - + @@ -4037,7 +4021,7 @@ - + @@ -4053,8 +4037,8 @@ Models/Props/PickUps/PickUpHolder.mesh - - + + @@ -4063,11 +4047,11 @@ 2 - + - + @@ -4082,103 +4066,9 @@ Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - 2 - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - 2 - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - + @@ -4204,11 +4094,11 @@ 2 - + - + @@ -4225,7 +4115,148 @@ - + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + @@ -4264,9 +4295,9 @@ Models/Props/Pillars/StonePillar.mesh - - - + + + @@ -4278,9 +4309,9 @@ Models/Props/Pillars/StonePillar.mesh - - - + + + @@ -4579,7 +4610,7 @@ false - + @@ -4592,7 +4623,7 @@ false - + @@ -4630,6 +4661,41 @@ + + + + 0.40000000596046448 + + + + + + + + + + + + 10 + + + + + + + + + + + + 10 + + + + + + + @@ -4650,18 +4716,6 @@ - - - - - 10 - - - - - - - @@ -4673,17 +4727,6 @@ - - - - 0.40000000596046448 - - - - - - - @@ -4695,18 +4738,6 @@ - - - - - 10 - - - - - - - diff --git a/src/Game/Systems/CapturePointHUDSystem.cpp b/src/Game/Systems/CapturePointHUDSystem.cpp index 6f1392e0..b7376249 100644 --- a/src/Game/Systems/CapturePointHUDSystem.cpp +++ b/src/Game/Systems/CapturePointHUDSystem.cpp @@ -9,7 +9,7 @@ CapturePointHUDSystem::CapturePointHUDSystem(SystemParams params) void CapturePointHUDSystem::Update(double dt) { - bool LoadCheck = true; + bool loadCheck = true; int redTeam; int blueTeam; int spectatorTeam; @@ -35,11 +35,11 @@ void CapturePointHUDSystem::Update(double dt) //Check if the HUD corresponds to the Capture Point Number if (HUD_ID == (int)entityCP["CapturePoint"]["CapturePointNumber"]) { ComponentWrapper& teamComponent = entityCP["Team"]; - if (LoadCheck) { + if (loadCheck) { redTeam = (int)teamComponent["Team"].Enum("Red"); blueTeam = (int)teamComponent["Team"].Enum("Blue"); spectatorTeam = (int)teamComponent["Team"].Enum("Spectator"); - LoadCheck = false; + loadCheck = false; } //Color hud with team color auto capturePointTeam = (int)teamComponent["Team"]; diff --git a/src/Game/Systems/ScoreScreenSystem.cpp b/src/Game/Systems/ScoreScreenSystem.cpp index 01a03b52..361d9f1f 100644 --- a/src/Game/Systems/ScoreScreenSystem.cpp +++ b/src/Game/Systems/ScoreScreenSystem.cpp @@ -18,32 +18,53 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& return; } + int redTeamEnum; + int blueTeamEnum; + int spectatorTeamEnum; + int currentTeam = 0; + + if(entity.HasComponent("Team")) { + auto cTeam = entity["Team"]; + redTeamEnum = (int)cTeam["Team"].Enum("Red"); + blueTeamEnum = (int)cTeam["Team"].Enum("Blue"); + spectatorTeamEnum = (int)cTeam["Team"].Enum("Spectator"); + currentTeam = (int)cTeam["Team"]; + } + auto children = entity.ChildrenWithComponent("ScoreIdentity"); for (auto it = m_PlayerIdentities.begin(); it != m_PlayerIdentities.end(); ++it) { + bool found = false; for (auto child : children) { - std::string name = (std::string)child["ScoreIdentity"]["Name"]; - if (it->first == name) { + int ID = (int)child["ScoreIdentity"]["ID"]; + if (it->first == ID) { + if (it->second.Team != currentTeam) { + m_World->DeleteEntity(child.ID); + break; + } found = true; break; } } if(found == false) { + if(it->second.Team != currentTeam) { + //This player is not the same team as this scoreboard should show. + break; + } //There is no entry for this player, create one. auto entityFile = ResourceManager::Load("Schema/Entities/ScoreIdentity.xml"); EntityWrapper scoreIdentity = entityFile->MergeInto(m_World); auto cScoreIdentity = scoreIdentity["ScoreIdentity"]; auto data = it->second; - std::printf("\n\n"); - std::printf(data.Name.c_str()); - std::printf("\n\n"); (std::string&)cScoreIdentity["Name"] = data.Name; (int&)cScoreIdentity["ID"] = data.ID; (int&)cScoreIdentity["Ping"] = 1337; - m_World->SetName(scoreIdentity.ID, data.Name); + std::string IdentityName = "#" + std::to_string(data.ID) + ": " + data.Name; + + m_World->SetName(scoreIdentity.ID, IdentityName); m_World->SetParent(scoreIdentity.ID, entity.ID); } } @@ -61,37 +82,36 @@ bool ScoreScreenSystem::OnPlayerDeath(const Events::PlayerDeath& e) bool ScoreScreenSystem::OnPlayerSpawn(const Events::PlayerSpawned& e) { - //When a player spawn, add a new entry to the score screen. - if(!e.Player.Valid()) { + //When a player spawn, add data to the list entry with the same ID. + + std::unordered_map::iterator got; + + got = m_PlayerIdentities.find(e.PlayerID); + if(got == m_PlayerIdentities.end()) { + LOG_ERROR("Player spawned without having an entry on score screen"); return 0; } - EntityWrapper entity = e.Player; + auto& data = got->second; + data.Player = e.Player; + data.Team = (int)data.Player["Team"]["Team"]; - std::unordered_map::const_iterator got; - got = m_PlayerIdentities.find(e.PlayerName); - if (got == m_PlayerIdentities.end()) { - PlayerData data; - data.ID = m_PlayerCounter; - data.Name = e.PlayerName; - data.Player = e.Player; - if(!entity.HasComponent("Team")) { - return 0; - } - data.Team = (int)entity["Team"]["Team"]; - - std::pair list (data.Name, data); - m_PlayerIdentities.insert(list); - m_PlayerCounter++; - } return 0; } bool ScoreScreenSystem::OnPlayerConnected(const Events::PlayerConnected& e) { + //player has connected, add his data to the list of ScoreIdentities + PlayerData data; + data.ID = e.PlayerID; + data.Name = e.PlayerName; + m_PlayerIdentities.insert( {data.ID, data} ); + return 0; } bool ScoreScreenSystem::OnPlayerDisconnected(const Events::PlayerDisconnected& e) { + //player has disconnected, remove him from list of ScoreIdentities + m_PlayerIdentities.erase(e.PlayerID); return 0; } From 9c1a638a41ff32e49cf78d96d81c4078fc85697e Mon Sep 17 00:00:00 2001 From: maqu14 Date: Thu, 3 Mar 2016 13:28:18 +0100 Subject: [PATCH 180/252] New map (NewMap2version4NEW) --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 10a61165..7a6d7078 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 10a611659ddaadfea6a560e707d395834855a979 +Subproject commit 7a6d70787b036d8ae8763b69ae6ad098bf221c22 From a9b19d9af18364252fea24150d3d3ebd1dc095d8 Mon Sep 17 00:00:00 2001 From: Jocke Date: Thu, 3 Mar 2016 13:29:45 +0100 Subject: [PATCH 181/252] Packet write now only warns when a a packet is huge --- include/Engine/Network/Packet.h | 4 +++- src/Engine/Network/Packet.cpp | 8 ++++++-- src/Game/Systems/PlayerMovementSystem.cpp | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/Engine/Network/Packet.h b/include/Engine/Network/Packet.h index 95419e10..e7444d9d 100644 --- a/include/Engine/Network/Packet.h +++ b/include/Engine/Network/Packet.h @@ -24,7 +24,9 @@ public: { // Check if we are trying to add more than the package can fit. if (m_MaxPacketSize < m_Offset + sizeof(T)) { - //LOG_WARNING("Packet AddPrimitive(): You are trying to add more than we have allocated for! New size is %i bytes\n", m_MaxPacketSize*2); + if (m_MaxPacketSize >= 32000) { + LOG_WARNING("Package::WritePrimitive(): New size is huge %i bytes\n", m_MaxPacketSize*2); + } resizeData(); } memcpy(m_Data + m_Offset, &val, sizeof(T)); diff --git a/src/Engine/Network/Packet.cpp b/src/Engine/Network/Packet.cpp index 475ca673..74afd656 100644 --- a/src/Engine/Network/Packet.cpp +++ b/src/Engine/Network/Packet.cpp @@ -49,7 +49,9 @@ void Packet::WriteString(const std::string& str) // Message, add one extra byte for null terminator size_t sizeOfString = str.size() + 1; if (m_Offset + sizeOfString > m_MaxPacketSize) { - //LOG_WARNING("Package::WriteString(): Data size in packet exceeded maximum package size. New size is %i bytes\n", m_MaxPacketSize*2); + if (m_MaxPacketSize >= 32000) { + LOG_WARNING("Package::WriteString(): New size is huge %i bytes\n", m_MaxPacketSize*2); + } resizeData(); } memcpy(m_Data + m_Offset, str.data(), sizeOfString * sizeof(char)); @@ -60,7 +62,9 @@ void Packet::WriteData(char * data, int sizeOfData) { if (m_Offset + sizeOfData > m_MaxPacketSize) { - //LOG_WARNING("Packet::WriteData(): Data size in packet exceeded maximum packet size. New size is %i bytes\n", m_MaxPacketSize*2); + if (m_MaxPacketSize >= 32000) { + LOG_WARNING("Package::WriteData(): New size is huge %i bytes\n", m_MaxPacketSize*2); + } while (m_Offset + sizeOfData > m_MaxPacketSize) { resizeData(); } diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index be85fddb..5037b019 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -19,7 +19,7 @@ void PlayerMovementSystem::Update(double dt) { updateMovementControllers(dt); // Only do physics calculations on client and only for themselves. - if (!IsServer && LocalPlayer.Valid()) { + if (IsClient && LocalPlayer.Valid()) { updateVelocity(LocalPlayer, dt); } } From 2cd39c718810419ae6b95bec3a1c0cc0acb42384 Mon Sep 17 00:00:00 2001 From: maqu14 Date: Thu, 3 Mar 2016 13:31:17 +0100 Subject: [PATCH 182/252] New map version (NewMap2version4NEW) --- .../Schema/Entities/NewMap2version4NEW.xml | 8770 +++++++++++++++++ 1 file changed, 8770 insertions(+) create mode 100644 resources/Schema/Entities/NewMap2version4NEW.xml diff --git a/resources/Schema/Entities/NewMap2version4NEW.xml b/resources/Schema/Entities/NewMap2version4NEW.xml new file mode 100644 index 00000000..0b94f444 --- /dev/null +++ b/resources/Schema/Entities/NewMap2version4NEW.xml @@ -0,0 +1,8770 @@ + + + + + + + + + + + + + + + + + + 2 + Models/Props/GroundTest.mesh + + + + + + + + + Models/Props/Walls/SciFiWallTop.mesh + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + true + + + + + + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall1.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall2.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallSmall3.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall4.mesh + + + + + + + + + + + + Models/Props/Highground1.mesh + + + + + + + + + + Models/Props/Highground2.mesh + + + + + + + + + + + Models/Props/Highground3.mesh + + + + + + + + + + + Models/Highgrounds/Highground24.mesh + + + + + + + + + + + + Models/Highgrounds/Hg13.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg25.mesh + + + + + + + + + + + + Models/Highgrounds/Hg26.mesh + + + + + + + + + + + + Models/Highgrounds/Hg9.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg4.mesh + + + + + + + + + + + + + + Models/Highgrounds/Hg10.mesh + + + + + + + + + + + + + + Models/Highgrounds/Hg19.mesh + + + + + + + + + + + + + + Models/Highgrounds/Hg19.mesh + + + + + + + + + + + + + + + Models/Highgrounds/Highground12.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg16.mesh + + + + + + + + + + + + Models/Highgrounds/Hg15.mesh + + + + + + + + + + + + Models/Highgrounds/Hg14.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg13.mesh + + + + + + + + + + + + Models/Highgrounds/Hg11.mesh + + + + + + + + + + + + Models/Highgrounds/Hg20.mesh + + + + + + + + + + + + Models/Highgrounds/Hg18.mesh + + + + + + + + + + + + Models/Highgrounds/Hg19.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg17.mesh + + + + + + + + + + + + + + + Models/Highgrounds/Hg8.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg7.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg3.mesh + + + + + + + + + + + + + + + Models/Props/Highground1.mesh + + + + + + + + + + + + Models/Props/Highground2.mesh + + + + + + + + + + + + + Models/Props/Highground3.mesh + + + + + + + + + + + + + Models/Highgrounds/Highground1.mesh + + + + + + + + + + + Models/Highgrounds/Highground2.mesh + + + + + + + + + + + + + + Models/Highgrounds/Hg1.mesh + + + + + + + + + + + Models/Highgrounds/Hg2.mesh + + + + + + + + + + + + + + Models/Highgrounds/Highground5.mesh + + + + + + + + + + + + Models/Highgrounds/Hg17.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg19.mesh + + + + + + + + + + + + Models/Highgrounds/Hg18.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg20.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg6.mesh + + + + + + + + + + + + Models/Highgrounds/Hg8.mesh + + + + + + + + + + + + Models/Highgrounds/Hg7.mesh + + + + + + + + + + + + Models/Highgrounds/Hg10.mesh + + + + + + + + + + + + Models/Highgrounds/Hg4.mesh + + + + + + + + + + + + Models/Highgrounds/Hg16.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg9.mesh + + + + + + + + + + + + Models/Highgrounds/Hg3.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg19.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Highgrounds/Hg10.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + + + Models/Highgrounds/Highground22.mesh + + + + + + + + + + + + Models/Highgrounds/Hg8.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg19.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg21.mesh + + + + + + + + + + + + Models/Highgrounds/Hg11.mesh + + + + + + + + + + + + Models/Highgrounds/Hg3.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg17.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg8.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + + + Models/Highgrounds/Hg28.mesh + + + + + + + + + + + Models/Highgrounds/Hg10.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg27.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg15.mesh + + + + + + + + + + + + + + Models/Highgrounds/Hg13.mesh + + + + + + + + + + + + + + + Models/Highgrounds/Hg27.mesh + + + + + + + + + + + + Models/Highgrounds/Hg23.mesh + + + + + + + + + + + + + + + Models/Highgrounds/Hg27.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg23.mesh + + + + + + + + + + + + + + + Models/Highgrounds/Hg28.mesh + + + + + + + + + + + + Models/Highgrounds/Hg10.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg27.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg15.mesh + + + + + + + + + + + + + + Models/Highgrounds/Hg13.mesh + + + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar3Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar3Red.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 5 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 4 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + + 3 + + + + + + + + + + + + 2 + 1 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 4 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/smallWall3.mesh + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 5 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 4 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + + 3 + + + + + + + + + + + + 2 + 1 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 4 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar3Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar3Blue.mesh + + + + + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointBlue.mesh + + + + + + + + + + + + + -15 + 4 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 3 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 15 + 2 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 15 + 1 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointRed.mesh + + + + + + + + + + + + + 15 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + + 10 + + + + + + + + + + + 1 + + + + + + + + + + + + 10 + + + + + + + + + + + + + + Schema/Entities/PlayerRed.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + From 1210c915351def2445ab8e9749e578261658d518 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 3 Mar 2016 13:51:47 +0100 Subject: [PATCH 183/252] Added Gameplay.AutoReload bool to config --- include/Game/Systems/Weapon/WeaponBehaviour.h | 8 ++++++-- resources/DefaultConfig.ini | 3 +++ src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp | 10 +++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/include/Game/Systems/Weapon/WeaponBehaviour.h b/include/Game/Systems/Weapon/WeaponBehaviour.h index e0783bd2..d4520c9f 100644 --- a/include/Game/Systems/Weapon/WeaponBehaviour.h +++ b/include/Game/Systems/Weapon/WeaponBehaviour.h @@ -8,6 +8,7 @@ #include "Input/EInputCommand.h" #include "Systems/SpawnerSystem.h" #include "Rendering/ESetCamera.h" +#include "Core/ConfigFile.h" template class WeaponBehaviour : public PureSystem @@ -21,8 +22,10 @@ public: , m_Renderer(renderer) , m_CollisionOctree(collisionOctree) { - EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &WeaponBehaviour::_OnInputCommand) - EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &WeaponBehaviour::_OnSetCamera) + EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &WeaponBehaviour::_OnInputCommand); + EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &WeaponBehaviour::_OnSetCamera); + auto config = ResourceManager::Load("Config.ini"); + m_ConfigAutoReload = config->Get("Gameplay.AutoReload", true); } virtual ~WeaponBehaviour() = default; @@ -49,6 +52,7 @@ protected: EntityWrapper m_CurrentCamera; Octree* m_CollisionOctree; std::unordered_map m_ActiveWeapons; + bool m_ConfigAutoReload; virtual void UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& wi, double dt) { } virtual void OnPrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) { } diff --git a/resources/DefaultConfig.ini b/resources/DefaultConfig.ini index 8917e3e1..fd468fd6 100644 --- a/resources/DefaultConfig.ini +++ b/resources/DefaultConfig.ini @@ -1,3 +1,6 @@ +[Gameplay] +AutoReload=true + [Debug] LogLevel=1 LoadMap= diff --git a/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp b/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp index 50d5889d..3a4ed3a4 100644 --- a/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp @@ -14,11 +14,16 @@ void DefenderWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& double& reloadTimer = cWeapon["ReloadTimer"]; reloadTimer = glm::max(0.0, reloadTimer - dt); + // Start reloading automatically if at 0 mag ammo + int& magAmmo = cWeapon["MagazineAmmo"]; + if (m_ConfigAutoReload && magAmmo <= 0) { + OnReload(cWeapon, wi); + } + // Handle reloading - double reloadTime = cWeapon["ReloadTime"]; bool& isReloading = cWeapon["IsReloading"]; if (isReloading && reloadTimer <= 0.0) { - int& magAmmo = cWeapon["MagazineAmmo"]; + double reloadTime = cWeapon["ReloadTime"]; int& magSize = cWeapon["MagazineSize"]; int& ammo = cWeapon["Ammo"]; if (magAmmo < magSize && ammo > 0) { @@ -130,7 +135,6 @@ void DefenderWeaponBehaviour::fireShell(ComponentWrapper cWeapon, WeaponInfo& wi // Ammo int& magAmmo = cWeapon["MagazineAmmo"]; if (magAmmo <= 0) { - OnReload(cWeapon, wi); return; } else { magAmmo -= 1; From f4983cf9610d6a2562cee64d29b86598e950cf22 Mon Sep 17 00:00:00 2001 From: Tleety Date: Thu, 3 Mar 2016 13:53:40 +0100 Subject: [PATCH 184/252] WIP --- resources/Schema/Entities/ScoreIdentity.xml | 104 ++++++++++++-------- src/Game/Systems/ScoreScreenSystem.cpp | 7 +- 2 files changed, 65 insertions(+), 46 deletions(-) diff --git a/resources/Schema/Entities/ScoreIdentity.xml b/resources/Schema/Entities/ScoreIdentity.xml index 7d1e2437..daf9d4eb 100644 --- a/resources/Schema/Entities/ScoreIdentity.xml +++ b/resources/Schema/Entities/ScoreIdentity.xml @@ -9,24 +9,17 @@ - - - - Simon needs to push shit shit so i can write text from Component - Fonts/DroidSans.ttf,64 - - - - - - - - ID + -1 Fonts/DroidSans.ttf,64 + + ScoreIdentity + ScoreIdentity + ID + @@ -36,35 +29,16 @@ - DickButt + Fonts/DroidSans.ttf,64 + + ScoreIdentity + ScoreIdentity + Name + - - - - - - - - - 5 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - 12 - Fonts/DroidSans.ttf,64 - - - + @@ -72,11 +46,50 @@ - 0.42 + 0 Fonts/DroidSans.ttf,64 + + ScoreIdentity + ScoreIdentity + KD + - + + + + + + + + + 0 + Fonts/DroidSans.ttf,64 + + + ScoreIdentity + ScoreIdentity + Kills + + + + + + + + + + + 0 + Fonts/DroidSans.ttf,64 + + + ScoreIdentity + ScoreIdentity + Deaths + + + @@ -84,11 +97,16 @@ - 84 + 0 Fonts/DroidSans.ttf,64 + + ScoreIdentity + ScoreIdentity + Ping + - + diff --git a/src/Game/Systems/ScoreScreenSystem.cpp b/src/Game/Systems/ScoreScreenSystem.cpp index 361d9f1f..0713e13b 100644 --- a/src/Game/Systems/ScoreScreenSystem.cpp +++ b/src/Game/Systems/ScoreScreenSystem.cpp @@ -14,6 +14,10 @@ ScoreScreenSystem::ScoreScreenSystem(SystemParams params) void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) { //TODO: Check team al + if (!IsServer) { + return; + } + if(!entity.HasComponent("ScoreScreen")){ return; } @@ -62,9 +66,6 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& (int&)cScoreIdentity["ID"] = data.ID; (int&)cScoreIdentity["Ping"] = 1337; - std::string IdentityName = "#" + std::to_string(data.ID) + ": " + data.Name; - - m_World->SetName(scoreIdentity.ID, IdentityName); m_World->SetParent(scoreIdentity.ID, entity.ID); } } From 73b8bff1f3ebfad3de5e22d06d53ce2cb1779c4f Mon Sep 17 00:00:00 2001 From: Tobias Dahl Date: Thu, 3 Mar 2016 14:24:43 +0100 Subject: [PATCH 185/252] Revert "Shadows" --- include/Engine/Rendering/DrawFinalPass.h | 4 +- include/Engine/Rendering/Renderer.h | 2 - include/Engine/Rendering/ShadowPass.h | 87 - include/Engine/Rendering/ShadowPassState.h | 15 - resources/Schema/Entities/GameMap.xml | 7 - resources/Schema/Entities/OliviaTestWorld.xml | 1558 ----------------- .../Schema/Entities/QualityAssurance.xml | 4 +- resources/Shaders/ExplosionEffect.geom.glsl | 6 - resources/Shaders/ForwardPlus.frag.glsl | 179 +- resources/Shaders/ForwardPlus.vert.glsl | 10 - .../Shaders/ForwardPlusShieldCheck.frag.glsl | 2 - .../Shaders/ForwardPlusSkinned.vert.glsl | 10 - .../Shaders/ForwardPlusSplatMap.frag.glsl | 3 - .../Shaders/ForwardPlusSplatMapRGB.frag.glsl | 2 - resources/Shaders/Shadow.frag.glsl | 22 - resources/Shaders/Shadow.vert.glsl | 18 - src/Engine/Rendering/DrawFinalPass.cpp | 20 +- src/Engine/Rendering/FrameBuffer.cpp | 8 +- src/Engine/Rendering/Renderer.cpp | 8 +- src/Engine/Rendering/ShadowPass.cpp | 305 ---- src/Engine/Rendering/ShadowPassState.cpp | 19 - 21 files changed, 9 insertions(+), 2280 deletions(-) delete mode 100644 include/Engine/Rendering/ShadowPass.h delete mode 100644 include/Engine/Rendering/ShadowPassState.h delete mode 100644 resources/Schema/Entities/OliviaTestWorld.xml delete mode 100644 resources/Shaders/Shadow.frag.glsl delete mode 100644 resources/Shaders/Shadow.vert.glsl delete mode 100644 src/Engine/Rendering/ShadowPass.cpp delete mode 100644 src/Engine/Rendering/ShadowPassState.cpp diff --git a/include/Engine/Rendering/DrawFinalPass.h b/include/Engine/Rendering/DrawFinalPass.h index c5b937c6..cfddd5c6 100644 --- a/include/Engine/Rendering/DrawFinalPass.h +++ b/include/Engine/Rendering/DrawFinalPass.h @@ -11,12 +11,11 @@ #include "Util/UnorderedMapVec2.h" #include "Util/CommonFunctions.h" #include "Texture.h" -#include "ShadowPass.h" class DrawFinalPass { public: - DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass, ShadowPass* shadowPass); + DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass); ~DrawFinalPass() { } void InitializeTextures(); void InitializeFrameBuffers(); @@ -66,7 +65,6 @@ private: const LightCullingPass* m_LightCullingPass; const CubeMapPass* m_CubeMapPass; const SSAOPass* m_SSAOPass; - const ShadowPass* m_ShadowPass; ShaderProgram* m_ForwardPlusProgram; ShaderProgram* m_ExplosionEffectProgram; diff --git a/include/Engine/Rendering/Renderer.h b/include/Engine/Rendering/Renderer.h index fd3b215e..a64a4aa3 100644 --- a/include/Engine/Rendering/Renderer.h +++ b/include/Engine/Rendering/Renderer.h @@ -26,7 +26,6 @@ #include "TextPass.h" #include "Util/CommonFunctions.h" #include "Core/PerformanceTimer.h" -#include "ShadowPass.h" class Renderer : public IRenderer { @@ -76,7 +75,6 @@ private: DrawColorCorrectionPass* m_DrawColorCorrectionPass; SSAOPass* m_SSAOPass; CubeMapPass* m_CubeMapPass; - ShadowPass* m_ShadowPass; //----------------------Functions----------------------// void InitializeWindow(); diff --git a/include/Engine/Rendering/ShadowPass.h b/include/Engine/Rendering/ShadowPass.h deleted file mode 100644 index 6db8a624..00000000 --- a/include/Engine/Rendering/ShadowPass.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef ShadowPass_h__ -#define ShadowPass_h__ - -#include "IRenderer.h" -#include "FrameBuffer.h" -#include "ShaderProgram.h" -#include "../Core/EventBroker.h" -#include "../Core/World.h" -#include "ShadowPassState.h" -#include "imgui/imgui.h" - -#define MAX_SPLITS 4 - -enum NearFar { NEAR = 0, FAR = 1 }; -enum LRBT { LEFT = 0, RIGHT = 1, BOTTOM = 2, TOP = 3 }; - -struct ShadowFrustum -{ - float NearClip; - float FarClip; - float FOV; - float AspectRatio; - glm::vec3 MiddlePoint; - float Radius; - std::array LRBT; - std::array CornerPoint; -}; - -class ShadowPass -{ -public: - ShadowPass(IRenderer* renderer); - ShadowPass(IRenderer * renderer, int ShadowResX, int ShadowResY); - ~ShadowPass(); - - void InitializeFrameBuffers(); - void InitializeShaderPrograms(); - void ClearBuffer(); - void Draw(RenderScene& scene); - - void DebugGUI(); - - GLuint DepthMap() const { return m_DepthMap; } - std::array LightP() const { return m_LightProjection; } - std::array LightV() const { return m_LightView; } - std::array FarDistance() const { std::array f; for (int i = 0; i < MAX_SPLITS; i++) f[i] = m_shadowFrusta[i].FarClip; return f; } - int CurrentNrOfSplits() const { return m_CurrentNrOfSplits; } - - void SetSplitWeight(float split_weight) { m_SplitWeight = split_weight; }; -private: - void InitializeCameras(RenderScene & scene); - void UpdateSplitDist(std::array& frusta, float near_distance, float far_distance); - void UpdateFrustumPoints(ShadowFrustum& frustum, glm::vec3 camera_position, glm::vec3 view_dir); - void UpdateFrustumPoints(ShadowFrustum& frustum, glm::mat4 p, glm::mat4 v); - - void PointsToLightspace(ShadowFrustum& frustum, glm::mat4 v); - - float FindRadius(ShadowFrustum& frustum); - void RadiusToLightspace(ShadowFrustum& frustum); - - EventBroker* m_EventBroker; - const IRenderer* m_Renderer; - - GLuint m_DepthMap; - FrameBuffer m_DepthBuffer; - ShaderProgram* m_ShadowProgram; - - std::array m_LightProjection; - std::array m_LightView; - - GLfloat m_NearFarPlane[2] = { -34.f, 27.f }; - GLuint m_ResolutionSizeWidth = 1024 * 2; - GLuint m_ResolutionSizeHeight = 1024 * 2; - - bool m_TransparentObjects = false; - bool m_TexturedShadows = false; - bool m_EnableShadows = true; - - int m_CurrentNrOfSplits = 4; - float m_SplitWeight = 0.962f; - - std::array m_shadowFrusta; - - Texture* m_WhiteTexture = ResourceManager::Load("Textures/Core/White.png"); -}; - -#endif \ No newline at end of file diff --git a/include/Engine/Rendering/ShadowPassState.h b/include/Engine/Rendering/ShadowPassState.h deleted file mode 100644 index f881b48e..00000000 --- a/include/Engine/Rendering/ShadowPassState.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef ShadowPassState_h_ -#define ShadowPassState_h_ - -#include "Rendering/RenderState.h" - -class ShadowPassState : public RenderState -{ -public: - ShadowPassState(GLuint frameBuffer); - ~ShadowPassState(); - -private: -}; - -#endif \ No newline at end of file diff --git a/resources/Schema/Entities/GameMap.xml b/resources/Schema/Entities/GameMap.xml index 473b9037..c3a16361 100644 --- a/resources/Schema/Entities/GameMap.xml +++ b/resources/Schema/Entities/GameMap.xml @@ -245,13 +245,6 @@ - - - - - - - diff --git a/resources/Schema/Entities/OliviaTestWorld.xml b/resources/Schema/Entities/OliviaTestWorld.xml deleted file mode 100644 index 23c2b283..00000000 --- a/resources/Schema/Entities/OliviaTestWorld.xml +++ /dev/null @@ -1,1558 +0,0 @@ - - - - - - - - - - - - - - - - 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/AssaultBlueWeapon.mesh - - - - - - - - - - - - - - - - Models/Core/UnitCylinder.mesh - - - - - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - Models/AssaultRedWeapon.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 - - 2.3331127968986038 - 3.7999999523162842 - - true - - - Models/AssaultWeaponBlue.mesh - true - - - - - - - - - - - - - - - - Models/Core/UnitCylinder.mesh - - - - - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - - - 0.28322599621543532 - - - Models/Assault.mesh - true - - - - - - - - - - - - - - - Models/Core/UnitCylinder.mesh - - - - - - - - - - - - - - - - - - - - 0.5 - - - - - - - - - - - Walk - - 1 - - - true - - - 1.8831113377486872 - - 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/QualityAssurance.xml b/resources/Schema/Entities/QualityAssurance.xml index 0d9421ab..04cc288a 100644 --- a/resources/Schema/Entities/QualityAssurance.xml +++ b/resources/Schema/Entities/QualityAssurance.xml @@ -559,8 +559,8 @@ - Models/BushAlive.mesh - + Models/Core/UnitCube.mesh + true diff --git a/resources/Shaders/ExplosionEffect.geom.glsl b/resources/Shaders/ExplosionEffect.geom.glsl index ffc78900..44b44aa6 100644 --- a/resources/Shaders/ExplosionEffect.geom.glsl +++ b/resources/Shaders/ExplosionEffect.geom.glsl @@ -1,7 +1,5 @@ #version 430 -#define MAX_SPLITS 4 - uniform mat4 M; uniform mat4 V; uniform mat4 P; @@ -24,7 +22,6 @@ in VertexData{ vec2 TextureCoordinate; vec4 ExplosionColor; float ExplosionPercentageElapsed; - vec4 PositionLightSpace[MAX_SPLITS]; }Input[]; out VertexData{ @@ -35,7 +32,6 @@ out VertexData{ vec2 TextureCoordinate; vec4 ExplosionColor; float ExplosionPercentageElapsed; - vec4 PositionLightSpace[MAX_SPLITS]; }Output; layout(triangles) in; @@ -149,7 +145,6 @@ void main() Output.TextureCoordinate = Input[i].TextureCoordinate; Output.Tangent = Input[i].Tangent; Output.BiTangent = Input[i].BiTangent; - Output.PositionLightSpace = Input[i].PositionLightSpace; // convert to model space for the gravity to always be in -y vec4 ExplodedPositionInModelSpace = M * vec4(ExplodedPosition, 1.0); @@ -191,7 +186,6 @@ void main() Output.TextureCoordinate = Input[i].TextureCoordinate; Output.Tangent = Input[i].Tangent; Output.BiTangent = Input[i].BiTangent; - Output.PositionLightSpace = Input[i].PositionLightSpace; // no change in position, pass through vertex gl_Position = gl_in[i].gl_Position; diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index f7ddd00c..aa45d118 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -1,7 +1,6 @@ #version 430 #define MIN_AMBIENT_LIGHT 0.3 -#define MAX_SPLITS 4 uniform mat4 M; uniform mat4 V; @@ -15,7 +14,6 @@ uniform float FillPercentage; uniform float GlowIntensity = 10; uniform vec3 CameraPosition; uniform int SSAOQuality; -uniform float FarDistance[MAX_SPLITS]; uniform vec2 DiffuseUVRepeat; uniform vec2 NormalUVRepeat; @@ -27,7 +25,6 @@ layout (binding = 2) uniform sampler2D NormalMapTexture; layout (binding = 3) uniform sampler2D SpecularMapTexture; layout (binding = 4) uniform sampler2D GlowMapTexture; layout (binding = 5) uniform samplerCube CubeMap; -layout (binding = 13) uniform sampler2DArrayShadow DepthMap; #define TILE_SIZE 16 @@ -62,6 +59,7 @@ layout (std430, binding = 4) buffer LightIndexBuffer float LightIndex[]; }; + in VertexData{ vec3 Position; vec3 Normal; @@ -70,7 +68,6 @@ in VertexData{ vec2 TextureCoordinate; vec4 ExplosionColor; float ExplosionPercentageElapsed; - vec4 PositionLightSpace[MAX_SPLITS]; }Input; out vec4 sceneColor; @@ -81,25 +78,6 @@ struct LightResult { vec4 Specular; }; -vec2 poissonDisk[16] = vec2[]( - vec2( -0.94201624, -0.39906216 ), - vec2( 0.94558609, -0.76890725 ), - vec2( -0.094184101, -0.92938870 ), - vec2( 0.34495938, 0.29387760 ), - vec2( -0.91588581, 0.45771432 ), - vec2( -0.81544232, -0.87912464 ), - vec2( -0.38277543, 0.27676845 ), - vec2( 0.97484398, 0.75648379 ), - vec2( 0.44323325, -0.97511554 ), - vec2( 0.53742981, -0.47373420 ), - vec2( -0.26496911, -0.41893023 ), - vec2( 0.79197514, 0.19090188 ), - vec2( -0.24188840, 0.99706507 ), - vec2( -0.81409955, 0.91437590 ), - vec2( 0.19984126, 0.78641367 ), - vec2( 0.14383161, -0.14100790 ) - ); - float CalcAttenuation(float radius, float dist, float falloff) { return 1.0 - smoothstep(radius * falloff, radius, dist); } @@ -146,154 +124,6 @@ vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textu return vec4(TBN * normalize(NormalMap), 0.0); } -// Returns a "random" value. -float Random(vec3 seed, int i) -{ - vec4 seed4 = vec4(seed, i); - float dot_product = dot(seed4, vec4(12.9898, 78.233, 45.164, 94.673)); - return fract(sin(dot_product) * 43758.5453); -} - -int getShadowIndex(float far_distance[1]) -{ - return 0; -} - -int getShadowIndex(float far_distance[2]) -{ - float depth = gl_FragCoord.z / gl_FragCoord.w; - - int index = 1; - if ( depth < far_distance[0] ) - { - index = 0; - } - - return index; -} - -int getShadowIndex(float far_distance[3]) -{ - float depth = gl_FragCoord.z / gl_FragCoord.w; - - int index = 2; - if ( depth < far_distance[0] ) - { - index = 0; - } - else if ( depth < far_distance[1] && depth > far_distance[0] ) - { - index = 1; - } - - return index; -} - -int getShadowIndex(float far_distance[4]) -{ - float depth = gl_FragCoord.z / gl_FragCoord.w; - - int index = 3; - if ( depth < far_distance[0] ) - { - index = 0; - } - else if ( depth < far_distance[1] && depth > far_distance[0] ) - { - index = 1; - } - else if ( depth < far_distance[2] && depth > far_distance[1] ) - { - index = 2; - } - - return index; -} - -// Standard hardware-calculated PCF method -float PCFShadow(sampler2DArrayShadow depth_texture_array, vec3 projection_coords, int layer_index) -{ - return texture(depth_texture_array, vec4(projection_coords.xy, layer_index, projection_coords.z)); -} - -// PCF + Poisson model method -float PoissonShadow(sampler2DArrayShadow depth_texture_array, vec3 projection_coords, int layer_index, int taps, float spread) -{ - int loop; - float multiplier = 1.0 / float(taps); - float shadowMapDepth; - - for (int i = 0; i < taps; i++) - { - loop = i; - vec3 newProjCoords = projection_coords + vec3(poissonDisk[loop], 0.0) / (spread * (1.0 + layer_index)); - shadowMapDepth += multiplier * texture(depth_texture_array, vec4(newProjCoords.xy, layer_index, newProjCoords.z)); - } - - return shadowMapDepth; -} - -// PCF + Poisson + RandomSample model method -float PoissonDotShadow(sampler2DArrayShadow depth_texture_array, vec3 projection_coords, int layer_index, int taps, float spread) -{ - int loop; - float multiplier = 1.0 / float(taps); - float shadowMapDepth; - - for (int i = 0; i < taps; i++) - { - loop = int(16.0 * Random(gl_FragCoord.xyy, i)) % 16; - vec3 newProjCoords = projection_coords + vec3(poissonDisk[loop], 0.0) / (spread * (1.0 + layer_index)); - shadowMapDepth += multiplier * texture(depth_texture_array, vec4(newProjCoords.xy, layer_index, newProjCoords.z)); - } - - return shadowMapDepth; -} - -// Hardware PCF + Additional software PCF method -float SoftwarePCF(sampler2DArrayShadow depth_texture_array, vec3 projection_coords, int layer_index, float bias) -{ - float shadow = 0.0; - - vec3 texelSize = 1.0 / textureSize(depth_texture_array, 0); - for(int x = -1; x <= 1; x++) - { - for(int y = -1; y <= 1; y++) - { - shadow += texture(depth_texture_array, vec4(projection_coords.xy + vec2(x, y) * texelSize.xy / (1.0 + layer_index), layer_index, projection_coords.z)); - } - } - - return shadow / 9.0; -} - -float CalcShadowValue(vec4 light_space_pos, vec3 normal, vec3 light_dir, sampler2DArrayShadow depth_texture_array, int layer_index) -{ - float shadowMapDepth; - float bias = 0.005; - - // Various bias methods. - - //bias = max(0.05 * (1.0 - dot(normal, light_dir)), bias); - //bias = bias * tan(acos(clamp(dot(normal, -light_dir), 0.0, 1.0))); - bias = bias + bias * tan(acos(clamp(dot(normal, -light_dir), 0.0, 1.0))); - - // Calculate coordinates in projection space. - - vec3 projCoords = vec3(light_space_pos.xy, light_space_pos.z + bias) / light_space_pos.w; - projCoords = projCoords * 0.5 + 0.5; - //projCoords = (floor(projCoords * 255.0)) / 255.0; - - // Various methods for shadow calculation in fastest to slowest order. - - //shadowMapDepth = PCFShadow(depth_texture_array, projCoords, layer_index); - //shadowMapDepth = PoissonShadow(depth_texture_array, projCoords, layer_index, 4, 25.0 * FarDistance[MAX_SPLITS - 1]); - //shadowMapDepth = PoissonDotShadow(depth_texture_array, projCoords, layer_index, 4, 25.0 * FarDistance[MAX_SPLITS - 1]); - shadowMapDepth = SoftwarePCF(depth_texture_array, projCoords, layer_index, bias); - - return shadowMapDepth; -} - void main() { float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy) >> int(SSAOQuality), 0).r; @@ -321,8 +151,6 @@ void main() int start = int(LightGrids.Data[currentTile].Start); int amount = int(LightGrids.Data[currentTile].Amount); - - float shadowFactor = 0.0; for(int i = start; i < start + amount; i++) { @@ -334,16 +162,11 @@ void main() if(light.Type == 1) { // point light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, position, normal, light.Falloff); } else if (light.Type == 2) { //Directional - int DepthMapIndex = getShadowIndex(FarDistance); light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal); - shadowFactor = CalcShadowValue(Input.PositionLightSpace[DepthMapIndex], Input.Normal, vec3(light.Direction), DepthMap, DepthMapIndex); } totalLighting.Diffuse += vec4(light_result.Diffuse.rgb * ao, light_result.Diffuse.a); totalLighting.Specular += vec4(light_result.Specular.rgb * ao, light_result.Specular.a); } - - totalLighting.Diffuse *= vec4(min(vec3(shadowFactor) + AmbientColor.xyz, vec3(1.0)), 1.0); - totalLighting.Specular *= vec4(min(vec3(shadowFactor) + AmbientColor.xyz, vec3(1.0)), 1.0); vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); diff --git a/resources/Shaders/ForwardPlus.vert.glsl b/resources/Shaders/ForwardPlus.vert.glsl index 2a54415b..26686222 100644 --- a/resources/Shaders/ForwardPlus.vert.glsl +++ b/resources/Shaders/ForwardPlus.vert.glsl @@ -1,12 +1,8 @@ #version 430 -#define MAX_SPLITS 4 - uniform mat4 M; uniform mat4 V; uniform mat4 P; -uniform mat4 LightV[MAX_SPLITS]; -uniform mat4 LightP[MAX_SPLITS]; layout(location = 0) in vec3 Position; layout(location = 1) in vec3 Normal; @@ -22,7 +18,6 @@ out VertexData{ vec2 TextureCoordinate; vec4 ExplosionColor; float ExplosionPercentageElapsed; - vec4 PositionLightSpace[MAX_SPLITS]; }Output; void main() @@ -36,9 +31,4 @@ void main() Output.BiTangent = vec3(TIM * vec4(BiTangent, 0.0)); Output.ExplosionColor = vec4(1.0); Output.ExplosionPercentageElapsed = 0.0; - - for(int i = 0; i < MAX_SPLITS; i++) - { - Output.PositionLightSpace[i] = LightP[i] * LightV[i] * M * vec4(Position, 1.0); - } } \ No newline at end of file diff --git a/resources/Shaders/ForwardPlusShieldCheck.frag.glsl b/resources/Shaders/ForwardPlusShieldCheck.frag.glsl index 8c7dce04..35db495b 100644 --- a/resources/Shaders/ForwardPlusShieldCheck.frag.glsl +++ b/resources/Shaders/ForwardPlusShieldCheck.frag.glsl @@ -1,7 +1,6 @@ #version 430 #define MIN_AMBIENT_LIGHT 0.3 -#define MAX_SPLITS 4 uniform mat4 M; uniform mat4 V; @@ -70,7 +69,6 @@ in VertexData{ vec2 TextureCoordinate; vec4 ExplosionColor; float ExplosionPercentageElapsed; - vec4 PositionLightSpace[MAX_SPLITS]; }Input; out vec4 sceneColor; diff --git a/resources/Shaders/ForwardPlusSkinned.vert.glsl b/resources/Shaders/ForwardPlusSkinned.vert.glsl index 12b3c406..5fd55a8c 100644 --- a/resources/Shaders/ForwardPlusSkinned.vert.glsl +++ b/resources/Shaders/ForwardPlusSkinned.vert.glsl @@ -1,13 +1,9 @@ #version 430 -#define MAX_SPLITS 4 - uniform mat4 M; uniform mat4 V; uniform mat4 P; uniform mat4 Bones[100]; -uniform mat4 LightV[MAX_SPLITS]; -uniform mat4 LightP[MAX_SPLITS]; layout(location = 0) in vec3 Position; layout(location = 1) in vec3 Normal; @@ -25,7 +21,6 @@ out VertexData{ vec2 TextureCoordinate; vec4 ExplosionColor; float ExplosionPercentageElapsed; - vec4 PositionLightSpace[MAX_SPLITS]; }Output; void main() @@ -48,9 +43,4 @@ void main() Output.BiTangent = vec3(M * vec4(BiTangent, 0.0)); Output.ExplosionColor = vec4(1.0); Output.ExplosionPercentageElapsed = 0.0; - - for(int i = 0; i < MAX_SPLITS; i++) - { - Output.PositionLightSpace[i] = LightP[i] * LightV[i] * M * boneTransform * vec4(Position, 1.0); - } } \ No newline at end of file diff --git a/resources/Shaders/ForwardPlusSplatMap.frag.glsl b/resources/Shaders/ForwardPlusSplatMap.frag.glsl index 655f5502..239c51b5 100644 --- a/resources/Shaders/ForwardPlusSplatMap.frag.glsl +++ b/resources/Shaders/ForwardPlusSplatMap.frag.glsl @@ -1,7 +1,5 @@ #version 430 -#define MAX_SPLITS 4 - uniform mat4 M; uniform mat4 V; uniform mat4 P; @@ -97,7 +95,6 @@ in VertexData{ vec2 TextureCoordinate; vec4 ExplosionColor; float ExplosionPercentageElapsed; - vec4 PositionLightSpace[MAX_SPLITS]; }Input; out vec4 sceneColor; diff --git a/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl b/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl index f933a605..c67a9c99 100644 --- a/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl +++ b/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl @@ -1,7 +1,6 @@ #version 430 #define MIN_AMBIENT_LIGHT 0.3 -#define MAX_SPLITS 4 uniform mat4 M; uniform mat4 V; @@ -84,7 +83,6 @@ in VertexData{ vec2 TextureCoordinate; vec4 ExplosionColor; float ExplosionPercentageElapsed; - vec4 PositionLightSpace[MAX_SPLITS]; }Input; out vec4 sceneColor; diff --git a/resources/Shaders/Shadow.frag.glsl b/resources/Shaders/Shadow.frag.glsl deleted file mode 100644 index c7d153c3..00000000 --- a/resources/Shaders/Shadow.frag.glsl +++ /dev/null @@ -1,22 +0,0 @@ -#version 430 - -#define ALPHA_CUTOFF 0.3 - -layout (binding = 24) uniform sampler2D DiffuseTexture; -uniform float Alpha; - -in VertexData{ - vec2 TextureCoordinate; -}Input; - -layout (location = 0) out float ShadowMap; - -void main() -{ - vec4 diffuseTexel = texture(DiffuseTexture, Input.TextureCoordinate) * Alpha; - - if (diffuseTexel.a < ALPHA_CUTOFF) - { - discard; - } -} \ No newline at end of file diff --git a/resources/Shaders/Shadow.vert.glsl b/resources/Shaders/Shadow.vert.glsl deleted file mode 100644 index 7b1b26fb..00000000 --- a/resources/Shaders/Shadow.vert.glsl +++ /dev/null @@ -1,18 +0,0 @@ -#version 430 - -uniform mat4 M; -uniform mat4 V; -uniform mat4 P; - -layout (location = 0) in vec3 Position; -layout (location = 4) in vec2 TextureCoords; - -out VertexData{ - vec2 TextureCoordinate; -}Output; - -void main() -{ - gl_Position = P * V * M * vec4(Position, 1.0); - Output.TextureCoordinate = TextureCoords; -} \ No newline at end of file diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 510c665e..6cdf42d1 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -1,10 +1,9 @@ #include "Rendering/DrawFinalPass.h" -DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass, ShadowPass* shadowPass) +DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass) : m_Renderer(renderer) , m_LightCullingPass(lightCullingPass) , m_CubeMapPass(cubeMapPass) , m_SSAOPass(ssaoPass) - , m_ShadowPass(shadowPass) { //TODO: Make sure that uniforms are not sent into shader if not needed. m_ShieldPixelRate = 8; @@ -344,14 +343,6 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, m_SSAOPass->SSAOTexture()); - glActiveTexture(GL_TEXTURE13); - if (m_ShadowPass->DepthMap() != NULL) { - glBindTexture(GL_TEXTURE_2D_ARRAY, m_ShadowPass->DepthMap()); - } - else { - glBindTexture(GL_TEXTURE_2D_ARRAY, m_WhiteTexture->m_Texture); - } - for (auto &job : jobs) { auto explosionEffectJob = std::dynamic_pointer_cast(job); if (explosionEffectJob) { @@ -1092,10 +1083,6 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptrGlowIntensity); - - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightP"), MAX_SPLITS, GL_FALSE, glm::value_ptr(*m_ShadowPass->LightP().data())); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightV"), MAX_SPLITS, GL_FALSE, glm::value_ptr(*m_ShadowPass->LightV().data())); - glUniform1fv(glGetUniformLocation(shaderHandle, "FarDistance"), MAX_SPLITS, m_ShadowPass->FarDistance().data()); GLERROR("END"); } @@ -1134,11 +1121,8 @@ void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptrGlowIntensity); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightP"), MAX_SPLITS, GL_FALSE, glm::value_ptr(*m_ShadowPass->LightP().data())); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "LightV"), MAX_SPLITS, GL_FALSE, glm::value_ptr(*m_ShadowPass->LightV().data())); - glUniform1fv(glGetUniformLocation(shaderHandle, "FarDistance"), MAX_SPLITS, m_ShadowPass->FarDistance().data()); + glUniform1f(Location_GlowIntensity, job->GlowIntensity); GLERROR("END"); } diff --git a/src/Engine/Rendering/FrameBuffer.cpp b/src/Engine/Rendering/FrameBuffer.cpp index ee02db94..da438e7a 100644 --- a/src/Engine/Rendering/FrameBuffer.cpp +++ b/src/Engine/Rendering/FrameBuffer.cpp @@ -53,20 +53,16 @@ void FrameBuffer::Generate() case GL_TEXTURE_2D: glFramebufferTexture2D(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle, 0); GLERROR("FrameBuffer generate: glFramebufferTexture2D"); + break; case GL_RENDERBUFFER: glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle); GLERROR("FrameBuffer generate: glFramebufferRenderbuffer"); break; - case GL_TEXTURE_2D_ARRAY: - glFramebufferTexture(GL_FRAMEBUFFER, (*it)->m_Attachment, *(*it)->m_ResourceHandle, 0); - GLERROR("FrameBuffer generate: glFramebufferTexture2DArray"); - break; } GLERROR("2"); - // Need GL_DEPTH_ATTACHMENT for shadows - if (/*(*it)->m_Attachment != GL_DEPTH_ATTACHMENT &&*/ (*it)->m_Attachment != GL_STENCIL_ATTACHMENT && (*it)->m_Attachment != GL_DEPTH_STENCIL_ATTACHMENT) { + if ((*it)->m_Attachment != GL_DEPTH_ATTACHMENT && (*it)->m_Attachment != GL_STENCIL_ATTACHMENT && (*it)->m_Attachment != GL_DEPTH_STENCIL_ATTACHMENT) { attachments.push_back((*it)->m_Attachment); } GLERROR("Attachment"); diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index b9a6aa05..3ce985b6 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -133,8 +133,6 @@ void Renderer::Draw(RenderFrame& frame) m_DrawFinalPass->ClearBuffer(); m_DrawBloomPass->ClearBuffer(); m_SSAOPass->ClearBuffer(); - m_ShadowPass->ClearBuffer(); - m_ShadowPass->DebugGUI(); PerformanceTimer::StopTimer("Renderer-ClearBuffers"); GLERROR("ClearBuffers"); for (auto scene : frame.RenderScenes) { @@ -150,9 +148,6 @@ void Renderer::Draw(RenderFrame& frame) PerformanceTimer::StartTimer("Renderer-Depth"); SortRenderJobsByDepth(*scene); GLERROR("SortByDepth"); - PerformanceTimer::StartTimerAndStopPrevious("Draw shadow maps"); - m_ShadowPass->Draw(*scene); - GLERROR("Draw shadow maps"); PerformanceTimer::StartTimerAndStopPrevious("Renderer-Generate Frustrums"); m_LightCullingPass->GenerateNewFrustum(*scene); GLERROR("Generate frustums"); @@ -249,8 +244,7 @@ void Renderer::InitializeRenderPasses() m_LightCullingPass = new LightCullingPass(this); m_CubeMapPass = new CubeMapPass(this); m_SSAOPass = new SSAOPass(this, m_Config); - m_ShadowPass = new ShadowPass(this); - m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass, m_SSAOPass, m_ShadowPass); + m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass, m_SSAOPass); m_DrawScreenQuadPass = new DrawScreenQuadPass(this); m_DrawBloomPass = new DrawBloomPass(this, m_Config); m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this); diff --git a/src/Engine/Rendering/ShadowPass.cpp b/src/Engine/Rendering/ShadowPass.cpp deleted file mode 100644 index daf63ef2..00000000 --- a/src/Engine/Rendering/ShadowPass.cpp +++ /dev/null @@ -1,305 +0,0 @@ -#include "Rendering/ShadowPass.h" - -ShadowPass::ShadowPass(IRenderer * renderer, int shadow_res_x, int shadow_res_y) -{ - m_Renderer = renderer; - m_ResolutionSizeWidth = shadow_res_x; - m_ResolutionSizeHeight = shadow_res_y; - - InitializeFrameBuffers(); - InitializeShaderPrograms(); -} - -ShadowPass::ShadowPass(IRenderer * renderer) -{ - m_Renderer = renderer; - - InitializeFrameBuffers(); - InitializeShaderPrograms(); -} - -ShadowPass::~ShadowPass() -{ - -} - -void ShadowPass::DebugGUI() -{ - ImGui::Checkbox("EnableShadows", &m_EnableShadows); - ImGui::DragFloat2("ShadowMapNearFar", m_NearFarPlane, 1.f, -1000.f, 1000.f); - ImGui::DragFloat("ShadowClippingWeight", &m_SplitWeight, 0.001f, 0.f, 1.f); - ImGui::Checkbox("ShadowTransparentObjects", &m_TransparentObjects); - ImGui::Checkbox("ShadowOnTextureAlphas", &m_TexturedShadows); -} - -void ShadowPass::InitializeCameras(RenderScene & scene) -{ - for (int i = 0; i < m_CurrentNrOfSplits; i++) { - m_shadowFrusta[i].AspectRatio = scene.Camera->AspectRatio(); - m_shadowFrusta[i].FOV = scene.Camera->FOV(); - } -} - -// UpdateSplitDist computes the near and far distances for every frustum slice -// in camera eye space - that is, at what distance does a slice start and end -void ShadowPass::UpdateSplitDist(std::array& frusta, float near_distance, float far_distance) -{ - float lambda = m_SplitWeight; - float ratio = far_distance / near_distance; - - frusta[0].NearClip = near_distance; - - for (int i = 1; i < m_CurrentNrOfSplits; i++) { - float si = i / static_cast(m_CurrentNrOfSplits); - - frusta[i].NearClip = lambda * (near_distance * powf(ratio, si)) + (1 - lambda) * (near_distance + (far_distance - near_distance) * si); - frusta[i - 1].FarClip = frusta[i].NearClip * 1.005f; - } - - frusta[m_CurrentNrOfSplits - 1].FarClip = far_distance; -} - -void ShadowPass::UpdateFrustumPoints(ShadowFrustum& frustum, glm::mat4 p, glm::mat4 v) -{ - std::array CornerPoint = { - glm::vec4(-1.f, -1.f, -1.f, 1.f), - glm::vec4(-1.f, 1.f, -1.f, 1.f), - glm::vec4(1.f, 1.f, -1.f, 1.f), - glm::vec4(1.f, -1.f, -1.f, 1.f), - glm::vec4(-1.f, -1.f, 1.f, 1.f), - glm::vec4(-1.f, 1.f, 1.f, 1.f), - glm::vec4(1.f, 1.f, 1.f, 1.f), - glm::vec4(1.f, -1.f, 1.f, 1.f) - }; - - for (int i = 0; i < 8; i++) { - glm::vec4 NDC = glm::inverse(p) * CornerPoint[i]; - NDC = NDC / NDC.w; - frustum.CornerPoint[i] = glm::vec3(glm::inverse(v) * NDC); - } -} - -// Compute the 8 corner points of the current view frustum in world space -void ShadowPass::UpdateFrustumPoints(ShadowFrustum& frustum, glm::vec3 camera_position, glm::vec3 view_dir) -{ - glm::vec3 up = glm::vec3(0.f, 1.f, 0.f); - glm::vec3 right = glm::normalize(glm::cross(view_dir, up)); - - glm::vec3 far_center = camera_position + glm::normalize(view_dir) * frustum.FarClip; - glm::vec3 near_center = camera_position + glm::normalize(view_dir) * frustum.NearClip; - frustum.MiddlePoint = near_center + (far_center - near_center) * 0.5f; - - up = glm::normalize(glm::cross(right, view_dir)); - - // these heights and widths are half the heights and widths of the near and far plane rectangles. - float near_height = tan(frustum.FOV / 2.f) * frustum.NearClip; - float near_width = near_height * frustum.AspectRatio; - float far_height = tan(frustum.FOV / 2.f) * frustum.FarClip; - float far_width = far_height * frustum.AspectRatio; - - frustum.CornerPoint[0] = near_center - up * near_height - right * near_width; - frustum.CornerPoint[1] = near_center + up * near_height - right * near_width; - frustum.CornerPoint[2] = near_center + up * near_height + right * near_width; - frustum.CornerPoint[3] = near_center - up * near_height + right * near_width; - - frustum.CornerPoint[4] = far_center - up * far_height - right * far_width; - frustum.CornerPoint[5] = far_center + up * far_height - right * far_width; - frustum.CornerPoint[6] = far_center + up * far_height + right * far_width; - frustum.CornerPoint[7] = far_center - up * far_height + right * far_width; -} - -float ShadowPass::FindRadius(ShadowFrustum& frustum) -{ - float radius = 0.f; - - for (int i = 0; i < 8; i++) { - float distance = glm::distance(frustum.MiddlePoint, frustum.CornerPoint[i]); - if (distance > radius) { - radius = distance; - } - } - - frustum.Radius = radius; - return radius; -} - -void ShadowPass::InitializeFrameBuffers() -{ - // Depth texture - glGenTextures(1, &m_DepthMap); - - glBindTexture(GL_TEXTURE_2D_ARRAY, m_DepthMap); - glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_DEPTH_COMPONENT16, m_ResolutionSizeWidth, m_ResolutionSizeHeight, m_CurrentNrOfSplits); - - glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, m_ResolutionSizeWidth, m_ResolutionSizeHeight, m_CurrentNrOfSplits, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr); - - glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); - glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); - glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); - glTexParameterfv(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_BORDER_COLOR, glm::vec4(1.f).data); - glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); - - m_DepthBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthMap, GL_DEPTH_ATTACHMENT))); - m_DepthBuffer.Generate(); - - GLERROR("depthMap failed END"); -} - -void ShadowPass::InitializeShaderPrograms() -{ - m_ShadowProgram = ResourceManager::Load("#ShadowProgram"); - m_ShadowProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/Shadow.vert.glsl"))); - m_ShadowProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/Shadow.frag.glsl"))); - m_ShadowProgram->Compile(); - m_ShadowProgram->BindFragDataLocation(0, "ShadowMap"); - m_ShadowProgram->Link(); - - -} - -void ShadowPass::ClearBuffer() -{ - m_DepthBuffer.Bind(); - - for (int i = 0; i < m_CurrentNrOfSplits; i++) { - glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_DepthMap, 0, i); - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - } - - m_DepthBuffer.Unbind(); -} - -void ShadowPass::PointsToLightspace(ShadowFrustum& frustum, glm::mat4 v) -{ - float left = INFINITY; - float right = -INFINITY; - float bottom = INFINITY; - float top = -INFINITY; - - for (int i = 0; i < 8; i++) - { - glm::vec3 tempPoint = glm::vec3(v * glm::vec4(frustum.CornerPoint[i], 1.f)); - - if (tempPoint.x < left) { left = tempPoint.x; } - if (tempPoint.x > right) { right = tempPoint.x; } - if (tempPoint.y < bottom) { bottom = tempPoint.y; } - if (tempPoint.y > top) { top = tempPoint.y; } - } - - frustum.LRBT = { left, right, bottom, top }; -} - -void ShadowPass::RadiusToLightspace(ShadowFrustum& frustum) -{ - float quantizationStep = 1.0f / m_ResolutionSizeHeight; - - float left = -frustum.Radius; - float right = frustum.Radius; - float bottom = -frustum.Radius; - float top = frustum.Radius; - - frustum.LRBT = { left, right, bottom, top }; -} - -void ShadowPass::Draw(RenderScene & scene) -{ - if (m_EnableShadows) { - InitializeCameras(scene); - UpdateSplitDist(m_shadowFrusta, scene.Camera->NearClip(), scene.Camera->FarClip()); - - ShadowPassState* state = new ShadowPassState(m_DepthBuffer.GetHandle()); - - m_ShadowProgram->Bind(); - GLuint shaderHandle = m_ShadowProgram->GetHandle(); - glViewport(0, 0, m_ResolutionSizeWidth, m_ResolutionSizeHeight); - - for (int i = 0; i < m_CurrentNrOfSplits; i++) { - UpdateFrustumPoints(m_shadowFrusta[i], scene.Camera->Position(), scene.Camera->Forward()); - - glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_DepthMap, 0, i); - - for (auto &job : scene.Jobs.DirectionalLight) { - auto directionalLightJob = std::dynamic_pointer_cast(job); - - if (directionalLightJob) { - m_LightView[i] = glm::lookAt(glm::vec3(-directionalLightJob->Direction) + m_shadowFrusta[i].MiddlePoint, m_shadowFrusta[i].MiddlePoint, glm::vec3(0.f, 1.f, 0.f)); - - PointsToLightspace(m_shadowFrusta[i], m_LightView[i]); - //FindRadius(m_shadowFrusta[i]); - //RadiusToLightspace(m_shadowFrusta[i]); - m_LightProjection[i] = glm::ortho(m_shadowFrusta[i].LRBT[LEFT], m_shadowFrusta[i].LRBT[RIGHT], m_shadowFrusta[i].LRBT[BOTTOM], m_shadowFrusta[i].LRBT[TOP], m_NearFarPlane[NEAR], m_NearFarPlane[FAR]); - - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection[i])); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView[i])); - - GLERROR("ShadowLight ERROR"); - - for (auto &objectJob : scene.Jobs.OpaqueObjects) { - if (!std::dynamic_pointer_cast(objectJob)) { - auto modelJob = std::dynamic_pointer_cast(objectJob); - - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); - glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), 1.f); - - 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("Shadow Draw ERROR"); - } - } - if (m_TransparentObjects) { - state->CullFace(GL_BACK); - for (auto &objectJob : scene.Jobs.TransparentObjects) { - if (!std::dynamic_pointer_cast(objectJob)) { - auto modelJob = std::dynamic_pointer_cast(objectJob); - - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); - glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), modelJob->Color.a); - - if (m_TexturedShadows) { - switch (modelJob->Type) { - case RawModel::MaterialType::SingleTextures: - case RawModel::MaterialType::Basic: - { - glActiveTexture(GL_TEXTURE24); - if (modelJob->DiffuseTexture.size() > 0 && modelJob->DiffuseTexture[0]->Texture != nullptr) { - glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture[0]->Texture->m_Texture); - glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(modelJob->DiffuseTexture[0]->UVRepeat)); - } - else { - glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); - glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f))); - } - break; - } - case RawModel::MaterialType::SplatMapping: - { - glActiveTexture(GL_TEXTURE24); - glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); - glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f))); - break; - } - } - } - - 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("Shadow Draw ERROR"); - } - } - state->CullFace(GL_FRONT); - } - } - } - } - glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); - m_DepthBuffer.Unbind(); - delete state; - } -} \ No newline at end of file diff --git a/src/Engine/Rendering/ShadowPassState.cpp b/src/Engine/Rendering/ShadowPassState.cpp deleted file mode 100644 index 2211e3ab..00000000 --- a/src/Engine/Rendering/ShadowPassState.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "Rendering/ShadowPassState.h" - -ShadowPassState::ShadowPassState(GLuint frameBuffer) -{ - BindFramebuffer(frameBuffer); - Enable(GL_DEPTH_TEST); - Enable(GL_CULL_FACE); - Disable(GL_BLEND); - Disable(GL_TEXTURE_2D); - CullFace(GL_FRONT); - ClearColor(glm::vec4(0.f, 0.f, 0.f, 0.f)); - //Enable(GL_ALPHA_TEST); - //glAlphaFunc(GL_GREATER, 0.9f); -} - -ShadowPassState::~ShadowPassState() -{ - -} \ No newline at end of file From a7bff928991f7e76b28764922c4271473b0f3913 Mon Sep 17 00:00:00 2001 From: stiffly Date: Thu, 3 Mar 2016 15:16:42 +0100 Subject: [PATCH 186/252] The readBuffer now checks if the whole packet has arrived before attempting to parse it. --- src/Engine/Network/Packet.cpp | 6 ++++-- src/Engine/Network/TCPClient.cpp | 5 ++++- src/Engine/Network/TCPServer.cpp | 5 ++++- src/Engine/Network/UDPClient.cpp | 5 ++++- src/Engine/Network/UDPServer.cpp | 5 +++++ 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/Engine/Network/Packet.cpp b/src/Engine/Network/Packet.cpp index 74afd656..6a4d0098 100644 --- a/src/Engine/Network/Packet.cpp +++ b/src/Engine/Network/Packet.cpp @@ -54,8 +54,10 @@ void Packet::WriteString(const std::string& str) } resizeData(); } - memcpy(m_Data + m_Offset, str.data(), sizeOfString * sizeof(char)); - m_Offset += sizeOfString * sizeof(char); + memcpy(m_Data + m_Offset, str.data(), str.size() * sizeof(char)); + m_Offset += str.size() * sizeof(char); + m_Data[m_Offset] = '\0'; + m_Offset += 1; } void Packet::WriteData(char * data, int sizeOfData) diff --git a/src/Engine/Network/TCPClient.cpp b/src/Engine/Network/TCPClient.cpp index f3394d3d..8bfa9ded 100644 --- a/src/Engine/Network/TCPClient.cpp +++ b/src/Engine/Network/TCPClient.cpp @@ -74,7 +74,10 @@ size_t TCPClient::readBuffer() boost::asio::ip::tcp::socket::message_peek, error); unsigned int sizeOfPacket = 0; memcpy(&sizeOfPacket, m_ReadBuffer, sizeof(int)); - + if (sizeOfPacket > m_Socket->available()) { + LOG_WARNING("TCPClient::readBuffer(): We haven't got the whole packet yet."); + return 0; + } // if the buffer is to small increase the size of it // TODO if message is huge 1 time the buffer will not decrease. if (sizeOfPacket > m_BufferSize) { diff --git a/src/Engine/Network/TCPServer.cpp b/src/Engine/Network/TCPServer.cpp index acd3d6d0..ff35aa91 100644 --- a/src/Engine/Network/TCPServer.cpp +++ b/src/Engine/Network/TCPServer.cpp @@ -106,7 +106,10 @@ int TCPServer::readBuffer(PlayerDefinition & playerDefinition) boost::asio::ip::tcp::socket::message_peek, error); unsigned int sizeOfPacket = 0; memcpy(&sizeOfPacket, m_ReadBuffer, sizeof(int)); - + if (sizeOfPacket > playerDefinition.TCPSocket->available()) { + LOG_WARNING("TCPServer::readBuffer(): We haven't got the whole packet yet."); + return 0; + } // if the buffer is to small increase the size of it if (sizeOfPacket > m_BufferSize) { delete[] m_ReadBuffer; diff --git a/src/Engine/Network/UDPClient.cpp b/src/Engine/Network/UDPClient.cpp index 51c29920..a7061884 100644 --- a/src/Engine/Network/UDPClient.cpp +++ b/src/Engine/Network/UDPClient.cpp @@ -45,7 +45,10 @@ int UDPClient::readBuffer() boost::asio::ip::udp::socket::message_peek, error); int sizeOfPacket = 0; memcpy(&sizeOfPacket, m_ReadBuffer, sizeof(int)); - + if (sizeOfPacket > m_Socket->available()) { + LOG_WARNING("UDPClient::readBuffer(): We haven't got the whole packet yet."); + return 0; + } // if the buffer is to small increase the size of it if (sizeOfPacket > m_BufferSize) { delete[] m_ReadBuffer; diff --git a/src/Engine/Network/UDPServer.cpp b/src/Engine/Network/UDPServer.cpp index 635ebd4d..13dd5ccd 100644 --- a/src/Engine/Network/UDPServer.cpp +++ b/src/Engine/Network/UDPServer.cpp @@ -92,6 +92,11 @@ int UDPServer::readBuffer() unsigned int sizeOfPacket = 0; memcpy(&sizeOfPacket, m_ReadBuffer, sizeof(int)); + if (sizeOfPacket > m_Socket->available()) { + LOG_WARNING("UDPServer::readBuffer(): We haven't got the whole packet yet."); + return 0; + } + // if the buffer is to small increase the size of it if (sizeOfPacket > m_BufferSize) { delete[] m_ReadBuffer; From 8859f652b92ffcd1a5bb8c85203036a9dd3a721f Mon Sep 17 00:00:00 2001 From: William Moberg Date: Thu, 3 Mar 2016 15:48:55 +0100 Subject: [PATCH 187/252] Input ClassPick now switches to a camera with class buttons, they do nothing now and have test textures. --- resources/DefaultInput.ini | 3 +- .../Schema/Entities/NewMapWSpectatorCam.xml | 3690 +++++++++-------- resources/Schema/Entities/OverwatchCamera.xml | 296 ++ resources/Schema/Entities/SpectatorCamera.xml | 219 - src/Game/Systems/PlayerSpawnSystem.cpp | 19 +- 5 files changed, 2196 insertions(+), 2031 deletions(-) create mode 100644 resources/Schema/Entities/OverwatchCamera.xml delete mode 100644 resources/Schema/Entities/SpectatorCamera.xml diff --git a/resources/DefaultInput.ini b/resources/DefaultInput.ini index 776cbecd..4dea88fd 100644 --- a/resources/DefaultInput.ini +++ b/resources/DefaultInput.ini @@ -27,4 +27,5 @@ M=SwitchToClient P=SwitchToPlayer K=TakeDamage,1500 F2=PerformanceTimingResetAllTimers -F3=PerformanceTimingCreateExcelData \ No newline at end of file +F3=PerformanceTimingCreateExcelData +F4=PickClass \ No newline at end of file diff --git a/resources/Schema/Entities/NewMapWSpectatorCam.xml b/resources/Schema/Entities/NewMapWSpectatorCam.xml index bf1b4c2b..79cdc2be 100644 --- a/resources/Schema/Entities/NewMapWSpectatorCam.xml +++ b/resources/Schema/Entities/NewMapWSpectatorCam.xml @@ -3,7 +3,6 @@ - 0.0 15 @@ -24,6 +23,16 @@ + + + + + Models/Props/Highground4.mesh + + + + + @@ -78,16 +87,6 @@ - - - - - Models/Props/Highground4.mesh - - - - - @@ -286,8 +285,8 @@ - + @@ -300,8 +299,8 @@ - + @@ -314,8 +313,8 @@ - + @@ -328,8 +327,8 @@ - + @@ -432,8 +431,8 @@ - + @@ -446,8 +445,8 @@ - + @@ -460,8 +459,8 @@ - + @@ -500,8 +499,8 @@ - + @@ -527,8 +526,8 @@ - + @@ -566,6 +565,19 @@ + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + @@ -691,8 +703,8 @@ - + @@ -705,8 +717,8 @@ - + @@ -779,19 +791,6 @@ - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - @@ -1042,8 +1041,8 @@ - + @@ -1512,8 +1511,8 @@ - + @@ -1744,8 +1743,8 @@ - + @@ -1822,8 +1821,8 @@ - + @@ -1836,8 +1835,8 @@ - + @@ -1857,8 +1856,8 @@ - + @@ -1871,8 +1870,8 @@ - + @@ -1898,8 +1897,8 @@ - + @@ -2017,8 +2016,8 @@ - + @@ -2137,8 +2136,8 @@ - + @@ -2177,8 +2176,8 @@ - + @@ -2217,8 +2216,8 @@ - + @@ -2238,8 +2237,8 @@ - + @@ -2252,8 +2251,8 @@ - + @@ -2407,8 +2406,8 @@ - + @@ -2436,8 +2435,8 @@ - + @@ -2451,8 +2450,8 @@ - + @@ -2465,8 +2464,8 @@ - + @@ -2478,8 +2477,8 @@ - + @@ -2494,8 +2493,8 @@ - + @@ -2508,8 +2507,8 @@ - + @@ -2616,8 +2615,8 @@ - + @@ -2877,8 +2876,8 @@ - + @@ -2891,8 +2890,8 @@ - + @@ -2917,8 +2916,8 @@ - + @@ -2933,8 +2932,8 @@ - + @@ -2947,8 +2946,8 @@ - + @@ -2975,8 +2974,8 @@ - + @@ -2989,8 +2988,8 @@ - + @@ -3016,8 +3015,8 @@ - + @@ -3031,8 +3030,8 @@ - + @@ -3046,8 +3045,8 @@ - + @@ -3061,8 +3060,8 @@ - + @@ -3083,1153 +3082,39 @@ - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + @@ -4347,22 +3232,8 @@ - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - @@ -4375,8 +3246,28 @@ - + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + @@ -4385,12 +3276,1120 @@ - Models/Props/Stones/AssaultHolder.mesh + Models/Props/Stones/MediumStone1.mesh - + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + - + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + @@ -4402,6 +4401,19 @@ + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + @@ -4480,19 +4492,6 @@ - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - @@ -4517,38 +4516,12 @@ - Models/Props/Stones/ShinyStoneCrystalRed.mesh + Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - + + - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - @@ -4561,133 +4534,8 @@ - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - @@ -4712,9 +4560,36 @@ Models/Props/Stones/ShinyStoneCrystalBlue.mesh - + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + - @@ -4727,8 +4602,132 @@ - + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + @@ -4741,8 +4740,8 @@ - + @@ -4751,6 +4750,235 @@ + + + + + Schema/Entities/PlayerRed.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + @@ -4775,6 +5003,7 @@ 4 + Models/Core/UnitCylinder.mesh @@ -4789,7 +5018,6 @@ - @@ -4811,6 +5039,7 @@ 3 + Models/Core/UnitCylinder.mesh @@ -4821,7 +5050,6 @@ - @@ -4843,6 +5071,7 @@ 2 + Models/Core/UnitCylinder.mesh @@ -4853,7 +5082,6 @@ - @@ -4876,6 +5104,7 @@ 1.5498908015879351 1 + Models/Core/UnitCylinder.mesh @@ -4886,7 +5115,6 @@ - @@ -4910,6 +5138,7 @@ + Models/Core/UnitCylinder.mesh @@ -4924,7 +5153,6 @@ - @@ -4937,6 +5165,17 @@ + + + + 10 + + + + + + + @@ -4991,17 +5230,6 @@ - - - - 10 - - - - - - - @@ -5015,76 +5243,6 @@ - - - - - Schema/Entities/PlayerRed.xml - - - - - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - @@ -5122,7 +5280,7 @@ false - + @@ -5135,7 +5293,7 @@ false - + @@ -5155,366 +5313,286 @@ - + - - - - - - - - 0.10000000149011612 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - 0.10000000149011612 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - - - 0.10000000149011612 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - 0.10000000149011612 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - 0.10000000149011612 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - - - 0.10000000149011612 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - 0.10000000149011612 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - - - 0.10000000149011612 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - - - + + 0.049999997019767761 + + - - + - + - + + - + - - - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - + + - + - - Textures/Core/UnitHexagon.png - - - - + - + - - 2 - - - - + - Textures/Core/UnitHexagon_Rotated.png + Textures/Core/UnitRaptor.png - - - + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + Textures/Test/aM4ME4GR.png + + + + + - + + + + + + + + + - - Textures/Core/UnitHexagon.png - - - - + - + - - 3 - - - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - + + - + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 2 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 3 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 4 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 1 + + + 0.10332605343919568 + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - + - - 4 - - - - - - Textures/Core/UnitHexagon_Rotated.png - - + + 16 + Fonts/DroidSans.ttf,64 + + - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - 1 - - - 0.59265931447347009 - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - + + diff --git a/resources/Schema/Entities/OverwatchCamera.xml b/resources/Schema/Entities/OverwatchCamera.xml new file mode 100644 index 00000000..323a62f2 --- /dev/null +++ b/resources/Schema/Entities/OverwatchCamera.xml @@ -0,0 +1,296 @@ + + + + + + 0.049999997019767761 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Textures/Core/UnitRaptor.png + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + Textures/Test/aM4ME4GR.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 2 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 3 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 4 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 1 + + + 0.10332605343919568 + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + + + 5 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/SpectatorCamera.xml b/resources/Schema/Entities/SpectatorCamera.xml deleted file mode 100644 index 5c3dc514..00000000 --- a/resources/Schema/Entities/SpectatorCamera.xml +++ /dev/null @@ -1,219 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - Time to respawn: 0 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - 2 - - - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - 3 - - - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - 4 - - - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - 1 - - - 0.59265931447347009 - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - - - - - diff --git a/src/Game/Systems/PlayerSpawnSystem.cpp b/src/Game/Systems/PlayerSpawnSystem.cpp index fbda849d..7a6881c4 100644 --- a/src/Game/Systems/PlayerSpawnSystem.cpp +++ b/src/Game/Systems/PlayerSpawnSystem.cpp @@ -105,7 +105,7 @@ void PlayerSpawnSystem::Update(double dt) bool PlayerSpawnSystem::OnInputCommand(Events::InputCommand& e) { - if (e.Command != "PickTeam") { + if (e.Command != "PickTeam" && e.Command != "PickClass") { return false; } @@ -113,11 +113,12 @@ bool PlayerSpawnSystem::OnInputCommand(Events::InputCommand& e) return false; } - // A dead client should be able to swap to the spectator camera. + // A dead client should be able to swap to the overwatch camera. if (IsClient && !LocalPlayer.Valid()) { - // Set the spectator camera as active, if it exists. - // Find the camera. - EntityWrapper spectatorCam = m_World->GetFirstEntityByName("SpectatorCamera"); + // Set the camera as active, if it exists. + // Find the respawn camera or class pick camera. + std::string camName = e.Command == "PickClass" ? "PickClassCamera" : "SpectatorCamera"; + EntityWrapper spectatorCam = m_World->GetFirstEntityByName(camName); if (spectatorCam.Valid() && spectatorCam.HasComponent("Camera")) { Events::SetCamera eSetCamera; eSetCamera.CameraEntity = spectatorCam; @@ -135,10 +136,18 @@ bool PlayerSpawnSystem::OnInputCommand(Events::InputCommand& e) auto iter = m_SpawnRequests.begin(); for (; iter != m_SpawnRequests.end(); ++iter) { if (iter->PlayerID == e.PlayerID) { + // If player wants to switch class, remove their spawn request. + if (e.Command == "PickClass") { + m_SpawnRequests.erase(iter); + } break; } } + if (e.Command == "PickClass") { + return true; + } + if (iter != m_SpawnRequests.end()) { // If player is in queue to spawn, then change their team affiliation in the request. iter->Team = (ComponentInfo::EnumType)e.Value; From 398bc725b670da2ee8b864332d0c643ca75603da Mon Sep 17 00:00:00 2001 From: William Moberg Date: Thu, 3 Mar 2016 16:32:24 +0100 Subject: [PATCH 188/252] When pick class buttons are clicked they send an InputCommand, not an ButtonClicked event. --- resources/Schema/Components.xsd | 1 + .../Schema/Components/InputCmdButton.xml | 5 + .../Schema/Components/InputCmdButton.xsd | 19 + .../Schema/Entities/NewMapWSpectatorCam.xml | 2300 +++++++++-------- resources/Schema/Entities/OverwatchCamera.xml | 132 +- resources/Schema/Types/Entity.xsd | 1 + src/Engine/GUI/ButtonSystem.cpp | 35 +- 7 files changed, 1281 insertions(+), 1212 deletions(-) create mode 100644 resources/Schema/Components/InputCmdButton.xml create mode 100644 resources/Schema/Components/InputCmdButton.xsd diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index 004a11a7..bb629094 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -59,4 +59,5 @@ + \ No newline at end of file diff --git a/resources/Schema/Components/InputCmdButton.xml b/resources/Schema/Components/InputCmdButton.xml new file mode 100644 index 00000000..58c3ba2c --- /dev/null +++ b/resources/Schema/Components/InputCmdButton.xml @@ -0,0 +1,5 @@ + + + + 0.0 + \ No newline at end of file diff --git a/resources/Schema/Components/InputCmdButton.xsd b/resources/Schema/Components/InputCmdButton.xsd new file mode 100644 index 00000000..f4dd8d3f --- /dev/null +++ b/resources/Schema/Components/InputCmdButton.xsd @@ -0,0 +1,19 @@ + + + + + + + Used with a Button component, the button will send an inputCommand event instead of ButtonPressed/Released event. + + + + The command name for the inputCommand. + + + The value in inputCommand.Value that will be sent on button press. + + + + + \ No newline at end of file diff --git a/resources/Schema/Entities/NewMapWSpectatorCam.xml b/resources/Schema/Entities/NewMapWSpectatorCam.xml index 79cdc2be..395eb1de 100644 --- a/resources/Schema/Entities/NewMapWSpectatorCam.xml +++ b/resources/Schema/Entities/NewMapWSpectatorCam.xml @@ -23,6 +23,16 @@ + + + + + Models/Props/Highground3.mesh + + + + + @@ -77,16 +87,6 @@ - - - - - Models/Props/Highground3.mesh - - - - - @@ -3082,6 +3082,148 @@ + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + @@ -3263,57 +3405,16 @@ - Models/Props/Stones/BigStone.mesh + Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - + + - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - @@ -3342,6 +3443,47 @@ + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + @@ -3357,12 +3499,11 @@ - Models/Props/Stones/SmallStone1.mesh + Models/Props/Stones/BigStone.mesh - - - + + @@ -3384,11 +3525,12 @@ - Models/Props/Stones/BigStone.mesh + Models/Props/Stones/SmallStone1.mesh - - + + + @@ -3400,8 +3542,8 @@ Models/Props/Stones/BigStone.mesh - - + + @@ -3428,104 +3570,8 @@ Models/Props/Stones/BigStone.mesh - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - + + @@ -3544,6 +3590,34 @@ + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + @@ -3551,8 +3625,8 @@ Models/Props/Stones/BigStone.mesh - - + + @@ -3578,13 +3652,252 @@ Models/Props/Stones/SmallStone2.mesh - - + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + @@ -3603,11 +3916,12 @@ - Models/Props/Stones/BigStone.mesh + Models/Props/Stones/MediumStone1.mesh - - + + + @@ -3619,8 +3933,103 @@ Models/Props/Stones/SmallStone2.mesh - - + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + @@ -3639,19 +4048,6 @@ - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - @@ -3666,19 +4062,6 @@ - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - @@ -3693,47 +4076,6 @@ - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - @@ -3747,20 +4089,6 @@ - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - @@ -3775,46 +4103,6 @@ - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - @@ -3827,32 +4115,6 @@ - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - @@ -3880,6 +4142,19 @@ + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + @@ -3893,6 +4168,19 @@ + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + @@ -3909,19 +4197,6 @@ - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - @@ -3934,19 +4209,6 @@ - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - @@ -3961,18 +4223,6 @@ - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - @@ -3987,19 +4237,6 @@ - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - @@ -4012,20 +4249,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - @@ -4039,20 +4262,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - @@ -4102,12 +4311,11 @@ - Models/Props/Stones/SmallStone2.mesh + Models/Props/Stones/SmallStone1.mesh - - - + + @@ -4116,11 +4324,12 @@ - Models/Props/Stones/SmallStone1.mesh + Models/Props/Stones/SmallStone2.mesh - - + + + @@ -4143,19 +4352,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - @@ -4170,47 +4366,6 @@ - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - @@ -4225,19 +4380,6 @@ - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - @@ -4254,153 +4396,24 @@ - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + @@ -4479,19 +4492,6 @@ - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - @@ -4512,74 +4512,6 @@ - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - @@ -4601,91 +4533,8 @@ Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - + + @@ -4711,8 +4560,36 @@ Models/Props/Stones/ShinyStoneCrystalRed.mesh - - + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + @@ -4732,6 +4609,129 @@ + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + @@ -4750,19 +4750,102 @@ - + + + + + + + + + 10 + + + + + + + + + + + 1 + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + 10 + + + + + + + + + + + + + 10 + + + + + + + + + + + 1 + + + + + + + + + + - Schema/Entities/PlayerRed.xml + Schema/Entities/Player.xml - + - + @@ -4774,7 +4857,7 @@ false - + @@ -4787,7 +4870,7 @@ false - + @@ -4800,7 +4883,7 @@ false - + @@ -4813,166 +4896,7 @@ false - - - - - - - - - - - - - - - - - - 0.10000000149011612 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - - - 0.10000000149011612 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - 0.10000000149011612 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - - - 0.10000000149011612 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - 0.10000000149011612 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - 0.10000000149011612 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - 0.10000000149011612 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - - - 0.10000000149011612 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - + @@ -4988,10 +4912,42 @@ - Models/Props/CapturePoint/CapturePointBlue.mesh + Models/Props/CapturePoint/CapturePointNeutral.mesh - + + + + + + + + 2 + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointRed.mesh + + + @@ -4999,24 +4955,23 @@ - + - 4 Models/Core/UnitCylinder.mesh - + true - + - - + + @@ -5055,38 +5010,6 @@ - - - - - Models/Props/CapturePoint/CapturePointNeutral.mesh - - - - - - - - - - 2 - - - - Models/Core/UnitCylinder.mesh - - true - - - - - - - - - - - @@ -5124,10 +5047,10 @@ - Models/Props/CapturePoint/CapturePointRed.mesh + Models/Props/CapturePoint/CapturePointBlue.mesh - + @@ -5135,23 +5058,24 @@ - + + 4 Models/Core/UnitCylinder.mesh - + true - + - - + + @@ -5160,102 +5084,19 @@ - - - - - - - - - 10 - - - - - - - - - - - 1 - - - - - - - - - 10 - - - - - - - - - - 10 - - - - - - - - - - - - - 10 - - - - - - - - - - - 10 - - - - - - - - - - - 1 - - - - - - - - - - + - Schema/Entities/Player.xml + Schema/Entities/PlayerRed.xml - + - + @@ -5267,7 +5108,7 @@ false - + @@ -5280,7 +5121,7 @@ false - + @@ -5293,7 +5134,7 @@ false - + @@ -5306,7 +5147,166 @@ false - + + + + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + 0.10000000149011612 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + @@ -5332,65 +5332,6 @@ - - - - - - - - - - - - - - - - - - Textures/Core/UnitRaptor.png - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - Textures/Test/aM4ME4GR.png - - - - - - - - - - - - - @@ -5601,6 +5542,77 @@ + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + PickClass + 2 + + + + + + + + + + + + + Textures/Core/UnitRaptor.png + + + + PickClass + 1 + + + + + + + + + + + + + Textures/Test/aM4ME4GR.png + + + + PickClass + 3 + + + + + + + + + + + + diff --git a/resources/Schema/Entities/OverwatchCamera.xml b/resources/Schema/Entities/OverwatchCamera.xml index 323a62f2..a2b774d3 100644 --- a/resources/Schema/Entities/OverwatchCamera.xml +++ b/resources/Schema/Entities/OverwatchCamera.xml @@ -20,65 +20,6 @@ - - - - - - - - - - - - - - - - - - Textures/Core/UnitRaptor.png - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - Textures/Test/aM4ME4GR.png - - - - - - - - - - - - - @@ -274,7 +215,7 @@ - 5 + 16 Fonts/DroidSans.ttf,64 @@ -289,6 +230,77 @@ + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + PickClass + 2 + + + + + + + + + + + + + Textures/Core/UnitRaptor.png + + + + PickClass + 1 + + + + + + + + + + + + + Textures/Test/aM4ME4GR.png + + + + PickClass + 3 + + + + + + + + + + + + diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index 1d8ea8f3..21e517c0 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -62,6 +62,7 @@ + diff --git a/src/Engine/GUI/ButtonSystem.cpp b/src/Engine/GUI/ButtonSystem.cpp index 93ae1811..cc9f2b47 100644 --- a/src/Engine/GUI/ButtonSystem.cpp +++ b/src/Engine/GUI/ButtonSystem.cpp @@ -1,4 +1,5 @@ #include "GUI/ButtonSystem.h" +#include "Input/EInputCommand.h" ButtonSystem::ButtonSystem(SystemParams params, IRenderer* renderer) : System(params) @@ -37,10 +38,19 @@ bool ButtonSystem::OnMousePress(const Events::MousePress& e) m_PickEntity = EntityWrapper(m_World, m_PickData.Entity); //You have clicked on a button entity, send pressed event. - Events::ButtonPressed ePressed; - ePressed.Entity = m_PickEntity; - ePressed.EntityName = m_PickEntity.Name(); - m_EventBroker->Publish(ePressed); + if (m_World->HasComponent(m_PickData.Entity, "InputCmdButton")) { + Events::InputCommand eInputCmd; + eInputCmd.PlayerID = LocalPlayer.ID; + eInputCmd.Player = LocalPlayer; + EntityWrapper button = EntityWrapper(m_World, m_PickData.Entity); + eInputCmd.Command = (std::string)button["InputCmdButton"]["Command"]; + eInputCmd.Value = (float)button["InputCmdButton"]["PressValue"]; + } else { + Events::ButtonPressed ePressed; + ePressed.Entity = m_PickEntity; + ePressed.EntityName = m_PickEntity.Name(); + m_EventBroker->Publish(ePressed); + } } } } @@ -55,10 +65,19 @@ bool ButtonSystem::OnMouseRelease(const Events::MouseRelease& e) if(m_PickData.Entity != EntityID_Invalid && m_PickData.World == m_World) { EntityWrapper ent = EntityWrapper(m_World, m_PickData.Entity); - Events::ButtonReleased eReleased; - eReleased.EntityName = m_PickEntity.Name(); - eReleased.Entity = m_PickEntity; - m_EventBroker->Publish(eReleased); + if (m_World->HasComponent(m_PickData.Entity, "InputCmdButton")) { + Events::InputCommand eInputCmd; + eInputCmd.PlayerID = LocalPlayer.ID; + eInputCmd.Player = LocalPlayer; + EntityWrapper button = EntityWrapper(m_World, m_PickData.Entity); + eInputCmd.Command = (std::string)button["InputCmdButton"]["Command"]; + eInputCmd.Value = 0; + } else { + Events::ButtonReleased eReleased; + eReleased.EntityName = m_PickEntity.Name(); + eReleased.Entity = m_PickEntity; + m_EventBroker->Publish(eReleased); + } if(m_World->HasComponent(m_PickData.Entity, "Button")) { if (ent == m_PickEntity) { From 98366ec03827ed028206deb82382c6e33a941869 Mon Sep 17 00:00:00 2001 From: William Moberg Date: Thu, 3 Mar 2016 16:59:17 +0100 Subject: [PATCH 189/252] PickClass used for class-picking, SwapToClassPick to swap camera. --- resources/DefaultInput.ini | 2 +- src/Engine/GUI/ButtonSystem.cpp | 2 ++ src/Game/Systems/PlayerSpawnSystem.cpp | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/resources/DefaultInput.ini b/resources/DefaultInput.ini index 4dea88fd..b47c1e9b 100644 --- a/resources/DefaultInput.ini +++ b/resources/DefaultInput.ini @@ -28,4 +28,4 @@ P=SwitchToPlayer K=TakeDamage,1500 F2=PerformanceTimingResetAllTimers F3=PerformanceTimingCreateExcelData -F4=PickClass \ No newline at end of file +F4=SwapToClassPick \ No newline at end of file diff --git a/src/Engine/GUI/ButtonSystem.cpp b/src/Engine/GUI/ButtonSystem.cpp index cc9f2b47..b28c0119 100644 --- a/src/Engine/GUI/ButtonSystem.cpp +++ b/src/Engine/GUI/ButtonSystem.cpp @@ -45,6 +45,7 @@ bool ButtonSystem::OnMousePress(const Events::MousePress& e) EntityWrapper button = EntityWrapper(m_World, m_PickData.Entity); eInputCmd.Command = (std::string)button["InputCmdButton"]["Command"]; eInputCmd.Value = (float)button["InputCmdButton"]["PressValue"]; + m_EventBroker->Publish(eInputCmd); } else { Events::ButtonPressed ePressed; ePressed.Entity = m_PickEntity; @@ -72,6 +73,7 @@ bool ButtonSystem::OnMouseRelease(const Events::MouseRelease& e) EntityWrapper button = EntityWrapper(m_World, m_PickData.Entity); eInputCmd.Command = (std::string)button["InputCmdButton"]["Command"]; eInputCmd.Value = 0; + m_EventBroker->Publish(eInputCmd); } else { Events::ButtonReleased eReleased; eReleased.EntityName = m_PickEntity.Name(); diff --git a/src/Game/Systems/PlayerSpawnSystem.cpp b/src/Game/Systems/PlayerSpawnSystem.cpp index 7a6881c4..39fa1606 100644 --- a/src/Game/Systems/PlayerSpawnSystem.cpp +++ b/src/Game/Systems/PlayerSpawnSystem.cpp @@ -105,7 +105,7 @@ void PlayerSpawnSystem::Update(double dt) bool PlayerSpawnSystem::OnInputCommand(Events::InputCommand& e) { - if (e.Command != "PickTeam" && e.Command != "PickClass") { + if (e.Command != "PickTeam" && e.Command != "SwapToClassPick") { return false; } @@ -117,7 +117,7 @@ bool PlayerSpawnSystem::OnInputCommand(Events::InputCommand& e) if (IsClient && !LocalPlayer.Valid()) { // Set the camera as active, if it exists. // Find the respawn camera or class pick camera. - std::string camName = e.Command == "PickClass" ? "PickClassCamera" : "SpectatorCamera"; + std::string camName = e.Command == "SwapToClassPick" ? "PickClassCamera" : "SpectatorCamera"; EntityWrapper spectatorCam = m_World->GetFirstEntityByName(camName); if (spectatorCam.Valid() && spectatorCam.HasComponent("Camera")) { Events::SetCamera eSetCamera; @@ -137,14 +137,14 @@ bool PlayerSpawnSystem::OnInputCommand(Events::InputCommand& e) for (; iter != m_SpawnRequests.end(); ++iter) { if (iter->PlayerID == e.PlayerID) { // If player wants to switch class, remove their spawn request. - if (e.Command == "PickClass") { + if (e.Command == "SwapToClassPick") { m_SpawnRequests.erase(iter); } break; } } - if (e.Command == "PickClass") { + if (e.Command == "SwapToClassPick") { return true; } From c5f3bfc0cd7881437e6fba55a0512a03e18b8def Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Thu, 3 Mar 2016 17:33:41 +0100 Subject: [PATCH 190/252] Fixed the stuff in comments --- .../Engine/Input/FirstPersonInputController.h | 25 ++++++------------- src/Game/Systems/PlayerMovementSystem.cpp | 2 +- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index 28795a7f..e5e6c0d5 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -28,9 +28,9 @@ public: virtual void Reset(); void AssaultDashCheck(double dt, bool isJumping, double assaultDashCoolDownMaxTimer, double& assaultDashCoolDownTimer); - bool SniperSprintingCheck(); virtual bool AssaultDashDoubleTapped() const { return m_AssaultDashDoubleTapped; } virtual bool PlayerIsDashing() const { return m_PlayerIsDashing; } + bool SpecialAbilityKeyDown() const { return m_SpecialAbilityKeyDown; } protected: const int m_PlayerID; @@ -145,10 +145,10 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm if (m_NumberOfMovementKeysDown == 0) { m_MovementKeyDown = false; } - //you have just released the key, store what key it was and reset the doubletap-sensitivity-timer - m_AssaultDashTapDirection = m_CurrentDirectionVector; - m_AssaultDashDoubleTapDeltaTime = 0.f; - + //you have just released the key, store what key it was and reset the doubletap-sensitivity-timer + m_AssaultDashTapDirection = m_CurrentDirectionVector; + m_AssaultDashDoubleTapDeltaTime = 0.f; + } } @@ -161,12 +161,9 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm } if (e.Command == "SpecialAbility") { - if (e.Value > 0) { - m_SpecialAbilityKeyDown = true; - } else { - m_SpecialAbilityKeyDown = false; - } + m_SpecialAbilityKeyDown = e.Value > 0; } + if (m_SpecialAbilityKeyDown && m_MovementKeyDown) { m_ShiftDashing = true; } else { @@ -241,12 +238,4 @@ void FirstPersonInputController::AssaultDashCheck(double dt, bool m_EventBroker->Publish(e); } -template -bool FirstPersonInputController::SniperSprintingCheck() { - if (m_SpecialAbilityKeyDown) { - return true; - } else { - return false; - } -} #endif \ No newline at end of file diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 8bcf092f..07090425 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -68,7 +68,7 @@ void PlayerMovementSystem::updateMovementControllers(double dt) } bool sniperSprinting = false; if (player.HasComponent("SprintAbility")) { - if (controller->SniperSprintingCheck()) { + if (controller->SpecialAbilityKeyDown()) { playerMovementSpeed *= (double)player["SprintAbility"]["StrengthOfEffect"]; playerCrouchSpeed *= (double)player["SprintAbility"]["StrengthOfEffect"]; sniperSprinting = true; From a3494b92c8cbf386bbd07ee9052ab1cde8b9ab07 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Thu, 3 Mar 2016 17:48:25 +0100 Subject: [PATCH 191/252] Blending queues now working --- include/Engine/Rendering/AnimationSystem.h | 41 +- include/Engine/Rendering/AutoBlendQueue.h | 21 +- include/Engine/Rendering/BlendTree.h | 8 +- include/Engine/Rendering/EAnimationBlend.h | 21 - .../Engine/Rendering/EAutoAnimationBlend.h | 6 +- resources/Schema/Components/Animation.xml | 2 + resources/Schema/Components/Animation.xsd | 2 + resources/Schema/Entities/BlendTreeTest.xml | 37 +- src/Engine/Rendering/AnimationSystem.cpp | 504 ++++++++---------- src/Engine/Rendering/AutoBlendQueue.cpp | 195 +++++++ src/Engine/Rendering/BlendTree.cpp | 95 +++- 11 files changed, 554 insertions(+), 378 deletions(-) delete mode 100644 include/Engine/Rendering/EAnimationBlend.h diff --git a/include/Engine/Rendering/AnimationSystem.h b/include/Engine/Rendering/AnimationSystem.h index fd53022f..4f18b4a4 100644 --- a/include/Engine/Rendering/AnimationSystem.h +++ b/include/Engine/Rendering/AnimationSystem.h @@ -7,13 +7,12 @@ #include "../Core/System.h" #include "../Core/ResourceManager.h" #include "Rendering/Model.h" -#include "Rendering/EAnimationComplete.h" #include "Rendering/Skeleton.h" #include "Rendering/BlendTree.h" -#include "Rendering/EAnimationBlend.h" #include "Rendering/EAutoAnimationBlend.h" #include "../Input/EInputCommand.h" #include "../Core/EntityWrapper.h" +#include "Rendering/AutoBlendQueue.h" #include "imgui/imgui.h" @@ -27,10 +26,7 @@ private: void CreateBlendTrees(); void UpdateAnimations(double dt); void UpdateWeights(double dt); - void AnimationComplete(EntityWrapper animationEntity); - EventRelay m_EAnimationBlend; - bool OnAnimationBlend(Events::AnimationBlend& e); EventRelay m_EAutoAnimationBlend; bool OnAutoAnimationBlend(Events::AutoAnimationBlend& e); @@ -38,40 +34,7 @@ private: EventRelay m_EInputCommand; bool OnInputCommand(const Events::InputCommand& e); - struct BlendJob - { - EntityWrapper BlendEntity = EntityWrapper::Invalid; - double StartWeight; - double GoalWeight; - double Duration; - double CurrentTime = 0.0; - }; - - struct QueuedBlendJob : BlendJob - { - EntityWrapper AnimationEntity = EntityWrapper::Invalid; - }; - - struct AutoBlendJob - { - EntityWrapper RootNode = EntityWrapper::Invalid; - double Duration; - double CurrentTime = 0.0; - double Delay = 0.0; - BlendTree::AutoBlendInfo BlendInfo; - }; - - - std::list m_AutoBlendJobs; - std::unordered_map m_QueuedAutoBlendJobs; - std::list m_BlendJobs; - std::list m_QueuedBlendJobs; - - char m_AnimationName1[20] = "Run"; - float m_BlendTime1 = 0.5f; - - char m_AnimationName2[20] = "Jump"; - float m_BlendTime2 = 0.5f; + std::unordered_map m_AutoBlendQueues; }; #endif \ No newline at end of file diff --git a/include/Engine/Rendering/AutoBlendQueue.h b/include/Engine/Rendering/AutoBlendQueue.h index 12dd249e..3c808408 100644 --- a/include/Engine/Rendering/AutoBlendQueue.h +++ b/include/Engine/Rendering/AutoBlendQueue.h @@ -5,6 +5,7 @@ #include "Skeleton.h" #include "Model.h" #include "BlendTree.h" +#include "../Core/EntityWrapper.h" class AutoBlendQueue { @@ -15,11 +16,29 @@ public: double Duration; double CurrentTime = 0.0; double Delay = 0.0; + EntityWrapper AnimationEntity = EntityWrapper::Invalid; BlendTree::AutoBlendInfo BlendInfo; }; + struct AutoblendNode + { + AutoBlendJob BlendJob; + double StartTime; + double EndTime; + }; + + AutoBlendQueue() { }; + + void Insert(AutoBlendJob autoBlendJob); + void UpdateTime(double dt); + + void PrintQueue(); + bool HasActiveBlendJob(); + std::shared_ptr GetBlendTree(); + + AutoBlendQueue::AutoBlendJob& GetActiveBlendJob(); private: - std::map m_BlendQueue; + std::list m_BlendQueue; }; diff --git a/include/Engine/Rendering/BlendTree.h b/include/Engine/Rendering/BlendTree.h index 5605707a..2c5f1aa8 100644 --- a/include/Engine/Rendering/BlendTree.h +++ b/include/Engine/Rendering/BlendTree.h @@ -60,8 +60,7 @@ public: { std::string NodeName; double progress; - bool Restart; - double AnimationSpeed; + bool Start; std::unordered_map StartWeights; }; @@ -78,6 +77,11 @@ public: void PrintTree(); BlendTree::AutoBlendInfo AutoBlendStep(AutoBlendInfo blendInfo); + BlendTree::Node* GetCommonParent(std::string NodeName1, std::string NodeName2); + BlendTree::Node* FirstCommonParent(Node* node1, Node* node2); + + EntityWrapper GetSubTreeRoot(std::string nodeName); + private: Skeleton* m_Skeleton = nullptr; Node* m_Root = nullptr; diff --git a/include/Engine/Rendering/EAnimationBlend.h b/include/Engine/Rendering/EAnimationBlend.h deleted file mode 100644 index 880a2fd0..00000000 --- a/include/Engine/Rendering/EAnimationBlend.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef Events_AnimationBlend_h__ -#define Events_AnimationBlend_h__ - -#include "../Core/EventBroker.h" -#include "../Core/EntityWrapper.h" - -namespace Events -{ - -struct AnimationBlend : Event -{ - EntityWrapper BlendEntity = EntityWrapper::Invalid; - double GoalWeight; - double Duration; - - EntityWrapper AnimationEntity = EntityWrapper::Invalid; -}; - -} - -#endif diff --git a/include/Engine/Rendering/EAutoAnimationBlend.h b/include/Engine/Rendering/EAutoAnimationBlend.h index edd8e0bc..08c49191 100644 --- a/include/Engine/Rendering/EAutoAnimationBlend.h +++ b/include/Engine/Rendering/EAutoAnimationBlend.h @@ -13,9 +13,9 @@ struct AutoAnimationBlend : Event std::string NodeName; double Duration = 0.0; double Delay = 0.0; - - - double AnimationSpeed = 1.0; + + bool Start = false; + bool Reverse = false; bool Restart = false; EntityWrapper AnimationEntity = EntityWrapper::Invalid; diff --git a/resources/Schema/Components/Animation.xml b/resources/Schema/Components/Animation.xml index 45ee8428..05de9f9f 100644 --- a/resources/Schema/Components/Animation.xml +++ b/resources/Schema/Components/Animation.xml @@ -2,6 +2,8 @@ + false + false 0 true false diff --git a/resources/Schema/Components/Animation.xsd b/resources/Schema/Components/Animation.xsd index 5e82c333..1090c4c7 100644 --- a/resources/Schema/Components/Animation.xsd +++ b/resources/Schema/Components/Animation.xsd @@ -8,6 +8,8 @@ + + diff --git a/resources/Schema/Entities/BlendTreeTest.xml b/resources/Schema/Entities/BlendTreeTest.xml index 3457fc5e..69590ceb 100644 --- a/resources/Schema/Entities/BlendTreeTest.xml +++ b/resources/Schema/Entities/BlendTreeTest.xml @@ -68,9 +68,9 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - + + - @@ -85,11 +85,11 @@ - + - AimRifleA - + AimSecWepA + false true @@ -97,11 +97,11 @@ - + - AimSecWepA - + AimRifleA + false true @@ -125,7 +125,7 @@ StandCrouchBlend JumpDashBlend - 0 + 0.00067602147306955462 @@ -183,8 +183,9 @@ RunF - + 1 + true @@ -317,7 +318,7 @@ Jump DashBlend - 1 + 0.01016461050458084 @@ -327,6 +328,8 @@ JumpF + 1 + false @@ -337,7 +340,7 @@ DashFBBlend DashLRBlend - 0 + 0.99999999999984523 @@ -347,7 +350,7 @@ DashForward DashBackward - 1 + 0.98238059685988577 @@ -356,6 +359,8 @@ DashForwardF + + 1 false @@ -367,6 +372,7 @@ DashBackwardF + 1 false @@ -380,7 +386,7 @@ DashLeft DashRight - 0 + 0.96547196574235861 @@ -390,6 +396,7 @@ DashLeftF + 1 false @@ -400,6 +407,8 @@ DashRightF + + 1 false diff --git a/src/Engine/Rendering/AnimationSystem.cpp b/src/Engine/Rendering/AnimationSystem.cpp index 4e7f15f6..166ecb47 100644 --- a/src/Engine/Rendering/AnimationSystem.cpp +++ b/src/Engine/Rendering/AnimationSystem.cpp @@ -3,21 +3,21 @@ AnimationSystem::AnimationSystem(SystemParams params) : System(params) { - EVENT_SUBSCRIBE_MEMBER(m_EAnimationBlend, &AnimationSystem::OnAnimationBlend); EVENT_SUBSCRIBE_MEMBER(m_EAutoAnimationBlend, &AnimationSystem::OnAutoAnimationBlend); EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &AnimationSystem::OnInputCommand); } void AnimationSystem::Update(double dt) { - ImGui::InputText("AnimationName1", &m_AnimationName1[0], sizeof(m_AnimationName1)); - ImGui::SliderFloat("Blendtime1", &m_BlendTime1, 0.f, 10.f); - ImGui::InputText("AnimationName2", &m_AnimationName2[0], sizeof(m_AnimationName2)); - ImGui::SliderFloat("Blendtime2", &m_BlendTime2, 0.f, 10.f); - UpdateAnimations(dt); CreateBlendTrees(); UpdateWeights(dt); + + + for(auto& autoBlendQueue : m_AutoBlendQueues) { + autoBlendQueue.second.UpdateTime(dt); + // autoBlendQueue.second.PrintQueue(); + } } void AnimationSystem::CreateBlendTrees() @@ -91,66 +91,29 @@ void AnimationSystem::UpdateAnimations(double dt) double animationSpeed = (double)animationC["Speed"]; - if (animationSpeed != 0.0) { + if((bool)animationC["Reverse"]) { + animationSpeed *= -1; + } + + + if ((bool)animationC["Play"]) { double nextTime = (double)animationC["Time"] + animationSpeed * dt; - - - //Pre animation end blend - if (m_QueuedAutoBlendJobs.find(entity) != m_QueuedAutoBlendJobs.end()) { - if (glm::sign(m_QueuedAutoBlendJobs.at(entity).Delay) < 0) { - if (!(bool)animationC["Loop"]) { - if (nextTime > animation->Duration + m_QueuedAutoBlendJobs.at(entity).Delay && glm::sign(animationSpeed) > 0) { - AnimationComplete(entity); - } else if (nextTime < 0 - m_QueuedAutoBlendJobs.at(entity).Delay && glm::sign(animationSpeed) < 0) { - AnimationComplete(entity); - } - } else { - if (nextTime > animation->Duration + m_QueuedAutoBlendJobs.at(entity).Delay && glm::sign(animationSpeed) > 0) { - AnimationComplete(entity); - } else if (nextTime < 0 - m_QueuedAutoBlendJobs.at(entity).Delay && glm::sign(animationSpeed) < 0) { - AnimationComplete(entity); - } - } - } - } - - if (!(bool)animationC["Loop"]) { if (nextTime > animation->Duration) { nextTime = animation->Duration; - Events::AnimationComplete e; - e.Entity = entity; - e.Name = (std::string)animationC["AnimationName"]; - m_EventBroker->Publish(e); - AnimationComplete(entity); - (double&)animationC["Speed"] = 0.0; + (bool&)animationC["Play"] = false; } else if (nextTime < 0) { - Events::AnimationComplete e; - e.Entity = entity; - e.Name = (std::string)animationC["AnimationName"]; - m_EventBroker->Publish(e); - AnimationComplete(entity); nextTime = 0; - (double&)animationC["Speed"] = 0.0; + (bool&)animationC["Play"] = false; } } else { if (nextTime > animation->Duration) { - Events::AnimationComplete e; - e.Entity = entity; - e.Name = (std::string)animationC["AnimationName"]; - m_EventBroker->Publish(e); - AnimationComplete(entity); while (nextTime > animation->Duration) { nextTime -= animation->Duration; } } else if (nextTime < 0) { - Events::AnimationComplete e; - e.Entity = entity; - e.Name = (std::string)animationC["AnimationName"]; - m_EventBroker->Publish(e); - AnimationComplete(entity); while (nextTime < 0) { nextTime += animation->Duration; } @@ -164,154 +127,27 @@ void AnimationSystem::UpdateAnimations(double dt) void AnimationSystem::UpdateWeights(double dt) { - for (auto it = m_BlendJobs.begin(); it != m_BlendJobs.end();) { - if (!it->BlendEntity.Valid()) { - it = m_BlendJobs.erase(it); - continue; - } + for (auto& autoBlendQueue : m_AutoBlendQueues) { - if (it->BlendEntity.HasComponent("Blend")) { - it->CurrentTime += dt; - double progress = it->CurrentTime / it->Duration; - progress = glm::clamp(progress, 0.0, 1.0); + if(autoBlendQueue.second.HasActiveBlendJob()) { + AutoBlendQueue::AutoBlendJob& blendJob = autoBlendQueue.second.GetActiveBlendJob(); - double weight = ((it->GoalWeight - it->StartWeight) * progress) + it->StartWeight; - (double&)it->BlendEntity["Blend"]["Weight"] = weight; + std::shared_ptr blendTree = autoBlendQueue.second.GetBlendTree(); - if(weight == it->GoalWeight) { - it = m_BlendJobs.erase(it); + if (blendTree != nullptr) { + blendJob.BlendInfo.progress = glm::clamp(blendJob.CurrentTime / blendJob.Duration, 0.0, 1.0); + LOG_INFO("Progress: %f, %s", blendJob.BlendInfo.progress, blendJob.BlendInfo.NodeName.c_str()); + blendJob.BlendInfo = blendTree->AutoBlendStep(blendJob.BlendInfo); } + } - ++it; - } - - - for (auto it = m_AutoBlendJobs.begin(); it != m_AutoBlendJobs.end();) { - it->CurrentTime += dt; - - if (!it->RootNode.Valid()) { - it = m_AutoBlendJobs.erase(it); - continue; - } - - if (!it->RootNode.HasComponent("Model")) { - it = m_AutoBlendJobs.erase(it); - continue; - } - - Model* model; - try { - model = ResourceManager::Load<::Model, true>(it->RootNode["Model"]["Resource"]); - } catch (const std::exception&) { - continue; - } - - Skeleton* skeleton = model->m_RawModel->m_Skeleton; - if (skeleton == nullptr) { - continue; - } - - std::shared_ptr blendTree; - if(skeleton->BlendTrees.find(it->RootNode) != skeleton->BlendTrees.end()) { - blendTree = skeleton->BlendTrees.at(it->RootNode); - } else { - it = m_AutoBlendJobs.erase(it); - continue; - } - - - it->BlendInfo.progress = glm::clamp(it->CurrentTime / it->Duration, 0.0, 1.0); - it->BlendInfo = blendTree->AutoBlendStep(it->BlendInfo); - - - if (it->CurrentTime >= it->Duration) { - it = m_AutoBlendJobs.erase(it); - continue; - } - - ++it; } } - -void AnimationSystem::AnimationComplete(EntityWrapper animationEntity) -{ - for (auto it = m_QueuedBlendJobs.begin(); it != m_QueuedBlendJobs.end();) { - if (!it->BlendEntity.Valid() || !it->AnimationEntity.Valid()) { - it = m_QueuedBlendJobs.erase(it); - continue; - } - - if(animationEntity == it->AnimationEntity) { - BlendJob bj; - bj.BlendEntity = it->BlendEntity; - bj.StartWeight = it->StartWeight; - bj.GoalWeight = it->GoalWeight; - bj.Duration = it->Duration; - bj.CurrentTime = 0.0; - m_BlendJobs.push_back(bj); - it = m_QueuedBlendJobs.erase(it); - continue; - } - - ++it; - } - - - if (m_QueuedAutoBlendJobs.find(animationEntity) != m_QueuedAutoBlendJobs.end()) { - AutoBlendJob abj = m_QueuedAutoBlendJobs.at(animationEntity); - - if (!abj.RootNode.Valid() || !animationEntity.Valid()) { - m_QueuedAutoBlendJobs.erase(animationEntity); - } else { - m_AutoBlendJobs.push_back(abj); - m_QueuedAutoBlendJobs.erase(animationEntity); - } - - - - } - - -} - -bool AnimationSystem::OnAnimationBlend(Events::AnimationBlend& e) -{ - if(!e.BlendEntity.Valid()) { - return false; - } - if(!e.BlendEntity.HasComponent("Blend")){ - return false; - } - - if (e.AnimationEntity.Valid()) { - if (e.AnimationEntity.HasComponent("Animation")) { - QueuedBlendJob qbj; - qbj.BlendEntity = e.BlendEntity; - qbj.StartWeight = (double)e.BlendEntity["Blend"]["Weight"]; - qbj.GoalWeight = e.GoalWeight; - qbj.Duration = e.Duration; - qbj.CurrentTime = 0.0; - qbj.AnimationEntity = e.AnimationEntity; - m_QueuedBlendJobs.push_back(qbj); - return true; - } - } else { - BlendJob bj; - bj.BlendEntity = e.BlendEntity; - bj.StartWeight = (double)e.BlendEntity["Blend"]["Weight"]; - bj.GoalWeight = e.GoalWeight; - bj.Duration = e.Duration; - bj.CurrentTime = 0.0; - m_BlendJobs.push_back(bj); - return true; - } -} - - bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e) { + if(!e.RootNode.Valid()) { return false; } @@ -320,108 +156,80 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e) return false; } - if (e.AnimationEntity.Valid()) { - AutoBlendJob abj; - abj.RootNode = e.RootNode; - abj.CurrentTime = 0.0; - abj.Duration = e.Duration; - abj.Delay = e.Delay; + Model* model; + try { + model = ResourceManager::Load<::Model, true>((std::string)e.RootNode["Model"]["Resource"]); + } catch (const std::exception&) { + return false; + } - BlendTree::AutoBlendInfo abInfo; - abInfo.NodeName = e.NodeName; - abInfo.progress = 0.0; - abInfo.Restart = e.Restart; - abInfo.AnimationSpeed = e.AnimationSpeed; - abj.BlendInfo = abInfo; + Skeleton* skeleton = model->m_RawModel->m_Skeleton; + if (skeleton == nullptr) { + return false; + } - m_QueuedAutoBlendJobs[e.AnimationEntity] = abj; - return true; + std::shared_ptr blendTree; + if (skeleton->BlendTrees.find(e.RootNode) != skeleton->BlendTrees.end()) { + blendTree = skeleton->BlendTrees.at(e.RootNode); } else { - AutoBlendJob abj; - abj.RootNode = e.RootNode; - abj.CurrentTime = 0.0; - abj.Duration = e.Duration; - - BlendTree::AutoBlendInfo abInfo; - abInfo.NodeName = e.NodeName; - abInfo.progress = 0.0; - abInfo.Restart = e.Restart; - abInfo.AnimationSpeed = e.AnimationSpeed; - - abj.BlendInfo = abInfo; - - m_AutoBlendJobs.push_back(abj); - return true; + return false; } + + EntityWrapper subTreeRoot = blendTree->GetSubTreeRoot(e.NodeName); + + if(!subTreeRoot.Valid()) { + return false; + } + + AutoBlendQueue::AutoBlendJob abj; + abj.AnimationEntity = e.AnimationEntity; + abj.CurrentTime = 0.0; + abj.Delay = e.Delay; + abj.Duration = e.Duration; + abj.RootNode = e.RootNode; + + abj.BlendInfo.NodeName = e.NodeName; + abj.BlendInfo.progress = 0.0; + abj.BlendInfo.Start = e.Start; + + if (e.Restart) { + EntityWrapper nodeEntity = subTreeRoot.FirstChildByName(e.NodeName); + if (nodeEntity.Valid()) { + if (nodeEntity.HasComponent("Animation")) { + const Skeleton::Animation* animation = skeleton->GetAnimation(nodeEntity["Animation"]["AnimationName"]); + + if (animation != nullptr) { + if (e.Restart) { + (bool&)nodeEntity["Animation"]["Reverse"] = e.Reverse; + if (e.Reverse) { + (double&)nodeEntity["Animation"]["Time"] = animation->Duration; + } else { + (double&)nodeEntity["Animation"]["Time"] = 0.0; + } + } + } + } + } + } + + + LOG_INFO("Inserting %s blendJob into %s subtree", e.NodeName.c_str(), subTreeRoot.Name().c_str()); + m_AutoBlendQueues[subTreeRoot].Insert(abj); + + LOG_INFO("\n"); + m_AutoBlendQueues.at(subTreeRoot).PrintQueue(); + LOG_INFO("\n"); + + + return true; } bool AnimationSystem::OnInputCommand(const Events::InputCommand& e) { if (e.Value == 1.f) { - if (e.Command == "BlendTest0") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - - - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - Events::AutoAnimationBlend aeb; - aeb.Duration = m_BlendTime1; - aeb.NodeName = m_AnimationName1; - aeb.RootNode = entity; - aeb.Restart = true; - - m_EventBroker->Publish(aeb); - - } - } - - } else if (e.Command == "BlendTest1") { - - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - - - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - - { - Events::AutoAnimationBlend aeb; - aeb.Duration = m_BlendTime2; - aeb.NodeName = m_AnimationName2; - aeb.RootNode = entity; - aeb.Restart = true; - m_EventBroker->Publish(aeb); - } - - { - Events::AutoAnimationBlend aeb; - aeb.Duration = m_BlendTime2; - aeb.NodeName = "Run"; - aeb.RootNode = entity; - aeb.Restart = true; - aeb.AnimationEntity = entity.FirstChildByName("DashLeft"); - m_EventBroker->Publish(aeb); - } - - } - } - } - - if(e.Command == "DashForward") { auto blendComponents = m_World->GetComponents("BlendAdditive"); @@ -434,19 +242,21 @@ bool AnimationSystem::OnInputCommand(const Events::InputCommand& e) if (entity.Name() == "Assault") { { Events::AutoAnimationBlend aeb; - aeb.Duration = 0.1; + aeb.Duration = 0.2; aeb.NodeName = "DashForward"; aeb.RootNode = entity; aeb.Restart = true; + aeb.Start = true; m_EventBroker->Publish(aeb); } { Events::AutoAnimationBlend aeb; aeb.Duration = 0.3; - aeb.NodeName = "Run"; + aeb.NodeName = "StandCrouchBlend"; aeb.RootNode = entity; - aeb.Restart = true; - aeb.Delay = 0; + aeb.Delay = -0.3; + aeb.Start = true; + aeb.Restart = false; aeb.AnimationEntity = entity.FirstChildByName("DashForward"); m_EventBroker->Publish(aeb); } @@ -469,14 +279,16 @@ bool AnimationSystem::OnInputCommand(const Events::InputCommand& e) aeb.NodeName = "DashBackward"; aeb.RootNode = entity; aeb.Restart = true; + aeb.Start = true; m_EventBroker->Publish(aeb); } { Events::AutoAnimationBlend aeb; aeb.Duration = 0.3; - aeb.NodeName = "Run"; + aeb.NodeName = "StandCrouchBlend"; aeb.RootNode = entity; - aeb.Restart = true; + aeb.Start = true; + aeb.Restart = false; aeb.Delay = -0.3; aeb.AnimationEntity = entity.FirstChildByName("DashBackward"); m_EventBroker->Publish(aeb); @@ -499,15 +311,17 @@ bool AnimationSystem::OnInputCommand(const Events::InputCommand& e) aeb.NodeName = "DashLeft"; aeb.RootNode = entity; aeb.Restart = true; + aeb.Start = true; m_EventBroker->Publish(aeb); } { Events::AutoAnimationBlend aeb; aeb.Duration = 0.3; - aeb.NodeName = "Run"; + aeb.NodeName = "StandCrouchBlend"; aeb.RootNode = entity; - aeb.Restart = true; aeb.Delay = -0.3; + aeb.Start = true; + aeb.Restart = false; aeb.AnimationEntity = entity.FirstChildByName("DashLeft"); m_EventBroker->Publish(aeb); } @@ -529,14 +343,16 @@ bool AnimationSystem::OnInputCommand(const Events::InputCommand& e) aeb.NodeName = "DashRight"; aeb.RootNode = entity; aeb.Restart = true; + aeb.Start = true; m_EventBroker->Publish(aeb); } { Events::AutoAnimationBlend aeb; aeb.Duration = 0.3; - aeb.NodeName = "Run"; + aeb.NodeName = "StandCrouchBlend"; aeb.RootNode = entity; - aeb.Restart = true; + aeb.Start = true; + aeb.Restart = false; aeb.AnimationEntity = entity.FirstChildByName("DashRight"); aeb.Delay = -0.3; m_EventBroker->Publish(aeb); @@ -558,20 +374,128 @@ bool AnimationSystem::OnInputCommand(const Events::InputCommand& e) aeb.Duration = 0.35; aeb.NodeName = "Jump"; aeb.RootNode = entity; + aeb.Start = true; aeb.Restart = true; m_EventBroker->Publish(aeb); } { Events::AutoAnimationBlend aeb; - aeb.Duration = 0.35; - aeb.NodeName = "Run"; + aeb.Duration = 0.6; + aeb.NodeName = "StandCrouchBlend"; aeb.RootNode = entity; + aeb.Start = true; aeb.Restart = false; aeb.AnimationEntity = entity.FirstChildByName("Jump"); m_EventBroker->Publish(aeb); } } } + } else if (e.Command == "Reload") { + auto blendComponents = m_World->GetComponents("BlendAdditive"); + + if (blendComponents == nullptr) { + return false; + } + for (auto& bc : *blendComponents) { + EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); + + if (entity.Name() == "Assault") { + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.2; + aeb.NodeName = "ReloadSwitch"; + aeb.RootNode = entity; + aeb.Start = true; + aeb.Restart = true; + m_EventBroker->Publish(aeb); + } + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.2; + aeb.NodeName = "IdlePrimary"; + aeb.RootNode = entity; + aeb.Delay = -0.1; + aeb.Start = true; + aeb.Restart = false; + aeb.AnimationEntity = entity.FirstChildByName("ReloadSwitch"); + m_EventBroker->Publish(aeb); + } + } + } + } else if (e.Command == "Crouch") { + auto blendComponents = m_World->GetComponents("BlendAdditive"); + + if (blendComponents == nullptr) { + return false; + } + for (auto& bc : *blendComponents) { + EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); + + if (entity.Name() == "Assault") { + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.3; + aeb.NodeName = "CrouchMovement"; + aeb.RootNode = entity; + aeb.Start = true; + aeb.Restart = true; + m_EventBroker->Publish(aeb); + } + } + } + } else if (e.Command == "Stand") { + auto blendComponents = m_World->GetComponents("BlendAdditive"); + + if (blendComponents == nullptr) { + return false; + } + for (auto& bc : *blendComponents) { + EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); + + if (entity.Name() == "Assault") { + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.3; + aeb.NodeName = "StandMovement"; + aeb.RootNode = entity; + aeb.Start = true; + aeb.Restart = true; + m_EventBroker->Publish(aeb); + } + } + } + } else if (e.Command == "Shoot") { + auto blendComponents = m_World->GetComponents("BlendAdditive"); + + if (blendComponents == nullptr) { + return false; + } + for (auto& bc : *blendComponents) { + EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); + + if (entity.Name() == "Assault") { + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.1; + aeb.NodeName = "ShootPrimary"; + aeb.RootNode = entity; + aeb.Start = true; + aeb.Restart = true; + m_EventBroker->Publish(aeb); + } + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.1; + aeb.NodeName = "IdlePrimary"; + aeb.RootNode = entity; + aeb.Delay = 0.0; + aeb.Start = true; + aeb.Restart = false; + aeb.AnimationEntity = entity.FirstChildByName("ShootPrimary"); + m_EventBroker->Publish(aeb); + } + } + } } diff --git a/src/Engine/Rendering/AutoBlendQueue.cpp b/src/Engine/Rendering/AutoBlendQueue.cpp index e69de29b..9f0a7366 100644 --- a/src/Engine/Rendering/AutoBlendQueue.cpp +++ b/src/Engine/Rendering/AutoBlendQueue.cpp @@ -0,0 +1,195 @@ +#include "Rendering/AutoBlendQueue.h" + +void AutoBlendQueue::Insert(AutoBlendJob autoBlendJob) +{ + if(!autoBlendJob.RootNode.HasComponent("Model")) { + return; + } + + AutoblendNode blendNode; + blendNode.BlendJob = autoBlendJob; + blendNode.StartTime = autoBlendJob.Delay; + blendNode.EndTime = autoBlendJob.Delay + autoBlendJob.Duration; + + + + if (autoBlendJob.AnimationEntity.Valid()) { + if (autoBlendJob.AnimationEntity.HasComponent("Animation")) { + Model* model; + try { + model = ResourceManager::Load<::Model, true>((std::string)autoBlendJob.RootNode["Model"]["Resource"]); + } catch (const std::exception&) { + return; + } + + Skeleton* skeleton = model->m_RawModel->m_Skeleton; + if (skeleton == nullptr) { + return; + } + + const Skeleton::Animation* animation = skeleton->GetAnimation((std::string)autoBlendJob.AnimationEntity["Animation"]["AnimationName"]); + + if (animation == nullptr) { + return; + } + + double AnimationDuration = 0.0; + + double animationSpeed = (double)autoBlendJob.AnimationEntity["Animation"]["Speed"]; + double animationTime = (double)autoBlendJob.AnimationEntity["Animation"]["Time"]; + + + if ((bool)autoBlendJob.AnimationEntity["Animation"]["Reverse"]) { + AnimationDuration = (animation->Duration * animationSpeed) - (animation->Duration - animationTime); + } else { + AnimationDuration = (animation->Duration * animationSpeed) - animationTime; + } + + LOG_INFO("Animation Duration %f", AnimationDuration); + blendNode.StartTime += AnimationDuration; + blendNode.EndTime += AnimationDuration; + if (m_BlendQueue.size() == 0) { + m_BlendQueue.push_back(blendNode); + } else { + for (auto it = m_BlendQueue.begin(); it != m_BlendQueue.end(); it++) { + auto next = std::next(it, 1); + + if (next != m_BlendQueue.end()) { + if (it->StartTime >= blendNode.StartTime && next->StartTime <= blendNode.StartTime) { + LOG_INFO("Inserted %s between %s and %s", blendNode.BlendJob.BlendInfo.NodeName.c_str(), it->BlendJob.BlendInfo.NodeName.c_str(), next->BlendJob.BlendInfo.NodeName.c_str()); + m_BlendQueue.insert(next, blendNode); + return; + } + } else if(it->StartTime > blendNode.StartTime){ + LOG_INFO("Inserted %s after %s", blendNode.BlendJob.BlendInfo.NodeName.c_str(), it->BlendJob.BlendInfo.NodeName.c_str()); + m_BlendQueue.push_front(blendNode); + return; + } else if (it->StartTime <= blendNode.StartTime) { + LOG_INFO("Inserted %s after %s", blendNode.BlendJob.BlendInfo.NodeName.c_str(), it->BlendJob.BlendInfo.NodeName.c_str()); + m_BlendQueue.push_back(blendNode); + return; + } + } + } + } + } + + + LOG_INFO("Cleared BlendQueue and inserted %s", blendNode.BlendJob.BlendInfo.NodeName.c_str()); + m_BlendQueue.clear(); + m_BlendQueue.push_back(blendNode); +} + +void AutoBlendQueue::UpdateTime(double dt) +{ + for (auto it = m_BlendQueue.begin(); it != m_BlendQueue.end();) { + it->EndTime -= dt; + it->StartTime -= dt; + if (it->EndTime < 0) { + it = m_BlendQueue.erase(it); + } else { + it++; + } + } +} + +void AutoBlendQueue::PrintQueue() +{ + for (auto it = m_BlendQueue.begin(); it != m_BlendQueue.end(); it++) { + LOG_INFO("Start: %f End: %f \t %s", it->StartTime, it->EndTime, it->BlendJob.BlendInfo.NodeName.c_str()); + } +} + + +bool AutoBlendQueue::HasActiveBlendJob() +{ + if(m_BlendQueue.empty()) { + return false; + } else { + AutoblendNode blendNode = m_BlendQueue.front(); + if (blendNode.StartTime <= 0) { + AutoBlendJob blendJob = blendNode.BlendJob; + + if (!blendJob.RootNode.Valid()) { + m_BlendQueue.pop_front(); + return false; + } + + if (!blendJob.RootNode.HasComponent("Model")) { + m_BlendQueue.pop_front(); + return HasActiveBlendJob(); + } + + Model* model; + try { + model = ResourceManager::Load<::Model, true>(blendJob.RootNode["Model"]["Resource"]); + } catch (const std::exception&) { + m_BlendQueue.pop_front(); + return HasActiveBlendJob(); + } + + Skeleton* skeleton = model->m_RawModel->m_Skeleton; + if (skeleton == nullptr) { + m_BlendQueue.pop_front(); + return HasActiveBlendJob(); + } + + + if (skeleton->BlendTrees.find(blendJob.RootNode) != skeleton->BlendTrees.end()) { + return true; + } else { + m_BlendQueue.pop_front(); + return HasActiveBlendJob(); + } + + + } else { + return false; + } + } +} + + +std::shared_ptr AutoBlendQueue::GetBlendTree() +{ + AutoblendNode blendNode = m_BlendQueue.front(); + AutoBlendJob blendJob = blendNode.BlendJob; + + if (!blendJob.RootNode.Valid()) { + m_BlendQueue.pop_front(); + return false; + } + + if (!blendJob.RootNode.HasComponent("Model")) { + return nullptr; + } + + Model* model; + try { + model = ResourceManager::Load<::Model, true>(blendJob.RootNode["Model"]["Resource"]); + } catch (const std::exception&) { + return nullptr; + } + + Skeleton* skeleton = model->m_RawModel->m_Skeleton; + if (skeleton == nullptr) { + return nullptr; + } + + + if (skeleton->BlendTrees.find(blendJob.RootNode) != skeleton->BlendTrees.end()) { + return skeleton->BlendTrees.at(blendJob.RootNode); + } else { + return nullptr; + } + + + +} + +AutoBlendQueue::AutoBlendJob& AutoBlendQueue::GetActiveBlendJob() +{ + AutoblendNode& blendNode = m_BlendQueue.front(); + blendNode.BlendJob.CurrentTime = -blendNode.StartTime; + return blendNode.BlendJob; +} diff --git a/src/Engine/Rendering/BlendTree.cpp b/src/Engine/Rendering/BlendTree.cpp index f7381d4d..036c3f49 100644 --- a/src/Engine/Rendering/BlendTree.cpp +++ b/src/Engine/Rendering/BlendTree.cpp @@ -51,8 +51,6 @@ BlendTree::BlendTree(EntityWrapper ModelEntity, Skeleton* skeleton) } m_FinalPose = AccumulateFinalPose(); - - // PrintTree(); } @@ -207,18 +205,16 @@ BlendTree::AutoBlendInfo BlendTree::AutoBlendStep(AutoBlendInfo blendInfo) { std::vector goalNodes = FindNodesByName(blendInfo.NodeName); - if (blendInfo.Restart) { + if (blendInfo.Start) { for (auto it = goalNodes.begin(); it != goalNodes.end(); it++) { EntityWrapper entity = (*it)->Entity; if (entity.Valid()) { if (entity.HasComponent("Animation")) { - (double&)entity["Animation"]["Time"] = 0.0; - (double&)entity["Animation"]["Speed"] = blendInfo.AnimationSpeed; + (bool&)entity["Animation"]["Play"] = true; } } } - blendInfo.Restart = false; } @@ -230,8 +226,6 @@ BlendTree::AutoBlendInfo BlendTree::AutoBlendStep(AutoBlendInfo blendInfo) while (currentNode != nullptr) { - - if(!currentNode->Entity.HasComponent("Blend")) { return blendInfo; } @@ -267,6 +261,91 @@ BlendTree::AutoBlendInfo BlendTree::AutoBlendStep(AutoBlendInfo blendInfo) return blendInfo; } + +BlendTree::Node* BlendTree::GetCommonParent(std::string NodeName1, std::string NodeName2) +{ + std::vector nodes1 = FindNodesByName(NodeName1); + std::vector nodes2 = FindNodesByName(NodeName2); + + for (auto it = nodes1.begin(); it != nodes1.end(); it++) { + auto next = std::next(it, 1); + + if(next != nodes1.end()) { + Node* commonParent = FirstCommonParent((*it), (*next)); + (*next) = commonParent; + nodes1.erase(it); + it = nodes1.begin(); + } + } + + for (auto it = nodes2.begin(); it != nodes2.end(); it++) { + auto next = std::next(it, 1); + + if (next != nodes2.end()) { + Node* commonParent = FirstCommonParent((*it), (*next)); + (*next) = commonParent; + nodes2.erase(it); + it = nodes2.begin(); + } + } + + return FirstCommonParent(nodes1.front(), nodes2.front());; +} + + +BlendTree::Node* BlendTree::FirstCommonParent(Node* node1, Node* node2) +{ + std::list node1Parents; + + Node* currentNode = node1; + while (currentNode != nullptr) { + node1Parents.push_back(currentNode); + currentNode = currentNode->Parent; + } + + currentNode = node2; + while (currentNode != nullptr) { + for (auto it = node1Parents.begin(); it != node1Parents.end(); it++) { + if (currentNode == (*it)) { + return currentNode; + } + } + currentNode = currentNode->Parent; + } + + return nullptr; +} + + +EntityWrapper BlendTree::GetSubTreeRoot(std::string nodeName) +{ + std::vector nodes = FindNodesByName(nodeName); + + std::vector subTreeRoots; + + for (auto it = nodes.begin(); it != nodes.end(); it++) { + Node* currentNode = (*it); + while (currentNode->Parent->Type == NodeType::Blend) { + currentNode = currentNode->Parent; + } + subTreeRoots.push_back(currentNode); + } + + + for (auto it = subTreeRoots.begin(); it != subTreeRoots.end(); it++) { + auto next = std::next(it, 1); + + if (next != subTreeRoots.end()) { + Node* commonParent = FirstCommonParent((*it), (*next)); + (*next) = commonParent; + subTreeRoots.erase(it); + it = subTreeRoots.begin(); + } + } + + return subTreeRoots.front()->Entity; +} + void BlendTree::Blend(std::map& pose) { Node* currentNode; From be331cb778665a670004cfebdea0d2b8f6dbf486 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Thu, 3 Mar 2016 18:05:10 +0100 Subject: [PATCH 192/252] fixed --- include/Engine/Input/FirstPersonInputController.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index f106a9eb..ed9469bd 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -165,11 +165,7 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm m_SpecialAbilityKeyDown = e.Value > 0; } - if (m_SpecialAbilityKeyDown && m_MovementKeyDown) { - m_ShiftDashing = true; - } else { - m_ShiftDashing = false; - } + m_ShiftDashing = m_SpecialAbilityKeyDown && m_MovementKeyDown; return true; } From 7943fc7ad688aa4af7bec1193cdc3154ddf1783a Mon Sep 17 00:00:00 2001 From: Jocke Date: Thu, 3 Mar 2016 18:14:33 +0100 Subject: [PATCH 193/252] Hot fix: Infinite loop when a player disconnected from the server. --- src/Engine/Network/UDPClient.cpp | 2 +- src/Engine/Network/UDPServer.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Engine/Network/UDPClient.cpp b/src/Engine/Network/UDPClient.cpp index a7061884..1d71c155 100644 --- a/src/Engine/Network/UDPClient.cpp +++ b/src/Engine/Network/UDPClient.cpp @@ -47,7 +47,7 @@ int UDPClient::readBuffer() memcpy(&sizeOfPacket, m_ReadBuffer, sizeof(int)); if (sizeOfPacket > m_Socket->available()) { LOG_WARNING("UDPClient::readBuffer(): We haven't got the whole packet yet."); - return 0; + //return 0; } // if the buffer is to small increase the size of it if (sizeOfPacket > m_BufferSize) { diff --git a/src/Engine/Network/UDPServer.cpp b/src/Engine/Network/UDPServer.cpp index 13dd5ccd..8c9950dc 100644 --- a/src/Engine/Network/UDPServer.cpp +++ b/src/Engine/Network/UDPServer.cpp @@ -94,7 +94,7 @@ int UDPServer::readBuffer() if (sizeOfPacket > m_Socket->available()) { LOG_WARNING("UDPServer::readBuffer(): We haven't got the whole packet yet."); - return 0; + //return 0; } // if the buffer is to small increase the size of it From b2371f4a43a92991a79266805472be145dd295b8 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 3 Mar 2016 20:00:42 +0100 Subject: [PATCH 194/252] Working AssaultWeapon --- .../Systems/Weapon/AssaultWeaponBehaviour.h | 51 +- .../Systems/Weapon/DefenderWeaponBehaviour.h | 7 +- .../Systems/Weapon/SidearmWeaponBehaviour.h | 7 +- resources/Schema/Components/AssaultWeapon.xml | 21 +- resources/Schema/Components/AssaultWeapon.xsd | 23 +- .../Schema/Components/DefenderWeapon.xml | 2 +- .../Schema/Components/DefenderWeapon.xsd | 2 +- resources/Schema/Components/SidearmWeapon.xml | 2 +- resources/Schema/Components/SidearmWeapon.xsd | 2 +- .../Schema/Entities/AssaultWeaponView.xml | 28 +- .../Schema/Entities/AssaultWeaponWorld.xml | 10 +- resources/Schema/Entities/Player.xml | 16 +- .../Entities/PlayerAssaultFallbackBlue.xml | 695 ++++++++++++++++++ resources/Schema/Entities/Ray2Red | 18 - resources/Schema/Entities/Ray2Red.xml | 43 -- resources/Schema/Entities/RayBlue | 17 - resources/Schema/Entities/RayBlue.xml | 44 +- resources/Schema/Entities/RayRed | 17 - resources/Schema/Entities/RayRed.xml | 20 - src/Game/Game.cpp | 2 + .../Systems/Weapon/AssaultWeaponBehaviour.cpp | 228 ++++++ 21 files changed, 1061 insertions(+), 194 deletions(-) create mode 100644 resources/Schema/Entities/PlayerAssaultFallbackBlue.xml delete mode 100644 resources/Schema/Entities/Ray2Red delete mode 100644 resources/Schema/Entities/Ray2Red.xml delete mode 100644 resources/Schema/Entities/RayBlue delete mode 100644 resources/Schema/Entities/RayRed delete mode 100644 resources/Schema/Entities/RayRed.xml create mode 100644 src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp diff --git a/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h b/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h index 993dd060..7244d443 100644 --- a/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h +++ b/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h @@ -1,47 +1,40 @@ #ifndef AssaultWeaponBehaviour_h__ #define AssaultWeaponBehaviour_h__ -#include "Sound/EPlaySoundOnEntity.h" -#include "Collision/Collision.h" -#include "Core/ConfigFile.h" #include "WeaponBehaviour.h" -#include "../SpawnerSystem.h" +#include "Collision/Collision.h" #include "Core/EPlayerDamage.h" -#include "Core/EShoot.h" +#include "Sound/EPlaySoundOnEntity.h" class AssaultWeaponBehaviour : public WeaponBehaviour { public: AssaultWeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree* collisionOctree) - : WeaponBehaviour(systemParams, "AssaultWeapon", renderer, collisionOctree) + : System(systemParams) + , WeaponBehaviour(systemParams, "AssaultWeapon", renderer, collisionOctree) + , m_RandomEngine(m_RandomDevice()) { } -protected: - virtual void OnPrimaryFire(WeaponInfo& wi) override; - virtual void OnCeasePrimaryFire(WeaponInfo& wi) override; - virtual void OnReload(WeaponInfo& wi) override; + void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cWeapon, double dt) override; + void UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& wi, double dt) override; + void OnPrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) override; + void OnCeasePrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) override; + void OnReload(ComponentWrapper cWeapon, WeaponInfo& wi) override; + void OnHolster(ComponentWrapper cWeapon, WeaponInfo& wi) override; + //bool OnInputCommand(ComponentWrapper cWeapon, WeaponInfo& wi, const Events::InputCommand& e) override; private: - // State - bool m_Firing = false; - bool m_Reloading = false; - double m_ReloadTimer = 0.0; - double m_TimeSinceLastFire = 0.0; - EntityWrapper m_FirstPersonReloadImpostor; + std::random_device m_RandomDevice; + std::mt19937 m_RandomEngine; - bool hasAmmo(); - void fireRound(); - void spawnTracer(); - float traceRayDistance(glm::vec3 origin, glm::vec3 direction); - void playFireSound(); - void playEmptySound(); - void viewPunch(); - void finishReload(); - void playShootAnimation(); - void playIdleAnimation(); - void playReloadAnimation(); - bool shoot(double damage); - void showHitMarker(); + // Weapon functions + void fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi); + //void dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi, glm::vec3 direction, double damage); + bool canFire(ComponentWrapper cWeapon, WeaponInfo& wi); + bool dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi); + + // Utility + //Camera cameraFromEntity(EntityWrapper camera); }; #endif \ No newline at end of file diff --git a/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h b/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h index 77d579f8..9e7d4991 100644 --- a/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h +++ b/include/Game/Systems/Weapon/DefenderWeaponBehaviour.h @@ -1,3 +1,6 @@ +#ifndef DefenderWeaponBehaviour_h__ +#define DefenderWeaponBehaviour_h__ + #include "WeaponBehaviour.h" #include "Collision/Collision.h" #include "Core/EPlayerDamage.h" @@ -31,4 +34,6 @@ private: // Utility Camera cameraFromEntity(EntityWrapper camera); -}; \ No newline at end of file +}; + +#endif \ No newline at end of file diff --git a/include/Game/Systems/Weapon/SidearmWeaponBehaviour.h b/include/Game/Systems/Weapon/SidearmWeaponBehaviour.h index d221b8bb..10e6105a 100644 --- a/include/Game/Systems/Weapon/SidearmWeaponBehaviour.h +++ b/include/Game/Systems/Weapon/SidearmWeaponBehaviour.h @@ -1,3 +1,6 @@ +#ifndef SidearmWeaponBehaviour_h__ +#define SidearmWeaponBehaviour_h__ + #include "WeaponBehaviour.h" #include "Collision/Collision.h" #include "Core/EPlayerDamage.h" @@ -30,4 +33,6 @@ private: bool canFire(ComponentWrapper cWeapon); bool playerInFirstPerson(EntityWrapper player); //float traceRayDistance(glm::vec3 origin, glm::vec3 direction); -}; \ No newline at end of file +}; + +#endif \ No newline at end of file diff --git a/resources/Schema/Components/AssaultWeapon.xml b/resources/Schema/Components/AssaultWeapon.xml index c835217b..ba74fbb7 100755 --- a/resources/Schema/Components/AssaultWeapon.xml +++ b/resources/Schema/Components/AssaultWeapon.xml @@ -1,12 +1,21 @@ + 32 32 - 360 - 360 - 5 - 120 - 0.01 + 320 + 320 + 15 + 0.174533 + 0.10 + 420 + 0.03 + 0.18 2 - + 0.5 + false + 0 + false + 0 + 0 \ No newline at end of file diff --git a/resources/Schema/Components/AssaultWeapon.xsd b/resources/Schema/Components/AssaultWeapon.xsd index 7e9854a2..a1e745de 100755 --- a/resources/Schema/Components/AssaultWeapon.xsd +++ b/resources/Schema/Components/AssaultWeapon.xsd @@ -7,6 +7,7 @@ + Ammo currently loaded into the magazine @@ -20,16 +21,32 @@ Maximum ammo able to be carried + + Spread angle in radians + + + Maximum vertical aim travel angle in radians + Rate of fire in rounds per minute - View punch in radians for each bullet fired + View punch in radians for each shell fired + + + The speed in radians per second the view returns to its original position after being punched - Time it takes to reload the weapon in seconds + Time it takes to load ONE SHELL into the weapon in seconds - + + Time it takes from selecting the weapon until it's ready to fire + + + + + + diff --git a/resources/Schema/Components/DefenderWeapon.xml b/resources/Schema/Components/DefenderWeapon.xml index 68b87759..b01955bc 100755 --- a/resources/Schema/Components/DefenderWeapon.xml +++ b/resources/Schema/Components/DefenderWeapon.xml @@ -1,5 +1,6 @@ + 8 8 64 @@ -12,7 +13,6 @@ 0.03 0.2 0.5 - false 0 false diff --git a/resources/Schema/Components/DefenderWeapon.xsd b/resources/Schema/Components/DefenderWeapon.xsd index d2b503f8..53200952 100755 --- a/resources/Schema/Components/DefenderWeapon.xsd +++ b/resources/Schema/Components/DefenderWeapon.xsd @@ -19,6 +19,7 @@ + Ammo currently loaded into the magazine @@ -53,7 +54,6 @@ Time it takes to load ONE SHELL into the weapon in seconds - diff --git a/resources/Schema/Components/SidearmWeapon.xml b/resources/Schema/Components/SidearmWeapon.xml index 1d503ecc..bc90c067 100644 --- a/resources/Schema/Components/SidearmWeapon.xml +++ b/resources/Schema/Components/SidearmWeapon.xml @@ -1,5 +1,6 @@ + 16 16 20 @@ -8,7 +9,6 @@ 0.01 0.5 0.5 - false 0 false diff --git a/resources/Schema/Components/SidearmWeapon.xsd b/resources/Schema/Components/SidearmWeapon.xsd index bafb9de2..514bf354 100644 --- a/resources/Schema/Components/SidearmWeapon.xsd +++ b/resources/Schema/Components/SidearmWeapon.xsd @@ -19,6 +19,7 @@ + Ammo currently loaded into the magazine @@ -41,7 +42,6 @@ Time it takes from selecting the weapon until it's ready to fire - diff --git a/resources/Schema/Entities/AssaultWeaponView.xml b/resources/Schema/Entities/AssaultWeaponView.xml index 4b985fbb..b5c87674 100755 --- a/resources/Schema/Entities/AssaultWeaponView.xml +++ b/resources/Schema/Entities/AssaultWeaponView.xml @@ -1,17 +1,11 @@ - + - - R_Arm_Weapon_Joint - Models/Weapons/Blue/AssaultWeaponBlue.mesh - - - - + @@ -21,7 +15,8 @@ Schema/Entities/RayBlue.xml - + + @@ -37,9 +32,8 @@ - - + @@ -70,6 +64,11 @@ Fonts/DroidSans.ttf,64 + + Player + AssaultWeapon + MagazineAmmo + @@ -79,10 +78,15 @@ - 360 + 320 Fonts/DroidSans.ttf,64 + + Player + AssaultWeapon + Ammo + diff --git a/resources/Schema/Entities/AssaultWeaponWorld.xml b/resources/Schema/Entities/AssaultWeaponWorld.xml index 6fcb97b3..9f33c8f2 100755 --- a/resources/Schema/Entities/AssaultWeaponWorld.xml +++ b/resources/Schema/Entities/AssaultWeaponWorld.xml @@ -1,17 +1,11 @@ - + - - R_Arm_Weapon_Joint - Models/Weapons/Blue/AssaultWeaponBlue.mesh - - - - + diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 1ee9d5d3..affe9f79 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -6,10 +6,14 @@ + + + + + - + - @@ -470,10 +474,10 @@ R_Arm_Weapon_Joint - DefenderWeapon + AssaultWeapon - Schema/Entities/DefenderWeaponView.xml + Schema/Entities/AssaultWeaponView.xml @@ -545,13 +549,13 @@ - DefenderWeapon + AssaultWeapon - Schema/Entities/DefenderWeaponWorld.xml + Schema/Entities/AssaultWeaponWorld.xml diff --git a/resources/Schema/Entities/PlayerAssaultFallbackBlue.xml b/resources/Schema/Entities/PlayerAssaultFallbackBlue.xml new file mode 100644 index 00000000..bb6367f8 --- /dev/null +++ b/resources/Schema/Entities/PlayerAssaultFallbackBlue.xml @@ -0,0 +1,695 @@ + + + + + + + + + + + + + + + + + + 5 + + + + + + + + + + + + + + + + + 0.10000000149011612 + 300 + + + + + + + + + + Models/Widgets/Camera.mesh + false + + + + + + + + + + + + + + + + + + + Textures/Weapons/Crosshair/SmallThickHoleDot.png + + false + + + + + + + + + + + + Schema/Entities/HitMarker.xml + + + + + + + + + + + + + + 1 + + + + + Textures/HealthHUD3.png + + + + + + + + + + + + + + + + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + + + + + + + 1 + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 2 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 3 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 4 + + + 1 + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 1 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + 1 + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + Models/Widgets/Arrows/Arrow5.mesh + + + + + + + + + + + + + + + + + + + + Idle + 1.8348644854054612 + 1 + + + + + Models/Characters/Assault/Test/FirstPerson.mesh + + + + + + + + + R_Arm_Weapon_Joint + + + AssaultWeapon + + + Schema/Entities/AssaultWeaponView.xml + + + + + + + + + + + + R_Arm_Weapon_Joint + + + SidearmWeapon + + + Schema/Entities/SidearmWeaponView.xml + + + + + + + + + + + + + + + + 0.10000000149011612 + 300 + + + Models/Widgets/Camera.mesh + false + + + + + + + + + + + + IdleF + 1 + + + + + AimRifle + + + + + + Models/Characters/Assault/AssaultBlue.mesh + + + + + + + + + R_Arm_Weapon_Joint + + + AssaultWeapon + + + + + + Schema/Entities/AssaultWeaponWorld.xml + + + + + + + + + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + Schema/Entities/RayBlue.xml + + + + + + + + + + + Schema/Entities/ReloadEffectWorld.xml + + + + + + + + + + + + + R_Arm_Weapon_Joint + + + SidearmWeapon + + + + + + Schema/Entities/SidearmWeaponWorld.xml + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + false + + + + + + + + + + + + Models/Core/UnitCube.mesh + + false + + + + + + + + + + + Insert name here + Fonts/DroidSans.ttf,100 + + + + + + + + + + + + + + Textures/Icons/Arrow.png + + false + + + + + 50 + true + + + + + + + + + + + + Schema/Entities/DefenderShield.xml + + + + + + + + + + diff --git a/resources/Schema/Entities/Ray2Red b/resources/Schema/Entities/Ray2Red deleted file mode 100644 index 813443b2..00000000 --- a/resources/Schema/Entities/Ray2Red +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - Textures/Effects/Ray.png - - - - - - - - - - - - diff --git a/resources/Schema/Entities/Ray2Red.xml b/resources/Schema/Entities/Ray2Red.xml deleted file mode 100644 index 6c7c3248..00000000 --- a/resources/Schema/Entities/Ray2Red.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - Textures/Effects/Ray.png - - - - - - - - - - - - - - - Textures/Effects/Ray.png - - - - - - - - - - - - - - diff --git a/resources/Schema/Entities/RayBlue b/resources/Schema/Entities/RayBlue deleted file mode 100644 index d34e185e..00000000 --- a/resources/Schema/Entities/RayBlue +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - Models/Core/UnitCylinder.mesh - - - - - - - - - - - diff --git a/resources/Schema/Entities/RayBlue.xml b/resources/Schema/Entities/RayBlue.xml index 022d7769..0ad0ddf0 100644 --- a/resources/Schema/Entities/RayBlue.xml +++ b/resources/Schema/Entities/RayBlue.xml @@ -1,20 +1,46 @@ - + - 0.25 + 0.10000000149011612 - - Models/Effects/CylinderShot.mesh - - true - - + - + + + + + Textures/Effects/Ray.png + + + + + + + + + + + + + + + Textures/Effects/Ray.png + + + + + + + + + + + + diff --git a/resources/Schema/Entities/RayRed b/resources/Schema/Entities/RayRed deleted file mode 100644 index d34e185e..00000000 --- a/resources/Schema/Entities/RayRed +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - Models/Core/UnitCylinder.mesh - - - - - - - - - - - diff --git a/resources/Schema/Entities/RayRed.xml b/resources/Schema/Entities/RayRed.xml deleted file mode 100644 index 0a20f148..00000000 --- a/resources/Schema/Entities/RayRed.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - 0.25 - - - Models/Effects/CylinderShot.mesh - - true - - - - - - - - - diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 10107ab1..9ebb28eb 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -18,6 +18,7 @@ #include "Game/Systems/PickupSpawnSystem.h" #include "Game/Systems/AmmoPickupSystem.h" #include "Game/Systems/DamageIndicatorSystem.h" +#include "Game/Systems/Weapon/AssaultWeaponBehaviour.h" #include "Game/Systems/Weapon/DefenderWeaponBehaviour.h" #include "Game/Systems/Weapon/SidearmWeaponBehaviour.h" #include "Rendering/AnimationSystem.h" @@ -128,6 +129,7 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); + m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer, m_OctreeCollision); m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer, m_OctreeCollision); m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer, m_OctreeCollision); m_SystemPipeline->AddSystem(updateOrderLevel); diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp new file mode 100644 index 00000000..c982637b --- /dev/null +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -0,0 +1,228 @@ +#include "Systems/Weapon/AssaultWeaponBehaviour.h" + +void AssaultWeaponBehaviour::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cWeapon, double dt) +{ + double& fireCooldown = cWeapon["FireCooldown"]; + fireCooldown = glm::max(0.0, fireCooldown - dt); + + WeaponBehaviour::UpdateComponent(entity, cWeapon, dt); +} + +void AssaultWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& wi, double dt) +{ + // Decrement reload timer + double& reloadTimer = cWeapon["ReloadTimer"]; + reloadTimer = glm::max(0.0, reloadTimer - dt); + + // Start reloading automatically if at 0 mag ammo + int& magAmmo = cWeapon["MagazineAmmo"]; + if (m_ConfigAutoReload && magAmmo <= 0) { + OnReload(cWeapon, wi); + } + + // Handle reloading + bool& isReloading = cWeapon["IsReloading"]; + if (isReloading && reloadTimer <= 0.0) { + int& magSize = cWeapon["MagazineSize"]; + int& ammo = cWeapon["Ammo"]; + + ammo = glm::max(0, ammo - (magSize - magAmmo)); + magAmmo = glm::min(magSize, ammo); + isReloading = false; + } + + // Restore view angle + if (IsClient) { + float& currentTravel = cWeapon["CurrentTravel"]; + float& returnSpeed = cWeapon["ViewReturnSpeed"]; + if (currentTravel > 0) { + float change = returnSpeed * dt; + currentTravel = glm::max(0.f, currentTravel - change); + EntityWrapper camera = wi.Player.FirstChildByName("Camera"); + if (camera.Valid()) { + glm::vec3& cameraOrientation = camera["Transform"]["Orientation"]; + cameraOrientation.x -= change; + } + } + } + + // Fire if we're able to fire + if (canFire(cWeapon, wi)) { + fireBullet(cWeapon, wi); + } +} + +void AssaultWeaponBehaviour::OnPrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) +{ + cWeapon["TriggerHeld"] = true; + if (canFire(cWeapon, wi)) { + fireBullet(cWeapon, wi); + } +} + +void AssaultWeaponBehaviour::OnCeasePrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) +{ + cWeapon["TriggerHeld"] = false; +} + +void AssaultWeaponBehaviour::OnReload(ComponentWrapper cWeapon, WeaponInfo& wi) +{ + bool& isReloading = cWeapon["IsReloading"]; + if (isReloading) { + return; + } + + int& magAmmo = cWeapon["MagazineAmmo"]; + int& magSize = cWeapon["MagazineSize"]; + if (magAmmo >= magSize) { + return; + } + int& ammo = cWeapon["Ammo"]; + if (ammo <= 0) { + return; + } + + double reloadTime = cWeapon["ReloadTime"]; + double& reloadTimer = cWeapon["ReloadTimer"]; + + // Start reload + isReloading = true; + reloadTimer = reloadTime; +} + +void AssaultWeaponBehaviour::OnHolster(ComponentWrapper cWeapon, WeaponInfo& wi) +{ + // Make sure the trigger is released if weapon is holstered while firing + cWeapon["TriggerHeld"] = false; + + // Cancel any reload + cWeapon["IsReloading"] = false; + cWeapon["ReloadTimer"] = 0.0; +} + +void AssaultWeaponBehaviour::fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi) +{ + cWeapon["FireCooldown"] = 60.0 / (double)cWeapon["RPM"]; + + // Ammo + int& magAmmo = cWeapon["MagazineAmmo"]; + if (magAmmo <= 0) { + return; + } else { + magAmmo -= 1; + } + + // View punch + if (IsClient) { + EntityWrapper camera = wi.Player.FirstChildByName("Camera"); + if (camera.Valid()) { + glm::vec3& cameraOrientation = camera["Transform"]["Orientation"]; + float viewPunch = cWeapon["ViewPunch"]; + float maxTravelAngle = cWeapon["MaxTravelAngle"]; + float& currentTravel = cWeapon["CurrentTravel"]; + if (currentTravel < maxTravelAngle) { + float change = viewPunch; + if (currentTravel + change > maxTravelAngle) { + change = maxTravelAngle - currentTravel; + } + cameraOrientation.x += change; + currentTravel += change; + } + } + } + + // Get weapon model based on current person + EntityWrapper weaponModelEntity = getRelevantWeaponModelEntity(wi); + if (!weaponModelEntity.Valid()) { + return; + } + + // Tracer + EntityWrapper tracerSpawner = weaponModelEntity.FirstChildByName("WeaponMuzzle"); + if (tracerSpawner.Valid()) { + glm::vec3 origin = Transform::AbsolutePosition(tracerSpawner); + glm::vec3 direction = glm::quat(Transform::AbsoluteOrientationEuler(tracerSpawner)) * glm::vec3(0, 0, -1); + float distance = traceRayDistance(origin, direction); + EntityWrapper ray = SpawnerSystem::Spawn(tracerSpawner); + if (ray.Valid()) { + ((glm::vec3&)ray["Transform"]["Scale"]).z = distance; + } + } + + // Deal damage + if (dealDamage(cWeapon, wi)) { + // Show hit marker + EntityWrapper hitMarkerSpawner = wi.Player.FirstChildByName("HitMarkerSpawner"); + if (hitMarkerSpawner.Valid()) { + SpawnerSystem::Spawn(hitMarkerSpawner, hitMarkerSpawner); + Events::PlaySoundOnEntity e; + e.EmitterID = wi.Player.ID; + e.FilePath = "Audio/weapon/hitclick.wav"; + m_EventBroker->Publish(e); + } + } +} + +bool AssaultWeaponBehaviour::canFire(ComponentWrapper cWeapon, WeaponInfo& wi) +{ + bool triggerHeld = cWeapon["TriggerHeld"]; + bool cooldownPassed = (double)cWeapon["FireCooldown"] <= 0.0; + bool isReloading = cWeapon["IsReloading"]; + return triggerHeld && cooldownPassed; +} + +bool AssaultWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi) +{ + // Only deal damage client side + if (!IsClient) { + return false; + } + + // Only handle damage for the local player + if (wi.Player != LocalPlayer) { + return false; + } + + // Make sure the player isn't shooting from the grave + if (!wi.Player.Valid()) { + return false; + } + + // 3D-pick middle of screen + Rectangle viewport = m_Renderer->GetViewportSize(); + glm::vec2 centerScreen(viewport.Width / 2, viewport.Height / 2); + // TODO: Some horizontal spread + PickData pickData = m_Renderer->Pick(centerScreen); + EntityWrapper victim(m_World, pickData.Entity); + if (!victim.Valid()) { + return false; + } + + // Don't let us somehow shoot ourselves in the foot + if (victim == LocalPlayer) { + return false; + } + + // Only care about players being hit + if (!victim.HasComponent("Player")) { + victim = victim.FirstParentWithComponent("Player"); + } + if (!victim.Valid()) { + return false; + } + + double damage = cWeapon["BaseDamage"]; + // If friendly fire, reduce damage to 0 (needed to make Boosts, Ammosharing work) + if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)wi.Player["Team"]["Team"]) { + damage = 0; + } + + // Deal damage! + Events::PlayerDamage ePlayerDamage; + ePlayerDamage.Inflictor = wi.Player; + ePlayerDamage.Victim = victim; + ePlayerDamage.Damage = damage; + m_EventBroker->Publish(ePlayerDamage); + + return damage > 0; +} From cbb2ec2fd66efbd394f153faa6e95503c24daa57 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Tue, 2 Feb 2016 20:50:46 +0100 Subject: [PATCH 195/252] Unique ids for entity nodes in the editor to prevent weird behaviour when multiple entities have the same name --- src/Engine/Editor/EditorGUI.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Engine/Editor/EditorGUI.cpp b/src/Engine/Editor/EditorGUI.cpp index 4e7c8ab6..7435bca8 100644 --- a/src/Engine/Editor/EditorGUI.cpp +++ b/src/Engine/Editor/EditorGUI.cpp @@ -157,7 +157,7 @@ void EditorGUI::drawEntitiesRecursive(World* world, EntityID parent) auto entityChildren = world->GetEntityChildren(); auto range = entityChildren.equal_range(parent); for (auto it = range.first; it != range.second; it++) { - if (EditorGUI::drawEntityNode(EntityWrapper(world, it->second))) { + if (drawEntityNode(EntityWrapper(world, it->second))) { drawEntitiesRecursive(world, it->second); ImGui::TreePop(); } @@ -217,6 +217,7 @@ bool EditorGUI::drawEntityNode(EntityWrapper entity) ImGui::EndPopup(); } + ImGui::PushID(("EntityNode" + std::to_string(entity.ID)).c_str()); ImGui::SetNextTreeNodeOpened(true, ImGuiSetCond_Once); if (ImGui::TreeNode(formatEntityName(entity).c_str())) { // Handle drop events for reparenting @@ -224,8 +225,10 @@ bool EditorGUI::drawEntityNode(EntityWrapper entity) entityChangeParent(m_CurrentlyDragging, entity); m_CurrentlyDragging = EntityWrapper::Invalid; } + ImGui::PopID(); return true; } else { + ImGui::PopID(); return false; } } From c0e160833c03a4cbb4d0aa0d73524ecdab4fe2ae Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 3 Mar 2016 20:39:21 +0100 Subject: [PATCH 196/252] Playtest 2 Fallback Map --- .../Entities/Maps/Playtest2-Fallback.xml | 8813 +++++++++++++++++ 1 file changed, 8813 insertions(+) create mode 100644 resources/Schema/Entities/Maps/Playtest2-Fallback.xml diff --git a/resources/Schema/Entities/Maps/Playtest2-Fallback.xml b/resources/Schema/Entities/Maps/Playtest2-Fallback.xml new file mode 100644 index 00000000..8217ab45 --- /dev/null +++ b/resources/Schema/Entities/Maps/Playtest2-Fallback.xml @@ -0,0 +1,8813 @@ + + + + + + + + + + + + + + + + + + 2 + Models/Props/GroundTest.mesh + + + + + + + + + Models/Props/Walls/SciFiWallTop.mesh + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + true + + + + + + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall1.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall2.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallSmall3.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall4.mesh + + + + + + + + + + + + Models/Props/Highground1.mesh + + + + + + + + + + Models/Props/Highground2.mesh + + + + + + + + + + + Models/Props/Highground3.mesh + + + + + + + + + + + Models/Highgrounds/Highground24.mesh + + + + + + + + + + + + Models/Highgrounds/Hg13.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg25.mesh + + + + + + + + + + + + Models/Highgrounds/Hg26.mesh + + + + + + + + + + + + Models/Highgrounds/Hg9.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg4.mesh + + + + + + + + + + + + + + Models/Highgrounds/Hg10.mesh + + + + + + + + + + + + + + Models/Highgrounds/Hg19.mesh + + + + + + + + + + + + + + Models/Highgrounds/Hg19.mesh + + + + + + + + + + + + + + + Models/Highgrounds/Highground12.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg16.mesh + + + + + + + + + + + + Models/Highgrounds/Hg15.mesh + + + + + + + + + + + + Models/Highgrounds/Hg14.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg13.mesh + + + + + + + + + + + + Models/Highgrounds/Hg11.mesh + + + + + + + + + + + + Models/Highgrounds/Hg20.mesh + + + + + + + + + + + + Models/Highgrounds/Hg18.mesh + + + + + + + + + + + + Models/Highgrounds/Hg19.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg17.mesh + + + + + + + + + + + + + + + Models/Highgrounds/Hg8.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg7.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg3.mesh + + + + + + + + + + + + + + + Models/Props/Highground1.mesh + + + + + + + + + + + + Models/Props/Highground2.mesh + + + + + + + + + + + + + Models/Props/Highground3.mesh + + + + + + + + + + + + + Models/Highgrounds/Highground1.mesh + + + + + + + + + + + Models/Highgrounds/Highground2.mesh + + + + + + + + + + + + + + Models/Highgrounds/Hg1.mesh + + + + + + + + + + + Models/Highgrounds/Hg2.mesh + + + + + + + + + + + + + + Models/Highgrounds/Highground5.mesh + + + + + + + + + + + + Models/Highgrounds/Hg7.mesh + + + + + + + + + + + + Models/Highgrounds/Hg17.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg19.mesh + + + + + + + + + + + + Models/Highgrounds/Hg18.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg20.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg6.mesh + + + + + + + + + + + + Models/Highgrounds/Hg8.mesh + + + + + + + + + + + + Models/Highgrounds/Hg10.mesh + + + + + + + + + + + + Models/Highgrounds/Hg4.mesh + + + + + + + + + + + + Models/Highgrounds/Hg16.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg9.mesh + + + + + + + + + + + + Models/Highgrounds/Hg3.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg19.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Highgrounds/Hg10.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + + + Models/Highgrounds/Highground22.mesh + + + + + + + + + + + + Models/Highgrounds/Hg8.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg19.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg21.mesh + + + + + + + + + + + + Models/Highgrounds/Hg11.mesh + + + + + + + + + + + + Models/Highgrounds/Hg3.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg17.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg8.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + + + Models/Highgrounds/Hg28.mesh + + + + + + + + + + + Models/Highgrounds/Hg10.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg27.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg15.mesh + + + + + + + + + + + + + + Models/Highgrounds/Hg13.mesh + + + + + + + + + + + + + + + Models/Highgrounds/Hg27.mesh + + + + + + + + + + + + Models/Highgrounds/Hg23.mesh + + + + + + + + + + + + + + + Models/Highgrounds/Hg27.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg23.mesh + + + + + + + + + + + + + + + Models/Highgrounds/Hg28.mesh + + + + + + + + + + + + Models/Highgrounds/Hg10.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg27.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg15.mesh + + + + + + + + + + + + + + Models/Highgrounds/Hg13.mesh + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar3Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar3Red.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 5 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 4 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + + 3 + + + + + + + + + + + + 2 + 1 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 4 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/smallWall3.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 4 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 3 + + + + + + + + + + + + 2 + + + + + + + + + + + + 2 + 1 + + + + + + + + + + + + + + 4 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar3Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar3Blue.mesh + + + + + + + + + + + + + + + + + + + + + + 10 + + + + + + + + + + + 1 + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + + 10 + + + + + + + + + + + 1 + + + + + + + + + + + + 10 + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 3 + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 15 + 1 + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointBlue.mesh + + + + + + + + + + -15 + + + + 4 + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 15 + 2 + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointRed.mesh + + + + + + + + + + 15 + + + + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + Schema/Entities/PlayerAssaultFallbackBlue.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + + + Schema/Entities/PlayerAssaultFallbackBlue.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + + + From 00c585de3cb762aa1e8e92ed26e555631feb226b Mon Sep 17 00:00:00 2001 From: Tleety Date: Thu, 3 Mar 2016 20:45:16 +0100 Subject: [PATCH 197/252] Score should now track to all clients --- include/Game/Systems/ScoreScreenSystem.h | 1 + resources/Schema/Components/ScoreScreen.xml | 1 + resources/Schema/Components/ScoreScreen.xsd | 3 + resources/Schema/Entities/CP_Rocky.xml | 2278 ++++++++++--------- resources/Schema/Entities/ScoreBoard.xml | 107 + src/Engine/Network/Server.cpp | 10 +- src/Game/Systems/ScoreScreenSystem.cpp | 32 +- 7 files changed, 1309 insertions(+), 1123 deletions(-) create mode 100644 resources/Schema/Entities/ScoreBoard.xml diff --git a/include/Game/Systems/ScoreScreenSystem.h b/include/Game/Systems/ScoreScreenSystem.h index a33d4684..7a1d0cae 100644 --- a/include/Game/Systems/ScoreScreenSystem.h +++ b/include/Game/Systems/ScoreScreenSystem.h @@ -34,6 +34,7 @@ private: EntityWrapper Player = EntityWrapper::Invalid; }; + std::vector m_DisconnectedIdentities; int m_PlayerCounter = 0; std::unordered_map m_PlayerIdentities; }; diff --git a/resources/Schema/Components/ScoreScreen.xml b/resources/Schema/Components/ScoreScreen.xml index 65d84aa6..d3571d07 100644 --- a/resources/Schema/Components/ScoreScreen.xml +++ b/resources/Schema/Components/ScoreScreen.xml @@ -2,4 +2,5 @@ 0 0 + \ No newline at end of file diff --git a/resources/Schema/Components/ScoreScreen.xsd b/resources/Schema/Components/ScoreScreen.xsd index c8d3fa59..fb285813 100644 --- a/resources/Schema/Components/ScoreScreen.xsd +++ b/resources/Schema/Components/ScoreScreen.xsd @@ -11,6 +11,9 @@ Where the next scoreIdentity should be placed. + + How much offset should be applied per position + diff --git a/resources/Schema/Entities/CP_Rocky.xml b/resources/Schema/Entities/CP_Rocky.xml index a6f6302d..a0ae548f 100644 --- a/resources/Schema/Entities/CP_Rocky.xml +++ b/resources/Schema/Entities/CP_Rocky.xml @@ -112,61 +112,111 @@ - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -629,6 +679,49 @@ + + + + + 5 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + 2 + + + + + + + + + @@ -673,17 +766,6 @@ - - - - - - - - - - - @@ -707,23 +789,19 @@ + + + + + + + + + + + - - - - - 5 - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - @@ -739,34 +817,6 @@ - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - 2 - - - - - - - - - @@ -858,11 +908,11 @@ 2 - + - + @@ -879,7 +929,7 @@ - + @@ -905,11 +955,11 @@ 2 - + - + @@ -926,7 +976,7 @@ - + @@ -952,11 +1002,11 @@ 2 - + - + @@ -973,7 +1023,7 @@ - + @@ -999,11 +1049,11 @@ 2 - + - + @@ -1020,7 +1070,7 @@ - + @@ -1046,11 +1096,11 @@ 2 - + - + @@ -1067,7 +1117,7 @@ - + @@ -1093,11 +1143,11 @@ 2 - + - + @@ -1114,7 +1164,7 @@ - + @@ -1140,11 +1190,11 @@ 2 - + - + @@ -1161,7 +1211,7 @@ - + @@ -2409,11 +2459,11 @@ 2 - + - + @@ -2430,7 +2480,7 @@ - + @@ -2456,11 +2506,11 @@ 2 - + - + @@ -2477,7 +2527,7 @@ - + @@ -2739,559 +2789,6 @@ - - - - - - - - - - Models/Props/Flora/SpecialRoot.mesh - - - - - - - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - @@ -3311,47 +2808,6 @@ - - - - - Models/Props/Bridges/SciFiBridge1Blue.mesh - - - - - - - - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridge1Blue.mesh - - - - - - - - - @@ -3470,6 +2926,135 @@ + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + @@ -3484,8 +3069,8 @@ Models/Props/SciFiHolder1.mesh - - + + @@ -3497,8 +3082,8 @@ Models/Props/SciFiHolder1.mesh - - + + @@ -3514,11 +3099,23 @@ - Models/Props/Walls/BigWallRed.mesh + Models/Props/Walls/MediumWall1.mesh - - + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + @@ -3540,11 +3137,10 @@ - Models/Props/Walls/MediumWall2.mesh + Models/Props/Walls/MediumWall1.mesh - - + @@ -3556,12 +3152,65 @@ Models/Props/Walls/SmallWall3.mesh - + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + @@ -3627,20 +3276,6 @@ - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - @@ -3654,18 +3289,6 @@ - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - @@ -3679,15 +3302,70 @@ + + + + + + + - Models/Props/Walls/MediumWall2.mesh + Models/Props/Flora/SpecialRoot.mesh - - + + + + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + @@ -3696,10 +3374,11 @@ - Models/Props/Walls/MediumWall1.mesh + Models/Props/Stones/MediumStone2.mesh - + + @@ -3708,11 +3387,382 @@ - Models/Props/Walls/SmallWall3.mesh + Models/Props/Stones/SmallStone2.mesh - - + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + @@ -3724,6 +3774,21 @@ + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + @@ -3739,6 +3804,85 @@ + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + @@ -3771,13 +3915,14 @@ - 6 + 4 Models/Props/Stones/ShinyStoneCrystalBlue.mesh + - - - + + + @@ -3785,20 +3930,10 @@ + 3 - - - - - - - - - - - - + @@ -3810,7 +3945,20 @@ 2 - + + + + + + + + + + 2 + 1 + + + @@ -3832,104 +3980,6 @@ - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - 4 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - 2 - 1 - - - - - - - - - - - - 2 - - - - - - - - - - - - 3 - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - @@ -3943,9 +3993,9 @@ Models/Props/PickUps/PickUpHolder.mesh - - - + + + @@ -3953,11 +4003,11 @@ 2 - + - + @@ -3972,56 +4022,9 @@ Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - 2 - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - + @@ -4047,11 +4050,11 @@ 2 - + - + @@ -4068,7 +4071,7 @@ - + @@ -4084,9 +4087,9 @@ Models/Props/PickUps/PickUpHolder.mesh - - - + + + @@ -4094,11 +4097,11 @@ 2 - + - + @@ -4114,55 +4117,8 @@ Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - 2 - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - + + @@ -4188,11 +4144,11 @@ 2 - + - + @@ -4209,7 +4165,54 @@ - + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + @@ -4235,11 +4238,11 @@ 2 - + - + @@ -4256,7 +4259,54 @@ - + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + @@ -4273,6 +4323,20 @@ + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + @@ -4302,20 +4366,6 @@ - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - @@ -4516,76 +4566,6 @@ - - - - - Schema/Entities/PlayerRed.xml - - - - - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - @@ -4610,7 +4590,7 @@ false - + @@ -4623,7 +4603,7 @@ false - + @@ -4656,18 +4636,97 @@ + + + + + Schema/Entities/PlayerRed.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + - + - - 0.40000000596046448 - + + 1 + + + + + + + + + 10 + - + @@ -4675,11 +4734,10 @@ - 10 - + @@ -4707,22 +4765,13 @@ - + - - 1 - - - - - - - - - 10 - + + 0.40000000596046448 + - + @@ -4730,10 +4779,11 @@ + 10 - + diff --git a/resources/Schema/Entities/ScoreBoard.xml b/resources/Schema/Entities/ScoreBoard.xml new file mode 100644 index 00000000..ce612800 --- /dev/null +++ b/resources/Schema/Entities/ScoreBoard.xml @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Engine/Network/Server.cpp b/src/Engine/Network/Server.cpp index 71889379..6d6c4f92 100644 --- a/src/Engine/Network/Server.cpp +++ b/src/Engine/Network/Server.cpp @@ -635,9 +635,13 @@ bool Server::shouldSendToClient(EntityWrapper childEntity) return true; } } - return childEntity.HasComponent("Player") || childEntity.FirstParentWithComponent("Player").Valid() - || childEntity.HasComponent("CapturePoint") || childEntity.HasComponent("HealthPickup") - || childEntity.HasComponent("AmmoPickup"); + return childEntity.HasComponent("Player") + || childEntity.FirstParentWithComponent("Player").Valid() + || childEntity.HasComponent("CapturePoint") + || childEntity.HasComponent("HealthPickup") + || childEntity.HasComponent("AmmoPickup") + || childEntity.HasComponent("ScoreScreen") + || childEntity.FirstParentWithComponent("ScoreScreen").Valid(); } PlayerID Server::GetPlayerIDFromEndpoint() diff --git a/src/Game/Systems/ScoreScreenSystem.cpp b/src/Game/Systems/ScoreScreenSystem.cpp index 0713e13b..e23fba1d 100644 --- a/src/Game/Systems/ScoreScreenSystem.cpp +++ b/src/Game/Systems/ScoreScreenSystem.cpp @@ -13,7 +13,6 @@ ScoreScreenSystem::ScoreScreenSystem(SystemParams params) void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) { - //TODO: Check team al if (!IsServer) { return; } @@ -37,6 +36,8 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& auto children = entity.ChildrenWithComponent("ScoreIdentity"); + float position = 0.f; + for (auto it = m_PlayerIdentities.begin(); it != m_PlayerIdentities.end(); ++it) { bool found = false; @@ -45,20 +46,38 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& if (it->first == ID) { if (it->second.Team != currentTeam) { m_World->DeleteEntity(child.ID); + (int&)entity["ScoreScreen"]["TotalIdentities"] -= 1; break; } + for (auto it = m_DisconnectedIdentities.begin(); it != m_DisconnectedIdentities.end(); ++it) { + if (ID = *it) { + + m_World->DeleteEntity(child.ID); + (int&)entity["ScoreScreen"]["TotalIdentities"] -= 1; + it = m_DisconnectedIdentities.erase(it); + break; + } + } found = true; + //Update position for childs + glm::vec3 offset = (glm::vec3)entity["ScoreScreen"]["Offset"]; + (glm::vec3&) child["Transform"]["Position"] = offset * position; + position += 1.f; + break; } } if(found == false) { if(it->second.Team != currentTeam) { //This player is not the same team as this scoreboard should show. - break; + continue; } //There is no entry for this player, create one. auto entityFile = ResourceManager::Load("Schema/Entities/ScoreIdentity.xml"); EntityWrapper scoreIdentity = entityFile->MergeInto(m_World); + glm::vec3 offset = (glm::vec3)entity["ScoreScreen"]["Offset"]; + int newPosition = (int)entity["ScoreScreen"]["TotalIdentities"]; + (glm::vec3&) scoreIdentity["Transform"]["Position"] = offset * (float)newPosition; auto cScoreIdentity = scoreIdentity["ScoreIdentity"]; auto data = it->second; @@ -67,12 +86,12 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& (int&)cScoreIdentity["Ping"] = 1337; m_World->SetParent(scoreIdentity.ID, entity.ID); + + (int&)entity["ScoreScreen"]["TotalIdentities"] += 1; + } } - //For each scoreboard, go through children and see if they have all of the ones needed. - //Also need to take into account the order so they dont flicker. - //If they do not have all children we need to add them. - //Just add a new component to the scorescreen entity, the "ScoreIdentity" component. + //Local player should have an icon, compare with LocalPlayer somthing } bool ScoreScreenSystem::OnPlayerDeath(const Events::PlayerDeath& e) @@ -113,6 +132,7 @@ bool ScoreScreenSystem::OnPlayerConnected(const Events::PlayerConnected& e) bool ScoreScreenSystem::OnPlayerDisconnected(const Events::PlayerDisconnected& e) { //player has disconnected, remove him from list of ScoreIdentities + m_DisconnectedIdentities.push_back(e.PlayerID); m_PlayerIdentities.erase(e.PlayerID); return 0; } From e24a0b127b9c7be5b871fd56a5df265272c1338d Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 3 Mar 2016 20:59:30 +0100 Subject: [PATCH 198/252] Added Ability cooldown UI and missing texture --- assets | 2 +- .../Entities/PlayerAssaultFallbackBlue.xml | 68 ++++++++++--------- 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/assets b/assets index 7a6d7078..c82b5716 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 7a6d70787b036d8ae8763b69ae6ad098bf221c22 +Subproject commit c82b5716d98a0c9fb3914367e9b08cc2e7dbca43 diff --git a/resources/Schema/Entities/PlayerAssaultFallbackBlue.xml b/resources/Schema/Entities/PlayerAssaultFallbackBlue.xml index bb6367f8..d5d7579c 100644 --- a/resources/Schema/Entities/PlayerAssaultFallbackBlue.xml +++ b/resources/Schema/Entities/PlayerAssaultFallbackBlue.xml @@ -169,6 +169,40 @@ + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + 0.0 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + @@ -538,6 +572,7 @@ Models/Characters/Assault/AssaultBlue.mesh + false @@ -561,38 +596,7 @@ - - - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - - - - - - - - Schema/Entities/RayBlue.xml - - - - - - - - - - - Schema/Entities/ReloadEffectWorld.xml - - - - - - - - + From 6532e9896eda73327421de694ed9127e70769fb2 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 3 Mar 2016 21:05:21 +0100 Subject: [PATCH 199/252] fixup! Playtest 2 Fallback Map --- resources/Schema/Entities/Maps/Playtest2-Fallback.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/Schema/Entities/Maps/Playtest2-Fallback.xml b/resources/Schema/Entities/Maps/Playtest2-Fallback.xml index 8217ab45..113abe6e 100644 --- a/resources/Schema/Entities/Maps/Playtest2-Fallback.xml +++ b/resources/Schema/Entities/Maps/Playtest2-Fallback.xml @@ -1,5 +1,5 @@ - + From 68332102ead701a3c07eddb7921cc3313853b989 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Thu, 3 Mar 2016 21:20:55 +0100 Subject: [PATCH 200/252] Can now blend non unique nodes --- resources/Schema/Entities/BlendTreeTest.xml | 47 +++++++++---- src/Engine/Rendering/AnimationSystem.cpp | 77 ++++++++++++++++++++- src/Engine/Rendering/AutoBlendQueue.cpp | 2 +- src/Engine/Rendering/BlendTree.cpp | 62 ++++++++++++++++- 4 files changed, 168 insertions(+), 20 deletions(-) diff --git a/resources/Schema/Entities/BlendTreeTest.xml b/resources/Schema/Entities/BlendTreeTest.xml index 69590ceb..d2c7ead9 100644 --- a/resources/Schema/Entities/BlendTreeTest.xml +++ b/resources/Schema/Entities/BlendTreeTest.xml @@ -68,8 +68,8 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - + + @@ -125,7 +125,7 @@ StandCrouchBlend JumpDashBlend - 0.00067602147306955462 + 1.055110346338068e-57 @@ -135,7 +135,7 @@ StandMovement CrouchMovement - 0 + 0.0069837930620454403 @@ -155,7 +155,7 @@ RunWalkBlend StrafeLRBlend - 0 + 2.4565650245976452e-16 @@ -165,7 +165,7 @@ Walk Run - 1 + 1.2938206818383024e-24 @@ -174,6 +174,9 @@ WalkF + + 1 + true @@ -183,7 +186,7 @@ RunF - + 1 true @@ -198,7 +201,7 @@ Left Right - 0 + 0.033793529385008014 @@ -207,6 +210,9 @@ StrafeLeftF + + 1 + true @@ -216,6 +222,9 @@ StrafeRightF + + 1 + true @@ -243,6 +252,7 @@ MovementBlend Idle + 0 @@ -252,7 +262,7 @@ Walk StrafeLRBlend - 0 + 2.4565650245976452e-16 @@ -262,7 +272,7 @@ Left Right - 0 + 0.033793529385008014 @@ -271,6 +281,9 @@ CrouchStrafeLeftF + + 1 + true @@ -280,6 +293,9 @@ CrouchStrafeRightF + + 1 + true @@ -291,6 +307,9 @@ CrouchWalkF + + 1 + true @@ -318,7 +337,7 @@ Jump DashBlend - 0.01016461050458084 + 1 @@ -340,7 +359,7 @@ DashFBBlend DashLRBlend - 0.99999999999984523 + 0.014621149736541383 @@ -350,7 +369,7 @@ DashForward DashBackward - 0.98238059685988577 + 0.014363533804961248 @@ -386,7 +405,7 @@ DashLeft DashRight - 0.96547196574235861 + 4.3244885367500671e-16 diff --git a/src/Engine/Rendering/AnimationSystem.cpp b/src/Engine/Rendering/AnimationSystem.cpp index 166ecb47..4434e80b 100644 --- a/src/Engine/Rendering/AnimationSystem.cpp +++ b/src/Engine/Rendering/AnimationSystem.cpp @@ -371,7 +371,7 @@ bool AnimationSystem::OnInputCommand(const Events::InputCommand& e) if (entity.Name() == "Assault") { { Events::AutoAnimationBlend aeb; - aeb.Duration = 0.35; + aeb.Duration = 0.25; aeb.NodeName = "Jump"; aeb.RootNode = entity; aeb.Start = true; @@ -380,7 +380,7 @@ bool AnimationSystem::OnInputCommand(const Events::InputCommand& e) } { Events::AutoAnimationBlend aeb; - aeb.Duration = 0.6; + aeb.Duration = 0.3; aeb.NodeName = "StandCrouchBlend"; aeb.RootNode = entity; aeb.Start = true; @@ -496,6 +496,79 @@ bool AnimationSystem::OnInputCommand(const Events::InputCommand& e) } } } + } else if (e.Command == "LeftTest") { + auto blendComponents = m_World->GetComponents("BlendAdditive"); + + if (blendComponents == nullptr) { + return false; + } + for (auto& bc : *blendComponents) { + EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); + + if (entity.Name() == "Assault") { + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.1; + aeb.NodeName = "Left"; + aeb.RootNode = entity; + aeb.Start = true; + m_EventBroker->Publish(aeb); + } + } + } + } else if (e.Command == "RightTest") { + auto blendComponents = m_World->GetComponents("BlendAdditive"); + + if (blendComponents == nullptr) { + return false; + } + for (auto& bc : *blendComponents) { + EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); + + if (entity.Name() == "Assault") { + /* { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.1; + aeb.NodeName = "Right"; + aeb.RootNode = entity; + aeb.Start = true; + m_EventBroker->Publish(aeb); + }*/ + + + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.3; + aeb.NodeName = "Right"; + aeb.RootNode = entity; + aeb.Start = true; + aeb.Restart = false; + aeb.AnimationEntity = entity.FirstChildByName("DashRight"); + aeb.Delay = -0.3; + m_EventBroker->Publish(aeb); + } + } + } + } else if (e.Command == "ForwardTest") { + auto blendComponents = m_World->GetComponents("BlendAdditive"); + + if (blendComponents == nullptr) { + return false; + } + for (auto& bc : *blendComponents) { + EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); + + if (entity.Name() == "Assault") { + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.1; + aeb.NodeName = "Walk"; + aeb.RootNode = entity; + aeb.Start = true; + m_EventBroker->Publish(aeb); + } + } + } } diff --git a/src/Engine/Rendering/AutoBlendQueue.cpp b/src/Engine/Rendering/AutoBlendQueue.cpp index 9f0a7366..e75e33b5 100644 --- a/src/Engine/Rendering/AutoBlendQueue.cpp +++ b/src/Engine/Rendering/AutoBlendQueue.cpp @@ -85,7 +85,7 @@ void AutoBlendQueue::UpdateTime(double dt) for (auto it = m_BlendQueue.begin(); it != m_BlendQueue.end();) { it->EndTime -= dt; it->StartTime -= dt; - if (it->EndTime < 0) { + if (it->EndTime <= 0) { it = m_BlendQueue.erase(it); } else { it++; diff --git a/src/Engine/Rendering/BlendTree.cpp b/src/Engine/Rendering/BlendTree.cpp index 036c3f49..2f74b45e 100644 --- a/src/Engine/Rendering/BlendTree.cpp +++ b/src/Engine/Rendering/BlendTree.cpp @@ -252,16 +252,72 @@ BlendTree::AutoBlendInfo BlendTree::AutoBlendStep(AutoBlendInfo blendInfo) lastNode = currentNode; currentNode = currentNode->Parent; } - - } else if(goalNodes.size() >= 2) { + std::vector sharedParents; + std::vector nodes = goalNodes; + + for (auto it = nodes.begin(); it != nodes.end(); it++) { + auto next = std::next(it, 1); + if (next != nodes.end()) { + Node* commonParent = FirstCommonParent((*it), (*next)); + sharedParents.push_back(commonParent); + (*next) = commonParent; + nodes.erase(it); + it = nodes.begin(); + } + } + + + for (auto it = goalNodes.begin(); it != goalNodes.end(); it++) { + + Node* currentNode = (*it)->Parent; + Node* lastNode = (*it); + + while (currentNode != nullptr) { + if (!currentNode->Entity.HasComponent("Blend")) { + return blendInfo; + } + + bool ShouldBreak = false; + for (auto it = sharedParents.begin(); it != sharedParents.end(); it++) { + if(currentNode == (*it)) { + ShouldBreak = true; + } + } + + if(ShouldBreak) { + break; + } + + double startWeight; + if (blendInfo.StartWeights.find(currentNode->Entity) != blendInfo.StartWeights.end()) { + startWeight = blendInfo.StartWeights.at(currentNode->Entity); + } else { + startWeight = currentNode->Weight; + blendInfo.StartWeights[currentNode->Entity] = startWeight; + } + + double goalWeight; + if (currentNode->Child[0] == lastNode) { + goalWeight = 0.0; + } else if (currentNode->Child[1] == lastNode) { + goalWeight = 1.0; + } + + double weight = ((goalWeight - startWeight) * blendInfo.progress) + startWeight; + (double&)currentNode->Entity["Blend"]["Weight"] = weight; + currentNode->Weight = weight; + + lastNode = currentNode; + currentNode = currentNode->Parent; + } + } } return blendInfo; } - BlendTree::Node* BlendTree::GetCommonParent(std::string NodeName1, std::string NodeName2) { std::vector nodes1 = FindNodesByName(NodeName1); From b1148c0c6cc8f00272459c6c00ee5281345e48f6 Mon Sep 17 00:00:00 2001 From: Jocke Date: Thu, 3 Mar 2016 21:24:31 +0100 Subject: [PATCH 201/252] Added a afterimage SprintEffect for the Sniper. --- include/Game/Systems/PlayerMovementSystem.h | 2 + resources/Schema/Components/SprintAbility.xml | 1 + resources/Schema/Components/SprintAbility.xsd | 3 ++ resources/Schema/Entities/SprintEffect.xml | 25 ++++++++++++ src/Game/Systems/PlayerMovementSystem.cpp | 40 ++++++++++++++++++- 5 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 resources/Schema/Entities/SprintEffect.xml diff --git a/include/Game/Systems/PlayerMovementSystem.h b/include/Game/Systems/PlayerMovementSystem.h index bf7b4718..981fc13a 100644 --- a/include/Game/Systems/PlayerMovementSystem.h +++ b/include/Game/Systems/PlayerMovementSystem.h @@ -30,6 +30,8 @@ private: bool m_LeftFoot = false; // To get a difference when calculating the walking state. glm::vec3 m_LastPosition = glm::vec3(); + // Used to track afterimages for sprint effect. + float m_SprintEffectTimer; // The logic for making the sound play when player is moving void playerStep(double dt); // Spawn a hexagon at origin of an Entity diff --git a/resources/Schema/Components/SprintAbility.xml b/resources/Schema/Components/SprintAbility.xml index 5cc59a3a..578c0017 100644 --- a/resources/Schema/Components/SprintAbility.xml +++ b/resources/Schema/Components/SprintAbility.xml @@ -1,4 +1,5 @@ 2.0 + false \ No newline at end of file diff --git a/resources/Schema/Components/SprintAbility.xsd b/resources/Schema/Components/SprintAbility.xsd index 9eabb450..7fe0d65a 100644 --- a/resources/Schema/Components/SprintAbility.xsd +++ b/resources/Schema/Components/SprintAbility.xsd @@ -12,6 +12,9 @@ This is the strength of the sprint effect + + True if currently sprinting. + diff --git a/resources/Schema/Entities/SprintEffect.xml b/resources/Schema/Entities/SprintEffect.xml new file mode 100644 index 00000000..ab897cf5 --- /dev/null +++ b/resources/Schema/Entities/SprintEffect.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + 0.1 + + + + 0.1 + + + + + + + + + + diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index b116bcd9..8d0ff990 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -2,6 +2,7 @@ PlayerMovementSystem::PlayerMovementSystem(SystemParams params) : System(params) + , m_SprintEffectTimer(0.f) { EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &PlayerMovementSystem::OnPlayerSpawned); EVENT_SUBSCRIBE_MEMBER(m_EDoubleJump, &PlayerMovementSystem::OnDoubleJump); @@ -19,8 +20,42 @@ void PlayerMovementSystem::Update(double dt) { updateMovementControllers(dt); // Only do physics calculations on client and only for themselves. - if (IsClient && LocalPlayer.Valid()) { - updateVelocity(LocalPlayer, dt); + if (IsClient) { + if (LocalPlayer.Valid()){ + updateVelocity(LocalPlayer, dt); + } + m_SprintEffectTimer += dt; + if (m_SprintEffectTimer < 0.016f) { + return; + } + m_SprintEffectTimer = 0.f; + const ComponentPool* pool = m_World->GetComponents("SprintAbility"); + if (pool == nullptr) { + return; + } + for (auto cSprint : *pool) { + if (/*cSprint.EntityID != LocalPlayer.ID && */(bool)cSprint["Active"]) { + // Spawn one afterimage for each player that sprints. + EntityWrapper player(m_World, cSprint.EntityID); + auto entityFile = ResourceManager::Load("Schema/Entities/SprintEffect.xml"); + EntityWrapper dashEffect = entityFile->MergeInto(m_World); + auto playerModel = player.FirstChildByName("PlayerModel"); + if (!playerModel.Valid()) { + continue; + } + auto playerEntityModel = playerModel["Model"]; + auto playerEntityAnimation = playerModel["Animation"]; + playerEntityModel.Copy(dashEffect["Model"]); + playerEntityAnimation.Copy(dashEffect["Animation"]); + dashEffect["ExplosionEffect"]["EndColor"] = (glm::vec4)playerEntityModel["Color"]; + ((glm::vec4&)dashEffect["ExplosionEffect"]["EndColor"]).w = 0.f; + dashEffect["Animation"]["Speed1"] = 0.0; + dashEffect["Animation"]["Speed2"] = 0.0; + dashEffect["Animation"]["Speed3"] = 0.0; + dashEffect["Transform"]["Position"] = (glm::vec3)player["Transform"]["Position"]; + dashEffect["Transform"]["Orientation"] = (glm::vec3)player["Transform"]["Orientation"]; + } + } } } @@ -64,6 +99,7 @@ void PlayerMovementSystem::updateMovementControllers(double dt) } bool sniperSprinting = false; if (player.HasComponent("SprintAbility")) { + (bool)player["SprintAbility"]["Active"] = controller->SpecialAbilityKeyDown(); if (controller->SpecialAbilityKeyDown()) { playerMovementSpeed *= (double)player["SprintAbility"]["StrengthOfEffect"]; playerCrouchSpeed *= (double)player["SprintAbility"]["StrengthOfEffect"]; From f5ea4e06c7b2b552e505a1c2f4c6c2e33b449058 Mon Sep 17 00:00:00 2001 From: Tleety Date: Thu, 3 Mar 2016 21:37:18 +0100 Subject: [PATCH 202/252] Map --- ...Playtest2-Fallback.xml => CP_RockHard.xml} | 4643 +++++++++-------- 1 file changed, 2322 insertions(+), 2321 deletions(-) rename resources/Schema/Entities/Maps/{Playtest2-Fallback.xml => CP_RockHard.xml} (99%) diff --git a/resources/Schema/Entities/Maps/Playtest2-Fallback.xml b/resources/Schema/Entities/Maps/CP_RockHard.xml similarity index 99% rename from resources/Schema/Entities/Maps/Playtest2-Fallback.xml rename to resources/Schema/Entities/Maps/CP_RockHard.xml index 113abe6e..4f104155 100644 --- a/resources/Schema/Entities/Maps/Playtest2-Fallback.xml +++ b/resources/Schema/Entities/Maps/CP_RockHard.xml @@ -1,5 +1,5 @@ - + @@ -30,6 +30,16 @@ + + + + + Models/Props/Walls/SciFiWallSmall2.mesh + + + + + @@ -73,16 +83,6 @@ - - - - - Models/Props/Walls/SciFiWallSmall2.mesh - - - - - @@ -704,6 +704,18 @@ + + + + + Models/Highgrounds/Hg8.mesh + + + + + + + @@ -779,18 +791,6 @@ - - - - - Models/Highgrounds/Hg8.mesh - - - - - - - @@ -2528,6 +2528,169 @@ + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + @@ -2565,7 +2728,7 @@ - + @@ -2607,7 +2770,7 @@ - + @@ -2649,7 +2812,7 @@ - + @@ -2691,7 +2854,7 @@ - + @@ -2733,7 +2896,7 @@ - + @@ -2775,7 +2938,7 @@ - + @@ -2817,7 +2980,7 @@ - + @@ -2859,7 +3022,7 @@ - + @@ -2901,7 +3064,7 @@ - + @@ -2975,6 +3138,52 @@ + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + @@ -3052,6 +3261,357 @@ + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + @@ -3331,19 +3891,6 @@ - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - @@ -3358,19 +3905,6 @@ - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - @@ -3384,19 +3918,6 @@ - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - @@ -3439,19 +3960,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - @@ -3465,19 +3973,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - @@ -3492,19 +3987,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - @@ -3518,20 +4000,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - @@ -3546,20 +4014,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - @@ -3574,20 +4028,6 @@ - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - @@ -3601,19 +4041,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - @@ -3627,19 +4054,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - @@ -3653,19 +4067,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - @@ -3679,19 +4080,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - @@ -3705,19 +4093,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - @@ -3731,20 +4106,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - @@ -3759,20 +4120,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - @@ -3787,20 +4134,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - @@ -3815,20 +4148,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - @@ -3843,20 +4162,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - @@ -3871,20 +4176,6 @@ - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - - @@ -3899,19 +4190,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - @@ -3925,20 +4203,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - @@ -3953,20 +4217,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - @@ -3981,20 +4231,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - @@ -4009,20 +4245,6 @@ - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - - @@ -4037,19 +4259,6 @@ - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - @@ -4065,7 +4274,7 @@ - + @@ -4074,38 +4283,12 @@ - Models/Props/Stones/AssaultHolder.mesh + Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - + + + @@ -4114,11 +4297,12 @@ - Models/Props/Stones/AssaultHolder.mesh + Models/Props/Walls/SpecialWall1.mesh - - + + + @@ -4127,19 +4311,33 @@ - Models/Props/Stones/AssaultHolder.mesh + Models/Props/Walls/SpecialWall1.mesh - - - + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + - + @@ -4151,77 +4349,7 @@ Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Red.mesh - - - - - - - - - - - - - - 6 - Models/Props/Pillars/SciFiPillar1Red.mesh - - - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Red.mesh - - - - + @@ -4251,11 +4379,11 @@ - Models/Props/Walls/MediumWall3.mesh + Models/Props/Walls/SmallWall3.mesh - - + + @@ -4273,6 +4401,19 @@ + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + @@ -4280,8 +4421,21 @@ Models/Props/Walls/SmallWall3.mesh - - + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + @@ -4313,46 +4467,6 @@ - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - @@ -4360,8 +4474,21 @@ Models/Props/Walls/MediumWall3.mesh - - + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + @@ -4373,21 +4500,8 @@ Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - + + @@ -4413,7 +4527,20 @@ Models/Props/Walls/SmallWall3.mesh - + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + @@ -4427,8 +4554,77 @@ Models/Props/Walls/MediumWall3.mesh - - + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + @@ -4446,20 +4642,6 @@ - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - @@ -4473,20 +4655,6 @@ - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - @@ -4555,19 +4723,6 @@ - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - @@ -4608,20 +4763,6 @@ - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - @@ -4636,19 +4777,6 @@ - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - @@ -4666,134 +4794,6 @@ - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - @@ -4801,7 +4801,7 @@ - + @@ -4810,65 +4810,11 @@ - Models/Props/Walls/BigWallRed.mesh + Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - + + @@ -4878,12 +4824,11 @@ - Models/Props/Walls/SmallWall3.mesh + Models/Props/Stones/AssaultHolder.mesh - - - + + @@ -4892,12 +4837,11 @@ - Models/Props/Walls/SmallWall3.mesh + Models/Props/Stones/AssaultHolder.mesh - - - + + @@ -4906,11 +4850,11 @@ - Models/Props/Walls/MediumWall3.mesh + Models/Props/Stones/AssaultHolder.mesh - - + + @@ -4919,11 +4863,11 @@ - Models/Props/Walls/BigWallRed.mesh + Models/Props/Stones/AssaultHolder.mesh - - + + @@ -4932,11 +4876,146 @@ - Models/Props/Walls/BigWallBlue.mesh + Models/Props/Stones/AssaultHolder.mesh - + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + @@ -4945,12 +5024,62 @@ - Models/Props/Walls/smallWall3.mesh + Models/Props/Stones/AssaultHolder.mesh - - - + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + @@ -4994,7 +5123,7 @@ - + @@ -5036,7 +5165,7 @@ - + @@ -5048,7 +5177,7 @@ - + @@ -5057,171 +5186,105 @@ - Models/Props/Stones/AssaultHolder.mesh + Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + @@ -5231,11 +5294,12 @@ - Models/Props/Stones/AssaultHolder.mesh + Models/Props/Walls/SmallWall3.mesh - - + + + @@ -5244,11 +5308,11 @@ - Models/Props/Stones/AssaultHolder.mesh + Models/Props/Walls/BigWallRed.mesh - - + + @@ -5257,39 +5321,12 @@ - Models/Props/Stones/AssaultHolder.mesh + Models/Props/Walls/smallWall3.mesh - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - + + + @@ -5318,11 +5355,12 @@ - Models/Props/Pillars/StonePillar.mesh + Models/Props/Stones/SmallStone2.mesh - - + + + @@ -5344,11 +5382,11 @@ - Models/Props/Stones/SmallStone1.mesh + Models/Props/Stones/MediumStone2.mesh - - + + @@ -5366,6 +5404,85 @@ + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + @@ -5380,19 +5497,6 @@ - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - @@ -5406,20 +5510,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - @@ -5461,19 +5551,6 @@ - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - @@ -5543,19 +5620,6 @@ - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - @@ -5570,20 +5634,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - @@ -5597,19 +5647,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - @@ -5625,43 +5662,6 @@ - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - @@ -5676,21 +5676,6 @@ - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - @@ -5710,10 +5695,10 @@ - 3 + 2 - + @@ -5722,10 +5707,10 @@ - 2 + 3 - + @@ -5761,21 +5746,6 @@ - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - @@ -5799,61 +5769,11 @@ Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - + + - - - - - - 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - @@ -5892,13 +5812,108 @@ Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + + + + + + + + + + + + 5 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + @@ -5914,21 +5929,6 @@ - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - @@ -5951,6 +5951,33 @@ + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + @@ -5958,9 +5985,21 @@ Models/Props/Stones/MediumStone2.mesh - - - + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + @@ -5978,46 +6017,6 @@ - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - @@ -6039,36 +6038,9 @@ Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - + + + @@ -6090,11 +6062,52 @@ - Models/Props/Stones/MediumStone2.mesh + Models/Props/Stones/BigStone.mesh - - + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + @@ -6120,8 +6133,89 @@ Models/Props/Stones/SmallStone1.mesh - - + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + @@ -6133,8 +6227,210 @@ Models/Props/Stones/BigStone.mesh - - + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + @@ -6152,20 +6448,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - @@ -6180,20 +6462,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - @@ -6207,20 +6475,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - @@ -6235,19 +6489,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - @@ -6261,19 +6502,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - @@ -6287,19 +6515,6 @@ - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - @@ -6341,19 +6556,6 @@ - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - @@ -6366,19 +6568,6 @@ - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - @@ -6392,20 +6581,6 @@ - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - @@ -6420,19 +6595,6 @@ - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - @@ -6446,19 +6608,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - @@ -6472,19 +6621,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - @@ -6498,20 +6634,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - @@ -6526,20 +6648,6 @@ - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - @@ -6553,19 +6661,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - @@ -6579,19 +6674,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - @@ -6605,19 +6687,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - @@ -6631,19 +6700,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - @@ -6658,20 +6714,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - @@ -6686,20 +6728,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - @@ -6714,20 +6742,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - @@ -6769,20 +6783,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - @@ -6813,11 +6813,116 @@ + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + @@ -6850,7 +6955,7 @@ - + @@ -6892,7 +6997,7 @@ - + @@ -6934,7 +7039,7 @@ - + @@ -6976,49 +7081,7 @@ - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - + @@ -7060,7 +7123,7 @@ - + @@ -7102,7 +7165,7 @@ - + @@ -7119,6 +7182,20 @@ + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + @@ -7147,20 +7224,6 @@ - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - @@ -7203,74 +7266,79 @@ - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + @@ -7403,74 +7471,6 @@ - - - - - Models/Props/Bridges/SciFiBridge1Blue.mesh - - - - - - - - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridge1Blue.mesh - - - - - - - - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - - - - - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - @@ -7478,6 +7478,19 @@ + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + @@ -7504,19 +7517,6 @@ - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - @@ -7544,9 +7544,8 @@ Models/Props/Flora/SpecialRoot.mesh - - - + + @@ -7558,8 +7557,9 @@ Models/Props/Flora/SpecialRoot.mesh - - + + + @@ -7599,6 +7599,126 @@ + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + @@ -7613,6 +7733,34 @@ + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + @@ -7652,20 +7800,6 @@ - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - @@ -7706,20 +7840,6 @@ - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - @@ -7746,33 +7866,6 @@ - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - @@ -7801,33 +7894,6 @@ - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - @@ -7855,32 +7921,6 @@ - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - @@ -7907,32 +7947,6 @@ - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - @@ -7974,20 +7988,6 @@ - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - @@ -8010,19 +8010,6 @@ - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - @@ -8050,6 +8037,19 @@ + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + @@ -8142,6 +8142,48 @@ + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + @@ -8171,20 +8213,6 @@ - - - - - 6 - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - @@ -8228,20 +8256,6 @@ - - - - - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - - @@ -8286,20 +8300,6 @@ - - - - - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - - @@ -8349,6 +8349,189 @@ + + + + + + + + + + Schema/Entities/PlayerAssaultFallbackBlue.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + + + Schema/Entities/PlayerAssaultFallbackBlue.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + @@ -8360,17 +8543,20 @@ 10 - + - - 1 - - + + + 10 + + + + @@ -8380,11 +8566,21 @@ 10 - + + + + + 0.69999998807907104 + 1.6000000238418579 + + + + + @@ -8411,7 +8607,7 @@ - 1 + 0.40000000596046448 @@ -8419,18 +8615,6 @@ - - - - - 10 - - - - - - - @@ -8438,38 +8622,6 @@ - - - - - Models/Props/CapturePoint/CapturePointNeutral.mesh - - - - - - - - - - 3 - - - - Models/Core/UnitCylinder.mesh - - true - - - - - - - - - - - @@ -8507,6 +8659,75 @@ + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 15 + 2 + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 3 + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + @@ -8547,43 +8768,6 @@ - - - - - Models/Props/CapturePoint/CapturePointNeutral.mesh - - - - - - - - - - 15 - 2 - - - - Models/Core/UnitCylinder.mesh - - true - - - - - - - - - - - - - - - @@ -8625,189 +8809,6 @@ - - - - - - - - - - Schema/Entities/PlayerAssaultFallbackBlue.xml - - - - - - - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - - - - - Schema/Entities/PlayerAssaultFallbackBlue.xml - - - - - - - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - - From 984b8ad3e9a8b588bdecb5e46bb918c19b0113c6 Mon Sep 17 00:00:00 2001 From: Jocke Date: Thu, 3 Mar 2016 21:57:27 +0100 Subject: [PATCH 203/252] SprintEffect defaults to 30% extra speed. --- resources/Schema/Components/SprintAbility.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/Schema/Components/SprintAbility.xml b/resources/Schema/Components/SprintAbility.xml index 578c0017..d9727ed9 100644 --- a/resources/Schema/Components/SprintAbility.xml +++ b/resources/Schema/Components/SprintAbility.xml @@ -1,5 +1,5 @@ - 2.0 + 1.3 false \ No newline at end of file From ae13a2db6b8df273d1490f1ecf9bf6215b28a6c5 Mon Sep 17 00:00:00 2001 From: Jocke Date: Thu, 3 Mar 2016 22:09:51 +0100 Subject: [PATCH 204/252] Player cannot see their own sprint effect. --- src/Game/Systems/PlayerMovementSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 8d0ff990..ab4ac6a1 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -34,7 +34,7 @@ void PlayerMovementSystem::Update(double dt) return; } for (auto cSprint : *pool) { - if (/*cSprint.EntityID != LocalPlayer.ID && */(bool)cSprint["Active"]) { + if (cSprint.EntityID != LocalPlayer.ID && (bool)cSprint["Active"]) { // Spawn one afterimage for each player that sprints. EntityWrapper player(m_World, cSprint.EntityID); auto entityFile = ResourceManager::Load("Schema/Entities/SprintEffect.xml"); From c84d7ebb8fd118dcc4edc73a3e60b79ed83d4294 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 3 Mar 2016 22:25:07 +0100 Subject: [PATCH 205/252] PlayerAssaultFallbackBlue and PlayerAssaultFallbackRed --- resources/Schema/Entities/MovementTest.xml | 8 +- .../Entities/PlayerAssaultFallbackBlue.xml | 144 ++- .../Entities/PlayerAssaultFallbackRed.xml | 829 ++++++++++++++++++ resources/Schema/Entities/RayBlue.xml | 2 +- resources/Schema/Entities/RayRed.xml | 46 + ...aponView.xml => WeaponAssaultBlueView.xml} | 0 ...onWorld.xml => WeaponAssaultBlueWorld.xml} | 0 .../Schema/Entities/WeaponAssaultRedView.xml | 103 +++ .../Schema/Entities/WeaponAssaultRedWorld.xml | 34 + 9 files changed, 1154 insertions(+), 12 deletions(-) create mode 100644 resources/Schema/Entities/PlayerAssaultFallbackRed.xml create mode 100644 resources/Schema/Entities/RayRed.xml rename resources/Schema/Entities/{AssaultWeaponView.xml => WeaponAssaultBlueView.xml} (100%) mode change 100755 => 100644 rename resources/Schema/Entities/{AssaultWeaponWorld.xml => WeaponAssaultBlueWorld.xml} (100%) mode change 100755 => 100644 create mode 100644 resources/Schema/Entities/WeaponAssaultRedView.xml create mode 100644 resources/Schema/Entities/WeaponAssaultRedWorld.xml diff --git a/resources/Schema/Entities/MovementTest.xml b/resources/Schema/Entities/MovementTest.xml index 3429194a..7bbaf21d 100644 --- a/resources/Schema/Entities/MovementTest.xml +++ b/resources/Schema/Entities/MovementTest.xml @@ -10,7 +10,7 @@ - Schema/Entities/PlayerRed.xml + Schema/Entities/PlayerAssaultFallbackRed.xml @@ -78,7 +78,7 @@ - Schema/Entities/Player.xml + Schema/Entities/PlayerAssaultFallbackBlue.xml @@ -98,7 +98,7 @@ - + @@ -111,7 +111,7 @@ - + diff --git a/resources/Schema/Entities/PlayerAssaultFallbackBlue.xml b/resources/Schema/Entities/PlayerAssaultFallbackBlue.xml index d5d7579c..94177cee 100644 --- a/resources/Schema/Entities/PlayerAssaultFallbackBlue.xml +++ b/resources/Schema/Entities/PlayerAssaultFallbackBlue.xml @@ -169,7 +169,7 @@ - + @@ -493,7 +493,7 @@ Models/Characters/Assault/Test/FirstPerson.mesh - + @@ -507,14 +507,114 @@ AssaultWeapon - Schema/Entities/AssaultWeaponView.xml + Schema/Entities/WeaponAssaultBlueView.xml - + + + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + Schema/Entities/Weapons/RayBlue.xml + + + + + + + + + + + + Schema/Entities/ReloadEffectView.xml + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + + + + 32 + Fonts/DroidSans.ttf,64 + + + + Player + AssaultWeapon + MagazineAmmo + + + + + + + + + + + 320 + Fonts/DroidSans.ttf,64 + + + + Player + AssaultWeapon + Ammo + + + + + + + + + + + + + + + @@ -572,7 +672,6 @@ Models/Characters/Assault/AssaultBlue.mesh - false @@ -589,14 +688,45 @@ - Schema/Entities/AssaultWeaponWorld.xml + Schema/Entities/WeaponAssaultBlueWorld.xml - + + + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + Schema/Entities/Weapons/RayBlue.xml + + + + + + + + + + + Schema/Entities/ReloadEffectWorld.xml + + + + + + + + diff --git a/resources/Schema/Entities/PlayerAssaultFallbackRed.xml b/resources/Schema/Entities/PlayerAssaultFallbackRed.xml new file mode 100644 index 00000000..c16cb556 --- /dev/null +++ b/resources/Schema/Entities/PlayerAssaultFallbackRed.xml @@ -0,0 +1,829 @@ + + + + + + + + + + + + + + + + + + 5 + + + + + + + + + + + + + + + + + 0.10000000149011612 + 300 + + + + + + + + + + Models/Widgets/Camera.mesh + false + + + + + + + + + + + + + + + + + + + Textures/Weapons/Crosshair/SmallThickHoleDot.png + + false + + + + + + + + + + + + Schema/Entities/HitMarker.xml + + + + + + + + + + + + + + 1 + + + + + Textures/HealthHUD3.png + + + + + + + + + + + + + + + + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + 0.0 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + 1 + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 2 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 3 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 4 + + + 1 + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 1 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + 1 + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + Models/Widgets/Arrows/Arrow5.mesh + + + + + + + + + + + + + + + + + + + + Idle + 1.8348644854054612 + 1 + + + + + Models/Characters/Assault/Test/FirstPerson.mesh + + + + + + + + + R_Arm_Weapon_Joint + + + AssaultWeapon + + + Schema/Entities/WeaponAssaultRedView.xml + + + + + + + + + + + Models/Weapons/Red/AssaultWeaponRed.mesh + + + + + + + + Schema/Entities/Weapons/RayRed.xml + + + + + + + + + + + + Schema/Entities/ReloadEffectView.xml + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + + + + 32 + Fonts/DroidSans.ttf,64 + + + + Player + AssaultWeapon + MagazineAmmo + + + + + + + + + + + 320 + Fonts/DroidSans.ttf,64 + + + + Player + AssaultWeapon + Ammo + + + + + + + + + + + + + + + + + + + + R_Arm_Weapon_Joint + + + SidearmWeapon + + + Schema/Entities/SidearmWeaponView.xml + + + + + + + + + + + + + + + + 0.10000000149011612 + 300 + + + Models/Widgets/Camera.mesh + false + + + + + + + + + + + + IdleF + 1 + + + + + AimRifle + + + + + + Models/Characters/Assault/AssaultRed.mesh + + + + + + + + + R_Arm_Weapon_Joint + + + AssaultWeapon + + + + + + Schema/Entities/WeaponAssaultRedWorld.xml + + + + + + + + + + + Models/Weapons/Red/AssaultWeaponRed.mesh + + + + + + + + Schema/Entities/Weapons/RayRed.xml + + + + + + + + + + + Schema/Entities/ReloadEffectWorld.xml + + + + + + + + + + + + + R_Arm_Weapon_Joint + + + SidearmWeapon + + + + + + Schema/Entities/SidearmWeaponWorld.xml + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + false + + + + + + + + + + + + Models/Core/UnitCube.mesh + + false + + + + + + + + + + + Insert name here + Fonts/DroidSans.ttf,100 + + + + + + + + + + + + + + Textures/Icons/Arrow.png + + false + + + + + 50 + true + + + + + + + + + + + + Schema/Entities/DefenderShield.xml + + + + + + + + + + diff --git a/resources/Schema/Entities/RayBlue.xml b/resources/Schema/Entities/RayBlue.xml index 0ad0ddf0..83adbe51 100644 --- a/resources/Schema/Entities/RayBlue.xml +++ b/resources/Schema/Entities/RayBlue.xml @@ -1,5 +1,5 @@ - + diff --git a/resources/Schema/Entities/RayRed.xml b/resources/Schema/Entities/RayRed.xml new file mode 100644 index 00000000..70ab685e --- /dev/null +++ b/resources/Schema/Entities/RayRed.xml @@ -0,0 +1,46 @@ + + + + + + 0.10000000149011612 + + + + + + + + + + + Textures/Effects/Ray.png + + + + + + + + + + + + + + + Textures/Effects/Ray.png + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/AssaultWeaponView.xml b/resources/Schema/Entities/WeaponAssaultBlueView.xml old mode 100755 new mode 100644 similarity index 100% rename from resources/Schema/Entities/AssaultWeaponView.xml rename to resources/Schema/Entities/WeaponAssaultBlueView.xml diff --git a/resources/Schema/Entities/AssaultWeaponWorld.xml b/resources/Schema/Entities/WeaponAssaultBlueWorld.xml old mode 100755 new mode 100644 similarity index 100% rename from resources/Schema/Entities/AssaultWeaponWorld.xml rename to resources/Schema/Entities/WeaponAssaultBlueWorld.xml diff --git a/resources/Schema/Entities/WeaponAssaultRedView.xml b/resources/Schema/Entities/WeaponAssaultRedView.xml new file mode 100644 index 00000000..322b1439 --- /dev/null +++ b/resources/Schema/Entities/WeaponAssaultRedView.xml @@ -0,0 +1,103 @@ + + + + + + Models/Weapons/Red/AssaultWeaponRed.mesh + + + + + + + + + Schema/Entities/RayRed.xml + + + + + + + + + + + + Schema/Entities/ReloadEffectView.xml + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + + + + 32 + Fonts/DroidSans.ttf,64 + + + + Player + AssaultWeapon + MagazineAmmo + + + + + + + + + + + 320 + Fonts/DroidSans.ttf,64 + + + + Player + AssaultWeapon + Ammo + + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/WeaponAssaultRedWorld.xml b/resources/Schema/Entities/WeaponAssaultRedWorld.xml new file mode 100644 index 00000000..68d78d03 --- /dev/null +++ b/resources/Schema/Entities/WeaponAssaultRedWorld.xml @@ -0,0 +1,34 @@ + + + + + + Models/Weapons/Red/AssaultWeaponRed.mesh + + + + + + + + + Schema/Entities/RayRed.xml + + + + + + + + + + + Schema/Entities/ReloadEffectWorld.xml + + + + + + + + From 8466a282b791fd34f54d6960ac55ec7f50ebfd7e Mon Sep 17 00:00:00 2001 From: stiffly Date: Thu, 3 Mar 2016 22:48:42 +0100 Subject: [PATCH 206/252] The server will now parse a death event and pass it forward with a KillDeath event to the score system. --- include/Engine/Core/EPlayerDeath.h | 5 +++-- include/Engine/Network/EKillDeath.h | 19 +++++++++++++++++ include/Engine/Network/Server.h | 7 ++++++- src/Engine/Network/Server.cpp | 32 +++++++++++++++++++++++------ src/Game/Systems/HealthSystem.cpp | 21 ++++++++++--------- 5 files changed, 65 insertions(+), 19 deletions(-) create mode 100644 include/Engine/Network/EKillDeath.h diff --git a/include/Engine/Core/EPlayerDeath.h b/include/Engine/Core/EPlayerDeath.h index 363745a6..dca47205 100644 --- a/include/Engine/Core/EPlayerDeath.h +++ b/include/Engine/Core/EPlayerDeath.h @@ -10,8 +10,9 @@ namespace Events struct PlayerDeath : Event { //KilledBy,KilledByWhat is optional for now. It might be used later in the playerlog-system - EntityWrapper Player; - std::string KilledByWhat; + EntityWrapper Player = EntityWrapper::Invalid; + EntityWrapper Killer = EntityWrapper::Invalid; + std::string KilledByWhat = ""; }; } diff --git a/include/Engine/Network/EKillDeath.h b/include/Engine/Network/EKillDeath.h new file mode 100644 index 00000000..e53f3b8c --- /dev/null +++ b/include/Engine/Network/EKillDeath.h @@ -0,0 +1,19 @@ +#ifndef Events_KillDeath_h__ +#define Events_KillDeath_h__ + +#include "Core/EventBroker.h" + +typedef unsigned int PlayerID; + +namespace Events +{ + +struct KillDeath : public Event +{ + PlayerID Casualty = -1; + PlayerID Killer = -1; +}; + +} + +#endif \ No newline at end of file diff --git a/include/Engine/Network/Server.h b/include/Engine/Network/Server.h index 7bcefc65..6796aaf2 100644 --- a/include/Engine/Network/Server.h +++ b/include/Engine/Network/Server.h @@ -21,6 +21,8 @@ #include "Core/EEntityDeleted.h" #include "Core/EComponentDeleted.h" #include "Core/EAmmoPickup.h" +#include "Core/EPlayerDeath.h" +#include "Network/EKillDeath.h" class Server : public Network { @@ -77,7 +79,8 @@ private: void parseOnPlayerDamage(Packet& packet); void identifyPacketLoss(); void kick(PlayerID player); - PlayerID GetPlayerIDFromEndpoint(); + PlayerID getPlayerIDFromEndpoint(); + PlayerID getPlayerIDFromEntityID(); void parsePlayerTransform(Packet& packet); void parseOnInputCommand(Packet& packet); void parseClientPing(); @@ -103,6 +106,8 @@ private: bool OnPlayerDamage(const Events::PlayerDamage& e); EventRelay m_EAmmoPickup; bool OnAmmoPickup(const Events::AmmoPickup& e); + EventRelay m_EPlayerDeath; + bool OnPlayerDeath(const Events::PlayerDeath& e); }; #endif diff --git a/src/Engine/Network/Server.cpp b/src/Engine/Network/Server.cpp index 68c00fbe..ebb95109 100644 --- a/src/Engine/Network/Server.cpp +++ b/src/Engine/Network/Server.cpp @@ -14,6 +14,7 @@ Server::Server(World* world, EventBroker* eventBroker, int port) EVENT_SUBSCRIBE_MEMBER(m_EComponentDeleted, &Server::OnComponentDeleted); EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &Server::OnPlayerDamage); EVENT_SUBSCRIBE_MEMBER(m_EAmmoPickup, &Server::OnAmmoPickup); + EVENT_SUBSCRIBE_MEMBER(m_EPlayerDeath, &Server::OnPlayerDeath); // BindWW if (port == 0) { port = config->Get("Networking.Port", 27666); @@ -351,7 +352,7 @@ void Server::parseTCPConnect(Packet & packet) LOG_INFO("Parsing connections"); // Check if player is already connected // Ska vara till lagd i TCPServer receive - PlayerID playerID = GetPlayerIDFromEndpoint(); + PlayerID playerID = getPlayerIDFromEndpoint(); if (playerID == -1) { return; } @@ -526,10 +527,19 @@ bool Server::OnAmmoPickup(const Events::AmmoPickup & e) return true; } + +bool Server::OnPlayerDeath(const Events::PlayerDeath& e) +{ + Events::KillDeath eKD; + eKD.Casualty = getPlayerIDFromEntityID(e.Player.ID); + eKD.Killer = getPlayerIDFromEntityID(e.Killer.ID); + m_EventBroker->Publish(eKD); +} + void Server::parseClientPing() { LOG_INFO("%i: Parsing ping", m_PacketID); - PlayerID player = GetPlayerIDFromEndpoint(); + PlayerID player = getPlayerIDFromEndpoint(); if (player == -1) { return; } @@ -567,7 +577,7 @@ void Server::parseOnInputCommand(Packet& packet) { PlayerID player = -1; // Check which player it was who sent the message - player = GetPlayerIDFromEndpoint(); + player = getPlayerIDFromEndpoint(); if (player != -1) { while (packet.DataReadSize() < packet.Size()) { Events::InputCommand e; @@ -586,7 +596,7 @@ void Server::parseOnInputCommand(Packet& packet) void Server::parsePlayerTransform(Packet& packet) { - PlayerID playerID = GetPlayerIDFromEndpoint(); + PlayerID playerID = getPlayerIDFromEndpoint(); if (playerID == -1) { return; } @@ -635,7 +645,7 @@ bool Server::shouldSendToClient(EntityWrapper childEntity) || childEntity.HasComponent("AmmoPickup"); } -PlayerID Server::GetPlayerIDFromEndpoint() +PlayerID Server::getPlayerIDFromEndpoint() { // check both tcp and udp connection for (auto& kv : m_ConnectedPlayers) { @@ -647,4 +657,14 @@ PlayerID Server::GetPlayerIDFromEndpoint() } } return -1; -} \ No newline at end of file +} + +PlayerID Server::getPlayerIDFromEntityID(EntityID entityID) +{ + for (int i = 0; i < m_ConnectedPlayers.size(); ++i) { + if (entityID == m_ConnectedPlayers[i].EntityID) { + return i; + } + } + return -1; +} diff --git a/src/Game/Systems/HealthSystem.cpp b/src/Game/Systems/HealthSystem.cpp index b4ace6b9..9fa570c2 100644 --- a/src/Game/Systems/HealthSystem.cpp +++ b/src/Game/Systems/HealthSystem.cpp @@ -12,15 +12,7 @@ HealthSystem::HealthSystem(SystemParams params) } void HealthSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cHealth, double dt) -{ - double& health = cHealth["Health"]; - if (health <= 0.0) { - Events::PlayerDeath ePlayerDeath; - ePlayerDeath.Player = entity; - m_EventBroker->Publish(ePlayerDeath); - //Note: we will delete the entity in PlayerDeathSystem - } -} +{ } bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e) { @@ -35,7 +27,16 @@ bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e) if (playerBoostDefenderEntity.Valid()) { e.Damage -= (double)playerBoostDefenderEntity["BoostDefender"]["StrengthOfEffect"]; } - health -= e.Damage; + if (health > 0) { + health -= e.Damage; + if (health <= 0.0) { + Events::PlayerDeath ePlayerDeath; + ePlayerDeath.Player = e.Victim; + ePlayerDeath.Killer = e.Inflictor; + m_EventBroker->Publish(ePlayerDeath); + //Note: we will delete the entity in PlayerDeathSystem + } + } return true; } From 714665f0a303cdbf7d1f864a4b763f8a3e896700 Mon Sep 17 00:00:00 2001 From: stiffly Date: Thu, 3 Mar 2016 22:55:12 +0100 Subject: [PATCH 207/252] Updated the PlayerID getter in Server.cpp. --- src/Engine/Network/Server.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Engine/Network/Server.cpp b/src/Engine/Network/Server.cpp index ebb95109..207b10f7 100644 --- a/src/Engine/Network/Server.cpp +++ b/src/Engine/Network/Server.cpp @@ -661,9 +661,9 @@ PlayerID Server::getPlayerIDFromEndpoint() PlayerID Server::getPlayerIDFromEntityID(EntityID entityID) { - for (int i = 0; i < m_ConnectedPlayers.size(); ++i) { - if (entityID == m_ConnectedPlayers[i].EntityID) { - return i; + for(auto& kv : m_ConnectedPlayers) { + if (entityID == kv.second.EntityID) { + return kv.first; } } return -1; From 011aa53bc0879e5c080cedc9f341443f22dc9003 Mon Sep 17 00:00:00 2001 From: Tleety Date: Thu, 3 Mar 2016 22:55:18 +0100 Subject: [PATCH 208/252] ScoreScreen things --- resources/Schema/Entities/CP_Rocky.xml | 2870 ++++++++++------- resources/Schema/Entities/ScoreBoard_Blue.xml | 121 + resources/Schema/Entities/ScoreBoard_Main.xml | 68 + resources/Schema/Entities/ScoreBoard_Red.xml | 121 + resources/Schema/Entities/ScoreIdentity.xml | 47 +- 5 files changed, 2031 insertions(+), 1196 deletions(-) create mode 100644 resources/Schema/Entities/ScoreBoard_Blue.xml create mode 100644 resources/Schema/Entities/ScoreBoard_Main.xml create mode 100644 resources/Schema/Entities/ScoreBoard_Red.xml diff --git a/resources/Schema/Entities/CP_Rocky.xml b/resources/Schema/Entities/CP_Rocky.xml index a0ae548f..a9c4aaac 100644 --- a/resources/Schema/Entities/CP_Rocky.xml +++ b/resources/Schema/Entities/CP_Rocky.xml @@ -21,6 +21,19 @@ + + + + + Models/Props/Highground7.mesh + + + + + + + + @@ -29,6 +42,29 @@ + + + + + Models/Props/Walls/SciFiWallBig.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + true + + + + + @@ -59,29 +95,6 @@ - - - - - Models/Props/Walls/SciFiWallBig.mesh - - - - - - - - - - - - Models/Props/Walls/SciFiWallBig.mesh - true - - - - - @@ -112,96 +125,36 @@ + + + + + + Schema/Entities/ScoreBoard_Main.xml + + + + + + - + - - - - + - - - - Models/Core/UnitCube.mesh - - - - - - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - Models/Core/UnitCube.mesh - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -209,11 +162,593 @@ - + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + Schema/Entities/ScoreBoard_Blue.xml + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + ID + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Name + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + KD + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Kills + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Deaths + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + Schema/Entities/ScoreBoard_Red.xml + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + ID + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Name + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + KD + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Kills + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Deaths + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + + + + + Schema/Entities/ScoreBoard_Main.xml + + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + Schema/Entities/ScoreBoard_Blue.xml + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + ID + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Name + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + KD + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Kills + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Deaths + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + Schema/Entities/ScoreBoard_Red.xml + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + ID + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Name + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + KD + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Kills + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Deaths + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + @@ -284,19 +819,6 @@ - - - - - Models/Props/Highground7.mesh - - - - - - - - @@ -766,6 +1288,17 @@ + + + + + + + + + + + @@ -789,17 +1322,6 @@ - - - - - - - - - - - @@ -908,11 +1430,11 @@ 2 - + - + @@ -929,7 +1451,7 @@ - + @@ -955,11 +1477,11 @@ 2 - + - + @@ -976,7 +1498,7 @@ - + @@ -1002,11 +1524,11 @@ 2 - + - + @@ -1023,7 +1545,7 @@ - + @@ -1049,11 +1571,11 @@ 2 - + - + @@ -1070,7 +1592,7 @@ - + @@ -1096,11 +1618,11 @@ 2 - + - + @@ -1117,7 +1639,7 @@ - + @@ -1143,11 +1665,11 @@ 2 - + - + @@ -1164,7 +1686,7 @@ - + @@ -1190,11 +1712,11 @@ 2 - + - + @@ -1211,7 +1733,7 @@ - + @@ -2459,11 +2981,11 @@ 2 - + - + @@ -2480,7 +3002,7 @@ - + @@ -2506,11 +3028,11 @@ 2 - + - + @@ -2527,7 +3049,7 @@ - + @@ -2774,6 +3296,308 @@ + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + @@ -2794,20 +3618,6 @@ - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - @@ -2926,6 +3736,20 @@ + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + @@ -2969,94 +3793,6 @@ - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - @@ -3090,220 +3826,6 @@ - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - @@ -3333,65 +3855,12 @@ - Models/Props/Stones/MediumStone1.mesh + Models/Props/Stones/BigStone.mesh - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - + + + @@ -3403,34 +3872,7 @@ Models/Props/Stones/BigStone.mesh - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - + @@ -3448,165 +3890,6 @@ - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - @@ -3614,20 +3897,8 @@ Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - + + @@ -3635,12 +3906,11 @@ - Models/Props/Stones/SmallStone2.mesh + Models/Props/Stones/SmallStone1.mesh - - - + + @@ -3678,11 +3948,92 @@ - Models/Props/Stones/MediumStone1.mesh + Models/Props/Stones/SmallStone1.mesh - - + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + @@ -3694,8 +4045,114 @@ Models/Props/Stones/BigStone.mesh - - + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + @@ -3730,12 +4187,39 @@ - Models/Props/Stones/BigStone.mesh + Models/Props/Stones/SmallStone1.mesh - - - + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + @@ -3747,9 +4231,8 @@ Models/Props/Stones/MediumStone2.mesh - - - + + @@ -3758,11 +4241,50 @@ - Models/Props/Stones/SmallStone2.mesh + Models/Props/Stones/MediumStone1.mesh - - + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + @@ -3789,100 +4311,6 @@ - - - - - 5 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - @@ -3911,6 +4339,85 @@ + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + @@ -3930,10 +4437,11 @@ - 3 + 2 + 1 - + @@ -3954,17 +4462,31 @@ - 2 - 1 + 3 - + + + + + + 5 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + @@ -3973,9 +4495,9 @@ Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - + + + @@ -3987,100 +4509,6 @@ - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - 2 - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - 2 - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - @@ -4097,11 +4525,11 @@ 2 - + - + @@ -4118,54 +4546,7 @@ - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - 2 - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - + @@ -4191,11 +4572,11 @@ 2 - + - + @@ -4212,7 +4593,7 @@ - + @@ -4238,11 +4619,11 @@ 2 - + - + @@ -4259,7 +4640,101 @@ - + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + @@ -4285,11 +4760,11 @@ 2 - + - + @@ -4306,7 +4781,54 @@ - + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + @@ -4327,12 +4849,13 @@ - Models/Props/Pillars/StonePillar.mesh + 6 + Models/Props/Pillars/SciFiPillar1Blue.mesh - - - + + + @@ -4341,13 +4864,12 @@ - 6 - Models/Props/Pillars/SciFiPillar1Blue.mesh + Models/Props/Pillars/StonePillar.mesh - - - + + + @@ -4384,6 +4906,160 @@ + + + + + + + + + 10 + + + + + + + + + + + 1 + + + + + + + + + + 10 + + + + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + 0.40000000596046448 + + + + + + + + + + + + + + Schema/Entities/PlayerRed.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + @@ -4582,6 +5258,19 @@ + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + @@ -4608,19 +5297,6 @@ - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - @@ -4636,160 +5312,6 @@ - - - - - Schema/Entities/PlayerRed.xml - - - - - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - - - - - - - 1 - - - - - - - - - 10 - - - - - - - - - - - 10 - - - - - - - - - - - - 10 - - - - - - - - - - - 10 - - - - - - - - - - - 0.40000000596046448 - - - - - - - - - - - - 10 - - - - - - - - - diff --git a/resources/Schema/Entities/ScoreBoard_Blue.xml b/resources/Schema/Entities/ScoreBoard_Blue.xml new file mode 100644 index 00000000..6b1a7bdd --- /dev/null +++ b/resources/Schema/Entities/ScoreBoard_Blue.xml @@ -0,0 +1,121 @@ + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + ID + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Name + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + KD + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Kills + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Deaths + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/ScoreBoard_Main.xml b/resources/Schema/Entities/ScoreBoard_Main.xml new file mode 100644 index 00000000..565fb57b --- /dev/null +++ b/resources/Schema/Entities/ScoreBoard_Main.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/ScoreBoard_Red.xml b/resources/Schema/Entities/ScoreBoard_Red.xml new file mode 100644 index 00000000..7c69656b --- /dev/null +++ b/resources/Schema/Entities/ScoreBoard_Red.xml @@ -0,0 +1,121 @@ + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + ID + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Name + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + KD + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Kills + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Deaths + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/ScoreIdentity.xml b/resources/Schema/Entities/ScoreIdentity.xml index daf9d4eb..b2df3821 100644 --- a/resources/Schema/Entities/ScoreIdentity.xml +++ b/resources/Schema/Entities/ScoreIdentity.xml @@ -14,6 +14,9 @@ -1 Fonts/DroidSans.ttf,64 + + + ScoreIdentity @@ -21,7 +24,8 @@ ID - + + @@ -31,6 +35,9 @@ Fonts/DroidSans.ttf,64 + + + ScoreIdentity @@ -38,7 +45,8 @@ Name - + + @@ -48,6 +56,9 @@ 0 Fonts/DroidSans.ttf,64 + + + ScoreIdentity @@ -55,7 +66,8 @@ KD - + + @@ -65,6 +77,9 @@ 0 Fonts/DroidSans.ttf,64 + + + ScoreIdentity @@ -72,7 +87,8 @@ Kills - + + @@ -82,6 +98,9 @@ 0 Fonts/DroidSans.ttf,64 + + + ScoreIdentity @@ -89,24 +108,8 @@ Deaths - - - - - - - - - 0 - Fonts/DroidSans.ttf,64 - - - ScoreIdentity - ScoreIdentity - Ping - - - + + From 217c3fe55cf8088c978a5ce16844b3f881656e3f Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 3 Mar 2016 22:58:45 +0100 Subject: [PATCH 209/252] Fixes --- resources/DefaultConfig.ini | 2 +- .../Entities/{Maps => }/CP_RockHard.xml | 6748 +++++++++-------- .../Entities/PlayerAssaultFallbackBlue.xml | 135 +- .../Entities/PlayerAssaultFallbackRed.xml | 135 +- src/Game/Game.cpp | 2 +- 5 files changed, 3536 insertions(+), 3486 deletions(-) rename resources/Schema/Entities/{Maps => }/CP_RockHard.xml (95%) diff --git a/resources/DefaultConfig.ini b/resources/DefaultConfig.ini index fd468fd6..92e7bad3 100644 --- a/resources/DefaultConfig.ini +++ b/resources/DefaultConfig.ini @@ -75,7 +75,7 @@ NumIterations=9 TextureQuality=0 [GLOW] -Quality=3; +Quality=3 [GLOW1] NumIterations=5 diff --git a/resources/Schema/Entities/Maps/CP_RockHard.xml b/resources/Schema/Entities/CP_RockHard.xml similarity index 95% rename from resources/Schema/Entities/Maps/CP_RockHard.xml rename to resources/Schema/Entities/CP_RockHard.xml index 4f104155..2231df59 100644 --- a/resources/Schema/Entities/Maps/CP_RockHard.xml +++ b/resources/Schema/Entities/CP_RockHard.xml @@ -2,6 +2,10 @@ + + 1.2059834585982117 + 4 + @@ -30,28 +34,6 @@ - - - - - Models/Props/Walls/SciFiWallSmall2.mesh - - - - - - - - - - Models/Props/Walls/SciFiWallBig.mesh - - - - - - - @@ -83,6 +65,28 @@ + + + + + Models/Props/Walls/SciFiWallSmall2.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + + + + + + + @@ -704,6 +708,44 @@ + + + + + Models/Highgrounds/Hg18.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg20.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg6.mesh + + + + + + + @@ -753,44 +795,6 @@ - - - - - Models/Highgrounds/Hg18.mesh - - - - - - - - - - - - - Models/Highgrounds/Hg20.mesh - - - - - - - - - - - - - Models/Highgrounds/Hg6.mesh - - - - - - - @@ -1926,6 +1930,68 @@ + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + @@ -2691,6 +2757,25 @@ + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + @@ -2728,7 +2813,7 @@ - + @@ -2770,7 +2855,7 @@ - + @@ -2812,7 +2897,7 @@ - + @@ -2854,7 +2939,7 @@ - + @@ -2896,7 +2981,7 @@ - + @@ -2938,7 +3023,7 @@ - + @@ -2980,7 +3065,7 @@ - + @@ -3022,7 +3107,7 @@ - + @@ -3064,7 +3149,7 @@ - + @@ -3076,73 +3161,24 @@ - - - - - - - - - - Models/Props/Flora/SpecialRoot.mesh - - - - - - - - - - - - - - Models/Props/Flora/SpecialRoot.mesh - - - - - - - - - - - - - - Models/Props/Flora/SpecialRoot.mesh - - - - - - - - - - - - - Models/Props/Flora/SpecialRoot.mesh - - - - - - - - - - - + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + @@ -3169,91 +3205,6 @@ - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - @@ -3261,32 +3212,6 @@ - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - @@ -3294,8 +3219,8 @@ Models/Props/Stones/SmallStone1.mesh - - + + @@ -3317,11 +3242,12 @@ - Models/Props/Stones/SmallStone2.mesh + Models/Props/Stones/mediumStone2.mesh - - + + + @@ -3333,48 +3259,8 @@ Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - + + @@ -3387,21 +3273,8 @@ Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - + + @@ -3420,102 +3293,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - @@ -3534,84 +3311,16 @@ - Models/Props/Stones/mediumStone2.mesh + Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - + + - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - @@ -3619,7 +3328,9 @@ Models/Props/Stones/BigStone.mesh - + + + @@ -3628,11 +3339,11 @@ - Models/Props/Stones/MediumStone2.mesh + Models/Props/Stones/SmallStone2.mesh - - + + @@ -3658,8 +3369,265 @@ Models/Props/Stones/MediumStone2.mesh - - + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + @@ -3677,6 +3645,219 @@ + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + @@ -3704,220 +3885,6 @@ - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - @@ -3946,33 +3913,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - @@ -3980,128 +3920,7 @@ Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - + @@ -4120,48 +3939,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - @@ -4176,47 +3953,6 @@ - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - @@ -4231,6 +3967,20 @@ + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + @@ -4238,9 +3988,8 @@ Models/Props/Stones/SmallStone2.mesh - - - + + @@ -4252,8 +4001,129 @@ Models/Props/Stones/mediumStone2.mesh - - + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + @@ -4263,18 +4133,114 @@ - Models/Props/Stones/mediumStone2.mesh + Models/Props/Stones/MediumStone2.mesh - - + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + - + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + @@ -4283,26 +4249,11 @@ - Models/Props/Walls/SpecialWall1.mesh + Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - + - @@ -4311,12 +4262,11 @@ - Models/Props/Walls/SpecialWall1.mesh + Models/Props/SciFiHolder1.mesh - - - + + @@ -4325,31 +4275,37 @@ - Models/Props/Walls/SpecialWall1.mesh + Models/Props/SciFiHolder1.mesh - - - + + - - - - - - - - Models/Props/Pillars/StonePillar.mesh + Models/Props/SciFiHolder1.mesh - + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + @@ -4368,21 +4324,7 @@ Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - + @@ -4395,8 +4337,35 @@ Models/Props/Walls/MediumWall3.mesh - - + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + @@ -4414,6 +4383,19 @@ + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + @@ -4421,13 +4403,121 @@ Models/Props/Walls/SmallWall3.mesh - + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + @@ -4441,6 +4531,115 @@ + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + @@ -4480,19 +4679,6 @@ - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - @@ -4507,19 +4693,6 @@ - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - @@ -4533,74 +4706,6 @@ - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - @@ -4615,101 +4720,6 @@ - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - @@ -4723,15 +4733,23 @@ + + + + + + + - Models/Props/Walls/MediumWall3.mesh + Models/Props/Walls/SpecialWall1.mesh - - + + + @@ -4740,11 +4758,12 @@ - Models/Props/Walls/MediumWall3.mesh + Models/Props/Walls/SpecialWall1.mesh - - + + + @@ -4753,12 +4772,12 @@ - Models/Props/Walls/SmallWall3.mesh + Models/Props/Walls/SpecialWall1.mesh - - - + + + @@ -4767,33 +4786,18 @@ - Models/Props/Walls/SmallWall3.mesh + Models/Props/Walls/SpecialWall1.mesh - - - + + + - - - - Models/Core/UnitPlane.mesh - - true - - - - - - - - - @@ -4813,61 +4817,8 @@ Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - + + @@ -4893,22 +4844,8 @@ Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - + + @@ -4933,8 +4870,9 @@ Models/Props/Stones/AssaultHolder.mesh - - + + + @@ -4946,9 +4884,8 @@ Models/Props/Stones/AssaultHolder.mesh - - - + + @@ -4974,8 +4911,8 @@ Models/Props/Stones/AssaultHolder.mesh - - + + @@ -4987,21 +4924,8 @@ Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - + + @@ -5027,8 +4951,8 @@ Models/Props/Stones/AssaultHolder.mesh - - + + @@ -5040,31 +4964,8 @@ Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - + + @@ -5073,107 +4974,82 @@ - 6 - Models/Props/Stones/ShinyStoneCrystalRed.mesh + Models/Props/Stones/AssaultHolder.mesh - - + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + - - - - - - - + - Models/Props/PickUps/PickUpHolder.mesh + Models/Props/Stones/AssaultHolder.mesh - - - + + - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - + + - Models/Props/PickUps/PickUpHolder.mesh + Models/Props/Stones/AssaultHolder.mesh - - - + + + - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + @@ -5208,88 +5084,6 @@ - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - @@ -5331,6 +5125,216 @@ + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + @@ -5338,6 +5342,34 @@ + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + @@ -5355,25 +5387,11 @@ - Models/Props/Stones/SmallStone2.mesh + Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - + + @@ -5398,8 +5416,8 @@ Models/Props/Stones/SmallStone1.mesh - - + + @@ -5408,11 +5426,11 @@ - Models/Props/Stones/mediumStone2.mesh + Models/Props/Stones/BigStone.mesh - - + + @@ -5434,11 +5452,11 @@ - Models/Props/Stones/SmallStone1.mesh + Models/Props/Stones/mediumStone2.mesh - - + + @@ -5450,35 +5468,8 @@ Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - + + @@ -5501,11 +5492,11 @@ - Models/Props/Stones/MediumStone2.mesh + Models/Props/Stones/SmallStone1.mesh - - + + @@ -5517,105 +5508,8 @@ Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - + + @@ -5638,11 +5532,25 @@ - Models/Props/Stones/SmallStone1.mesh + Models/Props/Stones/MediumStone2.mesh - - + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + @@ -5660,6 +5568,102 @@ + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + @@ -5676,6 +5680,189 @@ + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 5 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + @@ -5746,189 +5933,6 @@ - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - 2 - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - - - - - - - - - - - 2 - - - - - - - - - - - - - - - - - - - - - - - - - 5 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - @@ -5958,9 +5962,8 @@ Models/Props/Stones/SmallStone1.mesh - - - + + @@ -5982,11 +5985,12 @@ - Models/Props/Stones/MediumStone2.mesh + Models/Props/Stones/SmallStone1.mesh - - + + + @@ -5995,11 +5999,11 @@ - Models/Props/Stones/BigStone.mesh + Models/Props/Stones/MediumStone2.mesh - - + + @@ -6031,195 +6035,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - @@ -6253,8 +6068,62 @@ Models/Props/Stones/SmallStone1.mesh - - + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + @@ -6267,8 +6136,344 @@ Models/Props/Stones/SmallStone2.mesh - - + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + @@ -6287,101 +6492,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - @@ -6403,8 +6513,8 @@ Models/Props/Stones/SmallStone2.mesh - - + + @@ -6413,11 +6523,11 @@ - Models/Props/Stones/MediumStone2.mesh + Models/Props/Stones/BigStone.mesh - - + + @@ -6429,8 +6539,9 @@ Models/Props/Stones/SmallStone1.mesh - - + + + @@ -6442,8 +6553,49 @@ Models/Props/Stones/SmallStone2.mesh - - + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + @@ -6462,33 +6614,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - @@ -6496,8 +6621,21 @@ Models/Props/Stones/SmallStone2.mesh - - + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + @@ -6509,8 +6647,60 @@ Models/Props/Stones/MediumStone2.mesh - - + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + @@ -6556,98 +6746,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - @@ -6661,45 +6759,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - @@ -6714,20 +6773,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - @@ -6742,47 +6787,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - @@ -6813,158 +6817,11 @@ - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - @@ -6997,7 +6854,7 @@ - + @@ -7039,7 +6896,7 @@ - + @@ -7055,8 +6912,8 @@ Models/Props/PickUps/PickUpHolder.mesh - - + + @@ -7064,24 +6921,24 @@ - + - + 8 - Models/Props/PickUps/HealthPickUp.mesh + Models/Props/PickUps/AmmoPickUp.mesh - + @@ -7123,7 +6980,91 @@ - + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + @@ -7165,7 +7106,7 @@ - + @@ -7177,6 +7118,69 @@ + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + @@ -7189,37 +7193,7 @@ Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - - - - - - 6 - Models/Props/Pillars/SciFiPillar1Blue.mesh - - - - - + @@ -7242,10 +7216,12 @@ - Models/Props/Pillars/StonePillar.mesh + Models/Props/Pillars/SciFiPillar2Blue.mesh - + + + @@ -7257,9 +7233,37 @@ Models/Props/Pillars/SciFiPillar2Blue.mesh - - - + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + @@ -7283,19 +7287,6 @@ - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - @@ -7323,6 +7314,19 @@ + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + @@ -7544,8 +7548,9 @@ Models/Props/Flora/SpecialRoot.mesh - - + + + @@ -7557,9 +7562,8 @@ Models/Props/Flora/SpecialRoot.mesh - - - + + @@ -7606,13 +7610,187 @@ Models/Props/Walls/SmallWall3.mesh - - + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + @@ -7626,6 +7804,128 @@ + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + @@ -7652,181 +7952,6 @@ - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - @@ -7840,60 +7965,6 @@ - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - @@ -7908,32 +7979,6 @@ - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - @@ -7947,47 +7992,6 @@ - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - @@ -8150,8 +8154,9 @@ Models/Props/Pillars/SciFiPillar2Blue.mesh - - + + + @@ -8170,92 +8175,6 @@ - - - - - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - - - - - - - 4 - Models/Props/Pillars/SciFiPillar3Blue.mesh - - - - - - - - - - - - - - 6 - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - - - - - - 6 - Models/Props/Pillars/SciFiPillar1Blue.mesh - - - - - - - - - - - - - 4 - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - - - - - - - 6 - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - @@ -8279,9 +8198,8 @@ Models/Props/Pillars/SciFiPillar2Blue.mesh - - - + + @@ -8294,8 +8212,94 @@ Models/Props/Pillars/SciFiPillar2Blue.mesh - - + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar3Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + @@ -8349,189 +8353,6 @@ - - - - - - - - - - Schema/Entities/PlayerAssaultFallbackBlue.xml - - - - - - - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - - - - - Schema/Entities/PlayerAssaultFallbackBlue.xml - - - - - - - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - - - - - @@ -8560,13 +8381,13 @@ - + - - 10 - + + 0.40000000596046448 + - + @@ -8581,6 +8402,17 @@ + + + + 10 + + + + + + + @@ -8604,17 +8436,6 @@ - - - - 0.40000000596046448 - - - - - - - @@ -8622,43 +8443,6 @@ - - - - - Models/Props/CapturePoint/CapturePointNeutral.mesh - - - - - - - - - - 15 - 1 - - - - Models/Core/UnitCylinder.mesh - - true - - - - - - - - - - - - - - - @@ -8696,38 +8480,6 @@ - - - - - Models/Props/CapturePoint/CapturePointNeutral.mesh - - - - - - - - - - 3 - - - - Models/Core/UnitCylinder.mesh - - true - - - - - - - - - - - @@ -8768,6 +8520,75 @@ + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 15 + 1 + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 3 + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + @@ -8809,6 +8630,497 @@ + + + + + + + + + + Schema/Entities/PlayerAssaultFallbackBlue.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + + + Schema/Entities/PlayerAssaultFallbackRed.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + + + + + + + + + 0.049999997019767761 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 2 + + + 1 + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 3 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 4 + + + 1 + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 1 + + + 1 + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + 1 + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + + + 3 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + PickClass + 2 + + + + + + + + + + + + + Textures/Core/UnitRaptor.png + + + + PickClass + 1 + + + + + + + + + + + + + Textures/Test/aM4ME4GR.png + + + + PickClass + 3 + + + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/PlayerAssaultFallbackBlue.xml b/resources/Schema/Entities/PlayerAssaultFallbackBlue.xml index 94177cee..9650cfe8 100644 --- a/resources/Schema/Entities/PlayerAssaultFallbackBlue.xml +++ b/resources/Schema/Entities/PlayerAssaultFallbackBlue.xml @@ -514,107 +514,7 @@ - - - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - - - - - - - - Schema/Entities/Weapons/RayBlue.xml - - - - - - - - - - - - Schema/Entities/ReloadEffectView.xml - - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - - - - - - 32 - Fonts/DroidSans.ttf,64 - - - - Player - AssaultWeapon - MagazineAmmo - - - - - - - - - - - 320 - Fonts/DroidSans.ttf,64 - - - - Player - AssaultWeapon - Ammo - - - - - - - - - - - - - - - + @@ -695,38 +595,7 @@ - - - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - - - - - - - - Schema/Entities/Weapons/RayBlue.xml - - - - - - - - - - - Schema/Entities/ReloadEffectWorld.xml - - - - - - - - + diff --git a/resources/Schema/Entities/PlayerAssaultFallbackRed.xml b/resources/Schema/Entities/PlayerAssaultFallbackRed.xml index c16cb556..a32988c7 100644 --- a/resources/Schema/Entities/PlayerAssaultFallbackRed.xml +++ b/resources/Schema/Entities/PlayerAssaultFallbackRed.xml @@ -514,107 +514,7 @@ - - - - - Models/Weapons/Red/AssaultWeaponRed.mesh - - - - - - - - Schema/Entities/Weapons/RayRed.xml - - - - - - - - - - - - Schema/Entities/ReloadEffectView.xml - - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - - - - - - 32 - Fonts/DroidSans.ttf,64 - - - - Player - AssaultWeapon - MagazineAmmo - - - - - - - - - - - 320 - Fonts/DroidSans.ttf,64 - - - - Player - AssaultWeapon - Ammo - - - - - - - - - - - - - - - + @@ -695,38 +595,7 @@ - - - - - Models/Weapons/Red/AssaultWeaponRed.mesh - - - - - - - - Schema/Entities/Weapons/RayRed.xml - - - - - - - - - - - Schema/Entities/ReloadEffectWorld.xml - - - - - - - - + diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 0629fbd5..18e6fd5c 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -111,7 +111,7 @@ Game::Game(int argc, char* argv[]) // Create Octrees // TODO: Perhaps the world bounds should be set in some non-arbitrary way instead of this. - AABB boxContainingTheWorld(glm::vec3(-300), glm::vec3(300)); + AABB boxContainingTheWorld = AABB::FromOriginSize(glm::vec3(0.f, 10.7f, 0.f), glm::vec3(140.f, 31.f, 190.f)); m_OctreeCollision = new Octree(boxContainingTheWorld, 4); m_OctreeTrigger = new Octree(boxContainingTheWorld, 4); m_OctreeFrustrumCulling = new Octree(boxContainingTheWorld, 4); From e3fbd2082c18f6e761b9f7c1d211d4e0924312da Mon Sep 17 00:00:00 2001 From: viktorljung Date: Thu, 3 Mar 2016 23:20:13 +0100 Subject: [PATCH 210/252] BlendQueues fully working --- include/Engine/Rendering/BlendTree.h | 3 +- .../Engine/Rendering/EAutoAnimationBlend.h | 1 + resources/Schema/Components/Blend.xml | 1 + resources/Schema/Components/Blend.xsd | 1 + resources/Schema/Entities/BlendTreeTest.xml | 39 ++++--- src/Engine/Rendering/AnimationSystem.cpp | 101 ++++++++++-------- src/Engine/Rendering/AutoBlendQueue.cpp | 9 +- src/Engine/Rendering/BlendTree.cpp | 10 +- 8 files changed, 99 insertions(+), 66 deletions(-) diff --git a/include/Engine/Rendering/BlendTree.h b/include/Engine/Rendering/BlendTree.h index 2c5f1aa8..aa06f1e6 100644 --- a/include/Engine/Rendering/BlendTree.h +++ b/include/Engine/Rendering/BlendTree.h @@ -29,7 +29,7 @@ public: Node* Child[2] = { nullptr, nullptr }; NodeType Type; std::map Pose; - //std::vector Pose; + bool SubTreeRoot = false; double Weight = 0.0; Node* Next() { @@ -61,6 +61,7 @@ public: std::string NodeName; double progress; bool Start; + bool SingleBlend; std::unordered_map StartWeights; }; diff --git a/include/Engine/Rendering/EAutoAnimationBlend.h b/include/Engine/Rendering/EAutoAnimationBlend.h index 08c49191..ebd29848 100644 --- a/include/Engine/Rendering/EAutoAnimationBlend.h +++ b/include/Engine/Rendering/EAutoAnimationBlend.h @@ -17,6 +17,7 @@ struct AutoAnimationBlend : Event bool Start = false; bool Reverse = false; bool Restart = false; + bool SingleLevelBlend = false; EntityWrapper AnimationEntity = EntityWrapper::Invalid; }; diff --git a/resources/Schema/Components/Blend.xml b/resources/Schema/Components/Blend.xml index f949a102..a4a328ca 100644 --- a/resources/Schema/Components/Blend.xml +++ b/resources/Schema/Components/Blend.xml @@ -3,4 +3,5 @@ 0.5 + false \ No newline at end of file diff --git a/resources/Schema/Components/Blend.xsd b/resources/Schema/Components/Blend.xsd index 95fc8f49..34d32385 100644 --- a/resources/Schema/Components/Blend.xsd +++ b/resources/Schema/Components/Blend.xsd @@ -8,6 +8,7 @@ + diff --git a/resources/Schema/Entities/BlendTreeTest.xml b/resources/Schema/Entities/BlendTreeTest.xml index d2c7ead9..a3188348 100644 --- a/resources/Schema/Entities/BlendTreeTest.xml +++ b/resources/Schema/Entities/BlendTreeTest.xml @@ -68,8 +68,8 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - + + @@ -81,15 +81,16 @@ AimPrimary AimSecondary 0 + true - + - AimSecWepA - + AimRifleA + false true @@ -97,11 +98,11 @@ - + - AimRifleA - + AimSecWepA + false true @@ -125,7 +126,8 @@ StandCrouchBlend JumpDashBlend - 1.055110346338068e-57 + 2.5146881298480398e-63 + true @@ -135,7 +137,8 @@ StandMovement CrouchMovement - 0.0069837930620454403 + 0.012867419418159054 + true @@ -174,7 +177,7 @@ WalkF - + 1 true @@ -186,7 +189,7 @@ RunF - + 1 true @@ -210,7 +213,7 @@ StrafeLeftF - + 1 true @@ -222,7 +225,7 @@ StrafeRightF - + 1 true @@ -281,7 +284,7 @@ CrouchStrafeLeftF - + 1 true @@ -293,7 +296,7 @@ CrouchStrafeRightF - + 1 true @@ -307,7 +310,7 @@ CrouchWalkF - + 1 true @@ -338,6 +341,7 @@ Jump DashBlend 1 + true @@ -448,6 +452,7 @@ ReloadSwitch WeaponActionBlend 1 + true diff --git a/src/Engine/Rendering/AnimationSystem.cpp b/src/Engine/Rendering/AnimationSystem.cpp index 4434e80b..5c048fed 100644 --- a/src/Engine/Rendering/AnimationSystem.cpp +++ b/src/Engine/Rendering/AnimationSystem.cpp @@ -148,11 +148,11 @@ void AnimationSystem::UpdateWeights(double dt) bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e) { - if(!e.RootNode.Valid()) { + if (!e.RootNode.Valid()) { return false; } - if(!e.RootNode.HasComponent("Model")) { + if (!e.RootNode.HasComponent("Model")) { return false; } @@ -179,7 +179,7 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e) EntityWrapper subTreeRoot = blendTree->GetSubTreeRoot(e.NodeName); - if(!subTreeRoot.Valid()) { + if (!subTreeRoot.Valid()) { return false; } @@ -193,16 +193,18 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e) abj.BlendInfo.NodeName = e.NodeName; abj.BlendInfo.progress = 0.0; abj.BlendInfo.Start = e.Start; + abj.BlendInfo.SingleBlend = e.SingleLevelBlend; - if (e.Restart) { - EntityWrapper nodeEntity = subTreeRoot.FirstChildByName(e.NodeName); - if (nodeEntity.Valid()) { - if (nodeEntity.HasComponent("Animation")) { - const Skeleton::Animation* animation = skeleton->GetAnimation(nodeEntity["Animation"]["AnimationName"]); + EntityWrapper nodeEntity = subTreeRoot.FirstChildByName(e.NodeName); // more than one + if (nodeEntity.Valid()) { + if (nodeEntity.HasComponent("Animation")) { + const Skeleton::Animation* animation = skeleton->GetAnimation(nodeEntity["Animation"]["AnimationName"]); + (bool&)nodeEntity["Animation"]["Reverse"] = e.Reverse; + + if (e.Restart) { if (animation != nullptr) { if (e.Restart) { - (bool&)nodeEntity["Animation"]["Reverse"] = e.Reverse; if (e.Reverse) { (double&)nodeEntity["Animation"]["Time"] = animation->Duration; } else { @@ -439,27 +441,7 @@ bool AnimationSystem::OnInputCommand(const Events::InputCommand& e) aeb.RootNode = entity; aeb.Start = true; aeb.Restart = true; - m_EventBroker->Publish(aeb); - } - } - } - } else if (e.Command == "Stand") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; - aeb.NodeName = "StandMovement"; - aeb.RootNode = entity; - aeb.Start = true; - aeb.Restart = true; + aeb.SingleLevelBlend = true; m_EventBroker->Publish(aeb); } } @@ -526,27 +508,15 @@ bool AnimationSystem::OnInputCommand(const Events::InputCommand& e) EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); if (entity.Name() == "Assault") { - /* { + { Events::AutoAnimationBlend aeb; aeb.Duration = 0.1; aeb.NodeName = "Right"; aeb.RootNode = entity; aeb.Start = true; m_EventBroker->Publish(aeb); - }*/ - - - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; - aeb.NodeName = "Right"; - aeb.RootNode = entity; - aeb.Start = true; - aeb.Restart = false; - aeb.AnimationEntity = entity.FirstChildByName("DashRight"); - aeb.Delay = -0.3; - m_EventBroker->Publish(aeb); } + } } } else if (e.Command == "ForwardTest") { @@ -570,8 +540,51 @@ bool AnimationSystem::OnInputCommand(const Events::InputCommand& e) } } } + } else if (e.Command == "BackwardTest") { + auto blendComponents = m_World->GetComponents("BlendAdditive"); + if (blendComponents == nullptr) { + return false; + } + for (auto& bc : *blendComponents) { + EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); + if (entity.Name() == "Assault") { + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.1; + aeb.NodeName = "Walk"; + aeb.RootNode = entity; + aeb.Start = true; + aeb.Reverse = true; + m_EventBroker->Publish(aeb); + } + } + } + } else if (e.Value == 0.f) { + if (e.Command == "Crouch") { + auto blendComponents = m_World->GetComponents("BlendAdditive"); + + if (blendComponents == nullptr) { + return false; + } + for (auto& bc : *blendComponents) { + EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); + + if (entity.Name() == "Assault") { + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.3; + aeb.NodeName = "StandMovement"; + aeb.RootNode = entity; + aeb.Start = true; + aeb.Restart = true; + aeb.SingleLevelBlend = true; + m_EventBroker->Publish(aeb); + } + } + } + } } } diff --git a/src/Engine/Rendering/AutoBlendQueue.cpp b/src/Engine/Rendering/AutoBlendQueue.cpp index e75e33b5..7ea79383 100644 --- a/src/Engine/Rendering/AutoBlendQueue.cpp +++ b/src/Engine/Rendering/AutoBlendQueue.cpp @@ -54,6 +54,11 @@ void AutoBlendQueue::Insert(AutoBlendJob autoBlendJob) for (auto it = m_BlendQueue.begin(); it != m_BlendQueue.end(); it++) { auto next = std::next(it, 1); + + if (it->BlendJob.BlendInfo.NodeName == autoBlendJob.BlendInfo.NodeName) { + (*it) = blendNode; + } + if (next != m_BlendQueue.end()) { if (it->StartTime >= blendNode.StartTime && next->StartTime <= blendNode.StartTime) { LOG_INFO("Inserted %s between %s and %s", blendNode.BlendJob.BlendInfo.NodeName.c_str(), it->BlendJob.BlendInfo.NodeName.c_str(), next->BlendJob.BlendInfo.NodeName.c_str()); @@ -83,11 +88,11 @@ void AutoBlendQueue::Insert(AutoBlendJob autoBlendJob) void AutoBlendQueue::UpdateTime(double dt) { for (auto it = m_BlendQueue.begin(); it != m_BlendQueue.end();) { - it->EndTime -= dt; - it->StartTime -= dt; if (it->EndTime <= 0) { it = m_BlendQueue.erase(it); } else { + it->EndTime -= dt; + it->StartTime -= dt; it++; } } diff --git a/src/Engine/Rendering/BlendTree.cpp b/src/Engine/Rendering/BlendTree.cpp index 2f74b45e..60858f2a 100644 --- a/src/Engine/Rendering/BlendTree.cpp +++ b/src/Engine/Rendering/BlendTree.cpp @@ -27,6 +27,7 @@ BlendTree::BlendTree(EntityWrapper ModelEntity, Skeleton* skeleton) m_Root->Parent = nullptr; m_Root->Type = NodeType::Blend; m_Root->Weight = (double)ModelEntity["Blend"]["Weight"]; + m_Root->SubTreeRoot = (bool)ModelEntity["Blend"]["SubTreeRoot"]; (double&)ModelEntity["Blend"]["Weight"] = glm::clamp((double)ModelEntity["Blend"]["Weight"], 0.0, 1.0); m_Root->Child[0] = FillTreeByName(m_Root, (std::string)ModelEntity["Blend"]["Pose1"], ModelEntity); m_Root->Child[1] = FillTreeByName(m_Root, (std::string)ModelEntity["Blend"]["Pose2"], ModelEntity); @@ -132,6 +133,7 @@ BlendTree::Node* BlendTree::FillTreeByName(Node* parentNode, std::string name, E node->Type = NodeType::Blend; (double&)childEntity["Blend"]["Weight"] = glm::clamp((double)childEntity["Blend"]["Weight"], 0.0, 1.0); node->Weight = (double)childEntity["Blend"]["Weight"]; + node->SubTreeRoot = (bool)childEntity["Blend"]["SubTreeRoot"]; //if (node->Weight < 1.f && node->Weight > 0.f) { node->Child[0] = FillTreeByName(node, (std::string)childEntity["Blend"]["Pose1"], childEntity); node->Child[1] = FillTreeByName(node, (std::string)childEntity["Blend"]["Pose2"], childEntity); @@ -251,6 +253,10 @@ BlendTree::AutoBlendInfo BlendTree::AutoBlendStep(AutoBlendInfo blendInfo) lastNode = currentNode; currentNode = currentNode->Parent; + + if (blendInfo.SingleBlend) { + break; + } } } else if(goalNodes.size() >= 2) { std::vector sharedParents; @@ -380,8 +386,8 @@ EntityWrapper BlendTree::GetSubTreeRoot(std::string nodeName) std::vector subTreeRoots; for (auto it = nodes.begin(); it != nodes.end(); it++) { - Node* currentNode = (*it); - while (currentNode->Parent->Type == NodeType::Blend) { + Node* currentNode = (*it)->Parent; + while (!currentNode->SubTreeRoot) { currentNode = currentNode->Parent; } subTreeRoots.push_back(currentNode); From bebdacabb4ee15da79b33ac3ea7c57f256c49751 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Thu, 3 Mar 2016 23:41:08 +0100 Subject: [PATCH 211/252] Clean up --- include/Engine/Rendering/AnimationSystem.h | 5 - .../Schema/Entities/AssaultBlendTree.xml | 513 ++++++++++++++++++ resources/Schema/Entities/BlendTreeTest.xml | 42 +- src/Engine/Rendering/AnimationSystem.cpp | 373 ------------- src/Engine/Rendering/AutoBlendQueue.cpp | 5 - 5 files changed, 538 insertions(+), 400 deletions(-) create mode 100644 resources/Schema/Entities/AssaultBlendTree.xml diff --git a/include/Engine/Rendering/AnimationSystem.h b/include/Engine/Rendering/AnimationSystem.h index 4f18b4a4..a04aa3c5 100644 --- a/include/Engine/Rendering/AnimationSystem.h +++ b/include/Engine/Rendering/AnimationSystem.h @@ -10,7 +10,6 @@ #include "Rendering/Skeleton.h" #include "Rendering/BlendTree.h" #include "Rendering/EAutoAnimationBlend.h" -#include "../Input/EInputCommand.h" #include "../Core/EntityWrapper.h" #include "Rendering/AutoBlendQueue.h" @@ -30,10 +29,6 @@ private: EventRelay m_EAutoAnimationBlend; bool OnAutoAnimationBlend(Events::AutoAnimationBlend& e); - - EventRelay m_EInputCommand; - bool OnInputCommand(const Events::InputCommand& e); - std::unordered_map m_AutoBlendQueues; }; diff --git a/resources/Schema/Entities/AssaultBlendTree.xml b/resources/Schema/Entities/AssaultBlendTree.xml new file mode 100644 index 00000000..e8dcff8a --- /dev/null +++ b/resources/Schema/Entities/AssaultBlendTree.xml @@ -0,0 +1,513 @@ + + + + + + AimBlend + FinalBlend + + + 5 + Models/Characters/Assault/AssaultBlue.mesh + + + + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + + + + + AimPrimary + AimSecondary + 0 + true + + + + + + + + AimSecWepA + + false + true + + + + + + + + + AimRifleA + + false + true + + + + + + + + + + + ReloadSwitchBlend + MovementBlend + + + + + + + + StandCrouchBlend + JumpDashBlend + 2.5146881298480398e-63 + true + + + + + + + + StandMovement + CrouchMovement + 0.012867419418159054 + true + + + + + + + + MovementBlend + Idle + 1 + + + + + + + + RunWalkBlend + StrafeLRBlend + 2.4565650245976452e-16 + + + + + + + + Walk + Run + 1.2938206818383024e-24 + + + + + + + + WalkF + + 1 + true + + + + + + + + + RunF + + 1 + true + + + + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + StrafeLeftF + + 1 + true + + + + + + + + + StrafeRightF + + 1 + true + + + + + + + + + + + + + IdleF + + 1 + true + + + + + + + + + + + MovementBlend + Idle + 0 + + + + + + + + Walk + StrafeLRBlend + 2.4565650245976452e-16 + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + CrouchStrafeLeftF + + 1 + true + + + + + + + + + CrouchStrafeRightF + + 1 + true + + + + + + + + + + + CrouchWalkF + + 1 + true + + + + + + + + + + + CrouchF + + 1 + + + + + + + + + + + + + Jump + DashBlend + 1 + true + + + + + + + + JumpF + + 1 + false + + + + + + + + + DashFBBlend + DashLRBlend + 0.014621149736541383 + + + + + + + + DashForward + DashBackward + 0.014363533804961248 + + + + + + + + DashForwardF + + 1 + false + + + + + + + + + DashBackwardF + + 1 + false + + + + + + + + + + + DashLeft + DashRight + 4.3244885367500671e-16 + + + + + + + + DashLeftF + + 1 + false + + + + + + + + + DashRightF + + 1 + false + + + + + + + + + + + + + + + + + ReloadSwitch + WeaponActionBlend + 1 + true + + + + + + + + ReloadSwitchU + + 1 + + + + + + + + + IdleBlend + ShootBlend + 0 + + + + + + + + IdlePrimary + IdleSecondary + 0 + + + + + + + + IdleAssaultRifleU + + 1 + true + + + + + + + + + IdleSecWepU + + 1 + true + + + + + + + + + + + ShootPrimary + ShootSecondary + 0 + + + + + + + + ShootFastRifleU + + 1 + + + + + + + + + ShootSecWepFastU + + + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/BlendTreeTest.xml b/resources/Schema/Entities/BlendTreeTest.xml index a3188348..79e2e223 100644 --- a/resources/Schema/Entities/BlendTreeTest.xml +++ b/resources/Schema/Entities/BlendTreeTest.xml @@ -68,8 +68,8 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - + + @@ -86,11 +86,11 @@ - + - AimRifleA - + AimSecWepA + false true @@ -98,10 +98,10 @@ - + - AimSecWepA + AimRifleA false true @@ -148,7 +148,7 @@ MovementBlend Idle - 0 + 1 @@ -177,7 +177,7 @@ WalkF - + 1 true @@ -189,7 +189,7 @@ RunF - + 1 true @@ -213,7 +213,7 @@ StrafeLeftF - + 1 true @@ -225,7 +225,7 @@ StrafeRightF - + 1 true @@ -241,8 +241,9 @@ IdleF - + 1 + true @@ -284,7 +285,7 @@ CrouchStrafeLeftF - + 1 true @@ -296,7 +297,7 @@ CrouchStrafeRightF - + 1 true @@ -310,7 +311,7 @@ CrouchWalkF - + 1 true @@ -473,7 +474,7 @@ IdleBlend ShootBlend - 1 + 0 @@ -483,6 +484,7 @@ IdlePrimary IdleSecondary + 0 @@ -491,6 +493,9 @@ IdleAssaultRifleU + + 1 + true @@ -500,6 +505,9 @@ IdleSecWepU + + 1 + true diff --git a/src/Engine/Rendering/AnimationSystem.cpp b/src/Engine/Rendering/AnimationSystem.cpp index 5c048fed..99643997 100644 --- a/src/Engine/Rendering/AnimationSystem.cpp +++ b/src/Engine/Rendering/AnimationSystem.cpp @@ -4,7 +4,6 @@ AnimationSystem::AnimationSystem(SystemParams params) : System(params) { EVENT_SUBSCRIBE_MEMBER(m_EAutoAnimationBlend, &AnimationSystem::OnAutoAnimationBlend); - EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &AnimationSystem::OnInputCommand); } void AnimationSystem::Update(double dt) @@ -16,7 +15,6 @@ void AnimationSystem::Update(double dt) for(auto& autoBlendQueue : m_AutoBlendQueues) { autoBlendQueue.second.UpdateTime(dt); - // autoBlendQueue.second.PrintQueue(); } } @@ -136,7 +134,6 @@ void AnimationSystem::UpdateWeights(double dt) if (blendTree != nullptr) { blendJob.BlendInfo.progress = glm::clamp(blendJob.CurrentTime / blendJob.Duration, 0.0, 1.0); - LOG_INFO("Progress: %f, %s", blendJob.BlendInfo.progress, blendJob.BlendInfo.NodeName.c_str()); blendJob.BlendInfo = blendTree->AutoBlendStep(blendJob.BlendInfo); } @@ -215,376 +212,6 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e) } } } - - - LOG_INFO("Inserting %s blendJob into %s subtree", e.NodeName.c_str(), subTreeRoot.Name().c_str()); m_AutoBlendQueues[subTreeRoot].Insert(abj); - - LOG_INFO("\n"); - m_AutoBlendQueues.at(subTreeRoot).PrintQueue(); - LOG_INFO("\n"); - - return true; } - -bool AnimationSystem::OnInputCommand(const Events::InputCommand& e) -{ - - if (e.Value == 1.f) { - if(e.Command == "DashForward") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.2; - aeb.NodeName = "DashForward"; - aeb.RootNode = entity; - aeb.Restart = true; - aeb.Start = true; - m_EventBroker->Publish(aeb); - } - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; - aeb.NodeName = "StandCrouchBlend"; - aeb.RootNode = entity; - aeb.Delay = -0.3; - aeb.Start = true; - aeb.Restart = false; - aeb.AnimationEntity = entity.FirstChildByName("DashForward"); - m_EventBroker->Publish(aeb); - } - } - } - - } else if (e.Command == "DashBackward") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.1; - aeb.NodeName = "DashBackward"; - aeb.RootNode = entity; - aeb.Restart = true; - aeb.Start = true; - m_EventBroker->Publish(aeb); - } - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; - aeb.NodeName = "StandCrouchBlend"; - aeb.RootNode = entity; - aeb.Start = true; - aeb.Restart = false; - aeb.Delay = -0.3; - aeb.AnimationEntity = entity.FirstChildByName("DashBackward"); - m_EventBroker->Publish(aeb); - } - } - } - } else if (e.Command == "DashLeft") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.1; - aeb.NodeName = "DashLeft"; - aeb.RootNode = entity; - aeb.Restart = true; - aeb.Start = true; - m_EventBroker->Publish(aeb); - } - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; - aeb.NodeName = "StandCrouchBlend"; - aeb.RootNode = entity; - aeb.Delay = -0.3; - aeb.Start = true; - aeb.Restart = false; - aeb.AnimationEntity = entity.FirstChildByName("DashLeft"); - m_EventBroker->Publish(aeb); - } - } - } - } else if (e.Command == "DashRight") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.1; - aeb.NodeName = "DashRight"; - aeb.RootNode = entity; - aeb.Restart = true; - aeb.Start = true; - m_EventBroker->Publish(aeb); - } - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; - aeb.NodeName = "StandCrouchBlend"; - aeb.RootNode = entity; - aeb.Start = true; - aeb.Restart = false; - aeb.AnimationEntity = entity.FirstChildByName("DashRight"); - aeb.Delay = -0.3; - m_EventBroker->Publish(aeb); - } - } - } - } else if (e.Command == "Jump") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.25; - aeb.NodeName = "Jump"; - aeb.RootNode = entity; - aeb.Start = true; - aeb.Restart = true; - m_EventBroker->Publish(aeb); - } - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; - aeb.NodeName = "StandCrouchBlend"; - aeb.RootNode = entity; - aeb.Start = true; - aeb.Restart = false; - aeb.AnimationEntity = entity.FirstChildByName("Jump"); - m_EventBroker->Publish(aeb); - } - } - } - } else if (e.Command == "Reload") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.2; - aeb.NodeName = "ReloadSwitch"; - aeb.RootNode = entity; - aeb.Start = true; - aeb.Restart = true; - m_EventBroker->Publish(aeb); - } - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.2; - aeb.NodeName = "IdlePrimary"; - aeb.RootNode = entity; - aeb.Delay = -0.1; - aeb.Start = true; - aeb.Restart = false; - aeb.AnimationEntity = entity.FirstChildByName("ReloadSwitch"); - m_EventBroker->Publish(aeb); - } - } - } - } else if (e.Command == "Crouch") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; - aeb.NodeName = "CrouchMovement"; - aeb.RootNode = entity; - aeb.Start = true; - aeb.Restart = true; - aeb.SingleLevelBlend = true; - m_EventBroker->Publish(aeb); - } - } - } - } else if (e.Command == "Shoot") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.1; - aeb.NodeName = "ShootPrimary"; - aeb.RootNode = entity; - aeb.Start = true; - aeb.Restart = true; - m_EventBroker->Publish(aeb); - } - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.1; - aeb.NodeName = "IdlePrimary"; - aeb.RootNode = entity; - aeb.Delay = 0.0; - aeb.Start = true; - aeb.Restart = false; - aeb.AnimationEntity = entity.FirstChildByName("ShootPrimary"); - m_EventBroker->Publish(aeb); - } - } - } - } else if (e.Command == "LeftTest") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.1; - aeb.NodeName = "Left"; - aeb.RootNode = entity; - aeb.Start = true; - m_EventBroker->Publish(aeb); - } - } - } - } else if (e.Command == "RightTest") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.1; - aeb.NodeName = "Right"; - aeb.RootNode = entity; - aeb.Start = true; - m_EventBroker->Publish(aeb); - } - - } - } - } else if (e.Command == "ForwardTest") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.1; - aeb.NodeName = "Walk"; - aeb.RootNode = entity; - aeb.Start = true; - m_EventBroker->Publish(aeb); - } - } - } - } - } else if (e.Command == "BackwardTest") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.1; - aeb.NodeName = "Walk"; - aeb.RootNode = entity; - aeb.Start = true; - aeb.Reverse = true; - m_EventBroker->Publish(aeb); - } - } - } - } else if (e.Value == 0.f) { - if (e.Command == "Crouch") { - auto blendComponents = m_World->GetComponents("BlendAdditive"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Assault") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; - aeb.NodeName = "StandMovement"; - aeb.RootNode = entity; - aeb.Start = true; - aeb.Restart = true; - aeb.SingleLevelBlend = true; - m_EventBroker->Publish(aeb); - } - } - } - } - } -} - diff --git a/src/Engine/Rendering/AutoBlendQueue.cpp b/src/Engine/Rendering/AutoBlendQueue.cpp index 7ea79383..cafb7ee5 100644 --- a/src/Engine/Rendering/AutoBlendQueue.cpp +++ b/src/Engine/Rendering/AutoBlendQueue.cpp @@ -45,7 +45,6 @@ void AutoBlendQueue::Insert(AutoBlendJob autoBlendJob) AnimationDuration = (animation->Duration * animationSpeed) - animationTime; } - LOG_INFO("Animation Duration %f", AnimationDuration); blendNode.StartTime += AnimationDuration; blendNode.EndTime += AnimationDuration; if (m_BlendQueue.size() == 0) { @@ -61,16 +60,13 @@ void AutoBlendQueue::Insert(AutoBlendJob autoBlendJob) if (next != m_BlendQueue.end()) { if (it->StartTime >= blendNode.StartTime && next->StartTime <= blendNode.StartTime) { - LOG_INFO("Inserted %s between %s and %s", blendNode.BlendJob.BlendInfo.NodeName.c_str(), it->BlendJob.BlendInfo.NodeName.c_str(), next->BlendJob.BlendInfo.NodeName.c_str()); m_BlendQueue.insert(next, blendNode); return; } } else if(it->StartTime > blendNode.StartTime){ - LOG_INFO("Inserted %s after %s", blendNode.BlendJob.BlendInfo.NodeName.c_str(), it->BlendJob.BlendInfo.NodeName.c_str()); m_BlendQueue.push_front(blendNode); return; } else if (it->StartTime <= blendNode.StartTime) { - LOG_INFO("Inserted %s after %s", blendNode.BlendJob.BlendInfo.NodeName.c_str(), it->BlendJob.BlendInfo.NodeName.c_str()); m_BlendQueue.push_back(blendNode); return; } @@ -80,7 +76,6 @@ void AutoBlendQueue::Insert(AutoBlendJob autoBlendJob) } - LOG_INFO("Cleared BlendQueue and inserted %s", blendNode.BlendJob.BlendInfo.NodeName.c_str()); m_BlendQueue.clear(); m_BlendQueue.push_back(blendNode); } From 2167b6f7b1562430a01ecf19f0459adfa2881a46 Mon Sep 17 00:00:00 2001 From: stiffly Date: Thu, 3 Mar 2016 23:43:50 +0100 Subject: [PATCH 212/252] Fix for previous commit.. --- include/Engine/Network/Server.h | 2 +- src/Engine/Network/Server.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/Engine/Network/Server.h b/include/Engine/Network/Server.h index 6796aaf2..d1fd2975 100644 --- a/include/Engine/Network/Server.h +++ b/include/Engine/Network/Server.h @@ -80,7 +80,7 @@ private: void identifyPacketLoss(); void kick(PlayerID player); PlayerID getPlayerIDFromEndpoint(); - PlayerID getPlayerIDFromEntityID(); + PlayerID getPlayerIDFromEntityID(EntityID entityID); void parsePlayerTransform(Packet& packet); void parseOnInputCommand(Packet& packet); void parseClientPing(); diff --git a/src/Engine/Network/Server.cpp b/src/Engine/Network/Server.cpp index 207b10f7..3f664f7e 100644 --- a/src/Engine/Network/Server.cpp +++ b/src/Engine/Network/Server.cpp @@ -534,6 +534,7 @@ bool Server::OnPlayerDeath(const Events::PlayerDeath& e) eKD.Casualty = getPlayerIDFromEntityID(e.Player.ID); eKD.Killer = getPlayerIDFromEntityID(e.Killer.ID); m_EventBroker->Publish(eKD); + return false; } void Server::parseClientPing() From 7e6d32aaecac3649d6ac5f4c4a38198189951f25 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 3 Mar 2016 23:28:16 +0100 Subject: [PATCH 213/252] Fixed AssaultWeapon reload logic --- .../Systems/Weapon/AssaultWeaponBehaviour.h | 1 + resources/Schema/Components/AssaultWeapon.xml | 1 + resources/Schema/Components/AssaultWeapon.xsd | 1 + .../Systems/Weapon/AssaultWeaponBehaviour.cpp | 34 ++++++++++++++----- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h b/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h index 7244d443..69bd15e1 100644 --- a/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h +++ b/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h @@ -20,6 +20,7 @@ public: void OnPrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) override; void OnCeasePrimaryFire(ComponentWrapper cWeapon, WeaponInfo& wi) override; void OnReload(ComponentWrapper cWeapon, WeaponInfo& wi) override; + void OnEquip(ComponentWrapper cWeapon, WeaponInfo& wi) override; void OnHolster(ComponentWrapper cWeapon, WeaponInfo& wi) override; //bool OnInputCommand(ComponentWrapper cWeapon, WeaponInfo& wi, const Events::InputCommand& e) override; diff --git a/resources/Schema/Components/AssaultWeapon.xml b/resources/Schema/Components/AssaultWeapon.xml index ba74fbb7..263a840a 100755 --- a/resources/Schema/Components/AssaultWeapon.xml +++ b/resources/Schema/Components/AssaultWeapon.xml @@ -15,6 +15,7 @@ 0.5 false 0 + false false 0 0 diff --git a/resources/Schema/Components/AssaultWeapon.xsd b/resources/Schema/Components/AssaultWeapon.xsd index a1e745de..1faf14fa 100755 --- a/resources/Schema/Components/AssaultWeapon.xsd +++ b/resources/Schema/Components/AssaultWeapon.xsd @@ -44,6 +44,7 @@ + diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp index c982637b..4d0f2258 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -10,18 +10,28 @@ void AssaultWeaponBehaviour::UpdateComponent(EntityWrapper& entity, ComponentWra void AssaultWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& wi, double dt) { - // Decrement reload timer - double& reloadTimer = cWeapon["ReloadTimer"]; - reloadTimer = glm::max(0.0, reloadTimer - dt); - // Start reloading automatically if at 0 mag ammo int& magAmmo = cWeapon["MagazineAmmo"]; if (m_ConfigAutoReload && magAmmo <= 0) { OnReload(cWeapon, wi); } - // Handle reloading + // Only start reloading once we're done firing + bool& reloadQueued = cWeapon["ReloadQueued"]; + double& fireCooldown = cWeapon["FireCooldown"]; bool& isReloading = cWeapon["IsReloading"]; + if (reloadQueued && fireCooldown <= 0) { + reloadQueued = fireCooldown; + isReloading = true; + } + + // Decrement reload timer + double& reloadTimer = cWeapon["ReloadTimer"]; + if (isReloading) { + reloadTimer = glm::max(0.0, reloadTimer - dt); + } + + // Handle reloading if (isReloading && reloadTimer <= 0.0) { int& magSize = cWeapon["MagazineSize"]; int& ammo = cWeapon["Ammo"]; @@ -67,8 +77,9 @@ void AssaultWeaponBehaviour::OnCeasePrimaryFire(ComponentWrapper cWeapon, Weapon void AssaultWeaponBehaviour::OnReload(ComponentWrapper cWeapon, WeaponInfo& wi) { + bool& reloadQueued = cWeapon["ReloadQueued"]; bool& isReloading = cWeapon["IsReloading"]; - if (isReloading) { + if (reloadQueued || isReloading) { return; } @@ -86,10 +97,15 @@ void AssaultWeaponBehaviour::OnReload(ComponentWrapper cWeapon, WeaponInfo& wi) double& reloadTimer = cWeapon["ReloadTimer"]; // Start reload - isReloading = true; + reloadQueued = true; reloadTimer = reloadTime; } +void AssaultWeaponBehaviour::OnEquip(ComponentWrapper cWeapon, WeaponInfo& wi) +{ + cWeapon["FireCooldown"] = (double)cWeapon["EquipTime"]; +} + void AssaultWeaponBehaviour::OnHolster(ComponentWrapper cWeapon, WeaponInfo& wi) { // Make sure the trigger is released if weapon is holstered while firing @@ -167,8 +183,8 @@ bool AssaultWeaponBehaviour::canFire(ComponentWrapper cWeapon, WeaponInfo& wi) { bool triggerHeld = cWeapon["TriggerHeld"]; bool cooldownPassed = (double)cWeapon["FireCooldown"] <= 0.0; - bool isReloading = cWeapon["IsReloading"]; - return triggerHeld && cooldownPassed; + bool isNotReloading = !(bool)cWeapon["IsReloading"]; + return triggerHeld && cooldownPassed && isNotReloading; } bool AssaultWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi) From 118d61c711ef63a8fd36df67ed9d0b57dbbe1ce3 Mon Sep 17 00:00:00 2001 From: Tleety Date: Thu, 3 Mar 2016 23:55:52 +0100 Subject: [PATCH 214/252] Should now remove players from scoreboard if they disconnect --- src/Game/Systems/ScoreScreenSystem.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Game/Systems/ScoreScreenSystem.cpp b/src/Game/Systems/ScoreScreenSystem.cpp index e23fba1d..d237456d 100644 --- a/src/Game/Systems/ScoreScreenSystem.cpp +++ b/src/Game/Systems/ScoreScreenSystem.cpp @@ -39,7 +39,6 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& float position = 0.f; for (auto it = m_PlayerIdentities.begin(); it != m_PlayerIdentities.end(); ++it) { - bool found = false; for (auto child : children) { int ID = (int)child["ScoreIdentity"]["ID"]; @@ -49,12 +48,14 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& (int&)entity["ScoreScreen"]["TotalIdentities"] -= 1; break; } - for (auto it = m_DisconnectedIdentities.begin(); it != m_DisconnectedIdentities.end(); ++it) { - if (ID = *it) { - + for (auto it2 = m_DisconnectedIdentities.begin(); it2 != m_DisconnectedIdentities.end(); ++it2) { + if (ID == *it2) { m_World->DeleteEntity(child.ID); (int&)entity["ScoreScreen"]["TotalIdentities"] -= 1; - it = m_DisconnectedIdentities.erase(it); + it2 = m_DisconnectedIdentities.erase(it2); + it = m_PlayerIdentities.erase(it); + + //Remove from m_playerIdentities break; } } @@ -67,6 +68,11 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& break; } } + + if (it == m_PlayerIdentities.end()) { + break; + } + if(found == false) { if(it->second.Team != currentTeam) { //This player is not the same team as this scoreboard should show. @@ -133,6 +139,5 @@ bool ScoreScreenSystem::OnPlayerDisconnected(const Events::PlayerDisconnected& e { //player has disconnected, remove him from list of ScoreIdentities m_DisconnectedIdentities.push_back(e.PlayerID); - m_PlayerIdentities.erase(e.PlayerID); return 0; } From 66374b7ff9924747251cc14a59ceeba6e52df9a7 Mon Sep 17 00:00:00 2001 From: Tleety Date: Fri, 4 Mar 2016 00:21:01 +0100 Subject: [PATCH 215/252] Should now track score correctly --- include/Game/Systems/ScoreScreenSystem.h | 8 +++++--- src/Game/Systems/ScoreScreenSystem.cpp | 23 ++++++++++++++++++++--- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/include/Game/Systems/ScoreScreenSystem.h b/include/Game/Systems/ScoreScreenSystem.h index 7a1d0cae..384f3c8d 100644 --- a/include/Game/Systems/ScoreScreenSystem.h +++ b/include/Game/Systems/ScoreScreenSystem.h @@ -4,7 +4,7 @@ #include "Core/System.h" #include "Core/ResourceManager.h" #include "Core/EntityFile.h" -#include "Core/EPlayerDeath.h" +#include "Network/EKillDeath.h" #include "Core/EPlayerSpawned.h" #include "Network/EPlayerConnected.h" #include "Network/EPlayerDisconnected.h" @@ -17,8 +17,8 @@ public: virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) override; - EventRelay m_EPlayerDeath; - bool OnPlayerDeath(const Events::PlayerDeath& e); + EventRelay m_EPlayerDeath; + bool OnPlayerDeath(const Events::KillDeath& e); EventRelay m_EPlayerSpawned; bool OnPlayerSpawn(const Events::PlayerSpawned& e); EventRelay m_EPlayerConnected; @@ -34,6 +34,8 @@ private: EntityWrapper Player = EntityWrapper::Invalid; }; + std::unordered_map m_DeathAmount; + std::unordered_map m_KillAmount; std::vector m_DisconnectedIdentities; int m_PlayerCounter = 0; std::unordered_map m_PlayerIdentities; diff --git a/src/Game/Systems/ScoreScreenSystem.cpp b/src/Game/Systems/ScoreScreenSystem.cpp index d237456d..5c7fe569 100644 --- a/src/Game/Systems/ScoreScreenSystem.cpp +++ b/src/Game/Systems/ScoreScreenSystem.cpp @@ -60,7 +60,23 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& } } found = true; - //Update position for childs + //Update Deaths for child + std::unordered_map::iterator gotDeaths = m_DeathAmount.find(ID); + if(gotDeaths != m_DeathAmount.end()) { + (int&)child["ScoreIdentity"]["Deaths"] += gotDeaths->second; + (double&)child["ScoreIdentity"]["KD"] = (double)((int)child["ScoreIdentity"]["Deaths"]/(int)child["ScoreIdentity"]["Deaths"]); + m_DeathAmount.erase(gotDeaths); + + } + //Update Kills for child + std::unordered_map::iterator gotKills = m_KillAmount.find(ID); + if (gotKills != m_KillAmount.end()) { + (int&)child["ScoreIdentity"]["Kills"] += gotKills->second; + (double&)child["ScoreIdentity"]["KD"] = (double)((int)child["ScoreIdentity"]["Deaths"]/(int)child["ScoreIdentity"]["Deaths"]); + m_KillAmount.erase(gotKills); + + } + //Update position for child glm::vec3 offset = (glm::vec3)entity["ScoreScreen"]["Offset"]; (glm::vec3&) child["Transform"]["Position"] = offset * position; position += 1.f; @@ -89,7 +105,6 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& (std::string&)cScoreIdentity["Name"] = data.Name; (int&)cScoreIdentity["ID"] = data.ID; - (int&)cScoreIdentity["Ping"] = 1337; m_World->SetParent(scoreIdentity.ID, entity.ID); @@ -100,9 +115,11 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& //Local player should have an icon, compare with LocalPlayer somthing } -bool ScoreScreenSystem::OnPlayerDeath(const Events::PlayerDeath& e) +bool ScoreScreenSystem::OnPlayerDeath(const Events::KillDeath& e) { //When player die, add it to his score, and when possible the player who killed him. + m_DeathAmount[e.Casualty]++; + m_KillAmount[e.Killer]++; return 0; } From 00b5a1771c3447ec12c645f3385b1187aee125e6 Mon Sep 17 00:00:00 2001 From: Tleety Date: Fri, 4 Mar 2016 01:34:29 +0100 Subject: [PATCH 216/252] Should now work fully, not KD tho --- include/Game/Systems/ScoreScreenSystem.h | 4 ++-- src/Game/Systems/BoostSystem.cpp | 10 ++++++-- src/Game/Systems/ScoreScreenSystem.cpp | 29 +++++++++++------------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/include/Game/Systems/ScoreScreenSystem.h b/include/Game/Systems/ScoreScreenSystem.h index 384f3c8d..f2528a7f 100644 --- a/include/Game/Systems/ScoreScreenSystem.h +++ b/include/Game/Systems/ScoreScreenSystem.h @@ -31,11 +31,11 @@ private: int ID = -1; std::string Name = ""; int Team = 1; + int Kills = 0; + int Deaths = 0; EntityWrapper Player = EntityWrapper::Invalid; }; - std::unordered_map m_DeathAmount; - std::unordered_map m_KillAmount; std::vector m_DisconnectedIdentities; int m_PlayerCounter = 0; std::unordered_map m_PlayerIdentities; diff --git a/src/Game/Systems/BoostSystem.cpp b/src/Game/Systems/BoostSystem.cpp index c79576e4..c3dc1f2b 100644 --- a/src/Game/Systems/BoostSystem.cpp +++ b/src/Game/Systems/BoostSystem.cpp @@ -11,10 +11,16 @@ bool BoostSystem::OnPlayerDamage(Events::PlayerDamage& e) if (e.Victim.ID == e.Inflictor.ID) { return false; } - if (!e.Victim.Valid() && e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) { + + if (!e.Victim.Valid() || !LocalPlayer.Valid()) { return false; } - if (!e.Inflictor.Valid() || !e.Victim.Valid()) { + + if (e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) { + return false; + } + + if (!e.Inflictor.Valid()) { return false; } diff --git a/src/Game/Systems/ScoreScreenSystem.cpp b/src/Game/Systems/ScoreScreenSystem.cpp index 5c7fe569..29749a9b 100644 --- a/src/Game/Systems/ScoreScreenSystem.cpp +++ b/src/Game/Systems/ScoreScreenSystem.cpp @@ -40,7 +40,7 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& for (auto it = m_PlayerIdentities.begin(); it != m_PlayerIdentities.end(); ++it) { bool found = false; - for (auto child : children) { + for (auto& child : children) { int ID = (int)child["ScoreIdentity"]["ID"]; if (it->first == ID) { if (it->second.Team != currentTeam) { @@ -61,21 +61,11 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& } found = true; //Update Deaths for child - std::unordered_map::iterator gotDeaths = m_DeathAmount.find(ID); - if(gotDeaths != m_DeathAmount.end()) { - (int&)child["ScoreIdentity"]["Deaths"] += gotDeaths->second; - (double&)child["ScoreIdentity"]["KD"] = (double)((int)child["ScoreIdentity"]["Deaths"]/(int)child["ScoreIdentity"]["Deaths"]); - m_DeathAmount.erase(gotDeaths); - - } + (int&)child["ScoreIdentity"]["Kills"] = it->second.Kills; //Update Kills for child - std::unordered_map::iterator gotKills = m_KillAmount.find(ID); - if (gotKills != m_KillAmount.end()) { - (int&)child["ScoreIdentity"]["Kills"] += gotKills->second; - (double&)child["ScoreIdentity"]["KD"] = (double)((int)child["ScoreIdentity"]["Deaths"]/(int)child["ScoreIdentity"]["Deaths"]); - m_KillAmount.erase(gotKills); + (int&)child["ScoreIdentity"]["Deaths"] = it->second.Deaths; + //KD is not updated at the moment. - } //Update position for child glm::vec3 offset = (glm::vec3)entity["ScoreScreen"]["Offset"]; (glm::vec3&) child["Transform"]["Position"] = offset * position; @@ -118,8 +108,15 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& bool ScoreScreenSystem::OnPlayerDeath(const Events::KillDeath& e) { //When player die, add it to his score, and when possible the player who killed him. - m_DeathAmount[e.Casualty]++; - m_KillAmount[e.Killer]++; + std::unordered_map::iterator got; + got = m_PlayerIdentities.find(e.Casualty); + if(got != m_PlayerIdentities.end()) { + got->second.Deaths++; + } + got = m_PlayerIdentities.find(e.Killer); + if (got != m_PlayerIdentities.end()) { + got->second.Kills++; + } return 0; } From 1616fb20d14904f04c39f09c7f9f1c59186e253f Mon Sep 17 00:00:00 2001 From: viktorljung Date: Fri, 4 Mar 2016 02:03:50 +0100 Subject: [PATCH 217/252] Skinned meshes now in T-Pose when not it's blendtree is null --- include/Engine/Rendering/Skeleton.h | 3 + src/Engine/Rendering/DrawFinalPass.cpp | 110 +++++++++++++++++-------- src/Engine/Rendering/PickingPass.cpp | 15 +++- src/Engine/Rendering/Skeleton.cpp | 12 +++ 4 files changed, 102 insertions(+), 38 deletions(-) diff --git a/include/Engine/Rendering/Skeleton.h b/include/Engine/Rendering/Skeleton.h index 08e348ab..3711c8b2 100644 --- a/include/Engine/Rendering/Skeleton.h +++ b/include/Engine/Rendering/Skeleton.h @@ -77,6 +77,9 @@ public: std::map BlendPoseAdditive(const std::map& additivePose, const std::map& targetPose); void GetFinalPose(std::map& boneMatrices, std::vector& finalPose, std::map& boneTransforms); + std::vector GetTPose(); + + std::map Animations; private: Skeleton::PoseData GetAdditiveBonePose(const Bone* bone, const Animation* animation, double time); diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 1b7f87ea..a610fab1 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -362,11 +362,15 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); glUniform3fv(glGetUniformLocation(explosionSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + std::vector frameBones; if (explosionEffectJob->BlendTree != nullptr) { - std::vector frameBones; frameBones = explosionEffectJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { + frameBones = explosionEffectJob->Skeleton->GetTPose(); } + glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + + } else { m_ExplosionEffectProgram->Bind(); @@ -391,11 +395,14 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& //bind textures BindExplosionTextures(explosionSplatMapSkinnedHandle, explosionEffectJob); GLERROR("asdasd"); + std::vector frameBones; if (explosionEffectJob->BlendTree != nullptr) { - std::vector frameBones; frameBones = explosionEffectJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { + frameBones = explosionEffectJob->Skeleton->GetTPose(); } + glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { m_ExplosionEffectSplatMapProgram->Bind(); @@ -438,12 +445,14 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); glUniform3fv(glGetUniformLocation(forwardSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); - if (modelJob->BlendTree != nullptr) { - std::vector frameBones; + std::vector frameBones; + if (modelJob->BlendTree != nullptr) { frameBones = modelJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { + frameBones = modelJob->Skeleton->GetTPose(); } - } + glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { m_ForwardPlusProgram->Bind(); GLERROR("Bind ForwardPlusProgram"); @@ -467,11 +476,14 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& //bind textures BindModelTextures(forwardSplatMapSkinnedHandle, modelJob); GLERROR("asdasd"); + std::vector frameBones; if (modelJob->BlendTree != nullptr) { - std::vector frameBones; frameBones = modelJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { + frameBones = modelJob->Skeleton->GetTPose(); } + glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { m_ForwardPlusSplatMapProgram->Bind(); @@ -547,11 +559,14 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::listm_CubeMapTexture); glUniform3fv(glGetUniformLocation(explosionSkinnedShieldCheckHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + std::vector frameBones; if (explosionEffectJob->BlendTree != nullptr) { - std::vector frameBones; frameBones = explosionEffectJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedShieldCheckHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { + frameBones = explosionEffectJob->Skeleton->GetTPose(); } + glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedShieldCheckHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { m_ExplosionEffectShieldCheckProgram->Bind(); @@ -578,11 +593,14 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list frameBones; if (explosionEffectJob->BlendTree != nullptr) { - std::vector frameBones; frameBones = explosionEffectJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedShieldCheckHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { + frameBones = explosionEffectJob->Skeleton->GetTPose(); } + glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedShieldCheckHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { m_ExplosionEffectSplatMapShieldCheckProgram->Bind(); @@ -614,12 +632,14 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::listm_CubeMapTexture); glUniform3fv(glGetUniformLocation(explosionSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + std::vector frameBones; if (explosionEffectJob->BlendTree != nullptr) { - std::vector frameBones; frameBones = explosionEffectJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { + frameBones = explosionEffectJob->Skeleton->GetTPose(); } - } + glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { m_ExplosionEffectProgram->Bind(); GLERROR("Bind ExplosionEffect program"); @@ -643,12 +663,14 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list frameBones; if (explosionEffectJob->BlendTree != nullptr) { - std::vector frameBones; frameBones = explosionEffectJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { + frameBones = explosionEffectJob->Skeleton->GetTPose(); } + glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { m_ExplosionEffectSplatMapProgram->Bind(); @@ -693,11 +715,14 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::listm_CubeMapTexture); glUniform3fv(glGetUniformLocation(forwardSkinnedShieldCheckHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + std::vector frameBones; if (modelJob->BlendTree != nullptr) { - std::vector frameBones; frameBones = modelJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedShieldCheckHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { + frameBones = modelJob->Skeleton->GetTPose(); } + glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedShieldCheckHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { m_ForwardPlusShieldCheckProgram->Bind(); @@ -723,11 +748,13 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list frameBones; if (modelJob->BlendTree != nullptr) { - std::vector frameBones; frameBones = modelJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedShieldCheckHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { + frameBones = modelJob->Skeleton->GetTPose(); } + glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedShieldCheckHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } else { m_ForwardPlusSplatMapShieldCheckProgram->Bind(); @@ -757,11 +784,14 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::listm_CubeMapTexture); glUniform3fv(glGetUniformLocation(forwardSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + std::vector frameBones; if (modelJob->BlendTree != nullptr) { - std::vector frameBones; frameBones = modelJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { + frameBones = modelJob->Skeleton->GetTPose(); } + glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { m_ForwardPlusProgram->Bind(); @@ -787,11 +817,13 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list frameBones; if (modelJob->BlendTree != nullptr) { - std::vector frameBones; frameBones = modelJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { + frameBones = modelJob->Skeleton->GetTPose(); } + glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); } else { m_ForwardPlusSplatMapProgram->Bind(); @@ -849,11 +881,14 @@ void DrawFinalPass::DrawShieldedModelRenderQueue(std::list frameBones; if (explosionEffectJob->BlendTree != nullptr) { - std::vector frameBones; frameBones = explosionEffectJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { + frameBones = explosionEffectJob->Skeleton->GetTPose(); } + glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + if (GLERROR("Animation")) { continue; } @@ -885,12 +920,16 @@ void DrawFinalPass::DrawShieldedModelRenderQueue(std::list frameBones; if (modelJob->BlendTree != nullptr) { - std::vector frameBones; frameBones = modelJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(forwardHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { + frameBones = modelJob->Skeleton->GetTPose(); } + glUniformMatrix4fv(glGetUniformLocation(forwardHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + + //draw glBindVertexArray(modelJob->Model->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer); @@ -918,11 +957,14 @@ void DrawFinalPass::DrawToDepthStencilBuffer(std::listProjectionMatrix())); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); + std::vector frameBones; if (modelJob->BlendTree != nullptr) { - std::vector frameBones; frameBones = modelJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { + frameBones = modelJob->Skeleton->GetTPose(); } + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { m_FillDepthStencilBufferProgram->Bind(); GLuint shaderHandle = m_FillDepthStencilBufferProgram->GetHandle(); diff --git a/src/Engine/Rendering/PickingPass.cpp b/src/Engine/Rendering/PickingPass.cpp index 096762d8..57e10aff 100644 --- a/src/Engine/Rendering/PickingPass.cpp +++ b/src/Engine/Rendering/PickingPass.cpp @@ -104,11 +104,15 @@ void PickingPass::Draw(RenderScene& scene) glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1]))); + std::vector frameBones; if (modelJob->BlendTree != nullptr) { - std::vector frameBones; frameBones = modelJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { + frameBones = modelJob->Skeleton->GetTPose(); } + glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + + } else { m_PickingProgram->Bind(); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); @@ -210,12 +214,15 @@ void PickingPass::Draw(RenderScene& scene) glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1]))); + std::vector frameBones; if (modelJob->BlendTree != nullptr) { - std::vector frameBones; frameBones = modelJob->BlendTree->GetFinalPose(); - glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { + frameBones = modelJob->Skeleton->GetTPose(); } + glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); + } else { m_PickingProgram->Bind(); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); diff --git a/src/Engine/Rendering/Skeleton.cpp b/src/Engine/Rendering/Skeleton.cpp index c9ae2732..592279ed 100644 --- a/src/Engine/Rendering/Skeleton.cpp +++ b/src/Engine/Rendering/Skeleton.cpp @@ -249,6 +249,18 @@ void Skeleton::GetFinalPose(std::map& poseDatas, std::v } + +std::vector Skeleton::GetTPose() +{ + std::vector finalMatrices; + + for (auto b : Bones) { + finalMatrices.push_back(glm::mat4(1)); + } + + return finalMatrices; +} + void Skeleton::AccumulateFinalPose(std::map& boneMatrices, std::map& poseDatas, std::map& boneTransforms, const Bone* bone, glm::mat4 parentMatrix) { glm::mat4 boneMatrix; From 778bbd13ca32ce106714c96ec2289e529c955ebf Mon Sep 17 00:00:00 2001 From: Tleety Date: Fri, 4 Mar 2016 02:19:13 +0100 Subject: [PATCH 218/252] double's should now be displayed with only 1 decimal. --- include/Game/Systems/TextFieldReader.h | 2 ++ resources/Schema/Entities/ScoreIdentity.xml | 4 ++-- src/Game/Systems/TextFieldReader.cpp | 12 ++++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/Game/Systems/TextFieldReader.h b/include/Game/Systems/TextFieldReader.h index 1ea8e966..290bedbc 100644 --- a/include/Game/Systems/TextFieldReader.h +++ b/include/Game/Systems/TextFieldReader.h @@ -2,6 +2,8 @@ #define AmmunitionHUDSystem_h__ #include +#include +#include #include "../../Engine/Core/System.h" #include "../../Engine/GLM.h" diff --git a/resources/Schema/Entities/ScoreIdentity.xml b/resources/Schema/Entities/ScoreIdentity.xml index b2df3821..2d1b471a 100644 --- a/resources/Schema/Entities/ScoreIdentity.xml +++ b/resources/Schema/Entities/ScoreIdentity.xml @@ -54,7 +54,7 @@ - 0 + 0.0 Fonts/DroidSans.ttf,64 @@ -66,7 +66,7 @@ KD - + diff --git a/src/Game/Systems/TextFieldReader.cpp b/src/Game/Systems/TextFieldReader.cpp index 8712a61f..c2e5c1e4 100644 --- a/src/Game/Systems/TextFieldReader.cpp +++ b/src/Game/Systems/TextFieldReader.cpp @@ -35,9 +35,17 @@ void TextFieldReader::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c if (field.Type == "int") { text = boost::lexical_cast((const int&)component[fieldName]); } else if (field.Type == "float") { - text = boost::lexical_cast((const float&)component[fieldName]); + std::ostringstream ss; + float f = (float)component[fieldName]; + ss << std::fixed << std::setprecision(2); + ss << f; + text = ss.str(); } else if (field.Type == "double") { - text = boost::lexical_cast((const double&)component[fieldName]); + std::ostringstream ss; + double d = (double)component[fieldName]; + ss << std::fixed << std::setprecision(1); + ss << d; + text = ss.str(); } else if (field.Type == "bool") { text = boost::lexical_cast((const bool&)component[fieldName]); } else if (field.Type == "string") { From 45991000ae312eee4f611a2a823e2b0dc46a6bd4 Mon Sep 17 00:00:00 2001 From: Tleety Date: Fri, 4 Mar 2016 02:20:42 +0100 Subject: [PATCH 219/252] Removed unused code --- src/Game/Systems/ScoreScreenSystem.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Game/Systems/ScoreScreenSystem.cpp b/src/Game/Systems/ScoreScreenSystem.cpp index 29749a9b..338e7acc 100644 --- a/src/Game/Systems/ScoreScreenSystem.cpp +++ b/src/Game/Systems/ScoreScreenSystem.cpp @@ -27,11 +27,7 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& int currentTeam = 0; if(entity.HasComponent("Team")) { - auto cTeam = entity["Team"]; - redTeamEnum = (int)cTeam["Team"].Enum("Red"); - blueTeamEnum = (int)cTeam["Team"].Enum("Blue"); - spectatorTeamEnum = (int)cTeam["Team"].Enum("Spectator"); - currentTeam = (int)cTeam["Team"]; + currentTeam = (int)entity["Team"]["Team"]; } auto children = entity.ChildrenWithComponent("ScoreIdentity"); From 49802fed91ad6277bee9713b8c7ef6737376c127 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Fri, 4 Mar 2016 02:24:13 +0100 Subject: [PATCH 220/252] Blend duration can now be 0.0 --- include/Engine/Rendering/AnimationSystem.h | 5 ++- src/Engine/Rendering/AnimationSystem.cpp | 47 +++++++++++++++++++++- 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/include/Engine/Rendering/AnimationSystem.h b/include/Engine/Rendering/AnimationSystem.h index a04aa3c5..ec8db2dd 100644 --- a/include/Engine/Rendering/AnimationSystem.h +++ b/include/Engine/Rendering/AnimationSystem.h @@ -12,7 +12,7 @@ #include "Rendering/EAutoAnimationBlend.h" #include "../Core/EntityWrapper.h" #include "Rendering/AutoBlendQueue.h" - +#include "../Input/EInputCommand.h" #include "imgui/imgui.h" class AnimationSystem : public ImpureSystem @@ -28,7 +28,8 @@ private: EventRelay m_EAutoAnimationBlend; bool OnAutoAnimationBlend(Events::AutoAnimationBlend& e); - + EventRelay m_EInputCommand; + bool OnInputCommand(const Events::InputCommand& e); std::unordered_map m_AutoBlendQueues; }; diff --git a/src/Engine/Rendering/AnimationSystem.cpp b/src/Engine/Rendering/AnimationSystem.cpp index 99643997..9d785a5c 100644 --- a/src/Engine/Rendering/AnimationSystem.cpp +++ b/src/Engine/Rendering/AnimationSystem.cpp @@ -4,6 +4,7 @@ AnimationSystem::AnimationSystem(SystemParams params) : System(params) { EVENT_SUBSCRIBE_MEMBER(m_EAutoAnimationBlend, &AnimationSystem::OnAutoAnimationBlend); + EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &AnimationSystem::OnInputCommand); } void AnimationSystem::Update(double dt) @@ -133,7 +134,12 @@ void AnimationSystem::UpdateWeights(double dt) std::shared_ptr blendTree = autoBlendQueue.second.GetBlendTree(); if (blendTree != nullptr) { - blendJob.BlendInfo.progress = glm::clamp(blendJob.CurrentTime / blendJob.Duration, 0.0, 1.0); + if (blendJob.Duration != 0.0) { + blendJob.BlendInfo.progress = glm::clamp(blendJob.CurrentTime / blendJob.Duration, 0.0, 1.0); + } else { + blendJob.BlendInfo.progress = 1.0; + } + blendJob.BlendInfo = blendTree->AutoBlendStep(blendJob.BlendInfo); } @@ -215,3 +221,42 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e) m_AutoBlendQueues[subTreeRoot].Insert(abj); return true; } + +bool AnimationSystem::OnInputCommand(const Events::InputCommand& e) +{ + if (e.Value == 1.0f) { + if (e.Command == "Shoot") { + auto blendComponents = m_World->GetComponents("Model"); + + if (blendComponents == nullptr) { + return false; + } + for (auto& bc : *blendComponents) { + EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); + + if (entity.Name() == "Hands") { + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.0; + aeb.NodeName = "Fire"; + aeb.RootNode = entity; + aeb.Start = true; + aeb.Restart = true; + m_EventBroker->Publish(aeb); + } + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.1; + aeb.NodeName = "Idle"; + aeb.RootNode = entity; + aeb.Delay = 0.0; + aeb.Start = true; + aeb.Restart = false; + aeb.AnimationEntity = entity.FirstChildByName("PrimaryBlendTree").FirstChildByName("Fire"); + m_EventBroker->Publish(aeb); + } + } + } + } + } +} From 1ff91a5c5d595342ec8bb7b992ea0dfdf4fdabb4 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Fri, 4 Mar 2016 02:30:05 +0100 Subject: [PATCH 221/252] fixup! Blend duration can now be 0.0 Commited input test stuff --- include/Engine/Rendering/AnimationSystem.h | 2 -- src/Engine/Rendering/AnimationSystem.cpp | 40 ---------------------- 2 files changed, 42 deletions(-) diff --git a/include/Engine/Rendering/AnimationSystem.h b/include/Engine/Rendering/AnimationSystem.h index ec8db2dd..30c6fce5 100644 --- a/include/Engine/Rendering/AnimationSystem.h +++ b/include/Engine/Rendering/AnimationSystem.h @@ -28,8 +28,6 @@ private: EventRelay m_EAutoAnimationBlend; bool OnAutoAnimationBlend(Events::AutoAnimationBlend& e); - EventRelay m_EInputCommand; - bool OnInputCommand(const Events::InputCommand& e); std::unordered_map m_AutoBlendQueues; }; diff --git a/src/Engine/Rendering/AnimationSystem.cpp b/src/Engine/Rendering/AnimationSystem.cpp index 9d785a5c..5bac27f9 100644 --- a/src/Engine/Rendering/AnimationSystem.cpp +++ b/src/Engine/Rendering/AnimationSystem.cpp @@ -4,7 +4,6 @@ AnimationSystem::AnimationSystem(SystemParams params) : System(params) { EVENT_SUBSCRIBE_MEMBER(m_EAutoAnimationBlend, &AnimationSystem::OnAutoAnimationBlend); - EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &AnimationSystem::OnInputCommand); } void AnimationSystem::Update(double dt) @@ -221,42 +220,3 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e) m_AutoBlendQueues[subTreeRoot].Insert(abj); return true; } - -bool AnimationSystem::OnInputCommand(const Events::InputCommand& e) -{ - if (e.Value == 1.0f) { - if (e.Command == "Shoot") { - auto blendComponents = m_World->GetComponents("Model"); - - if (blendComponents == nullptr) { - return false; - } - for (auto& bc : *blendComponents) { - EntityWrapper entity = EntityWrapper(m_World, bc.EntityID); - - if (entity.Name() == "Hands") { - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.0; - aeb.NodeName = "Fire"; - aeb.RootNode = entity; - aeb.Start = true; - aeb.Restart = true; - m_EventBroker->Publish(aeb); - } - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.1; - aeb.NodeName = "Idle"; - aeb.RootNode = entity; - aeb.Delay = 0.0; - aeb.Start = true; - aeb.Restart = false; - aeb.AnimationEntity = entity.FirstChildByName("PrimaryBlendTree").FirstChildByName("Fire"); - m_EventBroker->Publish(aeb); - } - } - } - } - } -} From 3a8f7c5d03225a73611ff60999e31c2a459c58ae Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Fri, 4 Mar 2016 02:48:03 +0100 Subject: [PATCH 222/252] First attempt at AssaultWeapon animations! --- assets | 2 +- .../Systems/Weapon/AssaultWeaponBehaviour.h | 1 + .../Schema/Entities/AssaultBlendTree.xml | 513 ------------- resources/Schema/Entities/BlendTreeAim.xml | 41 ++ .../Schema/Entities/BlendTreeAssault.xml | 445 ++++++++++++ .../Entities/BlendTreeAssaultWeapon.xml | 65 ++ .../Entities/BlendTreeSidearmWeapon.xml | 10 + resources/Schema/Entities/MovementTest.xml | 20 +- resources/Schema/Entities/Player.xml | 684 ++++++++++++++++-- src/Game/Systems/PlayerMovementSystem.cpp | 89 +-- .../Systems/Weapon/AssaultWeaponBehaviour.cpp | 46 ++ 11 files changed, 1253 insertions(+), 663 deletions(-) delete mode 100644 resources/Schema/Entities/AssaultBlendTree.xml create mode 100644 resources/Schema/Entities/BlendTreeAim.xml create mode 100644 resources/Schema/Entities/BlendTreeAssault.xml create mode 100644 resources/Schema/Entities/BlendTreeAssaultWeapon.xml create mode 100644 resources/Schema/Entities/BlendTreeSidearmWeapon.xml diff --git a/assets b/assets index c82b5716..4205e927 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit c82b5716d98a0c9fb3914367e9b08cc2e7dbca43 +Subproject commit 4205e92755aa67c90db6d272047cd92037ae9f11 diff --git a/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h b/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h index 69bd15e1..d577e22f 100644 --- a/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h +++ b/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h @@ -5,6 +5,7 @@ #include "Collision/Collision.h" #include "Core/EPlayerDamage.h" #include "Sound/EPlaySoundOnEntity.h" +#include "Rendering/EAutoAnimationBlend.h" class AssaultWeaponBehaviour : public WeaponBehaviour { diff --git a/resources/Schema/Entities/AssaultBlendTree.xml b/resources/Schema/Entities/AssaultBlendTree.xml deleted file mode 100644 index e8dcff8a..00000000 --- a/resources/Schema/Entities/AssaultBlendTree.xml +++ /dev/null @@ -1,513 +0,0 @@ - - - - - - AimBlend - FinalBlend - - - 5 - Models/Characters/Assault/AssaultBlue.mesh - - - - - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - - - - - - - - - - - - - AimPrimary - AimSecondary - 0 - true - - - - - - - - AimSecWepA - - false - true - - - - - - - - - AimRifleA - - false - true - - - - - - - - - - - ReloadSwitchBlend - MovementBlend - - - - - - - - StandCrouchBlend - JumpDashBlend - 2.5146881298480398e-63 - true - - - - - - - - StandMovement - CrouchMovement - 0.012867419418159054 - true - - - - - - - - MovementBlend - Idle - 1 - - - - - - - - RunWalkBlend - StrafeLRBlend - 2.4565650245976452e-16 - - - - - - - - Walk - Run - 1.2938206818383024e-24 - - - - - - - - WalkF - - 1 - true - - - - - - - - - RunF - - 1 - true - - - - - - - - - - - Left - Right - 0.033793529385008014 - - - - - - - - StrafeLeftF - - 1 - true - - - - - - - - - StrafeRightF - - 1 - true - - - - - - - - - - - - - IdleF - - 1 - true - - - - - - - - - - - MovementBlend - Idle - 0 - - - - - - - - Walk - StrafeLRBlend - 2.4565650245976452e-16 - - - - - - - - Left - Right - 0.033793529385008014 - - - - - - - - CrouchStrafeLeftF - - 1 - true - - - - - - - - - CrouchStrafeRightF - - 1 - true - - - - - - - - - - - CrouchWalkF - - 1 - true - - - - - - - - - - - CrouchF - - 1 - - - - - - - - - - - - - Jump - DashBlend - 1 - true - - - - - - - - JumpF - - 1 - false - - - - - - - - - DashFBBlend - DashLRBlend - 0.014621149736541383 - - - - - - - - DashForward - DashBackward - 0.014363533804961248 - - - - - - - - DashForwardF - - 1 - false - - - - - - - - - DashBackwardF - - 1 - false - - - - - - - - - - - DashLeft - DashRight - 4.3244885367500671e-16 - - - - - - - - DashLeftF - - 1 - false - - - - - - - - - DashRightF - - 1 - false - - - - - - - - - - - - - - - - - ReloadSwitch - WeaponActionBlend - 1 - true - - - - - - - - ReloadSwitchU - - 1 - - - - - - - - - IdleBlend - ShootBlend - 0 - - - - - - - - IdlePrimary - IdleSecondary - 0 - - - - - - - - IdleAssaultRifleU - - 1 - true - - - - - - - - - IdleSecWepU - - 1 - true - - - - - - - - - - - ShootPrimary - ShootSecondary - 0 - - - - - - - - ShootFastRifleU - - 1 - - - - - - - - - ShootSecWepFastU - - - - - - - - - - - - - - - - diff --git a/resources/Schema/Entities/BlendTreeAim.xml b/resources/Schema/Entities/BlendTreeAim.xml new file mode 100644 index 00000000..a340c8d5 --- /dev/null +++ b/resources/Schema/Entities/BlendTreeAim.xml @@ -0,0 +1,41 @@ + + + + + + AimPrimary + AimSecondary + 0 + true + + + + + + + + + AimSecWepA + + false + true + + + + + + + + + AimRifleA + + false + true + + + + + + + + diff --git a/resources/Schema/Entities/BlendTreeAssault.xml b/resources/Schema/Entities/BlendTreeAssault.xml new file mode 100644 index 00000000..1cd121eb --- /dev/null +++ b/resources/Schema/Entities/BlendTreeAssault.xml @@ -0,0 +1,445 @@ + + + + + + ReloadSwitchBlend + MovementBlend + + + + + + + + + StandCrouchBlend + JumpDashBlend + 2.5146881298480398e-63 + true + + + + + + + + StandMovement + CrouchMovement + 0 + true + + + + + + + + MovementBlend + Idle + 1 + + + + + + + + Walk + StrafeLRBlend + 0 + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + CrouchStrafeLeftF + + 1 + true + + + + + + + + + CrouchStrafeRightF + + 1 + true + + + + + + + + + + + CrouchWalkF + + 1 + true + + + + + + + + + + + CrouchF + + 1 + + + + + + + + + + + MovementBlend + Idle + 1 + + + + + + + + RunWalkBlend + StrafeLRBlend + 2.4565650245976452e-16 + + + + + + + + Walk + Run + 1.2938206818383024e-24 + + + + + + + + WalkF + + 1 + true + + + + + + + + + RunF + + 1 + true + + + + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + StrafeLeftF + + 1 + true + + + + + + + + + StrafeRightF + + 1 + true + + + + + + + + + + + + + IdleF + + 1 + true + + + + + + + + + + + + + Jump + DashBlend + 1 + true + + + + + + + + JumpF + + 1 + false + + + + + + + + + DashFBBlend + DashLRBlend + 0.014621149736541383 + + + + + + + + DashForward + DashBackward + 0.014363533804961248 + + + + + + + + DashForwardF + + 1 + false + + + + + + + + + DashBackwardF + + 1 + false + + + + + + + + + + + DashLeft + DashRight + 4.3244885367500671e-16 + + + + + + + + DashLeftF + + 1 + false + + + + + + + + + DashRightF + + 1 + false + + + + + + + + + + + + + + + + + ReloadSwitch + WeaponActionBlend + 1 + true + + + + + + + + ReloadSwitchU + + 1 + + + + + + + + + IdleBlend + ShootBlend + 0 + + + + + + + + IdlePrimary + IdleSecondary + 0 + + + + + + + + IdleAssaultRifleU + + 1 + true + + + + + + + + + IdleSecWepU + + 1 + true + + + + + + + + + + + ShootPrimary + ShootSecondary + 0 + + + + + + + + ShootFastRifleU + + 1 + + + + + + + + + ShootSecWepFastU + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/BlendTreeAssaultWeapon.xml b/resources/Schema/Entities/BlendTreeAssaultWeapon.xml new file mode 100644 index 00000000..a68175a2 --- /dev/null +++ b/resources/Schema/Entities/BlendTreeAssaultWeapon.xml @@ -0,0 +1,65 @@ + + + + + + Idle + WeaponAction + 0 + true + + + + + + + + + Fire + Reload + 1 + + + + + + + + ShootShotgunF + 1 + true + false + + + + + + + + + ReloadSwitchF + + 1 + true + + + + + + + + + + + IdleF + + 1 + true + + + + + + + + diff --git a/resources/Schema/Entities/BlendTreeSidearmWeapon.xml b/resources/Schema/Entities/BlendTreeSidearmWeapon.xml new file mode 100644 index 00000000..627829e5 --- /dev/null +++ b/resources/Schema/Entities/BlendTreeSidearmWeapon.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/resources/Schema/Entities/MovementTest.xml b/resources/Schema/Entities/MovementTest.xml index 7bbaf21d..90c943ef 100644 --- a/resources/Schema/Entities/MovementTest.xml +++ b/resources/Schema/Entities/MovementTest.xml @@ -8,15 +8,15 @@ - - - Schema/Entities/PlayerAssaultFallbackRed.xml - + + + Schema/Entities/PlayerAssaultFallbackRed.xml + @@ -76,15 +76,15 @@ - - - Schema/Entities/PlayerAssaultFallbackBlue.xml - + + + Schema/Entities/Player.xml + @@ -98,7 +98,7 @@ - + @@ -111,7 +111,7 @@ - + diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index affe9f79..d34dba32 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -6,11 +6,12 @@ - - - - - + + + + + + @@ -22,11 +23,6 @@ 5 - - - - - @@ -173,6 +169,40 @@ + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + 0.0 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + @@ -219,12 +249,12 @@ - - 2 - + + 2 + Textures/Core/UnitHexagon_Rotated.png @@ -253,12 +283,12 @@ - - 3 - + + 3 + Textures/Core/UnitHexagon_Rotated.png @@ -287,13 +317,13 @@ - - 4 - 1 + + 4 + Textures/Core/UnitHexagon_Rotated.png @@ -322,12 +352,12 @@ - - 1 - + + 1 + Textures/Core/UnitHexagon_Rotated.png @@ -356,11 +386,11 @@ - 1 + Textures/Core/UnitHexagon_Rotated.png @@ -433,15 +463,15 @@ - - - Models/Widgets/Arrows/Arrow5.mesh - + + + Models/Widgets/Arrows/Arrow5.mesh + @@ -454,16 +484,14 @@ - - Idle - 1.8348644854054612 - 1 - - - + + BlendTreeAssaultWeapon + BlendTreeSecondaryWeapon + 0 + true + - Models/Characters/Assault/Test/FirstPerson.mesh - + Models/Characters/Defender/FirstPersonDefenderBlue.mesh @@ -477,11 +505,11 @@ AssaultWeapon - Schema/Entities/AssaultWeaponView.xml + Schema/Entities/WeaponAssaultBlueView.xml - - + + @@ -498,12 +526,79 @@ Schema/Entities/SidearmWeaponView.xml - - + + + + + + Idle + WeaponAction + 0 + true + + + + + + + + Fire + Reload + 1 + + + + + + + + ShootShotgunF + 1 + true + false + + + + + + + + + ReloadSwitchF + + 1 + true + + + + + + + + + + + IdleF + + 1 + true + + + + + + + + + + + + + @@ -527,27 +622,25 @@ - - IdleF - 1 - - - - - AimRifle - - + + BlendTreeAim + BlendTreeAssault + Models/Characters/Assault/AssaultBlue.mesh + false + + R_Arm_Weapon_Joint + AssaultWeapon @@ -555,9 +648,12 @@ - Schema/Entities/AssaultWeaponWorld.xml + Schema/Entities/WeaponAssaultBlueWorld.xml - + + + + @@ -576,12 +672,490 @@ Schema/Entities/SidearmWeaponWorld.xml - - + + + + + + AimPrimary + AimSecondary + 0 + true + + + + + + + + AimSecWepA + + false + true + + + + + + + + + AimRifleA + + false + true + + + + + + + + + + + ReloadSwitchBlend + MovementBlend + + + + + + + + StandCrouchBlend + JumpDashBlend + 2.5146881298480398e-63 + true + + + + + + + + StandMovement + CrouchMovement + 0 + true + + + + + + + + MovementBlend + Idle + 1 + + + + + + + + Walk + StrafeLRBlend + 0 + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + CrouchStrafeLeftF + + 1 + true + + + + + + + + + CrouchStrafeRightF + + 1 + true + + + + + + + + + + + CrouchWalkF + + 1 + true + + + + + + + + + + + CrouchF + + 1 + + + + + + + + + + + MovementBlend + Idle + 1 + + + + + + + + RunWalkBlend + StrafeLRBlend + 2.4565650245976452e-16 + + + + + + + + Walk + Run + 1.2938206818383024e-24 + + + + + + + + WalkF + + 1 + true + + + + + + + + + RunF + + 1 + true + + + + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + StrafeLeftF + + 1 + true + + + + + + + + + StrafeRightF + + 1 + true + + + + + + + + + + + + + IdleF + + 1 + true + + + + + + + + + + + + + Jump + DashBlend + 1 + true + + + + + + + + JumpF + + 1 + false + + + + + + + + + DashFBBlend + DashLRBlend + 0.014621149736541383 + + + + + + + + DashForward + DashBackward + 0.014363533804961248 + + + + + + + + DashForwardF + + 1 + false + + + + + + + + + DashBackwardF + + 1 + false + + + + + + + + + + + DashLeft + DashRight + 4.3244885367500671e-16 + + + + + + + + DashLeftF + + 1 + false + + + + + + + + + DashRightF + + 1 + false + + + + + + + + + + + + + + + + + ReloadSwitch + WeaponActionBlend + 1 + true + + + + + + + + ReloadSwitchU + + 1 + + + + + + + + + IdleBlend + ShootBlend + 0 + + + + + + + + IdlePrimary + IdleSecondary + 0 + + + + + + + + IdleAssaultRifleU + + 1 + true + + + + + + + + + IdleSecWepU + + 1 + true + + + + + + + + + + + ShootPrimary + ShootSecondary + 0 + + + + + + + + ShootFastRifleU + + 1 + + + + + + + + + ShootSecWepFastU + + + + + + + + + + + + + diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index b116bcd9..d67e77bd 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -43,10 +43,10 @@ void PlayerMovementSystem::updateMovementControllers(double dt) // Set third person model aim pitch EntityWrapper playerModel = player.FirstChildByName("PlayerModel"); if (playerModel.Valid()) { - ComponentWrapper cAnimationOffset = playerModel["AnimationOffset"]; - float pitch = cameraOrientation.x + 0.2f; - double time = (pitch + glm::half_pi()) / glm::pi(); - cAnimationOffset["Time"] = time; + //ComponentWrapper cAnimationOffset = playerModel["AnimationOffset"]; + //float pitch = cameraOrientation.x + 0.2f; + //double time = (pitch + glm::half_pi()) / glm::pi(); + //cAnimationOffset["Time"] = time; } } @@ -166,81 +166,7 @@ void PlayerMovementSystem::updateMovementControllers(double dt) } } - // Animations - EntityWrapper playerModel = player.FirstChildByName("PlayerModel"); - if (playerModel.Valid()) { - ComponentWrapper cAnimation = playerModel["Animation"]; - std::string& animationName1 = cAnimation["AnimationName1"]; - std::string& animationName2 = cAnimation["AnimationName2"]; - double& animationTime1 = cAnimation["Time1"]; - double& animationTime2 = cAnimation["Time2"]; - double& animationSpeed1 = cAnimation["Speed1"]; - double& animationSpeed2 = cAnimation["Speed2"]; - double& animationWeight1 = cAnimation["Weight1"]; - double& animationWeight2 = cAnimation["Weight2"]; - - float movementLength = glm::length(groundVelocity); - //TODO: add assault dash animation here - if (glm::length(controller->Movement()) > 0.f) { - double forwardMovement = controller->Movement().z; - double strafeMovement = controller->Movement().x; - - if (controller->Crouching() && animationName1 != "CrouchWalk") { - animationName1 = "CrouchWalk"; - animationSpeed1 = 1.0 * -glm::sign(controller->Movement().z); - } else { - if (glm::abs(forwardMovement) > 0) { - if (animationName1 != "Run") { - animationName1 = "Run"; - if (animationName2 == "StrafeLeft" || animationName2 == "StrafeRight") { - animationTime1 = animationTime2; - } else { - animationTime1 = 0.0; - } - } - animationSpeed1 = 2.f * -glm::sign(forwardMovement); - } - - if (glm::abs(strafeMovement) > 0) { - if (animationName2 != "StrafeLeft" && animationName2 != "StrafeRight") { - if (strafeMovement < 0) { - animationName2 = "StrafeLeft"; - } - if (strafeMovement > 0) { - animationName2 = "StrafeRight"; - } - if (animationName1 == "Run") { - animationTime2 = animationTime1; - } else { - animationTime2 = 0.0; - } - } - animationSpeed2 = 2.f * glm::abs(strafeMovement); - } - - double strafeWeight = glm::abs(strafeMovement) / (glm::abs(forwardMovement) + glm::abs(strafeMovement)); - animationWeight2 = strafeWeight; - animationWeight1 = 1.0 - strafeWeight; - } - } else { - if (controller->Crouching()) { - animationName1 = "Crouch"; - animationName2 = ""; - animationSpeed1 = 1.0; - animationSpeed2 = 0.0; - animationWeight1 = 1.0; - animationWeight2 = 0.0; - } else { - animationName1 = "Idle"; - animationName2 = ""; - animationSpeed1 = 1.f; - animationSpeed2 = 0.0; - animationWeight1 = 1.0; - animationWeight2 = 0.0; - //cAnimation["AnimationName2"] = "Idle"; - } - } - } + // TODO: Animations } controller->Reset(); @@ -354,10 +280,5 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) playerEntityAnimation.Copy(dashEffect["Animation"]); dashEffect["ExplosionEffect"]["EndColor"] = (glm::vec4)playerEntityModel["Color"]; ((glm::vec4&)dashEffect["ExplosionEffect"]["EndColor"]).w = 0.f; - dashEffect["Animation"]["Speed1"] = 0.0; - dashEffect["Animation"]["Speed2"] = 0.0; - dashEffect["Animation"]["Speed3"] = 0.0; - dashEffect["Transform"]["Position"] = (glm::vec3)player["Transform"]["Position"]; - dashEffect["Transform"]["Orientation"] = (glm::vec3)player["Transform"]["Orientation"]; return true; } diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp index 4d0f2258..4f5b2b05 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -99,6 +99,29 @@ void AssaultWeaponBehaviour::OnReload(ComponentWrapper cWeapon, WeaponInfo& wi) // Start reload reloadQueued = true; reloadTimer = reloadTime; + + // Play animation + EntityWrapper modelEntity = wi.FirstPersonEntity.Parent().Parent(); + if (modelEntity.Valid()) { + EntityWrapper blendTree = modelEntity.FirstChildByName("PrimaryBlendTree"); + EntityWrapper reloadBlend = blendTree.FirstChildByName("Reload"); + + Events::AutoAnimationBlend eFireBlend; + eFireBlend.RootNode = modelEntity; + eFireBlend.NodeName = "Reload"; + eFireBlend.Restart = true; + eFireBlend.Start = true; + eFireBlend.Duration = 0.0001; + m_EventBroker->Publish(eFireBlend); + + Events::AutoAnimationBlend eIdleBlend; + eIdleBlend.RootNode = modelEntity; + eIdleBlend.NodeName = "Idle"; + eIdleBlend.AnimationEntity = reloadBlend; + eIdleBlend.Delay = -0.2; + eIdleBlend.Duration = 0.2; + m_EventBroker->Publish(eIdleBlend); + } } void AssaultWeaponBehaviour::OnEquip(ComponentWrapper cWeapon, WeaponInfo& wi) @@ -177,6 +200,29 @@ void AssaultWeaponBehaviour::fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi m_EventBroker->Publish(e); } } + + // Play animation + EntityWrapper modelEntity = wi.FirstPersonEntity.Parent().Parent(); + if (modelEntity.Valid()) { + EntityWrapper blendTree = modelEntity.FirstChildByName("PrimaryBlendTree"); + EntityWrapper fireBlend = blendTree.FirstChildByName("Fire"); + + Events::AutoAnimationBlend eFireBlend; + eFireBlend.RootNode = modelEntity; + eFireBlend.NodeName = "Fire"; + eFireBlend.Restart = true; + eFireBlend.Start = true; + eFireBlend.Duration = 0.0001; + m_EventBroker->Publish(eFireBlend); + + Events::AutoAnimationBlend eIdleBlend; + eIdleBlend.RootNode = modelEntity; + eIdleBlend.NodeName = "Idle"; + eIdleBlend.AnimationEntity = fireBlend; + eIdleBlend.Delay = -0.2; + eIdleBlend.Duration = 0.2; + m_EventBroker->Publish(eIdleBlend); + } } bool AssaultWeaponBehaviour::canFire(ComponentWrapper cWeapon, WeaponInfo& wi) From b7fa7f9119da4125b145b13d547398df38b5fc4b Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Fri, 4 Mar 2016 02:50:03 +0100 Subject: [PATCH 223/252] Duration no longer needed --- src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp index 4f5b2b05..7d3b8615 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -111,7 +111,6 @@ void AssaultWeaponBehaviour::OnReload(ComponentWrapper cWeapon, WeaponInfo& wi) eFireBlend.NodeName = "Reload"; eFireBlend.Restart = true; eFireBlend.Start = true; - eFireBlend.Duration = 0.0001; m_EventBroker->Publish(eFireBlend); Events::AutoAnimationBlend eIdleBlend; From 0e95c5bb958a505f4971f997402fd5f81c785040 Mon Sep 17 00:00:00 2001 From: Tleety Date: Fri, 4 Mar 2016 02:52:04 +0100 Subject: [PATCH 224/252] Fixes --- include/Engine/Core/System.h | 2 +- include/Game/Systems/ScoreScreenSystem.h | 2 +- src/Game/Systems/ScoreScreenSystem.cpp | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/Engine/Core/System.h b/include/Engine/Core/System.h index 23d5f9a5..1ca1c824 100644 --- a/include/Engine/Core/System.h +++ b/include/Engine/Core/System.h @@ -68,7 +68,7 @@ protected: const std::string m_ComponentType; - virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt) = 0; + virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& scoreScreen, double dt) = 0; }; class ImpureSystem : public virtual System diff --git a/include/Game/Systems/ScoreScreenSystem.h b/include/Game/Systems/ScoreScreenSystem.h index f2528a7f..2559bfb3 100644 --- a/include/Game/Systems/ScoreScreenSystem.h +++ b/include/Game/Systems/ScoreScreenSystem.h @@ -15,7 +15,7 @@ class ScoreScreenSystem : public PureSystem public: ScoreScreenSystem(SystemParams params); - virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) override; + virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& scoreScreen, double dt) override; EventRelay m_EPlayerDeath; bool OnPlayerDeath(const Events::KillDeath& e); diff --git a/src/Game/Systems/ScoreScreenSystem.cpp b/src/Game/Systems/ScoreScreenSystem.cpp index 338e7acc..2ad45f53 100644 --- a/src/Game/Systems/ScoreScreenSystem.cpp +++ b/src/Game/Systems/ScoreScreenSystem.cpp @@ -11,7 +11,7 @@ ScoreScreenSystem::ScoreScreenSystem(SystemParams params) EVENT_SUBSCRIBE_MEMBER(m_EPlayerDisconnected, &ScoreScreenSystem::OnPlayerDisconnected); } -void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) +void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& scoreScreen, double dt) { if (!IsServer) { return; @@ -28,6 +28,8 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& if(entity.HasComponent("Team")) { currentTeam = (int)entity["Team"]["Team"]; + } else { + return; } auto children = entity.ChildrenWithComponent("ScoreIdentity"); @@ -56,6 +58,9 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& } } found = true; + if(!child.Valid()) { + break; + } //Update Deaths for child (int&)child["ScoreIdentity"]["Kills"] = it->second.Kills; //Update Kills for child From 1bd71931b8452dd01f1768b38f44c9503e2028dc Mon Sep 17 00:00:00 2001 From: viktorljung Date: Fri, 4 Mar 2016 02:53:23 +0100 Subject: [PATCH 225/252] Fixed crash when trying to blend to a nonexistent node --- src/Engine/Rendering/BlendTree.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Engine/Rendering/BlendTree.cpp b/src/Engine/Rendering/BlendTree.cpp index 60858f2a..9b6679ea 100644 --- a/src/Engine/Rendering/BlendTree.cpp +++ b/src/Engine/Rendering/BlendTree.cpp @@ -219,7 +219,6 @@ BlendTree::AutoBlendInfo BlendTree::AutoBlendStep(AutoBlendInfo blendInfo) } } - if(goalNodes.size() == 0) { return blendInfo; } else if(goalNodes.size() == 1) { @@ -383,6 +382,10 @@ EntityWrapper BlendTree::GetSubTreeRoot(std::string nodeName) { std::vector nodes = FindNodesByName(nodeName); + if (nodes.size() == 0) { + return EntityWrapper::Invalid; + } + std::vector subTreeRoots; for (auto it = nodes.begin(); it != nodes.end(); it++) { From d37b7c227725ed0ee724a224d22c66bc8e1c88fa Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Fri, 4 Mar 2016 02:55:19 +0100 Subject: [PATCH 226/252] fixup! First attempt at AssaultWeapon animations! --- src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp index 7d3b8615..fa1b3ca2 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -203,7 +203,7 @@ void AssaultWeaponBehaviour::fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi // Play animation EntityWrapper modelEntity = wi.FirstPersonEntity.Parent().Parent(); if (modelEntity.Valid()) { - EntityWrapper blendTree = modelEntity.FirstChildByName("PrimaryBlendTree"); + EntityWrapper blendTree = modelEntity.FirstChildByName("BlendTreeAssaultWeapon"); EntityWrapper fireBlend = blendTree.FirstChildByName("Fire"); Events::AutoAnimationBlend eFireBlend; From 03ea9bcf40607eff39b1dc781462cc730c572471 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Fri, 4 Mar 2016 03:00:03 +0100 Subject: [PATCH 227/252] fixup! Duration no longer needed --- src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp index fa1b3ca2..e181daf6 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -211,7 +211,6 @@ void AssaultWeaponBehaviour::fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi eFireBlend.NodeName = "Fire"; eFireBlend.Restart = true; eFireBlend.Start = true; - eFireBlend.Duration = 0.0001; m_EventBroker->Publish(eFireBlend); Events::AutoAnimationBlend eIdleBlend; From 103fe98fe2b0add7d6679517b81fe688a3d96f63 Mon Sep 17 00:00:00 2001 From: Tleety Date: Fri, 4 Mar 2016 03:06:42 +0100 Subject: [PATCH 228/252] KD now updated --- src/Game/Systems/ScoreScreenSystem.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Game/Systems/ScoreScreenSystem.cpp b/src/Game/Systems/ScoreScreenSystem.cpp index 2ad45f53..57b7a4da 100644 --- a/src/Game/Systems/ScoreScreenSystem.cpp +++ b/src/Game/Systems/ScoreScreenSystem.cpp @@ -66,6 +66,9 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& //Update Kills for child (int&)child["ScoreIdentity"]["Deaths"] = it->second.Deaths; //KD is not updated at the moment. + if (it->second.Deaths != 0) { + (double&)child["ScoreIdentity"]["KD"] = it->second.Kills/it->second.Deaths; + } //Update position for child glm::vec3 offset = (glm::vec3)entity["ScoreScreen"]["Offset"]; From dbafab2cef0fc7be4fca69dc3664b56b086f583a Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Fri, 4 Mar 2016 03:07:36 +0100 Subject: [PATCH 229/252] fixup! First attempt at AssaultWeapon animations! --- src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp index e181daf6..3918e9b8 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -103,7 +103,7 @@ void AssaultWeaponBehaviour::OnReload(ComponentWrapper cWeapon, WeaponInfo& wi) // Play animation EntityWrapper modelEntity = wi.FirstPersonEntity.Parent().Parent(); if (modelEntity.Valid()) { - EntityWrapper blendTree = modelEntity.FirstChildByName("PrimaryBlendTree"); + EntityWrapper blendTree = modelEntity.FirstChildByName("AssaultWeaponBlendTree"); EntityWrapper reloadBlend = blendTree.FirstChildByName("Reload"); Events::AutoAnimationBlend eFireBlend; From 0398006fdcb023af4162c2be60c92fde0aa08f0e Mon Sep 17 00:00:00 2001 From: Jocke Date: Fri, 4 Mar 2016 03:19:41 +0100 Subject: [PATCH 230/252] added safety ifs and renamed dasheffect to sprinteffect --- src/Game/Systems/PlayerMovementSystem.cpp | 26 ++++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index ab4ac6a1..025a8b70 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -38,22 +38,28 @@ void PlayerMovementSystem::Update(double dt) // Spawn one afterimage for each player that sprints. EntityWrapper player(m_World, cSprint.EntityID); auto entityFile = ResourceManager::Load("Schema/Entities/SprintEffect.xml"); - EntityWrapper dashEffect = entityFile->MergeInto(m_World); + EntityWrapper sprintEffect = entityFile->MergeInto(m_World); auto playerModel = player.FirstChildByName("PlayerModel"); if (!playerModel.Valid()) { continue; } + if (!playerModel.HasComponent("Model")) { + continue; + } + if (!playerModel.HasComponent("Animation")) { + continue; + } auto playerEntityModel = playerModel["Model"]; auto playerEntityAnimation = playerModel["Animation"]; - playerEntityModel.Copy(dashEffect["Model"]); - playerEntityAnimation.Copy(dashEffect["Animation"]); - dashEffect["ExplosionEffect"]["EndColor"] = (glm::vec4)playerEntityModel["Color"]; - ((glm::vec4&)dashEffect["ExplosionEffect"]["EndColor"]).w = 0.f; - dashEffect["Animation"]["Speed1"] = 0.0; - dashEffect["Animation"]["Speed2"] = 0.0; - dashEffect["Animation"]["Speed3"] = 0.0; - dashEffect["Transform"]["Position"] = (glm::vec3)player["Transform"]["Position"]; - dashEffect["Transform"]["Orientation"] = (glm::vec3)player["Transform"]["Orientation"]; + playerEntityModel.Copy(sprintEffect["Model"]); + playerEntityAnimation.Copy(sprintEffect["Animation"]); + sprintEffect["ExplosionEffect"]["EndColor"] = (glm::vec4)playerEntityModel["Color"]; + ((glm::vec4&)sprintEffect["ExplosionEffect"]["EndColor"]).w = 0.f; + sprintEffect["Animation"]["Speed1"] = 0.0; + sprintEffect["Animation"]["Speed2"] = 0.0; + sprintEffect["Animation"]["Speed3"] = 0.0; + sprintEffect["Transform"]["Position"] = (glm::vec3)player["Transform"]["Position"]; + sprintEffect["Transform"]["Orientation"] = (glm::vec3)player["Transform"]["Orientation"]; } } } From 2507516a85c049925dea86e4239b1393934e9bd2 Mon Sep 17 00:00:00 2001 From: Jocke Date: Fri, 4 Mar 2016 03:28:58 +0100 Subject: [PATCH 231/252] Tweaked values for the effect to look better --- resources/Schema/Entities/SprintEffect.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/Schema/Entities/SprintEffect.xml b/resources/Schema/Entities/SprintEffect.xml index ab897cf5..6e892f8f 100644 --- a/resources/Schema/Entities/SprintEffect.xml +++ b/resources/Schema/Entities/SprintEffect.xml @@ -8,11 +8,11 @@ - 0.1 + 0.15 - 0.1 + 0.15 From 19ee66fc75ff6946622dd2735bd8e927773212ce Mon Sep 17 00:00:00 2001 From: Tleety Date: Fri, 4 Mar 2016 03:57:37 +0100 Subject: [PATCH 232/252] Fix --- resources/Schema/Entities/PlayerHUD.xml | 399 ++++++++++++++++++++++++ src/Game/Systems/ScoreScreenSystem.cpp | 3 - 2 files changed, 399 insertions(+), 3 deletions(-) create mode 100644 resources/Schema/Entities/PlayerHUD.xml diff --git a/resources/Schema/Entities/PlayerHUD.xml b/resources/Schema/Entities/PlayerHUD.xml new file mode 100644 index 00000000..e3e9165b --- /dev/null +++ b/resources/Schema/Entities/PlayerHUD.xml @@ -0,0 +1,399 @@ + + + + + + + + + + + + + + Textures/Weapons/Crosshair/SmallThickHoleDot.png + + false + + + + + + + + + + + + Schema/Entities/HitMarker.xml + + + + + + + + + + + + + + 1 + + + + + Textures/HUD/HealthHudTriMain.png + + + + + + + + + + + + + + + + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + + + + + + + 1 + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 2 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 3 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 4 + + + 1 + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 1 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + 1 + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + Models/Widgets/Arrows/Arrow5.mesh + + + + + + + + + + + + + + + + + diff --git a/src/Game/Systems/ScoreScreenSystem.cpp b/src/Game/Systems/ScoreScreenSystem.cpp index 57b7a4da..6166e892 100644 --- a/src/Game/Systems/ScoreScreenSystem.cpp +++ b/src/Game/Systems/ScoreScreenSystem.cpp @@ -21,9 +21,6 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& return; } - int redTeamEnum; - int blueTeamEnum; - int spectatorTeamEnum; int currentTeam = 0; if(entity.HasComponent("Team")) { From 1f047ea30033d6e1dcc924645c4c7cab0d38b745 Mon Sep 17 00:00:00 2001 From: antc13 Date: Fri, 4 Mar 2016 04:22:04 +0100 Subject: [PATCH 233/252] Latest Map version (Hopefully) Now with textures. Made some very minor tweaks as well, by removing duplicated meshes. --- assets | 2 +- .../Schema/Entities/NewMap2version5NEW.xml | 8768 +++++++++++++++++ 2 files changed, 8769 insertions(+), 1 deletion(-) create mode 100644 resources/Schema/Entities/NewMap2version5NEW.xml diff --git a/assets b/assets index 7a6d7078..5d761454 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 7a6d70787b036d8ae8763b69ae6ad098bf221c22 +Subproject commit 5d7614549bfb6c497bfee12e2e295293a08e8e5e diff --git a/resources/Schema/Entities/NewMap2version5NEW.xml b/resources/Schema/Entities/NewMap2version5NEW.xml new file mode 100644 index 00000000..2925f516 --- /dev/null +++ b/resources/Schema/Entities/NewMap2version5NEW.xml @@ -0,0 +1,8768 @@ + + + + + + + + + + + + + + + + + + 2 + Models/Props/GroundTest.mesh + + + + + + + + Models/Props/Walls/SciFiWallTop.mesh + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + true + + + + + + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall1.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall2.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallSmall3.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall4.mesh + + + + + + + + + + + + Models/Highgrounds/Highground1.mesh + + + + + + + + + + Models/Highgrounds/Highground2.mesh + + + + + + + + + + + Models/Highgrounds/Highground3.mesh + + + + + + + + + + + Models/Highgrounds/Highground24.mesh + + + + + + + + + + + Models/Highgrounds/Hg13.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg25.mesh + + + + + + + + + + + + Models/Highgrounds/Hg26.mesh + + + + + + + + + + + + Models/Highgrounds/Hg9.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg4.mesh + + + + + + + + + + + + + + Models/Highgrounds/Hg10.mesh + + + + + + + + + + + + + + Models/Highgrounds/Hg19.mesh + + + + + + + + + + + + + + Models/Highgrounds/Hg19.mesh + + + + + + + + + + + + + + + Models/Highgrounds/Highground12.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg16.mesh + + + + + + + + + + + + Models/Highgrounds/Hg15.mesh + + + + + + + + + + + + Models/Highgrounds/Hg14.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg13.mesh + + + + + + + + + + + + Models/Highgrounds/Hg11.mesh + + + + + + + + + + + + Models/Highgrounds/Hg20.mesh + + + + + + + + + + + + Models/Highgrounds/Hg18.mesh + + + + + + + + + + + + Models/Highgrounds/Hg19.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg17.mesh + + + + + + + + + + + + + + + Models/Highgrounds/Hg8.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg7.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg3.mesh + + + + + + + + + + + + + + + Models/Highgrounds/Highground3.mesh + + + + + + + + + + + + Models/Highgrounds/Highground1.mesh + + + + + + + + + + + Models/Highgrounds/Highground2.mesh + + + + + + + + + + + + + + Models/Highgrounds/Hg1.mesh + + + + + + + + + + + Models/Highgrounds/Hg2.mesh + + + + + + + + + + + + + + Models/Highgrounds/Highground5.mesh + + + + + + + + + + + + Models/Highgrounds/Hg7.mesh + + + + + + + + + + + + Models/Highgrounds/Hg17.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg19.mesh + + + + + + + + + + + + Models/Highgrounds/Hg18.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg20.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg6.mesh + + + + + + + + + + + + Models/Highgrounds/Hg8.mesh + + + + + + + + + + + + Models/Highgrounds/Hg10.mesh + + + + + + + + + + + + Models/Highgrounds/Hg4.mesh + + + + + + + + + + + + Models/Highgrounds/Hg16.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg9.mesh + + + + + + + + + + + + Models/Highgrounds/Hg3.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg19.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Highgrounds/Hg10.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + + + Models/Highgrounds/Highground22.mesh + + + + + + + + + + + + Models/Highgrounds/Hg8.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg19.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg21.mesh + + + + + + + + + + + + Models/Highgrounds/Hg11.mesh + + + + + + + + + + + + Models/Highgrounds/Hg3.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg17.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg8.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + + + Models/Highgrounds/Hg28.mesh + + + + + + + + + + + Models/Highgrounds/Hg10.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg27.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg15.mesh + + + + + + + + + + + + + + Models/Highgrounds/Hg13.mesh + + + + + + + + + + + + + + + Models/Highgrounds/Hg27.mesh + + + + + + + + + + + + Models/Highgrounds/Hg23.mesh + + + + + + + + + + + + + + + Models/Highgrounds/Hg27.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg23.mesh + + + + + + + + + + + + + + + Models/Highgrounds/Hg28.mesh + + + + + + + + + + + + Models/Highgrounds/Hg10.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg27.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg15.mesh + + + + + + + + + + + + + + Models/Highgrounds/Hg13.mesh + + + + + + + + + + + + + + + Models/Highgrounds/Hg1.mesh + + + + + + + + + + + + Models/Highgrounds/Hg2.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar3Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar3Red.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 5 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 4 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 2 + + + + + + + + + + + + 3 + + + + + + + + + + + + 2 + 1 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 4 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/smallWall3.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 4 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 3 + + + + + + + + + + + + 2 + + + + + + + + + + + + 2 + 1 + + + + + + + + + + + + + + 4 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar3Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 4 + Models/Props/Pillars/SciFiPillar3Blue.mesh + + + + + + + + + + + + + + + + + + + + + + 10 + + + + + + + + + + + 1 + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + + 10 + + + + + + + + + + + 1 + + + + + + + + + + + + 10 + + + + + + + + + + + + + + + + + + + Schema/Entities/PlayerRed.xml + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 3 + + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 15 + 1 + + + + + + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointBlue.mesh + + + + + + + + + + -15 + + + + 4 + + + + + + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 15 + 2 + + + + + + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointRed.mesh + + + + + + + + + + 15 + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + + + Schema/Entities/Player.xml + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + From 177667eef5c310e6bc955e38cffc849bfa9b6ea8 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Fri, 4 Mar 2016 05:02:25 +0100 Subject: [PATCH 234/252] The only working branch ever --- include/Game/Systems/Weapon/WeaponBehaviour.h | 33 + resources/Schema/Components/AssaultWeapon.xml | 2 +- .../Schema/Entities/DefenderWeaponViewRed.xml | 99 -- .../Entities/DefenderWeaponWorldRed.xml | 41 - resources/Schema/Entities/Player.xml | 129 +- .../Schema/Entities/PlayerDefenderBlue.xml | 1239 +++++++++++++++++ resources/Schema/Entities/Spawnpoint | 32 - resources/Schema/Entities/Testingu | 45 - .../Schema/Entities/WeaponAssaultBlueView.xml | 6 + .../Schema/Entities/WeaponAssaultRedView.xml | 103 -- .../Schema/Entities/WeaponAssaultRedWorld.xml | 34 - ...ponView.xml => WeaponDefenderBlueView.xml} | 20 +- ...nWorld.xml => WeaponDefenderBlueWorld.xml} | 0 resources/Schema/Entities/temp | 38 - resources/Schema/Entities/yeeee.xml | 122 -- src/Game/Game.cpp | 1 - .../Systems/Weapon/AssaultWeaponBehaviour.cpp | 59 +- 17 files changed, 1385 insertions(+), 618 deletions(-) delete mode 100755 resources/Schema/Entities/DefenderWeaponViewRed.xml delete mode 100755 resources/Schema/Entities/DefenderWeaponWorldRed.xml create mode 100644 resources/Schema/Entities/PlayerDefenderBlue.xml delete mode 100644 resources/Schema/Entities/Spawnpoint delete mode 100644 resources/Schema/Entities/Testingu delete mode 100644 resources/Schema/Entities/WeaponAssaultRedView.xml delete mode 100644 resources/Schema/Entities/WeaponAssaultRedWorld.xml rename resources/Schema/Entities/{DefenderWeaponView.xml => WeaponDefenderBlueView.xml} (97%) mode change 100755 => 100644 rename resources/Schema/Entities/{DefenderWeaponWorld.xml => WeaponDefenderBlueWorld.xml} (100%) mode change 100755 => 100644 delete mode 100644 resources/Schema/Entities/temp delete mode 100644 resources/Schema/Entities/yeeee.xml diff --git a/include/Game/Systems/Weapon/WeaponBehaviour.h b/include/Game/Systems/Weapon/WeaponBehaviour.h index d4520c9f..3cda172e 100644 --- a/include/Game/Systems/Weapon/WeaponBehaviour.h +++ b/include/Game/Systems/Weapon/WeaponBehaviour.h @@ -94,6 +94,39 @@ protected: } } + void playAnimationAndReturn(EntityWrapper weaponModelEntity, const std::string& subTreeName, const std::string& animationNodeName) + { + EntityWrapper root = weaponModelEntity.FirstParentWithComponent("Model"); + if (!root.Valid()) { + return; + } + + EntityWrapper subTree = root.FirstChildByName(subTreeName); + if (!subTree.Valid()) { + return; + } + + EntityWrapper animationNode = subTree.FirstChildByName(animationNodeName); + if (!animationNode.Valid()) { + return; + } + + Events::AutoAnimationBlend eFireBlend; + eFireBlend.RootNode = root; + eFireBlend.NodeName = animationNodeName; + eFireBlend.Restart = true; + eFireBlend.Start = true; + m_EventBroker->Publish(eFireBlend); + + Events::AutoAnimationBlend eIdleBlend; + eIdleBlend.RootNode = root; + eIdleBlend.NodeName = "Idle"; + eIdleBlend.AnimationEntity = animationNode; + eIdleBlend.Delay = -0.2; + eIdleBlend.Duration = 0.2; + m_EventBroker->Publish(eIdleBlend); + } + private: EventRelay m_ESetCamera; bool _OnSetCamera(const Events::SetCamera& e) diff --git a/resources/Schema/Components/AssaultWeapon.xml b/resources/Schema/Components/AssaultWeapon.xml index 263a840a..0cb381c2 100755 --- a/resources/Schema/Components/AssaultWeapon.xml +++ b/resources/Schema/Components/AssaultWeapon.xml @@ -11,7 +11,7 @@ 420 0.03 0.18 - 2 + 1.65 0.5 false 0 diff --git a/resources/Schema/Entities/DefenderWeaponViewRed.xml b/resources/Schema/Entities/DefenderWeaponViewRed.xml deleted file mode 100755 index b5b1c322..00000000 --- a/resources/Schema/Entities/DefenderWeaponViewRed.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - R_Arm_Weapon_Joint - - - - Models/Weapons/Red/DefenderGunRed.mesh - - - - - - - - - - - Schema/Entities/RayRed.xml - - - - - - - - - - - Schema/Entities/ReloadEffectView.xml - - - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - - - - - - 32 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - 360 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - - diff --git a/resources/Schema/Entities/DefenderWeaponWorldRed.xml b/resources/Schema/Entities/DefenderWeaponWorldRed.xml deleted file mode 100755 index 7f697304..00000000 --- a/resources/Schema/Entities/DefenderWeaponWorldRed.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - R_Arm_Weapon_Joint - - - - Models/Weapons/Red/DefenderGunRed.mesh - - - - - - - - - - - - Schema/Entities/RayRed.xml - - - - - - - - - - - Schema/Entities/ReloadEffectWorld.xml - - - - - - - - diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index d34dba32..dfcf40a3 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -484,12 +484,10 @@ - - BlendTreeAssaultWeapon - BlendTreeSecondaryWeapon - 0 - true - + + Run + FinalBlend + Models/Characters/Defender/FirstPersonDefenderBlue.mesh @@ -508,8 +506,8 @@ Schema/Entities/WeaponAssaultBlueView.xml - - + + @@ -526,50 +524,73 @@ Schema/Entities/SidearmWeaponView.xml - - + + - + - Idle - WeaponAction + BlendTreeAssaultWeapon + BlendTreeSecondaryWeapon 0 true - + - Fire - Reload - 1 + Idle + WeaponAction + 0 + true - + - - ShootShotgunF - 1 - true - false - + + Fire + Reload + 0 + - + + + + + ShootShotgunF + 1 + false + + + + + + + + + ReloadSwitchF + 1 + false + + + + + + - + - ReloadSwitchF - + IdleF + 1 true @@ -579,22 +600,22 @@ - + - - IdleF - - 1 - true - - + + + RunF + + 1 + true + @@ -651,8 +672,8 @@ Schema/Entities/WeaponAssaultBlueWorld.xml - - + + @@ -672,8 +693,8 @@ Schema/Entities/SidearmWeaponWorld.xml - - + + @@ -780,7 +801,7 @@ CrouchStrafeLeftF - + 1 true @@ -792,7 +813,7 @@ CrouchStrafeRightF - + 1 true @@ -806,7 +827,7 @@ CrouchWalkF - + 1 true @@ -863,7 +884,7 @@ WalkF - + 1 true @@ -875,7 +896,7 @@ RunF - + 1 true @@ -895,11 +916,11 @@ - + - StrafeLeftF - + StrafeRightF + 1 true @@ -907,11 +928,11 @@ - + - StrafeRightF - + StrafeLeftF + 1 true @@ -927,7 +948,7 @@ IdleF - + 1 true @@ -1096,7 +1117,7 @@ IdleAssaultRifleU - + 1 true @@ -1108,7 +1129,7 @@ IdleSecWepU - + 1 true diff --git a/resources/Schema/Entities/PlayerDefenderBlue.xml b/resources/Schema/Entities/PlayerDefenderBlue.xml new file mode 100644 index 00000000..aef660a3 --- /dev/null +++ b/resources/Schema/Entities/PlayerDefenderBlue.xml @@ -0,0 +1,1239 @@ + + + + + + + + + + + + + + + + + + + + + + + + 5 + + + + + + + + + + + + 0.10000000149011612 + 300 + + + + + + + + + + Models/Widgets/Camera.mesh + false + + + + + + + + + + + + + + + + + + + Textures/Weapons/Crosshair/SmallThickHoleDot.png + + false + + + + + + + + + + + + Schema/Entities/HitMarker.xml + + + + + + + + + + + + + + 1 + + + + + Textures/HealthHUD3.png + + + + + + + + + + + + + + + + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + 0.0 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + 1 + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + 2 + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + 3 + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 1 + + + + 4 + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + 1 + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 1 + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + + Models/Widgets/Arrows/Arrow5.mesh + + + + + + + + + + + + + + + BlendTreeAssaultWeapon + BlendTreeSecondaryWeapon + 0 + true + + + Models/Characters/Defender/FirstPersonDefenderBlue.mesh + + + + + + + + R_Arm_Weapon_Joint + true + + + DefenderWeapon + + + Schema/Entities/WeaponDefenderBlueView.xml + + + + + + + + + + + + + R_Arm_Weapon_Joint + + + SidearmWeapon + + + Schema/Entities/SidearmWeaponView.xml + + + + + + + + + + + + Idle + WeaponAction + 0 + true + + + + + + + + Fire + Reload + 1 + + + + + + + + ShootShotgunF + + 1 + false + + + + + + + + + ReloadSwitchF + + 1 + true + + + + + + + + + + + IdleF + + 1 + true + + + + + + + + + + + + + + + + + + + + + 0.10000000149011612 + 300 + + + Models/Widgets/Camera.mesh + false + + + + + + + + + + + + BlendTreeAim + BlendTreeAssault + + + + + Models/Characters/Assault/AssaultBlue.mesh + + false + + + + + + + + R_Arm_Weapon_Joint + + + AssaultWeapon + + + + + + Schema/Entities/WeaponAssaultBlueWorld.xml + + + + + + + + + + + + R_Arm_Weapon_Joint + + + SidearmWeapon + + + + + + Schema/Entities/SidearmWeaponWorld.xml + + + + + + + + + + + + AimPrimary + AimSecondary + 0 + true + + + + + + + + AimSecWepA + + false + true + + + + + + + + + AimRifleA + + false + true + + + + + + + + + + + ReloadSwitchBlend + MovementBlend + + + + + + + + StandCrouchBlend + JumpDashBlend + 2.5146881298480398e-63 + true + + + + + + + + StandMovement + CrouchMovement + 0 + true + + + + + + + + MovementBlend + Idle + 1 + + + + + + + + Walk + StrafeLRBlend + 0 + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + CrouchStrafeLeftF + + 1 + true + + + + + + + + + CrouchStrafeRightF + + 1 + true + + + + + + + + + + + CrouchWalkF + + 1 + true + + + + + + + + + + + CrouchF + + 1 + + + + + + + + + + + MovementBlend + Idle + 1 + + + + + + + + RunWalkBlend + StrafeLRBlend + 2.4565650245976452e-16 + + + + + + + + Walk + Run + 1.2938206818383024e-24 + + + + + + + + WalkF + + 1 + true + + + + + + + + + RunF + + 1 + true + + + + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + StrafeRightF + + 1 + true + + + + + + + + + StrafeLeftF + + 1 + true + + + + + + + + + + + + + IdleF + + 1 + true + + + + + + + + + + + + + Jump + DashBlend + 1 + true + + + + + + + + JumpF + + 1 + false + + + + + + + + + DashFBBlend + DashLRBlend + 0.014621149736541383 + + + + + + + + DashForward + DashBackward + 0.014363533804961248 + + + + + + + + DashForwardF + + 1 + false + + + + + + + + + DashBackwardF + + 1 + false + + + + + + + + + + + DashLeft + DashRight + 4.3244885367500671e-16 + + + + + + + + DashLeftF + + 1 + false + + + + + + + + + DashRightF + + 1 + false + + + + + + + + + + + + + + + + + ReloadSwitch + WeaponActionBlend + 1 + true + + + + + + + + ReloadSwitchU + + 1 + + + + + + + + + IdleBlend + ShootBlend + 0 + + + + + + + + IdlePrimary + IdleSecondary + 0 + + + + + + + + IdleAssaultRifleU + + 1 + true + + + + + + + + + IdleSecWepU + + 1 + true + + + + + + + + + + + ShootPrimary + ShootSecondary + 0 + + + + + + + + ShootFastRifleU + + 1 + + + + + + + + + ShootSecWepFastU + + + + + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + false + + + + + + + + + + + + Models/Core/UnitCube.mesh + + false + + + + + + + + + + + Insert name here + Fonts/DroidSans.ttf,100 + + + + + + + + + + + + + + Textures/Icons/Arrow.png + + false + + + + + 50 + true + + + + + + + + + + + + Schema/Entities/DefenderShield.xml + + + + + + + + + + diff --git a/resources/Schema/Entities/Spawnpoint b/resources/Schema/Entities/Spawnpoint deleted file mode 100644 index a53aaa08..00000000 --- a/resources/Schema/Entities/Spawnpoint +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - Models/Core/UnitCube.mesh - - - Schema/Entities/Player.xml - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/Schema/Entities/Testingu b/resources/Schema/Entities/Testingu deleted file mode 100644 index 145550f4..00000000 --- a/resources/Schema/Entities/Testingu +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - Models/Core/UnitPlane.mesh - - - - - - - - - - - - Schema/Entities/Player.xml - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/Schema/Entities/WeaponAssaultBlueView.xml b/resources/Schema/Entities/WeaponAssaultBlueView.xml index b5c87674..9b10618b 100644 --- a/resources/Schema/Entities/WeaponAssaultBlueView.xml +++ b/resources/Schema/Entities/WeaponAssaultBlueView.xml @@ -98,6 +98,12 @@ + + + + + + diff --git a/resources/Schema/Entities/WeaponAssaultRedView.xml b/resources/Schema/Entities/WeaponAssaultRedView.xml deleted file mode 100644 index 322b1439..00000000 --- a/resources/Schema/Entities/WeaponAssaultRedView.xml +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - Models/Weapons/Red/AssaultWeaponRed.mesh - - - - - - - - - Schema/Entities/RayRed.xml - - - - - - - - - - - - Schema/Entities/ReloadEffectView.xml - - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - - - - - - 32 - Fonts/DroidSans.ttf,64 - - - - Player - AssaultWeapon - MagazineAmmo - - - - - - - - - - - 320 - Fonts/DroidSans.ttf,64 - - - - Player - AssaultWeapon - Ammo - - - - - - - - - - - - - - - diff --git a/resources/Schema/Entities/WeaponAssaultRedWorld.xml b/resources/Schema/Entities/WeaponAssaultRedWorld.xml deleted file mode 100644 index 68d78d03..00000000 --- a/resources/Schema/Entities/WeaponAssaultRedWorld.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - Models/Weapons/Red/AssaultWeaponRed.mesh - - - - - - - - - Schema/Entities/RayRed.xml - - - - - - - - - - - Schema/Entities/ReloadEffectWorld.xml - - - - - - - - diff --git a/resources/Schema/Entities/DefenderWeaponView.xml b/resources/Schema/Entities/WeaponDefenderBlueView.xml old mode 100755 new mode 100644 similarity index 97% rename from resources/Schema/Entities/DefenderWeaponView.xml rename to resources/Schema/Entities/WeaponDefenderBlueView.xml index 0886ac67..6ec4b452 --- a/resources/Schema/Entities/DefenderWeaponView.xml +++ b/resources/Schema/Entities/WeaponDefenderBlueView.xml @@ -60,16 +60,16 @@ + + 8 + Fonts/DroidSans.ttf,64 + + Player DefenderWeapon MagazineAmmo - - 0 - Fonts/DroidSans.ttf,64 - - @@ -78,16 +78,16 @@ + + 64 + Fonts/DroidSans.ttf,64 + + Player DefenderWeapon Ammo - - 0 - Fonts/DroidSans.ttf,64 - - diff --git a/resources/Schema/Entities/DefenderWeaponWorld.xml b/resources/Schema/Entities/WeaponDefenderBlueWorld.xml old mode 100755 new mode 100644 similarity index 100% rename from resources/Schema/Entities/DefenderWeaponWorld.xml rename to resources/Schema/Entities/WeaponDefenderBlueWorld.xml diff --git a/resources/Schema/Entities/temp b/resources/Schema/Entities/temp deleted file mode 100644 index baf4ce61..00000000 --- a/resources/Schema/Entities/temp +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - 0 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - 360 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - diff --git a/resources/Schema/Entities/yeeee.xml b/resources/Schema/Entities/yeeee.xml deleted file mode 100644 index d3853b8f..00000000 --- a/resources/Schema/Entities/yeeee.xml +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - AimAdditive - BlendOverride - - - Models/Characters/Assault/AssaultAnimations.mesh - - - - - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - - - - - - - - - - - AimRifleA - - true - - - - - - - - - ShootRifleAnimation - MovementBlend - - - - - - - - ShootFastRifleU - - 1 - - - - - - - - - BlendWalkRun - StrafeAnimation - 1 - - - - - - - - StrafeRightF - - 1 - - - - - - - - - RunAnimtaion - WalkAnimation - 0.43000054359436035 - - - - - - - - RunF - - 1 - - - - - - - - - WalkF - - 1 - - - - - - - - - - - - - - diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 18e6fd5c..d5622eec 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -143,7 +143,6 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); - m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp index 3918e9b8..cdb0a563 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -56,6 +56,21 @@ void AssaultWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& } } + // Update first person run animation + /*ComponentWrapper cPlayer = wi.Player["Player"]; + ComponentWrapper cPhysics = wi.Player["Physics"]; + const float& movementSpeed = cPlayer["MovementSpeed"]; + float speed = glm::length((const glm::vec3&)cPhysics["Velocity"]); + float animationSpeed = glm::max(speed, movementSpeed) / movementSpeed; + EntityWrapper rootNode = wi.FirstPersonEntity.FirstParentWithComponent("Model"); + if (rootNode.Valid()) { + EntityWrapper animationNode = rootNode.FirstChildByName("Run"); + if (animationNode.Valid()) { + (bool&)animationNode["Animation"]["Play"] = animationSpeed > 0; + (double&)animationNode["Animation"]["Speed"] = animationSpeed; + } + }*/ + // Fire if we're able to fire if (canFire(cWeapon, wi)) { fireBullet(cWeapon, wi); @@ -101,25 +116,12 @@ void AssaultWeaponBehaviour::OnReload(ComponentWrapper cWeapon, WeaponInfo& wi) reloadTimer = reloadTime; // Play animation - EntityWrapper modelEntity = wi.FirstPersonEntity.Parent().Parent(); - if (modelEntity.Valid()) { - EntityWrapper blendTree = modelEntity.FirstChildByName("AssaultWeaponBlendTree"); - EntityWrapper reloadBlend = blendTree.FirstChildByName("Reload"); + playAnimationAndReturn(wi.FirstPersonEntity, "BlendTreeAssaultWeapon", "Reload"); - Events::AutoAnimationBlend eFireBlend; - eFireBlend.RootNode = modelEntity; - eFireBlend.NodeName = "Reload"; - eFireBlend.Restart = true; - eFireBlend.Start = true; - m_EventBroker->Publish(eFireBlend); - - Events::AutoAnimationBlend eIdleBlend; - eIdleBlend.RootNode = modelEntity; - eIdleBlend.NodeName = "Idle"; - eIdleBlend.AnimationEntity = reloadBlend; - eIdleBlend.Delay = -0.2; - eIdleBlend.Duration = 0.2; - m_EventBroker->Publish(eIdleBlend); + // Spawn explosion effect + EntityWrapper reloadEffectSpawner = wi.FirstPersonEntity.FirstChildByName("FirstPersonReloadSpawner"); + if (reloadEffectSpawner.Valid()) { + SpawnerSystem::Spawn(reloadEffectSpawner, reloadEffectSpawner); } } @@ -201,26 +203,7 @@ void AssaultWeaponBehaviour::fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi } // Play animation - EntityWrapper modelEntity = wi.FirstPersonEntity.Parent().Parent(); - if (modelEntity.Valid()) { - EntityWrapper blendTree = modelEntity.FirstChildByName("BlendTreeAssaultWeapon"); - EntityWrapper fireBlend = blendTree.FirstChildByName("Fire"); - - Events::AutoAnimationBlend eFireBlend; - eFireBlend.RootNode = modelEntity; - eFireBlend.NodeName = "Fire"; - eFireBlend.Restart = true; - eFireBlend.Start = true; - m_EventBroker->Publish(eFireBlend); - - Events::AutoAnimationBlend eIdleBlend; - eIdleBlend.RootNode = modelEntity; - eIdleBlend.NodeName = "Idle"; - eIdleBlend.AnimationEntity = fireBlend; - eIdleBlend.Delay = -0.2; - eIdleBlend.Duration = 0.2; - m_EventBroker->Publish(eIdleBlend); - } + playAnimationAndReturn(wi.FirstPersonEntity, "BlendTreeAssaultWeapon", "Fire"); } bool AssaultWeaponBehaviour::canFire(ComponentWrapper cWeapon, WeaponInfo& wi) From eec40b651986b60a65a4e68af832759f3c18f4af Mon Sep 17 00:00:00 2001 From: Jocke Date: Fri, 4 Mar 2016 05:10:18 +0100 Subject: [PATCH 235/252] We can now read larger packets than 65536 bytes in TCPClient::readBuffer() --- src/Engine/Network/TCPClient.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Engine/Network/TCPClient.cpp b/src/Engine/Network/TCPClient.cpp index 8bfa9ded..b3aa7d1b 100644 --- a/src/Engine/Network/TCPClient.cpp +++ b/src/Engine/Network/TCPClient.cpp @@ -76,7 +76,7 @@ size_t TCPClient::readBuffer() memcpy(&sizeOfPacket, m_ReadBuffer, sizeof(int)); if (sizeOfPacket > m_Socket->available()) { LOG_WARNING("TCPClient::readBuffer(): We haven't got the whole packet yet."); - return 0; + //return 0; } // if the buffer is to small increase the size of it // TODO if message is huge 1 time the buffer will not decrease. @@ -85,12 +85,15 @@ size_t TCPClient::readBuffer() m_ReadBuffer = new char[sizeOfPacket]; m_BufferSize = sizeOfPacket; } - // Read the rest of the message - size_t bytesReceived = m_Socket->read_some(boost - ::asio::buffer((void*)(m_ReadBuffer), sizeOfPacket), - error); - if (error) { - //LOG_ERROR("receive: %s", error.message().c_str()); + size_t bytesReceived = 0; + while (sizeOfPacket > bytesReceived) { + // Read the rest of the message + bytesReceived += m_Socket->read_some(boost + ::asio::buffer((void*)(m_ReadBuffer), sizeOfPacket - bytesReceived), + error); + if (error) { + //LOG_ERROR("receive: %s", error.message().c_str()); + } } if (sizeOfPacket > 1000000) LOG_WARNING("The packets received are bigger than 1MB"); From 5b80ba4398192a60f62a0270690c0e70c64193e5 Mon Sep 17 00:00:00 2001 From: Jocke Date: Fri, 4 Mar 2016 08:22:48 +0100 Subject: [PATCH 236/252] Made 3 new healthHUDs 1 for each class. --- assets | 2 +- .../Schema/Entities/HealthHUDAssault.xml | 156 ++++++++++++++++++ .../Schema/Entities/HealthHUDDefender.xml | 156 ++++++++++++++++++ resources/Schema/Entities/HealthHUDSniper.xml | 156 ++++++++++++++++++ 4 files changed, 469 insertions(+), 1 deletion(-) create mode 100644 resources/Schema/Entities/HealthHUDAssault.xml create mode 100644 resources/Schema/Entities/HealthHUDDefender.xml create mode 100644 resources/Schema/Entities/HealthHUDSniper.xml diff --git a/assets b/assets index 5d761454..d3be164b 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 5d7614549bfb6c497bfee12e2e295293a08e8e5e +Subproject commit d3be164b6929ed0f3847bf7b53c1247843a9eae6 diff --git a/resources/Schema/Entities/HealthHUDAssault.xml b/resources/Schema/Entities/HealthHUDAssault.xml new file mode 100644 index 00000000..efd91399 --- /dev/null +++ b/resources/Schema/Entities/HealthHUDAssault.xml @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + 1 + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + 1 + + + + + Textures/HealthHUD3.png + + + + + + + + + + + + + + + + + + + + + + + + Textures/Icons/Boosts/Assault-01.png + + false + + + + + + + + + + + + + + + + + Textures/Icons/Boosts/Defender-01.png + + false + + + + + + + + + + + + + + + + + Textures/Icons/Boosts/Sniper-01.png + + false + + + + + + + + + + + + + + + + + + + + Textures/Icons/Abilities/Superman-01.png + + false + + + + + + + + + + + + + 0.0 + Fonts/DroidSans.ttf,64 + + false + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/HealthHUDDefender.xml b/resources/Schema/Entities/HealthHUDDefender.xml new file mode 100644 index 00000000..504fbd21 --- /dev/null +++ b/resources/Schema/Entities/HealthHUDDefender.xml @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + 1 + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + 1 + + + + + Textures/HealthHUD3.png + + + + + + + + + + + + + + + + + + + + + + + + Textures/Icons/Boosts/Assault-01.png + + false + + + + + + + + + + + + + + + + + Textures/Icons/Boosts/Defender-01.png + + false + + + + + + + + + + + + + + + + + Textures/Icons/Boosts/Sniper-01.png + + false + + + + + + + + + + + + + + + + + + + + Textures/Icons/Abilities/SheildDots-01.png + + false + + + + + + + + + + + + + 0.0 + Fonts/DroidSans.ttf,64 + + false + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/HealthHUDSniper.xml b/resources/Schema/Entities/HealthHUDSniper.xml new file mode 100644 index 00000000..13b6dc4d --- /dev/null +++ b/resources/Schema/Entities/HealthHUDSniper.xml @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + 1 + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + 1 + + + + + Textures/HealthHUD3.png + + + + + + + + + + + + + + + + + + + + + + + + Textures/Icons/Boosts/Assault-01.png + + false + + + + + + + + + + + + + + + + + Textures/Icons/Boosts/Defender-01.png + + false + + + + + + + + + + + + + + + + + Textures/Icons/Boosts/Sniper-01.png + + false + + + + + + + + + + + + + + + + + + + + Textures/Icons/Abilities/Dash-01.png + + false + + + + + + + + + + + + + 0.0 + Fonts/DroidSans.ttf,64 + + false + + + + + + + + + + + + + + From 7ba0e4ea9d8b2e5319feaad3a8a977cba92c3f90 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Fri, 4 Mar 2016 08:35:02 +0100 Subject: [PATCH 237/252] Run, Strafe and jump animations now playing --- .../Editor/EditorCameraInputController.h | 4 +- .../Engine/Input/FirstPersonInputController.h | 96 ++++++++++++- include/Engine/Rendering/BlendTree.h | 1 + .../Engine/Rendering/EAutoAnimationBlend.h | 2 + resources/Schema/Entities/Player.xml | 13 +- src/Engine/Editor/EditorSystem.cpp | 2 +- src/Engine/Rendering/AnimationSystem.cpp | 2 +- src/Engine/Rendering/BlendTree.cpp | 16 +++ src/Game/Systems/PlayerDeathSystem.cpp | 4 - src/Game/Systems/PlayerMovementSystem.cpp | 136 +++++++++++++++++- .../Systems/Weapon/AssaultWeaponBehaviour.cpp | 2 +- 11 files changed, 253 insertions(+), 25 deletions(-) diff --git a/include/Engine/Editor/EditorCameraInputController.h b/include/Engine/Editor/EditorCameraInputController.h index 6cb31d99..257e3424 100644 --- a/include/Engine/Editor/EditorCameraInputController.h +++ b/include/Engine/Editor/EditorCameraInputController.h @@ -12,8 +12,8 @@ template class EditorCameraInputController : public FirstPersonInputController { public: - EditorCameraInputController(EventBroker* eventBroker, unsigned int playerID) - : FirstPersonInputController(eventBroker, playerID) + EditorCameraInputController(EventBroker* eventBroker, unsigned int playerID, EntityWrapper playerEntity) + : FirstPersonInputController(eventBroker, playerID, playerEntity) { EVENT_SUBSCRIBE_MEMBER(m_EMousePress, &EditorCameraInputController::OnMousePress); EVENT_SUBSCRIBE_MEMBER(m_EMouseRelease, &EditorCameraInputController::OnMouseRelease); diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index ed9469bd..2c7013e4 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -6,12 +6,13 @@ #include "../Core/ELockMouse.h" #include "../Game/Events/EDashAbility.h" #include "InputHandler.h" +#include "Rendering/EAutoAnimationBlend.h" template class FirstPersonInputController : public InputController { public: - FirstPersonInputController(EventBroker* eventBroker, int playerID); + FirstPersonInputController(EventBroker* eventBroker, int playerID, EntityWrapper playerEntity); virtual const glm::vec3 Movement() const { return m_Movement; } virtual const glm::vec3 Rotation() const { return m_Rotation; } @@ -34,6 +35,8 @@ public: protected: const int m_PlayerID; + EntityWrapper m_PlayerEntity; + bool m_MouseLocked = false; glm::vec3 m_Rotation; glm::vec3 m_Movement; @@ -65,9 +68,10 @@ protected: }; template -FirstPersonInputController::FirstPersonInputController(EventBroker* eventBroker, int playerID) +FirstPersonInputController::FirstPersonInputController(EventBroker* eventBroker, int playerID, EntityWrapper playerEntity) : InputController(eventBroker) , m_PlayerID(playerID) + , m_PlayerEntity(playerEntity) { EVENT_SUBSCRIBE_MEMBER(m_ELockMouse, &FirstPersonInputController::OnLockMouse); EVENT_SUBSCRIBE_MEMBER(m_EUnlockMouse, &FirstPersonInputController::OnUnlockMouse); @@ -118,13 +122,75 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm if (e.Command == "Forward") { float val = glm::clamp(e.Value, -1.f, 1.f); m_Movement.z = -val; + + if (m_PlayerEntity.Valid()) { + EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel"); + if (playerModel.Valid()) { + if (val > 0) { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.1; + aeb.NodeName = "Run"; + aeb.RootNode = playerModel; + aeb.Start = true; + m_EventBroker->Publish(aeb); + } else if (val < 0) { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.1; + aeb.NodeName = "Run"; + aeb.RootNode = playerModel; + aeb.Start = true; + aeb.Reverse = true; + m_EventBroker->Publish(aeb); + } else { + + } + } + } } if (e.Command == "Right") { float val = glm::clamp(e.Value, -1.f, 1.f); m_Movement.x = val; + + if (m_PlayerEntity.Valid()) { + EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel"); + + if (playerModel.Valid()) { + if (val > 0) { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.1; + aeb.NodeName = "Right"; + aeb.RootNode = playerModel; + aeb.Start = true; + m_EventBroker->Publish(aeb); + } else if (val < 0) { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.1; + aeb.NodeName = "Left"; + aeb.RootNode = playerModel; + aeb.Start = true; + m_EventBroker->Publish(aeb); + } else { + + + } + } + } + } if (glm::length2(m_Movement) > 0) { m_Movement = glm::normalize(m_Movement); + } else { + if (m_PlayerEntity.Valid()) { + EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel"); + + if (playerModel.Valid()) { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.1; + aeb.NodeName = "Idle"; + aeb.RootNode = playerModel; + m_EventBroker->Publish(aeb); + } + } } } @@ -159,6 +225,32 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm if (e.Command == "Crouch") { m_Crouching = e.Value > 0; + + if (m_PlayerEntity.Valid()) { + EntityWrapper playerModel = m_PlayerEntity.FirstChildByName("PlayerModel"); + if (playerModel.Valid()) { + if (e.Value == 0.f) { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.3; + aeb.NodeName = "StandMovement"; + aeb.RootNode = playerModel; + aeb.Start = true; + aeb.Restart = true; + aeb.SingleLevelBlend = true; + m_EventBroker->Publish(aeb); + } else if(e.Value == 1.0f) { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.3; + aeb.NodeName = "CrouchMovement"; + aeb.RootNode = playerModel; + aeb.Start = true; + aeb.Restart = true; + aeb.SingleLevelBlend = true; + m_EventBroker->Publish(aeb); + } + } + } + } if (e.Command == "SpecialAbility") { diff --git a/include/Engine/Rendering/BlendTree.h b/include/Engine/Rendering/BlendTree.h index aa06f1e6..02f4a348 100644 --- a/include/Engine/Rendering/BlendTree.h +++ b/include/Engine/Rendering/BlendTree.h @@ -62,6 +62,7 @@ public: double progress; bool Start; bool SingleBlend; + double Weight; std::unordered_map StartWeights; }; diff --git a/include/Engine/Rendering/EAutoAnimationBlend.h b/include/Engine/Rendering/EAutoAnimationBlend.h index ebd29848..29d3d612 100644 --- a/include/Engine/Rendering/EAutoAnimationBlend.h +++ b/include/Engine/Rendering/EAutoAnimationBlend.h @@ -19,6 +19,8 @@ struct AutoAnimationBlend : Event bool Restart = false; bool SingleLevelBlend = false; + double Weight = -1.0; + EntityWrapper AnimationEntity = EntityWrapper::Invalid; }; diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index d34dba32..4ff512ac 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -631,7 +631,6 @@ Models/Characters/Assault/AssaultBlue.mesh - false @@ -719,12 +718,12 @@ ReloadSwitchBlend - MovementBlend + FinalMovementBlend - + StandCrouchBlend @@ -987,7 +986,7 @@ DashForwardF - 1 + 2 false @@ -999,7 +998,7 @@ DashBackwardF - 1 + 2 false @@ -1023,7 +1022,7 @@ DashLeftF - 1 + 3 false @@ -1035,7 +1034,7 @@ DashRightF - 1 + 3 false diff --git a/src/Engine/Editor/EditorSystem.cpp b/src/Engine/Editor/EditorSystem.cpp index 62ddba88..f9cdde0b 100644 --- a/src/Engine/Editor/EditorSystem.cpp +++ b/src/Engine/Editor/EditorSystem.cpp @@ -19,7 +19,7 @@ EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame m_ActualCamera = m_EditorCamera; m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Transform"); m_EditorWorld->AttachComponent(m_EditorCamera.ID, "Camera"); - m_EditorCameraInputController = new EditorCameraInputController(m_EventBroker, -1); + m_EditorCameraInputController = new EditorCameraInputController(m_EventBroker, -1, EntityWrapper::Invalid); m_EditorGUI = new EditorGUI(m_World, m_EventBroker); m_EditorGUI->SetEntitySelectedCallback(std::bind(&EditorSystem::OnEntitySelected, this, std::placeholders::_1)); diff --git a/src/Engine/Rendering/AnimationSystem.cpp b/src/Engine/Rendering/AnimationSystem.cpp index 5bac27f9..005778e7 100644 --- a/src/Engine/Rendering/AnimationSystem.cpp +++ b/src/Engine/Rendering/AnimationSystem.cpp @@ -196,7 +196,7 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e) abj.BlendInfo.progress = 0.0; abj.BlendInfo.Start = e.Start; abj.BlendInfo.SingleBlend = e.SingleLevelBlend; - + abj.BlendInfo.Weight = e.Weight; EntityWrapper nodeEntity = subTreeRoot.FirstChildByName(e.NodeName); // more than one if (nodeEntity.Valid()) { diff --git a/src/Engine/Rendering/BlendTree.cpp b/src/Engine/Rendering/BlendTree.cpp index 9b6679ea..29bbe7e6 100644 --- a/src/Engine/Rendering/BlendTree.cpp +++ b/src/Engine/Rendering/BlendTree.cpp @@ -207,6 +207,22 @@ BlendTree::AutoBlendInfo BlendTree::AutoBlendStep(AutoBlendInfo blendInfo) { std::vector goalNodes = FindNodesByName(blendInfo.NodeName); + if(blendInfo.Weight >= 0 && blendInfo.Weight <= 1.0) { + for (auto it = goalNodes.begin(); it != goalNodes.end(); it++) { + EntityWrapper entity = (*it)->Entity; + + if (entity.Valid()) { + if (entity.HasComponent("Blend")) { + (double&)entity["Blend"]["Weight"] = blendInfo.Weight; + } + } + } + + return blendInfo; + } + + + if (blendInfo.Start) { for (auto it = goalNodes.begin(); it != goalNodes.end(); it++) { EntityWrapper entity = (*it)->Entity; diff --git a/src/Game/Systems/PlayerDeathSystem.cpp b/src/Game/Systems/PlayerDeathSystem.cpp index cbf0927f..b9a42ffc 100644 --- a/src/Game/Systems/PlayerDeathSystem.cpp +++ b/src/Game/Systems/PlayerDeathSystem.cpp @@ -45,10 +45,6 @@ void PlayerDeathSystem::createDeathEffect(EntityWrapper player) //copy the data from player to explosioneffectmodel playerEntityModel.Copy(deathEffectEW["Model"]); playerEntityAnimation.Copy(deathEffectEW["Animation"]); - //freeze the animation - deathEffectEW["Animation"]["Speed1"] = 0.0; - deathEffectEW["Animation"]["Speed2"] = 0.0; - deathEffectEW["Animation"]["Speed3"] = 0.0; //copy the models position,orientation deathEffectEW["Transform"]["Position"] = (glm::vec3)player["Transform"]["Position"]; diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index d67e77bd..8fddbe96 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -42,11 +42,25 @@ void PlayerMovementSystem::updateMovementControllers(double dt) cameraOrientation.x = glm::clamp(cameraOrientation.x, -glm::half_pi(), glm::half_pi()); // Set third person model aim pitch EntityWrapper playerModel = player.FirstChildByName("PlayerModel"); + + //Third-person aim if (playerModel.Valid()) { - //ComponentWrapper cAnimationOffset = playerModel["AnimationOffset"]; - //float pitch = cameraOrientation.x + 0.2f; - //double time = (pitch + glm::half_pi()) / glm::pi(); - //cAnimationOffset["Time"] = time; + EntityWrapper aimPrimaryEntity = playerModel.FirstChildByName("AimPrimary"); + if(aimPrimaryEntity.Valid()){ + if(aimPrimaryEntity.HasComponent("Animation")) { + float pitch = cameraOrientation.x + 0.2f; + double time = (pitch + glm::half_pi()) / glm::pi(); + (double&)aimPrimaryEntity["Animation"]["Time"] = time; + } + } + EntityWrapper aimSecondaryEntity = playerModel.FirstChildByName("AimSecondary"); + if (aimSecondaryEntity.Valid()) { + if (aimSecondaryEntity.HasComponent("Animation")) { + float pitch = cameraOrientation.x + 0.2f; + double time = (pitch + glm::half_pi()) / glm::pi(); + (double&)aimSecondaryEntity["Animation"]["Time"] = time; + } + } } } @@ -140,10 +154,64 @@ void PlayerMovementSystem::updateMovementControllers(double dt) if (isOnGround) { (bool)cPhysics["IsOnGround"] = false; velocity.y = player["Player"]["JumpSpeed"]; + + + if (player.Valid()) { + EntityWrapper playerModel = player.FirstChildByName("PlayerModel"); + if (playerModel.Valid()) { + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.15; + aeb.NodeName = "Jump"; + aeb.RootNode = playerModel; + aeb.Start = true; + aeb.Restart = true; + m_EventBroker->Publish(aeb); + } + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.25; + aeb.NodeName = "StandCrouchBlend"; + aeb.RootNode = playerModel; + aeb.Start = true; + aeb.Restart = false; + aeb.AnimationEntity = playerModel.FirstChildByName("Jump"); + m_EventBroker->Publish(aeb); + } + } + } + + } else if (player.HasComponent("DoubleJump") && !controller->DoubleJumping()) { //Enter here if player can double jump and is doing so. (bool)cPhysics["IsOnGround"] = false; velocity.y = player["DoubleJump"]["DoubleJumpSpeed"]; + + if (player.Valid()) { + EntityWrapper playerModel = player.FirstChildByName("PlayerModel"); + if (playerModel.Valid()) { + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.15; + aeb.NodeName = "Jump"; + aeb.RootNode = playerModel; + aeb.Start = true; + aeb.Restart = true; + m_EventBroker->Publish(aeb); + } + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.25; + aeb.NodeName = "StandCrouchBlend"; + aeb.RootNode = playerModel; + aeb.Start = true; + aeb.Restart = false; + aeb.AnimationEntity = playerModel.FirstChildByName("Jump"); + m_EventBroker->Publish(aeb); + } + } + } + // If IsServer and network is off this will not work if (IsClient) { //put a hexagon at the players feet @@ -234,7 +302,7 @@ void PlayerMovementSystem::playerStep(double dt) bool PlayerMovementSystem::OnPlayerSpawned(Events::PlayerSpawned& e) { // When a player spawns, create an input controller for them - m_PlayerInputControllers[e.Player] = new FirstPersonInputController(m_EventBroker, e.PlayerID); + m_PlayerInputControllers[e.Player] = new FirstPersonInputController(m_EventBroker, e.PlayerID, e.Player); if (e.PlayerID == -1) { // Keep track of the local player m_LocalPlayer = e.Player; @@ -267,18 +335,72 @@ void PlayerMovementSystem::spawnHexagon(EntityWrapper target) bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) { EntityWrapper player(m_World, e.Player); - if (!player.Valid() || !IsClient || player.ID == LocalPlayer.ID) { + if (!player.Valid() || !IsClient){// || player.ID == LocalPlayer.ID) { return false; } auto entityFile = ResourceManager::Load("Schema/Entities/DashEffect.xml"); EntityWrapper dashEffect = entityFile->MergeInto(m_World); - auto playerModel = player.FirstChildByName("PlayerModel"); + EntityWrapper playerModel = player.FirstChildByName("PlayerModel"); + +/* auto playerEntityModel = playerModel["Model"]; + + + if (player.HasComponent("Physics")) { + glm::vec3 velocity = (glm::vec3)player["Physics"]["Velocity"]; + + glm::vec2 direction = glm::vec2(velocity.x, velocity.z); + + std::string DashName = ""; + if (glm::abs(direction.x) > glm::abs(direction.y)) { + if(glm::sign(direction.x) > 0) { + DashName = "DashRight"; + } else { + DashName = "DashLeft"; + } + } else { + if (glm::sign(direction.y) > 0) { + DashName = "DashForward"; + } else { + DashName = "DashBackward"; + } + } + + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.1; + aeb.NodeName = DashName; + aeb.RootNode = playerModel; + aeb.Restart = true; + aeb.Start = true; + m_EventBroker->Publish(aeb); + } + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.3; + aeb.NodeName = "StandCrouchBlend"; + aeb.RootNode = playerModel; + aeb.Delay = 0.3; + aeb.Start = true; + aeb.Restart = false; + aeb.AnimationEntity = playerModel.FirstChildByName(DashName); + m_EventBroker->Publish(aeb); + } + } + */ + +/* auto playerEntityAnimation = playerModel["Animation"]; + playerEntityModel.Copy(dashEffect["Model"]); playerEntityAnimation.Copy(dashEffect["Animation"]); dashEffect["ExplosionEffect"]["EndColor"] = (glm::vec4)playerEntityModel["Color"]; ((glm::vec4&)dashEffect["ExplosionEffect"]["EndColor"]).w = 0.f; +*/ + + + + return true; } diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp index 3918e9b8..55f6bb56 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -103,7 +103,7 @@ void AssaultWeaponBehaviour::OnReload(ComponentWrapper cWeapon, WeaponInfo& wi) // Play animation EntityWrapper modelEntity = wi.FirstPersonEntity.Parent().Parent(); if (modelEntity.Valid()) { - EntityWrapper blendTree = modelEntity.FirstChildByName("AssaultWeaponBlendTree"); + EntityWrapper blendTree = modelEntity.FirstChildByName("BlendTreeAssaultWeapon"); EntityWrapper reloadBlend = blendTree.FirstChildByName("Reload"); Events::AutoAnimationBlend eFireBlend; From 2b55450c183e222cac3293e159ba6cc0f1a3541b Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Fri, 4 Mar 2016 08:54:59 +0100 Subject: [PATCH 238/252] Cray cray weapons --- assets | 2 +- include/Game/Systems/Weapon/WeaponBehaviour.h | 26 + resources/Schema/Entities/DefenderShield.xml | 42 +- resources/Schema/Entities/MovementTest.xml | 6 +- resources/Schema/Entities/Player.xml | 205 +-- .../Schema/Entities/PlayerAssaultBlue.xml | 1258 +++++++++++++++++ .../Schema/Entities/PlayerDefenderBlue.xml | 334 +++-- .../Entities/WeaponDefenderBlueView.xml | 8 +- .../Entities/WeaponDefenderBlueWorld.xml | 11 +- .../Systems/Weapon/AssaultWeaponBehaviour.cpp | 17 +- .../Weapon/DefenderWeaponBehaviour.cpp | 39 + 11 files changed, 1694 insertions(+), 254 deletions(-) create mode 100644 resources/Schema/Entities/PlayerAssaultBlue.xml diff --git a/assets b/assets index 4205e927..819f9d1c 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 4205e92755aa67c90db6d272047cd92037ae9f11 +Subproject commit 819f9d1c8f62e8ebb07dafbb39f6dff1fd4d5a05 diff --git a/include/Game/Systems/Weapon/WeaponBehaviour.h b/include/Game/Systems/Weapon/WeaponBehaviour.h index 3cda172e..b00dd2e0 100644 --- a/include/Game/Systems/Weapon/WeaponBehaviour.h +++ b/include/Game/Systems/Weapon/WeaponBehaviour.h @@ -9,6 +9,7 @@ #include "Systems/SpawnerSystem.h" #include "Rendering/ESetCamera.h" #include "Core/ConfigFile.h" +#include "Rendering/EAutoAnimationBlend.h" template class WeaponBehaviour : public PureSystem @@ -94,6 +95,31 @@ protected: } } + void playAnimation(EntityWrapper weaponModelEntity, const std::string& subTreeName, const std::string& animationNodeName) + { + EntityWrapper root = weaponModelEntity.FirstParentWithComponent("Model"); + if (!root.Valid()) { + return; + } + + EntityWrapper subTree = root.FirstChildByName(subTreeName); + if (!subTree.Valid()) { + return; + } + + EntityWrapper animationNode = subTree.FirstChildByName(animationNodeName); + if (!animationNode.Valid()) { + return; + } + + Events::AutoAnimationBlend eFireBlend; + eFireBlend.RootNode = root; + eFireBlend.NodeName = animationNodeName; + eFireBlend.Restart = true; + eFireBlend.Start = true; + m_EventBroker->Publish(eFireBlend); + } + void playAnimationAndReturn(EntityWrapper weaponModelEntity, const std::string& subTreeName, const std::string& animationNodeName) { EntityWrapper root = weaponModelEntity.FirstParentWithComponent("Model"); diff --git a/resources/Schema/Entities/DefenderShield.xml b/resources/Schema/Entities/DefenderShield.xml index da760e72..5cb72116 100755 --- a/resources/Schema/Entities/DefenderShield.xml +++ b/resources/Schema/Entities/DefenderShield.xml @@ -2,36 +2,36 @@ + + Deploy + Idle + 0 + + + Models/Characters/Defender/DefenderShield.mesh + - + - - Models/Core/UnitPlane.mesh - - - - - - + + ActivateDeactiveShieldF + + 1 + + - + - - - Models/Core/UnitHexagon.mesh - - true - - - - - - + + ShieldFrontF + 1 + + diff --git a/resources/Schema/Entities/MovementTest.xml b/resources/Schema/Entities/MovementTest.xml index 90c943ef..8202bff3 100644 --- a/resources/Schema/Entities/MovementTest.xml +++ b/resources/Schema/Entities/MovementTest.xml @@ -15,7 +15,7 @@ - Schema/Entities/PlayerAssaultFallbackRed.xml + Schema/Entities/PlayerDefenderBlue.xml @@ -98,7 +98,7 @@ - + @@ -111,7 +111,7 @@ - + diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index dfcf40a3..70b387bb 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -485,11 +485,11 @@ - Run + MovementBlend FinalBlend - Models/Characters/Defender/FirstPersonDefenderBlue.mesh + Models/Characters/Assault/FirstPersonAssaultBlue.mesh @@ -506,8 +506,8 @@ Schema/Entities/WeaponAssaultBlueView.xml - - + + @@ -524,8 +524,8 @@ Schema/Entities/SidearmWeaponView.xml - - + + @@ -544,55 +544,31 @@ - Idle - WeaponAction + Fire + Reload 0 true - - - - Fire - Reload - 0 - - - - - - - - ShootShotgunF - 1 - false - - - - - - - - - ReloadSwitchF - 1 - false - - - - - - - - + - IdleF - + ShootRifleF 1 - true + false + + + + + + + + + ReloadSwitchF + 1 + false @@ -608,17 +584,42 @@ - + - - RunF - - 1 - true - + + Idle + Run + 0 + true + - + + + + + RunF + 1 + true + true + + + + + + + + + IdleF + 1 + true + true + + + + + + @@ -672,8 +673,8 @@ Schema/Entities/WeaponAssaultBlueWorld.xml - - + + @@ -693,8 +694,8 @@ Schema/Entities/SidearmWeaponWorld.xml - - + + @@ -801,7 +802,7 @@ CrouchStrafeLeftF - + 1 true @@ -813,7 +814,7 @@ CrouchStrafeRightF - + 1 true @@ -827,7 +828,7 @@ CrouchWalkF - + 1 true @@ -870,42 +871,6 @@ - - - - Walk - Run - 1.2938206818383024e-24 - - - - - - - - WalkF - - 1 - true - - - - - - - - - RunF - - 1 - true - - - - - - - @@ -920,7 +885,7 @@ StrafeRightF - + 1 true @@ -932,7 +897,43 @@ StrafeLeftF - + + 1 + true + + + + + + + + + + + Walk + Run + 1.2938206818383024e-24 + + + + + + + + WalkF + + 1 + true + + + + + + + + + RunF + 1 true @@ -948,7 +949,7 @@ IdleF - + 1 true @@ -1117,7 +1118,7 @@ IdleAssaultRifleU - + 1 true @@ -1129,7 +1130,7 @@ IdleSecWepU - + 1 true diff --git a/resources/Schema/Entities/PlayerAssaultBlue.xml b/resources/Schema/Entities/PlayerAssaultBlue.xml new file mode 100644 index 00000000..bcf4b5e5 --- /dev/null +++ b/resources/Schema/Entities/PlayerAssaultBlue.xml @@ -0,0 +1,1258 @@ + + + + + + + + + + + + + + + + + + + + + + + 5 + + + + + + + + + + + + + 0.10000000149011612 + 300 + + + + + + + + + + Models/Widgets/Camera.mesh + false + + + + + + + + + + + + + + + + + + + Textures/Weapons/Crosshair/SmallThickHoleDot.png + + false + + + + + + + + + + + + Schema/Entities/HitMarker.xml + + + + + + + + + + + + + + 1 + + + + + Textures/HealthHUD3.png + + + + + + + + + + + + + + + + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + 0.0 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + 1 + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + 2 + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + 3 + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 1 + + + + 4 + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + 1 + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 1 + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + + Models/Widgets/Arrows/Arrow5.mesh + + + + + + + + + + + + + + + MovementBlend + FinalBlend + + + Models/Characters/Assault/FirstPersonAssaultBlue.mesh + + + + + + + + R_Arm_Weapon_Joint + + + AssaultWeapon + + + Schema/Entities/WeaponAssaultBlueView.xml + + + + + + + + + + + + R_Arm_Weapon_Joint + + + SidearmWeapon + + + Schema/Entities/SidearmWeaponView.xml + + + + + + + + + + + + BlendTreeAssaultWeapon + BlendTreeSecondaryWeapon + 0 + true + + + + + + + + Fire + Reload + 0 + true + + + + + + + + ShootRifleF + 1 + false + + + + + + + + + ReloadSwitchF + 1 + false + + + + + + + + + + + + + + + + + + + Idle + Run + 0 + true + + + + + + + + RunF + 1 + true + true + + + + + + + + + IdleF + 1 + true + true + + + + + + + + + + + + + + + 0.10000000149011612 + 300 + + + Models/Widgets/Camera.mesh + false + + + + + + + + + + + + BlendTreeAim + BlendTreeAssault + + + + + Models/Characters/Assault/AssaultBlue.mesh + + + + + + + + + R_Arm_Weapon_Joint + + + AssaultWeapon + + + + + + Schema/Entities/WeaponAssaultBlueWorld.xml + + + + + + + + + + + + R_Arm_Weapon_Joint + + + SidearmWeapon + + + + + + Schema/Entities/SidearmWeaponWorld.xml + + + + + + + + + + + + AimPrimary + AimSecondary + 0 + true + + + + + + + + AimSecWepA + + false + true + + + + + + + + + AimRifleA + + false + true + + + + + + + + + + + ReloadSwitchBlend + MovementBlend + + + + + + + + StandCrouchBlend + JumpDashBlend + 2.5146881298480398e-63 + true + + + + + + + + StandMovement + CrouchMovement + 0 + true + + + + + + + + MovementBlend + Idle + 1 + + + + + + + + Walk + StrafeLRBlend + 0 + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + CrouchStrafeLeftF + + 1 + true + + + + + + + + + CrouchStrafeRightF + + 1 + true + + + + + + + + + + + CrouchWalkF + + 1 + true + + + + + + + + + + + CrouchF + + 1 + + + + + + + + + + + MovementBlend + Idle + 1 + + + + + + + + RunWalkBlend + StrafeLRBlend + 2.4565650245976452e-16 + + + + + + + + Walk + Run + 1.2938206818383024e-24 + + + + + + + + WalkF + + 1 + true + + + + + + + + + RunF + + 1 + true + + + + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + StrafeRightF + + 1 + true + + + + + + + + + StrafeLeftF + + 1 + true + + + + + + + + + + + + + IdleF + + 1 + true + + + + + + + + + + + + + Jump + DashBlend + 1 + true + + + + + + + + JumpF + + 1 + false + + + + + + + + + DashFBBlend + DashLRBlend + 0.014621149736541383 + + + + + + + + DashForward + DashBackward + 0.014363533804961248 + + + + + + + + DashForwardF + + 1 + false + + + + + + + + + DashBackwardF + + 1 + false + + + + + + + + + + + DashLeft + DashRight + 4.3244885367500671e-16 + + + + + + + + DashLeftF + + 1 + false + + + + + + + + + DashRightF + + 1 + false + + + + + + + + + + + + + + + + + ReloadSwitch + WeaponActionBlend + 1 + true + + + + + + + + ReloadSwitchU + + 1 + + + + + + + + + IdleBlend + ShootBlend + 0 + + + + + + + + IdlePrimary + IdleSecondary + 0 + + + + + + + + IdleAssaultRifleU + + 1 + true + + + + + + + + + IdleSecWepU + + 1 + true + + + + + + + + + + + ShootPrimary + ShootSecondary + 0 + + + + + + + + ShootFastRifleU + + 1 + + + + + + + + + ShootSecWepFastU + + + + + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + false + + + + + + + + + + + + Models/Core/UnitCube.mesh + + false + + + + + + + + + + + Insert name here + Fonts/DroidSans.ttf,100 + + + + + + + + + + + + + + Textures/Icons/Arrow.png + + false + + + + + 50 + true + + + + + + + + + + + + Schema/Entities/DefenderShield.xml + + + + + + + + + + diff --git a/resources/Schema/Entities/PlayerDefenderBlue.xml b/resources/Schema/Entities/PlayerDefenderBlue.xml index aef660a3..c3bfc074 100644 --- a/resources/Schema/Entities/PlayerDefenderBlue.xml +++ b/resources/Schema/Entities/PlayerDefenderBlue.xml @@ -1,31 +1,38 @@ - + - - + - - - - + + 4 + 52 + + + + 150 + 150 + + - + + true 5 - + + @@ -38,6 +45,7 @@ + @@ -213,7 +221,7 @@ - 100/100 + 150/150 Fonts/DroidSans.ttf,64 @@ -422,6 +430,7 @@ Fonts/DroidSans.ttf,64 + @@ -485,12 +494,10 @@ - - BlendTreeAssaultWeapon - BlendTreeSecondaryWeapon - 0 - true - + + MovementBlend + FinalBlend + Models/Characters/Defender/FirstPersonDefenderBlue.mesh @@ -501,7 +508,6 @@ R_Arm_Weapon_Joint - true DefenderWeapon @@ -510,9 +516,8 @@ Schema/Entities/WeaponDefenderBlueView.xml - - - + + @@ -529,38 +534,39 @@ Schema/Entities/SidearmWeaponView.xml - - + + - + - Idle - WeaponAction + BlendTreeDefenderWeapon + BlendTreeSecondaryWeapon 0 true - + - Fire - Reload - 1 + ActionBlend + Shield + 0 + true - + - ShootShotgunF - + ActivateDeactiveShieldF + 1 false @@ -568,39 +574,112 @@ - + - - ReloadSwitchF - - 1 - true - + + Idle + ActionBlend2 + 0 + true + - + + + + + IdleF + + + + + + + + + Fire + Reload + 0 + + + + + + + + ShootShotgunF + + 1 + false + + + + + + + + + ShotgunReloadTwoF + + 1 + false + + + + + + + + - + - - IdleF - - 1 - true - - + + + Idle + Run + 0 + true + - + + + + + RunF + + 1 + true + true + + + + + + + + + IdleF + + 1 + true + true + + + + + + @@ -632,9 +711,8 @@ - Models/Characters/Assault/AssaultBlue.mesh - - false + Models/Characters/Defender/DefenderBlue.mesh + @@ -651,11 +729,11 @@ - Schema/Entities/WeaponAssaultBlueWorld.xml + Schema/Entities/WeaponDefenderBlueWorld.xml - - + + @@ -675,8 +753,8 @@ Schema/Entities/SidearmWeaponWorld.xml - - + + @@ -779,11 +857,11 @@ - + - CrouchStrafeLeftF - + CrouchStrafeRightF + 1 true @@ -791,11 +869,11 @@ - + - CrouchStrafeRightF - + CrouchStrafeLeftF + 1 true @@ -809,7 +887,7 @@ CrouchWalkF - + 1 true @@ -852,42 +930,6 @@ - - - - Walk - Run - 1.2938206818383024e-24 - - - - - - - - WalkF - - 1 - true - - - - - - - - - RunF - - 1 - true - - - - - - - @@ -902,7 +944,7 @@ StrafeRightF - + 1 true @@ -914,7 +956,43 @@ StrafeLeftF - + + 1 + true + + + + + + + + + + + Walk + Run + 1.2938206818383024e-24 + + + + + + + + WalkF + + 1 + true + + + + + + + + + RunF + 1 true @@ -930,7 +1008,7 @@ IdleF - + 1 true @@ -1099,7 +1177,7 @@ IdleAssaultRifleU - + 1 true @@ -1111,7 +1189,7 @@ IdleSecWepU - + 1 true @@ -1159,6 +1237,50 @@ + + + + + + + + + + + Deploy + Idle + 0 + + + Models/Characters/Defender/DefenderShield.mesh + + + + + + + + ActivateDeactiveShieldF + 1 + + + + + + + + + ShieldFrontF + 1 + + + + + + + + + @@ -1191,7 +1313,7 @@ - Insert name here + Fonts/DroidSans.ttf,100 diff --git a/resources/Schema/Entities/WeaponDefenderBlueView.xml b/resources/Schema/Entities/WeaponDefenderBlueView.xml index 6ec4b452..24b18f68 100644 --- a/resources/Schema/Entities/WeaponDefenderBlueView.xml +++ b/resources/Schema/Entities/WeaponDefenderBlueView.xml @@ -3,11 +3,9 @@ - Models/Weapons/Blue/DefenderGunBlue.mesh + Models/Weapons/Blue/DefenderWeaponBlue.mesh - - - + @@ -34,7 +32,7 @@ - + diff --git a/resources/Schema/Entities/WeaponDefenderBlueWorld.xml b/resources/Schema/Entities/WeaponDefenderBlueWorld.xml index 826301b4..6c750964 100644 --- a/resources/Schema/Entities/WeaponDefenderBlueWorld.xml +++ b/resources/Schema/Entities/WeaponDefenderBlueWorld.xml @@ -2,17 +2,10 @@ - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/DefenderGunBlue.mesh + Models/Weapons/Blue/DefenderWeaponBlue.mesh - - - - + diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp index cdb0a563..0fd987ae 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -39,6 +39,8 @@ void AssaultWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& ammo = glm::max(0, ammo - (magSize - magAmmo)); magAmmo = glm::min(magSize, ammo); isReloading = false; + wi.FirstPersonEntity["Model"]["Visible"] = true; + wi.ThirdPersonEntity["Model"]["Visible"] = true; } // Restore view angle @@ -57,19 +59,18 @@ void AssaultWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& } // Update first person run animation - /*ComponentWrapper cPlayer = wi.Player["Player"]; + ComponentWrapper cPlayer = wi.Player["Player"]; ComponentWrapper cPhysics = wi.Player["Physics"]; const float& movementSpeed = cPlayer["MovementSpeed"]; float speed = glm::length((const glm::vec3&)cPhysics["Velocity"]); - float animationSpeed = glm::max(speed, movementSpeed) / movementSpeed; + float animationWeight = glm::min(speed, movementSpeed) / movementSpeed; EntityWrapper rootNode = wi.FirstPersonEntity.FirstParentWithComponent("Model"); if (rootNode.Valid()) { - EntityWrapper animationNode = rootNode.FirstChildByName("Run"); - if (animationNode.Valid()) { - (bool&)animationNode["Animation"]["Play"] = animationSpeed > 0; - (double&)animationNode["Animation"]["Speed"] = animationSpeed; + EntityWrapper blend = rootNode.FirstChildByName("MovementBlend"); + if (blend.Valid()) { + (double&)blend["Blend"]["Weight"] = animationWeight; } - }*/ + } // Fire if we're able to fire if (canFire(cWeapon, wi)) { @@ -122,6 +123,8 @@ void AssaultWeaponBehaviour::OnReload(ComponentWrapper cWeapon, WeaponInfo& wi) EntityWrapper reloadEffectSpawner = wi.FirstPersonEntity.FirstChildByName("FirstPersonReloadSpawner"); if (reloadEffectSpawner.Valid()) { SpawnerSystem::Spawn(reloadEffectSpawner, reloadEffectSpawner); + wi.FirstPersonEntity["Model"]["Visible"] = false; + wi.ThirdPersonEntity["Model"]["Visible"] = false; } } diff --git a/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp b/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp index 3a4ed3a4..2d6ab74b 100644 --- a/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/DefenderWeaponBehaviour.cpp @@ -36,6 +36,7 @@ void DefenderWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& m_EventBroker->Publish(e); } else { isReloading = false; + playAnimationAndReturn(wi.FirstPersonEntity, "FinalBlend", "Idle"); } } @@ -96,6 +97,9 @@ void DefenderWeaponBehaviour::OnReload(ComponentWrapper cWeapon, WeaponInfo& wi) // Start reload isReloading = true; reloadTimer = reloadTime; + + // Play animation + playAnimationAndReturn(wi.FirstPersonEntity, "FinalBlend", "Reload"); } void DefenderWeaponBehaviour::OnHolster(ComponentWrapper cWeapon, WeaponInfo& wi) @@ -115,8 +119,40 @@ bool DefenderWeaponBehaviour::OnInputCommand(ComponentWrapper cWeapon, WeaponInf if (attachment.Valid()) { if (e.Value > 0) { SpawnerSystem::Spawn(attachment, attachment); + + EntityWrapper root = wi.FirstPersonEntity.FirstParentWithComponent("Model"); + if (root.Valid()) { + EntityWrapper subTree = root.FirstChildByName("FinalBlend"); + if (subTree.Valid()) { + EntityWrapper animationNode = subTree.FirstChildByName("Shield"); + if (animationNode.Valid()) { + Events::AutoAnimationBlend eFireBlend; + eFireBlend.RootNode = root; + eFireBlend.NodeName = "Shield"; + eFireBlend.Restart = true; + eFireBlend.Start = true; + m_EventBroker->Publish(eFireBlend); + } + } + } } else { attachment.DeleteChildren(); + + EntityWrapper root = wi.FirstPersonEntity.FirstParentWithComponent("Model"); + if (root.Valid()) { + EntityWrapper subTree = root.FirstChildByName("FinalBlend"); + if (subTree.Valid()) { + EntityWrapper animationNode = subTree.FirstChildByName("ActionBlend"); + if (animationNode.Valid()) { + Events::AutoAnimationBlend eFireBlend; + eFireBlend.RootNode = root; + eFireBlend.NodeName = "ActionBlend"; + eFireBlend.Restart = true; + eFireBlend.Start = true; + m_EventBroker->Publish(eFireBlend); + } + } + } } } } @@ -195,6 +231,9 @@ void DefenderWeaponBehaviour::fireShell(ComponentWrapper cWeapon, WeaponInfo& wi } } + // Play animation + playAnimationAndReturn(wi.FirstPersonEntity, "BlendTreeDefenderWeapon", "Fire"); + // Sound Events::PlaySoundOnEntity e; e.EmitterID = wi.Player.ID; From e2674d915ecf0a9828945f9eaa35b6a582977dc7 Mon Sep 17 00:00:00 2001 From: Jocke Date: Fri, 4 Mar 2016 08:55:55 +0100 Subject: [PATCH 239/252] Constrained weapon behavior to client side only --- include/Game/Systems/Weapon/WeaponBehaviour.h | 6 ++++-- src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp | 11 ++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/include/Game/Systems/Weapon/WeaponBehaviour.h b/include/Game/Systems/Weapon/WeaponBehaviour.h index 3cda172e..a823f9dd 100644 --- a/include/Game/Systems/Weapon/WeaponBehaviour.h +++ b/include/Game/Systems/Weapon/WeaponBehaviour.h @@ -242,8 +242,10 @@ private: // Spawn the weapon(s) EntityWrapper firstPersonWeapon; EntityWrapper thirdPersonWeapon; - if (firstPersonAttachment.Valid()) { - firstPersonWeapon = SpawnerSystem::Spawn(firstPersonAttachment, firstPersonAttachment); + if (IsClient) { + if (firstPersonAttachment.Valid()) { + firstPersonWeapon = SpawnerSystem::Spawn(firstPersonAttachment, firstPersonAttachment); + } } if (thirdPersonAttachment.Valid()) { thirdPersonWeapon = SpawnerSystem::Spawn(thirdPersonAttachment, thirdPersonAttachment); diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp index cdb0a563..4c970500 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -117,11 +117,12 @@ void AssaultWeaponBehaviour::OnReload(ComponentWrapper cWeapon, WeaponInfo& wi) // Play animation playAnimationAndReturn(wi.FirstPersonEntity, "BlendTreeAssaultWeapon", "Reload"); - - // Spawn explosion effect - EntityWrapper reloadEffectSpawner = wi.FirstPersonEntity.FirstChildByName("FirstPersonReloadSpawner"); - if (reloadEffectSpawner.Valid()) { - SpawnerSystem::Spawn(reloadEffectSpawner, reloadEffectSpawner); + if (IsClient) { + // Spawn explosion effect + EntityWrapper reloadEffectSpawner = wi.FirstPersonEntity.FirstChildByName("FirstPersonReloadSpawner"); + if (reloadEffectSpawner.Valid()) { + SpawnerSystem::Spawn(reloadEffectSpawner, reloadEffectSpawner); + } } } From ebd4c58c41c903dc680d7d8aadd3bcc1edf27aeb Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Fri, 4 Mar 2016 09:23:18 +0100 Subject: [PATCH 240/252] "Fixed" weapon spawning over network --- include/Game/Systems/Weapon/WeaponBehaviour.h | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/include/Game/Systems/Weapon/WeaponBehaviour.h b/include/Game/Systems/Weapon/WeaponBehaviour.h index 60675d67..e2d5980b 100644 --- a/include/Game/Systems/Weapon/WeaponBehaviour.h +++ b/include/Game/Systems/Weapon/WeaponBehaviour.h @@ -32,6 +32,21 @@ public: virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cWeapon, double dt) override { + EntityWrapper firstPersonWeapon = entity.FirstChildByName("Hands").FirstChildByName("AssaultWeapon"); + EntityWrapper thirdPersonWeapon = entity.FirstChildByName("PlayerModel").FirstChildByName("AssaultWeapon"); + if (IsClient && (firstPersonWeapon.Valid() || thirdPersonWeapon.Valid())) { + if (m_ActiveWeapons.count(entity) == 0) { + + WeaponInfo& wi = m_ActiveWeapons[entity]; + wi.Player = entity; + wi.WeaponEntity = entity; + wi.FirstPersonEntity = firstPersonWeapon; + wi.ThirdPersonEntity = thirdPersonWeapon; + + OnEquip(cWeapon, wi); + } + } + auto weapon = getActiveWeapon(entity); if (!weapon) { return; @@ -239,6 +254,10 @@ private: void selectWeapon(ComponentWrapper cWeapon, EntityWrapper player) { + if (!IsServer) { + return; + } + // Don't reselect weapon if it's already active if (getActiveWeapon(player)) { return; @@ -268,11 +287,11 @@ private: // Spawn the weapon(s) EntityWrapper firstPersonWeapon; EntityWrapper thirdPersonWeapon; - if (IsClient) { + //if (IsClient) { if (firstPersonAttachment.Valid()) { firstPersonWeapon = SpawnerSystem::Spawn(firstPersonAttachment, firstPersonAttachment); } - } + //} if (thirdPersonAttachment.Valid()) { thirdPersonWeapon = SpawnerSystem::Spawn(thirdPersonAttachment, thirdPersonAttachment); } From 3ac8a5c7ef4c8bf62063c965d576c94d858f9497 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Fri, 4 Mar 2016 09:38:38 +0100 Subject: [PATCH 241/252] Working map --- .../Schema/Entities/NewMap2version5NEW.xml | 8623 ++++++++--------- .../Schema/Entities/PlayerAssaultBlue.xml | 72 +- .../Schema/Entities/PlayerAssaultRed.xml | 1258 +++ .../Schema/Entities/WeaponAssaultRedView.xml | 109 + .../Schema/Entities/WeaponAssaultRedWorld.xml | 34 + 5 files changed, 5747 insertions(+), 4349 deletions(-) create mode 100644 resources/Schema/Entities/PlayerAssaultRed.xml create mode 100644 resources/Schema/Entities/WeaponAssaultRedView.xml create mode 100644 resources/Schema/Entities/WeaponAssaultRedWorld.xml diff --git a/resources/Schema/Entities/NewMap2version5NEW.xml b/resources/Schema/Entities/NewMap2version5NEW.xml index 2925f516..aa709967 100644 --- a/resources/Schema/Entities/NewMap2version5NEW.xml +++ b/resources/Schema/Entities/NewMap2version5NEW.xml @@ -2,6 +2,9 @@ + + 2.4355835422707059 + @@ -29,29 +32,6 @@ - - - - - Models/Props/Walls/SciFiWallBig.mesh - - - - - - - - - - - - Models/Props/Walls/SciFiWallBig.mesh - true - - - - - @@ -82,6 +62,29 @@ + + + + + Models/Props/Walls/SciFiWallBig.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + true + + + + + @@ -676,6 +679,42 @@ + + + + + Models/Highgrounds/Hg8.mesh + + + + + + + + + + + + Models/Highgrounds/Hg10.mesh + + + + + + + + + + + + Models/Highgrounds/Hg4.mesh + + + + + + + @@ -751,42 +790,6 @@ - - - - - Models/Highgrounds/Hg8.mesh - - - - - - - - - - - - Models/Highgrounds/Hg10.mesh - - - - - - - - - - - - Models/Highgrounds/Hg4.mesh - - - - - - - @@ -1924,6 +1927,68 @@ + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + @@ -2526,392 +2591,7 @@ - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - - + @@ -2920,12 +2600,12 @@ - Models/Props/Flora/SpecialRoot.mesh + Models/Props/Pillars/StonePillar.mesh - - - + + + @@ -2934,12 +2614,11 @@ - Models/Props/Flora/SpecialRoot.mesh + Models/Props/Pillars/SciFiPillar2Red.mesh - - - + + @@ -2948,11 +2627,13 @@ - Models/Props/Flora/SpecialRoot.mesh + 6 + Models/Props/Pillars/SciFiPillar1Red.mesh - - + + + @@ -2961,32 +2642,10 @@ - Models/Props/Flora/SpecialRoot.mesh + Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - + @@ -2995,496 +2654,11 @@ - Models/Props/SciFiHolder1.mesh + Models/Props/Pillars/SciFiPillar2Red.mesh - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - + + @@ -3494,573 +2668,16 @@ - Models/Props/Stones/SmallStone1.mesh + Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - + + - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - @@ -4068,6 +2685,19 @@ + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + @@ -4108,19 +2738,6 @@ - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - @@ -4137,579 +2754,6 @@ - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Red.mesh - - - - - - - - - - - - - - 6 - Models/Props/Pillars/SciFiPillar1Red.mesh - - - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Red.mesh - - - - - - - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Core/UnitPlane.mesh - - true - - - - - - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - @@ -4729,232 +2773,6 @@ - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - Models/Props/Walls/smallWall3.mesh - - - - - - - - - - - @@ -4966,8 +2784,8 @@ Models/Props/PickUps/PickUpHolder.mesh - - + + @@ -4975,49 +2793,7 @@ - - - - - - - - - - 8 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - + @@ -5034,7 +2810,343 @@ - + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + @@ -5046,324 +3158,11 @@ - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - @@ -5371,593 +3170,8 @@ Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - 4 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - 3 - - - - - - - - - - - - 2 - - - - - - - - - - - - 2 - 1 - - - - - - - - - - - - - - 4 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - 2 - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - + + @@ -5976,6 +3190,46 @@ + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + @@ -5983,8 +3237,195 @@ Models/Props/Stones/BigStone.mesh - - + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + @@ -5997,8 +3438,8 @@ - - + + @@ -6010,8 +3451,308 @@ Models/Props/Stones/SmallStone1.mesh - - + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + @@ -6044,20 +3785,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - @@ -6071,46 +3798,6 @@ - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - @@ -6118,48 +3805,8 @@ Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - + + @@ -6185,8 +3832,114 @@ Models/Props/Stones/SmallStone1.mesh - - + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + @@ -6199,8 +3952,22 @@ Models/Props/Stones/SmallStone1.mesh - - + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + @@ -6212,75 +3979,8 @@ Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - + + @@ -6298,47 +3998,6 @@ - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - @@ -6352,18 +4011,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - @@ -6418,112 +4065,6 @@ - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - @@ -6531,13 +4072,41 @@ Models/Props/Stones/MediumStone2.mesh - - + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + @@ -6551,71 +4120,6 @@ - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - @@ -6629,75 +4133,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - @@ -6712,6 +4147,1958 @@ + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/smallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 5 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 4 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 3 + + + + + + + + + + + + 2 + 1 + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 4 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + @@ -6733,9 +6120,211 @@ Models/Props/Stones/SmallStone1.mesh - - - + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + @@ -6754,6 +6343,192 @@ + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + @@ -6767,6 +6542,73 @@ + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + @@ -6774,9 +6616,170 @@ Models/Props/Stones/SmallStone1.mesh - - - + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + @@ -6816,90 +6819,6 @@ - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - @@ -6932,7 +6851,7 @@ - + @@ -6948,8 +6867,8 @@ Models/Props/PickUps/PickUpHolder.mesh - - + + @@ -6957,49 +6876,7 @@ - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - + @@ -7016,7 +6893,7 @@ - + @@ -7058,7 +6935,133 @@ - + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + @@ -7100,7 +7103,7 @@ - + @@ -7112,11 +7115,100 @@ + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + @@ -7130,6 +7222,20 @@ + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + @@ -7145,20 +7251,6 @@ - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - @@ -7173,95 +7265,6 @@ - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - @@ -7413,19 +7416,6 @@ - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - @@ -7453,6 +7443,19 @@ + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + @@ -7542,9 +7545,8 @@ Models/Props/Flora/SpecialRoot.mesh - - - + + @@ -7556,8 +7558,9 @@ Models/Props/Flora/SpecialRoot.mesh - - + + + @@ -7601,12 +7604,11 @@ - Models/Props/Walls/SmallWall3.mesh + Models/Props/Walls/MediumWall3.mesh - - - + + @@ -7618,8 +7620,76 @@ Models/Props/Walls/MediumWall3.mesh - - + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + @@ -7657,48 +7727,8 @@ Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - + + @@ -7718,6 +7748,20 @@ + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + @@ -7725,12 +7769,26 @@ Models/Props/Walls/BigWallBlue.mesh - + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + @@ -7751,8 +7809,7 @@ Models/Props/Walls/SmallWall3.mesh - - + @@ -7765,8 +7822,21 @@ Models/Props/Walls/MediumWall3.mesh - - + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + @@ -7792,8 +7862,8 @@ Models/Props/Walls/SmallWall3.mesh - - + + @@ -7806,49 +7876,9 @@ Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - + + + @@ -7866,6 +7896,19 @@ + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + @@ -7883,11 +7926,39 @@ - Models/Props/Walls/BigWallBlue.mesh + Models/Props/Walls/SmallWall3.mesh - - + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + @@ -7905,32 +7976,6 @@ - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - @@ -7944,48 +7989,6 @@ - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - @@ -8008,19 +8011,6 @@ - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - @@ -8048,6 +8038,19 @@ + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + @@ -8144,13 +8147,12 @@ - 4 - Models/Props/Pillars/SciFiPillar3Blue.mesh + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh - - - + + @@ -8177,8 +8179,9 @@ Models/Props/Pillars/SciFiPillar2Blue.mesh - - + + + @@ -8187,12 +8190,12 @@ - 6 - Models/Props/Pillars/SciFiPillar1Blue.mesh + Models/Props/Pillars/SciFiPillar2Blue.mesh - - + + + @@ -8220,8 +8223,8 @@ Models/Props/Pillars/SciFiPillar2Blue.mesh - - + + @@ -8240,6 +8243,49 @@ + + + + + 4 + Models/Props/Pillars/SciFiPillar3Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + @@ -8255,49 +8301,6 @@ - - - - - 6 - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - - - - - - - 6 - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - - @@ -8352,26 +8355,6 @@ - - - - 10 - - - - - - - - - - - 1 - - - - - @@ -8383,17 +8366,6 @@ - - - - 10 - - - - - - - @@ -8406,6 +8378,17 @@ + + + + 10 + + + + + + + @@ -8429,6 +8412,26 @@ + + + + 1 + + + + + + + + + 10 + + + + + + + @@ -8440,7 +8443,7 @@ - Schema/Entities/PlayerRed.xml + Schema/Entities/PlayerAssaultRed.xml @@ -8702,61 +8705,55 @@ - Schema/Entities/Player.xml + Schema/Entities/PlayerAssaultBlue.xml - + - + - Models/Characters/Assault/AssaultTPose.mesh - false + Models/Core/UnitCube.mesh + + + + + + + + + + Models/Core/UnitCube.mesh - + - + - Models/Characters/Assault/AssaultTPose.mesh - false + Models/Core/UnitCube.mesh - + - + - Models/Characters/Assault/AssaultTPose.mesh - false + Models/Core/UnitCube.mesh - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - + diff --git a/resources/Schema/Entities/PlayerAssaultBlue.xml b/resources/Schema/Entities/PlayerAssaultBlue.xml index bcf4b5e5..c918dcd6 100644 --- a/resources/Schema/Entities/PlayerAssaultBlue.xml +++ b/resources/Schema/Entities/PlayerAssaultBlue.xml @@ -871,42 +871,6 @@ - - - - Walk - Run - 1.2938206818383024e-24 - - - - - - - - WalkF - - 1 - true - - - - - - - - - RunF - - 1 - true - - - - - - - @@ -943,6 +907,42 @@ + + + + Walk + Run + 1.2938206818383024e-24 + + + + + + + + WalkF + + 1 + true + + + + + + + + + RunF + + 1 + true + + + + + + + diff --git a/resources/Schema/Entities/PlayerAssaultRed.xml b/resources/Schema/Entities/PlayerAssaultRed.xml new file mode 100644 index 00000000..af0ba963 --- /dev/null +++ b/resources/Schema/Entities/PlayerAssaultRed.xml @@ -0,0 +1,1258 @@ + + + + + + + + + + + + + + + + + + + + + + + 5 + + + + + + + + + + + + + 0.10000000149011612 + 300 + + + + + + + + + + Models/Widgets/Camera.mesh + false + + + + + + + + + + + + + + + + + + + Textures/Weapons/Crosshair/SmallThickHoleDot.png + + false + + + + + + + + + + + + Schema/Entities/HitMarker.xml + + + + + + + + + + + + + + 1 + + + + + Textures/HealthHUD3.png + + + + + + + + + + + + + + + + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + + + + + + + + + Textures/Core/White.png + + false + + + + + + + + + + + 0.0 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + 1 + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + 2 + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + 3 + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 1 + + + + 4 + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + 1 + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 1 + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + + Models/Widgets/Arrows/Arrow5.mesh + + + + + + + + + + + + + + + MovementBlend + FinalBlend + + + Models/Characters/Assault/FirstPersonAssaultRed.mesh + + + + + + + + R_Arm_Weapon_Joint + + + AssaultWeapon + + + Schema/Entities/WeaponAssaultRedView.xml + + + + + + + + + + + + R_Arm_Weapon_Joint + + + SidearmWeapon + + + Schema/Entities/SidearmWeaponView.xml + + + + + + + + + + + + BlendTreeAssaultWeapon + BlendTreeSecondaryWeapon + 0 + true + + + + + + + + Fire + Reload + 0 + true + + + + + + + + ShootRifleF + 1 + false + + + + + + + + + ReloadSwitchF + 1 + false + + + + + + + + + + + + + + + + + + + Idle + Run + 0 + true + + + + + + + + RunF + 1 + true + true + + + + + + + + + IdleF + 1 + true + true + + + + + + + + + + + + + + + 0.10000000149011612 + 300 + + + Models/Widgets/Camera.mesh + false + + + + + + + + + + + + BlendTreeAim + BlendTreeAssault + + + + + Models/Characters/Assault/AssaultRed.mesh + + + + + + + + + R_Arm_Weapon_Joint + + + AssaultWeapon + + + + + + Schema/Entities/WeaponAssaultRedWorld.xml + + + + + + + + + + + + R_Arm_Weapon_Joint + + + SidearmWeapon + + + + + + Schema/Entities/SidearmWeaponWorld.xml + + + + + + + + + + + + AimPrimary + AimSecondary + 0 + true + + + + + + + + AimSecWepA + + false + true + + + + + + + + + AimRifleA + + false + true + + + + + + + + + + + ReloadSwitchBlend + MovementBlend + + + + + + + + StandCrouchBlend + JumpDashBlend + 2.5146881298480398e-63 + true + + + + + + + + StandMovement + CrouchMovement + 0 + true + + + + + + + + MovementBlend + Idle + 1 + + + + + + + + Walk + StrafeLRBlend + 0 + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + CrouchStrafeLeftF + + 1 + true + + + + + + + + + CrouchStrafeRightF + + 1 + true + + + + + + + + + + + CrouchWalkF + + 1 + true + + + + + + + + + + + CrouchF + + 1 + + + + + + + + + + + MovementBlend + Idle + 1 + + + + + + + + RunWalkBlend + StrafeLRBlend + 2.4565650245976452e-16 + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + StrafeRightF + + 1 + true + + + + + + + + + StrafeLeftF + + 1 + true + + + + + + + + + + + Walk + Run + 1.2938206818383024e-24 + + + + + + + + WalkF + + 1 + true + + + + + + + + + RunF + + 1 + true + + + + + + + + + + + + + IdleF + + 1 + true + + + + + + + + + + + + + Jump + DashBlend + 1 + true + + + + + + + + JumpF + + 1 + false + + + + + + + + + DashFBBlend + DashLRBlend + 0.014621149736541383 + + + + + + + + DashForward + DashBackward + 0.014363533804961248 + + + + + + + + DashForwardF + + 1 + false + + + + + + + + + DashBackwardF + + 1 + false + + + + + + + + + + + DashLeft + DashRight + 4.3244885367500671e-16 + + + + + + + + DashLeftF + + 1 + false + + + + + + + + + DashRightF + + 1 + false + + + + + + + + + + + + + + + + + ReloadSwitch + WeaponActionBlend + 1 + true + + + + + + + + ReloadSwitchU + + 1 + + + + + + + + + IdleBlend + ShootBlend + 0 + + + + + + + + IdlePrimary + IdleSecondary + 0 + + + + + + + + IdleAssaultRifleU + + 1 + true + + + + + + + + + IdleSecWepU + + 1 + true + + + + + + + + + + + ShootPrimary + ShootSecondary + 0 + + + + + + + + ShootFastRifleU + + 1 + + + + + + + + + ShootSecWepFastU + + + + + + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + false + + + + + + + + + + + + Models/Core/UnitCube.mesh + + false + + + + + + + + + + + Insert name here + Fonts/DroidSans.ttf,100 + + + + + + + + + + + + + + Textures/Icons/Arrow.png + + false + + + + + 50 + true + + + + + + + + + + + + Schema/Entities/DefenderShield.xml + + + + + + + + + + diff --git a/resources/Schema/Entities/WeaponAssaultRedView.xml b/resources/Schema/Entities/WeaponAssaultRedView.xml new file mode 100644 index 00000000..0a9b65b2 --- /dev/null +++ b/resources/Schema/Entities/WeaponAssaultRedView.xml @@ -0,0 +1,109 @@ + + + + + + Models/Weapons/Red/AssaultWeaponRed.mesh + + + + + + + + + Schema/Entities/RayRed.xml + + + + + + + + + + + + Schema/Entities/ReloadEffectView.xml + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + + + + 32 + Fonts/DroidSans.ttf,64 + + + + Player + AssaultWeapon + MagazineAmmo + + + + + + + + + + + 320 + Fonts/DroidSans.ttf,64 + + + + Player + AssaultWeapon + Ammo + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/WeaponAssaultRedWorld.xml b/resources/Schema/Entities/WeaponAssaultRedWorld.xml new file mode 100644 index 00000000..68d78d03 --- /dev/null +++ b/resources/Schema/Entities/WeaponAssaultRedWorld.xml @@ -0,0 +1,34 @@ + + + + + + Models/Weapons/Red/AssaultWeaponRed.mesh + + + + + + + + + Schema/Entities/RayRed.xml + + + + + + + + + + + Schema/Entities/ReloadEffectWorld.xml + + + + + + + + From c1f5cf65a7211ea1029084e48d68f8066ed53630 Mon Sep 17 00:00:00 2001 From: viktorljung Date: Fri, 4 Mar 2016 09:39:16 +0100 Subject: [PATCH 242/252] Movement animations --- .../Engine/Input/FirstPersonInputController.h | 13 +- resources/Schema/Entities/Player.xml | 16 +- src/Game/Systems/PlayerMovementSystem.cpp | 139 ++++++++++++------ 3 files changed, 117 insertions(+), 51 deletions(-) diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index 2c7013e4..00f36ac7 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -129,14 +129,23 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm if (val > 0) { Events::AutoAnimationBlend aeb; aeb.Duration = 0.1; - aeb.NodeName = "Run"; + + if(m_Crouching) { + aeb.NodeName = "Walk"; + } else { + aeb.NodeName = "Run"; + } aeb.RootNode = playerModel; aeb.Start = true; m_EventBroker->Publish(aeb); } else if (val < 0) { Events::AutoAnimationBlend aeb; aeb.Duration = 0.1; - aeb.NodeName = "Run"; + if (m_Crouching) { + aeb.NodeName = "Walk"; + } else { + aeb.NodeName = "Run"; + } aeb.RootNode = playerModel; aeb.Start = true; aeb.Reverse = true; diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 4ff512ac..475acf78 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -894,11 +894,11 @@ - + - StrafeLeftF - + StrafeRightF + 1 true @@ -906,11 +906,11 @@ - + - StrafeRightF - + StrafeLeftF + 1 true @@ -1022,7 +1022,7 @@ DashLeftF - 3 + 2 false @@ -1034,7 +1034,7 @@ DashRightF - 3 + 2 false diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 8fddbe96..3d897bf7 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -343,52 +343,109 @@ bool PlayerMovementSystem::OnDashAbility(Events::DashAbility & e) EntityWrapper dashEffect = entityFile->MergeInto(m_World); EntityWrapper playerModel = player.FirstChildByName("PlayerModel"); -/* - auto playerEntityModel = playerModel["Model"]; - + for (auto& kv : m_PlayerInputControllers) { + EntityWrapper player = kv.first; + auto& controller = kv.second; - if (player.HasComponent("Physics")) { - glm::vec3 velocity = (glm::vec3)player["Physics"]["Velocity"]; - - glm::vec2 direction = glm::vec2(velocity.x, velocity.z); - - std::string DashName = ""; - if (glm::abs(direction.x) > glm::abs(direction.y)) { - if(glm::sign(direction.x) > 0) { - DashName = "DashRight"; - } else { - DashName = "DashLeft"; - } - } else { - if (glm::sign(direction.y) > 0) { - DashName = "DashForward"; - } else { - DashName = "DashBackward"; - } + if (!player.Valid()) { + continue; } - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.1; - aeb.NodeName = DashName; - aeb.RootNode = playerModel; - aeb.Restart = true; - aeb.Start = true; - m_EventBroker->Publish(aeb); - } - { - Events::AutoAnimationBlend aeb; - aeb.Duration = 0.3; - aeb.NodeName = "StandCrouchBlend"; - aeb.RootNode = playerModel; - aeb.Delay = 0.3; - aeb.Start = true; - aeb.Restart = false; - aeb.AnimationEntity = playerModel.FirstChildByName(DashName); - m_EventBroker->Publish(aeb); + if (player.Valid()) { + EntityWrapper playerModel = player.FirstChildByName("PlayerModel"); + if (playerModel.Valid()) { + if (glm::abs(controller->Movement().x) > glm::abs(controller->Movement().z)) { + if (controller->Movement().x > 0) { + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.3; + aeb.NodeName = "DashRight"; + aeb.RootNode = playerModel; + aeb.Restart = true; + aeb.Start = true; + m_EventBroker->Publish(aeb); + } + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.3; + aeb.NodeName = "StandCrouchBlend"; + aeb.RootNode = playerModel; + aeb.Delay = -0.3; + aeb.Start = true; + aeb.Restart = false; + aeb.AnimationEntity = playerModel.FirstChildByName("DashForward"); + m_EventBroker->Publish(aeb); + } + } else { + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.3; + aeb.NodeName = "DashLeft"; + aeb.RootNode = playerModel; + aeb.Restart = true; + aeb.Start = true; + m_EventBroker->Publish(aeb); + } + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.3; + aeb.NodeName = "StandCrouchBlend"; + aeb.RootNode = playerModel; + aeb.Delay = -0.3; + aeb.Start = true; + aeb.Restart = false; + aeb.AnimationEntity = playerModel.FirstChildByName("DashForward"); + m_EventBroker->Publish(aeb); + } + } + } else { + if (controller->Movement().z < 0) { + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.3; + aeb.NodeName = "DashForward"; + aeb.RootNode = playerModel; + aeb.Restart = true; + aeb.Start = true; + m_EventBroker->Publish(aeb); + } + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.3; + aeb.NodeName = "StandCrouchBlend"; + aeb.RootNode = playerModel; + aeb.Delay = -0.3; + aeb.Start = true; + aeb.Restart = false; + aeb.AnimationEntity = playerModel.FirstChildByName("DashForward"); + m_EventBroker->Publish(aeb); + } + } else { + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.3; + aeb.NodeName = "DashBackward"; + aeb.RootNode = playerModel; + aeb.Restart = true; + aeb.Start = true; + m_EventBroker->Publish(aeb); + } + { + Events::AutoAnimationBlend aeb; + aeb.Duration = 0.3; + aeb.NodeName = "StandCrouchBlend"; + aeb.RootNode = playerModel; + aeb.Delay = -0.3; + aeb.Start = true; + aeb.Restart = false; + aeb.AnimationEntity = playerModel.FirstChildByName("DashForward"); + m_EventBroker->Publish(aeb); + } + } + } + } } } - */ /* auto playerEntityAnimation = playerModel["Animation"]; From 4557455e491387b141faed830b3b7c3152ce2bac Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Fri, 4 Mar 2016 09:41:12 +0100 Subject: [PATCH 243/252] HUD stuff --- .../Schema/Entities/PlayerAssaultBlue.xml | 368 +++++++++--------- .../Schema/Entities/PlayerAssaultRed.xml | 368 +++++++++--------- 2 files changed, 376 insertions(+), 360 deletions(-) diff --git a/resources/Schema/Entities/PlayerAssaultBlue.xml b/resources/Schema/Entities/PlayerAssaultBlue.xml index c918dcd6..18125e2c 100644 --- a/resources/Schema/Entities/PlayerAssaultBlue.xml +++ b/resources/Schema/Entities/PlayerAssaultBlue.xml @@ -84,150 +84,6 @@ - - - - - - - - - 1 - - - - - Textures/HealthHUD3.png - - - - - - - - - - - - - - - - - - - - - - - Textures/Core/White.png - - false - - - - - - - - - - - - - - - - Textures/Core/White.png - - false - - - - - - - - - - - - - - - - Textures/Core/White.png - - false - - - - - - - - - - - - - - - - - - - Textures/Core/White.png - - false - - - - - - - - - - - 0.0 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - - - - 1 - - - - 100/100 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - @@ -481,6 +337,158 @@ + + + + + + + + + + + + 1 + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + 1 + + + + + Textures/HealthHUD3.png + + + + + + + + + + + + + + + + + + + + + + + + Textures/Icons/Boosts/Assault-01.png + + false + + + + + + + + + + + + + + + + + Textures/Icons/Boosts/Defender-01.png + + false + + + + + + + + + + + + + + + + + Textures/Icons/Boosts/Sniper-01.png + + false + + + + + + + + + + + + + + + + + + + + Textures/Icons/Abilities/Superman-01.png + + false + + + + + + + + + + + + + 0.0 + Fonts/DroidSans.ttf,64 + + false + + + + + + + + + + + + + @@ -871,42 +879,6 @@ - - - - Left - Right - 0.033793529385008014 - - - - - - - - StrafeRightF - - 1 - true - - - - - - - - - StrafeLeftF - - 1 - true - - - - - - - @@ -943,6 +915,42 @@ + + + + Left + Right + 0.033793529385008014 + + + + + + + + StrafeRightF + + 1 + true + + + + + + + + + StrafeLeftF + + 1 + true + + + + + + + diff --git a/resources/Schema/Entities/PlayerAssaultRed.xml b/resources/Schema/Entities/PlayerAssaultRed.xml index af0ba963..6dfc94bc 100644 --- a/resources/Schema/Entities/PlayerAssaultRed.xml +++ b/resources/Schema/Entities/PlayerAssaultRed.xml @@ -84,150 +84,6 @@ - - - - - - - - - 1 - - - - - Textures/HealthHUD3.png - - - - - - - - - - - - - - - - - - - - - - - Textures/Core/White.png - - false - - - - - - - - - - - - - - - - Textures/Core/White.png - - false - - - - - - - - - - - - - - - - Textures/Core/White.png - - false - - - - - - - - - - - - - - - - - - - Textures/Core/White.png - - false - - - - - - - - - - - 0.0 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - - - - 1 - - - - 100/100 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - @@ -481,6 +337,158 @@ + + + + + + + + + + + + 1 + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + 1 + + + + + Textures/HealthHUD3.png + + + + + + + + + + + + + + + + + + + + + + + + Textures/Icons/Boosts/Assault-01.png + + false + + + + + + + + + + + + + + + + + Textures/Icons/Boosts/Defender-01.png + + false + + + + + + + + + + + + + + + + + Textures/Icons/Boosts/Sniper-01.png + + false + + + + + + + + + + + + + + + + + + + + Textures/Icons/Abilities/Superman-01.png + + false + + + + + + + + + + + + + 0.0 + Fonts/DroidSans.ttf,64 + + false + + + + + + + + + + + + + @@ -871,42 +879,6 @@ - - - - Left - Right - 0.033793529385008014 - - - - - - - - StrafeRightF - - 1 - true - - - - - - - - - StrafeLeftF - - 1 - true - - - - - - - @@ -943,6 +915,42 @@ + + + + Left + Right + 0.033793529385008014 + + + + + + + + StrafeRightF + + 1 + true + + + + + + + + + StrafeLeftF + + 1 + true + + + + + + + From 434ff1e7eb55e53a0e925e951f3a6c31da98f063 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Fri, 4 Mar 2016 10:03:06 +0100 Subject: [PATCH 244/252] ???? --- resources/Schema/Entities/MovementTest.xml | 6 +- resources/Schema/Entities/Player.xml | 189 +++-- .../Schema/Entities/PlayerAssaultBlue.xml | 658 +++++++++--------- .../Schema/Entities/PlayerAssaultRed.xml | 658 +++++++++--------- resources/Schema/Entities/PlayerModel.xml | 542 +++++++++++++++ .../Systems/Weapon/AssaultWeaponBehaviour.cpp | 12 + 6 files changed, 1300 insertions(+), 765 deletions(-) create mode 100644 resources/Schema/Entities/PlayerModel.xml diff --git a/resources/Schema/Entities/MovementTest.xml b/resources/Schema/Entities/MovementTest.xml index 8202bff3..50f77401 100644 --- a/resources/Schema/Entities/MovementTest.xml +++ b/resources/Schema/Entities/MovementTest.xml @@ -83,7 +83,7 @@ - Schema/Entities/Player.xml + Schema/Entities/PlayerAssaultBlue.xml @@ -98,7 +98,7 @@ - + @@ -111,7 +111,7 @@ - + diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 70b387bb..475acf78 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -484,12 +484,14 @@ - - MovementBlend - FinalBlend - + + BlendTreeAssaultWeapon + BlendTreeSecondaryWeapon + 0 + true + - Models/Characters/Assault/FirstPersonAssaultBlue.mesh + Models/Characters/Defender/FirstPersonDefenderBlue.mesh @@ -506,8 +508,8 @@ Schema/Entities/WeaponAssaultBlueView.xml - - + + @@ -524,30 +526,29 @@ Schema/Entities/SidearmWeaponView.xml - - + + - + - BlendTreeAssaultWeapon - BlendTreeSecondaryWeapon + Idle + WeaponAction 0 true - + Fire Reload - 0 - true + 1 @@ -555,8 +556,9 @@ - ShootRifleF + ShootShotgunF 1 + true false @@ -567,8 +569,9 @@ ReloadSwitchF + 1 - false + true @@ -576,50 +579,25 @@ - + + + IdleF + + 1 + true + - + - - Idle - Run - 0 - true - - - - - - RunF - 1 - true - true - - - - - - - - - IdleF - 1 - true - true - - - - - - + @@ -653,7 +631,6 @@ Models/Characters/Assault/AssaultBlue.mesh - false @@ -673,8 +650,8 @@ Schema/Entities/WeaponAssaultBlueWorld.xml - - + + @@ -694,8 +671,8 @@ Schema/Entities/SidearmWeaponWorld.xml - - + + @@ -741,12 +718,12 @@ ReloadSwitchBlend - MovementBlend + FinalMovementBlend - + StandCrouchBlend @@ -802,7 +779,7 @@ CrouchStrafeLeftF - + 1 true @@ -814,7 +791,7 @@ CrouchStrafeRightF - + 1 true @@ -828,7 +805,7 @@ CrouchWalkF - + 1 true @@ -871,42 +848,6 @@ - - - - Left - Right - 0.033793529385008014 - - - - - - - - StrafeRightF - - 1 - true - - - - - - - - - StrafeLeftF - - 1 - true - - - - - - - @@ -921,7 +862,7 @@ WalkF - + 1 true @@ -933,7 +874,43 @@ RunF - + + 1 + true + + + + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + StrafeRightF + + 1 + true + + + + + + + + + StrafeLeftF + 1 true @@ -949,7 +926,7 @@ IdleF - + 1 true @@ -1009,7 +986,7 @@ DashForwardF - 1 + 2 false @@ -1021,7 +998,7 @@ DashBackwardF - 1 + 2 false @@ -1045,7 +1022,7 @@ DashLeftF - 1 + 2 false @@ -1057,7 +1034,7 @@ DashRightF - 1 + 2 false @@ -1118,7 +1095,7 @@ IdleAssaultRifleU - + 1 true @@ -1130,7 +1107,7 @@ IdleSecWepU - + 1 true diff --git a/resources/Schema/Entities/PlayerAssaultBlue.xml b/resources/Schema/Entities/PlayerAssaultBlue.xml index 18125e2c..057a0abb 100644 --- a/resources/Schema/Entities/PlayerAssaultBlue.xml +++ b/resources/Schema/Entities/PlayerAssaultBlue.xml @@ -652,191 +652,179 @@ + + + BlendTreeAim + BlendTreeAssault + + + + + Models/Characters/Assault/AssaultBlue.mesh + + false + + + + + + - - BlendTreeAim - BlendTreeAssault - - - - - Models/Characters/Assault/AssaultBlue.mesh - - + + R_Arm_Weapon_Joint + + + AssaultWeapon + + + + + + Schema/Entities/WeaponAssaultBlueWorld.xml + + + + + + + + + + + + R_Arm_Weapon_Joint + + + SidearmWeapon + + + + + + Schema/Entities/SidearmWeaponWorld.xml + + + + + + + + + + + + AimPrimary + AimSecondary + 0 + true + - + - - R_Arm_Weapon_Joint - - - AssaultWeapon - - - - - - Schema/Entities/WeaponAssaultBlueWorld.xml - - - - - + + AimSecWepA + + false + true + + - + - - R_Arm_Weapon_Joint - - - SidearmWeapon - - - - - - Schema/Entities/SidearmWeaponWorld.xml - - - - - + + AimRifleA + + false + true + + - + + + + + + ReloadSwitchBlend + FinalMovementBlend + + + + + - AimPrimary - AimSecondary - 0 + StandCrouchBlend + JumpDashBlend + 2.5146881298480398e-63 true - - - - AimSecWepA - - false - true - - - - - - - - - AimRifleA - - false - true - - - - - - - - - - - ReloadSwitchBlend - MovementBlend - - - - - + - StandCrouchBlend - JumpDashBlend - 2.5146881298480398e-63 + StandMovement + CrouchMovement + 0 true - + - StandMovement - CrouchMovement - 0 - true + MovementBlend + Idle + 1 - + - MovementBlend - Idle - 1 + Walk + StrafeLRBlend + 0 - + - Walk - StrafeLRBlend - 0 + Left + Right + 0.033793529385008014 - - - - Left - Right - 0.033793529385008014 - - - - - - - - CrouchStrafeLeftF - - 1 - true - - - - - - - - - CrouchStrafeRightF - - 1 - true - - - - - - - - + - CrouchWalkF - + CrouchStrafeLeftF + + 1 + true + + + + + + + + + CrouchStrafeRightF + 1 true @@ -846,118 +834,11 @@ - + - CrouchF - - 1 - - - - - - - - - - - MovementBlend - Idle - 1 - - - - - - - - RunWalkBlend - StrafeLRBlend - 2.4565650245976452e-16 - - - - - - - - Walk - Run - 1.2938206818383024e-24 - - - - - - - - WalkF - - 1 - true - - - - - - - - - RunF - - 1 - true - - - - - - - - - - - Left - Right - 0.033793529385008014 - - - - - - - - StrafeRightF - - 1 - true - - - - - - - - - StrafeLeftF - - 1 - true - - - - - - - - - - - - - IdleF - + CrouchWalkF + 1 true @@ -967,70 +848,68 @@ - - - - - - Jump - DashBlend - 1 - true - - - - - + - JumpF - + CrouchF + 1 - false - + + + + + + MovementBlend + Idle + 1 + + + + + - DashFBBlend - DashLRBlend - 0.014621149736541383 + RunWalkBlend + StrafeLRBlend + 2.4565650245976452e-16 - + - DashForward - DashBackward - 0.014363533804961248 + Walk + Run + 1.2938206818383024e-24 - + - DashForwardF - + WalkF + 1 - false + true - + - DashBackwardF - + RunF + 1 - false + true @@ -1038,35 +917,35 @@ - + - DashLeft - DashRight - 4.3244885367500671e-16 + Left + Right + 0.033793529385008014 - + - DashLeftF - + StrafeLeftF + 1 - false + true - + - DashRightF - + StrafeRightF + 1 - false + true @@ -1076,71 +955,84 @@ + + + + IdleF + + 1 + true + + + + + - + - ReloadSwitch - WeaponActionBlend + Jump + DashBlend 1 true - + - ReloadSwitchU - + JumpF + 1 + false - + - IdleBlend - ShootBlend - 0 + DashFBBlend + DashLRBlend + 0.014621149736541383 - + - IdlePrimary - IdleSecondary - 0 + DashForward + DashBackward + 0.014363533804961248 - + - IdleAssaultRifleU - - 1 - true + DashForwardF + + 2 + false - + - IdleSecWepU - - 1 - true + DashBackwardF + + 2 + false @@ -1148,31 +1040,35 @@ - + - ShootPrimary - ShootSecondary - 0 + DashLeft + DashRight + 4.3244885367500671e-16 - + - ShootFastRifleU - - 1 + DashLeftF + + 2 + false - + - ShootSecWepFastU + DashRightF + + 2 + false @@ -1186,8 +1082,114 @@ + + + + ReloadSwitch + WeaponActionBlend + 1 + true + + + + + + + + ReloadSwitchU + + 1 + + + + + + + + + IdleBlend + ShootBlend + 0 + + + + + + + + IdlePrimary + IdleSecondary + 0 + + + + + + + + IdleAssaultRifleU + + 1 + true + + + + + + + + + IdleSecWepU + + 1 + true + + + + + + + + + + + ShootPrimary + ShootSecondary + 0 + + + + + + + + ShootFastRifleU + + 1 + + + + + + + + + ShootSecWepFastU + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/PlayerAssaultRed.xml b/resources/Schema/Entities/PlayerAssaultRed.xml index 6dfc94bc..5811cc74 100644 --- a/resources/Schema/Entities/PlayerAssaultRed.xml +++ b/resources/Schema/Entities/PlayerAssaultRed.xml @@ -652,191 +652,179 @@ + + + BlendTreeAim + BlendTreeAssault + + + + + Models/Characters/Assault/AssaultRed.mesh + + false + + + + + + - - BlendTreeAim - BlendTreeAssault - - - - - Models/Characters/Assault/AssaultRed.mesh - - + + R_Arm_Weapon_Joint + + + AssaultWeapon + + + + + + Schema/Entities/WeaponAssaultRedWorld.xml + + + + + + + + + + + + R_Arm_Weapon_Joint + + + SidearmWeapon + + + + + + Schema/Entities/SidearmWeaponWorld.xml + + + + + + + + + + + + AimPrimary + AimSecondary + 0 + true + - + - - R_Arm_Weapon_Joint - - - AssaultWeapon - - - - - - Schema/Entities/WeaponAssaultRedWorld.xml - - - - - + + AimSecWepA + + false + true + + - + - - R_Arm_Weapon_Joint - - - SidearmWeapon - - - - - - Schema/Entities/SidearmWeaponWorld.xml - - - - - + + AimRifleA + + false + true + + - + + + + + + ReloadSwitchBlend + FinalMovementBlend + + + + + - AimPrimary - AimSecondary - 0 + StandCrouchBlend + JumpDashBlend + 2.5146881298480398e-63 true - - - - AimSecWepA - - false - true - - - - - - - - - AimRifleA - - false - true - - - - - - - - - - - ReloadSwitchBlend - MovementBlend - - - - - + - StandCrouchBlend - JumpDashBlend - 2.5146881298480398e-63 + StandMovement + CrouchMovement + 0 true - + - StandMovement - CrouchMovement - 0 - true + MovementBlend + Idle + 1 - + - MovementBlend - Idle - 1 + Walk + StrafeLRBlend + 0 - + - Walk - StrafeLRBlend - 0 + Left + Right + 0.033793529385008014 - - - - Left - Right - 0.033793529385008014 - - - - - - - - CrouchStrafeLeftF - - 1 - true - - - - - - - - - CrouchStrafeRightF - - 1 - true - - - - - - - - + - CrouchWalkF - + CrouchStrafeLeftF + + 1 + true + + + + + + + + + CrouchStrafeRightF + 1 true @@ -846,118 +834,11 @@ - + - CrouchF - - 1 - - - - - - - - - - - MovementBlend - Idle - 1 - - - - - - - - RunWalkBlend - StrafeLRBlend - 2.4565650245976452e-16 - - - - - - - - Walk - Run - 1.2938206818383024e-24 - - - - - - - - WalkF - - 1 - true - - - - - - - - - RunF - - 1 - true - - - - - - - - - - - Left - Right - 0.033793529385008014 - - - - - - - - StrafeRightF - - 1 - true - - - - - - - - - StrafeLeftF - - 1 - true - - - - - - - - - - - - - IdleF - + CrouchWalkF + 1 true @@ -967,70 +848,68 @@ - - - - - - Jump - DashBlend - 1 - true - - - - - + - JumpF - + CrouchF + 1 - false - + + + + + + MovementBlend + Idle + 1 + + + + + - DashFBBlend - DashLRBlend - 0.014621149736541383 + RunWalkBlend + StrafeLRBlend + 2.4565650245976452e-16 - + - DashForward - DashBackward - 0.014363533804961248 + Walk + Run + 1.2938206818383024e-24 - + - DashForwardF - + WalkF + 1 - false + true - + - DashBackwardF - + RunF + 1 - false + true @@ -1038,35 +917,35 @@ - + - DashLeft - DashRight - 4.3244885367500671e-16 + Left + Right + 0.033793529385008014 - + - DashLeftF - + StrafeLeftF + 1 - false + true - + - DashRightF - + StrafeRightF + 1 - false + true @@ -1076,71 +955,84 @@ + + + + IdleF + + 1 + true + + + + + - + - ReloadSwitch - WeaponActionBlend + Jump + DashBlend 1 true - + - ReloadSwitchU - + JumpF + 1 + false - + - IdleBlend - ShootBlend - 0 + DashFBBlend + DashLRBlend + 0.014621149736541383 - + - IdlePrimary - IdleSecondary - 0 + DashForward + DashBackward + 0.014363533804961248 - + - IdleAssaultRifleU - - 1 - true + DashForwardF + + 2 + false - + - IdleSecWepU - - 1 - true + DashBackwardF + + 2 + false @@ -1148,31 +1040,35 @@ - + - ShootPrimary - ShootSecondary - 0 + DashLeft + DashRight + 4.3244885367500671e-16 - + - ShootFastRifleU - - 1 + DashLeftF + + 2 + false - + - ShootSecWepFastU + DashRightF + + 2 + false @@ -1186,8 +1082,114 @@ + + + + ReloadSwitch + WeaponActionBlend + 1 + true + + + + + + + + ReloadSwitchU + + 1 + + + + + + + + + IdleBlend + ShootBlend + 0 + + + + + + + + IdlePrimary + IdleSecondary + 0 + + + + + + + + IdleAssaultRifleU + + 1 + true + + + + + + + + + IdleSecWepU + + 1 + true + + + + + + + + + + + ShootPrimary + ShootSecondary + 0 + + + + + + + + ShootFastRifleU + + 1 + + + + + + + + + ShootSecWepFastU + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/PlayerModel.xml b/resources/Schema/Entities/PlayerModel.xml new file mode 100644 index 00000000..a26fbc08 --- /dev/null +++ b/resources/Schema/Entities/PlayerModel.xml @@ -0,0 +1,542 @@ + + + + + + BlendTreeAim + BlendTreeAssault + + + + + Models/Characters/Assault/AssaultBlue.mesh + + false + + + + + + + + + R_Arm_Weapon_Joint + + + AssaultWeapon + + + + + + Schema/Entities/WeaponAssaultBlueWorld.xml + + + + + + + + + + + + R_Arm_Weapon_Joint + + + SidearmWeapon + + + + + + Schema/Entities/SidearmWeaponWorld.xml + + + + + + + + + + + + AimPrimary + AimSecondary + 0 + true + + + + + + + + AimSecWepA + + false + true + + + + + + + + + AimRifleA + + false + true + + + + + + + + + + + ReloadSwitchBlend + FinalMovementBlend + + + + + + + + StandCrouchBlend + JumpDashBlend + 2.5146881298480398e-63 + true + + + + + + + + StandMovement + CrouchMovement + 0 + true + + + + + + + + MovementBlend + Idle + 1 + + + + + + + + Walk + StrafeLRBlend + 0 + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + CrouchStrafeLeftF + + 1 + true + + + + + + + + + CrouchStrafeRightF + + 1 + true + + + + + + + + + + + CrouchWalkF + + 1 + true + + + + + + + + + + + CrouchF + + 1 + + + + + + + + + + + MovementBlend + Idle + 1 + + + + + + + + RunWalkBlend + StrafeLRBlend + 2.4565650245976452e-16 + + + + + + + + Walk + Run + 1.2938206818383024e-24 + + + + + + + + WalkF + + 1 + true + + + + + + + + + RunF + + 1 + true + + + + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + StrafeLeftF + + 1 + true + + + + + + + + + StrafeRightF + + 1 + true + + + + + + + + + + + + + IdleF + + 1 + true + + + + + + + + + + + + + Jump + DashBlend + 1 + true + + + + + + + + JumpF + + 1 + false + + + + + + + + + DashFBBlend + DashLRBlend + 0.014621149736541383 + + + + + + + + DashForward + DashBackward + 0.014363533804961248 + + + + + + + + DashForwardF + + 2 + false + + + + + + + + + DashBackwardF + + 2 + false + + + + + + + + + + + DashLeft + DashRight + 4.3244885367500671e-16 + + + + + + + + DashLeftF + + 2 + false + + + + + + + + + DashRightF + + 2 + false + + + + + + + + + + + + + + + + + ReloadSwitch + WeaponActionBlend + 1 + true + + + + + + + + ReloadSwitchU + + 1 + + + + + + + + + IdleBlend + ShootBlend + 0 + + + + + + + + IdlePrimary + IdleSecondary + 0 + + + + + + + + IdleAssaultRifleU + + 1 + true + + + + + + + + + IdleSecWepU + + 1 + true + + + + + + + + + + + ShootPrimary + ShootSecondary + 0 + + + + + + + + ShootFastRifleU + + 1 + + + + + + + + + ShootSecWepFastU + + + + + + + + + + + + + + + + diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp index 3e97fe85..2e21bc18 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -127,6 +127,12 @@ void AssaultWeaponBehaviour::OnReload(ComponentWrapper cWeapon, WeaponInfo& wi) wi.FirstPersonEntity["Model"]["Visible"] = false; wi.ThirdPersonEntity["Model"]["Visible"] = false; } + + // Sound + Events::PlaySoundOnEntity e; + e.EmitterID = wi.Player.ID; + e.FilePath = "Audio/weapon/Assault/AssaultWeaponReload.wav"; + m_EventBroker->Publish(e); } void AssaultWeaponBehaviour::OnEquip(ComponentWrapper cWeapon, WeaponInfo& wi) @@ -208,6 +214,12 @@ void AssaultWeaponBehaviour::fireBullet(ComponentWrapper cWeapon, WeaponInfo& wi // Play animation playAnimationAndReturn(wi.FirstPersonEntity, "BlendTreeAssaultWeapon", "Fire"); + + // Sound + Events::PlaySoundOnEntity e; + e.EmitterID = wi.Player.ID; + e.FilePath = "Audio/weapon/Assault/AssaultWeaponFire.wav"; + m_EventBroker->Publish(e); } bool AssaultWeaponBehaviour::canFire(ComponentWrapper cWeapon, WeaponInfo& wi) From b7a7f7fd5e4279af002ecfa03cc44c4ee7a37ec4 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Fri, 4 Mar 2016 15:02:01 +0100 Subject: [PATCH 245/252] ???? --- include/Engine/Network/Client.h | 2 +- include/Engine/Network/Server.h | 2 +- .../Schema/Entities/PlayerAssaultBlue.xml | 771 ++++++++++-------- .../Schema/Entities/PlayerAssaultRed.xml | 771 ++++++++++-------- src/Engine/Network/Client.cpp | 28 +- src/Engine/Network/Server.cpp | 71 +- src/Engine/Network/UDPServer.cpp | 11 +- .../Systems/Weapon/AssaultWeaponBehaviour.cpp | 16 +- 8 files changed, 951 insertions(+), 721 deletions(-) diff --git a/include/Engine/Network/Client.h b/include/Engine/Network/Client.h index 4ee071d2..2fa81549 100644 --- a/include/Engine/Network/Client.h +++ b/include/Engine/Network/Client.h @@ -52,7 +52,7 @@ public: void Connect(std::string address, int port); void Update() override; private: - UDPClient m_Unreliable; + //UDPClient m_Unreliable; TCPClient m_Reliable; std::vector m_PlayerSpawnEvents; void parseSpawnEvents(); diff --git a/include/Engine/Network/Server.h b/include/Engine/Network/Server.h index 395c80c7..48b7bcfa 100644 --- a/include/Engine/Network/Server.h +++ b/include/Engine/Network/Server.h @@ -36,7 +36,7 @@ public: private: // Network channels TCPServer m_Reliable; - UDPServer m_Unreliable; + //UDPServer m_Unreliable; UDPServer m_ServerlistRequest; // dont forget to set these in the childrens receive logic boost::asio::ip::address m_Address; diff --git a/resources/Schema/Entities/PlayerAssaultBlue.xml b/resources/Schema/Entities/PlayerAssaultBlue.xml index 057a0abb..7773235b 100644 --- a/resources/Schema/Entities/PlayerAssaultBlue.xml +++ b/resources/Schema/Entities/PlayerAssaultBlue.xml @@ -6,7 +6,9 @@ - + + 0.5 + @@ -519,7 +521,113 @@ - + + + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + + + + + + Schema/Entities/RayBlue.xml + + + + + + + + + + + + Schema/Entities/ReloadEffectView.xml + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + + + + 32 + Fonts/DroidSans.ttf,64 + + + + PlayerAssault + AssaultWeapon + MagazineAmmo + + + + + + + + + + + 320 + Fonts/DroidSans.ttf,64 + + + + PlayerAssault + AssaultWeapon + Ammo + + + + + + + + + + + + + + + @@ -652,179 +760,192 @@ - - - BlendTreeAim - BlendTreeAssault - - - - - Models/Characters/Assault/AssaultBlue.mesh - - false - - - - - - - - R_Arm_Weapon_Joint - - - AssaultWeapon - - - - - - Schema/Entities/WeaponAssaultBlueWorld.xml - - - - - - - - - - - - R_Arm_Weapon_Joint - - - SidearmWeapon - - - - - - Schema/Entities/SidearmWeaponWorld.xml - - - - - - - - - - - - AimPrimary - AimSecondary - 0 - true - + + BlendTreeAim + BlendTreeAssault + + + + + Models/Characters/Assault/AssaultBlue.mesh + + true + - + - - AimSecWepA - - false - true - - + + R_Arm_Weapon_Joint + + + AssaultWeapon + + + + + + Schema/Entities/WeaponAssaultBlueWorld.xml + + + + + - + - - AimRifleA - - false - true - - + + R_Arm_Weapon_Joint + + + SidearmWeapon + + + + + + Schema/Entities/SidearmWeaponWorld.xml + + + + + - - - - - - ReloadSwitchBlend - FinalMovementBlend - - - - - + - StandCrouchBlend - JumpDashBlend - 2.5146881298480398e-63 + AimPrimary + AimSecondary + 0 true - + + + + AimSecWepA + + false + true + + + + + + + + + AimRifleA + + false + true + + + + + + + + + + + ReloadSwitchBlend + FinalMovementBlend + + + + + - StandMovement - CrouchMovement - 0 + StandCrouchBlend + JumpDashBlend + 2.5146881298480398e-63 true - + - MovementBlend - Idle - 1 + StandMovement + CrouchMovement + 0 + true - + - Walk - StrafeLRBlend - 0 + MovementBlend + Idle + 1 - + - Left - Right - 0.033793529385008014 + Walk + StrafeLRBlend + 0 - + - - CrouchStrafeLeftF - - 1 - true - + + Left + Right + 0.033793529385008014 + - + + + + + CrouchStrafeLeftF + + 1 + true + + + + + + + + + CrouchStrafeRightF + + 1 + true + + + + + + - + - CrouchStrafeRightF - + CrouchWalkF + 1 true @@ -834,11 +955,118 @@ - + - CrouchWalkF - + CrouchF + + 1 + + + + + + + + + + + MovementBlend + Idle + 1 + + + + + + + + RunWalkBlend + StrafeLRBlend + 2.4565650245976452e-16 + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + StrafeLeftF + + 1 + true + + + + + + + + + StrafeRightF + + 1 + true + + + + + + + + + + + Walk + Run + 1.2938206818383024e-24 + + + + + + + + WalkF + + 1 + true + + + + + + + + + RunF + + 1 + true + + + + + + + + + + + + + IdleF + 1 true @@ -848,68 +1076,70 @@ - + + + + + + Jump + DashBlend + 1 + true + + + + + - CrouchF - + JumpF + 1 + false - - - - - - MovementBlend - Idle - 1 - - - - - + - RunWalkBlend - StrafeLRBlend - 2.4565650245976452e-16 + DashFBBlend + DashLRBlend + 0.014621149736541383 - + - Walk - Run - 1.2938206818383024e-24 + DashForward + DashBackward + 0.014363533804961248 - + - WalkF - - 1 - true + DashForwardF + + 2 + false - + - RunF - - 1 - true + DashBackwardF + + 2 + false @@ -917,35 +1147,35 @@ - + - Left - Right - 0.033793529385008014 + DashLeft + DashRight + 4.3244885367500671e-16 - + - StrafeLeftF - - 1 - true + DashLeftF + + 2 + false - + - StrafeRightF - - 1 - true + DashRightF + + 2 + false @@ -955,84 +1185,71 @@ - - - - IdleF - - 1 - true - - - - - - + - Jump - DashBlend + ReloadSwitch + WeaponActionBlend 1 true - + - JumpF - + ReloadSwitchU + 1 - false - + - DashFBBlend - DashLRBlend - 0.014621149736541383 + IdleBlend + ShootBlend + 0 - + - DashForward - DashBackward - 0.014363533804961248 + IdlePrimary + IdleSecondary + 0 - + - DashForwardF - - 2 - false + IdleAssaultRifleU + + 1 + true - + - DashBackwardF - - 2 - false + IdleSecWepU + + 1 + true @@ -1040,35 +1257,31 @@ - + - DashLeft - DashRight - 4.3244885367500671e-16 + ShootPrimary + ShootSecondary + 0 - + - DashLeftF - - 2 - false + ShootFastRifleU + + 1 - + - DashRightF - - 2 - false + ShootSecWepFastU @@ -1082,114 +1295,8 @@ - - - - ReloadSwitch - WeaponActionBlend - 1 - true - - - - - - - - ReloadSwitchU - - 1 - - - - - - - - - IdleBlend - ShootBlend - 0 - - - - - - - - IdlePrimary - IdleSecondary - 0 - - - - - - - - IdleAssaultRifleU - - 1 - true - - - - - - - - - IdleSecWepU - - 1 - true - - - - - - - - - - - ShootPrimary - ShootSecondary - 0 - - - - - - - - ShootFastRifleU - - 1 - - - - - - - - - ShootSecWepFastU - - - - - - - - - - - - - diff --git a/resources/Schema/Entities/PlayerAssaultRed.xml b/resources/Schema/Entities/PlayerAssaultRed.xml index 5811cc74..a198196e 100644 --- a/resources/Schema/Entities/PlayerAssaultRed.xml +++ b/resources/Schema/Entities/PlayerAssaultRed.xml @@ -6,7 +6,9 @@ - + + 0.5 + @@ -519,7 +521,113 @@ - + + + + + Models/Weapons/Red/AssaultWeaponRed.mesh + + + + + + + + + + + + + + Schema/Entities/RayRed.xml + + + + + + + + + + + + Schema/Entities/ReloadEffectView.xml + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + + + + 32 + Fonts/DroidSans.ttf,64 + + + + PlayerAssault + AssaultWeapon + MagazineAmmo + + + + + + + + + + + 320 + Fonts/DroidSans.ttf,64 + + + + PlayerAssault + AssaultWeapon + Ammo + + + + + + + + + + + + + + + @@ -652,179 +760,192 @@ - - - BlendTreeAim - BlendTreeAssault - - - - - Models/Characters/Assault/AssaultRed.mesh - - false - - - - - - - - R_Arm_Weapon_Joint - - - AssaultWeapon - - - - - - Schema/Entities/WeaponAssaultRedWorld.xml - - - - - - - - - - - - R_Arm_Weapon_Joint - - - SidearmWeapon - - - - - - Schema/Entities/SidearmWeaponWorld.xml - - - - - - - - - - - - AimPrimary - AimSecondary - 0 - true - + + BlendTreeAim + BlendTreeAssault + + + + + Models/Characters/Assault/AssaultRed.mesh + + true + - + - - AimSecWepA - - false - true - - + + R_Arm_Weapon_Joint + + + AssaultWeapon + + + + + + Schema/Entities/WeaponAssaultRedWorld.xml + + + + + - + - - AimRifleA - - false - true - - + + R_Arm_Weapon_Joint + + + SidearmWeapon + + + + + + Schema/Entities/SidearmWeaponWorld.xml + + + + + - - - - - - ReloadSwitchBlend - FinalMovementBlend - - - - - + - StandCrouchBlend - JumpDashBlend - 2.5146881298480398e-63 + AimPrimary + AimSecondary + 0 true - + + + + AimSecWepA + + false + true + + + + + + + + + AimRifleA + + false + true + + + + + + + + + + + ReloadSwitchBlend + FinalMovementBlend + + + + + - StandMovement - CrouchMovement - 0 + StandCrouchBlend + JumpDashBlend + 2.5146881298480398e-63 true - + - MovementBlend - Idle - 1 + StandMovement + CrouchMovement + 0 + true - + - Walk - StrafeLRBlend - 0 + MovementBlend + Idle + 1 - + - Left - Right - 0.033793529385008014 + Walk + StrafeLRBlend + 0 - + - - CrouchStrafeLeftF - - 1 - true - + + Left + Right + 0.033793529385008014 + - + + + + + CrouchStrafeLeftF + + 1 + true + + + + + + + + + CrouchStrafeRightF + + 1 + true + + + + + + - + - CrouchStrafeRightF - + CrouchWalkF + 1 true @@ -834,11 +955,118 @@ - + - CrouchWalkF - + CrouchF + + 1 + + + + + + + + + + + MovementBlend + Idle + 1 + + + + + + + + RunWalkBlend + StrafeLRBlend + 2.4565650245976452e-16 + + + + + + + + Left + Right + 0.033793529385008014 + + + + + + + + StrafeLeftF + + 1 + true + + + + + + + + + StrafeRightF + + 1 + true + + + + + + + + + + + Walk + Run + 1.2938206818383024e-24 + + + + + + + + WalkF + + 1 + true + + + + + + + + + RunF + + 1 + true + + + + + + + + + + + + + IdleF + 1 true @@ -848,68 +1076,70 @@ - + + + + + + Jump + DashBlend + 1 + true + + + + + - CrouchF - + JumpF + 1 + false - - - - - - MovementBlend - Idle - 1 - - - - - + - RunWalkBlend - StrafeLRBlend - 2.4565650245976452e-16 + DashFBBlend + DashLRBlend + 0.014621149736541383 - + - Walk - Run - 1.2938206818383024e-24 + DashForward + DashBackward + 0.014363533804961248 - + - WalkF - - 1 - true + DashForwardF + + 2 + false - + - RunF - - 1 - true + DashBackwardF + + 2 + false @@ -917,35 +1147,35 @@ - + - Left - Right - 0.033793529385008014 + DashLeft + DashRight + 4.3244885367500671e-16 - + - StrafeLeftF - - 1 - true + DashLeftF + + 2 + false - + - StrafeRightF - - 1 - true + DashRightF + + 2 + false @@ -955,84 +1185,71 @@ - - - - IdleF - - 1 - true - - - - - - + - Jump - DashBlend + ReloadSwitch + WeaponActionBlend 1 true - + - JumpF - + ReloadSwitchU + 1 - false - + - DashFBBlend - DashLRBlend - 0.014621149736541383 + IdleBlend + ShootBlend + 0 - + - DashForward - DashBackward - 0.014363533804961248 + IdlePrimary + IdleSecondary + 0 - + - DashForwardF - - 2 - false + IdleAssaultRifleU + + 1 + true - + - DashBackwardF - - 2 - false + IdleSecWepU + + 1 + true @@ -1040,35 +1257,31 @@ - + - DashLeft - DashRight - 4.3244885367500671e-16 + ShootPrimary + ShootSecondary + 0 - + - DashLeftF - - 2 - false + ShootFastRifleU + + 1 - + - DashRightF - - 2 - false + ShootSecWepFastU @@ -1082,114 +1295,8 @@ - - - - ReloadSwitch - WeaponActionBlend - 1 - true - - - - - - - - ReloadSwitchU - - 1 - - - - - - - - - IdleBlend - ShootBlend - 0 - - - - - - - - IdlePrimary - IdleSecondary - 0 - - - - - - - - IdleAssaultRifleU - - 1 - true - - - - - - - - - IdleSecWepU - - 1 - true - - - - - - - - - - - ShootPrimary - ShootSecondary - 0 - - - - - - - - ShootFastRifleU - - 1 - - - - - - - - - ShootSecWepFastU - - - - - - - - - - - - - diff --git a/src/Engine/Network/Client.cpp b/src/Engine/Network/Client.cpp index d666e550..e29c4755 100644 --- a/src/Engine/Network/Client.cpp +++ b/src/Engine/Network/Client.cpp @@ -49,16 +49,16 @@ void Client::Connect(std::string address, int port) void Client::Update() { m_EventBroker->Process(); - while (m_Unreliable.IsSocketAvailable()) { - // Packet will get real data in receive - Packet packet(MessageType::Invalid); - m_Unreliable.Receive(packet); - if (packet.GetMessageType() == MessageType::Connect) { - parseUDPConnect(packet); - } else { - parseMessageType(packet); - } - } + //while (m_Unreliable.IsSocketAvailable()) { + // // Packet will get real data in receive + // Packet packet(MessageType::Invalid); + // m_Unreliable.Receive(packet); + // if (packet.GetMessageType() == MessageType::Connect) { + // parseUDPConnect(packet); + // } else { + // parseMessageType(packet); + // } + //} while (m_Reliable.IsSocketAvailable()) { // Packet will get real data in receive Packet packet(MessageType::Invalid); @@ -177,8 +177,8 @@ void Client::parseTCPConnect(Packet& packet) Packet UnreliablePacket(MessageType::Connect, m_SendPacketID); // Add player id and other stuff packet.WritePrimitive(m_PlayerID); - m_Unreliable.Send(packet); - LOG_INFO("Sent UDP Connect Server"); + // m_Unreliable.Send(packet); + // LOG_INFO("Sent UDP Connect Server"); } void Client::parsePlayerConnected(Packet & packet) @@ -476,7 +476,7 @@ bool Client::OnInputCommand(const Events::InputCommand & e) if (e.Command == "ConnectToServer") { // Connect for now if (e.Value > 0) { m_Reliable.Connect(m_PlayerName, m_Address, m_Port); - m_Unreliable.Connect(m_PlayerName, m_Address, m_Port); + // m_Unreliable.Connect(m_PlayerName, m_Address, m_Port); } //LOG_DEBUG("Client::OnInputCommand: Command is %s. Value is %f. PlayerID is %i.", e.Command.c_str(), e.Value, e.PlayerID); return true; @@ -613,7 +613,7 @@ void Client::sendLocalPlayerTransform() packet.WritePrimitive((int)cAssaultWeapon["Ammo"]); } - m_Unreliable.Send(packet); + m_Reliable.Send(packet); } void Client::identifyPacketLoss() diff --git a/src/Engine/Network/Server.cpp b/src/Engine/Network/Server.cpp index 0927a675..5bfb4000 100644 --- a/src/Engine/Network/Server.cpp +++ b/src/Engine/Network/Server.cpp @@ -47,19 +47,19 @@ void Server::Update() } } - PlayerDefinition pd; - while (m_Unreliable.IsSocketAvailable()) { - // Packet will get real data in receive - Packet packet(MessageType::Invalid); - m_Unreliable.Receive(packet, pd); - m_Address = pd.Endpoint.address(); - m_Port = pd.Endpoint.port(); - if (packet.GetMessageType() == MessageType::Connect) { - parseUDPConnect(packet); - } else { - parseMessageType(packet); - } - } + //PlayerDefinition pd; + //while (m_Unreliable.IsSocketAvailable()) { + // // Packet will get real data in receive + // Packet packet(MessageType::Invalid); + // m_Unreliable.Receive(packet, pd); + // m_Address = pd.Endpoint.address(); + // m_Port = pd.Endpoint.port(); + // if (packet.GetMessageType() == MessageType::Connect) { + // parseUDPConnect(packet); + // } else { + // parseMessageType(packet); + // } + //} while (m_ServerlistRequest.IsSocketAvailable()) { Packet packet(MessageType::Invalid); @@ -162,7 +162,7 @@ void Server::unreliableBroadcast(Packet& packet) { for (auto& kv : m_ConnectedPlayers) { packet.ChangePacketID(kv.second.PacketID); - m_Unreliable.Send(packet, kv.second); +// m_Unreliable.Send(packet, kv.second); } } @@ -172,7 +172,7 @@ void Server::sendSnapshot() Packet packet(MessageType::Snapshot); addInputCommandsToPacket(packet); addPlayersToPacket(packet, EntityID_Invalid); - unreliableBroadcast(packet); + reliableBroadcast(packet); } void Server::addInputCommandsToPacket(Packet& packet) @@ -320,25 +320,28 @@ void Server::checkForTimeOuts() } } -void Server::parseUDPConnect(Packet & packet) -{ - // Pop size of message int - packet.ReadPrimitive(); - int messageType = packet.ReadPrimitive(); - // Read packet ID - m_PreviousPacketID = m_PacketID; // Set previous packet id - m_PacketID = packet.ReadPrimitive(); //Read new packet id - // parse player id and other stuff - PlayerID playerID = packet.ReadPrimitive(); - // Do something here? - boost::asio::ip::udp::endpoint endpoint(m_Address, m_Port); - m_ConnectedPlayers.at(playerID).Endpoint = endpoint; - LOG_INFO("parseUDPConnect: Spectator \"%s\" connected on IP: %s", m_ConnectedPlayers.at(playerID).Name.c_str(), m_ConnectedPlayers.at(playerID).Endpoint.address().to_string().c_str()); - // Send a message to the player that connected - Packet connnectPacket(MessageType::Connect, m_ConnectedPlayers.at(playerID).PacketID); - m_Unreliable.Send(connnectPacket); - LOG_INFO("UDP Connect sent to client"); -} +//void Server::parseUDPConnect(Packet & packet) +//{ +// // Pop size of message int +// packet.ReadPrimitive(); +// int messageType = packet.ReadPrimitive(); +// // Read packet ID +// m_PreviousPacketID = m_PacketID; // Set previous packet id +// m_PacketID = packet.ReadPrimitive(); //Read new packet id +// // parse player id and other stuff +// PlayerID playerID = packet.ReadPrimitive(); +// if (!EntityWrapper(m_World, playerID).Valid()) { +// +// } +// // Do something here? +// boost::asio::ip::udp::endpoint endpoint(m_Address, m_Port); +// m_ConnectedPlayers.at(playerID).Endpoint = endpoint; +// LOG_INFO("parseUDPConnect: Spectator \"%s\" connected on IP: %s", m_ConnectedPlayers.at(playerID).Name.c_str(), m_ConnectedPlayers.at(playerID).Endpoint.address().to_string().c_str()); +// // Send a message to the player that connected +// Packet connnectPacket(MessageType::Connect, m_ConnectedPlayers.at(playerID).PacketID); +// m_Unreliable.Send(connnectPacket); +// LOG_INFO("UDP Connect sent to client"); +//} void Server::parseTCPConnect(Packet & packet) { diff --git a/src/Engine/Network/UDPServer.cpp b/src/Engine/Network/UDPServer.cpp index 8c9950dc..bfa27d69 100644 --- a/src/Engine/Network/UDPServer.cpp +++ b/src/Engine/Network/UDPServer.cpp @@ -21,33 +21,38 @@ void UDPServer::Send(Packet& packet, PlayerDefinition & playerDefinition) boost::asio::buffer(packet.Data(), packet.Size()), playerDefinition.Endpoint, 0); + LOG_INFO("Size of packet is %i", bytesSent); } catch (const boost::system::system_error& e) { + LOG_INFO(e.what()); // TODO: Clean up invalid endpoints out of m_ConnectedPlayers later playerDefinition.Endpoint = boost::asio::ip::udp::endpoint(); } + } // Send back to endpoint of received packet void UDPServer::Send(Packet & packet) { packet.UpdateSize(); - m_Socket->send_to( + size_t bytesSent = m_Socket->send_to( boost::asio::buffer( packet.Data(), packet.Size()), m_ReceiverEndpoint, 0); + LOG_INFO("Size of packet is %i", bytesSent); } // Broadcasting respond specific logic void UDPServer::Send(Packet & packet, boost::asio::ip::udp::endpoint endpoint) { packet.UpdateSize(); - m_Socket->send_to( + size_t bytesSent = m_Socket->send_to( boost::asio::buffer( packet.Data(), packet.Size()), endpoint, 0); + LOG_INFO("Size of packet is %i", bytesSent); } // Broadcasting @@ -55,7 +60,7 @@ void UDPServer::Broadcast(Packet & packet, int port) { packet.UpdateSize(); m_Socket->set_option(boost::asio::socket_base::broadcast(true)); - m_Socket->send_to( + size_t bytesSent = m_Socket->send_to( boost::asio::buffer( packet.Data(), packet.Size()), diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp index 2e21bc18..fc5334c9 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -39,8 +39,12 @@ void AssaultWeaponBehaviour::UpdateWeapon(ComponentWrapper cWeapon, WeaponInfo& ammo = glm::max(0, ammo - (magSize - magAmmo)); magAmmo = glm::min(magSize, ammo); isReloading = false; - wi.FirstPersonEntity["Model"]["Visible"] = true; - wi.ThirdPersonEntity["Model"]["Visible"] = true; + if (wi.FirstPersonEntity.Valid()) { + wi.FirstPersonEntity["Model"]["Visible"] = true; + } + if (wi.ThirdPersonEntity.Valid()) { + wi.ThirdPersonEntity["Model"]["Visible"] = true; + } } // Restore view angle @@ -124,8 +128,12 @@ void AssaultWeaponBehaviour::OnReload(ComponentWrapper cWeapon, WeaponInfo& wi) if (reloadEffectSpawner.Valid()) { SpawnerSystem::Spawn(reloadEffectSpawner, reloadEffectSpawner); } - wi.FirstPersonEntity["Model"]["Visible"] = false; - wi.ThirdPersonEntity["Model"]["Visible"] = false; + if (wi.FirstPersonEntity.Valid()) { + wi.FirstPersonEntity["Model"]["Visible"] = false; + } + if (wi.ThirdPersonEntity.Valid()) { + wi.ThirdPersonEntity["Model"]["Visible"] = false; + } } // Sound From a8f2d0a8e6edddca2ece78fc2538aea5001fb836 Mon Sep 17 00:00:00 2001 From: Tleety Date: Mon, 7 Mar 2016 10:48:46 +0100 Subject: [PATCH 246/252] Some assets, some fixes to the scoreboard --- assets | 2 +- resources/Schema/Entities/CP_Rocky.xml | 2288 ++++++++--------- resources/Schema/Entities/ScoreBoard_Main.xml | 4 +- src/Game/Systems/ScoreScreenSystem.cpp | 2 +- 4 files changed, 1148 insertions(+), 1148 deletions(-) diff --git a/assets b/assets index 7a6d7078..0ae73657 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 7a6d70787b036d8ae8763b69ae6ad098bf221c22 +Subproject commit 0ae736570b5600c2ad05f556ccaec4f5341c2b06 diff --git a/resources/Schema/Entities/CP_Rocky.xml b/resources/Schema/Entities/CP_Rocky.xml index a9c4aaac..d034be78 100644 --- a/resources/Schema/Entities/CP_Rocky.xml +++ b/resources/Schema/Entities/CP_Rocky.xml @@ -21,6 +21,27 @@ + + + + + Models/Props/Highground5.mesh + + + + + + + + + + Models/Props/Highground6.mesh + + + + + + @@ -46,11 +67,9 @@ - Models/Props/Walls/SciFiWallBig.mesh + Models/Props/Walls/SciFiWallSmall1.mesh - - - + @@ -69,9 +88,11 @@ - Models/Props/Walls/SciFiWallMedium.mesh + Models/Props/Walls/SciFiWallBig.mesh - + + + @@ -79,7 +100,7 @@ - Models/Props/Walls/SciFiWallSmall1.mesh + Models/Props/Walls/SciFiWallMedium.mesh @@ -149,8 +170,8 @@ Models/Core/UnitCube.mesh - - + + @@ -462,8 +483,8 @@ Models/Core/UnitCube.mesh - - + + @@ -494,23 +515,23 @@ - Schema/Entities/ScoreBoard_Blue.xml + Schema/Entities/ScoreBoard_Red.xml - + - + - + Models/Core/UnitCube.mesh - + @@ -519,14 +540,14 @@ - + - + @@ -623,23 +644,23 @@ - Schema/Entities/ScoreBoard_Red.xml + Schema/Entities/ScoreBoard_Blue.xml - + - + - + Models/Core/UnitCube.mesh - + @@ -648,14 +669,14 @@ - + - + @@ -798,27 +819,6 @@ - - - - - Models/Props/Highground5.mesh - - - - - - - - - - Models/Props/Highground6.mesh - - - - - - @@ -944,6 +944,20 @@ + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + @@ -1103,20 +1117,6 @@ - - - - - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - - @@ -1430,11 +1430,11 @@ 2 - + - + @@ -1451,7 +1451,7 @@ - + @@ -1477,11 +1477,11 @@ 2 - + - + @@ -1498,7 +1498,7 @@ - + @@ -1524,11 +1524,11 @@ 2 - + - + @@ -1545,7 +1545,7 @@ - + @@ -1571,11 +1571,11 @@ 2 - + - + @@ -1592,7 +1592,7 @@ - + @@ -1618,11 +1618,11 @@ 2 - + - + @@ -1639,7 +1639,7 @@ - + @@ -1665,11 +1665,11 @@ 2 - + - + @@ -1686,7 +1686,7 @@ - + @@ -1712,11 +1712,11 @@ 2 - + - + @@ -1733,7 +1733,7 @@ - + @@ -2981,11 +2981,11 @@ 2 - + - + @@ -3002,7 +3002,7 @@ - + @@ -3028,11 +3028,11 @@ 2 - + - + @@ -3049,7 +3049,7 @@ - + @@ -3301,19 +3301,6 @@ - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - @@ -3382,237 +3369,21 @@ - - - - - - - - Models/Props/Walls/SmallWall3.mesh + Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - + + - - - - Models/Core/UnitPlane.mesh - - true - - - - - - - - - @@ -3630,58 +3401,6 @@ - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - - @@ -3734,6 +3453,58 @@ + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + @@ -3826,6 +3597,235 @@ + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + @@ -3855,37 +3855,11 @@ - Models/Props/Stones/BigStone.mesh + Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - + + @@ -3917,6 +3891,164 @@ + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + @@ -3948,11 +4080,103 @@ - Models/Props/Stones/SmallStone1.mesh + Models/Props/Stones/BigStone.mesh - - + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + @@ -3970,6 +4194,19 @@ + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + @@ -4038,98 +4275,6 @@ - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - @@ -4144,151 +4289,6 @@ - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - @@ -4304,9 +4304,59 @@ Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + @@ -4347,47 +4397,27 @@ Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - + + + - - - - - - - - - - - - - - - - - 2 - - - - - - - - - - - - - - - - - - - + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + @@ -4403,21 +4433,6 @@ - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - @@ -4433,6 +4448,18 @@ + + + + + 3 + + + + + + + @@ -4458,18 +4485,6 @@ - - - - - 3 - - - - - - - @@ -4487,21 +4502,6 @@ - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - @@ -4509,6 +4509,53 @@ + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + @@ -4525,11 +4572,11 @@ 2 - + - + @@ -4546,54 +4593,7 @@ - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - 2 - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - + @@ -4619,11 +4619,11 @@ 2 - + - + @@ -4640,148 +4640,7 @@ - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - 2 - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - 2 - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - 2 - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - + @@ -4807,11 +4666,11 @@ 2 - + - + @@ -4828,7 +4687,148 @@ - + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + 2 + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + @@ -4845,21 +4845,6 @@ - - - - - 6 - Models/Props/Pillars/SciFiPillar1Blue.mesh - - - - - - - - - @@ -4888,6 +4873,21 @@ + + + + + 6 + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + @@ -4906,84 +4906,70 @@ - + - + + + Schema/Entities/Player.xml + + + + + + + + + - + - - 10 - + + + Models/Characters/Assault/AssaultTPose.mesh + false + - + - + - - 1 - - - - - - - - - - 10 - + + + Models/Characters/Assault/AssaultTPose.mesh + false + - + - + - - - 10 - + + + Models/Characters/Assault/AssaultTPose.mesh + false + - + - + - - 10 - + + + Models/Characters/Assault/AssaultTPose.mesh + false + - - - - - - - - - 10 - - - - - - - - - - - 0.40000000596046448 - - - + @@ -5006,19 +4992,6 @@ - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - @@ -5032,19 +5005,6 @@ - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - @@ -5058,6 +5018,116 @@ + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + + + + + + + + 10 + + + + + + + + + + + 0.40000000596046448 + + + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + + 10 + + + + + + + + + + + 1 + + + + + + + + + 10 + + + + + + + @@ -5065,6 +5135,38 @@ + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 1 + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + @@ -5105,38 +5207,6 @@ - - - - - Models/Props/CapturePoint/CapturePointNeutral.mesh - - - - - - - - - - 3 - - - - Models/Core/UnitCylinder.mesh - - true - - - - - - - - - - - @@ -5169,38 +5239,6 @@ - - - - - Models/Props/CapturePoint/CapturePointNeutral.mesh - - - - - - - - - - 1 - - - - Models/Core/UnitCylinder.mesh - - true - - - - - - - - - - - @@ -5240,75 +5278,37 @@ - - - - - - - Schema/Entities/Player.xml - - - - - - - - - - - - + - + - Models/Characters/Assault/AssaultTPose.mesh - false + Models/Props/CapturePoint/CapturePointNeutral.mesh - + - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - + + + + + 3 + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + diff --git a/resources/Schema/Entities/ScoreBoard_Main.xml b/resources/Schema/Entities/ScoreBoard_Main.xml index 565fb57b..ccc1df68 100644 --- a/resources/Schema/Entities/ScoreBoard_Main.xml +++ b/resources/Schema/Entities/ScoreBoard_Main.xml @@ -21,11 +21,11 @@ - + - + diff --git a/src/Game/Systems/ScoreScreenSystem.cpp b/src/Game/Systems/ScoreScreenSystem.cpp index 6166e892..94674432 100644 --- a/src/Game/Systems/ScoreScreenSystem.cpp +++ b/src/Game/Systems/ScoreScreenSystem.cpp @@ -78,7 +78,7 @@ void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& if (it == m_PlayerIdentities.end()) { break; - } + } if(found == false) { if(it->second.Team != currentTeam) { From 388fe7c259fd71418fbe67c101a14d0b45f44eeb Mon Sep 17 00:00:00 2001 From: Tleety Date: Mon, 7 Mar 2016 11:28:10 +0100 Subject: [PATCH 247/252] Fixed some stuff on the player HUD --- resources/Schema/Entities/PlayerHUD.xml | 356 +++++++++++++----------- 1 file changed, 195 insertions(+), 161 deletions(-) diff --git a/resources/Schema/Entities/PlayerHUD.xml b/resources/Schema/Entities/PlayerHUD.xml index e3e9165b..cf07bc56 100644 --- a/resources/Schema/Entities/PlayerHUD.xml +++ b/resources/Schema/Entities/PlayerHUD.xml @@ -31,116 +31,6 @@ - - - - - - - - - 1 - - - - - Textures/HUD/HealthHudTriMain.png - - - - - - - - - - - - - - - - - - - - - - - Textures/Core/White.png - - false - - - - - - - - - - - - - - - - Textures/Core/White.png - - false - - - - - - - - - - - - - - - - Textures/Core/White.png - - false - - - - - - - - - - - - - - - - - 1 - - - - 100/100 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - @@ -154,40 +44,7 @@ Textures/Core/UnitHexagon.png - - - - - - - - - - - 2 - - - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - + false @@ -197,15 +54,16 @@ - - 3 - + + 3 + Textures/Core/UnitHexagon_Rotated.png + false @@ -222,6 +80,7 @@ Textures/Core/UnitHexagon.png + false @@ -231,16 +90,17 @@ - - 4 - 1 + + 4 + Textures/Core/UnitHexagon_Rotated.png + false @@ -257,6 +117,43 @@ Textures/Core/UnitHexagon.png + false + + + + + + + + + + + + + + 2 + + + Textures/Core/UnitHexagon_Rotated.png + + false + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + false @@ -266,15 +163,16 @@ - - 1 - + + 1 + Textures/Core/UnitHexagon_Rotated.png + false @@ -291,6 +189,7 @@ Textures/Core/UnitHexagon.png + false @@ -300,14 +199,15 @@ - 1 + Textures/Core/UnitHexagon_Rotated.png + false @@ -377,23 +277,157 @@ - - - Models/Widgets/Arrows/Arrow5.mesh - + + + Models/Widgets/Arrows/Arrow5.mesh + - - - + + + + + + + + + + + + + + 1 + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + 1 + + + + + Textures/HealthHUD3.png + + + + + + + + + + + + + + + + + + + + + + + + Textures/Icons/Boosts/Assault-01.png + + false + + + + + + + + + + + + + + + + + Textures/Icons/Boosts/Defender-01.png + + false + + + + + + + + + + + + + + + + + Textures/Icons/Boosts/Sniper-01.png + + false + + + + + + + + + + + + + + + + + + + + Textures/Icons/Abilities/Superman-01.png + + false + + + + + + + + + + + + From 99d663d5a226866d431a09e3e128f28f8acd718e Mon Sep 17 00:00:00 2001 From: Tleety Date: Mon, 7 Mar 2016 13:55:37 +0100 Subject: [PATCH 248/252] ShiftIcon should now track ability depending on what ability the player has and change icon accordingly. --- .../Game/Systems/AbilityCooldownHUDSystem.h | 1 + src/Game/Systems/AbilityCooldownHUDSystem.cpp | 48 +++++++++++++++---- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/include/Game/Systems/AbilityCooldownHUDSystem.h b/include/Game/Systems/AbilityCooldownHUDSystem.h index 610b4dc2..f2710ce3 100644 --- a/include/Game/Systems/AbilityCooldownHUDSystem.h +++ b/include/Game/Systems/AbilityCooldownHUDSystem.h @@ -12,6 +12,7 @@ public: { } virtual void Update(double dt) override; +private: }; #endif \ No newline at end of file diff --git a/src/Game/Systems/AbilityCooldownHUDSystem.cpp b/src/Game/Systems/AbilityCooldownHUDSystem.cpp index ccb12a97..e2734b47 100644 --- a/src/Game/Systems/AbilityCooldownHUDSystem.cpp +++ b/src/Game/Systems/AbilityCooldownHUDSystem.cpp @@ -11,21 +11,53 @@ void AbilityCooldownHUDSystem::Update(double dt) for (auto& abilityHUDC : *abilityHUDs) { EntityWrapper entity = EntityWrapper(m_World, abilityHUDC.EntityID); EntityWrapper abilityEntity = entity.FirstParentWithComponent("DashAbility"); - if (!abilityEntity.Valid()) - return; + std::string abilityName = ""; + + if (!abilityEntity.Valid()) { + //If we dont have a dash ability on player, we check for Sprint ability + abilityEntity = entity.FirstParentWithComponent("SprintAbility"); + + if (!abilityEntity.Valid()) { + //If we dont have a sprint ability on player, we check for shield ability + abilityEntity = entity.FirstParentWithComponent("ShieldAbility"); + + if (!abilityEntity.Valid()) { + //If we dont have a shield ability, we return, since we cannot do anything. + return; + } else { + //If we have a shield ability, we set the right icon + abilityName = "ShieldAbility"; + if (entity.HasComponent("Sprite")) { + (std::string&)entity["Sprite"]["DiffuseTexture"] = "Textures\\Icons\\Abilities\\SheildDots-01.png"; + } + } + } else { + //If we do have a sprint ability, we change the icon + abilityName = "SprintAbility"; + if (entity.HasComponent("Sprite")) { + (std::string&)entity["Sprite"]["DiffuseTexture"] = "Textures\\Icons\\Abilities\\Dash-01.png"; + } + } + } else { + //If we have a dash ability, we set the icon to the correct one. + abilityName = "DashAbility"; + if (entity.HasComponent("Sprite")) { + (std::string&)entity["Sprite"]["DiffuseTexture"] = "Textures\\Icons\\Abilities\\Superman-01.png"; + } + } + EntityWrapper cooldownTextEntity = entity.FirstChildByName("Cooldown"); - double maxAbilityCD = (double)abilityEntity["DashAbility"]["CoolDownMaxTimer"]; - double currentAbilityCD = (double)abilityEntity["DashAbility"]["CoolDownTimer"]; - + double maxAbilityCD = (double)abilityEntity[abilityName]["CoolDownMaxTimer"]; + double currentAbilityCD = (double)abilityEntity[abilityName]["CoolDownTimer"]; currentAbilityCD = currentAbilityCD >= 0.0 ? currentAbilityCD : 0.0; - if(cooldownTextEntity.Valid()) { - if(cooldownTextEntity.HasComponent("Text")) - { + if (cooldownTextEntity.Valid()) { + if (cooldownTextEntity.HasComponent("Text")) { std::string t = (std::string&)cooldownTextEntity["Text"]["Content"] = std::to_string(currentAbilityCD).substr(0, 3); } } + if (entity.HasComponent("Fill")) { entity["Fill"]["Percentage"] = currentAbilityCD/maxAbilityCD; } From 64df3fd7ad4e78d66634a9c703eec9fef49256a2 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Mon, 7 Mar 2016 14:27:12 +0100 Subject: [PATCH 249/252] CapturePoints now have red/blue/spectator model-children --- resources/Schema/Entities/CP_RockHard.xml | 7936 ++++++++--------- resources/Schema/Entities/CapturePoint.xml | 35 +- resources/Schema/Entities/aim_rays.xml | 40 +- .../Entities/aim_rays_with_capturep.xml | 336 + src/Game/Systems/CapturePointSystem.cpp | 12 + 5 files changed, 4362 insertions(+), 3997 deletions(-) create mode 100644 resources/Schema/Entities/aim_rays_with_capturep.xml diff --git a/resources/Schema/Entities/CP_RockHard.xml b/resources/Schema/Entities/CP_RockHard.xml index 2231df59..9f11d052 100644 --- a/resources/Schema/Entities/CP_RockHard.xml +++ b/resources/Schema/Entities/CP_RockHard.xml @@ -3,8 +3,8 @@ - 1.2059834585982117 - 4 + 0.58443805362486501 + 3 @@ -34,27 +34,6 @@ - - - - - Models/Props/Walls/SciFiWallBig.mesh - true - - - - - - - - - - Models/Props/Walls/SciFiWallMedium.mesh - - - - - @@ -87,6 +66,27 @@ + + + + + Models/Props/Walls/SciFiWallBig.mesh + true + + + + + + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + @@ -708,6 +708,43 @@ + + + + + Models/Highgrounds/Hg7.mesh + + + + + + + + + + + + Models/Highgrounds/Hg17.mesh + + + + + + + + + + + + + Models/Highgrounds/Hg19.mesh + + + + + + + @@ -758,43 +795,6 @@ - - - - - Models/Highgrounds/Hg7.mesh - - - - - - - - - - - - Models/Highgrounds/Hg17.mesh - - - - - - - - - - - - - Models/Highgrounds/Hg19.mesh - - - - - - - @@ -1930,6 +1930,78 @@ + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + @@ -2309,7 +2381,7 @@ - + @@ -2318,11 +2390,38 @@ - Models/Props/Bridges/SciFiBridge1Red.mesh + Models/Props/Stones/SmallStone2.mesh - - + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + @@ -2330,116 +2429,12 @@ - Models/Props/Bridges/SciFiBridge1Red.mesh + Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - + + + @@ -2450,16 +2445,1521 @@ - Models/Props/Pillars/SciFiBridgePillar1.mesh + Models/Props/Stones/SmallStone1.mesh - - - + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + + + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + + + @@ -2578,6 +4078,152 @@ + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + @@ -2594,95 +4240,6 @@ - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Red.mesh - - - - - - - - - - - - - 6 - Models/Props/Pillars/SciFiPillar1Red.mesh - - - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Red.mesh - - - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - @@ -2701,6 +4258,20 @@ + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + @@ -2741,1575 +4312,6 @@ - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Core/UnitPlane.mesh - - true - - - - - - - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - @@ -4324,78 +4326,13 @@ Models/Props/Walls/SmallWall3.mesh - + + - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - @@ -4403,53 +4340,13 @@ Models/Props/Walls/SmallWall3.mesh - + - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - @@ -4467,12 +4364,11 @@ - Models/Props/Walls/SmallWall3.mesh + Models/Props/Walls/MediumWall3.mesh - - - + + @@ -4484,7 +4380,21 @@ Models/Props/Walls/BigWallRed.mesh - + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + @@ -4494,12 +4404,24 @@ - Models/Props/Walls/SmallWall3.mesh + Models/Props/Walls/MediumWall3.mesh - - - + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + @@ -4511,8 +4433,8 @@ Models/Props/Walls/SmallWall3.mesh - - + + @@ -4538,26 +4460,13 @@ Models/Props/Walls/SmallWall3.mesh - + - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - @@ -4565,54 +4474,13 @@ Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - + + - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - @@ -4620,22 +4488,8 @@ Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - + + @@ -4670,11 +4524,11 @@ - Models/Props/Walls/MediumWall3.mesh + Models/Props/Walls/BigWallRed.mesh - - + + @@ -4686,13 +4540,188 @@ Models/Props/Walls/SmallWall3.mesh - - + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + @@ -4706,36 +4735,9 @@ - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - + @@ -4744,12 +4746,11 @@ - Models/Props/Walls/SpecialWall1.mesh + Models/Props/Stones/AssaultHolder.mesh - - - + + @@ -4758,12 +4759,11 @@ - Models/Props/Walls/SpecialWall1.mesh + Models/Props/Stones/AssaultHolder.mesh - - - + + @@ -4772,32 +4772,32 @@ - Models/Props/Walls/SpecialWall1.mesh + Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + @@ -4805,6 +4805,43 @@ + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + @@ -4817,8 +4854,8 @@ Models/Props/Stones/AssaultHolder.mesh - - + + @@ -4844,21 +4881,8 @@ Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - + + @@ -4884,8 +4908,8 @@ Models/Props/Stones/AssaultHolder.mesh - - + + @@ -4897,89 +4921,8 @@ Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - + + @@ -4997,33 +4940,6 @@ - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - @@ -5045,8 +4961,129 @@ Models/Props/Stones/AssaultHolder.mesh - - + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + @@ -5058,6 +5095,60 @@ + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + @@ -5075,11 +5166,12 @@ - Models/Props/Walls/MediumWall3.mesh + Models/Props/Walls/SmallWall3.mesh - - + + + @@ -5098,6 +5190,19 @@ + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + @@ -5132,22 +5237,29 @@ Models/Props/Walls/SmallWall3.mesh - - + + + + + + + + + - Models/Props/Walls/BigWallRed.mesh + Models/Props/Stones/BigStone.mesh - - + + @@ -5156,11 +5268,11 @@ - Models/Props/Walls/BigWallBlue.mesh + Models/Props/Stones/MediumStone2.mesh - - + + @@ -5169,12 +5281,11 @@ - Models/Props/Walls/SmallWall3.mesh + Models/Props/Pillars/StonePillar.mesh - - - + + @@ -5183,11 +5294,52 @@ - Models/Props/Walls/SmallWall3.mesh + Models/Props/Stones/SmallStone1.mesh - - + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + @@ -5197,12 +5349,226 @@ - Models/Props/Walls/SmallWall3.mesh + Models/Props/Stones/MediumStone2.mesh - - - + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/mediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + @@ -5246,7 +5612,7 @@ - + @@ -5288,7 +5654,7 @@ - + @@ -5300,372 +5666,6 @@ - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/mediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - @@ -5688,24 +5688,9 @@ Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - + + + @@ -5739,9 +5724,10 @@ + 2 - + @@ -5750,10 +5736,9 @@ - 2 - + @@ -5764,27 +5749,13 @@ - 5 + 4 Models/Props/Stones/ShinyStoneCrystalBlue.mesh + - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - + + @@ -5818,6 +5789,21 @@ + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + @@ -5833,36 +5819,6 @@ - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - 6 - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - @@ -5878,6 +5834,19 @@ + + + + + 2 + 1 + + + + + + + @@ -5902,32 +5871,63 @@ - - - - - 2 - 1 - - - - - - - - 4 + 6 Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - + + + + + + + + + + + + 5 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + @@ -5959,37 +5959,11 @@ - Models/Props/Stones/SmallStone1.mesh + Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - + + @@ -5999,11 +5973,25 @@ - Models/Props/Stones/MediumStone2.mesh + Models/Props/Stones/SmallStone1.mesh - - + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + @@ -6035,193 +6023,6 @@ - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - @@ -6249,6 +6050,32 @@ + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + @@ -6256,9 +6083,8 @@ Models/Props/Stones/SmallStone2.mesh - - - + + @@ -6267,51 +6093,11 @@ - Models/Props/Stones/SmallStone1.mesh + Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - + + @@ -6336,106 +6122,13 @@ Models/Props/Stones/SmallStone1.mesh - - + + - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - @@ -6450,20 +6143,6 @@ - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - @@ -6471,54 +6150,13 @@ Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - + + - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - @@ -6526,22 +6164,8 @@ Models/Props/Stones/BigStone.mesh - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - + + @@ -6567,8 +6191,128 @@ Models/Props/Stones/SmallStone2.mesh - - + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + @@ -6586,6 +6330,112 @@ + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + @@ -6607,9 +6457,9 @@ Models/Props/Stones/SmallStone1.mesh - - - + + + @@ -6618,10 +6468,11 @@ - Models/Props/Stones/SmallStone2.mesh + Models/Props/Stones/BigStone.mesh - + + @@ -6633,26 +6484,26 @@ Models/Props/Stones/SmallStone1.mesh - - + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - @@ -6660,8 +6511,9 @@ Models/Props/Stones/SmallStone2.mesh - - + + + @@ -6670,37 +6522,12 @@ - Models/Props/Stones/SmallStone2.mesh + Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - + + + @@ -6732,33 +6559,6 @@ - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - @@ -6780,13 +6580,213 @@ Models/Props/Stones/SmallStone1.mesh - - + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + @@ -6822,90 +6822,6 @@ - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - 8 - - - - Models/Props/PickUps/HealthPickUp.mesh - - - - - - - - - - - - - @@ -6938,7 +6854,7 @@ - + @@ -6980,7 +6896,7 @@ - + @@ -7022,7 +6938,91 @@ - + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + 8 + + + + Models/Props/PickUps/HealthPickUp.mesh + + + + @@ -7064,7 +7064,7 @@ - + @@ -7106,7 +7106,7 @@ - + @@ -7193,7 +7193,37 @@ Models/Props/Pillars/StonePillar.mesh - + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + @@ -7212,6 +7242,18 @@ + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + @@ -7226,48 +7268,6 @@ - - - - - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - - 6 - Models/Props/Pillars/SciFiPillar1Blue.mesh - - - - - - - - - @@ -7548,9 +7548,8 @@ Models/Props/Flora/SpecialRoot.mesh - - - + + @@ -7562,8 +7561,9 @@ Models/Props/Flora/SpecialRoot.mesh - - + + + @@ -7610,7 +7610,7 @@ Models/Props/Walls/SmallWall3.mesh - + @@ -7624,7 +7624,8 @@ Models/Props/Walls/SmallWall3.mesh - + + @@ -7637,61 +7638,9 @@ Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - + + + @@ -7717,88 +7666,7 @@ Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - + @@ -7851,13 +7719,38 @@ Models/Props/Walls/SmallWall3.mesh - - + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + @@ -7865,27 +7758,13 @@ Models/Props/Walls/SmallWall3.mesh - - + + - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - @@ -7899,6 +7778,32 @@ + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + @@ -7906,7 +7811,89 @@ Models/Props/Walls/SmallWall3.mesh - + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + @@ -7939,6 +7926,59 @@ + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + @@ -7952,46 +7992,6 @@ - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - @@ -8151,12 +8151,11 @@ 6 - Models/Props/Pillars/SciFiPillar2Blue.mesh + Models/Props/Pillars/SciFiPillar1Blue.mesh - - - + + @@ -8180,12 +8179,12 @@ 4 - Models/Props/Pillars/SciFiPillar2Red.mesh + Models/Props/Pillars/SciFiPillar3Blue.mesh - - - + + + @@ -8198,8 +8197,8 @@ Models/Props/Pillars/SciFiPillar2Blue.mesh - - + + @@ -8222,12 +8221,13 @@ - Models/Props/Pillars/SciFiPillar2Blue.mesh + 4 + Models/Props/Pillars/SciFiPillar2Red.mesh - - - + + + @@ -8255,37 +8255,9 @@ Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - - - - 4 - Models/Props/Pillars/SciFiPillar3Blue.mesh - - - - - - - - - - - - - - 6 - Models/Props/Pillars/SciFiPillar1Blue.mesh - - - - + + + @@ -8298,8 +8270,36 @@ Models/Props/Pillars/SciFiPillar2Blue.mesh - - + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + 6 + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + @@ -8353,283 +8353,6 @@ - - - - - - - - - 10 - - - - - - - - - - - - 10 - - - - - - - - - - - 0.40000000596046448 - - - - - - - - - - - 0.69999998807907104 - 1.6000000238418579 - - - - - - - - - 10 - - - - - - - - - - - 10 - - - - - - - - - - - - 10 - - - - - - - - - - - - - - - - - - - Models/Props/CapturePoint/CapturePointNeutral.mesh - - - - - - - - - - 15 - 2 - - - - Models/Core/UnitCylinder.mesh - - true - - - - - - - - - - - - - - - - - - - - Models/Props/CapturePoint/CapturePointBlue.mesh - - - - - - - - - - -15 - - - - 4 - - - - Models/Core/UnitCylinder.mesh - - true - - - - - - - - - - - - - - - - - - - - Models/Props/CapturePoint/CapturePointNeutral.mesh - - - - - - - - - - 15 - 1 - - - - Models/Core/UnitCylinder.mesh - - true - - - - - - - - - - - - - - - - - - - - Models/Props/CapturePoint/CapturePointNeutral.mesh - - - - - - - - - - 3 - - - - Models/Core/UnitCylinder.mesh - - true - - - - - - - - - - - - - - - - Models/Props/CapturePoint/CapturePointRed.mesh - - - - - - - - - - 15 - - - - - - - Models/Core/UnitCylinder.mesh - - true - - - - - - - - - - - - - - - - - @@ -8637,15 +8360,15 @@ - - - Schema/Entities/PlayerAssaultFallbackBlue.xml - + + + Schema/Entities/PlayerAssaultFallbackBlue.xml + @@ -8657,9 +8380,7 @@ Models/Characters/Assault/Test/AssaultTPose.mesh - - - + @@ -8693,7 +8414,9 @@ Models/Characters/Assault/Test/AssaultTPose.mesh - + + + @@ -8725,20 +8448,32 @@ - - - Schema/Entities/PlayerAssaultFallbackRed.xml - + + + Schema/Entities/PlayerAssaultFallbackRed.xml + + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + @@ -8751,6 +8486,18 @@ + + + + + Models/Characters/Assault/Test/AssaultTPose.mesh + + + + + + + @@ -8775,18 +8522,6 @@ - - - - - Models/Characters/Assault/Test/AssaultTPose.mesh - - - - - - - @@ -8797,14 +8532,269 @@ + + + + + + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + + 10 + + + + + + + + + + + 0.40000000596046448 + + + + + + + + + + + 10 + + + + + + + + + + + 0.69999998807907104 + 1.6000000238418579 + + + + + + + + + 10 + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + - + + 3 + + + - Models/Characters/Assault/Test/AssaultTPose.mesh + Models/Core/UnitCylinder.mesh + + true - + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 1 + + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointBlue.mesh + + + + + + + + + + -15 + + + + 4 + + + + + + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 2 + + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointRed.mesh + + + + + + + + + + 15 + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + true + + + + @@ -8821,7 +8811,7 @@ - + @@ -8859,7 +8849,7 @@ Textures/Core/UnitHexagon.png - + @@ -8868,20 +8858,53 @@ + + + 2 - - 1 - - Textures/Core/UnitHexagon_Rotated.png - + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + 1 + + + Textures/Core/UnitHexagon_Rotated.png + + + + + @@ -8903,12 +8926,12 @@ + + + 3 - - - Textures/Core/UnitHexagon_Rotated.png @@ -8923,76 +8946,6 @@ - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - 4 - - - 1 - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - 1 - - - 1 - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - @@ -9007,11 +8960,11 @@ - 1 + Textures/Core/UnitHexagon_Rotated.png @@ -9026,6 +8979,41 @@ + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 1 + + + + 4 + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + diff --git a/resources/Schema/Entities/CapturePoint.xml b/resources/Schema/Entities/CapturePoint.xml index 9f33c4de..35c89e3e 100644 --- a/resources/Schema/Entities/CapturePoint.xml +++ b/resources/Schema/Entities/CapturePoint.xml @@ -4,14 +4,39 @@ - - Models/Core/UnitSphere.mesh - - + - + + + + + models/core/unitcube.mesh + + + + + + + + + models/core/unitcube.mesh + + + + + + + + + models/core/unitcube.mesh + + + + + + diff --git a/resources/Schema/Entities/aim_rays.xml b/resources/Schema/Entities/aim_rays.xml index c8dac9a3..1d953bf1 100644 --- a/resources/Schema/Entities/aim_rays.xml +++ b/resources/Schema/Entities/aim_rays.xml @@ -92,15 +92,15 @@ - - - Schema/Entities/Player.xml - + + + Schema/Entities/Player.xml + @@ -143,15 +143,15 @@ - - - Schema/Entities/Player.xml - + + + Schema/Entities/Player.xml + @@ -209,24 +209,26 @@ + -15 - - Models\Core\UnitCube.mesh - - + + + Models\Core\UnitCube.mesh + + true + - @@ -234,25 +236,27 @@ + 15 1 - - Models\Core\UnitCube.mesh - - + + + Models\Core\UnitCube.mesh + + true + - diff --git a/resources/Schema/Entities/aim_rays_with_capturep.xml b/resources/Schema/Entities/aim_rays_with_capturep.xml new file mode 100644 index 00000000..6aa3246a --- /dev/null +++ b/resources/Schema/Entities/aim_rays_with_capturep.xml @@ -0,0 +1,336 @@ + + + + + + + + + + + + + + models/core/unitcube.mesh + + + + + + + + + + + + + + + models/core/unitcube.mesh + + + + + + + + + + + + + + + + + + + + + + + + models/core/unitcube.mesh + + + + + + + + + + + + + + + models/core/unitcube.mesh + + + + + + + + + + + + + + + models/core/unitcube.mesh + + + + + + + + + + + + + + + + + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + models/core/unitcube.mesh + + + + + + + + + + + + + + + + + + 15 + + + + + + + + + + + + + + + + + + + models/core/unitcube.mesh + + + + + + + + + + + models/core/unitcube.mesh + + + + + + + + + + + models/core/unitcube.mesh + + + + + + + + + + + + + + + + + + + + + -15 + + + + 1 + + + + + + + + + + + + + + + + models/core/unitcube.mesh + + + + + + + + + + + models/core/unitcube.mesh + + + + + + + + + + + + models/core/unitcube.mesh + + + + + + + + + + + + + + diff --git a/src/Game/Systems/CapturePointSystem.cpp b/src/Game/Systems/CapturePointSystem.cpp index 0d6089c5..4647d1b7 100644 --- a/src/Game/Systems/CapturePointSystem.cpp +++ b/src/Game/Systems/CapturePointSystem.cpp @@ -69,6 +69,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp int ownedBy = teamComponent["Team"]; int redTeamPlayersStandingInside = 0; int blueTeamPlayersStandingInside = 0; + //note: old color system if (capturePointEntity.HasComponent("Model")) { //Now sets team color to the capturepoint, or white if it is uncaptured. capturePointEntity["Model"]["Color"] = ownedBy == blueTeam ? glm::vec4(0, 0.0f, 1, 0.3) : ownedBy == redTeam ? glm::vec4(1, 0.0f, 0, 0.3) : glm::vec4(1, 1, 1, 0.3); @@ -102,7 +103,18 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp nextPossibleCapturePoint["Blue"] = i - 1; } } + if (m_RecentlyCapturedNeedNextCapturePointNow) { + //change what model is displaying (change all in case 2 capturepoints has been captured on the same frame) + for (int i = 0; i < m_NumberOfCapturePoints; i++) { + auto owner = (int)m_CapturePointNumberToEntityMap[i]["Team"]["Team"]; + if (m_CapturePointNumberToEntityMap[i].FirstChildByName("Red").ID != EntityID_Invalid) { + (bool&)m_CapturePointNumberToEntityMap[i].FirstChildByName("Red")["Model"]["Visible"] = owner == redTeam ? true : false; + (bool&)m_CapturePointNumberToEntityMap[i].FirstChildByName("Blue")["Model"]["Visible"] = owner == blueTeam ? true : false; + (bool&)m_CapturePointNumberToEntityMap[i].FirstChildByName("Spectator")["Model"]["Visible"] = owner == spectatorTeam ? true : false; + } + } + //save the next cap points and publish the captured event m_CapturedEvent.BlueTeamNextCapturePoint = m_CapturePointNumberToEntityMap[nextPossibleCapturePoint["Blue"]]; m_CapturedEvent.RedTeamNextCapturePoint = m_CapturePointNumberToEntityMap[nextPossibleCapturePoint["Red"]]; m_EventBroker->Publish(m_CapturedEvent); From 47ece6a5bf7ac1b5f7feb2d15a26e7a97ff38401 Mon Sep 17 00:00:00 2001 From: Tleety Date: Mon, 7 Mar 2016 14:42:50 +0100 Subject: [PATCH 250/252] Changed shield component to track Active, so it and sprint glow full if they are active. Changed how reflections are calculated with light. --- assets | 2 +- resources/Schema/Components/ShieldAbility.xml | 2 +- resources/Schema/Components/ShieldAbility.xsd | 4 +-- resources/Shaders/ForwardPlus.frag.glsl | 2 +- .../Shaders/ForwardPlusShieldCheck.frag.glsl | 2 +- src/Game/Systems/AbilityCooldownHUDSystem.cpp | 29 +++++++++++++++---- 6 files changed, 29 insertions(+), 12 deletions(-) diff --git a/assets b/assets index 0ae73657..52ea74c5 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 0ae736570b5600c2ad05f556ccaec4f5341c2b06 +Subproject commit 52ea74c5d5996ebcd7b064e0a8be469c9f07926e diff --git a/resources/Schema/Components/ShieldAbility.xml b/resources/Schema/Components/ShieldAbility.xml index 49fcf0c0..d66dca31 100644 --- a/resources/Schema/Components/ShieldAbility.xml +++ b/resources/Schema/Components/ShieldAbility.xml @@ -1,4 +1,4 @@ - 2.0 + false \ No newline at end of file diff --git a/resources/Schema/Components/ShieldAbility.xsd b/resources/Schema/Components/ShieldAbility.xsd index 5cf2145c..bbb30c82 100644 --- a/resources/Schema/Components/ShieldAbility.xsd +++ b/resources/Schema/Components/ShieldAbility.xsd @@ -9,8 +9,8 @@ - - This is the cooldown on shield + + If the shield is active or not diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index aa45d118..8f0f7deb 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -171,7 +171,7 @@ void main() vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0; - vec4 reflectionTotal = reflectionColor * (1-specularTexel.a) * color_result.a; + vec4 reflectionTotal = reflectionColor * (1-specularTexel.a) * color_result.a * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); color_result = color_result * clamp(1/specularTexel.a, 0, 1) + reflectionTotal; //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; diff --git a/resources/Shaders/ForwardPlusShieldCheck.frag.glsl b/resources/Shaders/ForwardPlusShieldCheck.frag.glsl index 35db495b..5995facb 100644 --- a/resources/Shaders/ForwardPlusShieldCheck.frag.glsl +++ b/resources/Shaders/ForwardPlusShieldCheck.frag.glsl @@ -178,7 +178,7 @@ void main() vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0; - vec4 reflectionTotal = reflectionColor * (1-specularTexel.a) * color_result.a; + vec4 reflectionTotal = reflectionColor * (1-specularTexel.a) * color_result.a * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); color_result = color_result * clamp(1/specularTexel.a, 0, 1) + reflectionTotal; //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; diff --git a/src/Game/Systems/AbilityCooldownHUDSystem.cpp b/src/Game/Systems/AbilityCooldownHUDSystem.cpp index e2734b47..07461f95 100644 --- a/src/Game/Systems/AbilityCooldownHUDSystem.cpp +++ b/src/Game/Systems/AbilityCooldownHUDSystem.cpp @@ -47,19 +47,36 @@ void AbilityCooldownHUDSystem::Update(double dt) } EntityWrapper cooldownTextEntity = entity.FirstChildByName("Cooldown"); + //TODO: Fix so this track correctly for shield and sprint depending on how they work. + double maxAbilityCD, currentAbilityCD; - double maxAbilityCD = (double)abilityEntity[abilityName]["CoolDownMaxTimer"]; - double currentAbilityCD = (double)abilityEntity[abilityName]["CoolDownTimer"]; - currentAbilityCD = currentAbilityCD >= 0.0 ? currentAbilityCD : 0.0; + if (abilityName == "DashAbility") { + maxAbilityCD = (double)abilityEntity[abilityName]["CoolDownMaxTimer"]; + currentAbilityCD = (double)abilityEntity[abilityName]["CoolDownTimer"]; + currentAbilityCD = currentAbilityCD >= 0.0 ? currentAbilityCD : 0.0; - if (cooldownTextEntity.Valid()) { - if (cooldownTextEntity.HasComponent("Text")) { - std::string t = (std::string&)cooldownTextEntity["Text"]["Content"] = std::to_string(currentAbilityCD).substr(0, 3); + if (cooldownTextEntity.Valid()) { + if (cooldownTextEntity.HasComponent("Text")) { + std::string t = (std::string&)cooldownTextEntity["Text"]["Content"] = std::to_string(currentAbilityCD).substr(0, 3); + } } } + if (abilityName == "ShieldAbility") { + maxAbilityCD = 0.0; + currentAbilityCD = 1 - (bool)abilityEntity[abilityName]["Active"]; + } + + if (abilityName == "SprintAbility") { + maxAbilityCD = 0.0; + currentAbilityCD = 1 - (bool)abilityEntity[abilityName]["Active"]; + } + if (entity.HasComponent("Fill")) { entity["Fill"]["Percentage"] = currentAbilityCD/maxAbilityCD; } + + + } } From 3eaad275ba6a84d1d8282d313aec81bc4692fe7e Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Mon, 7 Mar 2016 14:50:31 +0100 Subject: [PATCH 251/252] New CapturePointAddition fixed to work on Network by Joachim --- src/Engine/Network/Server.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Engine/Network/Server.cpp b/src/Engine/Network/Server.cpp index 5bfb4000..9de3e419 100644 --- a/src/Engine/Network/Server.cpp +++ b/src/Engine/Network/Server.cpp @@ -162,7 +162,7 @@ void Server::unreliableBroadcast(Packet& packet) { for (auto& kv : m_ConnectedPlayers) { packet.ChangePacketID(kv.second.PacketID); -// m_Unreliable.Send(packet, kv.second); + // m_Unreliable.Send(packet, kv.second); } } @@ -649,13 +649,14 @@ bool Server::shouldSendToClient(EntityWrapper childEntity) return true; } } - return childEntity.HasComponent("Player") + return childEntity.HasComponent("Player") || childEntity.FirstParentWithComponent("Player").Valid() - || childEntity.HasComponent("CapturePoint") + || childEntity.HasComponent("CapturePoint") || childEntity.HasComponent("HealthPickup") || childEntity.HasComponent("AmmoPickup") || childEntity.HasComponent("ScoreScreen") - || childEntity.FirstParentWithComponent("ScoreScreen").Valid(); + || childEntity.FirstParentWithComponent("ScoreScreen").Valid() + || childEntity.FirstParentWithComponent("CapturePoint").Valid(); } PlayerID Server::getPlayerIDFromEndpoint() @@ -674,7 +675,7 @@ PlayerID Server::getPlayerIDFromEndpoint() PlayerID Server::getPlayerIDFromEntityID(EntityID entityID) { - for(auto& kv : m_ConnectedPlayers) { + for (auto& kv : m_ConnectedPlayers) { if (entityID == kv.second.EntityID) { return kv.first; } From fc3a3a8f2e53e17511d3273997795339fa77348d Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Mon, 7 Mar 2016 17:16:18 +0100 Subject: [PATCH 252/252] Fixed a crashbug in Ammo/HealthPickup which was actually caused by systems being added twice in Game.cpp. This is also a possible fix for DamageIndicator,Capturepoint,TextField,KillFeed --- src/Game/Game.cpp | 7 ------- src/Game/Systems/AmmoPickupSystem.cpp | 9 +++++---- src/Game/Systems/PickupSpawnSystem.cpp | 4 ++++ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 8f589e34..69a9ad57 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -137,20 +137,13 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); - m_SystemPipeline->AddSystem(updateOrderLevel); - m_SystemPipeline->AddSystem(updateOrderLevel); - m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); - m_SystemPipeline->AddSystem(updateOrderLevel); - m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); - m_SystemPipeline->AddSystem(updateOrderLevel); - m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer); m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer); diff --git a/src/Game/Systems/AmmoPickupSystem.cpp b/src/Game/Systems/AmmoPickupSystem.cpp index 062efe94..e28c38ff 100644 --- a/src/Game/Systems/AmmoPickupSystem.cpp +++ b/src/Game/Systems/AmmoPickupSystem.cpp @@ -96,6 +96,7 @@ bool AmmoPickupSystem::OnAmmoPickup(Events::AmmoPickup & e) } currentAmmo = std::min(currentAmmo + e.AmmoGain, maxWeaponAmmo); + return false; } @@ -114,8 +115,11 @@ bool AmmoPickupSystem::OnTriggerLeave(Events::TriggerLeave& e) { } void AmmoPickupSystem::DoPickup(EntityWrapper &player, EntityWrapper &trigger) { + //trigger should be valid but if it isnt we just return (to avoid crash) + if (!trigger.Valid()) { + return; + } int maxWeaponAmmo = (int)player["AssaultWeapon"]["MaxAmmo"]; - int& currentAmmo = (int)player["AssaultWeapon"]["Ammo"]; int ammoGiven = 0.01*(double)trigger["AmmoPickup"]["AmmoGain"] * maxWeaponAmmo; Events::AmmoPickup ePlayerAmmoPickup; @@ -123,9 +127,6 @@ void AmmoPickupSystem::DoPickup(EntityWrapper &player, EntityWrapper &trigger) { ePlayerAmmoPickup.Player = player; m_EventBroker->Publish(ePlayerAmmoPickup); - //immediately give the player the ammo (on server) - currentAmmo = std::min(currentAmmo + ammoGiven, maxWeaponAmmo); - //copy position, ammogain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object) //we need to copy all values since each value can be different for each ammoPickup m_ETriggerTouchVector.push_back({ (glm::vec3)trigger["Transform"]["Position"], trigger["AmmoPickup"]["AmmoGain"], diff --git a/src/Game/Systems/PickupSpawnSystem.cpp b/src/Game/Systems/PickupSpawnSystem.cpp index 99da931f..b0efd696 100644 --- a/src/Game/Systems/PickupSpawnSystem.cpp +++ b/src/Game/Systems/PickupSpawnSystem.cpp @@ -83,6 +83,10 @@ bool PickupSpawnSystem::OnTriggerLeave(Events::TriggerLeave& e) } void PickupSpawnSystem::DoPickup(EntityWrapper &player, EntityWrapper &trigger) { + //trigger should be valid but if it isnt we just return (to avoid crash) + if (!trigger.Valid()) { + return; + } double healthGiven = 0.01*(double)trigger["HealthPickup"]["HealthGain"] * (double)player["Health"]["MaxHealth"]; //only the server will increase the players hp and set it in the next delta