From 8034b42c870aa109efaa3362f2c67565b4e260fe Mon Sep 17 00:00:00 2001 From: viktorljung Date: Fri, 5 Feb 2016 16:43:57 +0100 Subject: [PATCH 01/37] spriteComponent WIP --- include/Engine/Rendering/Camera.h | 2 + include/Engine/Rendering/DrawFinalPass.h | 2 + include/Engine/Rendering/RenderQueue.h | 4 ++ include/Engine/Rendering/RenderSystem.h | 1 + include/Engine/Rendering/SpriteJob.h | 75 ++++++++++++++++++++ resources/Schema/Components.xsd | 1 + resources/Schema/Components/Sprite.xml | 7 ++ resources/Schema/Components/Sprite.xsd | 27 +++++++ resources/Schema/Entities/RenderingWorld.xml | 16 ++++- resources/Shaders/Sprite.frag.glsl | 41 +++++++++++ resources/Shaders/Sprite.vert.glsl | 24 +++++++ src/Engine/Rendering/Camera.cpp | 7 ++ src/Engine/Rendering/DrawFinalPass.cpp | 56 ++++++++++++++- src/Engine/Rendering/RenderSystem.cpp | 53 +++++++++++++- src/Engine/Rendering/Texture.cpp | 7 +- src/Game/Game.cpp | 3 +- 16 files changed, 318 insertions(+), 8 deletions(-) create mode 100644 include/Engine/Rendering/SpriteJob.h create mode 100644 resources/Schema/Components/Sprite.xml create mode 100644 resources/Schema/Components/Sprite.xsd create mode 100644 resources/Shaders/Sprite.frag.glsl create mode 100644 resources/Shaders/Sprite.vert.glsl diff --git a/include/Engine/Rendering/Camera.h b/include/Engine/Rendering/Camera.h index 29dd4626..6130fd01 100644 --- a/include/Engine/Rendering/Camera.h +++ b/include/Engine/Rendering/Camera.h @@ -33,6 +33,8 @@ public: glm::mat4 ViewMatrix() const { return m_ViewMatrix; } void SetViewMatrix(glm::mat4 val); + glm::mat4 BillboardMatrix(); + float AspectRatio() const { return m_AspectRatio; } void SetAspectRatio(float val); diff --git a/include/Engine/Rendering/DrawFinalPass.h b/include/Engine/Rendering/DrawFinalPass.h index 74f505fe..867ec844 100644 --- a/include/Engine/Rendering/DrawFinalPass.h +++ b/include/Engine/Rendering/DrawFinalPass.h @@ -31,6 +31,7 @@ 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 DrawModelRenderQueues(std::list>& job, RenderScene& scene); + void DrawSprites(std::list>&jobs, RenderScene& scene); void BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene); void BindModelUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene); @@ -53,6 +54,7 @@ private: ShaderProgram* m_ForwardPlusProgram; ShaderProgram* m_ExplosionEffectProgram; + ShaderProgram* m_SpriteProgram; }; #endif \ No newline at end of file diff --git a/include/Engine/Rendering/RenderQueue.h b/include/Engine/Rendering/RenderQueue.h index af9d928e..47b15b63 100644 --- a/include/Engine/Rendering/RenderQueue.h +++ b/include/Engine/Rendering/RenderQueue.h @@ -15,6 +15,7 @@ #include "PointLightJob.h" #include "DirectionalLightJob.h" #include "ExplosionEffectJob.h" +#include "SpriteJob.h" struct RenderScene { @@ -24,6 +25,8 @@ struct RenderScene std::list> PointLightJobs; std::list> TextJobs; std::list> DirectionalLightJobs; + std::list> SpriteJobs; + Rectangle Viewport; bool ClearDepth = false; glm::vec4 AmbientColor; @@ -35,6 +38,7 @@ struct RenderScene PointLightJobs.clear(); TextJobs.clear(); DirectionalLightJobs.clear(); + SpriteJobs.clear(); } }; diff --git a/include/Engine/Rendering/RenderSystem.h b/include/Engine/Rendering/RenderSystem.h index d64147b9..6ab4b98b 100644 --- a/include/Engine/Rendering/RenderSystem.h +++ b/include/Engine/Rendering/RenderSystem.h @@ -45,6 +45,7 @@ private: void fillPointLights(std::list>& jobs, World* world); void fillDirectionalLights(std::list>& jobs, World* world); void fillLight(std::list>& jobs); + void fillSprites(std::list>& jobs, World* world); bool isChildOfACamera(EntityWrapper entity); bool isChildOfCurrentCamera(EntityWrapper entity); diff --git a/include/Engine/Rendering/SpriteJob.h b/include/Engine/Rendering/SpriteJob.h new file mode 100644 index 00000000..a20d0395 --- /dev/null +++ b/include/Engine/Rendering/SpriteJob.h @@ -0,0 +1,75 @@ +#ifndef SpriteJob_h__ +#define SpriteJob_h__ + +#include + +#include "../Common.h" +#include "../GLM.h" +#include "../Core/ComponentWrapper.h" +#include "Texture.h" +#include "Model.h" +#include "RenderJob.h" +#include "../Core/ResourceManager.h" +#include "Camera.h" +#include "../Core/World.h" +#include "../Core/Transform.h" +#include "Skeleton.h" + +struct SpriteJob : RenderJob +{ + SpriteJob(ComponentWrapper cSprite, Camera* camera, glm::mat4 matrix, World* world, glm::vec4 fillColor, float fillPercentage) + : RenderJob() + { + Model = ResourceManager::Load<::Model>("Models/Core/UnitQuad.mesh"); + ::RawModel::MaterialGroup matGroup = Model->MaterialGroups().front(); + TextureID = (matGroup.Texture) ? matGroup.Texture->ResourceID : 0; + + if (cSprite["DiffuseTexture"]) { + DiffuseTexture = ResourceManager::Load(cSprite["DiffuseTexture"]); + } else { + DiffuseTexture = nullptr; + } + if (cSprite["GlowMap"]) { + IncandescenceTexture = ResourceManager::Load(cSprite["GlowMap"]); + } else { + IncandescenceTexture = nullptr; + } + StartIndex = matGroup.StartIndex; + EndIndex = matGroup.EndIndex; + Matrix = matrix; + Color = cSprite["Color"]; + Entity = cSprite.EntityID; + glm::vec3 abspos = Transform::AbsolutePosition(world, cSprite.EntityID); + glm::vec3 viewpos = glm::vec3(camera->ViewMatrix() * glm::vec4(abspos, 1)); + Depth = viewpos.z; + World = world; + + FillColor = fillColor; + FillPercentage = fillPercentage; + }; + + unsigned int TextureID; + + EntityID Entity; + glm::mat4 Matrix; + const Texture* DiffuseTexture; + const Texture* NormalTexture; + const Texture* SpecularTexture; + const Texture* IncandescenceTexture; + float Shininess = 0.f; + glm::vec4 Color; + const ::Model* Model = nullptr; + unsigned int StartIndex = 0; + unsigned int EndIndex = 0; + World* World; + + glm::vec4 FillColor = glm::vec4(0); + float FillPercentage = 0.0; + + void CalculateHash() override + { + Hash = TextureID; + } +}; + +#endif \ No newline at end of file diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index 265a3cc5..3163c787 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -31,4 +31,5 @@ + \ No newline at end of file diff --git a/resources/Schema/Components/Sprite.xml b/resources/Schema/Components/Sprite.xml new file mode 100644 index 00000000..c2a2057f --- /dev/null +++ b/resources/Schema/Components/Sprite.xml @@ -0,0 +1,7 @@ + + + + + + true + diff --git a/resources/Schema/Components/Sprite.xsd b/resources/Schema/Components/Sprite.xsd new file mode 100644 index 00000000..c8f0c187 --- /dev/null +++ b/resources/Schema/Components/Sprite.xsd @@ -0,0 +1,27 @@ + + + + + + + + A sprite that will be facing the camera + + + + + Diffuse Texture file + + + GlowMap file + + + Color tint + + + Whether the model is visible or not + + + + + \ No newline at end of file diff --git a/resources/Schema/Entities/RenderingWorld.xml b/resources/Schema/Entities/RenderingWorld.xml index 20301d5f..d9f7c62d 100644 --- a/resources/Schema/Entities/RenderingWorld.xml +++ b/resources/Schema/Entities/RenderingWorld.xml @@ -52,11 +52,11 @@ - 0.65990006923675537 + Models/Core/UnitHexagon.mesh @@ -161,7 +161,7 @@ - + @@ -346,6 +346,18 @@ + + + + Textures/HexmapDiff.png + Textures/GlowFrame.png + + + + + + + diff --git a/resources/Shaders/Sprite.frag.glsl b/resources/Shaders/Sprite.frag.glsl new file mode 100644 index 00000000..c391322d --- /dev/null +++ b/resources/Shaders/Sprite.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 = 0) uniform sampler2D DiffuseTexture; +layout (binding = 1) 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; + } + 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); +} + + diff --git a/resources/Shaders/Sprite.vert.glsl b/resources/Shaders/Sprite.vert.glsl new file mode 100644 index 00000000..e910a26a --- /dev/null +++ b/resources/Shaders/Sprite.vert.glsl @@ -0,0 +1,24 @@ +#version 430 + +uniform mat4 M; +uniform mat4 V; +uniform mat4 P; + +layout(location = 0) in vec3 Position; +layout(location = 1) in vec3 Normal; +layout(location = 4) in vec2 TextureCoords; + +out VertexData{ + vec3 Position; + vec3 Normal; + vec2 TextureCoordinate; +}Output; + +void main() +{ + gl_Position = P * M * vec4(Position, 1.0); + + Output.Position = Position; + Output.TextureCoordinate = TextureCoords; + Output.Normal = Normal; +} \ No newline at end of file diff --git a/src/Engine/Rendering/Camera.cpp b/src/Engine/Rendering/Camera.cpp index f6b2e5ef..c1246c6a 100644 --- a/src/Engine/Rendering/Camera.cpp +++ b/src/Engine/Rendering/Camera.cpp @@ -62,6 +62,13 @@ void Camera::SetViewMatrix(glm::mat4 val) m_ViewMatrix = val; } + +glm::mat4 Camera::BillboardMatrix() +{ + glm::mat4 matrix = glm::toMat4(m_Orientation); + return matrix; +} + //void Camera::Pitch(float val) //{ // m_Pitch = val; diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 8247797e..e5919fbe 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -55,6 +55,15 @@ void DrawFinalPass::InitializeShaderPrograms() m_ExplosionEffectProgram->BindFragDataLocation(1, "bloomColor"); m_ExplosionEffectProgram->Link(); GLERROR("Creating explosion program"); + + m_SpriteProgram = ResourceManager::Load("#m_SpriteProgram"); + m_SpriteProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/Sprite.vert.glsl"))); + m_SpriteProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/Sprite.frag.glsl"))); + m_SpriteProgram->Compile(); + m_SpriteProgram->BindFragDataLocation(0, "sceneColor"); + m_SpriteProgram->BindFragDataLocation(1, "bloomColor"); + m_SpriteProgram->Link(); + GLERROR("Creating sprite program"); } void DrawFinalPass::Draw(RenderScene& scene) @@ -70,6 +79,8 @@ void DrawFinalPass::Draw(RenderScene& scene) GLERROR("OpaqueObjects"); DrawModelRenderQueues(scene.TransparentObjects, scene); GLERROR("TransparentObjects"); + DrawSprites(scene.SpriteJobs, scene); + GLERROR("SpriteJobs"); delete state; GLERROR("END"); @@ -201,6 +212,50 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& } + +void DrawFinalPass::DrawSprites(std::list>&jobs, RenderScene& scene) +{ + m_SpriteProgram->Bind(); + + GLuint shaderHandle = m_SpriteProgram->GetHandle(); + + for(auto& job : jobs) { + auto spriteJob = std::dynamic_pointer_cast(job); + + if(spriteJob) { + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(spriteJob->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())); + glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(spriteJob->Color)); + glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(spriteJob->FillColor)); + glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), spriteJob->FillPercentage); + + glActiveTexture(GL_TEXTURE0); + if (spriteJob->DiffuseTexture != nullptr) { + glBindTexture(GL_TEXTURE_2D, spriteJob->DiffuseTexture->m_Texture); + } else { + glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); + } + + glActiveTexture(GL_TEXTURE1); + if (spriteJob->IncandescenceTexture != nullptr) { + glBindTexture(GL_TEXTURE_2D, spriteJob->IncandescenceTexture->m_Texture); + } else { + glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture); + } + + + glBindVertexArray(spriteJob->Model->VAO); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, spriteJob->Model->ElementBuffer); + glDrawElements(GL_TRIANGLES, spriteJob->EndIndex - spriteJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(spriteJob->StartIndex*sizeof(unsigned int))); + } + } + + + + // m_SpriteProgram->Unbind(); +} + void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) { glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix)); @@ -245,7 +300,6 @@ void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr& job) { glActiveTexture(GL_TEXTURE0); diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index eaecf99e..3a1729fc 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -31,6 +31,56 @@ bool RenderSystem::OnSetCamera(Events::SetCamera& e) return true; } + +void RenderSystem::fillSprites(std::list>& jobs, World* world) +{ + auto sprites = world->GetComponents("Sprite"); + if (sprites == nullptr) { + return; + } + + for (auto& cSprite : *sprites) { + bool visible = cSprite["Visible"]; + if (!visible) { + continue; + } + + + EntityWrapper entity(world, cSprite.EntityID); + + // Only render children of a camera if that camera is currently active + if (isChildOfACamera(entity) && !isChildOfCurrentCamera(entity)) { + continue; + } + + // Hide things parented to local player if they have the HiddenFromLocalPlayer component + if (entity.HasComponent("HiddenForLocalPlayer") && (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer))) { + continue; + } + + std::string diffuseResource = cSprite["DiffuseTexture"]; + std::string glowResource = cSprite["GlowMap"]; + 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 = Transform::ModelMatrix(entity.ID, world); + //modelMatrix *= m_Camera->BillboardMatrix(); + + std::shared_ptr spriteJob = std::shared_ptr(new SpriteJob(cSprite, m_Camera, modelMatrix, world, fillColor, fillPercentage)); + + jobs.push_back(spriteJob); + } +} + bool RenderSystem::isChildOfACamera(EntityWrapper entity) { return entity.FirstParentWithComponent("Camera").Valid(); @@ -167,7 +217,6 @@ void RenderSystem::fillPointLights(std::list>& jobs, } } - void RenderSystem::fillDirectionalLights(std::list>& jobs, World* world) { auto directionalLights = world->GetComponents("DirectionalLight"); @@ -189,7 +238,6 @@ void RenderSystem::fillDirectionalLights(std::list>& } } - void RenderSystem::fillText(std::list>& jobs, World* world) { auto texts = world->GetComponents("Text"); @@ -255,6 +303,7 @@ void RenderSystem::Update(double dt) fillPointLights(scene.PointLightJobs, m_World); fillDirectionalLights(scene.DirectionalLightJobs, m_World); fillText(scene.TextJobs, m_World); + fillSprites(scene.SpriteJobs, m_World); m_RenderFrame->Add(scene); } \ No newline at end of file diff --git a/src/Engine/Rendering/Texture.cpp b/src/Engine/Rendering/Texture.cpp index 57f3ca36..492b35be 100644 --- a/src/Engine/Rendering/Texture.cpp +++ b/src/Engine/Rendering/Texture.cpp @@ -2,14 +2,17 @@ Texture::Texture(std::string path) { + PNG image(path); if (image.Width == 0 && image.Height == 0 || image.Format == Image::ImageFormat::Unknown) { - image = PNG("Textures/Core/ErrorTexture.png"); + //image = PNG("Textures/Core/ErrorTexture.png"); + return; // Temporary fix to remove crash + /* if (image.Width == 0 && image.Height == 0 || image.Format == Image::ImageFormat::Unknown) { LOG_ERROR("Couldn't even load the error texture. This is a dark day indeed."); return; - } + }*/ } this->Width = image.Width; diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index f5afcaeb..d7806ba5 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -14,6 +14,7 @@ #include "Game/Systems/PlayerHUD.h" #include "Game/Systems/LifetimeSystem.h" #include "../Engine/Rendering/AnimationSystem.h" +#include "../Engine/Core/UniformScaleSystem.h" Game::Game(int argc, char* argv[]) { @@ -97,7 +98,7 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeTrigger, "Player"); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); - + m_SystemPipeline->AddSystem(updateOrderLevel); // Collision and TriggerSystem should update after player. ++updateOrderLevel; m_SystemPipeline->AddSystem(updateOrderLevel, m_OctreeCollision); From 0e9fb16399a648a4571351b579da9e02ecadd135 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Mon, 8 Feb 2016 17:58:07 +0100 Subject: [PATCH 02/37] Work started on DamageIndicatorSystem. Made some initial tests and test calculations --- include/Engine/Core/EPlayerDamage.h | 1 + include/Game/Systems/DamageIndicatorSystem.h | 41 ++ resources/Schema/Entities/GameMapTest.xml | 430 ++++++++++++++++++ .../Schema/Entities/SpriteTestTemporary.xml | 24 + src/Game/Game.cpp | 2 + src/Game/Systems/DamageIndicatorSystem.cpp | 101 ++++ 6 files changed, 599 insertions(+) create mode 100644 include/Game/Systems/DamageIndicatorSystem.h create mode 100644 resources/Schema/Entities/GameMapTest.xml create mode 100644 resources/Schema/Entities/SpriteTestTemporary.xml create mode 100644 src/Game/Systems/DamageIndicatorSystem.cpp diff --git a/include/Engine/Core/EPlayerDamage.h b/include/Engine/Core/EPlayerDamage.h index 8ba3907e..c11b121f 100644 --- a/include/Engine/Core/EPlayerDamage.h +++ b/include/Engine/Core/EPlayerDamage.h @@ -11,6 +11,7 @@ struct PlayerDamage : Event { //NOTE: this struct is missing information on what the damageSource is EntityWrapper Player; + EntityWrapper PlayerShooter; double Damage; }; diff --git a/include/Game/Systems/DamageIndicatorSystem.h b/include/Game/Systems/DamageIndicatorSystem.h new file mode 100644 index 00000000..646887e2 --- /dev/null +++ b/include/Game/Systems/DamageIndicatorSystem.h @@ -0,0 +1,41 @@ +#ifndef DamageIndicatorSystem_h__ +#define DamageIndicatorSystem_h__ + +#include "Core/System.h" +#include "Core/Transform.h" +#include "Core/ResourceManager.h" +#include "Core/EntityFileParser.h" +#include "Core/EPickupSpawned.h" +#include "Core/EPlayerDamage.h" +#include "Engine/Collision/ETrigger.h" +#include "Common.h" +#include + +//temp +#include "Input/EInputCommand.h" +#include "Rendering/ESetCamera.h" + +#include + +class DamageIndicatorSystem : public ImpureSystem +{ +public: + DamageIndicatorSystem(World* world, EventBroker* eventBroker); + + virtual void Update(double dt) override; + +private: + + EventRelay m_DamageTakenFromPlayer; + bool OnPlayerDamageTaken(Events::PlayerDamage& e); + + //temp + EventRelay m_EInputCommand; + bool OnInputCommand(Events::InputCommand& e); + + EventRelay m_ESetCamera; + bool OnSetCamera(const Events::SetCamera& e); + + EntityID m_CurrentCamera = -1; +}; +#endif diff --git a/resources/Schema/Entities/GameMapTest.xml b/resources/Schema/Entities/GameMapTest.xml new file mode 100644 index 00000000..ee68da96 --- /dev/null +++ b/resources/Schema/Entities/GameMapTest.xml @@ -0,0 +1,430 @@ + + + + + + + + + + + + + + + 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 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 99 + + + + + + 5 + + + + + + + + + + + + + + + + + + + + + + + Fonts/DroidSans.ttf,100 + + + + + + + + + + + + + + Models/Camera.mesh + false + + + + + + + + + + + + + + + + + + + 0.99000000953674316 + + + + + Models/Core/UnitHexagon.mesh + + + + + + + + + + + + + + Models/CrosshairQuad.mesh + + + + + + + + + + + + + Models/AssaultWeaponRed.mesh + + + + + + + + + + + + + + + + + + + + + + + + + Models/Camera.mesh + false + + + + + + + + + + + + Hold Pos + + 1 + + + + Models/AssaultAnimated.mesh + + + + + + + + + + Models/Core/UnitCube.mesh + + false + + + + + + + + + + + + Models/Core/UnitCube.mesh + + false + + + + + + + + + + + + diff --git a/resources/Schema/Entities/SpriteTestTemporary.xml b/resources/Schema/Entities/SpriteTestTemporary.xml new file mode 100644 index 00000000..f66e9158 --- /dev/null +++ b/resources/Schema/Entities/SpriteTestTemporary.xml @@ -0,0 +1,24 @@ + + + + + + Textures/DefenderGunRedDiff.png + Textures/DefenderGunRedIncd.png + + + + Models/Core/UnitQuad.mesh + + + + + + + 1.5 + + + + + + diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 0cc41a73..5875bc81 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -12,6 +12,7 @@ #include "Core/EntityFileWriter.h" #include "Game/Systems/CapturePointSystem.h" #include "Game/Systems/PickupSpawnSystem.h" +#include "Game/Systems/DamageIndicatorSystem.h" #include "Game/Systems/WeaponSystem.h" #include "Game/Systems/PlayerHUD.h" #include "Game/Systems/LifetimeSystem.h" @@ -96,6 +97,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/DamageIndicatorSystem.cpp b/src/Game/Systems/DamageIndicatorSystem.cpp new file mode 100644 index 00000000..5f6ad725 --- /dev/null +++ b/src/Game/Systems/DamageIndicatorSystem.cpp @@ -0,0 +1,101 @@ +#include "Systems/DamageIndicatorSystem.h" + +DamageIndicatorSystem::DamageIndicatorSystem(World* m_World, EventBroker* eventBroker) + : System(m_World, eventBroker) +{ + EVENT_SUBSCRIBE_MEMBER(m_DamageTakenFromPlayer, &DamageIndicatorSystem::OnPlayerDamageTaken); + //TEMP + EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &DamageIndicatorSystem::OnInputCommand); + //current camera + EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &DamageIndicatorSystem::OnSetCamera); + +} + +void DamageIndicatorSystem::Update(double dt) +{ + +} + + +bool DamageIndicatorSystem::OnPlayerDamageTaken(Events::PlayerDamage& e) +{ + auto test1 = (glm::vec3)e.PlayerShooter["Transform"]["Orientation"]; + auto test2 = (glm::vec3)e.Player["Transform"]["Orientation"]; + //calculate direction + auto enemyOrientation = glm::quat(((glm::vec3)e.PlayerShooter["Transform"]["Orientation"])); + auto playerOrientation = glm::quat((glm::vec3)e.Player["Transform"]["Orientation"]); + //calculate difference in angle (quaternion math) + auto angle1 = glm::angle(playerOrientation); + auto angle2 = glm::angle(enemyOrientation); + auto quat = glm::angleAxis(angle2 - angle1, glm::vec3(0, 1, 0)); + auto vec3Orientation = glm::eulerAngles(quat); + + //load & set the "2d" sprite + auto entityFile = ResourceManager::Load("Schema/Entities/SpriteTestTemporary.xml"); + EntityFileParser parser(entityFile); + EntityID spriteID = parser.MergeEntities(m_World); + m_World->SetParent(spriteID, m_CurrentCamera); + auto cameraWrapper = EntityWrapper(m_World, spriteID); + cameraWrapper["Transform"]["Orientation"] = vec3Orientation; + + return true; +} + +//TEMP +bool DamageIndicatorSystem::OnInputCommand(Events::InputCommand& e) +{ + if (e.Command != "Jump" || e.Value > 0) { + return false; + } + //auto entityFile = ResourceManager::Load("Schema/Entities/SpriteTestTemporary.xml"); + //EntityFileParser parser(entityFile); + //EntityID spriteID = parser.MergeEntities(m_World); + ////get currently active camera + ////auto cameras = m_World->GetComponents("Camera"); + ////for (auto& cCamera : *cameras) { + //// + //// //auto temp = m_World->GetParent(cCamera.EntityID); + //// m_World->SetParent(spriteID, cCamera.EntityID); + ////} + ////m_CurrentCamera + //m_World->SetParent(spriteID, m_CurrentCamera); + + //auto cameraWrapper = EntityWrapper(m_World, spriteID); + //cameraWrapper["Transform"]["Orientation"] = glm::vec3(1, 1, 1); + //ray player-enemyplayer eller bara spelarnas direction + + + //TODO: life time, rotering +//den ska väl vara där hela tiden, bara det att den inte syns + + + //EntityWrapper(m_World, spriteID); + + auto players = m_World->GetComponents("Player"); + EntityID id1 = (*players->begin()).EntityID; + EntityID id2; + int lameCounter = 0; + for (auto& cPlayers : *players) { + if (lameCounter == 1) { + id2 = cPlayers.EntityID; + } + lameCounter++; + } + if (lameCounter != 2) { + return false; + } + + //do something here + Events::PlayerDamage ePlayerDamage; + ePlayerDamage.Player = EntityWrapper(m_World, id1); + ePlayerDamage.PlayerShooter = EntityWrapper(m_World, id2); + ePlayerDamage.Damage = 1; + m_EventBroker->Publish(ePlayerDamage); + + return true; +} + +bool DamageIndicatorSystem::OnSetCamera(const Events::SetCamera& e) { + m_CurrentCamera = e.CameraEntity.ID; + return true; +} \ No newline at end of file From 971fee4a0cfaa0b9017718a8a9e2ade928bc05f2 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Tue, 9 Feb 2016 15:38:21 +0100 Subject: [PATCH 03/37] DamageIndicatorSystem code looking good. Test working well. Sprite display fixed by Viktor --- include/Game/Systems/DamageIndicatorSystem.h | 1 + .../Schema/Entities/SpriteTestTemporary.xml | 7 +--- resources/Shaders/Sprite.vert.glsl | 2 +- src/Game/Systems/DamageIndicatorSystem.cpp | 42 +++++++++++++++---- 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/include/Game/Systems/DamageIndicatorSystem.h b/include/Game/Systems/DamageIndicatorSystem.h index 646887e2..561654d1 100644 --- a/include/Game/Systems/DamageIndicatorSystem.h +++ b/include/Game/Systems/DamageIndicatorSystem.h @@ -16,6 +16,7 @@ #include "Rendering/ESetCamera.h" #include +#include class DamageIndicatorSystem : public ImpureSystem { diff --git a/resources/Schema/Entities/SpriteTestTemporary.xml b/resources/Schema/Entities/SpriteTestTemporary.xml index f66e9158..2d02443c 100644 --- a/resources/Schema/Entities/SpriteTestTemporary.xml +++ b/resources/Schema/Entities/SpriteTestTemporary.xml @@ -3,13 +3,10 @@ - Textures/DefenderGunRedDiff.png - Textures/DefenderGunRedIncd.png + Textures/TempDamageIndicator.png + Textures/TempDamageIndicator.png - - Models/Core/UnitQuad.mesh - diff --git a/resources/Shaders/Sprite.vert.glsl b/resources/Shaders/Sprite.vert.glsl index e910a26a..61b387ad 100644 --- a/resources/Shaders/Sprite.vert.glsl +++ b/resources/Shaders/Sprite.vert.glsl @@ -16,7 +16,7 @@ out VertexData{ void main() { - gl_Position = P * M * vec4(Position, 1.0); + gl_Position = P * V * M * vec4(Position, 1.0); Output.Position = Position; Output.TextureCoordinate = TextureCoords; diff --git a/src/Game/Systems/DamageIndicatorSystem.cpp b/src/Game/Systems/DamageIndicatorSystem.cpp index 5f6ad725..24d1cfa4 100644 --- a/src/Game/Systems/DamageIndicatorSystem.cpp +++ b/src/Game/Systems/DamageIndicatorSystem.cpp @@ -21,22 +21,46 @@ bool DamageIndicatorSystem::OnPlayerDamageTaken(Events::PlayerDamage& e) { auto test1 = (glm::vec3)e.PlayerShooter["Transform"]["Orientation"]; auto test2 = (glm::vec3)e.Player["Transform"]["Orientation"]; - //calculate direction - auto enemyOrientation = glm::quat(((glm::vec3)e.PlayerShooter["Transform"]["Orientation"])); + + //grab players direction auto playerOrientation = glm::quat((glm::vec3)e.Player["Transform"]["Orientation"]); - //calculate difference in angle (quaternion math) - auto angle1 = glm::angle(playerOrientation); - auto angle2 = glm::angle(enemyOrientation); - auto quat = glm::angleAxis(angle2 - angle1, glm::vec3(0, 1, 0)); - auto vec3Orientation = glm::eulerAngles(quat); + + //get the position vectors, but ignore the y-height + auto enemyPosition = (glm::vec3) e.PlayerShooter["Transform"]["Position"]; + auto playerPosition = (glm::vec3) e.Player["Transform"]["Position"]; + enemyPosition.y = 0.0f; + playerPosition.y = 0.0f; + + //calculate the enemy to player vector + auto enemyPlayerVector = glm::normalize((glm::vec3) 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; + } + + //LOG_INFO("vector angle %f %f %f %f", t1, t3, t4, enemyPlayerVector.x); //load & set the "2d" sprite auto entityFile = ResourceManager::Load("Schema/Entities/SpriteTestTemporary.xml"); EntityFileParser parser(entityFile); EntityID spriteID = parser.MergeEntities(m_World); m_World->SetParent(spriteID, m_CurrentCamera); - auto cameraWrapper = EntityWrapper(m_World, spriteID); - cameraWrapper["Transform"]["Orientation"] = vec3Orientation; + auto spriteWrapper = EntityWrapper(m_World, spriteID); + //simply set the rotation z-wise to the angleBetweenVectors + spriteWrapper["Transform"]["Orientation"] = glm::vec3(0, 0, angleBetweenVectors); return true; } From 8bdf87da12663aeb6b8b6a23b7288b032411b8f0 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Tue, 9 Feb 2016 16:15:19 +0100 Subject: [PATCH 04/37] Some cleanup of the code --- include/Game/Systems/DamageIndicatorSystem.h | 14 +--- src/Game/Systems/DamageIndicatorSystem.cpp | 70 +------------------- src/Game/Systems/WeaponSystem.cpp | 1 + 3 files changed, 5 insertions(+), 80 deletions(-) diff --git a/include/Game/Systems/DamageIndicatorSystem.h b/include/Game/Systems/DamageIndicatorSystem.h index 561654d1..fd3ba33f 100644 --- a/include/Game/Systems/DamageIndicatorSystem.h +++ b/include/Game/Systems/DamageIndicatorSystem.h @@ -5,35 +5,23 @@ #include "Core/Transform.h" #include "Core/ResourceManager.h" #include "Core/EntityFileParser.h" -#include "Core/EPickupSpawned.h" #include "Core/EPlayerDamage.h" -#include "Engine/Collision/ETrigger.h" #include "Common.h" #include -//temp -#include "Input/EInputCommand.h" #include "Rendering/ESetCamera.h" - #include #include -class DamageIndicatorSystem : public ImpureSystem +class DamageIndicatorSystem : public System { public: DamageIndicatorSystem(World* world, EventBroker* eventBroker); - virtual void Update(double dt) override; - private: - EventRelay m_DamageTakenFromPlayer; bool OnPlayerDamageTaken(Events::PlayerDamage& e); - //temp - EventRelay m_EInputCommand; - bool OnInputCommand(Events::InputCommand& e); - EventRelay m_ESetCamera; bool OnSetCamera(const Events::SetCamera& e); diff --git a/src/Game/Systems/DamageIndicatorSystem.cpp b/src/Game/Systems/DamageIndicatorSystem.cpp index 24d1cfa4..0acb24c3 100644 --- a/src/Game/Systems/DamageIndicatorSystem.cpp +++ b/src/Game/Systems/DamageIndicatorSystem.cpp @@ -4,23 +4,15 @@ DamageIndicatorSystem::DamageIndicatorSystem(World* m_World, EventBroker* eventB : System(m_World, eventBroker) { EVENT_SUBSCRIBE_MEMBER(m_DamageTakenFromPlayer, &DamageIndicatorSystem::OnPlayerDamageTaken); - //TEMP - EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &DamageIndicatorSystem::OnInputCommand); //current camera EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &DamageIndicatorSystem::OnSetCamera); - } -void DamageIndicatorSystem::Update(double dt) -{ - -} - - bool DamageIndicatorSystem::OnPlayerDamageTaken(Events::PlayerDamage& e) { - auto test1 = (glm::vec3)e.PlayerShooter["Transform"]["Orientation"]; - auto test2 = (glm::vec3)e.Player["Transform"]["Orientation"]; + if (m_CurrentCamera == -1) { + return false; + } //grab players direction auto playerOrientation = glm::quat((glm::vec3)e.Player["Transform"]["Orientation"]); @@ -51,8 +43,6 @@ bool DamageIndicatorSystem::OnPlayerDamageTaken(Events::PlayerDamage& e) angleBetweenVectors = -angleBetweenVectors; } - //LOG_INFO("vector angle %f %f %f %f", t1, t3, t4, enemyPlayerVector.x); - //load & set the "2d" sprite auto entityFile = ResourceManager::Load("Schema/Entities/SpriteTestTemporary.xml"); EntityFileParser parser(entityFile); @@ -65,60 +55,6 @@ bool DamageIndicatorSystem::OnPlayerDamageTaken(Events::PlayerDamage& e) return true; } -//TEMP -bool DamageIndicatorSystem::OnInputCommand(Events::InputCommand& e) -{ - if (e.Command != "Jump" || e.Value > 0) { - return false; - } - //auto entityFile = ResourceManager::Load("Schema/Entities/SpriteTestTemporary.xml"); - //EntityFileParser parser(entityFile); - //EntityID spriteID = parser.MergeEntities(m_World); - ////get currently active camera - ////auto cameras = m_World->GetComponents("Camera"); - ////for (auto& cCamera : *cameras) { - //// - //// //auto temp = m_World->GetParent(cCamera.EntityID); - //// m_World->SetParent(spriteID, cCamera.EntityID); - ////} - ////m_CurrentCamera - //m_World->SetParent(spriteID, m_CurrentCamera); - - //auto cameraWrapper = EntityWrapper(m_World, spriteID); - //cameraWrapper["Transform"]["Orientation"] = glm::vec3(1, 1, 1); - //ray player-enemyplayer eller bara spelarnas direction - - - //TODO: life time, rotering -//den ska väl vara där hela tiden, bara det att den inte syns - - - //EntityWrapper(m_World, spriteID); - - auto players = m_World->GetComponents("Player"); - EntityID id1 = (*players->begin()).EntityID; - EntityID id2; - int lameCounter = 0; - for (auto& cPlayers : *players) { - if (lameCounter == 1) { - id2 = cPlayers.EntityID; - } - lameCounter++; - } - if (lameCounter != 2) { - return false; - } - - //do something here - Events::PlayerDamage ePlayerDamage; - ePlayerDamage.Player = EntityWrapper(m_World, id1); - ePlayerDamage.PlayerShooter = EntityWrapper(m_World, id2); - ePlayerDamage.Damage = 1; - m_EventBroker->Publish(ePlayerDamage); - - return true; -} - bool DamageIndicatorSystem::OnSetCamera(const Events::SetCamera& e) { m_CurrentCamera = e.CameraEntity.ID; return true; diff --git a/src/Game/Systems/WeaponSystem.cpp b/src/Game/Systems/WeaponSystem.cpp index 1613cb7a..bc7c86b6 100644 --- a/src/Game/Systems/WeaponSystem.cpp +++ b/src/Game/Systems/WeaponSystem.cpp @@ -134,6 +134,7 @@ bool WeaponSystem::OnShoot(Events::Shoot& eShoot) // TODO: Weapon damage calculations etc Events::PlayerDamage ePlayerDamage; ePlayerDamage.Player = player; + ePlayerDamage.PlayerShooter = eShoot.Player; ePlayerDamage.Damage = 100; m_EventBroker->Publish(ePlayerDamage); From e9f5a3d263bc6a00b7526db945732e7dcfc448d0 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Tue, 9 Feb 2016 16:28:43 +0100 Subject: [PATCH 05/37] Renamed some files from temporary filenames to DamageIndicator filenames --- .../Entities/{SpriteTestTemporary.xml => DamageIndicator.xml} | 0 .../Entities/{GameMapTest.xml => DamageIndicatorTest.xml} | 0 src/Game/Systems/DamageIndicatorSystem.cpp | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) rename resources/Schema/Entities/{SpriteTestTemporary.xml => DamageIndicator.xml} (100%) rename resources/Schema/Entities/{GameMapTest.xml => DamageIndicatorTest.xml} (100%) diff --git a/resources/Schema/Entities/SpriteTestTemporary.xml b/resources/Schema/Entities/DamageIndicator.xml similarity index 100% rename from resources/Schema/Entities/SpriteTestTemporary.xml rename to resources/Schema/Entities/DamageIndicator.xml diff --git a/resources/Schema/Entities/GameMapTest.xml b/resources/Schema/Entities/DamageIndicatorTest.xml similarity index 100% rename from resources/Schema/Entities/GameMapTest.xml rename to resources/Schema/Entities/DamageIndicatorTest.xml diff --git a/src/Game/Systems/DamageIndicatorSystem.cpp b/src/Game/Systems/DamageIndicatorSystem.cpp index 0acb24c3..638307bf 100644 --- a/src/Game/Systems/DamageIndicatorSystem.cpp +++ b/src/Game/Systems/DamageIndicatorSystem.cpp @@ -44,7 +44,7 @@ bool DamageIndicatorSystem::OnPlayerDamageTaken(Events::PlayerDamage& e) } //load & set the "2d" sprite - auto entityFile = ResourceManager::Load("Schema/Entities/SpriteTestTemporary.xml"); + auto entityFile = ResourceManager::Load("Schema/Entities/DamageIndicator.xml"); EntityFileParser parser(entityFile); EntityID spriteID = parser.MergeEntities(m_World); m_World->SetParent(spriteID, m_CurrentCamera); From b6b96c5f11f52b12954ac170b9496330668ced1e Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Wed, 10 Feb 2016 11:51:58 +0100 Subject: [PATCH 06/37] Added DoubleJumpHexagon entity. Spawned DoubleJumpHexagon as the player doublejumps. Fixed DoubleJumping bug where you couldnt doublejump on rocks (where velocity wasnt 0.0) --- include/Game/Systems/PlayerMovementSystem.h | 3 ++ resources/DefaultInput.ini | 3 ++ .../Schema/Entities/DoubleJumpHexagon.xml | 30 +++++++++++++++++++ src/Game/Systems/PlayerMovementSystem.cpp | 8 ++++- 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 resources/Schema/Entities/DoubleJumpHexagon.xml diff --git a/include/Game/Systems/PlayerMovementSystem.h b/include/Game/Systems/PlayerMovementSystem.h index 34862e90..a0194545 100644 --- a/include/Game/Systems/PlayerMovementSystem.h +++ b/include/Game/Systems/PlayerMovementSystem.h @@ -5,6 +5,9 @@ #include "Input/FirstPersonInputController.h" #include +#include "Core/EntityFile.h" +#include "Core/EntityFileParser.h" + class PlayerMovementSystem : public ImpureSystem, PureSystem { public: diff --git a/resources/DefaultInput.ini b/resources/DefaultInput.ini index 589dfb3f..eb5b7658 100644 --- a/resources/DefaultInput.ini +++ b/resources/DefaultInput.ini @@ -2,6 +2,9 @@ Sensitivity=0.5 InvertPitch=false +[KeyBoard] +DoubleTapToDash=true + [Bindings] MouseLeft=PrimaryFire MouseX=Yaw diff --git a/resources/Schema/Entities/DoubleJumpHexagon.xml b/resources/Schema/Entities/DoubleJumpHexagon.xml new file mode 100644 index 00000000..bbc41119 --- /dev/null +++ b/resources/Schema/Entities/DoubleJumpHexagon.xml @@ -0,0 +1,30 @@ + + + + + + Models/JumpEffectHexagon.mesh + + true + + + + + + + 1.5 + + + true + + + true + 3 + + true + + + + + + diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 52890c3a..6b26db1c 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -90,9 +90,15 @@ void PlayerMovementSystem::Update(double dt) //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 (velocity.y == 0.f) { + if (isOnGround) { controller->SetDoubleJumping(false); } else { + //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"]; controller->SetDoubleJumping(true); } velocity.y = 4.f; From 53265bbc90c4c2e647be75ddbfe739e34eb9e5c2 Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 10 Feb 2016 17:50:17 +0100 Subject: [PATCH 07/37] PNG is now a resource. You can now load textures threaded. PNG will now throw exceptions when errors happend SpriteComponent is now working without billboarding. --- include/Engine/GUI/TextureFrame.h | 5 +- include/Engine/Rendering/DrawFinalPass.h | 2 + include/Engine/Rendering/Model.h | 1 + include/Engine/Rendering/PNG.h | 3 +- include/Engine/Rendering/Renderer.h | 1 + include/Engine/Rendering/SpriteJob.h | 19 ++--- .../Engine/Rendering/Util/CommonFunctions.h | 11 +-- .../Schema/Entities/QualityAssurance.xml | 74 +++++++++++++++---- resources/Shaders/Sprite.vert.glsl | 3 +- src/Engine/Rendering/DrawBloomPass.cpp | 2 +- src/Engine/Rendering/DrawFinalPass.cpp | 17 +++-- src/Engine/Rendering/Model.cpp | 8 +- src/Engine/Rendering/PNG.cpp | 22 ++---- src/Engine/Rendering/Renderer.cpp | 17 +++-- src/Engine/Rendering/Texture.cpp | 29 ++++---- src/Engine/Rendering/Util/CommonFunctions.cpp | 17 +++++ src/Game/Game.cpp | 1 + 17 files changed, 149 insertions(+), 83 deletions(-) diff --git a/include/Engine/GUI/TextureFrame.h b/include/Engine/GUI/TextureFrame.h index 2c6d34dd..77967b4d 100644 --- a/include/Engine/GUI/TextureFrame.h +++ b/include/Engine/GUI/TextureFrame.h @@ -3,6 +3,7 @@ #include "Frame.h" #include "../Rendering/Texture.h" +#include "../Rendering/Util/CommonFunctions.h" namespace GUI { @@ -55,10 +56,10 @@ public: return; } - m_Texture = ResourceManager::Load(resourceName); + m_Texture = CommonFunctions::LoadTexture(resourceName, false); m_TextureName = resourceName; if (m_Texture == nullptr) { - m_Texture = ResourceManager::Load("Textures/Core/ErrorTexture.png"); + m_Texture = CommonFunctions::LoadTexture("Textures/Core/ErrorTexture.png", false); } SizeToTexture(); diff --git a/include/Engine/Rendering/DrawFinalPass.h b/include/Engine/Rendering/DrawFinalPass.h index 867ec844..98f986b4 100644 --- a/include/Engine/Rendering/DrawFinalPass.h +++ b/include/Engine/Rendering/DrawFinalPass.h @@ -7,6 +7,7 @@ #include "FrameBuffer.h" #include "ShaderProgram.h" #include "Util/UnorderedMapVec2.h" +#include "Util/CommonFunctions.h" #include "Texture.h" class DrawFinalPass @@ -43,6 +44,7 @@ private: Texture* m_BlackTexture; Texture* m_NeutralNormalTexture; Texture* m_GreyTexture; + Texture* m_ErrorTexture; FrameBuffer m_FinalPassFrameBuffer; GLuint m_BloomTexture; diff --git a/include/Engine/Rendering/Model.h b/include/Engine/Rendering/Model.h index f751a8cc..6812494c 100644 --- a/include/Engine/Rendering/Model.h +++ b/include/Engine/Rendering/Model.h @@ -2,6 +2,7 @@ #define Model_h__ #include "Rendering/RawModelCustom.h" +#include "Util/CommonFunctions.h" //#include "Rendering/RawModelAssimp.h" #include "../OpenGL.h" diff --git a/include/Engine/Rendering/PNG.h b/include/Engine/Rendering/PNG.h index f2cbf157..a45e9e7c 100644 --- a/include/Engine/Rendering/PNG.h +++ b/include/Engine/Rendering/PNG.h @@ -6,9 +6,10 @@ #include #include "../Common.h" +#include "../Core/ResourceManager.h" #include "Image.h" -class PNG : public Image +class PNG : public Image, public Resource { public: PNG(std::string path); diff --git a/include/Engine/Rendering/Renderer.h b/include/Engine/Rendering/Renderer.h index 33a61edf..04754514 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 "Util/CommonFunctions.h" class Renderer : public IRenderer { diff --git a/include/Engine/Rendering/SpriteJob.h b/include/Engine/Rendering/SpriteJob.h index a20d0395..23bf6360 100644 --- a/include/Engine/Rendering/SpriteJob.h +++ b/include/Engine/Rendering/SpriteJob.h @@ -24,23 +24,17 @@ struct SpriteJob : RenderJob ::RawModel::MaterialGroup matGroup = Model->MaterialGroups().front(); TextureID = (matGroup.Texture) ? matGroup.Texture->ResourceID : 0; - if (cSprite["DiffuseTexture"]) { - DiffuseTexture = ResourceManager::Load(cSprite["DiffuseTexture"]); - } else { - DiffuseTexture = nullptr; - } - if (cSprite["GlowMap"]) { - IncandescenceTexture = ResourceManager::Load(cSprite["GlowMap"]); - } else { - IncandescenceTexture = nullptr; - } + DiffuseTexture = CommonFunctions::LoadTexture(cSprite["DiffuseTexture"], true); + + IncandescenceTexture = CommonFunctions::LoadTexture(cSprite["GlowMap"], true); + StartIndex = matGroup.StartIndex; EndIndex = matGroup.EndIndex; Matrix = matrix; Color = cSprite["Color"]; Entity = cSprite.EntityID; - glm::vec3 abspos = Transform::AbsolutePosition(world, cSprite.EntityID); - glm::vec3 viewpos = glm::vec3(camera->ViewMatrix() * glm::vec4(abspos, 1)); + Position = Transform::AbsolutePosition(world, cSprite.EntityID); + glm::vec3 viewpos = glm::vec3(camera->ViewMatrix() * glm::vec4(Position, 1)); Depth = viewpos.z; World = world; @@ -58,6 +52,7 @@ struct SpriteJob : RenderJob const Texture* IncandescenceTexture; float Shininess = 0.f; glm::vec4 Color; + glm::vec3 Position; const ::Model* Model = nullptr; unsigned int StartIndex = 0; unsigned int EndIndex = 0; diff --git a/include/Engine/Rendering/Util/CommonFunctions.h b/include/Engine/Rendering/Util/CommonFunctions.h index b262568c..e178f52d 100644 --- a/include/Engine/Rendering/Util/CommonFunctions.h +++ b/include/Engine/Rendering/Util/CommonFunctions.h @@ -4,14 +4,11 @@ #include "../../Common.h" #include "../../OpenGL.h" #include "../../GLM.h" +#include "../Texture.h" -class CommonFuntions -{ -public: - CommonFuntions() = delete; - -private: - +namespace CommonFunctions +{ +Texture* LoadTexture(std::string path, bool threaded); }; #endif \ No newline at end of file diff --git a/resources/Schema/Entities/QualityAssurance.xml b/resources/Schema/Entities/QualityAssurance.xml index e057cf38..23ebb4a5 100644 --- a/resources/Schema/Entities/QualityAssurance.xml +++ b/resources/Schema/Entities/QualityAssurance.xml @@ -40,7 +40,7 @@ - + @@ -188,7 +188,7 @@ - + @@ -683,7 +683,7 @@ - + @@ -730,7 +730,7 @@ - + @@ -790,7 +790,7 @@ - + @@ -837,7 +837,7 @@ - + @@ -883,7 +883,7 @@ - + @@ -930,7 +930,7 @@ - + @@ -977,7 +977,7 @@ - + @@ -1374,7 +1374,7 @@ - + @@ -1383,7 +1383,7 @@ true - 0.75008034908941568 + 0.75102457088592522 3.7999999523162842 true @@ -1430,7 +1430,7 @@ - + @@ -1439,7 +1439,7 @@ - 1.1999860997035228 + 1.2009303215000324 Models/Assault.mesh @@ -1482,7 +1482,7 @@ - + @@ -1497,7 +1497,7 @@ true - 0.68343188336345406 + 0.68437610515996361 true @@ -1553,6 +1553,50 @@ + + + + + + + + + + + + Textures/FoliageDiff.png + Textures/DefenderGunBlueIncd.png + + + + + + + + + Textures/FoliageDiff.png + Textures/AssaultWeaponBlueGlowMap.png + + + + + + + + + + + Textures/FoliageDiff.png + Textures/GlowTest.png + + + + + + + + + diff --git a/resources/Shaders/Sprite.vert.glsl b/resources/Shaders/Sprite.vert.glsl index e910a26a..c09d745b 100644 --- a/resources/Shaders/Sprite.vert.glsl +++ b/resources/Shaders/Sprite.vert.glsl @@ -16,7 +16,8 @@ out VertexData{ void main() { - gl_Position = P * M * vec4(Position, 1.0); + + gl_Position = P * V * M * vec4(Position, 1.0); Output.Position = Position; Output.TextureCoordinate = TextureCoords; diff --git a/src/Engine/Rendering/DrawBloomPass.cpp b/src/Engine/Rendering/DrawBloomPass.cpp index 5d8b2359..2c9e47b4 100644 --- a/src/Engine/Rendering/DrawBloomPass.cpp +++ b/src/Engine/Rendering/DrawBloomPass.cpp @@ -13,7 +13,7 @@ DrawBloomPass::DrawBloomPass(IRenderer* renderer) void DrawBloomPass::InitializeTextures() { - m_WhiteTexture = ResourceManager::Load("Textures/Core/White.png"); + m_WhiteTexture = CommonFunctions::LoadTexture("Textures/Core/White.png", false); } void DrawBloomPass::InitializeShaderPrograms() diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index e5919fbe..98f17835 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -11,10 +11,11 @@ DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCulling void DrawFinalPass::InitializeTextures() { - m_WhiteTexture = ResourceManager::Load("Textures/Core/White.png"); - m_BlackTexture = ResourceManager::Load("Textures/Core/Black.png"); - m_NeutralNormalTexture = ResourceManager::Load("Textures/Core/NeutralNormalMap.png"); - m_GreyTexture = ResourceManager::Load("Textures/Core/Grey.png"); + m_WhiteTexture = CommonFunctions::LoadTexture("Textures/Core/White.png", false); + m_BlackTexture = CommonFunctions::LoadTexture("Textures/Core/Black.png", false); + m_NeutralNormalTexture = CommonFunctions::LoadTexture("Textures/Core/NeutralNormalMap.png", false); + m_GreyTexture = CommonFunctions::LoadTexture("Textures/Core/Grey.png", false); + m_ErrorTexture = CommonFunctions::LoadTexture("Textures/Core/ErrorTexture.png", false); } void DrawFinalPass::InitializeFrameBuffers() @@ -56,7 +57,7 @@ void DrawFinalPass::InitializeShaderPrograms() m_ExplosionEffectProgram->Link(); GLERROR("Creating explosion program"); - m_SpriteProgram = ResourceManager::Load("#m_SpriteProgram"); + m_SpriteProgram = ResourceManager::Load("#SpriteProgram"); m_SpriteProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/Sprite.vert.glsl"))); m_SpriteProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/Sprite.frag.glsl"))); m_SpriteProgram->Compile(); @@ -222,10 +223,12 @@ void DrawFinalPass::DrawSprites(std::list>&jobs, Rend for(auto& job : jobs) { auto spriteJob = std::dynamic_pointer_cast(job); - if(spriteJob) { + if (spriteJob) { + glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(spriteJob->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())); + glUniform3fv(glGetUniformLocation(shaderHandle, "CameraPos"), 1, glm::value_ptr(scene.Camera->Position())); glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(spriteJob->Color)); glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(spriteJob->FillColor)); glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), spriteJob->FillPercentage); @@ -234,7 +237,7 @@ void DrawFinalPass::DrawSprites(std::list>&jobs, Rend if (spriteJob->DiffuseTexture != nullptr) { glBindTexture(GL_TEXTURE_2D, spriteJob->DiffuseTexture->m_Texture); } else { - glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture); + glBindTexture(GL_TEXTURE_2D, m_ErrorTexture->m_Texture); } glActiveTexture(GL_TEXTURE1); diff --git a/src/Engine/Rendering/Model.cpp b/src/Engine/Rendering/Model.cpp index cf4923a3..82dd71af 100644 --- a/src/Engine/Rendering/Model.cpp +++ b/src/Engine/Rendering/Model.cpp @@ -7,16 +7,16 @@ Model::Model(std::string fileName) for (auto& group : m_RawModel->MaterialGroups) { if (!group.TexturePath.empty()) { - group.Texture = std::shared_ptr(ResourceManager::Load(group.TexturePath)); + group.Texture = std::shared_ptr(CommonFunctions::LoadTexture(group.TexturePath, false)); } if (!group.NormalMapPath.empty()) { - group.NormalMap = std::shared_ptr(ResourceManager::Load(group.NormalMapPath)); + group.NormalMap = std::shared_ptr(CommonFunctions::LoadTexture(group.NormalMapPath, false)); } if (!group.SpecularMapPath.empty()) { - group.SpecularMap = std::shared_ptr(ResourceManager::Load(group.SpecularMapPath)); + group.SpecularMap = std::shared_ptr(CommonFunctions::LoadTexture(group.SpecularMapPath, false)); } if (!group.IncandescenceMapPath.empty()) { - group.IncandescenceMap = std::shared_ptr(ResourceManager::Load(group.IncandescenceMapPath)); + group.IncandescenceMap = std::shared_ptr(CommonFunctions::LoadTexture(group.IncandescenceMapPath, false)); } } diff --git a/src/Engine/Rendering/PNG.cpp b/src/Engine/Rendering/PNG.cpp index 7ffd5c20..409da9b1 100644 --- a/src/Engine/Rendering/PNG.cpp +++ b/src/Engine/Rendering/PNG.cpp @@ -4,40 +4,35 @@ PNG::PNG(std::string path) { FILE* file = fopen(path.c_str(), "rb"); if (!file) { - LOG_ERROR("Failed to open texture file \"%s\": %s", path.c_str(), const_cast(strerror(errno))); - return; + throw Resource::FailedLoadingException("Failed to open texture file."); } png_byte header[8]; fread(header, 1, 8, file); bool isPNG = !png_sig_cmp(header, 0, 8); if (!isPNG) { - LOG_ERROR("Failed to load texture file \"%s\": File isn't PNG", path.c_str()); fclose(file); - return; + throw Resource::FailedLoadingException("File is not PNG."); } // Initialize libpng png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, (png_error_ptr)&PNG::pngErrorFunction, (png_error_ptr)&PNG::pngErrorFunction); if (!png_ptr) { - LOG_ERROR("libpng: Failed to initialze png_struct"); png_destroy_read_struct(&png_ptr, nullptr, nullptr); fclose(file); - return; + throw Resource::FailedLoadingException("Failed to initialze png_struct."); } png_infop info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { - LOG_ERROR("libpng: Failed to initialze png_info"); png_destroy_read_struct(&png_ptr, nullptr, nullptr); fclose(file); - return; + throw Resource::FailedLoadingException("Failed to initialze png_info."); } png_infop info_end_ptr = png_create_info_struct(png_ptr); if (!info_end_ptr) { - LOG_ERROR("libpng: Failed to initialze second png_info"); png_destroy_read_struct(&png_ptr, &info_ptr, nullptr); fclose(file); - return; + throw Resource::FailedLoadingException("Failed to initialze second png_info."); } png_init_io(png_ptr, file); @@ -51,8 +46,8 @@ PNG::PNG(std::string path) unsigned int width, height; png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, NULL, NULL, NULL); if (bit_depth != 8) { - LOG_ERROR("libpng: Unsupported bit depth \"%i\" of image \"%s\", must be 8", bit_depth, path.c_str()); - return; + throw Resource::FailedLoadingException("Unsupported bit depth. Must be 8"); + } switch (color_type) { case PNG_COLOR_TYPE_RGB: @@ -60,8 +55,7 @@ PNG::PNG(std::string path) Format = Image::ImageFormat::RGBA; break; default: - LOG_ERROR("libpng: Unsupported color format \"%i\" of image \"%s\"", color_type, path.c_str()); - return; + throw Resource::FailedLoadingException("Unsupported color format."); } // Convert RGB to RGBA, since DirectX rather treat them all the same way diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index a63e02a0..c0e4d07c 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -106,16 +106,21 @@ void Renderer::Draw(RenderFrame& frame) for (auto scene : frame.RenderScenes){ SortRenderJobsByDepth(*scene); + GLERROR("SortByDepth"); m_PickingPass->Draw(*scene); + GLERROR("Drawing pickingpass"); m_LightCullingPass->GenerateNewFrustum(*scene); + GLERROR("Generate frustums"); m_LightCullingPass->FillLightList(*scene); + GLERROR("Filling light list"); m_LightCullingPass->CullLights(*scene); + GLERROR("LightCulling"); m_DrawFinalPass->Draw(*scene); + GLERROR("Draw Geometry+Light"); //m_DrawScenePass->Draw(*scene); - GLERROR("Renderer::Draw m_DrawScenePass->Draw"); - m_TextPass->Draw(*scene, *m_DrawFinalPass->FinalPassFrameBuffer()); + GLERROR("Draw Text"); } m_DrawBloomPass->Draw(m_DrawFinalPass->BloomTexture()); @@ -136,7 +141,8 @@ void Renderer::Draw(RenderFrame& frame) } m_ImGuiRenderPass->Draw(); - glfwSwapBuffers(m_Window); + GLERROR("Imgui draw"); + glfwSwapBuffers(m_Window); } PickData Renderer::Pick(glm::vec2 screenCoord) @@ -146,8 +152,8 @@ PickData Renderer::Pick(glm::vec2 screenCoord) void Renderer::InitializeTextures() { - m_ErrorTexture = ResourceManager::Load("Textures/Core/ErrorTexture.png"); - m_WhiteTexture = ResourceManager::Load("Textures/Core/White.png"); + m_ErrorTexture = CommonFunctions::LoadTexture("Textures/Core/ErrorTexture.png", false); + m_WhiteTexture = CommonFunctions::LoadTexture("Textures/Core/White.png", false); } @@ -155,6 +161,7 @@ void Renderer::SortRenderJobsByDepth(RenderScene &scene) { //Sort all forward jobs so transparency is good. scene.TransparentObjects.sort(Renderer::DepthSort); + scene.SpriteJobs.sort(Renderer::DepthSort); } void Renderer::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) diff --git a/src/Engine/Rendering/Texture.cpp b/src/Engine/Rendering/Texture.cpp index 492b35be..a4b2d4c9 100644 --- a/src/Engine/Rendering/Texture.cpp +++ b/src/Engine/Rendering/Texture.cpp @@ -2,24 +2,25 @@ Texture::Texture(std::string path) { + PNG* img = ResourceManager::Load(path); //TODO: Make this threaded. Catch exeptions in all other load places. - PNG image(path); + //PNG image(path); - if (image.Width == 0 && image.Height == 0 || image.Format == Image::ImageFormat::Unknown) { - //image = PNG("Textures/Core/ErrorTexture.png"); - return; // Temporary fix to remove crash - /* - if (image.Width == 0 && image.Height == 0 || image.Format == Image::ImageFormat::Unknown) { - LOG_ERROR("Couldn't even load the error texture. This is a dark day indeed."); - return; - }*/ - } + //if (img->Width == 0 && img->Height == 0 || img->Format == Image::ImageFormat::Unknown) { + // //image = PNG("Textures/Core/ErrorTexture.png"); + // //return; // Temporary fix to remove crash - this->Width = image.Width; - this->Height = image.Height; + // if (img->Width == 0 && img->Height == 0 || img->Format == Image::ImageFormat::Unknown) { + // LOG_ERROR("Couldn't even load the error texture. This is a dark day indeed."); + // return; + // } + //} + + this->Width = img->Width; + this->Height = img->Height; GLint format; - switch (image.Format) { + switch (img->Format) { case Image::ImageFormat::RGB: format = GL_RGB; break; @@ -32,7 +33,7 @@ Texture::Texture(std::string path) glGenTextures(1, &m_Texture); glBindTexture(GL_TEXTURE_2D, m_Texture); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexImage2D(GL_TEXTURE_2D, 0, format, image.Width, image.Height, 0, format, GL_UNSIGNED_BYTE, image.Data); + glTexImage2D(GL_TEXTURE_2D, 0, format, img->Width, img->Height, 0, format, GL_UNSIGNED_BYTE, img->Data); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); diff --git a/src/Engine/Rendering/Util/CommonFunctions.cpp b/src/Engine/Rendering/Util/CommonFunctions.cpp index 3c81de66..382cb790 100644 --- a/src/Engine/Rendering/Util/CommonFunctions.cpp +++ b/src/Engine/Rendering/Util/CommonFunctions.cpp @@ -1,2 +1,19 @@ #include "Rendering/Util/CommonFunctions.h" +Texture* CommonFunctions::LoadTexture(std::string path, bool threaded) +{ + Texture* img; + try { + if(threaded) { + img = ResourceManager::Load(path); + } else { + img = ResourceManager::Load(path); + } + } catch (const Resource::StillLoadingException&) { + img = ResourceManager::Load("Textures/Core/ErrorTexture.png"); + } catch (const std::exception&) { + img = nullptr; + } + + return img; +} diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 0cc41a73..780842a6 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -25,6 +25,7 @@ Game::Game(int argc, char* argv[]) ResourceManager::RegisterType("Model"); ResourceManager::RegisterType("RawModel"); ResourceManager::RegisterType("Texture"); + ResourceManager::RegisterType("Png"); ResourceManager::RegisterType("ShaderProgram"); ResourceManager::RegisterType("EntityFile"); ResourceManager::RegisterType("FontFile"); From a53ab7f74574e2bdd018563ded7a62d2a7357314 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Wed, 10 Feb 2016 20:46:16 +0100 Subject: [PATCH 08/37] A few fixes for DashAbility. Default DoubleTapToDash is now set to false. --- .../Engine/Input/FirstPersonInputController.h | 25 +++++++++++-------- resources/DefaultInput.ini | 4 +-- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/include/Engine/Input/FirstPersonInputController.h b/include/Engine/Input/FirstPersonInputController.h index 2bbd768d..20402cd0 100644 --- a/include/Engine/Input/FirstPersonInputController.h +++ b/include/Engine/Input/FirstPersonInputController.h @@ -54,6 +54,7 @@ protected: //specialabilitys bool m_MovementKeyDown = false; bool m_SpecialAbilityKeyDown = false; + int m_NumberOfMovementKeysDown = 0; EventRelay m_ELockMouse; bool OnLockMouse(const Events::LockMouse& e); @@ -131,6 +132,7 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm } //if value = 0 then you have just released this key if (e.Value != 0) { + m_NumberOfMovementKeysDown++; m_MovementKeyDown = true; //if you pressed the same key within m_AssaultDashDoubleTapSensitivityTimer then you have doubletapped it if (m_AssaultDashDoubleTapDeltaTime < m_AssaultDashDoubleTapSensitivityTimer && m_AssaultDashTapDirection == m_CurrentDirectionVector) { @@ -138,10 +140,14 @@ bool FirstPersonInputController::OnCommand(const Events::InputComm } } else { //== 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; + m_NumberOfMovementKeysDown--; + 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; + } } @@ -201,12 +207,6 @@ void FirstPersonInputController::AssaultDashCheck(double dt, bool m_AssaultDashCoolDownTimer = assaultDashCoolDownMaxTimer; m_AssaultDashDoubleTapped = true; m_AssaultDashDoubleTapDeltaTime = 0.f; - //moving to the side has priority - return; - } - - //dashing with doubletap - check if doubletap to dash enabled - if (ResourceManager::Load("Input.ini")->Get("Keyboard.DoubleTapToDash", false)) { return; } @@ -215,6 +215,11 @@ void FirstPersonInputController::AssaultDashCheck(double dt, bool m_AssaultDashDoubleTapped = false; } + //dashing with doubletap - check if doubletap to dash enabled + if (!ResourceManager::Load("Input.ini")->Get("Keyboard.DoubleTapToDash", false)) { + return; + } + //check if we have received a valid doubletap if (!m_ValidDoubleTap) { return; diff --git a/resources/DefaultInput.ini b/resources/DefaultInput.ini index eb5b7658..35aceeb1 100644 --- a/resources/DefaultInput.ini +++ b/resources/DefaultInput.ini @@ -2,8 +2,8 @@ Sensitivity=0.5 InvertPitch=false -[KeyBoard] -DoubleTapToDash=true +[Keyboard] +DoubleTapToDash=false [Bindings] MouseLeft=PrimaryFire From f5de267f2552d3bc6ae8211fd2c77b6fe3862867 Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 10 Feb 2016 20:58:10 +0100 Subject: [PATCH 09/37] Merge fixes and CapturePointHUD component skeleton added. --- include/Engine/Rendering/RawModelCustom.h | 2 +- include/Engine/Rendering/RenderQueue.h | 5 +- include/Engine/Rendering/SpriteJob.h | 8 +- resources/Schema/Components.xsd | 1 + .../Schema/Components/CapturePointHUD.xml | 2 + .../Schema/Components/CapturePointHUD.xsd | 6 + .../Schema/Entities/QualityAssurance.xml | 104 ++++++++++-------- resources/Schema/Types/Entity.xsd | 1 + src/Engine/Rendering/DrawFinalPass.cpp | 2 +- src/Engine/Rendering/Model.cpp | 47 ++------ src/Engine/Rendering/RenderSystem.cpp | 2 +- src/Engine/Rendering/Renderer.cpp | 2 +- 12 files changed, 87 insertions(+), 95 deletions(-) create mode 100644 resources/Schema/Components/CapturePointHUD.xml create mode 100644 resources/Schema/Components/CapturePointHUD.xsd diff --git a/include/Engine/Rendering/RawModelCustom.h b/include/Engine/Rendering/RawModelCustom.h index cf21fb6d..ebf8da2b 100644 --- a/include/Engine/Rendering/RawModelCustom.h +++ b/include/Engine/Rendering/RawModelCustom.h @@ -50,7 +50,7 @@ public: struct TextureProperties { std::string TexturePath; glm::vec2 UVRepeat; - std::shared_ptr<::Texture> Texture; + Texture* Texture; }; struct MaterialBasic diff --git a/include/Engine/Rendering/RenderQueue.h b/include/Engine/Rendering/RenderQueue.h index 21802e05..647adab8 100644 --- a/include/Engine/Rendering/RenderQueue.h +++ b/include/Engine/Rendering/RenderQueue.h @@ -26,8 +26,7 @@ struct RenderScene std::list> OpaqueShieldedObjects; std::list> TransparentShieldedObjects; std::list> ShieldObjects; - std::list> SpriteJobs; - + std::list> SpriteJob; std::list> PointLight; std::list> Text; std::list> DirectionalLight; @@ -44,7 +43,7 @@ struct RenderScene Jobs.OpaqueShieldedObjects.clear(); Jobs.TransparentShieldedObjects.clear(); Jobs.ShieldObjects.clear(); - SpriteJobs.clear(); + Jobs.SpriteJob.clear(); Jobs.DirectionalLight.clear(); } }; diff --git a/include/Engine/Rendering/SpriteJob.h b/include/Engine/Rendering/SpriteJob.h index 23bf6360..2708ab0e 100644 --- a/include/Engine/Rendering/SpriteJob.h +++ b/include/Engine/Rendering/SpriteJob.h @@ -21,15 +21,15 @@ struct SpriteJob : RenderJob : RenderJob() { Model = ResourceManager::Load<::Model>("Models/Core/UnitQuad.mesh"); - ::RawModel::MaterialGroup matGroup = Model->MaterialGroups().front(); - TextureID = (matGroup.Texture) ? matGroup.Texture->ResourceID : 0; + ::RawModel::MaterialProperties matProp = Model->MaterialGroups().front(); + TextureID = 0; DiffuseTexture = CommonFunctions::LoadTexture(cSprite["DiffuseTexture"], true); IncandescenceTexture = CommonFunctions::LoadTexture(cSprite["GlowMap"], true); - StartIndex = matGroup.StartIndex; - EndIndex = matGroup.EndIndex; + StartIndex = matProp.material->StartIndex; + EndIndex = matProp.material->EndIndex; Matrix = matrix; Color = cSprite["Color"]; Entity = cSprite.EntityID; diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index 9487a7ad..bcc3fbdf 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -37,4 +37,5 @@ + \ No newline at end of file diff --git a/resources/Schema/Components/CapturePointHUD.xml b/resources/Schema/Components/CapturePointHUD.xml new file mode 100644 index 00000000..c024411c --- /dev/null +++ b/resources/Schema/Components/CapturePointHUD.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/resources/Schema/Components/CapturePointHUD.xsd b/resources/Schema/Components/CapturePointHUD.xsd new file mode 100644 index 00000000..dfdef822 --- /dev/null +++ b/resources/Schema/Components/CapturePointHUD.xsd @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/resources/Schema/Entities/QualityAssurance.xml b/resources/Schema/Entities/QualityAssurance.xml index 7a69ed32..c234f93a 100644 --- a/resources/Schema/Entities/QualityAssurance.xml +++ b/resources/Schema/Entities/QualityAssurance.xml @@ -40,7 +40,7 @@ - + @@ -120,11 +120,7 @@ - - Run - - 1 - + Models/Characters/Assault/AssaultAnimated.mesh @@ -136,11 +132,7 @@ - - Walk - - 1 - + Models/Characters/Assault/AssaultAnimated.mesh @@ -188,17 +180,13 @@ - + - - Run - - 1 - + Models/Characters/Assault/AssaultAnimated.mesh @@ -683,7 +671,7 @@ - + @@ -730,7 +718,7 @@ - + @@ -790,7 +778,7 @@ - + @@ -837,7 +825,7 @@ - + @@ -883,7 +871,7 @@ - + @@ -930,7 +918,7 @@ - + @@ -977,7 +965,7 @@ - + @@ -1390,7 +1378,7 @@ - + @@ -1399,7 +1387,7 @@ true - 0.75102457088592522 + 0.75134174339666815 3.7999999523162842 true @@ -1446,7 +1434,7 @@ - + @@ -1455,7 +1443,7 @@ - 1.2009303215000324 + 1.2012474940107754 Models/Characters/Assault/AssaultTPose.mesh @@ -1498,22 +1486,18 @@ - + - - Walk - - 1 - + true - 0.68437610515996361 + 0.68469327767070653 true @@ -1558,7 +1542,7 @@ - + @@ -1568,7 +1552,7 @@ true - 0.95047462600732735 + 0.95079179851807027 10 3 @@ -1616,7 +1600,7 @@ - + @@ -1626,7 +1610,7 @@ true - 1.350502887383392 + 1.3508200598941349 true 5 true @@ -1807,7 +1791,7 @@ true - 1.3671759474185377 + 1.3674931199292806 3.7999999523162842 true @@ -1850,11 +1834,7 @@ - - Hold Pos - - 1 - + Models/AssaultAnimated.mesh @@ -1916,7 +1896,8 @@ - Models/BushAlive.mesh + Models/Props/Flora/AliveBush.mesh + true @@ -1943,6 +1924,37 @@ + + + + + + + + + + + + Textures/Props/FoliageDiff.png + + + + + + + + + + Textures/Props/FoliageDiff.png + + + + + + + + + diff --git a/resources/Schema/Types/Entity.xsd b/resources/Schema/Types/Entity.xsd index 16366a67..8c9f6bcc 100644 --- a/resources/Schema/Types/Entity.xsd +++ b/resources/Schema/Types/Entity.xsd @@ -41,6 +41,7 @@ + diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 2e1e717e..e5e046dc 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -193,7 +193,7 @@ void DrawFinalPass::Draw(RenderScene& scene) GLERROR("OpaqueObjects"); DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene); GLERROR("TransparentObjects"); - DrawSprites(scene.SpriteJobs, scene); + DrawSprites(scene.Jobs.SpriteJob, scene); GLERROR("SpriteJobs"); //DrawStencilState* stencilState = new DrawStencilState(m_FinalPassFrameBuffer.GetHandle()); diff --git a/src/Engine/Rendering/Model.cpp b/src/Engine/Rendering/Model.cpp index 009e4abe..ce6eab8c 100644 --- a/src/Engine/Rendering/Model.cpp +++ b/src/Engine/Rendering/Model.cpp @@ -10,60 +10,31 @@ Model::Model(std::string fileName) case RawModel::MaterialType::SingleTextures: { RawModel::MaterialSingleTextures* materialSingleTexture = static_cast(materialProperty.material); - if (!materialSingleTexture->ColorMap.TexturePath.empty()) { - materialSingleTexture->ColorMap.Texture = std::shared_ptr(ResourceManager::LoadfixTexture>(materialSingleTexture->ColorMap.TexturePath)); - } - if (!materialSingleTexture->NormalMap.TexturePath.empty()) { - materialSingleTexture->NormalMap.Texture = std::shared_ptr(ResourceManager::LoadfixTexture>(materialSingleTexture->NormalMap.TexturePath)); - } - if (!materialSingleTexture->SpecularMap.TexturePath.empty()) { - materialSingleTexture->SpecularMap.Texture = std::shared_ptr(ResourceManager::LoadfixTexture>(materialSingleTexture->SpecularMap.TexturePath)); - } - if (!materialSingleTexture->IncandescenceMap.TexturePath.empty()) { - materialSingleTexture->IncandescenceMap.Texture = std::shared_ptr(ResourceManager::LoadfixTexture>(materialSingleTexture->IncandescenceMap.TexturePath)); - } + materialSingleTexture->ColorMap.Texture = CommonFunctions::LoadTexture(materialSingleTexture->ColorMap.TexturePath, false); + materialSingleTexture->NormalMap.Texture = CommonFunctions::LoadTexture(materialSingleTexture->NormalMap.TexturePath, false); + materialSingleTexture->SpecularMap.Texture = CommonFunctions::LoadTexture(materialSingleTexture->SpecularMap.TexturePath, false); + materialSingleTexture->IncandescenceMap.Texture = CommonFunctions::LoadTexture(materialSingleTexture->IncandescenceMap.TexturePath, false); } break; case RawModel::MaterialType::SplatMapping: { RawModel::MaterialSplatMapping* materialSplatMapping = static_cast(materialProperty.material); - if (!materialSplatMapping->SplatMap.TexturePath.empty()) { - materialSplatMapping->SplatMap.Texture = std::shared_ptr(ResourceManager::Load(materialSplatMapping->SplatMap.TexturePath)); - } + materialSplatMapping->SplatMap.Texture = CommonFunctions::LoadTexture(materialSplatMapping->SplatMap.TexturePath, false); for (auto& texture : materialSplatMapping->ColorMaps) { - if (!texture.TexturePath.empty()) { - texture.Texture = std::shared_ptr(ResourceManager::Load(texture.TexturePath)); - } - else { - texture.Texture = nullptr; - } + texture.Texture = CommonFunctions::LoadTexture(texture.TexturePath, false); } for (auto& texture : materialSplatMapping->NormalMaps) { - if (!texture.TexturePath.empty()) { - texture.Texture = std::shared_ptr(ResourceManager::Load(texture.TexturePath)); - } else { - texture.Texture = nullptr; - } + texture.Texture = CommonFunctions::LoadTexture(texture.TexturePath, false); } for (auto& texture : materialSplatMapping->SpecularMaps) { - if (!texture.TexturePath.empty()) { - texture.Texture = std::shared_ptr(ResourceManager::Load(texture.TexturePath)); - } - else { - texture.Texture = nullptr; - } + texture.Texture = CommonFunctions::LoadTexture(texture.TexturePath, false); } for (auto& texture : materialSplatMapping->IncandescenceMaps) { - if (!texture.TexturePath.empty()) { - texture.Texture = std::shared_ptr(ResourceManager::Load(texture.TexturePath)); - } - else { - texture.Texture = nullptr; - } + texture.Texture = CommonFunctions::LoadTexture(texture.TexturePath, false); } } break; diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index eb81818e..173afc95 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -346,7 +346,7 @@ void RenderSystem::Update(double dt) fillPointLights(scene.Jobs.PointLight, m_World); //TODO: Make sure all objects needed are also sorted. scene.Jobs.OpaqueObjects.sort(); - fillSprites(scene.SpriteJobs, m_World); + fillSprites(scene.Jobs.SpriteJob, m_World); fillDirectionalLights(scene.Jobs.DirectionalLight, m_World); fillText(scene.Jobs.Text, m_World); m_RenderFrame->Add(scene); diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index f02ca4d5..6f53eeda 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -167,7 +167,7 @@ void Renderer::SortRenderJobsByDepth(RenderScene &scene) { //Sort all forward jobs so transparency is good. scene.Jobs.TransparentObjects.sort(Renderer::DepthSort); - scene.SpriteJobs.sort(Renderer::DepthSort); + scene.Jobs.SpriteJob.sort(Renderer::DepthSort); } void Renderer::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) From 64a2354b24ee1e0304d00831e967ca12b4ad944c Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 10 Feb 2016 22:22:09 +0100 Subject: [PATCH 10/37] WIP with CapturePointHUDSystem --- include/Game/Systems/CapturePointHUDSystem.h | 55 ++++ resources/Schema/Components.xsd | 2 +- .../Schema/Components/CapturePointHUD.xml | 5 +- .../Schema/Components/CapturePointHUD.xsd | 18 ++ .../Entities/CapturePointHUDHexagon.xml | 34 +++ .../Schema/Entities/QualityAssurance.xml | 208 +++++++++++++-- src/Game/Systems/CapturePointHUDSystem.cpp | 243 ++++++++++++++++++ 7 files changed, 542 insertions(+), 23 deletions(-) create mode 100644 include/Game/Systems/CapturePointHUDSystem.h create mode 100644 resources/Schema/Entities/CapturePointHUDHexagon.xml create mode 100644 src/Game/Systems/CapturePointHUDSystem.cpp diff --git a/include/Game/Systems/CapturePointHUDSystem.h b/include/Game/Systems/CapturePointHUDSystem.h new file mode 100644 index 00000000..18c32c76 --- /dev/null +++ b/include/Game/Systems/CapturePointHUDSystem.h @@ -0,0 +1,55 @@ +#ifndef CapturePointSystem_h__ +#define CapturePointSystem_h__ + +#include +#include + +#include "Common.h" +#include "Core/System.h" +#include "Engine/Collision/ETrigger.h" +#include "Core/ECaptured.h" +#include "Core/EWin.h" + +#include +#include + +class CapturePointSystem : public PureSystem +{ +public: + //WARNING: on new map, destroy all info in the vectors, as well as reset all variables (just make new?) + CapturePointSystem(World* world, EventBroker* eventBroker); + + //updatecomponent + virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) override; + +private: + //methods which will take care of specific events + EventRelay m_ETriggerTouch; + bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e); + EventRelay m_ETriggerLeave; + bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e); + EventRelay m_ECaptured; + bool CapturePointSystem::OnCaptured(const Events::Captured& e); + + bool m_WinnerWasFound = false; + //need to track these variables for the captureSystem to work as per design! + const int m_NotACapturePoint = 999; + int m_RedTeamNextPossibleCapturePoint = m_NotACapturePoint; + int m_BlueTeamNextPossibleCapturePoint = m_NotACapturePoint; + int m_RedTeamHomeCapturePoint = m_NotACapturePoint; + int m_BlueTeamHomeCapturePoint = m_NotACapturePoint; + + int m_NumberOfCapturePoints = 0; + std::map m_CapturePointNumberToEntityMap; + + //std::vector + + const double m_CaptureTimeToTakeOver = 15.0; + bool m_ResetTimers = false; + + //vectors which will keep track of enter/leave changes + std::vector> m_ETriggerTouchVector; + std::vector> m_ETriggerLeaveVector; +}; + +#endif \ No newline at end of file diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index bcc3fbdf..bf452eba 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -37,5 +37,5 @@ - + \ No newline at end of file diff --git a/resources/Schema/Components/CapturePointHUD.xml b/resources/Schema/Components/CapturePointHUD.xml index c024411c..2943d57b 100644 --- a/resources/Schema/Components/CapturePointHUD.xml +++ b/resources/Schema/Components/CapturePointHUD.xml @@ -1,2 +1,5 @@ - \ No newline at end of file + + 0 + + \ No newline at end of file diff --git a/resources/Schema/Components/CapturePointHUD.xsd b/resources/Schema/Components/CapturePointHUD.xsd index dfdef822..7984fc50 100644 --- a/resources/Schema/Components/CapturePointHUD.xsd +++ b/resources/Schema/Components/CapturePointHUD.xsd @@ -1,6 +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 diff --git a/resources/Schema/Entities/CapturePointHUDHexagon.xml b/resources/Schema/Entities/CapturePointHUDHexagon.xml new file mode 100644 index 00000000..68cf42a7 --- /dev/null +++ b/resources/Schema/Entities/CapturePointHUDHexagon.xml @@ -0,0 +1,34 @@ + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + 0.5 + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + diff --git a/resources/Schema/Entities/QualityAssurance.xml b/resources/Schema/Entities/QualityAssurance.xml index c234f93a..ce6a650e 100644 --- a/resources/Schema/Entities/QualityAssurance.xml +++ b/resources/Schema/Entities/QualityAssurance.xml @@ -40,7 +40,7 @@ - + @@ -180,7 +180,7 @@ - + @@ -671,7 +671,7 @@ - + @@ -718,7 +718,7 @@ - + @@ -778,7 +778,7 @@ - + @@ -825,7 +825,7 @@ - + @@ -871,7 +871,7 @@ - + @@ -918,7 +918,7 @@ - + @@ -965,7 +965,7 @@ - + @@ -1378,7 +1378,7 @@ - + @@ -1387,7 +1387,7 @@ true - 0.75134174339666815 + 0.75158864645285173 3.7999999523162842 true @@ -1434,7 +1434,7 @@ - + @@ -1443,7 +1443,7 @@ - 1.2012474940107754 + 1.2014943970669589 Models/Characters/Assault/AssaultTPose.mesh @@ -1486,7 +1486,7 @@ - + @@ -1497,7 +1497,7 @@ true - 0.68469327767070653 + 0.68494018072689011 true @@ -1542,7 +1542,7 @@ - + @@ -1552,7 +1552,7 @@ true - 0.95079179851807027 + 0.95103870157425385 10 3 @@ -1600,7 +1600,7 @@ - + @@ -1610,7 +1610,7 @@ true - 1.3508200598941349 + 1.3510669629503185 true 5 true @@ -1791,7 +1791,7 @@ true - 1.3674931199292806 + 1.3677400229854642 3.7999999523162842 true @@ -1936,7 +1936,6 @@ Textures/Props/FoliageDiff.png - @@ -1955,6 +1954,173 @@ + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 2 + + + 0.5 + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 3 + + + 0.5 + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 4 + + + 0.5 + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 1 + + + 0.5 + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + 0.5 + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + diff --git a/src/Game/Systems/CapturePointHUDSystem.cpp b/src/Game/Systems/CapturePointHUDSystem.cpp new file mode 100644 index 00000000..a943e234 --- /dev/null +++ b/src/Game/Systems/CapturePointHUDSystem.cpp @@ -0,0 +1,243 @@ +#include "Systems/CapturePointSystem.h" +#include + +CapturePointSystem::CapturePointSystem(World* world, EventBroker* eventBroker) + : System(world, eventBroker) + , 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); +} + +//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 (m_WinnerWasFound) { + return; + } + const int capturePointNumber = cCapturePoint["CapturePointNumber"]; + const bool hasTeamComponent = capturePointEntity.HasComponent("Team"); + + //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) { + m_World->AttachComponent(cCapturePoint.EntityID, "Team"); + ComponentWrapper& teamComponent = capturePointEntity["Team"]; + teamComponent["Team"] = (int)teamComponent["Team"].Enum("Spectator"); + } + ComponentWrapper& teamComponent = capturePointEntity["Team"]; + const int redTeam = (int)teamComponent["Team"].Enum("Red"); + const int blueTeam = (int)teamComponent["Team"].Enum("Blue"); + const int spectatorTeam = (int)teamComponent["Team"].Enum("Spectator"); + + int homePointForTeam = (int)cCapturePoint["HomePointForTeam"]; + if (m_NumberOfCapturePoints == 0 && capturePointNumber != 0 && (homePointForTeam == redTeam || homePointForTeam == blueTeam)) { + m_NumberOfCapturePoints = capturePointNumber + 1;//ex 2 -> 0,1,2 = 3 + if (homePointForTeam == redTeam) { + m_RedTeamHomeCapturePoint = capturePointNumber; + m_BlueTeamHomeCapturePoint = 0; + } else { + m_BlueTeamHomeCapturePoint = capturePointNumber; + m_RedTeamHomeCapturePoint = 0; + } + } + + //if we havent received all capturepoints yet, just return + if (m_NumberOfCapturePoints == 0 || m_NumberOfCapturePoints != m_CapturePointNumberToEntityMap.size()) { + m_CapturePointNumberToEntityMap.insert(std::make_pair(capturePointNumber, capturePointEntity)); + return; + } + + //we have all capturepoints now - process stuff + int ownedBy = teamComponent["Team"]; + int redTeamPlayersStandingInside = 0; + int blueTeamPlayersStandingInside = 0; + 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.2f, 1, 0.3) : ownedBy == redTeam ? glm::vec4(1, 0.2f, 0, 0.3) : glm::vec4(1, 1, 1, 0.3); + } + + //calculate next possible capturePoint for both teams + std::map nextPossibleCapturePoint; + nextPossibleCapturePoint["Red"] = -1; + nextPossibleCapturePoint["Blue"] = -1; + for (int i = 0; i < m_NumberOfCapturePoints; i++) + { + if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) { + continue; + } + ComponentWrapper& capturePointOwnedBy = m_CapturePointNumberToEntityMap[i]["Team"]; + if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint == 0) { + nextPossibleCapturePoint["Red"] = i + 1; + } + if ((int)capturePointOwnedBy["Team"] == blueTeam && m_BlueTeamHomeCapturePoint == 0) { + nextPossibleCapturePoint["Blue"] = i + 1; + } + } + for (int i = m_NumberOfCapturePoints - 1; i >= 0; i--) + { + if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) { + continue; + } + ComponentWrapper& capturePointOwnedBy = m_CapturePointNumberToEntityMap[i]["Team"]; + if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint != 0) { + nextPossibleCapturePoint["Red"] = i - 1; + } + if ((int)capturePointOwnedBy["Team"] == blueTeam && m_BlueTeamHomeCapturePoint != 0) { + nextPossibleCapturePoint["Blue"] = i - 1; + } + } + + //reset timers and reset the bool that triggers this + if (m_ResetTimers) { + 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"]) { + capturePoint["CaptureTimer"] = 0.0; + } + } + m_ResetTimers = false; + } + + //colorize next possible capturepoint + if (nextPossibleCapturePoint["Red"] == capturePointNumber) { + capturePointEntity["Model"]["Color"] = glm::vec4(1, 1, 0, 0.3); + } + if (nextPossibleCapturePoint["Blue"] == capturePointNumber) { + capturePointEntity["Model"]["Color"] = glm::vec4(0, 1, 1, 0.3); + } + + //check how many players are standing inside and are healthy + 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 + EntityWrapper player = std::get<0>(triggerTouched); + //check if its really a player that has triggered the touch + if (!player.HasComponent("Player")) { + //if a non-player has entered the capturePoint, just erase that event and continue + m_ETriggerTouchVector.erase(m_ETriggerTouchVector.begin() + i - 1); + continue; + } + bool hasHealthComponent = player.HasComponent("Health"); + if (hasHealthComponent) { + double currentHealth = player["Health"]["Health"]; + //check if player is dead + if ((int)currentHealth == 0) { + continue; + } + } + //check team - spectatorNumber = "no team" + int teamNumber = player["Team"]["Team"]; + if (teamNumber == redTeam) { + redTeamPlayersStandingInside++; + } else if (teamNumber == blueTeam) { + blueTeamPlayersStandingInside++; + } + continue; + } + } + + //create data to be used in option B + //check so this is the next possible capture point for the take-over team and see if only one team is standing inside it + double timerDeltaChange = 0.0; + int currentTeam = 0; + bool canCapture = false; + if (redTeamPlayersStandingInside > 0 && blueTeamPlayersStandingInside == 0) { + timerDeltaChange = redTeamPlayersStandingInside*dt; + currentTeam = redTeam; + canCapture = nextPossibleCapturePoint["Red"] == capturePointNumber; + } + if (redTeamPlayersStandingInside == 0 && blueTeamPlayersStandingInside > 0) { + timerDeltaChange = -blueTeamPlayersStandingInside*dt; + currentTeam = blueTeam; + canCapture = nextPossibleCapturePoint["Blue"] == capturePointNumber; + } + + if (redTeamPlayersStandingInside == 0 && blueTeamPlayersStandingInside == 0) { + //A.nobodys standing inside + //do nothing (?) + } else if (redTeamPlayersStandingInside > 0 && blueTeamPlayersStandingInside > 0) { + //C.both teams have players inside + //do nothing (?) + } else { + //B. at most one of the teams have players inside + //if capturePoint is not owned by the take-over team, just modify the CaptureTimer accordingly + if (ownedBy != currentTeam && canCapture) { + if (abs((double)cCapturePoint["CaptureTimer"]) < 0.001f) { + LOG_DEBUG("Point is being captured by team %i", currentTeam); //Remove when we tested sufficiently. + } + 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)) { + cCapturePoint["CaptureTimer"] = (double)cCapturePoint["CaptureTimer"] + timerDeltaChange; + } + //check if captureTimer > m_CaptureTimeToTakeOver and if so change owner and publish the eCaptured event + if (abs((double)cCapturePoint["CaptureTimer"]) > abs(m_CaptureTimeToTakeOver) && canCapture) { + teamComponent["Team"] = currentTeam; + cCapturePoint["CaptureTimer"] = 0.0; + //publish Captured event + LOG_DEBUG("Point is captured by team %i!", currentTeam); //Remove when we tested sufficiently. + Events::Captured e; + e.CapturePointID = cCapturePoint.EntityID; + e.TeamNumberThatCapturedCapturePoint = currentTeam; + m_EventBroker->Publish(e); + //NextPossibleCapturePoint will be calculated in the next update... + } + } + + //check for possible winCondition = check if the homebase is owned by the other team + bool checkForWinner = false; + if (capturePointNumber == m_RedTeamHomeCapturePoint && ownedBy != redTeam) + { + checkForWinner = true; + } + if (capturePointNumber == m_BlueTeamHomeCapturePoint && ownedBy != blueTeam) + { + checkForWinner = true; + } + + if (checkForWinner && !m_WinnerWasFound) + { + //publish Win event + Events::Win e; + e.TeamThatWon = ownedBy; + m_EventBroker->Publish(e); + m_WinnerWasFound = true; + } + +} + +bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e) +{ + //personEntered = e.Entity, thingEntered = e.Trigger + m_ETriggerTouchVector.push_back(std::make_tuple(e.Entity, e.Trigger)); + return true; +} + +bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e) +{ + 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); + break; + } + } + return true; +} +bool CapturePointSystem::OnCaptured(const Events::Captured& e) +{ + //reset the timers in the next update since a capture has changed the "nextCapturePoint" for 1-2 teams + m_ResetTimers = true; + return true; +} From 447f41dbff935c9521a2e74c594d85b1490b6cd9 Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 10 Feb 2016 23:59:13 +0100 Subject: [PATCH 11/37] HUD for capture points now update with Capture point data. --- include/Game/Systems/CapturePointHUDSystem.h | 52 +- resources/Shaders/Sprite.frag.glsl | 5 +- src/Game/Game.cpp | 2 + src/Game/Systems/CapturePointHUDSystem.cpp | 482 ++++++++++--------- 4 files changed, 287 insertions(+), 254 deletions(-) diff --git a/include/Game/Systems/CapturePointHUDSystem.h b/include/Game/Systems/CapturePointHUDSystem.h index 18c32c76..102c52ce 100644 --- a/include/Game/Systems/CapturePointHUDSystem.h +++ b/include/Game/Systems/CapturePointHUDSystem.h @@ -1,55 +1,49 @@ -#ifndef CapturePointSystem_h__ -#define CapturePointSystem_h__ +#ifndef CapturePointHUDSystem_h__ +#define CapturePointHUDSystem_h__ #include #include +#include #include "Common.h" #include "Core/System.h" #include "Engine/Collision/ETrigger.h" -#include "Core/ECaptured.h" -#include "Core/EWin.h" -#include -#include - -class CapturePointSystem : public PureSystem +class CapturePointHUDSystem : public ImpureSystem { public: - //WARNING: on new map, destroy all info in the vectors, as well as reset all variables (just make new?) - CapturePointSystem(World* world, EventBroker* eventBroker); + CapturePointHUDSystem(World* world, EventBroker* eventBroker); - //updatecomponent - virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) override; + virtual void Update(double dt) override; private: //methods which will take care of specific events - EventRelay m_ETriggerTouch; + /* EventRelay m_ETriggerTouch; bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e); EventRelay m_ETriggerLeave; bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e); EventRelay m_ECaptured; - bool CapturePointSystem::OnCaptured(const Events::Captured& e); + bool CapturePointSystem::OnCaptured(const Events::Captured& e);*/ - bool m_WinnerWasFound = false; - //need to track these variables for the captureSystem to work as per design! - const int m_NotACapturePoint = 999; - int m_RedTeamNextPossibleCapturePoint = m_NotACapturePoint; - int m_BlueTeamNextPossibleCapturePoint = m_NotACapturePoint; - int m_RedTeamHomeCapturePoint = m_NotACapturePoint; - int m_BlueTeamHomeCapturePoint = m_NotACapturePoint; + //bool m_WinnerWasFound = false; + ////need to track these variables for the captureSystem to work as per design! + //const int m_NotACapturePoint = 999; + //int m_RedTeamNextPossibleCapturePoint = m_NotACapturePoint; + //int m_BlueTeamNextPossibleCapturePoint = m_NotACapturePoint; + //int m_RedTeamHomeCapturePoint = m_NotACapturePoint; + //int m_BlueTeamHomeCapturePoint = m_NotACapturePoint; - int m_NumberOfCapturePoints = 0; - std::map m_CapturePointNumberToEntityMap; + //int m_NumberOfCapturePoints = 0; + //std::map m_CapturePointNumberToEntityMap; - //std::vector + ////std::vector - const double m_CaptureTimeToTakeOver = 15.0; - bool m_ResetTimers = false; + //const double m_CaptureTimeToTakeOver = 15.0; + //bool m_ResetTimers = false; - //vectors which will keep track of enter/leave changes - std::vector> m_ETriggerTouchVector; - std::vector> m_ETriggerLeaveVector; + ////vectors which will keep track of enter/leave changes + //std::vector> m_ETriggerTouchVector; + //std::vector> m_ETriggerLeaveVector; }; #endif \ No newline at end of file diff --git a/resources/Shaders/Sprite.frag.glsl b/resources/Shaders/Sprite.frag.glsl index c391322d..a1ff3025 100644 --- a/resources/Shaders/Sprite.frag.glsl +++ b/resources/Shaders/Sprite.frag.glsl @@ -30,12 +30,11 @@ void main() float pos = ((P * vec4(Input.Position, 1)).y + 1.0)/2.0; if(pos <= FillPercentage) { - color_result += FillColor; + color_result = FillColor*diffuseTexel.a; } 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); + bloomColor = vec4(clamp((glowTexel.xyz*3) - 1.0, 0, 100), 1.0); } diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 002efe26..b13cbda2 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -12,6 +12,7 @@ #include "Systems/PlayerDeathSystem.h" #include "Core/EntityFileWriter.h" #include "Game/Systems/CapturePointSystem.h" +#include "Game/Systems/CapturePointHUDSystem.h" #include "Game/Systems/PickupSpawnSystem.h" #include "Game/Systems/WeaponSystem.h" #include "Rendering/AnimationSystem.h" @@ -103,6 +104,7 @@ Game::Game(int argc, char* argv[]) m_SystemPipeline->AddSystem(updateOrderLevel, m_Renderer); m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); + m_SystemPipeline->AddSystem(updateOrderLevel); m_SystemPipeline->AddSystem(updateOrderLevel); // Populate Octree with collidables ++updateOrderLevel; diff --git a/src/Game/Systems/CapturePointHUDSystem.cpp b/src/Game/Systems/CapturePointHUDSystem.cpp index a943e234..5c4c2b60 100644 --- a/src/Game/Systems/CapturePointHUDSystem.cpp +++ b/src/Game/Systems/CapturePointHUDSystem.cpp @@ -1,243 +1,281 @@ -#include "Systems/CapturePointSystem.h" -#include +#include "Systems/CapturePointHUDSystem.h" -CapturePointSystem::CapturePointSystem(World* world, EventBroker* eventBroker) +CapturePointHUDSystem::CapturePointHUDSystem(World* world, EventBroker* eventBroker) : System(world, eventBroker) - , PureSystem("CapturePoint") + , ImpureSystem() { //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); + //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) + +void CapturePointHUDSystem::Update(double dt) { - if (m_WinnerWasFound) { - return; - } - const int capturePointNumber = cCapturePoint["CapturePointNumber"]; - const bool hasTeamComponent = capturePointEntity.HasComponent("Team"); + bool LoadCheck = false; + int redTeam; + int blueTeam; + int spectatorTeam; - //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) { - m_World->AttachComponent(cCapturePoint.EntityID, "Team"); - ComponentWrapper& teamComponent = capturePointEntity["Team"]; - teamComponent["Team"] = (int)teamComponent["Team"].Enum("Spectator"); - } - ComponentWrapper& teamComponent = capturePointEntity["Team"]; - const int redTeam = (int)teamComponent["Team"].Enum("Red"); - const int blueTeam = (int)teamComponent["Team"].Enum("Blue"); - const int spectatorTeam = (int)teamComponent["Team"].Enum("Spectator"); + auto CapturePointHUDElements = m_World->GetComponents("CapturePointHUD"); + auto CapturePoints = m_World->GetComponents("CapturePoint"); - int homePointForTeam = (int)cCapturePoint["HomePointForTeam"]; - if (m_NumberOfCapturePoints == 0 && capturePointNumber != 0 && (homePointForTeam == redTeam || homePointForTeam == blueTeam)) { - m_NumberOfCapturePoints = capturePointNumber + 1;//ex 2 -> 0,1,2 = 3 - if (homePointForTeam == redTeam) { - m_RedTeamHomeCapturePoint = capturePointNumber; - m_BlueTeamHomeCapturePoint = 0; - } else { - m_BlueTeamHomeCapturePoint = capturePointNumber; - m_RedTeamHomeCapturePoint = 0; - } - } + for(auto& cCapturePointHUD : *CapturePointHUDElements) { + int HUD_ID = cCapturePointHUD["CapturePointNumber"]; + EntityWrapper entityHUD = EntityWrapper(m_World, cCapturePointHUD.EntityID); + EntityWrapper entityHUDparent = entityHUD.Parent(); - //if we havent received all capturepoints yet, just return - if (m_NumberOfCapturePoints == 0 || m_NumberOfCapturePoints != m_CapturePointNumberToEntityMap.size()) { - m_CapturePointNumberToEntityMap.insert(std::make_pair(capturePointNumber, capturePointEntity)); - return; - } + for(auto& cCapturePoint : *CapturePoints) { + EntityWrapper entityCP = EntityWrapper(m_World, cCapturePoint.EntityID); - //we have all capturepoints now - process stuff - int ownedBy = teamComponent["Team"]; - int redTeamPlayersStandingInside = 0; - int blueTeamPlayersStandingInside = 0; - 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.2f, 1, 0.3) : ownedBy == redTeam ? glm::vec4(1, 0.2f, 0, 0.3) : glm::vec4(1, 1, 1, 0.3); - } - - //calculate next possible capturePoint for both teams - std::map nextPossibleCapturePoint; - nextPossibleCapturePoint["Red"] = -1; - nextPossibleCapturePoint["Blue"] = -1; - for (int i = 0; i < m_NumberOfCapturePoints; i++) - { - if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) { - continue; - } - ComponentWrapper& capturePointOwnedBy = m_CapturePointNumberToEntityMap[i]["Team"]; - if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint == 0) { - nextPossibleCapturePoint["Red"] = i + 1; - } - if ((int)capturePointOwnedBy["Team"] == blueTeam && m_BlueTeamHomeCapturePoint == 0) { - nextPossibleCapturePoint["Blue"] = i + 1; - } - } - for (int i = m_NumberOfCapturePoints - 1; i >= 0; i--) - { - if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) { - continue; - } - ComponentWrapper& capturePointOwnedBy = m_CapturePointNumberToEntityMap[i]["Team"]; - if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint != 0) { - nextPossibleCapturePoint["Red"] = i - 1; - } - if ((int)capturePointOwnedBy["Team"] == blueTeam && m_BlueTeamHomeCapturePoint != 0) { - nextPossibleCapturePoint["Blue"] = i - 1; - } - } - - //reset timers and reset the bool that triggers this - if (m_ResetTimers) { - 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"]) { - capturePoint["CaptureTimer"] = 0.0; - } - } - m_ResetTimers = false; - } - - //colorize next possible capturepoint - if (nextPossibleCapturePoint["Red"] == capturePointNumber) { - capturePointEntity["Model"]["Color"] = glm::vec4(1, 1, 0, 0.3); - } - if (nextPossibleCapturePoint["Blue"] == capturePointNumber) { - capturePointEntity["Model"]["Color"] = glm::vec4(0, 1, 1, 0.3); - } - - //check how many players are standing inside and are healthy - 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 - EntityWrapper player = std::get<0>(triggerTouched); - //check if its really a player that has triggered the touch - if (!player.HasComponent("Player")) { - //if a non-player has entered the capturePoint, just erase that event and continue - m_ETriggerTouchVector.erase(m_ETriggerTouchVector.begin() + i - 1); - continue; - } - bool hasHealthComponent = player.HasComponent("Health"); - if (hasHealthComponent) { - double currentHealth = player["Health"]["Health"]; - //check if player is dead - if ((int)currentHealth == 0) { - continue; + //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"); } + //Color hud with team color + auto capturePointTeam = (int)teamComponent["Team"]; + entityHUDparent["Sprite"]["Color"] = capturePointTeam == blueTeam ? glm::vec4(0, 0.2f, 1, 0.7) : capturePointTeam == redTeam ? glm::vec4(1, 0.2f, 0, 0.7) : glm::vec4(1, 1, 1, 0.3); + + //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.2f, 0, 0.7) : glm::vec4(0, 0.2f, 1, 0.7); + entityHUD["Fill"]["Color"] = fillColor; + entityHUD["Fill"]["Percentage"] = progress; } - //check team - spectatorNumber = "no team" - int teamNumber = player["Team"]["Team"]; - if (teamNumber == redTeam) { - redTeamPlayersStandingInside++; - } else if (teamNumber == blueTeam) { - blueTeamPlayersStandingInside++; - } - continue; } } - //create data to be used in option B - //check so this is the next possible capture point for the take-over team and see if only one team is standing inside it - double timerDeltaChange = 0.0; - int currentTeam = 0; - bool canCapture = false; - if (redTeamPlayersStandingInside > 0 && blueTeamPlayersStandingInside == 0) { - timerDeltaChange = redTeamPlayersStandingInside*dt; - currentTeam = redTeam; - canCapture = nextPossibleCapturePoint["Red"] == capturePointNumber; - } - if (redTeamPlayersStandingInside == 0 && blueTeamPlayersStandingInside > 0) { - timerDeltaChange = -blueTeamPlayersStandingInside*dt; - currentTeam = blueTeam; - canCapture = nextPossibleCapturePoint["Blue"] == capturePointNumber; - } + //if (m_WinnerWasFound) { + // return; + //} + //const int capturePointNumber = cCapturePoint["CapturePointNumber"]; + //const bool hasTeamComponent = capturePointEntity.HasComponent("Team"); - if (redTeamPlayersStandingInside == 0 && blueTeamPlayersStandingInside == 0) { - //A.nobodys standing inside - //do nothing (?) - } else if (redTeamPlayersStandingInside > 0 && blueTeamPlayersStandingInside > 0) { - //C.both teams have players inside - //do nothing (?) - } else { - //B. at most one of the teams have players inside - //if capturePoint is not owned by the take-over team, just modify the CaptureTimer accordingly - if (ownedBy != currentTeam && canCapture) { - if (abs((double)cCapturePoint["CaptureTimer"]) < 0.001f) { - LOG_DEBUG("Point is being captured by team %i", currentTeam); //Remove when we tested sufficiently. - } - 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)) { - cCapturePoint["CaptureTimer"] = (double)cCapturePoint["CaptureTimer"] + timerDeltaChange; - } - //check if captureTimer > m_CaptureTimeToTakeOver and if so change owner and publish the eCaptured event - if (abs((double)cCapturePoint["CaptureTimer"]) > abs(m_CaptureTimeToTakeOver) && canCapture) { - teamComponent["Team"] = currentTeam; - cCapturePoint["CaptureTimer"] = 0.0; - //publish Captured event - LOG_DEBUG("Point is captured by team %i!", currentTeam); //Remove when we tested sufficiently. - Events::Captured e; - e.CapturePointID = cCapturePoint.EntityID; - e.TeamNumberThatCapturedCapturePoint = currentTeam; - m_EventBroker->Publish(e); - //NextPossibleCapturePoint will be calculated in the next update... - } - } + ////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) { + // m_World->AttachComponent(cCapturePoint.EntityID, "Team"); + // ComponentWrapper& teamComponent = capturePointEntity["Team"]; + // teamComponent["Team"] = (int)teamComponent["Team"].Enum("Spectator"); + //} + //ComponentWrapper& teamComponent = capturePointEntity["Team"]; + //const int redTeam = (int)teamComponent["Team"].Enum("Red"); + //const int blueTeam = (int)teamComponent["Team"].Enum("Blue"); + //const int spectatorTeam = (int)teamComponent["Team"].Enum("Spectator"); - //check for possible winCondition = check if the homebase is owned by the other team - bool checkForWinner = false; - if (capturePointNumber == m_RedTeamHomeCapturePoint && ownedBy != redTeam) - { - checkForWinner = true; - } - if (capturePointNumber == m_BlueTeamHomeCapturePoint && ownedBy != blueTeam) - { - checkForWinner = true; - } + //int homePointForTeam = (int)cCapturePoint["HomePointForTeam"]; + //if (m_NumberOfCapturePoints == 0 && capturePointNumber != 0 && (homePointForTeam == redTeam || homePointForTeam == blueTeam)) { + // m_NumberOfCapturePoints = capturePointNumber + 1;//ex 2 -> 0,1,2 = 3 + // if (homePointForTeam == redTeam) { + // m_RedTeamHomeCapturePoint = capturePointNumber; + // m_BlueTeamHomeCapturePoint = 0; + // } else { + // m_BlueTeamHomeCapturePoint = capturePointNumber; + // m_RedTeamHomeCapturePoint = 0; + // } + //} - if (checkForWinner && !m_WinnerWasFound) - { - //publish Win event - Events::Win e; - e.TeamThatWon = ownedBy; - m_EventBroker->Publish(e); - m_WinnerWasFound = true; - } + ////if we havent received all capturepoints yet, just return + //if (m_NumberOfCapturePoints == 0 || m_NumberOfCapturePoints != m_CapturePointNumberToEntityMap.size()) { + // m_CapturePointNumberToEntityMap.insert(std::make_pair(capturePointNumber, capturePointEntity)); + // return; + //} + + ////we have all capturepoints now - process stuff + //int ownedBy = teamComponent["Team"]; + //int redTeamPlayersStandingInside = 0; + //int blueTeamPlayersStandingInside = 0; + //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.2f, 1, 0.3) : ownedBy == redTeam ? glm::vec4(1, 0.2f, 0, 0.3) : glm::vec4(1, 1, 1, 0.3); + //} + + ////calculate next possible capturePoint for both teams + //std::map nextPossibleCapturePoint; + //nextPossibleCapturePoint["Red"] = -1; + //nextPossibleCapturePoint["Blue"] = -1; + //for (int i = 0; i < m_NumberOfCapturePoints; i++) + //{ + // if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) { + // continue; + // } + // ComponentWrapper& capturePointOwnedBy = m_CapturePointNumberToEntityMap[i]["Team"]; + // if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint == 0) { + // nextPossibleCapturePoint["Red"] = i + 1; + // } + // if ((int)capturePointOwnedBy["Team"] == blueTeam && m_BlueTeamHomeCapturePoint == 0) { + // nextPossibleCapturePoint["Blue"] = i + 1; + // } + //} + //for (int i = m_NumberOfCapturePoints - 1; i >= 0; i--) + //{ + // if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) { + // continue; + // } + // ComponentWrapper& capturePointOwnedBy = m_CapturePointNumberToEntityMap[i]["Team"]; + // if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint != 0) { + // nextPossibleCapturePoint["Red"] = i - 1; + // } + // if ((int)capturePointOwnedBy["Team"] == blueTeam && m_BlueTeamHomeCapturePoint != 0) { + // nextPossibleCapturePoint["Blue"] = i - 1; + // } + //} + + ////reset timers and reset the bool that triggers this + //if (m_ResetTimers) { + // 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"]) { + // capturePoint["CaptureTimer"] = 0.0; + // } + // } + // m_ResetTimers = false; + //} + + ////colorize next possible capturepoint + //if (nextPossibleCapturePoint["Red"] == capturePointNumber) { + // capturePointEntity["Model"]["Color"] = glm::vec4(1, 1, 0, 0.3); + //} + //if (nextPossibleCapturePoint["Blue"] == capturePointNumber) { + // capturePointEntity["Model"]["Color"] = glm::vec4(0, 1, 1, 0.3); + //} + + ////check how many players are standing inside and are healthy + //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 + // EntityWrapper player = std::get<0>(triggerTouched); + // //check if its really a player that has triggered the touch + // if (!player.HasComponent("Player")) { + // //if a non-player has entered the capturePoint, just erase that event and continue + // m_ETriggerTouchVector.erase(m_ETriggerTouchVector.begin() + i - 1); + // continue; + // } + // bool hasHealthComponent = player.HasComponent("Health"); + // if (hasHealthComponent) { + // double currentHealth = player["Health"]["Health"]; + // //check if player is dead + // if ((int)currentHealth == 0) { + // continue; + // } + // } + // //check team - spectatorNumber = "no team" + // int teamNumber = player["Team"]["Team"]; + // if (teamNumber == redTeam) { + // redTeamPlayersStandingInside++; + // } else if (teamNumber == blueTeam) { + // blueTeamPlayersStandingInside++; + // } + // continue; + // } + //} + + ////create data to be used in option B + ////check so this is the next possible capture point for the take-over team and see if only one team is standing inside it + //double timerDeltaChange = 0.0; + //int currentTeam = 0; + //bool canCapture = false; + //if (redTeamPlayersStandingInside > 0 && blueTeamPlayersStandingInside == 0) { + // timerDeltaChange = redTeamPlayersStandingInside*dt; + // currentTeam = redTeam; + // canCapture = nextPossibleCapturePoint["Red"] == capturePointNumber; + //} + //if (redTeamPlayersStandingInside == 0 && blueTeamPlayersStandingInside > 0) { + // timerDeltaChange = -blueTeamPlayersStandingInside*dt; + // currentTeam = blueTeam; + // canCapture = nextPossibleCapturePoint["Blue"] == capturePointNumber; + //} + + //if (redTeamPlayersStandingInside == 0 && blueTeamPlayersStandingInside == 0) { + // //A.nobodys standing inside + // //do nothing (?) + //} else if (redTeamPlayersStandingInside > 0 && blueTeamPlayersStandingInside > 0) { + // //C.both teams have players inside + // //do nothing (?) + //} else { + // //B. at most one of the teams have players inside + // //if capturePoint is not owned by the take-over team, just modify the CaptureTimer accordingly + // if (ownedBy != currentTeam && canCapture) { + // if (abs((double)cCapturePoint["CaptureTimer"]) < 0.001f) { + // LOG_DEBUG("Point is being captured by team %i", currentTeam); //Remove when we tested sufficiently. + // } + // 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)) { + // cCapturePoint["CaptureTimer"] = (double)cCapturePoint["CaptureTimer"] + timerDeltaChange; + // } + // //check if captureTimer > m_CaptureTimeToTakeOver and if so change owner and publish the eCaptured event + // if (abs((double)cCapturePoint["CaptureTimer"]) > abs(m_CaptureTimeToTakeOver) && canCapture) { + // teamComponent["Team"] = currentTeam; + // cCapturePoint["CaptureTimer"] = 0.0; + // //publish Captured event + // LOG_DEBUG("Point is captured by team %i!", currentTeam); //Remove when we tested sufficiently. + // Events::Captured e; + // e.CapturePointID = cCapturePoint.EntityID; + // e.TeamNumberThatCapturedCapturePoint = currentTeam; + // m_EventBroker->Publish(e); + // //NextPossibleCapturePoint will be calculated in the next update... + // } + //} + + ////check for possible winCondition = check if the homebase is owned by the other team + //bool checkForWinner = false; + //if (capturePointNumber == m_RedTeamHomeCapturePoint && ownedBy != redTeam) + //{ + // checkForWinner = true; + //} + //if (capturePointNumber == m_BlueTeamHomeCapturePoint && ownedBy != blueTeam) + //{ + // checkForWinner = true; + //} + + //if (checkForWinner && !m_WinnerWasFound) + //{ + // //publish Win event + // Events::Win e; + // e.TeamThatWon = ownedBy; + // m_EventBroker->Publish(e); + // m_WinnerWasFound = true; + //} } - -bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e) -{ - //personEntered = e.Entity, thingEntered = e.Trigger - m_ETriggerTouchVector.push_back(std::make_tuple(e.Entity, e.Trigger)); - return true; -} - -bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e) -{ - 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); - break; - } - } - return true; -} -bool CapturePointSystem::OnCaptured(const Events::Captured& e) -{ - //reset the timers in the next update since a capture has changed the "nextCapturePoint" for 1-2 teams - m_ResetTimers = true; - return true; -} +// +//bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e) +//{ +// //personEntered = e.Entity, thingEntered = e.Trigger +// m_ETriggerTouchVector.push_back(std::make_tuple(e.Entity, e.Trigger)); +// return true; +//} +// +//bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e) +//{ +// 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); +// break; +// } +// } +// return true; +//} +//bool CapturePointSystem::OnCaptured(const Events::Captured& e) +//{ +// //reset the timers in the next update since a capture has changed the "nextCapturePoint" for 1-2 teams +// m_ResetTimers = true; +// return true; +//} From 4b8f4981a36f819512c1faf535bd29f5d6dd2c4f Mon Sep 17 00:00:00 2001 From: antc13 Date: Thu, 11 Feb 2016 00:05:27 +0100 Subject: [PATCH 12/37] New Map with Meshes, WIP. --- assets | 2 +- resources/Schema/Entities/NewMap.xml | 1287 +++++++- resources/Schema/Entities/NewMapBackup.xml | 3222 ++++++++++++++++++++ resources/Schema/Entities/StoneWall.xml | 147 + 4 files changed, 4591 insertions(+), 67 deletions(-) create mode 100644 resources/Schema/Entities/NewMapBackup.xml create mode 100644 resources/Schema/Entities/StoneWall.xml diff --git a/assets b/assets index e0ad8b8d..c56f6380 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit e0ad8b8d45a79b8f17876f9541cc5e03758ae16c +Subproject commit c56f6380ab05c23419beafe14190013d1432e32c diff --git a/resources/Schema/Entities/NewMap.xml b/resources/Schema/Entities/NewMap.xml index a79fee7b..8a5227aa 100644 --- a/resources/Schema/Entities/NewMap.xml +++ b/resources/Schema/Entities/NewMap.xml @@ -134,7 +134,7 @@ - + @@ -199,7 +199,7 @@ Models/Props/Pillars/SciFiPillar1.mesh - + @@ -213,7 +213,7 @@ Models/Props/Pillars/SciFiPillar1.mesh - + @@ -292,7 +292,7 @@ Models/Props/Pillars/SciFiPillar2.mesh - + @@ -338,7 +338,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -363,7 +363,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -388,7 +388,8 @@ Models/Props/Walls/BigWall.mesh - + + @@ -413,7 +414,8 @@ Models/Props/Walls/BigWall.mesh - + + @@ -438,7 +440,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -713,8 +715,8 @@ Models/Props/Walls/MediumWall3.mesh - - + + @@ -725,7 +727,7 @@ Models/Props/Walls/MediumWall3.mesh - + @@ -737,7 +739,7 @@ Models/Props/Walls/MediumWall3.mesh - + @@ -801,7 +803,8 @@ Models/Props/Walls/BigWall.mesh - + + @@ -813,7 +816,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -966,7 +969,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -1136,6 +1139,247 @@ + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + Models/Props/Walls/BigWall.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 + + + + + + + + @@ -1150,8 +1394,8 @@ Models/Props/Bridges/WoodenBridge.mesh - - + + @@ -1178,8 +1422,8 @@ Models/Props/Bridges/WoodenBridge.mesh - - + + @@ -1205,12 +1449,118 @@ Models/Props/Bridges/SciFiBridge.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 + + + + + + + + + + + + + + @@ -1254,7 +1604,7 @@ Models/Props/Pillars/SciFiBridgePillar1.mesh - + @@ -1506,7 +1856,7 @@ true - + @@ -1517,7 +1867,7 @@ true - + @@ -1529,7 +1879,7 @@ true - + @@ -1541,7 +1891,7 @@ true - + @@ -1553,7 +1903,7 @@ true - + @@ -1565,7 +1915,7 @@ true - + @@ -1612,6 +1962,227 @@ + + + + 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 + + + + + + + + + @@ -1679,7 +2250,8 @@ Models/Props/Stones/MediumStone1.mesh - + + @@ -1717,8 +2289,8 @@ Models/Props/Stones/MediumStone1.mesh - - + + @@ -1730,8 +2302,8 @@ Models/Props/Stones/MediumStone1.mesh - - + + @@ -1756,7 +2328,7 @@ Models/Props/Stones/MediumStone1.mesh - + @@ -1768,21 +2340,8 @@ Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - + + @@ -1794,7 +2353,7 @@ Models/Props/Stones/MediumStone1.mesh - + @@ -1819,7 +2378,7 @@ Models/Props/Stones/MediumStone1.mesh - + @@ -2093,6 +2652,226 @@ + + + + + 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/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystal.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystal.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystal.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + @@ -2107,7 +2886,7 @@ Models/Props/PickUps/PickUpHolder.mesh - + @@ -2184,6 +2963,168 @@ + + + + + + + + + + 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 + + + + + + + + + + @@ -2193,9 +3134,6 @@ - - - @@ -2203,7 +3141,8 @@ Models/Props/CapturePoint.mesh - + + true @@ -2219,13 +3158,13 @@ - 1 Models/Props/CapturePoint.mesh - + + true @@ -2237,12 +3176,13 @@ - 2 Models/Props/CapturePoint.mesh + + true @@ -2254,13 +3194,13 @@ - 3 Models/Props/CapturePoint.mesh - + + true @@ -2272,7 +3212,6 @@ - @@ -2281,7 +3220,8 @@ Models/Props/CapturePoint.mesh - + + true @@ -2373,7 +3313,7 @@ 1 - + @@ -2386,11 +3326,226 @@ Models/Characters/Assault/AssaultTPose.mesh - + + + + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/NewMapBackup.xml b/resources/Schema/Entities/NewMapBackup.xml new file mode 100644 index 00000000..15ec64cf --- /dev/null +++ b/resources/Schema/Entities/NewMapBackup.xml @@ -0,0 +1,3222 @@ + + + + + + + + + + + + + + + + + + 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/Pillars/SciFiPillar1.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar3.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar3.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWall.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/MediumWall3.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWall.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/BigWall.mesh + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + Models/Props/Walls/BigWall.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/WoodenBridge.mesh + + + + + + + + + + + + + + Models/Props/Bridges/WoodenBridge.mesh + + + + + + + + + + + + + + Models/Props/Bridges/WoodenBridge.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge.mesh + + + + + + + + + + + + + + Models/Props/Flora/TreeLog.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/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/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/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/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone1.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/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone1.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/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/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystal.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystal.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystal.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/CapturePoint.mesh + + true + + + + + + + + + + + + + + + + + + 1 + + + Models/Props/CapturePoint.mesh + + true + + + + + + + + + + + + + + 2 + + + Models/Props/CapturePoint.mesh + + true + + + + + + + + + + + + + + 3 + + + Models/Props/CapturePoint.mesh + + true + + + + + + + + + + + + + + + + + 4 + + + Models/Props/CapturePoint.mesh + + true + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + 10 + + + + + + + + + + 10 + + + + + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + 1 + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + + + + + + + + + + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/StoneWall.xml b/resources/Schema/Entities/StoneWall.xml new file mode 100644 index 00000000..e578d339 --- /dev/null +++ b/resources/Schema/Entities/StoneWall.xml @@ -0,0 +1,147 @@ + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + From 73f59b89ccce4709376beb9cc5273f68afc71178 Mon Sep 17 00:00:00 2001 From: William Moberg Date: Thu, 11 Feb 2016 00:11:37 +0100 Subject: [PATCH 13/37] Added method EntityFirstHitByRay, takes an Octree or a vector of sorted entities and outputs the frist entity hit by a ray. --- include/Engine/Collision/Collision.h | 23 +++++++-- include/Engine/Core/Octree.h | 75 ++++++++++++++++++++++++++++ src/Engine/Collision/Collision.cpp | 66 ++++++++++++++++++------ src/Engine/Core/Octree.cpp | 25 +++------- 4 files changed, 151 insertions(+), 38 deletions(-) diff --git a/include/Engine/Collision/Collision.h b/include/Engine/Collision/Collision.h index c3759393..5b4150d8 100644 --- a/include/Engine/Collision/Collision.h +++ b/include/Engine/Collision/Collision.h @@ -20,6 +20,9 @@ class World; struct ComponentWrapper; +template +class Octree; + namespace Collision { //Return true if the ray hits the box. @@ -44,21 +47,24 @@ bool RayVsTriangle(const Ray& ray, float& outVCoord, bool trueOnNegativeDistance = false); //Return true if the ray hits any of the triangles in the model. Stops checking when a hit is detected. -bool RayVsModel(const Ray& ray, - const std::vector& modelVertices, - const std::vector& modelIndices); +bool RayVsModel(const Ray& ray, + const RawModel::Vertex* modelVertices, + const std::vector& modelIndices, + const glm::mat4& modelMatrix); //Return true if the ray hits any of the triangles in the model. //Also returns the position of the intersection point. Will loop through all the whole model indices. bool RayVsModel(const Ray& ray, - const std::vector& modelVertices, + const RawModel::Vertex* modelVertices, const std::vector& modelIndices, + const glm::mat4& modelMatrix, glm::vec3& outHitPosition); //Return true if the ray hits any of the triangles in the model. //Also returns the distance from the ray origin to the closest //intersection point, and the barycentric u,v-coordinates. Will loop through all the whole model indices. bool RayVsModel(const Ray& ray, - const std::vector& modelVertices, + const RawModel::Vertex* modelVertices, const std::vector& modelIndices, + const glm::mat4& modelMatrix, float& outDistance, float& outUCoord, float& outVCoord); @@ -81,6 +87,13 @@ bool AABBVsAABB(const AABB& a, const AABB& b, glm::vec3& minimumTranslation); // Calculates an absolute AABB from an entity AABB component boost::optional EntityAbsoluteAABB(EntityWrapper& entity, bool takeModelBox = false); boost::optional AbsoluteAABBExplosionEffect(EntityWrapper& entity); +//Returns the first entity hit by the input ray. entitiesPotentiallyHitSorted needs to be sorted +//by their distance to the ray, e.g. result from Octree::ObjectsPossiblyHitByRay. +//Returns boost::none if none was hit. outDistance will be the distance to the intersection point if the ray intersects. +boost::optional EntityFirstHitByRay(const Ray& ray, std::vector entitiesPotentiallyHitSorted, float outDistance, glm::vec3& outIntersectPos); +//Returns the first entity hit by the input ray that exists in the octree. +//outDistance will be the distance to the intersection point if the ray intersects. +boost::optional EntityFirstHitByRay(const Ray& ray, Octree* octree, float outDistance, glm::vec3& outIntersectPos); } diff --git a/include/Engine/Core/Octree.h b/include/Engine/Core/Octree.h index 6bdea4d3..be0cac95 100644 --- a/include/Engine/Core/Octree.h +++ b/include/Engine/Core/Octree.h @@ -43,6 +43,8 @@ public: void ObjectsInSameRegion(const Box& box, std::vector& outObjects); //Get the objects that are inside the frustum, the objects are put in outObjects. void ObjectsInFrustum(const Frustum& frustum, std::vector& outObjects); + //Get objects, which AABB the input ray intersects, the objects are put in outObjects. + void ObjectsPossiblyHitByRay(const Ray& ray, std::vector& outObjects); //Empty the tree of all objects, static and dynamic. void ClearObjects(); //Empty the tree of all dynamic objects. Static objects remain in the tree. @@ -102,6 +104,8 @@ struct Child void ObjectsInSameRegion(const Box& box, std::vector& outObjects) const; template void ObjectsInFrustum(const Frustum& frustum, std::vector& outObjects, bool takeAllDontTest) const; + template + void ObjectsPossiblyHitByRay(const Ray& ray, std::vector& outObjects) const; void ClearObjects(); void ClearDynamicObjects(); bool RayCollides(const Ray& ray, Output& data) const; @@ -121,6 +125,15 @@ struct Child std::vector childIndicesContainingBox(const AABB& box) const; }; +//To be able to sort child nodes and contained objects based on distance to ray origin. +struct RaySorterInfo +{ + int Index; + float Distance; +}; + +bool isFirstLower(const RaySorterInfo& first, const RaySorterInfo& second); + } template @@ -166,6 +179,13 @@ void Octree::ObjectsInFrustum(const Frustum& frustum, std::vector& outObje m_Root->ObjectsInFrustum(frustum, outObjects, false); } +template +void Octree::ObjectsPossiblyHitByRay(const Ray& ray, std::vector& outObjects) +{ + falsifyObjectChecks(); + m_Root->ObjectsPossiblyHitByRay(ray, outObjects); +} + template void Octree::ClearObjects() { @@ -284,4 +304,59 @@ void OctSpace::Child::ObjectsInFrustum(const Frustum& frustum, std::vector& o } } +template +void OctSpace::Child::ObjectsPossiblyHitByRay(const Ray& ray, std::vector& outObjects) const +{ + //If the node AABB is missed, everything it contains is missed. + if (Collision::RayAABBIntr(ray, m_Box)) { + //If the ray shoots the tree, and it is a parent. + if (hasChildren()) { + //Sort children according to their distance from the ray origin. + std::vector childInfos; + childInfos.resize(8); + for (int i = 0; i < 8; ++i) { + childInfos[i] = { i, glm::distance(ray.Origin(), m_Children[i]->m_Box.Origin()) }; + } + std::sort(childInfos.begin(), childInfos.end(), isFirstLower); + //Loop through the children, starting with the one closest to the ray origin. I.e the first to be hit. + for (const RaySorterInfo& info : childInfos) { + m_Children[info.Index]->ObjectsPossiblyHitByRay(ray, outObjects); + } + } else { + //Check against boxes in the node. + bool intersected = false; + float dist; + //Sort all contained objects according to the distance from the ray origin to + //the intersection, if they are intersecting. + std::vector objectHitInfos; + objectHitInfos.reserve(m_StaticObjIndices.size() + m_DynamicObjIndices.size()); + for (int i : m_StaticObjIndices) { + //If we haven't tested against this object before, and the ray hits. + if (!m_StaticObjectsRef[i].Checked && + Collision::RayVsAABB(ray, *m_StaticObjectsRef[i].Box, dist)) { + objectHitInfos.push_back({ i, dist }); + } + m_StaticObjectsRef[i].Checked = true; + } + for (int i : m_DynamicObjIndices) { + //If we haven't tested against this object before, and the ray hits. + if (!m_DynamicObjectsRef[i].Checked && + Collision::RayVsAABB(ray, *m_DynamicObjectsRef[i].Box, dist)) { + objectHitInfos.push_back({ i + (int)m_StaticObjIndices.size(), dist }); + } + m_DynamicObjectsRef[i].Checked = true; + } + std::sort(objectHitInfos.begin(), objectHitInfos.end(), isFirstLower); + int startSize = (int)outObjects.size(); + outObjects.resize(startSize + objectHitInfos.size()); + for (int i = 0; i < objectHitInfos.size(); ++i) { + outObjects[startSize + i] = (objectHitInfos[i].Index < m_StaticObjIndices.size()) ? + *static_cast(m_StaticObjectsRef[objectHitInfos[i].Index].Box.get()) : + *static_cast(m_DynamicObjectsRef[objectHitInfos[i].Index - m_StaticObjIndices.size()].Box.get()); + } + } + } +} + + #endif \ No newline at end of file diff --git a/src/Engine/Collision/Collision.cpp b/src/Engine/Collision/Collision.cpp index b7b21969..7b182de1 100644 --- a/src/Engine/Collision/Collision.cpp +++ b/src/Engine/Collision/Collision.cpp @@ -6,6 +6,7 @@ #include "Core/World.h" #include "Rendering/Model.h" #include "imgui/imgui.h" +#include "Core/Octree.h" namespace Collision { @@ -145,13 +146,14 @@ bool RayVsTriangle(const Ray& ray, } bool RayVsModel(const Ray& ray, - const std::vector& modelVertices, - const std::vector& modelIndices) + const RawModel::Vertex* modelVertices, + const std::vector& modelIndices, + const glm::mat4& modelMatrix) { - for (int i = 0; i < modelIndices.size(); ++i) { - glm::vec3 v0 = modelVertices[modelIndices[i]].Position; - glm::vec3 v1 = modelVertices[modelIndices[++i]].Position; - glm::vec3 v2 = modelVertices[modelIndices[++i]].Position; + for (int i = 0; i < modelIndices.size();) { + glm::vec3 v0 = Transform::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix); + glm::vec3 v1 = Transform::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix); + glm::vec3 v2 = Transform::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix); if (RayVsTriangle(ray, v0, v1, v2)) { return true; } @@ -192,19 +194,20 @@ bool RayVsTriangle(const Ray& ray, } bool RayVsModel(const Ray& ray, - const std::vector& modelVertices, + const RawModel::Vertex* modelVertices, const std::vector& modelIndices, + const glm::mat4& modelMatrix, float& outDistance, float& outUCoord, float& outVCoord) { outDistance = INFINITY; bool hit = false; - for (int i = 0; i < modelIndices.size(); ++i) { - glm::vec3 v0 = modelVertices[modelIndices[i]].Position; - glm::vec3 v1 = modelVertices[modelIndices[++i]].Position; - glm::vec3 v2 = modelVertices[modelIndices[++i]].Position; - float dist; + for (int i = 0; i < modelIndices.size();) { + glm::vec3 v0 = Transform::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix); + glm::vec3 v1 = Transform::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix); + glm::vec3 v2 = Transform::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix); + float dist = INFINITY; float u; float v; if (RayVsTriangle(ray, v0, v1, v2, dist, u, v)) { @@ -218,14 +221,15 @@ bool RayVsModel(const Ray& ray, } bool RayVsModel(const Ray& ray, - const std::vector& modelVertices, + const RawModel::Vertex* modelVertices, const std::vector& modelIndices, + const glm::mat4& modelMatrix, glm::vec3& outHitPosition) { float u; float v; float dist; - bool hit = RayVsModel(ray, modelVertices, modelIndices, dist, u, v); + bool hit = RayVsModel(ray, modelVertices, modelIndices, modelMatrix, dist, u, v); outHitPosition = ray.Origin() + dist * ray.Direction(); return hit; } @@ -572,11 +576,11 @@ boost::optional EntityAbsoluteAABB(EntityWrapper& entity, bool takeM ComponentWrapper& cAABB = entity["AABB"]; modelSpaceBox = EntityAABB::FromOriginSize((glm::vec3)cAABB["Origin"], (glm::vec3)cAABB["Size"]); } else if (entity.HasComponent("Model")) { - Model* model; std::string res = entity["Model"]["Resource"]; if (res.empty()) { return boost::none; } + Model* model; try { model = ResourceManager::Load<::Model, true>(res); } catch (const Resource::StillLoadingException&) { @@ -638,4 +642,36 @@ boost::optional AbsoluteAABBExplosionEffect(EntityWrapper& entity) return aabb; } +boost::optional EntityFirstHitByRay(const Ray& ray, std::vector entitiesPotentiallyHitSorted, float outDistance, glm::vec3& outIntersectPos) +{ + for (EntityAABB& entityBox : entitiesPotentiallyHitSorted) { + if (!entityBox.Entity.HasComponent("Model")) { + continue; + } + std::string res = entityBox.Entity["Model"]["Resource"]; + if (res.empty()) { + continue; + } + Model* model; + try { + model = ResourceManager::Load<::Model, true>(res); + } catch (const std::exception&) { + continue; + } + float u, v; + if (RayVsModel(ray, model->Vertices(), model->m_RawModel->m_Indices, Transform::ModelMatrix(entityBox.Entity), outDistance, u, v)) { + outIntersectPos = ray.Origin() + outDistance * ray.Direction(); + return entityBox; + } + } + return boost::none; +} + +boost::optional EntityFirstHitByRay(const Ray& ray, Octree* octree, float outDistance, glm::vec3& outIntersectPos) +{ + std::vector outObjects; + octree->ObjectsPossiblyHitByRay(ray, outObjects); + return Collision::EntityFirstHitByRay(ray, outObjects, outDistance, outIntersectPos); +} + } \ No newline at end of file diff --git a/src/Engine/Core/Octree.cpp b/src/Engine/Core/Octree.cpp index 7eee1f81..dca06c6f 100644 --- a/src/Engine/Core/Octree.cpp +++ b/src/Engine/Core/Octree.cpp @@ -5,22 +5,6 @@ #include "Core/Octree.h" #include "Collision/Collision.h" -namespace -{ -//To be able to sort nodes based on distance to ray origin. -struct ChildInfo -{ - int Index; - float Distance; -}; - -bool isFirstLower(const ChildInfo& first, const ChildInfo& second) -{ - return first.Distance < second.Distance; -} - -} - namespace OctSpace { @@ -123,14 +107,14 @@ bool Child::RayCollides(const Ray& ray, OctSpace::Output& data) const //If the ray shoots the tree, and it is a parent to 8 children :o if (hasChildren()) { //Sort children according to their distance from the ray origin. - std::vector childInfos; + std::vector childInfos; childInfos.reserve(8); for (int i = 0; i < 8; ++i) { childInfos.push_back({ i, glm::distance(ray.Origin(), m_Children[i]->m_Box.Origin()) }); } std::sort(childInfos.begin(), childInfos.end(), isFirstLower); //Loop through the children, starting with the one closest to the ray origin. I.e the first to be hit. - for (const ChildInfo& info : childInfos) { + for (const RaySorterInfo& info : childInfos) { if (m_Children[info.Index]->RayCollides(ray, data)) { return true; } @@ -275,4 +259,9 @@ std::vector Child::childIndicesContainingBox(const AABB& box) const } } +bool isFirstLower(const RaySorterInfo& first, const RaySorterInfo& second) +{ + return first.Distance < second.Distance; +} + } \ No newline at end of file From 35e4935497910a37711fc744646d05efced90e3e Mon Sep 17 00:00:00 2001 From: Tleety Date: Thu, 11 Feb 2016 10:01:11 +0100 Subject: [PATCH 14/37] Some assets and HUD stuff --- assets | 2 +- .../Schema/Entities/CapturePointHUDGroup | 172 ++++++++++++++++++ .../Schema/Entities/QualityAssurance.xml | 75 ++++---- src/Game/Systems/CapturePointHUDSystem.cpp | 5 +- 4 files changed, 215 insertions(+), 39 deletions(-) create mode 100644 resources/Schema/Entities/CapturePointHUDGroup diff --git a/assets b/assets index 7531e441..0580eeae 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 7531e441fea639076d69c6cf05e3ae8ff7170cf9 +Subproject commit 0580eeae80919127622e16f2ec4f4083668d36cd diff --git a/resources/Schema/Entities/CapturePointHUDGroup b/resources/Schema/Entities/CapturePointHUDGroup new file mode 100644 index 00000000..9dce0ffb --- /dev/null +++ b/resources/Schema/Entities/CapturePointHUDGroup @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 2 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 3 + + + 0.80222018197612788 + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 4 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 1 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/QualityAssurance.xml b/resources/Schema/Entities/QualityAssurance.xml index ce6a650e..2c77bc30 100644 --- a/resources/Schema/Entities/QualityAssurance.xml +++ b/resources/Schema/Entities/QualityAssurance.xml @@ -40,7 +40,7 @@ - + @@ -180,7 +180,7 @@ - + @@ -671,7 +671,7 @@ - + @@ -718,7 +718,7 @@ - + @@ -778,7 +778,7 @@ - + @@ -825,7 +825,7 @@ - + @@ -871,7 +871,7 @@ - + @@ -918,7 +918,7 @@ - + @@ -965,7 +965,7 @@ - + @@ -1023,6 +1023,7 @@ + 15 Models/Core/UnitCube.mesh @@ -1162,7 +1163,6 @@ - -12.033302729641917 3 @@ -1212,6 +1212,7 @@ + -15 4 @@ -1378,7 +1379,7 @@ - + @@ -1387,7 +1388,7 @@ true - 0.75158864645285173 + 0.75184169309215043 3.7999999523162842 true @@ -1434,7 +1435,7 @@ - + @@ -1443,7 +1444,7 @@ - 1.2014943970669589 + 1.2017474437062576 Models/Characters/Assault/AssaultTPose.mesh @@ -1486,7 +1487,7 @@ - + @@ -1497,7 +1498,7 @@ true - 0.68494018072689011 + 0.68519322736618882 true @@ -1542,7 +1543,7 @@ - + @@ -1552,7 +1553,7 @@ true - 0.95103870157425385 + 0.95129174821355256 10 3 @@ -1600,7 +1601,7 @@ - + @@ -1610,7 +1611,7 @@ true - 1.3510669629503185 + 1.3513200095896172 true 5 true @@ -1791,7 +1792,7 @@ true - 1.3677400229854642 + 1.3679930696247629 3.7999999523162842 true @@ -1965,7 +1966,7 @@ Textures/Core/UnitHexagon.png - + @@ -1978,7 +1979,7 @@ 2 - 0.5 + Textures/Core/UnitHexagon_Rotated.png @@ -1986,7 +1987,7 @@ - + @@ -1997,7 +1998,7 @@ Textures/Core/UnitHexagon.png - + @@ -2010,7 +2011,7 @@ 3 - 0.5 + Textures/Core/UnitHexagon_Rotated.png @@ -2018,7 +2019,7 @@ - + @@ -2029,7 +2030,7 @@ Textures/Core/UnitHexagon.png - + @@ -2042,7 +2043,8 @@ 4 - 0.5 + 1 + Textures/Core/UnitHexagon_Rotated.png @@ -2050,7 +2052,7 @@ - + @@ -2061,7 +2063,7 @@ Textures/Core/UnitHexagon.png - + @@ -2074,7 +2076,7 @@ 1 - 0.5 + Textures/Core/UnitHexagon_Rotated.png @@ -2082,7 +2084,7 @@ - + @@ -2093,7 +2095,7 @@ Textures/Core/UnitHexagon.png - + @@ -2104,7 +2106,8 @@ - 0.5 + 1 + Textures/Core/UnitHexagon_Rotated.png @@ -2112,7 +2115,7 @@ - + diff --git a/src/Game/Systems/CapturePointHUDSystem.cpp b/src/Game/Systems/CapturePointHUDSystem.cpp index 5c4c2b60..ad8cc63a 100644 --- a/src/Game/Systems/CapturePointHUDSystem.cpp +++ b/src/Game/Systems/CapturePointHUDSystem.cpp @@ -13,7 +13,7 @@ CapturePointHUDSystem::CapturePointHUDSystem(World* world, EventBroker* eventBro void CapturePointHUDSystem::Update(double dt) { - bool LoadCheck = false; + bool LoadCheck = true; int redTeam; int blueTeam; int spectatorTeam; @@ -32,10 +32,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; } //Color hud with team color auto capturePointTeam = (int)teamComponent["Team"]; From 350effd8ebc045f1614e3a1422f99d3d62fe8758 Mon Sep 17 00:00:00 2001 From: Tleety Date: Thu, 11 Feb 2016 11:32:51 +0100 Subject: [PATCH 15/37] New assets and some QA map stuff --- assets | 2 +- .../Schema/Entities/QualityAssurance.xml | 59 +++++++++++++------ 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/assets b/assets index 0580eeae..8ffd0a99 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 0580eeae80919127622e16f2ec4f4083668d36cd +Subproject commit 8ffd0a99b9a2e5c140307d382a25c4a470cc8f33 diff --git a/resources/Schema/Entities/QualityAssurance.xml b/resources/Schema/Entities/QualityAssurance.xml index 2c77bc30..40951468 100644 --- a/resources/Schema/Entities/QualityAssurance.xml +++ b/resources/Schema/Entities/QualityAssurance.xml @@ -180,7 +180,7 @@ - + @@ -671,7 +671,7 @@ - + @@ -718,7 +718,7 @@ - + @@ -778,7 +778,7 @@ - + @@ -825,7 +825,7 @@ - + @@ -871,7 +871,7 @@ - + @@ -918,7 +918,7 @@ - + @@ -965,7 +965,7 @@ - + @@ -1379,7 +1379,7 @@ - + @@ -1388,7 +1388,7 @@ true - 0.75184169309215043 + 0.75205058136495551 3.7999999523162842 true @@ -1435,7 +1435,7 @@ - + @@ -1444,7 +1444,7 @@ - 1.2017474437062576 + 1.2019563319790627 Models/Characters/Assault/AssaultTPose.mesh @@ -1487,7 +1487,7 @@ - + @@ -1498,7 +1498,7 @@ true - 0.68519322736618882 + 0.68540211563899389 true @@ -1543,7 +1543,7 @@ - + @@ -1553,7 +1553,7 @@ true - 0.95129174821355256 + 0.95150063648635763 10 3 @@ -1601,7 +1601,7 @@ - + @@ -1611,7 +1611,7 @@ true - 1.3513200095896172 + 1.3515288978624223 true 5 true @@ -1792,7 +1792,7 @@ true - 1.3679930696247629 + 1.3682019578975679 3.7999999523162842 true @@ -2124,6 +2124,27 @@ + + + + + + + + + + + + Models/Widgets/Camera.mesh + + + + + + + + + From f11bd24d539cd9847b3307250bea8202272f02f3 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Thu, 11 Feb 2016 11:46:34 +0100 Subject: [PATCH 16/37] Added CapturePointMaxTimer in CapturePointComponent. Removed next-capturepoint Color. Modified captureTimer to +-captureTimeToTakeOver after a capture. --- include/Game/Systems/CapturePointSystem.h | 1 - resources/Schema/Components/CapturePoint.xml | 1 + resources/Schema/Components/CapturePoint.xsd | 6 +- .../Schema/Entities/CaptureTestState5.xml | 323 ++++++++++++++---- src/Game/Systems/CapturePointSystem.cpp | 29 +- 5 files changed, 273 insertions(+), 87 deletions(-) diff --git a/include/Game/Systems/CapturePointSystem.h b/include/Game/Systems/CapturePointSystem.h index 18c32c76..33ba40c8 100644 --- a/include/Game/Systems/CapturePointSystem.h +++ b/include/Game/Systems/CapturePointSystem.h @@ -44,7 +44,6 @@ private: //std::vector - const double m_CaptureTimeToTakeOver = 15.0; bool m_ResetTimers = false; //vectors which will keep track of enter/leave changes diff --git a/resources/Schema/Components/CapturePoint.xml b/resources/Schema/Components/CapturePoint.xml index ba164fd9..638b16c3 100644 --- a/resources/Schema/Components/CapturePoint.xml +++ b/resources/Schema/Components/CapturePoint.xml @@ -2,5 +2,6 @@ 0 0 + 15 \ No newline at end of file diff --git a/resources/Schema/Components/CapturePoint.xsd b/resources/Schema/Components/CapturePoint.xsd index fbdb3568..3c91dfdd 100644 --- a/resources/Schema/Components/CapturePoint.xsd +++ b/resources/Schema/Components/CapturePoint.xsd @@ -20,7 +20,11 @@ CapturePointNumber specify an int number for this - + + + The time needed to take over a Capture Point + + Specify if this is a HomePoint for either team diff --git a/resources/Schema/Entities/CaptureTestState5.xml b/resources/Schema/Entities/CaptureTestState5.xml index 8fe85068..c733706c 100644 --- a/resources/Schema/Entities/CaptureTestState5.xml +++ b/resources/Schema/Entities/CaptureTestState5.xml @@ -2,12 +2,246 @@ - - - + + + + + + + + + Models/LevelBase/MapVersion1.mesh + + + + + + + + + 2 + + + Models/Widgets/Lights/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 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -15,10 +249,12 @@ + 15 Models/Core/UnitSphere.mesh - + + true @@ -26,7 +262,7 @@ - + @@ -40,11 +276,12 @@ Models/Core/UnitSphere.mesh - + + true - + @@ -58,15 +295,12 @@ Models/Core/UnitSphere.mesh - + + true - - - - - + - + @@ -76,11 +310,13 @@ + -15 3 Models/Core/UnitSphere.mesh - + + true @@ -88,7 +324,7 @@ - + @@ -101,11 +337,13 @@ + -15 4 Models/Core/UnitSphere.mesh - + + true @@ -113,61 +351,12 @@ - + - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - - - - Models/Test/DummyScene.mesh - - - - - - - diff --git a/src/Game/Systems/CapturePointSystem.cpp b/src/Game/Systems/CapturePointSystem.cpp index a943e234..971c194c 100644 --- a/src/Game/Systems/CapturePointSystem.cpp +++ b/src/Game/Systems/CapturePointSystem.cpp @@ -1,7 +1,7 @@ #include "Systems/CapturePointSystem.h" #include -CapturePointSystem::CapturePointSystem(World* world, EventBroker* eventBroker) +CapturePointSystem::CapturePointSystem(World* world, EventBroker* eventBroker) : System(world, eventBroker) , PureSystem("CapturePoint") { @@ -32,6 +32,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp const int redTeam = (int)teamComponent["Team"].Enum("Red"); const int blueTeam = (int)teamComponent["Team"].Enum("Blue"); const int spectatorTeam = (int)teamComponent["Team"].Enum("Spectator"); + const double captureTimeToTakeOver = (double)cCapturePoint["CapturePointMaxTimer"]; int homePointForTeam = (int)cCapturePoint["HomePointForTeam"]; if (m_NumberOfCapturePoints == 0 && capturePointNumber != 0 && (homePointForTeam == redTeam || homePointForTeam == blueTeam)) { @@ -57,7 +58,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp int blueTeamPlayersStandingInside = 0; 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.2f, 1, 0.3) : ownedBy == redTeam ? glm::vec4(1, 0.2f, 0, 0.3) : glm::vec4(1, 1, 1, 0.3); + 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); } //calculate next possible capturePoint for both teams @@ -98,20 +99,16 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp ComponentWrapper& capturePoint = m_CapturePointNumberToEntityMap[i]["CapturePoint"]; if ((int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Red"] && (int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Blue"]) { - capturePoint["CaptureTimer"] = 0.0; + //RED = +, BLUE = -, NONE + auto teamOwners = (int)m_CapturePointNumberToEntityMap[i]["Team"]["Team"]; + if (teamOwners == redTeam || teamOwners == blueTeam) { + capturePoint["CaptureTimer"] = teamOwners == blueTeam ? -captureTimeToTakeOver : captureTimeToTakeOver; + } } } m_ResetTimers = false; } - //colorize next possible capturepoint - if (nextPossibleCapturePoint["Red"] == capturePointNumber) { - capturePointEntity["Model"]["Color"] = glm::vec4(1, 1, 0, 0.3); - } - if (nextPossibleCapturePoint["Blue"] == capturePointNumber) { - capturePointEntity["Model"]["Color"] = glm::vec4(0, 1, 1, 0.3); - } - //check how many players are standing inside and are healthy for (size_t i = m_ETriggerTouchVector.size(); i > 0; i--) { @@ -170,9 +167,6 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp //B. at most one of the teams have players inside //if capturePoint is not owned by the take-over team, just modify the CaptureTimer accordingly if (ownedBy != currentTeam && canCapture) { - if (abs((double)cCapturePoint["CaptureTimer"]) < 0.001f) { - LOG_DEBUG("Point is being captured by team %i", currentTeam); //Remove when we tested sufficiently. - } 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 @@ -180,12 +174,11 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp (ownedBy == currentTeam && currentTeam == blueTeam && (double)cCapturePoint["CaptureTimer"] > 0.0)) { cCapturePoint["CaptureTimer"] = (double)cCapturePoint["CaptureTimer"] + timerDeltaChange; } - //check if captureTimer > m_CaptureTimeToTakeOver and if so change owner and publish the eCaptured event - if (abs((double)cCapturePoint["CaptureTimer"]) > abs(m_CaptureTimeToTakeOver) && canCapture) { + //check if captureTimer > captureTimeToTakeOver and if so change owner and publish the eCaptured event + if (abs((double)cCapturePoint["CaptureTimer"]) > captureTimeToTakeOver && canCapture) { teamComponent["Team"] = currentTeam; - cCapturePoint["CaptureTimer"] = 0.0; + cCapturePoint["CaptureTimer"] = glm::sign((double)cCapturePoint["CaptureTimer"])*captureTimeToTakeOver; //publish Captured event - LOG_DEBUG("Point is captured by team %i!", currentTeam); //Remove when we tested sufficiently. Events::Captured e; e.CapturePointID = cCapturePoint.EntityID; e.TeamNumberThatCapturedCapturePoint = currentTeam; From 2f640d224ced2eb89b32762a1351e964ea938a0b Mon Sep 17 00:00:00 2001 From: antc13 Date: Thu, 11 Feb 2016 12:23:20 +0100 Subject: [PATCH 17/37] New Map with Meshes WIP --- resources/Schema/Entities/NewMap.xml | 65 ++++++++++++++-------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/resources/Schema/Entities/NewMap.xml b/resources/Schema/Entities/NewMap.xml index 8a5227aa..7a1d620b 100644 --- a/resources/Schema/Entities/NewMap.xml +++ b/resources/Schema/Entities/NewMap.xml @@ -338,7 +338,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -349,6 +349,7 @@ Models/Props/Walls/BigWall.mesh + @@ -363,7 +364,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -440,7 +441,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -452,7 +453,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -466,7 +467,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -482,7 +483,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -494,7 +495,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -507,7 +508,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -753,7 +754,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -764,7 +765,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -776,7 +777,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -803,7 +804,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -830,7 +831,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -841,7 +842,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -853,7 +854,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -879,7 +880,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -1030,7 +1031,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -1057,7 +1058,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -1068,7 +1069,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -1080,7 +1081,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -1092,7 +1093,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -1106,7 +1107,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -1118,7 +1119,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -1183,7 +1184,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -1195,7 +1196,7 @@ Models/Props/Walls/BigWall.mesh - + @@ -1449,7 +1450,7 @@ Models/Props/Bridges/SciFiBridge.mesh - + @@ -1462,7 +1463,7 @@ Models/Props/Bridges/SciFiBridgeDefense.mesh - + @@ -1515,7 +1516,7 @@ Models/Props/Bridges/SciFiBridgeDefense.mesh - + @@ -1604,7 +1605,7 @@ Models/Props/Pillars/SciFiBridgePillar1.mesh - + @@ -2886,9 +2887,9 @@ Models/Props/PickUps/PickUpHolder.mesh - + - + @@ -3117,7 +3118,7 @@ Models/Props/SciFiHolder1.mesh - + From 9f657ada4ebd5ed1177b7ca078c5870c8df5f1a4 Mon Sep 17 00:00:00 2001 From: Tleety Date: Thu, 11 Feb 2016 14:52:52 +0100 Subject: [PATCH 18/37] merge fixes --- include/Game/Systems/CapturePointHUDSystem.h | 2 +- src/Engine/Rendering/DrawFinalPass.cpp | 1 - src/Game/Systems/CapturePointHUDSystem.cpp | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/Game/Systems/CapturePointHUDSystem.h b/include/Game/Systems/CapturePointHUDSystem.h index 102c52ce..94be3798 100644 --- a/include/Game/Systems/CapturePointHUDSystem.h +++ b/include/Game/Systems/CapturePointHUDSystem.h @@ -12,7 +12,7 @@ class CapturePointHUDSystem : public ImpureSystem { public: - CapturePointHUDSystem(World* world, EventBroker* eventBroker); + CapturePointHUDSystem(SystemParams params); virtual void Update(double dt) override; diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 42cbd22b..362f2252 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -323,7 +323,6 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO()); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO()); - for (auto &job : jobs) { auto explosionEffectJob = std::dynamic_pointer_cast(job); if (explosionEffectJob) { diff --git a/src/Game/Systems/CapturePointHUDSystem.cpp b/src/Game/Systems/CapturePointHUDSystem.cpp index ad8cc63a..c2d62c4b 100644 --- a/src/Game/Systems/CapturePointHUDSystem.cpp +++ b/src/Game/Systems/CapturePointHUDSystem.cpp @@ -1,7 +1,7 @@ #include "Systems/CapturePointHUDSystem.h" -CapturePointHUDSystem::CapturePointHUDSystem(World* world, EventBroker* eventBroker) - : System(world, eventBroker) +CapturePointHUDSystem::CapturePointHUDSystem(SystemParams params) + : System(params) , ImpureSystem() { //subscribe/listenTo playerdamage,healthpickup events (using the eventBroker) From 6ba1e95da77a8c5e7c4d34a6357d2026bab0ea9e Mon Sep 17 00:00:00 2001 From: Tleety Date: Thu, 11 Feb 2016 15:27:07 +0100 Subject: [PATCH 19/37] Fixed depth sorting for HUD elements. --- include/Engine/Rendering/SpriteJob.h | 9 ++++--- include/Game/Systems/CapturePointHUDSystem.h | 27 -------------------- resources/Schema/Components/Sprite.xml | 1 + resources/Schema/Components/Sprite.xsd | 3 +++ src/Engine/Rendering/DrawFinalPass.cpp | 6 ++++- src/Engine/Rendering/RenderSystem.cpp | 4 ++- 6 files changed, 18 insertions(+), 32 deletions(-) diff --git a/include/Engine/Rendering/SpriteJob.h b/include/Engine/Rendering/SpriteJob.h index 2708ab0e..3bb43a1c 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) + SpriteJob(ComponentWrapper cSprite, Camera* camera, glm::mat4 matrix, World* world, glm::vec4 fillColor, float fillPercentage, bool depthSorted) : RenderJob() { Model = ResourceManager::Load<::Model>("Models/Core/UnitQuad.mesh"); @@ -34,8 +34,11 @@ struct SpriteJob : RenderJob Color = cSprite["Color"]; Entity = cSprite.EntityID; Position = Transform::AbsolutePosition(world, cSprite.EntityID); - glm::vec3 viewpos = glm::vec3(camera->ViewMatrix() * glm::vec4(Position, 1)); - Depth = viewpos.z; + Depth = 0; + if (depthSorted) { + glm::vec3 viewpos = glm::vec3(camera->ViewMatrix() * glm::vec4(Position, 1)); + Depth = viewpos.z; + } World = world; FillColor = fillColor; diff --git a/include/Game/Systems/CapturePointHUDSystem.h b/include/Game/Systems/CapturePointHUDSystem.h index 94be3798..41db0c12 100644 --- a/include/Game/Systems/CapturePointHUDSystem.h +++ b/include/Game/Systems/CapturePointHUDSystem.h @@ -17,33 +17,6 @@ public: virtual void Update(double dt) override; private: - //methods which will take care of specific events - /* EventRelay m_ETriggerTouch; - bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e); - EventRelay m_ETriggerLeave; - bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e); - EventRelay m_ECaptured; - bool CapturePointSystem::OnCaptured(const Events::Captured& e);*/ - - //bool m_WinnerWasFound = false; - ////need to track these variables for the captureSystem to work as per design! - //const int m_NotACapturePoint = 999; - //int m_RedTeamNextPossibleCapturePoint = m_NotACapturePoint; - //int m_BlueTeamNextPossibleCapturePoint = m_NotACapturePoint; - //int m_RedTeamHomeCapturePoint = m_NotACapturePoint; - //int m_BlueTeamHomeCapturePoint = m_NotACapturePoint; - - //int m_NumberOfCapturePoints = 0; - //std::map m_CapturePointNumberToEntityMap; - - ////std::vector - - //const double m_CaptureTimeToTakeOver = 15.0; - //bool m_ResetTimers = false; - - ////vectors which will keep track of enter/leave changes - //std::vector> m_ETriggerTouchVector; - //std::vector> m_ETriggerLeaveVector; }; #endif \ No newline at end of file diff --git a/resources/Schema/Components/Sprite.xml b/resources/Schema/Components/Sprite.xml index c2a2057f..ce4a6e1b 100644 --- a/resources/Schema/Components/Sprite.xml +++ b/resources/Schema/Components/Sprite.xml @@ -4,4 +4,5 @@ true + true diff --git a/resources/Schema/Components/Sprite.xsd b/resources/Schema/Components/Sprite.xsd index c8f0c187..3c3d124a 100644 --- a/resources/Schema/Components/Sprite.xsd +++ b/resources/Schema/Components/Sprite.xsd @@ -21,6 +21,9 @@ Whether the model is visible or not + + Whether the sprite should be sorted with depth or not. Only use false for textures that are on HUD + diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 362f2252..83bacd37 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -623,9 +623,13 @@ void DrawFinalPass::DrawSprites(std::list>&jobs, Rend for(auto& job : jobs) { auto spriteJob = std::dynamic_pointer_cast(job); + RenderState jobState; if (spriteJob) { - + if(spriteJob->Depth == 0) + { + jobState.Disable(GL_DEPTH_TEST); + } glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(spriteJob->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())); diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index f10e6043..6600bc4f 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -62,6 +62,7 @@ void RenderSystem::fillSprites(std::list>& jobs, Worl std::string diffuseResource = cSprite["DiffuseTexture"]; std::string glowResource = cSprite["GlowMap"]; + bool depthSorted = cSprite["DepthSort"]; if (diffuseResource.empty() && glowResource.empty()) { continue; } @@ -77,7 +78,8 @@ void RenderSystem::fillSprites(std::list>& jobs, Worl glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, world); //modelMatrix *= m_Camera->BillboardMatrix(); - std::shared_ptr spriteJob = std::shared_ptr(new SpriteJob(cSprite, m_Camera, modelMatrix, world, fillColor, fillPercentage)); + + std::shared_ptr spriteJob = std::shared_ptr(new SpriteJob(cSprite, m_Camera, modelMatrix, world, fillColor, fillPercentage, depthSorted)); jobs.push_back(spriteJob); } From 7ccaf5b040363df66989c749780b367ac9a16cab Mon Sep 17 00:00:00 2001 From: Tleety Date: Thu, 11 Feb 2016 15:42:27 +0100 Subject: [PATCH 20/37] Removed commeted code --- src/Game/Systems/CapturePointHUDSystem.cpp | 236 +-------------------- 1 file changed, 3 insertions(+), 233 deletions(-) diff --git a/src/Game/Systems/CapturePointHUDSystem.cpp b/src/Game/Systems/CapturePointHUDSystem.cpp index c2d62c4b..784c7e16 100644 --- a/src/Game/Systems/CapturePointHUDSystem.cpp +++ b/src/Game/Systems/CapturePointHUDSystem.cpp @@ -4,10 +4,6 @@ CapturePointHUDSystem::CapturePointHUDSystem(SystemParams params) : System(params) , ImpureSystem() { - //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); } @@ -21,12 +17,12 @@ void CapturePointHUDSystem::Update(double dt) auto CapturePointHUDElements = m_World->GetComponents("CapturePointHUD"); auto CapturePoints = m_World->GetComponents("CapturePoint"); - for(auto& cCapturePointHUD : *CapturePointHUDElements) { + for (auto& cCapturePointHUD : *CapturePointHUDElements) { int HUD_ID = cCapturePointHUD["CapturePointNumber"]; EntityWrapper entityHUD = EntityWrapper(m_World, cCapturePointHUD.EntityID); EntityWrapper entityHUDparent = entityHUD.Parent(); - for(auto& cCapturePoint : *CapturePoints) { + for (auto& cCapturePoint : *CapturePoints) { EntityWrapper entityCP = EntityWrapper(m_World, cCapturePoint.EntityID); //Check if the HUD corresponds to the Capture Point Number @@ -53,230 +49,4 @@ void CapturePointHUDSystem::Update(double dt) } } } - - //if (m_WinnerWasFound) { - // return; - //} - //const int capturePointNumber = cCapturePoint["CapturePointNumber"]; - //const bool hasTeamComponent = capturePointEntity.HasComponent("Team"); - - ////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) { - // m_World->AttachComponent(cCapturePoint.EntityID, "Team"); - // ComponentWrapper& teamComponent = capturePointEntity["Team"]; - // teamComponent["Team"] = (int)teamComponent["Team"].Enum("Spectator"); - //} - //ComponentWrapper& teamComponent = capturePointEntity["Team"]; - //const int redTeam = (int)teamComponent["Team"].Enum("Red"); - //const int blueTeam = (int)teamComponent["Team"].Enum("Blue"); - //const int spectatorTeam = (int)teamComponent["Team"].Enum("Spectator"); - - //int homePointForTeam = (int)cCapturePoint["HomePointForTeam"]; - //if (m_NumberOfCapturePoints == 0 && capturePointNumber != 0 && (homePointForTeam == redTeam || homePointForTeam == blueTeam)) { - // m_NumberOfCapturePoints = capturePointNumber + 1;//ex 2 -> 0,1,2 = 3 - // if (homePointForTeam == redTeam) { - // m_RedTeamHomeCapturePoint = capturePointNumber; - // m_BlueTeamHomeCapturePoint = 0; - // } else { - // m_BlueTeamHomeCapturePoint = capturePointNumber; - // m_RedTeamHomeCapturePoint = 0; - // } - //} - - ////if we havent received all capturepoints yet, just return - //if (m_NumberOfCapturePoints == 0 || m_NumberOfCapturePoints != m_CapturePointNumberToEntityMap.size()) { - // m_CapturePointNumberToEntityMap.insert(std::make_pair(capturePointNumber, capturePointEntity)); - // return; - //} - - ////we have all capturepoints now - process stuff - //int ownedBy = teamComponent["Team"]; - //int redTeamPlayersStandingInside = 0; - //int blueTeamPlayersStandingInside = 0; - //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.2f, 1, 0.3) : ownedBy == redTeam ? glm::vec4(1, 0.2f, 0, 0.3) : glm::vec4(1, 1, 1, 0.3); - //} - - ////calculate next possible capturePoint for both teams - //std::map nextPossibleCapturePoint; - //nextPossibleCapturePoint["Red"] = -1; - //nextPossibleCapturePoint["Blue"] = -1; - //for (int i = 0; i < m_NumberOfCapturePoints; i++) - //{ - // if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) { - // continue; - // } - // ComponentWrapper& capturePointOwnedBy = m_CapturePointNumberToEntityMap[i]["Team"]; - // if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint == 0) { - // nextPossibleCapturePoint["Red"] = i + 1; - // } - // if ((int)capturePointOwnedBy["Team"] == blueTeam && m_BlueTeamHomeCapturePoint == 0) { - // nextPossibleCapturePoint["Blue"] = i + 1; - // } - //} - //for (int i = m_NumberOfCapturePoints - 1; i >= 0; i--) - //{ - // if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) { - // continue; - // } - // ComponentWrapper& capturePointOwnedBy = m_CapturePointNumberToEntityMap[i]["Team"]; - // if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint != 0) { - // nextPossibleCapturePoint["Red"] = i - 1; - // } - // if ((int)capturePointOwnedBy["Team"] == blueTeam && m_BlueTeamHomeCapturePoint != 0) { - // nextPossibleCapturePoint["Blue"] = i - 1; - // } - //} - - ////reset timers and reset the bool that triggers this - //if (m_ResetTimers) { - // 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"]) { - // capturePoint["CaptureTimer"] = 0.0; - // } - // } - // m_ResetTimers = false; - //} - - ////colorize next possible capturepoint - //if (nextPossibleCapturePoint["Red"] == capturePointNumber) { - // capturePointEntity["Model"]["Color"] = glm::vec4(1, 1, 0, 0.3); - //} - //if (nextPossibleCapturePoint["Blue"] == capturePointNumber) { - // capturePointEntity["Model"]["Color"] = glm::vec4(0, 1, 1, 0.3); - //} - - ////check how many players are standing inside and are healthy - //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 - // EntityWrapper player = std::get<0>(triggerTouched); - // //check if its really a player that has triggered the touch - // if (!player.HasComponent("Player")) { - // //if a non-player has entered the capturePoint, just erase that event and continue - // m_ETriggerTouchVector.erase(m_ETriggerTouchVector.begin() + i - 1); - // continue; - // } - // bool hasHealthComponent = player.HasComponent("Health"); - // if (hasHealthComponent) { - // double currentHealth = player["Health"]["Health"]; - // //check if player is dead - // if ((int)currentHealth == 0) { - // continue; - // } - // } - // //check team - spectatorNumber = "no team" - // int teamNumber = player["Team"]["Team"]; - // if (teamNumber == redTeam) { - // redTeamPlayersStandingInside++; - // } else if (teamNumber == blueTeam) { - // blueTeamPlayersStandingInside++; - // } - // continue; - // } - //} - - ////create data to be used in option B - ////check so this is the next possible capture point for the take-over team and see if only one team is standing inside it - //double timerDeltaChange = 0.0; - //int currentTeam = 0; - //bool canCapture = false; - //if (redTeamPlayersStandingInside > 0 && blueTeamPlayersStandingInside == 0) { - // timerDeltaChange = redTeamPlayersStandingInside*dt; - // currentTeam = redTeam; - // canCapture = nextPossibleCapturePoint["Red"] == capturePointNumber; - //} - //if (redTeamPlayersStandingInside == 0 && blueTeamPlayersStandingInside > 0) { - // timerDeltaChange = -blueTeamPlayersStandingInside*dt; - // currentTeam = blueTeam; - // canCapture = nextPossibleCapturePoint["Blue"] == capturePointNumber; - //} - - //if (redTeamPlayersStandingInside == 0 && blueTeamPlayersStandingInside == 0) { - // //A.nobodys standing inside - // //do nothing (?) - //} else if (redTeamPlayersStandingInside > 0 && blueTeamPlayersStandingInside > 0) { - // //C.both teams have players inside - // //do nothing (?) - //} else { - // //B. at most one of the teams have players inside - // //if capturePoint is not owned by the take-over team, just modify the CaptureTimer accordingly - // if (ownedBy != currentTeam && canCapture) { - // if (abs((double)cCapturePoint["CaptureTimer"]) < 0.001f) { - // LOG_DEBUG("Point is being captured by team %i", currentTeam); //Remove when we tested sufficiently. - // } - // 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)) { - // cCapturePoint["CaptureTimer"] = (double)cCapturePoint["CaptureTimer"] + timerDeltaChange; - // } - // //check if captureTimer > m_CaptureTimeToTakeOver and if so change owner and publish the eCaptured event - // if (abs((double)cCapturePoint["CaptureTimer"]) > abs(m_CaptureTimeToTakeOver) && canCapture) { - // teamComponent["Team"] = currentTeam; - // cCapturePoint["CaptureTimer"] = 0.0; - // //publish Captured event - // LOG_DEBUG("Point is captured by team %i!", currentTeam); //Remove when we tested sufficiently. - // Events::Captured e; - // e.CapturePointID = cCapturePoint.EntityID; - // e.TeamNumberThatCapturedCapturePoint = currentTeam; - // m_EventBroker->Publish(e); - // //NextPossibleCapturePoint will be calculated in the next update... - // } - //} - - ////check for possible winCondition = check if the homebase is owned by the other team - //bool checkForWinner = false; - //if (capturePointNumber == m_RedTeamHomeCapturePoint && ownedBy != redTeam) - //{ - // checkForWinner = true; - //} - //if (capturePointNumber == m_BlueTeamHomeCapturePoint && ownedBy != blueTeam) - //{ - // checkForWinner = true; - //} - - //if (checkForWinner && !m_WinnerWasFound) - //{ - // //publish Win event - // Events::Win e; - // e.TeamThatWon = ownedBy; - // m_EventBroker->Publish(e); - // m_WinnerWasFound = true; - //} - -} -// -//bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e) -//{ -// //personEntered = e.Entity, thingEntered = e.Trigger -// m_ETriggerTouchVector.push_back(std::make_tuple(e.Entity, e.Trigger)); -// return true; -//} -// -//bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e) -//{ -// 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); -// break; -// } -// } -// return true; -//} -//bool CapturePointSystem::OnCaptured(const Events::Captured& e) -//{ -// //reset the timers in the next update since a capture has changed the "nextCapturePoint" for 1-2 teams -// m_ResetTimers = true; -// return true; -//} +} \ No newline at end of file From 51e0b852d2ef4ddb785a43be8fc4ad864274c596 Mon Sep 17 00:00:00 2001 From: Tleety Date: Thu, 11 Feb 2016 15:43:41 +0100 Subject: [PATCH 21/37] Adamfix --- src/Engine/Rendering/DrawFinalPass.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 83bacd37..5e1d7f6e 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -626,8 +626,7 @@ void DrawFinalPass::DrawSprites(std::list>&jobs, Rend RenderState jobState; if (spriteJob) { - if(spriteJob->Depth == 0) - { + if(spriteJob->Depth == 0) { jobState.Disable(GL_DEPTH_TEST); } glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(spriteJob->Matrix)); From 4e23e7bf3097abd5ff60dbf1468dc89e435ff848 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Thu, 11 Feb 2016 15:58:58 +0100 Subject: [PATCH 22/37] misc changes do the DoubleJumpHexagon.xml --- resources/Schema/Entities/DoubleJumpHexagon.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/Schema/Entities/DoubleJumpHexagon.xml b/resources/Schema/Entities/DoubleJumpHexagon.xml index bbc41119..c1aaec34 100644 --- a/resources/Schema/Entities/DoubleJumpHexagon.xml +++ b/resources/Schema/Entities/DoubleJumpHexagon.xml @@ -3,8 +3,8 @@ - Models/JumpEffectHexagon.mesh - + Models/Effects/JumpEffectHexagon.mesh + true @@ -12,14 +12,14 @@ - 1.5 + 0.5 true true - 3 + 0.5 true From 1d14094e903ca7baa09263fcea33a52cb298232e Mon Sep 17 00:00:00 2001 From: antc13 Date: Thu, 11 Feb 2016 16:52:10 +0100 Subject: [PATCH 23/37] NewMap Updated. Still WIP --- assets | 2 +- resources/Schema/Entities/NewMap.xml | 422 ++++++++++++++++++++++----- 2 files changed, 353 insertions(+), 71 deletions(-) diff --git a/assets b/assets index c56f6380..66e2a73b 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit c56f6380ab05c23419beafe14190013d1432e32c +Subproject commit 66e2a73bdb2c385cac37476980809cc587e2e612 diff --git a/resources/Schema/Entities/NewMap.xml b/resources/Schema/Entities/NewMap.xml index 7a1d620b..f4c768f0 100644 --- a/resources/Schema/Entities/NewMap.xml +++ b/resources/Schema/Entities/NewMap.xml @@ -104,6 +104,100 @@ + + + + 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 + + + + + + + @@ -1436,12 +1530,117 @@ Models/Props/Bridges/SciFiBridge.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 + + + + + + + + + + + + + + @@ -1591,9 +1790,9 @@ Models/Props/Pillars/SciFiBridgePillar1.mesh - + - + @@ -2901,9 +3100,9 @@ Models/Props/PickUps/PickUpHolder.mesh - + - + @@ -3124,6 +3323,19 @@ + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + @@ -3135,106 +3347,176 @@ - - - - - + - Models/Props/CapturePoint.mesh - - true + Models/Props/CapturePoint/CapturePointBlue.mesh - - - - - - + - - + + + + + + + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + - - 1 - + - Models/Props/CapturePoint.mesh - - true + Models/Props/CapturePoint/CapturePointNeutral.mesh - - + - - + + + + + 1 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + - - 2 - + - Models/Props/CapturePoint.mesh - - true + Models/Props/CapturePoint/CapturePointNeutral.mesh - - + - - + + + + + 2 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + - - 3 - + - Models/Props/CapturePoint.mesh - - true + Models/Props/CapturePoint/CapturePointNeutral.mesh - - + - - + + + + + 3 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + - - - - - 4 - + - Models/Props/CapturePoint.mesh - - true + Models/Props/CapturePoint/CapturePointNeutral.mesh - - - - - - + - - + + + + + + + + 4 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + From e47201ff6108627fc7997bf7aa5e22f2658b70d8 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 11 Feb 2016 17:06:34 +0100 Subject: [PATCH 24/37] First person shoot animations --- .../Systems/Weapon/AssaultWeaponBehaviour.h | 34 ++++ include/Game/Systems/Weapon/WeaponBehaviour.h | 31 +++ include/Game/Systems/Weapon/WeaponSystem.h | 46 +++++ include/Game/Systems/WeaponSystem.h | 192 ------------------ resources/Schema/Components/AssaultWeapon.xml | 1 + resources/Schema/Components/AssaultWeapon.xsd | 3 + resources/Schema/Components/Player.xml | 1 + resources/Schema/Components/Player.xsd | 3 +- src/Engine/Rendering/AnimationSystem.cpp | 21 +- src/Game/CMakeLists.txt | 7 + src/Game/Game.cpp | 2 +- src/Game/Systems/PlayerMovementSystem.cpp | 3 +- .../Systems/Weapon/AssaultWeaponBehaviour.cpp | 190 +++++++++++++++++ .../Systems/{ => Weapon}/WeaponSystem.cpp | 5 +- 14 files changed, 338 insertions(+), 201 deletions(-) create mode 100644 include/Game/Systems/Weapon/AssaultWeaponBehaviour.h create mode 100644 include/Game/Systems/Weapon/WeaponBehaviour.h create mode 100644 include/Game/Systems/Weapon/WeaponSystem.h delete mode 100644 include/Game/Systems/WeaponSystem.h create mode 100644 src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp rename src/Game/Systems/{ => Weapon}/WeaponSystem.cpp (97%) diff --git a/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h b/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h new file mode 100644 index 00000000..58d7755f --- /dev/null +++ b/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h @@ -0,0 +1,34 @@ +#include "Sound/EPlaySoundOnEntity.h" +#include "Rendering/AnimationSystem.h" +#include "WeaponBehaviour.h" +#include "../SpawnerSystem.h" + +class AssaultWeaponBehaviour : public WeaponBehaviour +{ +public: + AssaultWeaponBehaviour(SystemParams systemParams, Octree* collisionOctree, EntityWrapper weaponEntity); + + virtual void Fire() override; + virtual void CeaseFire() override; + virtual void Reload() override; + + virtual void Update(double dt) override; + +private: + EntityWrapper m_FirstPersonModel; + // State + bool m_Firing = false; + bool m_Reloading = false; + double m_TimeSinceLastFire = 0.0; + + EventRelay m_EAnimationComplete; + bool OnAnimationComplete(Events::AnimationComplete& e); + + void fireRound(); + void spawnTracer(); + float traceRayDistance(glm::vec3 origin, glm::vec3 direction); + void playSound(); + void viewPunch(); + void playShootAnimation(); + void playIdleAnimation(); +}; diff --git a/include/Game/Systems/Weapon/WeaponBehaviour.h b/include/Game/Systems/Weapon/WeaponBehaviour.h new file mode 100644 index 00000000..38ab5f58 --- /dev/null +++ b/include/Game/Systems/Weapon/WeaponBehaviour.h @@ -0,0 +1,31 @@ +#ifndef WeaponBehaviour_h__ +#define WeaponBehaviour_h__ + +#include "Core/System.h" +#include "Core/Octree.h" +#include "Collision/EntityAABB.h" + +class WeaponBehaviour : public System +{ +public: + WeaponBehaviour(SystemParams systemParams, Octree* collisionOctree, EntityWrapper weaponEntity) + : System(systemParams) + , m_CollisionOctree(collisionOctree) + , m_Entity(weaponEntity) + { } + 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) { } + +protected: + Octree* m_CollisionOctree; + EntityWrapper m_Entity; +}; + +#endif diff --git a/include/Game/Systems/Weapon/WeaponSystem.h b/include/Game/Systems/Weapon/WeaponSystem.h new file mode 100644 index 00000000..68cf2ef3 --- /dev/null +++ b/include/Game/Systems/Weapon/WeaponSystem.h @@ -0,0 +1,46 @@ +#ifndef WeaponSystem_h__ +#define WeaponSystem_h__ + +#include "Rendering/IRenderer.h" + +#include "Common.h" +#include "Core/System.h" +#include "Core/EPlayerDamage.h" +#include "Core/EShoot.h" +#include "Core/EPlayerSpawned.h" +#include "Input/EInputCommand.h" +#include "Core/EntityFile.h" +#include "Core/EntityFileParser.h" +#include "Core/Octree.h" +#include "Collision/EntityAABB.h" +#include "Systems/SpawnerSystem.h" +#include "Sound/EPlaySoundOnEntity.h" +#include "AssaultWeaponBehaviour.h" + +class WeaponSystem : public PureSystem, ImpureSystem +{ +public: + WeaponSystem(SystemParams params, IRenderer* renderer, Octree* collisionOctree); + + virtual void Update(double dt) override; + virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cPlayer, double dt) override; + +private: + SystemParams m_SystemParams; + IRenderer* m_Renderer; + Octree* m_CollisionOctree; + + std::unordered_map> m_ActiveWeapons; + + // Events + EventRelay m_EPlayerSpawned; + bool OnPlayerSpawned(Events::PlayerSpawned& e); + EventRelay m_EShoot; + bool OnShoot(Events::Shoot& e); + EventRelay m_EInputCommand; + bool OnInputCommand(Events::InputCommand& e); + + void selectWeapon(EntityWrapper player, ComponentInfo::EnumType slot); +}; + +#endif \ No newline at end of file diff --git a/include/Game/Systems/WeaponSystem.h b/include/Game/Systems/WeaponSystem.h deleted file mode 100644 index b118b8cd..00000000 --- a/include/Game/Systems/WeaponSystem.h +++ /dev/null @@ -1,192 +0,0 @@ -#ifndef WeaponSystem_h__ -#define WeaponSystem_h__ - -//#include -//#include -#include "Rendering/IRenderer.h" - -#include "Common.h" -#include "Core/System.h" -#include "Core/EPlayerDamage.h" -#include "Core/EShoot.h" -#include "Core/EPlayerSpawned.h" -#include "Input/EInputCommand.h" -#include "Core/EntityFile.h" -#include "Core/EntityFileParser.h" -#include "Core/Octree.h" -#include "Collision/EntityAABB.h" -#include "Systems/SpawnerSystem.h" -#include "Sound/EPlaySoundOnEntity.h" - -class WeaponBehaviour; - -class WeaponSystem : public PureSystem, ImpureSystem -{ -public: - WeaponSystem(SystemParams params, IRenderer* renderer, Octree* collisionOctree); - - virtual void Update(double dt) override; - virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cPlayer, double dt) override; - -private: - SystemParams m_SystemParams; - IRenderer* m_Renderer; - Octree* m_CollisionOctree; - - std::unordered_map> m_ActiveWeapons; - - // Events - EventRelay m_EPlayerSpawned; - bool OnPlayerSpawned(Events::PlayerSpawned& e); - EventRelay m_EShoot; - bool OnShoot(Events::Shoot& e); - EventRelay m_EInputCommand; - bool OnInputCommand(Events::InputCommand& e); - - void selectWeapon(EntityWrapper player, ComponentInfo::EnumType slot); -}; - -class WeaponBehaviour : public System -{ -public: - WeaponBehaviour(SystemParams systemParams, Octree* collisionOctree, EntityWrapper weaponEntity) - : System(systemParams) - , m_CollisionOctree(collisionOctree) - , m_Entity(weaponEntity) - { } - 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) { } - -protected: - Octree* m_CollisionOctree; - EntityWrapper m_Entity; -}; - -class AssaultWeaponBehaviour : public WeaponBehaviour -{ -public: - AssaultWeaponBehaviour(SystemParams systemParams, Octree* collisionOctree, EntityWrapper weaponEntity) - : WeaponBehaviour(systemParams, collisionOctree, weaponEntity) - { } - - virtual void Fire() override - { - m_TimeSinceLastFire = 0.0; - m_Firing = true; - fireRound(); - } - - virtual void CeaseFire() override - { - m_Firing = false; - } - - virtual void Reload() override - { - ComponentWrapper& cAssaultWeapon = m_Entity["AssaultWeapon"]; - - int& magAmmo = cAssaultWeapon["MagazineAmmo"]; - int magSize = cAssaultWeapon["MagazineSize"]; - int& ammo = cAssaultWeapon["Ammo"]; - - // Don't reload if we're already fully loaded - if (magAmmo == magSize) { - return; - } - - // Throw away rounds in magazine to incentivise ammo sharing - int toLoad = glm::min(magSize, ammo); - magAmmo = toLoad; - ammo -= toLoad; - } - - virtual void Update(double dt) override - { - if (!m_Firing) { - return; - } - - m_TimeSinceLastFire += dt; - - ComponentWrapper& cAssaultWeapon = m_Entity["AssaultWeapon"]; - if (m_TimeSinceLastFire >= 1.0 / ((double)cAssaultWeapon["RPM"] / 60.0)) { - fireRound(); - } - } - -private: - bool m_Firing = false; - double m_TimeSinceLastFire = 0.0; - EntityFile* m_RayRed = nullptr; - EntityFile* m_RayBlue = nullptr; - - void fireRound() - { - ComponentWrapper& cAssaultWeapon = m_Entity["AssaultWeapon"]; - - int& magAmmo = cAssaultWeapon["MagazineAmmo"]; - int ammo = cAssaultWeapon["Ammo"]; - - // Reload if our magazine is empty - if (magAmmo <= 0) { - Reload(); - return; - } - - // Fire - magAmmo -= 1; - spawnTracer(); - playSound(); - - m_TimeSinceLastFire = 0.0; - } - - void spawnTracer() - { - if (!IsClient) { - return; - } - - EntityWrapper spawner; - if (m_Entity == LocalPlayer) { - spawner = m_Entity.FirstChildByName("WeaponMuzzle"); - } else { - spawner = m_Entity.FirstChildByName("ThirdPersonWeaponMuzzle"); - } - - if (!spawner.Valid()) { - return; - } - - Events::SpawnerSpawn e; - e.Spawner = spawner; - m_EventBroker->Publish(e); - } - - float traceRayDistance(glm::vec3 origin, glm::vec3 direction) - { - // TODO: Cast a ray and size tracer appropriately - return 100.f; - } - - void playSound() - { - if (!IsClient) { - return; - } - - Events::PlaySoundOnEntity e; - e.EmitterID = m_Entity.ID; - e.FilePath = "Audio/laser/laser1.wav"; - m_EventBroker->Publish(e); - } -}; - -#endif \ No newline at end of file diff --git a/resources/Schema/Components/AssaultWeapon.xml b/resources/Schema/Components/AssaultWeapon.xml index 902795c1..c7dbfb0d 100755 --- a/resources/Schema/Components/AssaultWeapon.xml +++ b/resources/Schema/Components/AssaultWeapon.xml @@ -6,4 +6,5 @@ 360 5 120 + 0.01 \ No newline at end of file diff --git a/resources/Schema/Components/AssaultWeapon.xsd b/resources/Schema/Components/AssaultWeapon.xsd index 1b2704ea..65558db5 100755 --- a/resources/Schema/Components/AssaultWeapon.xsd +++ b/resources/Schema/Components/AssaultWeapon.xsd @@ -22,6 +22,9 @@ Rate of fire in rounds per minute + + View punch in radians for each bullet fired + diff --git a/resources/Schema/Components/Player.xml b/resources/Schema/Components/Player.xml index b51326aa..00cff257 100644 --- a/resources/Schema/Components/Player.xml +++ b/resources/Schema/Components/Player.xml @@ -2,4 +2,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 13948dc2..1b33d222 100644 --- a/resources/Schema/Components/Player.xsd +++ b/resources/Schema/Components/Player.xsd @@ -5,12 +5,13 @@ - The player charachter + The player entity + diff --git a/src/Engine/Rendering/AnimationSystem.cpp b/src/Engine/Rendering/AnimationSystem.cpp index 48681e6e..d5b5984d 100644 --- a/src/Engine/Rendering/AnimationSystem.cpp +++ b/src/Engine/Rendering/AnimationSystem.cpp @@ -34,19 +34,32 @@ void AnimationSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& a if (!(bool)animationComponent["Loop" + std::to_string(i)]) { if (nextTime > animation->Duration) { nextTime = animation->Duration; + Events::AnimationComplete e; + e.Entity = entity; + e.Name = (std::string)animationComponent["AnimationName" + std::to_string(i)]; + m_EventBroker->Publish(e); } 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 = 0; } (double&)animationComponent["Speed" + std::to_string(i)] = 0.0; - Events::AnimationComplete e; - e.Entity = entity; - e.Name = (std::string)animationComponent["AnimationName" + std::to_string(i)]; - m_EventBroker->Publish(e); + } else { if (nextTime > animation->Duration) { + Events::AnimationComplete e; + e.Entity = entity; + e.Name = (std::string)animationComponent["AnimationName" + std::to_string(i)]; + m_EventBroker->Publish(e); 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; } } diff --git a/src/Game/CMakeLists.txt b/src/Game/CMakeLists.txt index db923364..f188d7fa 100644 --- a/src/Game/CMakeLists.txt +++ b/src/Game/CMakeLists.txt @@ -16,6 +16,12 @@ file(GLOB SOURCE_FILES_Systems ) source_group(Systems FILES ${SOURCE_FILES_Systems}) +file(GLOB SOURCE_FILES_Systems_Weapon + "${INCLUDE_PATH}/Systems/Weapon/*.h" + "Systems/Weapon/*.cpp" +) +source_group(Systems\\Weapon FILES ${SOURCE_FILES_Systems_Weapon}) + file(GLOB SOURCE_FILES_Events "${INCLUDE_PATH}/Events/*.h" "Events/*.cpp" @@ -31,6 +37,7 @@ set(SOURCE_FILES ${SOURCE_FILES} "Game.cpp" ${SOURCE_FILES_Systems} + ${SOURCE_FILES_Systems_Weapon} ${SOURCE_FILES_Events} ${SOURCE_FILES_Network} ) diff --git a/src/Game/Game.cpp b/src/Game/Game.cpp index 6057d463..cf14fc76 100644 --- a/src/Game/Game.cpp +++ b/src/Game/Game.cpp @@ -13,7 +13,7 @@ #include "Core/EntityFileWriter.h" #include "Game/Systems/CapturePointSystem.h" #include "Game/Systems/PickupSpawnSystem.h" -#include "Game/Systems/WeaponSystem.h" +#include "Game/Systems/Weapon/WeaponSystem.h" #include "Rendering/AnimationSystem.h" #include "Game/Systems/PlayerHUDSystem.h" #include "Rendering/BoneAttachmentSystem.h" diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 7c69f0ce..65f7c302 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -51,6 +51,7 @@ void PlayerMovementSystem::updateMovementControllers(double dt) float playerMovementSpeed = player["Player"]["MovementSpeed"]; float playerCrouchSpeed = player["Player"]["CrouchSpeed"]; + glm::vec3& wishDirection = player["Player"]["CurrentWishDirection"]; if (player.HasComponent("Physics")) { ComponentWrapper cPhysics = player["Physics"]; @@ -58,7 +59,7 @@ void PlayerMovementSystem::updateMovementControllers(double dt) if (player.HasComponent("DashAbility")) { controller->AssaultDashCheck(dt, ((glm::vec3)cPhysics["Velocity"]).y != 0.0f, player["DashAbility"]["CoolDownMaxTimer"]); } - glm::vec3 wishDirection = controller->Movement() * glm::inverse(glm::quat(ori)); + wishDirection = controller->Movement() * glm::inverse(glm::quat(ori)); //this makes sure you can only dash in the 4 directions: forw,backw,left,right if (controller->AssaultDashDoubleTapped() && controller->Movement().z != 0 && controller->Movement().x != 0) { wishDirection = glm::vec3(controller->Movement().x, 0, 0)* glm::inverse(glm::quat(ori)); diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp new file mode 100644 index 00000000..bb5a025f --- /dev/null +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -0,0 +1,190 @@ +#include "Systems/Weapon/AssaultWeaponBehaviour.h" + +AssaultWeaponBehaviour::AssaultWeaponBehaviour(SystemParams systemParams, Octree* collisionOctree, EntityWrapper weaponEntity) + : WeaponBehaviour(systemParams, collisionOctree, weaponEntity) +{ + m_FirstPersonModel = m_Entity.FirstChildByName("Hands"); + EVENT_SUBSCRIBE_MEMBER(m_EAnimationComplete, &AssaultWeaponBehaviour::OnAnimationComplete); +} + +void AssaultWeaponBehaviour::Fire() +{ + m_TimeSinceLastFire = 0.0; + m_Firing = true; + fireRound(); + playShootAnimation(); +} + +void AssaultWeaponBehaviour::CeaseFire() +{ + m_Firing = false; +} + +void AssaultWeaponBehaviour::Reload() +{ + ComponentWrapper& cAssaultWeapon = m_Entity["AssaultWeapon"]; + + int& magAmmo = cAssaultWeapon["MagazineAmmo"]; + int magSize = cAssaultWeapon["MagazineSize"]; + int& ammo = cAssaultWeapon["Ammo"]; + + // Don't reload if we're already fully loaded + if (magAmmo == magSize) { + return; + } + + // Throw away rounds in magazine to incentivise ammo sharing + int toLoad = glm::min(magSize, ammo); + magAmmo = toLoad; + ammo -= toLoad; +} + +void AssaultWeaponBehaviour::Update(double dt) +{ + if (m_Firing) { + m_TimeSinceLastFire += dt; + + ComponentWrapper& cAssaultWeapon = m_Entity["AssaultWeapon"]; + if (m_TimeSinceLastFire >= 1.0 / ((double)cAssaultWeapon["RPM"] / 60.0)) { + fireRound(); + } + } + + if (!m_Firing && !m_Reloading) { + playIdleAnimation(); + } +} + +bool AssaultWeaponBehaviour::OnAnimationComplete(Events::AnimationComplete& e) +{ + if (e.Entity != m_FirstPersonModel) { + return false; + } + + //if (e.Name == "ShootRifle") { + // if (!m_Firing) { + // playIdleAnimation(); + // } + //} + + return true; +} + +void AssaultWeaponBehaviour::fireRound() +{ + ComponentWrapper& cAssaultWeapon = m_Entity["AssaultWeapon"]; + + int& magAmmo = cAssaultWeapon["MagazineAmmo"]; + int ammo = cAssaultWeapon["Ammo"]; + + // Reload if our magazine is empty + if (magAmmo <= 0) { + Reload(); + return; + } + + // Fire + magAmmo -= 1; + spawnTracer(); + playSound(); + viewPunch(); + + m_TimeSinceLastFire = 0.0; +} + +void AssaultWeaponBehaviour::spawnTracer() +{ + if (!IsClient) { + return; + } + + EntityWrapper spawner; + if (m_Entity == LocalPlayer) { + spawner = m_Entity.FirstChildByName("WeaponMuzzle"); + } else { + spawner = m_Entity.FirstChildByName("ThirdPersonWeaponMuzzle"); + } + + if (!spawner.Valid()) { + return; + } + + Events::SpawnerSpawn e; + e.Spawner = spawner; + m_EventBroker->Publish(e); +} + +float AssaultWeaponBehaviour::traceRayDistance(glm::vec3 origin, glm::vec3 direction) +{ + // TODO: Cast a ray and size tracer appropriately + return 100.f; +} + +void AssaultWeaponBehaviour::playSound() +{ + if (!IsClient) { + return; + } + + Events::PlaySoundOnEntity e; + e.EmitterID = m_Entity.ID; + e.FilePath = "Audio/laser/laser1.wav"; + m_EventBroker->Publish(e); +} + +void AssaultWeaponBehaviour::viewPunch() +{ + EntityWrapper playerCamera = m_Entity.FirstChildByName("Camera"); + if (!playerCamera.Valid()) { + return; + } + float viewPunch = m_Entity["AssaultWeapon"]["ViewPunch"]; + ComponentWrapper cTransform = playerCamera["Transform"]; + glm::vec3& orientation = cTransform["Orientation"]; + orientation.x += viewPunch; +} + +void AssaultWeaponBehaviour::playShootAnimation() +{ + EntityWrapper firstPersonWeapon = m_Entity.FirstChildByName("Hands"); + ComponentWrapper cAnimation = firstPersonWeapon["Animation"]; + cAnimation["AnimationName1"] = "ShootRifle"; + cAnimation["Weight1"] = 1.0; + cAnimation["Time1"] = 0.0; + cAnimation["Speed1"] = 1.0; + cAnimation["Loop1"] = true; +} + +void AssaultWeaponBehaviour::playIdleAnimation() +{ + if (!m_FirstPersonModel.Valid()) { + return; + } + + ComponentWrapper cAnimation = m_FirstPersonModel["Animation"]; + std::string& animationName1 = cAnimation["AnimationName1"]; + double& animationSpeed1 = cAnimation["Speed1"]; + + std::string animationToPlay = "Idle"; + double speedToSet = 1.0; + + ComponentWrapper cPlayer = m_Entity["Player"]; + glm::vec3 movementDirection = cPlayer["CurrentWishDirection"]; + if (glm::length2(movementDirection) > 0) { + animationToPlay = "Run"; + ComponentWrapper cPhysics = m_Entity["Physics"]; + speedToSet = glm::length((glm::vec3)cPhysics["Velocity"]) / (float)cPlayer["MovementSpeed"]; + } + + if (animationName1 != animationToPlay) { + cAnimation["AnimationName1"] = animationToPlay; + cAnimation["Weight1"] = 1.0; + cAnimation["Time1"] = 0.0; + cAnimation["Loop1"] = true; + } + + if (animationSpeed1 != speedToSet) { + cAnimation["Speed1"] = speedToSet; + } +} + diff --git a/src/Game/Systems/WeaponSystem.cpp b/src/Game/Systems/Weapon/WeaponSystem.cpp similarity index 97% rename from src/Game/Systems/WeaponSystem.cpp rename to src/Game/Systems/Weapon/WeaponSystem.cpp index eeb7dd00..bdd27ea9 100644 --- a/src/Game/Systems/WeaponSystem.cpp +++ b/src/Game/Systems/Weapon/WeaponSystem.cpp @@ -1,4 +1,4 @@ -#include "Systems/WeaponSystem.h" +#include "Systems/Weapon/WeaponSystem.h" WeaponSystem::WeaponSystem(SystemParams params, IRenderer* renderer, Octree* collisionOctree) : System(params) @@ -24,7 +24,8 @@ void WeaponSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cPla if (it == m_ActiveWeapons.end()) { selectWeapon(entity, 1); } - + + m_EventBroker->Process(); m_ActiveWeapons.at(entity)->Update(dt); } From 6caa7e94a4945cfd7bf2944cfe0bb8b515a6a701 Mon Sep 17 00:00:00 2001 From: Teejoon Date: Thu, 11 Feb 2016 18:28:33 +0100 Subject: [PATCH 25/37] RGB is now the only channels thats beeing usesed in splatmap --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index c56f6380..0107c7df 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit c56f6380ab05c23419beafe14190013d1432e32c +Subproject commit 0107c7dfdfd02bc4966b35ed6ee0f0f3e366f23d From f088aa1d85d82bbc78a50006a6effc19c7330bfa Mon Sep 17 00:00:00 2001 From: Teejoon Date: Thu, 11 Feb 2016 18:45:48 +0100 Subject: [PATCH 26/37] Commit the files now.... --- .../Shaders/ForwardPlusSplatMapRGB.frag.glsl | 245 ++++++++++++++++++ src/Engine/Rendering/DrawFinalPass.cpp | 16 +- 2 files changed, 253 insertions(+), 8 deletions(-) create mode 100644 resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl diff --git a/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl b/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl new file mode 100644 index 00000000..e862d926 --- /dev/null +++ b/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl @@ -0,0 +1,245 @@ +#version 430 + +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; + +//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 SplatMapTexture; +layout (binding = 1) uniform sampler2D DiffuseTexture1; +layout (binding = 2) uniform sampler2D DiffuseTexture2; +layout (binding = 3) uniform sampler2D DiffuseTexture3; +layout (binding = 4) uniform sampler2D NormalMapTexture1; +layout (binding = 5) uniform sampler2D NormalMapTexture2; +layout (binding = 6) uniform sampler2D NormalMapTexture3; +layout (binding = 7) uniform sampler2D SpecularMapTexture1; +layout (binding = 8) uniform sampler2D SpecularMapTexture2; +layout (binding = 9) uniform sampler2D SpecularMapTexture3; +layout (binding = 10) uniform sampler2D GlowMapTexture1; +layout (binding = 11) uniform sampler2D GlowMapTexture2; +layout (binding = 12) uniform sampler2D GlowMapTexture3; + +#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() +{ + 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, 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 += light_result.Diffuse; + totalLighting.Specular += light_result.Specular; + } + + 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/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 0d08b98f..bd57df3a 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -81,7 +81,7 @@ void DrawFinalPass::InitializeShaderPrograms() 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/ForwardPlusSplatMap.frag.glsl"))); + m_ForwardPlusSplatMapProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/ForwardPlusSplatMapRGB.frag.glsl"))); m_ForwardPlusSplatMapProgram->Compile(); m_ForwardPlusSplatMapProgram->BindFragDataLocation(0, "sceneColor"); m_ForwardPlusSplatMapProgram->BindFragDataLocation(1, "bloomColor"); @@ -91,7 +91,7 @@ void DrawFinalPass::InitializeShaderPrograms() m_ExplosionEffectSplatMapProgram = ResourceManager::Load("#ExplosionEffectSplatMapProgram"); m_ExplosionEffectSplatMapProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/ForwardPlus.vert.glsl"))); m_ExplosionEffectSplatMapProgram->AddShader(std::shared_ptr(new GeometryShader("Shaders/ExplosionEffect.geom.glsl"))); - m_ExplosionEffectSplatMapProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/ForwardPlusSplatMap.frag.glsl"))); + m_ExplosionEffectSplatMapProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/ForwardPlusSplatMapRGB.frag.glsl"))); m_ExplosionEffectSplatMapProgram->Compile(); m_ExplosionEffectSplatMapProgram->BindFragDataLocation(0, "sceneColor"); m_ExplosionEffectSplatMapProgram->BindFragDataLocation(1, "bloomColor"); @@ -119,7 +119,7 @@ void DrawFinalPass::InitializeShaderPrograms() m_ExplosionEffectSplatMapSkinnedProgram = ResourceManager::Load("#ExplosionEffectSplatMapSkinnedProgram"); m_ExplosionEffectSplatMapSkinnedProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/ForwardPlusSkinned.vert.glsl"))); - m_ExplosionEffectSplatMapSkinnedProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/ForwardPlusSplatMap.frag.glsl"))); + m_ExplosionEffectSplatMapSkinnedProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/ForwardPlusSplatMapRGB.frag.glsl"))); m_ExplosionEffectSplatMapSkinnedProgram->Compile(); m_ExplosionEffectSplatMapSkinnedProgram->BindFragDataLocation(0, "sceneColor"); m_ExplosionEffectSplatMapSkinnedProgram->BindFragDataLocation(1, "bloomColor"); @@ -128,7 +128,7 @@ void DrawFinalPass::InitializeShaderPrograms() m_ForwardPlusSplatMapSkinnedProgram = ResourceManager::Load("#ForwardPlusSplatMapSkinnedProgram"); m_ForwardPlusSplatMapSkinnedProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/ForwardPlusSkinned.vert.glsl"))); - m_ForwardPlusSplatMapSkinnedProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/ForwardPlusSplatMap.frag.glsl"))); + m_ForwardPlusSplatMapSkinnedProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/ForwardPlusSplatMapRGB.frag.glsl"))); m_ForwardPlusSplatMapSkinnedProgram->Compile(); m_ForwardPlusSplatMapSkinnedProgram->BindFragDataLocation(0, "sceneColor"); m_ForwardPlusSplatMapSkinnedProgram->BindFragDataLocation(1, "bloomColor"); @@ -892,7 +892,7 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptrDiffuseTexture.size() > i && job->DiffuseTexture[i]->Texture != nullptr) { glBindTexture(GL_TEXTURE_2D, job->DiffuseTexture[i]->Texture->m_Texture); @@ -906,7 +906,7 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptrNormalTexture.size() > i && job->NormalTexture[i]->Texture != nullptr) { glBindTexture(GL_TEXTURE_2D, job->NormalTexture[i]->Texture->m_Texture); @@ -920,7 +920,7 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptrSpecularTexture.size() > i && job->SpecularTexture[i]->Texture != nullptr) { glBindTexture(GL_TEXTURE_2D, job->SpecularTexture[i]->Texture->m_Texture); @@ -934,7 +934,7 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptrIncandescenceTexture.size() > i && job->IncandescenceTexture[i]->Texture != nullptr) { glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture[i]->Texture->m_Texture); From 99747c518efec59e8270caf5b410fcdc915be44a Mon Sep 17 00:00:00 2001 From: Teejoon Date: Thu, 11 Feb 2016 18:48:07 +0100 Subject: [PATCH 27/37] commit assets --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 66e2a73b..105b22fc 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 66e2a73bdb2c385cac37476980809cc587e2e612 +Subproject commit 105b22fc67b68993db43deec3250084ed625d893 From f79649cf9a5a80eed6699581342d34516a12172d Mon Sep 17 00:00:00 2001 From: Teejoon Date: Thu, 11 Feb 2016 19:38:43 +0100 Subject: [PATCH 28/37] Fixed material file reading bug --- src/Engine/Rendering/RawModelCustom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Engine/Rendering/RawModelCustom.cpp b/src/Engine/Rendering/RawModelCustom.cpp index 4ebf80b6..dd6a96de 100644 --- a/src/Engine/Rendering/RawModelCustom.cpp +++ b/src/Engine/Rendering/RawModelCustom.cpp @@ -277,8 +277,8 @@ void RawModelCustom::ReadMaterialTextureProperties(RawModelCustom::TextureProper throw Resource::FailedLoadingException("Reading Material texture UVTiling failed"); } memcpy(&texture.UVRepeat[0], fileData + offset, sizeof(glm::vec2)); - offset += sizeof(glm::vec2); } + offset += sizeof(glm::vec2); } void RawModelCustom::ReadAnimationFile(std::string filePath) From fee1ed6d6d4e65e51403b5da162900c5a82fb624 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 11 Feb 2016 20:00:59 +0100 Subject: [PATCH 29/37] FIXME: Temporarily removed glow from sprite shader to prevent transparent sprite from occluding other glow --- resources/Shaders/Sprite.frag.glsl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/Shaders/Sprite.frag.glsl b/resources/Shaders/Sprite.frag.glsl index a1ff3025..9ce2bbdf 100644 --- a/resources/Shaders/Sprite.frag.glsl +++ b/resources/Shaders/Sprite.frag.glsl @@ -34,7 +34,8 @@ void main() } 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(clamp((glowTexel.xyz*3) - 1.0, 0, 100), 1.0); + bloomColor = vec4(1.0, 1.0, 1.0, 0.0); } From 5e05e51309d2eae3434c0d368710b2bec776aa71 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 11 Feb 2016 20:01:23 +0100 Subject: [PATCH 30/37] Fixed EntityFirstHitByRay not returning outDistance properly --- include/Engine/Collision/Collision.h | 4 ++-- src/Engine/Collision/Collision.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/Engine/Collision/Collision.h b/include/Engine/Collision/Collision.h index 5b4150d8..546d03f5 100644 --- a/include/Engine/Collision/Collision.h +++ b/include/Engine/Collision/Collision.h @@ -90,10 +90,10 @@ boost::optional AbsoluteAABBExplosionEffect(EntityWrapper& entity); //Returns the first entity hit by the input ray. entitiesPotentiallyHitSorted needs to be sorted //by their distance to the ray, e.g. result from Octree::ObjectsPossiblyHitByRay. //Returns boost::none if none was hit. outDistance will be the distance to the intersection point if the ray intersects. -boost::optional EntityFirstHitByRay(const Ray& ray, std::vector entitiesPotentiallyHitSorted, float outDistance, glm::vec3& outIntersectPos); +boost::optional EntityFirstHitByRay(const Ray& ray, std::vector entitiesPotentiallyHitSorted, float& outDistance, glm::vec3& outIntersectPos); //Returns the first entity hit by the input ray that exists in the octree. //outDistance will be the distance to the intersection point if the ray intersects. -boost::optional EntityFirstHitByRay(const Ray& ray, Octree* octree, float outDistance, glm::vec3& outIntersectPos); +boost::optional EntityFirstHitByRay(const Ray& ray, Octree* octree, float& outDistance, glm::vec3& outIntersectPos); } diff --git a/src/Engine/Collision/Collision.cpp b/src/Engine/Collision/Collision.cpp index 7b182de1..ab2098b7 100644 --- a/src/Engine/Collision/Collision.cpp +++ b/src/Engine/Collision/Collision.cpp @@ -642,7 +642,7 @@ boost::optional AbsoluteAABBExplosionEffect(EntityWrapper& entity) return aabb; } -boost::optional EntityFirstHitByRay(const Ray& ray, std::vector entitiesPotentiallyHitSorted, float outDistance, glm::vec3& outIntersectPos) +boost::optional EntityFirstHitByRay(const Ray& ray, std::vector entitiesPotentiallyHitSorted, float& outDistance, glm::vec3& outIntersectPos) { for (EntityAABB& entityBox : entitiesPotentiallyHitSorted) { if (!entityBox.Entity.HasComponent("Model")) { @@ -667,7 +667,7 @@ boost::optional EntityFirstHitByRay(const Ray& ray, std::vector EntityFirstHitByRay(const Ray& ray, Octree* octree, float outDistance, glm::vec3& outIntersectPos) +boost::optional EntityFirstHitByRay(const Ray& ray, Octree* octree, float& outDistance, glm::vec3& outIntersectPos) { std::vector outObjects; octree->ObjectsPossiblyHitByRay(ray, outObjects); From 8f500965d481a2621a8f4a9e5d8536f5938d9d92 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Thu, 11 Feb 2016 20:34:25 +0100 Subject: [PATCH 31/37] Changed DamageIndicator.xml to not use a glowmap and not a depthsort. --- include/Game/Systems/DamageIndicatorSystem.h | 5 ++++- resources/Schema/Entities/DamageIndicator.xml | 5 +++-- resources/Schema/Entities/DamageIndicatorTest.xml | 8 ++------ src/Game/Systems/CapturePointHUDSystem.cpp | 3 +++ src/Game/Systems/DamageIndicatorSystem.cpp | 10 +++++++--- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/include/Game/Systems/DamageIndicatorSystem.h b/include/Game/Systems/DamageIndicatorSystem.h index fd3ba33f..e70a69a9 100644 --- a/include/Game/Systems/DamageIndicatorSystem.h +++ b/include/Game/Systems/DamageIndicatorSystem.h @@ -13,10 +13,12 @@ #include #include +#include "Rendering/Util/CommonFunctions.h" + class DamageIndicatorSystem : public System { public: - DamageIndicatorSystem(World* world, EventBroker* eventBroker); + DamageIndicatorSystem(SystemParams params); private: EventRelay m_DamageTakenFromPlayer; @@ -26,5 +28,6 @@ private: bool OnSetCamera(const Events::SetCamera& e); EntityID m_CurrentCamera = -1; + }; #endif diff --git a/resources/Schema/Entities/DamageIndicator.xml b/resources/Schema/Entities/DamageIndicator.xml index 2d02443c..3e9e4fef 100644 --- a/resources/Schema/Entities/DamageIndicator.xml +++ b/resources/Schema/Entities/DamageIndicator.xml @@ -3,8 +3,9 @@ - Textures/TempDamageIndicator.png - Textures/TempDamageIndicator.png + Textures/DamageIndicator.png + + false diff --git a/resources/Schema/Entities/DamageIndicatorTest.xml b/resources/Schema/Entities/DamageIndicatorTest.xml index ee68da96..1155ddd5 100644 --- a/resources/Schema/Entities/DamageIndicatorTest.xml +++ b/resources/Schema/Entities/DamageIndicatorTest.xml @@ -382,14 +382,10 @@ - - Hold Pos - - 1 - + - Models/AssaultAnimated.mesh + Models/Characters/Assault/AssaultAnimations.mesh diff --git a/src/Game/Systems/CapturePointHUDSystem.cpp b/src/Game/Systems/CapturePointHUDSystem.cpp index 784c7e16..21737fbe 100644 --- a/src/Game/Systems/CapturePointHUDSystem.cpp +++ b/src/Game/Systems/CapturePointHUDSystem.cpp @@ -16,6 +16,9 @@ void CapturePointHUDSystem::Update(double dt) auto CapturePointHUDElements = m_World->GetComponents("CapturePointHUD"); auto CapturePoints = m_World->GetComponents("CapturePoint"); + if (CapturePointHUDElements == nullptr) { + return; + } for (auto& cCapturePointHUD : *CapturePointHUDElements) { int HUD_ID = cCapturePointHUD["CapturePointNumber"]; diff --git a/src/Game/Systems/DamageIndicatorSystem.cpp b/src/Game/Systems/DamageIndicatorSystem.cpp index 638307bf..93385e48 100644 --- a/src/Game/Systems/DamageIndicatorSystem.cpp +++ b/src/Game/Systems/DamageIndicatorSystem.cpp @@ -1,11 +1,15 @@ #include "Systems/DamageIndicatorSystem.h" -DamageIndicatorSystem::DamageIndicatorSystem(World* m_World, EventBroker* eventBroker) - : System(m_World, eventBroker) +DamageIndicatorSystem::DamageIndicatorSystem(SystemParams params) + : System(params) { EVENT_SUBSCRIBE_MEMBER(m_DamageTakenFromPlayer, &DamageIndicatorSystem::OnPlayerDamageTaken); //current camera EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &DamageIndicatorSystem::OnSetCamera); + + //load texture to cache + auto texture = CommonFunctions::LoadTexture("Textures/DamageIndicator.png", false); + auto entityFile = ResourceManager::Load("Schema/Entities/DamageIndicator.xml"); } bool DamageIndicatorSystem::OnPlayerDamageTaken(Events::PlayerDamage& e) @@ -58,4 +62,4 @@ bool DamageIndicatorSystem::OnPlayerDamageTaken(Events::PlayerDamage& e) bool DamageIndicatorSystem::OnSetCamera(const Events::SetCamera& e) { m_CurrentCamera = e.CameraEntity.ID; return true; -} \ No newline at end of file +} From 3a15550b57faf975d0e651199b748f933d0e49b2 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Thu, 11 Feb 2016 21:07:47 +0100 Subject: [PATCH 32/37] maybe a good commit --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 8ffd0a99..dfa0fc61 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 8ffd0a99b9a2e5c140307d382a25c4a470cc8f33 +Subproject commit dfa0fc61ab88456f3461779bd7c6ac97d15f6493 From 4a17e3c8f384dc2a998d75f55baeb5a350d978cd Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Thu, 11 Feb 2016 21:42:29 +0100 Subject: [PATCH 33/37] airFriction changed to 2.0 to fix the dash ability in the air --- src/Game/Systems/PlayerMovementSystem.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp index 93f0cd3d..bad512df 100644 --- a/src/Game/Systems/PlayerMovementSystem.cpp +++ b/src/Game/Systems/PlayerMovementSystem.cpp @@ -233,7 +233,8 @@ void PlayerMovementSystem::updateVelocity(double dt) float speed = glm::length(velocity); static float groundFriction = 7.f; ImGui::InputFloat("groundFriction", &groundFriction); - static float airFriction = 0.f; + static float airFriction = 2.f; + ImGui::InputFloat("airFriction", &airFriction); float friction = isOnGround ? groundFriction : airFriction; if (speed > 0) { From d1213f9f59d36d25813e8a5cd90f6106edcdd322 Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 11 Feb 2016 22:50:44 +0100 Subject: [PATCH 34/37] Working damage dealing, a super cool reload effect and hit markers! --- assets | 2 +- include/Engine/Core/EPlayerDamage.h | 4 +- include/Engine/Core/EShoot.h | 3 +- .../Systems/Weapon/AssaultWeaponBehaviour.h | 12 +- include/Game/Systems/Weapon/WeaponBehaviour.h | 9 +- include/Game/Systems/Weapon/WeaponSystem.h | 2 - resources/Schema/Components/AssaultWeapon.xml | 1 + resources/Schema/Components/AssaultWeapon.xsd | 3 + resources/Schema/Entities/HitMarker.xml | 20 ++ resources/Schema/Entities/MovementTest.xml | 158 ++++++++++++- resources/Schema/Entities/Player.xml | 46 +++- .../Schema/Entities/WeaponReloadEffect.xml | 31 +++ src/Engine/Core/EntityFilePreprocessor.cpp | 1 - src/Engine/Network/Client.cpp | 3 +- src/Engine/Network/Server.cpp | 3 +- src/Game/Systems/HealthSystem.cpp | 4 +- src/Game/Systems/PlayerDeathSystem.cpp | 14 +- src/Game/Systems/SoundSystem.cpp | 2 +- src/Game/Systems/SpawnerSystem.cpp | 10 +- .../Systems/Weapon/AssaultWeaponBehaviour.cpp | 218 +++++++++++++++--- src/Game/Systems/Weapon/WeaponSystem.cpp | 60 +---- src/Tests/HealthSystemTest.cpp | 2 +- 22 files changed, 473 insertions(+), 135 deletions(-) create mode 100644 resources/Schema/Entities/HitMarker.xml create mode 100644 resources/Schema/Entities/WeaponReloadEffect.xml diff --git a/assets b/assets index 8ffd0a99..4d36fdce 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 8ffd0a99b9a2e5c140307d382a25c4a470cc8f33 +Subproject commit 4d36fdced7007a594a56b7371bb26861876889aa diff --git a/include/Engine/Core/EPlayerDamage.h b/include/Engine/Core/EPlayerDamage.h index 8ba3907e..6f3f2c12 100644 --- a/include/Engine/Core/EPlayerDamage.h +++ b/include/Engine/Core/EPlayerDamage.h @@ -9,8 +9,8 @@ namespace Events struct PlayerDamage : Event { - //NOTE: this struct is missing information on what the damageSource is - EntityWrapper Player; + EntityWrapper Inflictor; + EntityWrapper Victim; double Damage; }; diff --git a/include/Engine/Core/EShoot.h b/include/Engine/Core/EShoot.h index 76821a24..28346abb 100644 --- a/include/Engine/Core/EShoot.h +++ b/include/Engine/Core/EShoot.h @@ -9,7 +9,8 @@ namespace Events struct Shoot : Event { - EntityWrapper Player; + EntityWrapper Inflictor; + double Damage; }; } diff --git a/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h b/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h index 58d7755f..915854ff 100644 --- a/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h +++ b/include/Game/Systems/Weapon/AssaultWeaponBehaviour.h @@ -1,12 +1,15 @@ #include "Sound/EPlaySoundOnEntity.h" +#include "Collision/Collision.h" #include "Rendering/AnimationSystem.h" #include "WeaponBehaviour.h" #include "../SpawnerSystem.h" +#include "Core/EPlayerDamage.h" +#include "Core/EShoot.h" class AssaultWeaponBehaviour : public WeaponBehaviour { public: - AssaultWeaponBehaviour(SystemParams systemParams, Octree* collisionOctree, EntityWrapper weaponEntity); + AssaultWeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree* collisionOctree, EntityWrapper weaponEntity); virtual void Fire() override; virtual void CeaseFire() override; @@ -19,16 +22,23 @@ private: // State bool m_Firing = false; bool m_Reloading = false; + double m_ReloadTimer = 0.0; + EntityWrapper m_ReloadImpersonator; double m_TimeSinceLastFire = 0.0; EventRelay m_EAnimationComplete; bool OnAnimationComplete(Events::AnimationComplete& e); + bool hasAmmo(); void fireRound(); void spawnTracer(); float traceRayDistance(glm::vec3 origin, glm::vec3 direction); void playSound(); void viewPunch(); + void finishReload(); void playShootAnimation(); void playIdleAnimation(); + void playReloadAnimation(); + bool shoot(double damage); + void showHitMarker(); }; diff --git a/include/Game/Systems/Weapon/WeaponBehaviour.h b/include/Game/Systems/Weapon/WeaponBehaviour.h index 38ab5f58..7a0b4626 100644 --- a/include/Game/Systems/Weapon/WeaponBehaviour.h +++ b/include/Game/Systems/Weapon/WeaponBehaviour.h @@ -2,16 +2,18 @@ #define WeaponBehaviour_h__ #include "Core/System.h" +#include "Rendering/IRenderer.h" #include "Core/Octree.h" #include "Collision/EntityAABB.h" class WeaponBehaviour : public System { public: - WeaponBehaviour(SystemParams systemParams, Octree* collisionOctree, EntityWrapper weaponEntity) + WeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree* collisionOctree, EntityWrapper player) : System(systemParams) + , m_Renderer(renderer) , m_CollisionOctree(collisionOctree) - , m_Entity(weaponEntity) + , m_Player(player) { } virtual ~WeaponBehaviour() = default; @@ -24,8 +26,9 @@ public: virtual void Update(double dt) { } protected: + IRenderer* m_Renderer; Octree* m_CollisionOctree; - EntityWrapper m_Entity; + EntityWrapper m_Player; }; #endif diff --git a/include/Game/Systems/Weapon/WeaponSystem.h b/include/Game/Systems/Weapon/WeaponSystem.h index 68cf2ef3..b8278bc4 100644 --- a/include/Game/Systems/Weapon/WeaponSystem.h +++ b/include/Game/Systems/Weapon/WeaponSystem.h @@ -35,8 +35,6 @@ private: // Events EventRelay m_EPlayerSpawned; bool OnPlayerSpawned(Events::PlayerSpawned& e); - EventRelay m_EShoot; - bool OnShoot(Events::Shoot& e); EventRelay m_EInputCommand; bool OnInputCommand(Events::InputCommand& e); diff --git a/resources/Schema/Components/AssaultWeapon.xml b/resources/Schema/Components/AssaultWeapon.xml index c7dbfb0d..6c645624 100755 --- a/resources/Schema/Components/AssaultWeapon.xml +++ b/resources/Schema/Components/AssaultWeapon.xml @@ -7,4 +7,5 @@ 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 65558db5..95df64b7 100755 --- a/resources/Schema/Components/AssaultWeapon.xsd +++ b/resources/Schema/Components/AssaultWeapon.xsd @@ -25,6 +25,9 @@ View punch in radians for each bullet fired + + Time it takes to reload the weapon in seconds + diff --git a/resources/Schema/Entities/HitMarker.xml b/resources/Schema/Entities/HitMarker.xml new file mode 100644 index 00000000..74a539d0 --- /dev/null +++ b/resources/Schema/Entities/HitMarker.xml @@ -0,0 +1,20 @@ + + + + + + 0.1 + + + Textures/Weapons/Crosshair/SmallThickHoleDot.png + false + + + + + + + + + + diff --git a/resources/Schema/Entities/MovementTest.xml b/resources/Schema/Entities/MovementTest.xml index 16a28684..84aaa03a 100644 --- a/resources/Schema/Entities/MovementTest.xml +++ b/resources/Schema/Entities/MovementTest.xml @@ -124,10 +124,14 @@ + + 600 + - + + - false + 5 @@ -138,8 +142,7 @@ - - + @@ -147,7 +150,7 @@ - + @@ -156,10 +159,9 @@ Fonts/DroidSans.ttf,100 - false - + @@ -170,6 +172,7 @@ Models/Widgets/Camera.mesh + false @@ -178,6 +181,100 @@ + + + + + + + + + + + 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 + + + + + + + @@ -196,15 +293,52 @@ + + Idle + 1.8055945618467364 + 1 + + + AimRifle + + + - Models/Characters/Assault/AssaultHeadless.mesh + Models/Characters/Assault/AssaultAnimations.mesh - - - + - + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + false + + + + + + + + + + + Schema/Entities/RayBlue.xml + + + + + + + + + + diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 4ba23a0d..9f8e0955 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -23,7 +23,9 @@ - + + + @@ -90,24 +92,33 @@ - - Models/Weapons/CrosshairQuad.mesh - + + Textures/Weapons/Crosshair/SmallThickHoleDot.png + false + - - + + + + + Schema/Entities/HitMarker.xml + + + + + Idle - 0.52743271827223559 + 0.1719161089749548 1 @@ -124,10 +135,11 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh + true - - + + @@ -144,6 +156,15 @@ + + + + Schema/Entities/WeaponReloadEffect.xml + + + + + @@ -166,7 +187,7 @@ Idle - 0.69666320633760392 + 1.8038469763698401 1 @@ -188,10 +209,11 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh + false - - + + diff --git a/resources/Schema/Entities/WeaponReloadEffect.xml b/resources/Schema/Entities/WeaponReloadEffect.xml new file mode 100644 index 00000000..3099b405 --- /dev/null +++ b/resources/Schema/Entities/WeaponReloadEffect.xml @@ -0,0 +1,31 @@ + + + + + + R_Arm_Weapon_Joint + + + 2 + + + true + + + true + + true + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + true + + + + + + + + + + diff --git a/src/Engine/Core/EntityFilePreprocessor.cpp b/src/Engine/Core/EntityFilePreprocessor.cpp index 86217979..a1370dd2 100644 --- a/src/Engine/Core/EntityFilePreprocessor.cpp +++ b/src/Engine/Core/EntityFilePreprocessor.cpp @@ -65,7 +65,6 @@ void EntityFilePreprocessor::parseComponentInfo() // Name compInfo.Name = XS::ToString(element->getName()); - bool brk = compInfo.Name == "HiddenForLocalPlayer"; // Known allocation compInfo.Meta->Allocation = m_ComponentCounts[compInfo.Name]; // Annotation diff --git a/src/Engine/Network/Client.cpp b/src/Engine/Network/Client.cpp index 7d2c8f92..b03aad07 100644 --- a/src/Engine/Network/Client.cpp +++ b/src/Engine/Network/Client.cpp @@ -390,8 +390,9 @@ bool Client::OnInputCommand(const Events::InputCommand & e) bool Client::OnPlayerDamage(const Events::PlayerDamage & e) { Packet packet(MessageType::OnPlayerDamage, m_SendPacketID); + packet.WritePrimitive(m_ClientIDToServerID.at(e.Inflictor.ID)); + packet.WritePrimitive(m_ClientIDToServerID.at(e.Victim.ID)); packet.WritePrimitive(e.Damage); - packet.WritePrimitive(m_ClientIDToServerID.at(e.Player.ID)); send(packet); return false; } diff --git a/src/Engine/Network/Server.cpp b/src/Engine/Network/Server.cpp index 7ad1cc76..1f0b3bc7 100644 --- a/src/Engine/Network/Server.cpp +++ b/src/Engine/Network/Server.cpp @@ -299,8 +299,9 @@ void Server::parseOnInputCommand(Packet& packet) void Server::parseOnPlayerDamage(Packet & packet) { Events::PlayerDamage e; + e.Inflictor = EntityWrapper(m_World, packet.ReadPrimitive()); + e.Victim = EntityWrapper(m_World, packet.ReadPrimitive()); e.Damage = packet.ReadPrimitive(); - e.Player = EntityWrapper(m_World, packet.ReadPrimitive()); m_EventBroker->Publish(e); //LOG_DEBUG("Server::parseOnPlayerDamage: Command is %s. Value is %f. PlayerID is %i.", e.DamageAmount, e.PlayerDamagedID, e.TypeOfDamage.c_str()); } diff --git a/src/Game/Systems/HealthSystem.cpp b/src/Game/Systems/HealthSystem.cpp index bb02ea13..29d8790d 100644 --- a/src/Game/Systems/HealthSystem.cpp +++ b/src/Game/Systems/HealthSystem.cpp @@ -15,13 +15,13 @@ void HealthSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& comp bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e) { - ComponentWrapper cHealth = e.Player["Health"]; + ComponentWrapper cHealth = e.Victim["Health"]; double& health = cHealth["Health"]; health -= e.Damage; if (health <= 0.0) { Events::PlayerDeath ePlayerDeath; - ePlayerDeath.Player = e.Player; + ePlayerDeath.Player = e.Victim; m_EventBroker->Publish(ePlayerDeath); //Note: we will delete the entity in PlayerDeathSystem } diff --git a/src/Game/Systems/PlayerDeathSystem.cpp b/src/Game/Systems/PlayerDeathSystem.cpp index 29ed9832..78e20490 100644 --- a/src/Game/Systems/PlayerDeathSystem.cpp +++ b/src/Game/Systems/PlayerDeathSystem.cpp @@ -41,7 +41,9 @@ void PlayerDeathSystem::createDeathEffect(EntityWrapper player) playerEntityModel.Copy(deathEffectEW["Model"]); playerEntityAnimation.Copy(deathEffectEW["Animation"]); //freeze the animation - deathEffectEW["Animation"]["Speed"] = 0.0; + 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"]; @@ -50,8 +52,10 @@ void PlayerDeathSystem::createDeathEffect(EntityWrapper player) //deathEffectEW["ExplosionEffect"]["ExplosionOrigin"] = glm::vec3(0, 0, 0); //camera (with lifetime) behind the player - auto cam = deathEffectEW.FirstChildByName("Camera"); - Events::SetCamera eSetCamera; - eSetCamera.CameraEntity = cam; - m_EventBroker->Publish(eSetCamera); + if (player == LocalPlayer) { + auto cam = deathEffectEW.FirstChildByName("Camera"); + Events::SetCamera eSetCamera; + eSetCamera.CameraEntity = cam; + m_EventBroker->Publish(eSetCamera); + } } diff --git a/src/Game/Systems/SoundSystem.cpp b/src/Game/Systems/SoundSystem.cpp index 10dc61f7..d6ac7dab 100644 --- a/src/Game/Systems/SoundSystem.cpp +++ b/src/Game/Systems/SoundSystem.cpp @@ -54,7 +54,7 @@ bool SoundSystem::OnInputCommand(const Events::InputCommand & e) } if (e.Command == "TakeDamage" && e.Value > 0) { Events::PlayerDamage ev; - ev.Player = LocalPlayer; + ev.Victim = LocalPlayer; ev.Damage = 1.0; m_EventBroker->Publish(ev); } diff --git a/src/Game/Systems/SpawnerSystem.cpp b/src/Game/Systems/SpawnerSystem.cpp index 99f5df93..b3c556f1 100644 --- a/src/Game/Systems/SpawnerSystem.cpp +++ b/src/Game/Systems/SpawnerSystem.cpp @@ -48,10 +48,12 @@ EntityWrapper SpawnerSystem::Spawn(EntityWrapper spawner, EntityWrapper parent / EntityFileParser parser(entityFile); EntityWrapper spawnedEntity(world, parser.MergeEntities(world, parent.ID)); - // Set its position and orientation to that of the SpawnPoint - spawnedEntity["Transform"]["Position"] = Transform::AbsolutePosition(spawnPoint.World, spawnPoint.ID); - // TODO: Quaternions, bitch - spawnedEntity["Transform"]["Orientation"] = glm::eulerAngles(Transform::AbsoluteOrientation(spawnPoint)); + if (spawnPoint != parent) { + // Set its position and orientation to that of the SpawnPoint + spawnedEntity["Transform"]["Position"] = Transform::AbsolutePosition(spawnPoint.World, spawnPoint.ID); + // TODO: Quaternions, bitch + spawnedEntity["Transform"]["Orientation"] = glm::eulerAngles(Transform::AbsoluteOrientation(spawnPoint)); + } return spawnedEntity; } diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp index bb5a025f..724e1f2c 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -1,9 +1,9 @@ #include "Systems/Weapon/AssaultWeaponBehaviour.h" -AssaultWeaponBehaviour::AssaultWeaponBehaviour(SystemParams systemParams, Octree* collisionOctree, EntityWrapper weaponEntity) - : WeaponBehaviour(systemParams, collisionOctree, weaponEntity) +AssaultWeaponBehaviour::AssaultWeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree* collisionOctree, EntityWrapper player) + : WeaponBehaviour(systemParams, renderer, collisionOctree, player) { - m_FirstPersonModel = m_Entity.FirstChildByName("Hands"); + m_FirstPersonModel = m_Player.FirstChildByName("Hands"); EVENT_SUBSCRIBE_MEMBER(m_EAnimationComplete, &AssaultWeaponBehaviour::OnAnimationComplete); } @@ -12,7 +12,6 @@ void AssaultWeaponBehaviour::Fire() m_TimeSinceLastFire = 0.0; m_Firing = true; fireRound(); - playShootAnimation(); } void AssaultWeaponBehaviour::CeaseFire() @@ -22,29 +21,48 @@ void AssaultWeaponBehaviour::CeaseFire() void AssaultWeaponBehaviour::Reload() { - ComponentWrapper& cAssaultWeapon = m_Entity["AssaultWeapon"]; + if (m_Reloading) { + return; + } - int& magAmmo = cAssaultWeapon["MagazineAmmo"]; + ComponentWrapper& cAssaultWeapon = m_Player["AssaultWeapon"]; + int magAmmo = cAssaultWeapon["MagazineAmmo"]; int magSize = cAssaultWeapon["MagazineSize"]; - int& ammo = cAssaultWeapon["Ammo"]; + int ammo = cAssaultWeapon["Ammo"]; // Don't reload if we're already fully loaded if (magAmmo == magSize) { return; } - // Throw away rounds in magazine to incentivise ammo sharing - int toLoad = glm::min(magSize, ammo); - magAmmo = toLoad; - ammo -= toLoad; + // Don't reload if we're completly out of ammo + if (ammo == 0) { + return; + } + + m_Reloading = true; + m_ReloadTimer = cAssaultWeapon["ReloadTime"]; + playReloadAnimation(); } void AssaultWeaponBehaviour::Update(double dt) { - if (m_Firing) { - m_TimeSinceLastFire += dt; + if (m_Reloading) { + m_ReloadTimer -= dt; + // Re-enable glow on reload impersonator half-way through the animation + if (m_ReloadTimer <= (double)m_Player["AssaultWeapon"]["ReloadTime"] / 2.0) { + if (m_ReloadImpersonator.Valid()) { + m_ReloadImpersonator["Model"]["GlowMap"] = true; + } + } + if (m_ReloadTimer <= 0) { + finishReload(); + } + } - ComponentWrapper& cAssaultWeapon = m_Entity["AssaultWeapon"]; + if (m_Firing && !m_Reloading) { + m_TimeSinceLastFire += dt; + ComponentWrapper& cAssaultWeapon = m_Player["AssaultWeapon"]; if (m_TimeSinceLastFire >= 1.0 / ((double)cAssaultWeapon["RPM"] / 60.0)) { fireRound(); } @@ -53,6 +71,13 @@ void AssaultWeaponBehaviour::Update(double dt) if (!m_Firing && !m_Reloading) { playIdleAnimation(); } + + // Disable glow map on weapon if it's out of ammo + // Make real first person weapon model visible again + EntityWrapper firstPersonWeaponModel = m_Player.FirstChildByName("WeaponModel"); + if (firstPersonWeaponModel.Valid()) { + firstPersonWeaponModel["Model"]["GlowMap"] = hasAmmo(); + } } bool AssaultWeaponBehaviour::OnAnimationComplete(Events::AnimationComplete& e) @@ -70,9 +95,20 @@ bool AssaultWeaponBehaviour::OnAnimationComplete(Events::AnimationComplete& e) return true; } +bool AssaultWeaponBehaviour::hasAmmo() +{ + ComponentWrapper& cAssaultWeapon = m_Player["AssaultWeapon"]; + int& magAmmo = cAssaultWeapon["MagazineAmmo"]; + return magAmmo > 0; +} + void AssaultWeaponBehaviour::fireRound() { - ComponentWrapper& cAssaultWeapon = m_Entity["AssaultWeapon"]; + if (m_Reloading) { + return; + } + + ComponentWrapper& cAssaultWeapon = m_Player["AssaultWeapon"]; int& magAmmo = cAssaultWeapon["MagazineAmmo"]; int ammo = cAssaultWeapon["Ammo"]; @@ -88,6 +124,11 @@ void AssaultWeaponBehaviour::fireRound() spawnTracer(); playSound(); viewPunch(); + playShootAnimation(); + bool hit = shoot(cAssaultWeapon["BaseDamage"]); + if (hit) { + showHitMarker(); + } m_TimeSinceLastFire = 0.0; } @@ -99,25 +140,32 @@ void AssaultWeaponBehaviour::spawnTracer() } EntityWrapper spawner; - if (m_Entity == LocalPlayer) { - spawner = m_Entity.FirstChildByName("WeaponMuzzle"); + if (m_Player == LocalPlayer) { + spawner = m_Player.FirstChildByName("WeaponMuzzle"); } else { - spawner = m_Entity.FirstChildByName("ThirdPersonWeaponMuzzle"); + spawner = m_Player.FirstChildByName("ThirdPersonWeaponMuzzle"); } if (!spawner.Valid()) { return; } - Events::SpawnerSpawn e; - e.Spawner = spawner; - m_EventBroker->Publish(e); + float distance = traceRayDistance(Transform::AbsolutePosition(spawner), Transform::AbsoluteOrientation(spawner) * glm::vec3(0, 0, -1)); + EntityWrapper ray = SpawnerSystem::Spawn(spawner); + ((glm::vec3&)ray["Transform"]["Scale"]).z = (distance / 100.f); } float AssaultWeaponBehaviour::traceRayDistance(glm::vec3 origin, glm::vec3 direction) { // TODO: Cast a ray and size tracer appropriately - return 100.f; + float distance; + glm::vec3 pos; + auto entity = Collision::EntityFirstHitByRay(Ray(origin, direction), m_CollisionOctree, distance, pos); + if (entity) { + return distance; + } else { + return 100.f; + } } void AssaultWeaponBehaviour::playSound() @@ -127,32 +175,52 @@ void AssaultWeaponBehaviour::playSound() } Events::PlaySoundOnEntity e; - e.EmitterID = m_Entity.ID; + e.EmitterID = m_Player.ID; e.FilePath = "Audio/laser/laser1.wav"; m_EventBroker->Publish(e); } void AssaultWeaponBehaviour::viewPunch() { - EntityWrapper playerCamera = m_Entity.FirstChildByName("Camera"); + EntityWrapper playerCamera = m_Player.FirstChildByName("Camera"); if (!playerCamera.Valid()) { return; } - float viewPunch = m_Entity["AssaultWeapon"]["ViewPunch"]; + float viewPunch = m_Player["AssaultWeapon"]["ViewPunch"]; ComponentWrapper cTransform = playerCamera["Transform"]; glm::vec3& orientation = cTransform["Orientation"]; orientation.x += viewPunch; } +void AssaultWeaponBehaviour::finishReload() +{ + ComponentWrapper& cAssaultWeapon = m_Player["AssaultWeapon"]; + int& magAmmo = cAssaultWeapon["MagazineAmmo"]; + int magSize = cAssaultWeapon["MagazineSize"]; + int& ammo = cAssaultWeapon["Ammo"]; + + // Throw away rounds in magazine to incentivise ammo sharing + int toLoad = glm::min(magSize, ammo); + magAmmo = toLoad; + ammo -= toLoad; + + // Make real first person weapon model visible again + EntityWrapper firstPersonWeaponModel = m_Player.FirstChildByName("WeaponModel"); + firstPersonWeaponModel["Model"]["Visible"] = true; + + m_Reloading = false; +} + void AssaultWeaponBehaviour::playShootAnimation() { - EntityWrapper firstPersonWeapon = m_Entity.FirstChildByName("Hands"); - ComponentWrapper cAnimation = firstPersonWeapon["Animation"]; - cAnimation["AnimationName1"] = "ShootRifle"; - cAnimation["Weight1"] = 1.0; - cAnimation["Time1"] = 0.0; - cAnimation["Speed1"] = 1.0; - cAnimation["Loop1"] = true; + ComponentWrapper cAnimation = m_FirstPersonModel["Animation"]; + if (cAnimation["AnimationName1"] != "ShootRifle") { + cAnimation["AnimationName1"] = "ShootRifle"; + cAnimation["Weight1"] = 1.0; + cAnimation["Time1"] = 0.0; + cAnimation["Speed1"] = 1.0; + cAnimation["Loop1"] = true; + } } void AssaultWeaponBehaviour::playIdleAnimation() @@ -168,11 +236,11 @@ void AssaultWeaponBehaviour::playIdleAnimation() std::string animationToPlay = "Idle"; double speedToSet = 1.0; - ComponentWrapper cPlayer = m_Entity["Player"]; + ComponentWrapper cPlayer = m_Player["Player"]; glm::vec3 movementDirection = cPlayer["CurrentWishDirection"]; if (glm::length2(movementDirection) > 0) { animationToPlay = "Run"; - ComponentWrapper cPhysics = m_Entity["Physics"]; + ComponentWrapper cPhysics = m_Player["Physics"]; speedToSet = glm::length((glm::vec3)cPhysics["Velocity"]) / (float)cPlayer["MovementSpeed"]; } @@ -188,3 +256,85 @@ void AssaultWeaponBehaviour::playIdleAnimation() } } +void AssaultWeaponBehaviour::playReloadAnimation() +{ + // Play animation + ComponentWrapper cAnimation = m_FirstPersonModel["Animation"]; + cAnimation["AnimationName1"] = "ReloadSwitch"; + cAnimation["Weight1"] = 1.0; + cAnimation["Time1"] = 0.0; + cAnimation["Speed1"] = 0.5; + cAnimation["Loop1"] = true; + + // Hide weapon model and spawn the exploding version + EntityWrapper firstPersonWeaponModel = m_Player.FirstChildByName("WeaponModel"); + EntityWrapper reloadSpawner = m_Player.FirstChildByName("FirstPersonReloadSpawner"); + m_ReloadImpersonator = SpawnerSystem::Spawn(reloadSpawner, reloadSpawner); + firstPersonWeaponModel["Model"].Copy(m_ReloadImpersonator["Model"]); + firstPersonWeaponModel["Model"]["Visible"] = false; +} + +bool AssaultWeaponBehaviour::shoot(double damage) +{ + // Only do shooting clientside + if (!IsClient) { + return false; + } + + // Only handle shooting for the local player + if (m_Player != LocalPlayer) { + return false; + } + + // Make sure the player isn't shooting from the grave + if (!m_Player.Valid()) { + return false; + } + + // Screen center, based on current resolution! + Rectangle screenResolution = m_Renderer->GetViewportSize(); + glm::vec2 centerScreen = glm::vec2(screenResolution.Width / 2, screenResolution.Height / 2); + + // Pick middle of screen + PickData pickData = m_Renderer->Pick(centerScreen); + if (pickData.Entity == EntityID_Invalid) { + return false; + } + + EntityWrapper victim(m_World, pickData.Entity); + + // Don't let us 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; + } + + // Check for friendly fire + if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)m_Player["Team"]["Team"]) { + return false; + } + + // Deal damage! + Events::PlayerDamage ePlayerDamage; + ePlayerDamage.Victim = victim; + ePlayerDamage.Damage = damage; + m_EventBroker->Publish(ePlayerDamage); + + return true; +} + +void AssaultWeaponBehaviour::showHitMarker() +{ + // Show hit marker + EntityWrapper hitMarkerSpawner = m_Player.FirstChildByName("HitMarkerSpawner"); + if (hitMarkerSpawner.Valid()) { + SpawnerSystem::Spawn(hitMarkerSpawner, hitMarkerSpawner); + } +} diff --git a/src/Game/Systems/Weapon/WeaponSystem.cpp b/src/Game/Systems/Weapon/WeaponSystem.cpp index bdd27ea9..34d5fd43 100644 --- a/src/Game/Systems/Weapon/WeaponSystem.cpp +++ b/src/Game/Systems/Weapon/WeaponSystem.cpp @@ -8,7 +8,6 @@ WeaponSystem::WeaponSystem(SystemParams params, IRenderer* renderer, OctreeReload(); + } + } + return true; } @@ -69,7 +76,7 @@ void WeaponSystem::selectWeapon(EntityWrapper player, ComponentInfo::EnumType sl 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_CollisionOctree, player))); + m_ActiveWeapons.insert(std::make_pair(player, std::make_shared(m_SystemParams, m_Renderer, m_CollisionOctree, player))); } else { //m_ActiveWeapons.erase(player); } @@ -87,52 +94,3 @@ bool WeaponSystem::OnPlayerSpawned(Events::PlayerSpawned& e) // TODO: Select the active one specified by player component return true; } - -bool WeaponSystem::OnShoot(Events::Shoot& eShoot) -{ - if (!eShoot.Player.Valid()) { - return false; - } - - // Only run further picking code for the local player! - if (eShoot.Player != LocalPlayer) { - return false; - } - - // Screen center, based on current resolution! - // TODO: check if player has enough ammo and if weapon has a cooldown or not - Rectangle screenResolution = m_Renderer->GetViewportSize(); - glm::vec2 centerScreen = glm::vec2(screenResolution.Width / 2, screenResolution.Height / 2); - - // TODO: check if player has enough ammo and if weapon has a cooldown or not - - // Pick middle of screen - PickData pickData = m_Renderer->Pick(centerScreen); - if (pickData.Entity == EntityID_Invalid) { - return false; - } - - EntityWrapper player(m_World, pickData.Entity); - - // Only care about players being hit - if (!player.HasComponent("Player")) { - player = player.FirstParentWithComponent("Player"); - } - if (!player.Valid()) { - return false; - } - - // Check for friendly fire - EntityWrapper shooter = eShoot.Player; - if ((ComponentInfo::EnumType)player["Team"]["Team"] == (ComponentInfo::EnumType)shooter["Team"]["Team"]) { - return false; - } - - // TODO: Weapon damage calculations etc - Events::PlayerDamage ePlayerDamage; - ePlayerDamage.Player = player; - ePlayerDamage.Damage = 100; - m_EventBroker->Publish(ePlayerDamage); - - return true; -} \ No newline at end of file diff --git a/src/Tests/HealthSystemTest.cpp b/src/Tests/HealthSystemTest.cpp index 36608f8f..8bf16024 100644 --- a/src/Tests/HealthSystemTest.cpp +++ b/src/Tests/HealthSystemTest.cpp @@ -71,7 +71,7 @@ GameHealthSystemTest::GameHealthSystemTest() //damage player with 50 Events::PlayerDamage e; e.Damage = 50.0f; - e.Player = EntityWrapper(m_World, player.EntityID); + e.Victim = EntityWrapper(m_World, player.EntityID); m_EventBroker->Publish(e); //heal some other player with 40 From 1bb1a1445ee23982189736389ed6edd6cbf094ed Mon Sep 17 00:00:00 2001 From: Teejoon Date: Thu, 11 Feb 2016 22:51:39 +0100 Subject: [PATCH 35/37] Commit assets --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 105b22fc..4d36fdce 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 105b22fc67b68993db43deec3250084ed625d893 +Subproject commit 4d36fdced7007a594a56b7371bb26861876889aa From 44a73ef88376cf22665e4189069aa5d484ae383d Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 11 Feb 2016 23:44:20 +0100 Subject: [PATCH 36/37] fixup! Merge remote-tracking branch 'origin/master' into WeaponSystem --- include/Game/Systems/DamageIndicatorSystem.h | 4 ++-- src/Game/Systems/DamageIndicatorSystem.cpp | 18 +++++++++++------- .../Systems/Weapon/AssaultWeaponBehaviour.cpp | 1 + src/Game/Systems/Weapon/WeaponSystem.cpp | 4 +--- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/include/Game/Systems/DamageIndicatorSystem.h b/include/Game/Systems/DamageIndicatorSystem.h index e70a69a9..053b196b 100644 --- a/include/Game/Systems/DamageIndicatorSystem.h +++ b/include/Game/Systems/DamageIndicatorSystem.h @@ -21,8 +21,8 @@ public: DamageIndicatorSystem(SystemParams params); private: - EventRelay m_DamageTakenFromPlayer; - bool OnPlayerDamageTaken(Events::PlayerDamage& e); + EventRelay m_EPlayerDamage; + bool OnPlayerDamage(Events::PlayerDamage& e); EventRelay m_ESetCamera; bool OnSetCamera(const Events::SetCamera& e); diff --git a/src/Game/Systems/DamageIndicatorSystem.cpp b/src/Game/Systems/DamageIndicatorSystem.cpp index 93385e48..a29309b5 100644 --- a/src/Game/Systems/DamageIndicatorSystem.cpp +++ b/src/Game/Systems/DamageIndicatorSystem.cpp @@ -3,7 +3,7 @@ DamageIndicatorSystem::DamageIndicatorSystem(SystemParams params) : System(params) { - EVENT_SUBSCRIBE_MEMBER(m_DamageTakenFromPlayer, &DamageIndicatorSystem::OnPlayerDamageTaken); + EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &DamageIndicatorSystem::OnPlayerDamage); //current camera EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &DamageIndicatorSystem::OnSetCamera); @@ -12,23 +12,27 @@ DamageIndicatorSystem::DamageIndicatorSystem(SystemParams params) auto entityFile = ResourceManager::Load("Schema/Entities/DamageIndicator.xml"); } -bool DamageIndicatorSystem::OnPlayerDamageTaken(Events::PlayerDamage& e) +bool DamageIndicatorSystem::OnPlayerDamage(Events::PlayerDamage& e) { - if (m_CurrentCamera == -1) { + if (m_CurrentCamera == EntityID_Invalid) { + return false; + } + + if (e.Victim != LocalPlayer) { return false; } //grab players direction - auto playerOrientation = glm::quat((glm::vec3)e.Player["Transform"]["Orientation"]); + auto playerOrientation = glm::quat((glm::vec3)e.Victim["Transform"]["Orientation"]); //get the position vectors, but ignore the y-height - auto enemyPosition = (glm::vec3) e.PlayerShooter["Transform"]["Position"]; - auto playerPosition = (glm::vec3) e.Player["Transform"]["Position"]; + 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((glm::vec3) playerPosition - enemyPosition); + 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); diff --git a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp index 724e1f2c..54c3a590 100644 --- a/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp +++ b/src/Game/Systems/Weapon/AssaultWeaponBehaviour.cpp @@ -323,6 +323,7 @@ bool AssaultWeaponBehaviour::shoot(double damage) // Deal damage! Events::PlayerDamage ePlayerDamage; + ePlayerDamage.Inflictor = m_Player; ePlayerDamage.Victim = victim; ePlayerDamage.Damage = damage; m_EventBroker->Publish(ePlayerDamage); diff --git a/src/Game/Systems/Weapon/WeaponSystem.cpp b/src/Game/Systems/Weapon/WeaponSystem.cpp index 4a25b811..3a49ae90 100644 --- a/src/Game/Systems/Weapon/WeaponSystem.cpp +++ b/src/Game/Systems/Weapon/WeaponSystem.cpp @@ -93,6 +93,4 @@ bool WeaponSystem::OnPlayerSpawned(Events::PlayerSpawned& e) // Select primary weapon on player spawn // TODO: Select the active one specified by player component return true; -} - - ePlayerDamage.PlayerShooter = eShoot.Player; \ No newline at end of file +} \ No newline at end of file From b761439c843bb85ab189f9432b5ac1881f78683c Mon Sep 17 00:00:00 2001 From: sippeangelo Date: Thu, 11 Feb 2016 23:45:30 +0100 Subject: [PATCH 37/37] Added config flag Debug.OutOfBodyExperience that allows you to spawn and view a player from a third person perspective, without the active camera being changed. --- include/Engine/Rendering/RenderSystem.h | 4 +++ resources/DefaultConfig.ini | 2 ++ src/Engine/Rendering/RenderSystem.cpp | 40 +++++++++++++++---------- src/Game/Systems/PlayerSpawnSystem.cpp | 3 +- tools/deploy.bat | 2 ++ 5 files changed, 34 insertions(+), 17 deletions(-) diff --git a/include/Engine/Rendering/RenderSystem.h b/include/Engine/Rendering/RenderSystem.h index d73d8680..7580d654 100644 --- a/include/Engine/Rendering/RenderSystem.h +++ b/include/Engine/Rendering/RenderSystem.h @@ -18,6 +18,7 @@ #include "../Core/EPlayerSpawned.h" #include "../Core/Octree.h" #include "../Collision/EntityAABB.h" +#include "../Core/ConfigFile.h" class RenderSystem : public ImpureSystem { @@ -48,6 +49,9 @@ private: void fillDirectionalLights(std::list>& jobs, World* world); void fillLight(std::list>& jobs); void fillSprites(std::list>& jobs, World* world); + + bool isEntityVisible(EntityWrapper& entity); + bool isChildOfACamera(EntityWrapper entity); bool isChildOfCurrentCamera(EntityWrapper entity); }; diff --git a/resources/DefaultConfig.ini b/resources/DefaultConfig.ini index 12ec06c8..6911632f 100644 --- a/resources/DefaultConfig.ini +++ b/resources/DefaultConfig.ini @@ -4,6 +4,8 @@ LoadMap= ; if true -> Pool allocation is not used when calling Allocate/Free, just use regular dynamic allocation. ; if false -> Use pool allocation. DisableMemoryPool=false +EditorEnabled=false +OutOfBodyExperience=false [Editor] CameraSpeed=3 diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index 6600bc4f..7beb85db 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -47,16 +47,8 @@ void RenderSystem::fillSprites(std::list>& jobs, Worl continue; } - EntityWrapper entity(world, cSprite.EntityID); - - // Only render children of a camera if that camera is currently active - if (isChildOfACamera(entity) && !isChildOfCurrentCamera(entity)) { - continue; - } - - // Hide things parented to local player if they have the HiddenFromLocalPlayer component - if (entity.HasComponent("HiddenForLocalPlayer") && (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer))) { + if (!isEntityVisible(entity)) { continue; } @@ -85,6 +77,23 @@ void RenderSystem::fillSprites(std::list>& jobs, Worl } } +bool RenderSystem::isEntityVisible(EntityWrapper& entity) +{ + + // Only render children of a camera if that camera is currently active + if (isChildOfACamera(entity) && !isChildOfCurrentCamera(entity)) { + return false; + } + + // Hide things parented to local player if they have the HiddenFromLocalPlayer component + bool outOfBodyExperience = ResourceManager::Load("Config.ini")->Get("Debug.OutOfBodyExperience", false); + if (entity.HasComponent("HiddenForLocalPlayer") && (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer)) && !outOfBodyExperience) { + return false; + } + + return true; +} + bool RenderSystem::isChildOfACamera(EntityWrapper entity) { return entity.FirstParentWithComponent("Camera").Valid(); @@ -112,13 +121,7 @@ void RenderSystem::fillModels(RenderScene::Queues &Jobs) continue; } - // Only render children of a camera if that camera is currently active - if (isChildOfACamera(entity) && !isChildOfCurrentCamera(entity)) { - continue; - } - - // Hide things parented to local player if they have the HiddenFromLocalPlayer component - if ((entity.HasComponent("HiddenForLocalPlayer") || entity.FirstParentWithComponent("HiddenForLocalPlayer").Valid()) && (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer))) { + if (!isEntityVisible(entity)) { continue; } @@ -299,6 +302,11 @@ void RenderSystem::fillText(std::list>& jobs, World* continue; } + EntityWrapper entity(world, textComponent.EntityID); + if (!isEntityVisible(entity)) { + continue; + } + Font* font; try { font = ResourceManager::Load(resource); diff --git a/src/Game/Systems/PlayerSpawnSystem.cpp b/src/Game/Systems/PlayerSpawnSystem.cpp index 507ed0f5..444fc08f 100644 --- a/src/Game/Systems/PlayerSpawnSystem.cpp +++ b/src/Game/Systems/PlayerSpawnSystem.cpp @@ -88,7 +88,8 @@ bool PlayerSpawnSystem::OnPlayerSpawned(Events::PlayerSpawned& e) // Set the camera to the correct entity EntityWrapper cameraEntity = e.Player.FirstChildByName("Camera"); - if (cameraEntity.Valid()) { + bool outOfBodyExperience = ResourceManager::Load("Config.ini")->Get("Debug.OutOfBodyExperience", false); + if (cameraEntity.Valid() && !outOfBodyExperience) { Events::SetCamera e; e.CameraEntity = cameraEntity; m_EventBroker->Publish(e); diff --git a/tools/deploy.bat b/tools/deploy.bat index 29dc9e62..cd7a44bc 100755 --- a/tools/deploy.bat +++ b/tools/deploy.bat @@ -22,7 +22,9 @@ MKLINK "%DeployLocation%\Schema\" "resources\Schema" /J RMDIR /S /Q "%DeployLocation%\Shaders" MKLINK "%DeployLocation%\Shaders\" "resources\Shaders" /J :: Configuration files +DEL "%DeployLocation%\DefaultConfig.ini" MKLINK "%DeployLocation%\DefaultConfig.ini" "resources\DefaultConfig.ini" /H +DEL "%DeployLocation%\DefaultInput.ini" MKLINK "%DeployLocation%\DefaultInput.ini" "resources\DefaultInput.ini" /H :: Platform specific binaries