Merge remote-tracking branch 'origin/Menu'
# Conflicts: # include/Engine/Rendering/ModelJob.h # resources/Schema/Components.xsd # resources/Schema/Entities/Player.xml # resources/Schema/Entities/RenderingWorld.xml # src/Game/Game.cpp
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "Editor/EditorGUI.h"
|
||||
#include "Rendering/ESetCamera.h"
|
||||
|
||||
EditorGUI::EditorGUI(World* world, EventBroker* eventBroker)
|
||||
: m_World(world)
|
||||
@@ -305,6 +306,14 @@ bool EditorGUI::drawComponentNode(EntityWrapper entity, const ComponentInfo& ci)
|
||||
}
|
||||
}
|
||||
|
||||
if (ci.Name == "Camera") {
|
||||
if (ImGui::Button("Activate")) {
|
||||
Events::SetCamera e;
|
||||
e.CameraEntity = entity;
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ void EditorRenderSystem::Update(double dt)
|
||||
EntityWrapper entity(m_World, cModel.EntityID);
|
||||
glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, entity.World);
|
||||
for (auto matGroup : model->MaterialGroups()) {
|
||||
std::shared_ptr<ModelJob> modelJob = std::make_shared<ModelJob>(model, scene.Camera, modelMatrix, matGroup, cModel, entity.World);
|
||||
std::shared_ptr<ModelJob> modelJob = std::make_shared<ModelJob>(model, scene.Camera, modelMatrix, matGroup, cModel, entity.World, glm::vec4(0), 0.f);
|
||||
scene.ForwardJobs.push_back(modelJob);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ bool EditorSystem::OnSetCamera(const Events::SetCamera& e)
|
||||
m_ActualCamera = e.CameraEntity;
|
||||
Events::SetCamera e2;
|
||||
e2.CameraEntity = m_EditorCamera;
|
||||
m_EventBroker->Publish(e2);
|
||||
//m_EventBroker->Publish(e2);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -75,6 +75,10 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
||||
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(modelJob->Color));
|
||||
glUniform4fv(glGetUniformLocation(shaderHandle, "DiffuseColor"), 1, glm::value_ptr(modelJob->DiffuseColor));
|
||||
|
||||
glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(modelJob->FillColor));
|
||||
glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), modelJob->FillPercentage);
|
||||
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
if(modelJob->DiffuseTexture != nullptr) {
|
||||
glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture->m_Texture);
|
||||
|
||||
@@ -4,6 +4,7 @@ RenderSystem::RenderSystem(World* world, EventBroker* eventBroker, const IRender
|
||||
: System(world, eventBroker)
|
||||
, m_Renderer(renderer)
|
||||
, m_RenderFrame(renderFrame)
|
||||
, m_World(world)
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &RenderSystem::OnSetCamera);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &RenderSystem::OnInputCommand);
|
||||
@@ -51,7 +52,9 @@ void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& jobs)
|
||||
|
||||
// Don't render the local player
|
||||
if (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer)) {
|
||||
continue;
|
||||
if (!entity.HasComponent("HealthHUD")) { //Should work but needs to be fixed. Should only render the things "childed" to the local player camera
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Model* model;
|
||||
@@ -68,9 +71,21 @@ void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& jobs)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
float fillPercentage = 0.f;
|
||||
glm::vec4 fillColor = glm::vec4(0);
|
||||
|
||||
if(m_World->HasComponent(modelComponent.EntityID, "Fill")) {
|
||||
auto fillComponent = m_World->GetComponent(modelComponent.EntityID, "Fill");
|
||||
fillPercentage = (float)(double)fillComponent["Percentage"];
|
||||
fillColor = (glm::vec4)fillComponent["Color"];
|
||||
}
|
||||
|
||||
|
||||
|
||||
glm::mat4 modelMatrix = Transform::ModelMatrix(modelComponent.EntityID, m_World);
|
||||
for (auto matGroup : model->MaterialGroups()) {
|
||||
std::shared_ptr<ModelJob> modelJob = std::shared_ptr<ModelJob>(new ModelJob(model, m_Camera, modelMatrix, matGroup, modelComponent, m_World));
|
||||
std::shared_ptr<ModelJob> modelJob = std::shared_ptr<ModelJob>(new ModelJob(model, m_Camera, modelMatrix, matGroup, modelComponent, m_World, fillColor, fillPercentage));
|
||||
jobs.push_back(modelJob);
|
||||
}
|
||||
}
|
||||
@@ -156,8 +171,8 @@ void RenderSystem::fillText(std::list<std::shared_ptr<RenderJob>>& jobs, World*
|
||||
}
|
||||
|
||||
glm::mat4 modelMatrix = Transform::ModelMatrix(textComponent.EntityID, world);
|
||||
std::shared_ptr<TextJob> modelJob = std::shared_ptr<TextJob>(new TextJob(modelMatrix, font, textComponent));
|
||||
jobs.push_back(modelJob);
|
||||
std::shared_ptr<TextJob> textJob = std::shared_ptr<TextJob>(new TextJob(modelMatrix, font, textComponent));
|
||||
jobs.push_back(textJob);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -177,7 +192,6 @@ void RenderSystem::Update(double dt)
|
||||
m_Camera->SetOrientation(Transform::AbsoluteOrientation(m_CurrentCamera));
|
||||
}
|
||||
|
||||
//Only supports opaque geometry atm
|
||||
|
||||
RenderScene scene;
|
||||
scene.Camera = m_Camera;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "Core/EntityFileWriter.h"
|
||||
#include "Game/Systems/CapturePointSystem.h"
|
||||
#include "Game/Systems/WeaponSystem.h"
|
||||
#include "Game/Systems/PlayerHUD.h"
|
||||
#include "../Engine/Rendering/AnimationSystem.h"
|
||||
|
||||
Game::Game(int argc, char* argv[])
|
||||
@@ -87,7 +88,9 @@ Game::Game(int argc, char* argv[])
|
||||
// Populate Octree with collidables
|
||||
++updateOrderLevel;
|
||||
m_SystemPipeline->AddSystem<CollidableOctreeSystem>(updateOrderLevel, m_OctreeCollision);
|
||||
m_SystemPipeline->AddSystem<PlayerHUD>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<AnimationSystem>(updateOrderLevel);
|
||||
|
||||
// Collision and TriggerSystem should update after player.
|
||||
++updateOrderLevel;
|
||||
m_SystemPipeline->AddSystem<CollisionSystem>(updateOrderLevel, m_OctreeCollision);
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
#include "Game/Systems/PlayerHUD.h"
|
||||
|
||||
PlayerHUD::PlayerHUD(World* world, EventBroker* eventBrokerer)
|
||||
:System(world, eventBrokerer)
|
||||
, m_World(world)
|
||||
, m_EventBroker(eventBrokerer)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
PlayerHUD::~PlayerHUD()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void PlayerHUD::Update(double dt)
|
||||
{
|
||||
auto healthHUDs = m_World->GetComponents("HealthHUD");
|
||||
if (healthHUDs == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto& healthHUDComponent : *healthHUDs) {
|
||||
EntityWrapper entity = EntityWrapper(m_World, healthHUDComponent.EntityID);
|
||||
|
||||
EntityWrapper entityIDParent = entity;
|
||||
while (entityIDParent.Parent().Valid()) {
|
||||
entityIDParent = entityIDParent.Parent();
|
||||
|
||||
if (entityIDParent.HasComponent("Health")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (entityIDParent.HasComponent("Health")) {
|
||||
|
||||
if (entity.HasComponent("Text")) {
|
||||
std::string s = "";
|
||||
s = s + std::to_string((int)(double)entityIDParent["Health"]["Health"]);
|
||||
s = s + "/";
|
||||
s = s + std::to_string((int)(double)entityIDParent["Health"]["MaxHealth"]);
|
||||
float healthPercentage = (double)entityIDParent["Health"]["Health"]/(double)entityIDParent["Health"]["MaxHealth"];
|
||||
(glm::vec4&)entity["Text"]["Color"] = glm::vec4(1.0 - healthPercentage, 0.f, healthPercentage, 1.f);
|
||||
entity["Text"]["Content"] = s;
|
||||
}
|
||||
|
||||
if(entity.HasComponent("Fill")) {
|
||||
float healthPercentage = (double)entityIDParent["Health"]["Health"]/(double)entityIDParent["Health"]["MaxHealth"];
|
||||
(glm::vec4&)entity["Fill"]["Color"] = glm::vec4(1.0 - healthPercentage, 0.f, healthPercentage, 0.f);
|
||||
(double&)entity["Fill"]["Percentage"] = healthPercentage;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user