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:
2016-01-25 00:25:03 +01:00
18 changed files with 357 additions and 109 deletions
+7 -1
View File
@@ -17,7 +17,7 @@
struct ModelJob : RenderJob struct ModelJob : RenderJob
{ {
ModelJob(Model* model, Camera* camera, glm::mat4 matrix, ::RawModel::MaterialGroup matGroup, ComponentWrapper modelComponent, World* world) ModelJob(Model* model, Camera* camera, glm::mat4 matrix, ::RawModel::MaterialGroup matGroup, ComponentWrapper modelComponent, World* world, glm::vec4 fillColor, float fillPercentage)
: RenderJob() : RenderJob()
{ {
Model = model; Model = model;
@@ -39,6 +39,9 @@ struct ModelJob : RenderJob
Depth = worldpos.z; Depth = worldpos.z;
World = world; World = world;
FillColor = fillColor;
FillPercentage = fillPercentage;
Skeleton = Model->m_RawModel->m_Skeleton; Skeleton = Model->m_RawModel->m_Skeleton;
if (world->HasComponent(Entity, "Animation") && Skeleton != nullptr) { if (world->HasComponent(Entity, "Animation") && Skeleton != nullptr) {
@@ -72,6 +75,9 @@ struct ModelJob : RenderJob
unsigned int EndIndex = 0; unsigned int EndIndex = 0;
World* World; World* World;
glm::vec4 FillColor = glm::vec4(0);
float FillPercentage = 0.0;
void CalculateHash() override void CalculateHash() override
{ {
Hash = TextureID; Hash = TextureID;
+1
View File
@@ -29,6 +29,7 @@ private:
const IRenderer* m_Renderer; const IRenderer* m_Renderer;
RenderFrame* m_RenderFrame; RenderFrame* m_RenderFrame;
Camera* m_Camera; Camera* m_Camera;
World* m_World;
EntityWrapper m_CurrentCamera = EntityWrapper::Invalid; EntityWrapper m_CurrentCamera = EntityWrapper::Invalid;
EntityWrapper m_LocalPlayer = EntityWrapper::Invalid; EntityWrapper m_LocalPlayer = EntityWrapper::Invalid;
+23
View File
@@ -0,0 +1,23 @@
#ifndef PlayerHUD_h__
#define PlayerHUD_h__
#include "../../Engine/Core/System.h"
#include "../../Engine/GLM.h"
#include "../../Engine/Rendering/ESetCamera.h"
#include <imgui/imgui.h>
class PlayerHUD : public ImpureSystem
{
public:
PlayerHUD(World* world, EventBroker* eventBrokerer);
~PlayerHUD();
virtual void Update(double dt) override;
private:
World* m_World;
EventBroker* m_EventBroker;
};
#endif
+2
View File
@@ -23,5 +23,7 @@
<xs:include schemaLocation="Components/Team.xsd"/> <xs:include schemaLocation="Components/Team.xsd"/>
<xs:include schemaLocation="Components/UniformScale.xsd"/> <xs:include schemaLocation="Components/UniformScale.xsd"/>
<xs:include schemaLocation="Components/EditorWidget.xsd"/> <xs:include schemaLocation="Components/EditorWidget.xsd"/>
<xs:include schemaLocation="Components/HealthHUD.xsd"/>
<xs:include schemaLocation="Components/Animation.xsd"/> <xs:include schemaLocation="Components/Animation.xsd"/>
<xs:include schemaLocation="Components/Fill.xsd"/>
</xs:schema> </xs:schema>
+5
View File
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Fill xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Fill.xsd">
<Percentage>0.0</Percentage>
<Color R="1" G="1" B="1" A="1"/>
</Fill>
+14
View File
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
<xs:element name="Fill">
<xs:complexType>
<xs:all>
<xs:element name="Percentage" type="t:double" minOccurs="0"/>
<xs:element name="Color" type="t:Color" minOccurs="0"/>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Listener xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Listener.xsd"/>
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
<xs:element name="HealthHUD">
</xs:element>
</xs:schema>
+30 -2
View File
@@ -2,6 +2,7 @@
<Entity name="Player" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd"> <Entity name="Player" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components> <Components>
<c:Health/>
<c:AABB> <c:AABB>
<Origin X="0" Y="0.772000015" Z="0"/> <Origin X="0" Y="0.772000015" Z="0"/>
<Size X="1" Y="1.60000002" Z="1"/> <Size X="1" Y="1.60000002" Z="1"/>
@@ -16,9 +17,8 @@
<Red/> <Red/>
</Team> </Team>
</c:Team> </c:Team>
<c:Transform> <c:Transform/>
<Position X="-0.246963501" Y="0.0264999941" Z="3.01600003"/> <Position X="-0.246963501" Y="0.0264999941" Z="3.01600003"/>
</c:Transform>
</Components> </Components>
<Children> <Children>
@@ -58,6 +58,34 @@
</Components> </Components>
<Children/> <Children/>
</Entity> </Entity>
<Entity name="HUD">
<Components>
<c:Transform>
<Position X="0" Y="0" Z="-0.5"/>
</c:Transform>
</Components>
<Children>
<Entity name="HealthBar">
<Components>
<c:HealthHUD/>
<c:Fill>
<Percentage>1</Percentage>
<Color A="0" B="1" G="0" R="0"/>
</c:Fill>
<c:Model>
<Resource>Models/Core/UnitHexagon.mesh</Resource>
<Color A="1" B="0.70588237" G="0.70588237" R="0.70588237"/>
</c:Model>
<c:Transform>
<Position X="-0.383000016" Y="-0.185000002" Z="0"/>
<Scale X="0.150000006" Y="0.150000006" Z="0.150000006"/>
<Orientation X="0" Y="0.594000041" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children> </Children>
</Entity> </Entity>
<Entity name="ThirdPersonCamera"> <Entity name="ThirdPersonCamera">
+154 -97
View File
@@ -6,34 +6,115 @@
</Components> </Components>
<Children> <Children>
<Entity> <Entity name="Player">
<Components> <Components>
<c:Camera/> <c:Health>
<c:Model> <Health>65.990005493164063</Health>
<Resource>Models/Camera.mesh</Resource> </c:Health>
</c:Model> <c:Player/>
<c:Transform> <c:Transform>
<Position X="-0.504807115" Y="6.00582743" Z="9.68687439"/> <Position X="0" Y="0" Z="2.5"/>
<Orientation X="-0.733036518" Y="0.000105090476" Z="5.12391125e-07"/>
</c:Transform> </c:Transform>
</Components> </Components>
<Children> <Children>
<Entity> <Entity name="Model">
<Components> <Components>
<c:Text> <c:Model>
<Content>Camera #2</Content> <Resource>Models/Assault.obj</Resource>
<Resource>Fonts/DroidSans.ttf,64</Resource> <Color A="1" B="3.92156863" G="3.92156863" R="3.92156863"/>
<Alignment> </c:Model>
<Right/>
</Alignment>
</c:Text>
<c:Transform> <c:Transform>
<Position X="0.700063765" Y="0.310270816" Z="-1"/> <Orientation X="0" Y="3.14159203" Z="0"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
</c:Transform> </c:Transform>
</Components> </Components>
<Children/> <Children/>
</Entity> </Entity>
<Entity name="Camera">
<Components>
<c:Camera>
<FOV>80</FOV>
</c:Camera>
<c:Model>
<Resource>Models/Camera.mesh</Resource>
</c:Model>
<c:Transform>
<Position X="0" Y="1.39121652" Z="-0.043014247"/>
<Orientation X="6.28300047" Y="0" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity name="HUD">
<Components>
<c:Transform>
<Position X="0" Y="-0.000463247066" Z="-0.744767368"/>
</c:Transform>
</Components>
<Children>
<Entity name="Hexagon">
<Components>
<c:HealthHUD/>
<c:Fill>
<Percentage>0.65990006923675537</Percentage>
<Color A="0" B="0.659900069" G="0" R="0.340099931"/>
</c:Fill>
<c:Model>
<Resource>Models/Core/UnitHexagon.mesh</Resource>
<Color A="0.313725501" B="0.70588237" G="0.70588237" R="0.70588237"/>
</c:Model>
<c:Transform>
<Position X="-0.285538822" Y="-0.282350302" Z="-1.52214652e-05"/>
<Scale X="0.200000003" Y="0.200000003" Z="0.5"/>
<Orientation X="0" Y="0.666000009" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity name="Ammo">
<Components>
<c:Text>
<Content>24</Content>
<Resource>Fonts/DroidSans.ttf,60</Resource>
</c:Text>
<c:Transform>
<Position X="-1.43861985e-06" Y="0.0125972452" Z="0.0100018298"/>
<Scale X="0.349999994" Y="0.349999994" Z="0.200000003"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Text>
<Content>262</Content>
<Resource>Fonts/DroidSans.ttf,60</Resource>
</c:Text>
<c:Transform>
<Position X="-4.27209579e-06" Y="-0.0390000008" Z="5.43686883e-06"/>
<Scale X="0.65200001" Y="0.643000007" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
<Entity>
<Components>
<c:HealthHUD/>
<c:Text>
<Content>65/100</Content>
<Resource>Fonts/DroidSans.ttf,60</Resource>
<Color A="1" B="0.659900069" G="0" R="0.340099931"/>
</c:Text>
<c:Transform>
<Scale X="0.200000003" Y="0.200000003" Z="0.200000003"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
</Children> </Children>
</Entity> </Entity>
<Entity> <Entity>
@@ -42,7 +123,7 @@
<Resource>Models/Core/UnitPlane.mesh</Resource> <Resource>Models/Core/UnitPlane.mesh</Resource>
</c:Model> </c:Model>
<c:Transform> <c:Transform>
<Position X="0" Y="-1" Z="0.600000024"/> <Position X="0" Y="-0.689623177" Z="0.600000024"/>
<Scale X="100" Y="1" Z="100"/> <Scale X="100" Y="1" Z="100"/>
</c:Transform> </c:Transform>
</Components> </Components>
@@ -52,6 +133,7 @@
<Components> <Components>
<c:Model> <c:Model>
<Resource>Models/Assault.mesh</Resource> <Resource>Models/Assault.mesh</Resource>
<Color A="1" B="3.92156863" G="1" R="1"/>
</c:Model> </c:Model>
<c:Transform> <c:Transform>
<Position X="-2.5" Y="0" Z="1"/> <Position X="-2.5" Y="0" Z="1"/>
@@ -64,7 +146,7 @@
<c:Text> <c:Text>
<Content>Welcome!</Content> <Content>Welcome!</Content>
<Resource>Fonts/DroidSans.ttf,1280</Resource> <Resource>Fonts/DroidSans.ttf,1280</Resource>
<Color A="0" B="1" G="7.84313726" R="1"/> <Color A="0" B="3.92156863" G="3.92156863" R="3.92156863"/>
</c:Text> </c:Text>
<c:Transform> <c:Transform>
<Position X="0" Y="0" Z="0.700000048"/> <Position X="0" Y="0" Z="0.700000048"/>
@@ -75,32 +157,40 @@
<Entity> <Entity>
<Components> <Components>
<c:RaptorCopter> <c:RaptorCopter>
<Speed>2</Speed> <Speed>3</Speed>
<Axis X="0" Y="1" Z="0"/> <Axis X="0.200000003" Y="3.4000001" Z="0.5"/>
</c:RaptorCopter> </c:RaptorCopter>
<c:Transform> <c:Transform>
<Position X="0" Y="2.37320328" Z="0"/> <Orientation X="758.058899" Y="20632.8691" Z="1320.68018"/>
<Orientation X="0" Y="9868.3418" Z="0"/>
</c:Transform> </c:Transform>
</Components> </Components>
<Children> <Children>
<Entity> <Entity>
<Components> <Components>
<c:Model>
<Resource>Models/Core/UnitSphere.obj</Resource>
<Color A="1" B="7.84313726" G="0" R="7.84313726"/>
</c:Model>
<c:PointLight> <c:PointLight>
<Color A="1" B="1" G="0" R="1"/> <Color A="1" B="1" G="0" R="1"/>
<Radius>6</Radius> <Radius>70</Radius>
<Intensity>0.5</Intensity> <Intensity>0.5</Intensity>
</c:PointLight> </c:PointLight>
<c:Transform> <c:Transform>
<Position X="-2.5" Y="0" Z="0"/> <Position X="-2.5" Y="0" Z="0"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
</c:Transform> </c:Transform>
</Components> </Components>
<Children> <Children>
<Entity> <Entity>
<Components> <Components>
<c:Model>
<Resource>Models/Core/UnitSphere.obj</Resource>
<Color A="1" B="0" G="0" R="7.84313726"/>
</c:Model>
<c:PointLight> <c:PointLight>
<Color A="1" B="0" G="0" R="1"/> <Color A="1" B="0" G="0" R="1"/>
<Radius>8</Radius> <Radius>70</Radius>
</c:PointLight> </c:PointLight>
<c:Transform> <c:Transform>
<Position X="-5" Y="0" Z="0"/> <Position X="-5" Y="0" Z="0"/>
@@ -112,21 +202,30 @@
</Entity> </Entity>
<Entity> <Entity>
<Components> <Components>
<c:Model>
<Resource>Models/Core/UnitSphere.obj</Resource>
<Color A="1" B="0" G="7.84313726" R="7.84313726"/>
</c:Model>
<c:PointLight> <c:PointLight>
<Color A="1" B="0" G="1" R="1"/> <Color A="1" B="0" G="1" R="1"/>
<Radius>6</Radius> <Radius>70</Radius>
<Intensity>0.5</Intensity> <Intensity>0.5</Intensity>
</c:PointLight> </c:PointLight>
<c:Transform> <c:Transform>
<Position X="0" Y="0" Z="-2.5"/> <Position X="0" Y="0" Z="-2.5"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
</c:Transform> </c:Transform>
</Components> </Components>
<Children> <Children>
<Entity> <Entity>
<Components> <Components>
<c:Model>
<Resource>Models/Core/UnitSphere.obj</Resource>
<Color A="1" B="0" G="7.84313726" R="0"/>
</c:Model>
<c:PointLight> <c:PointLight>
<Color A="1" B="0" G="1" R="0"/> <Color A="1" B="0" G="1" R="0"/>
<Radius>8</Radius> <Radius>70</Radius>
</c:PointLight> </c:PointLight>
<c:Transform> <c:Transform>
<Position X="0" Y="0" Z="-5"/> <Position X="0" Y="0" Z="-5"/>
@@ -138,21 +237,30 @@
</Entity> </Entity>
<Entity> <Entity>
<Components> <Components>
<c:Model>
<Resource>Models/Core/UnitSphere.obj</Resource>
<Color A="1" B="7.84313726" G="7.84313726" R="0"/>
</c:Model>
<c:PointLight> <c:PointLight>
<Color A="1" B="1" G="1" R="0"/> <Color A="1" B="1" G="1" R="0"/>
<Radius>6</Radius> <Radius>70</Radius>
<Intensity>0.5</Intensity> <Intensity>0.5</Intensity>
</c:PointLight> </c:PointLight>
<c:Transform> <c:Transform>
<Position X="0" Y="0" Z="2.5"/> <Position X="0" Y="0" Z="2.5"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
</c:Transform> </c:Transform>
</Components> </Components>
<Children> <Children>
<Entity> <Entity>
<Components> <Components>
<c:Model>
<Resource>Models/Core/UnitSphere.obj</Resource>
<Color A="1" B="7.84313726" G="0" R="0"/>
</c:Model>
<c:PointLight> <c:PointLight>
<Color A="1" B="1" G="0.00784313772" R="0"/> <Color A="1" B="1" G="0" R="0"/>
<Radius>8</Radius> <Radius>70</Radius>
</c:PointLight> </c:PointLight>
<c:Transform> <c:Transform>
<Position X="0" Y="0" Z="5"/> <Position X="0" Y="0" Z="5"/>
@@ -164,19 +272,28 @@
</Entity> </Entity>
<Entity> <Entity>
<Components> <Components>
<c:Model>
<Resource>Models/Core/UnitSphere.obj</Resource>
<Color A="1" B="7.84313726" G="7.84313726" R="7.84313726"/>
</c:Model>
<c:PointLight> <c:PointLight>
<Radius>6</Radius> <Radius>70</Radius>
<Intensity>0.5</Intensity> <Intensity>0.5</Intensity>
</c:PointLight> </c:PointLight>
<c:Transform> <c:Transform>
<Position X="2.5" Y="0" Z="0"/> <Position X="2.5" Y="0" Z="0"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
</c:Transform> </c:Transform>
</Components> </Components>
<Children> <Children>
<Entity> <Entity>
<Components> <Components>
<c:Model>
<Resource>Models/Core/UnitSphere.obj</Resource>
<Color A="1" B="7.84313726" G="7.84313726" R="7.84313726"/>
</c:Model>
<c:PointLight> <c:PointLight>
<Radius>8</Radius> <Radius>70</Radius>
</c:PointLight> </c:PointLight>
<c:Transform> <c:Transform>
<Position X="5" Y="0" Z="0"/> <Position X="5" Y="0" Z="0"/>
@@ -192,6 +309,7 @@
<Components> <Components>
<c:Model> <c:Model>
<Resource>Models/Assault.mesh</Resource> <Resource>Models/Assault.mesh</Resource>
<Color A="1" B="1" G="1" R="3.92156863"/>
</c:Model> </c:Model>
<c:Transform> <c:Transform>
<Position X="2.5" Y="0" Z="1"/> <Position X="2.5" Y="0" Z="1"/>
@@ -199,46 +317,15 @@
</Components> </Components>
<Children/> <Children/>
</Entity> </Entity>
<Entity> <Entity name="DirectionalLight">
<Components>
<c:Camera/>
<c:Listener/>
<c:Model>
<Resource>Models/Camera.mesh</Resource>
<Visible>false</Visible>
</c:Model>
<c:Transform>
<Position X="-1.27354908" Y="5.18422079" Z="10.6223917"/>
<Orientation X="-0.436328411" Y="-0.0523675606" Z="1.67869363e-08"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Text>
<Content>Taiwan #1</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Alignment>
<Right/>
</Alignment>
</c:Text>
<c:Transform>
<Position X="0.716896772" Y="0.296712071" Z="-1"/>
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity>
<Components> <Components>
<c:DirectionalLight> <c:DirectionalLight>
<Color A="1" B="0.996078432" G="1" R="1"/> <Color A="1" B="0.996078432" G="1" R="1"/>
<Intensity>0.80000001192092896</Intensity> <Intensity>0.10000000149011612</Intensity>
</c:DirectionalLight> </c:DirectionalLight>
<c:Model> <c:Model>
<Resource>Models/DirectionalLightWidget.mesh</Resource> <Resource>Models/DirectionalLightWidget.mesh</Resource>
<Color A="1" B="0" G="3.92156863" R="3.92156863"/>
</c:Model> </c:Model>
<c:Transform> <c:Transform>
<Position X="-0.0013256073" Y="1.89540339" Z="6.53467274"/> <Position X="-0.0013256073" Y="1.89540339" Z="6.53467274"/>
@@ -251,6 +338,7 @@
<Components> <Components>
<c:Model> <c:Model>
<Resource>Models/Core/UnitCube.mesh</Resource> <Resource>Models/Core/UnitCube.mesh</Resource>
<Color A="1" B="1" G="39.2156868" R="1"/>
</c:Model> </c:Model>
<c:Transform> <c:Transform>
<Position X="-5.4082036" Y="0" Z="-1.84950542"/> <Position X="-5.4082036" Y="0" Z="-1.84950542"/>
@@ -258,37 +346,6 @@
</Components> </Components>
<Children/> <Children/>
</Entity> </Entity>
<Entity>
<Components>
<c:Animation/>
<c:Model>
<Resource>asd</Resource>
<Color A="1" B="1" G="3.92156863" R="1"/>
</c:Model>
<c:Transform>
<Position X="0" Y="0" Z="-6.38434124"/>
<Orientation X="5.046" Y="0" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Animation>
<Name>running</Name>
<Time>0.93047409991569907</Time>
<Speed>1</Speed>
</c:Animation>
<c:Model>
<Resource>Models/Animtest.mesh</Resource>
<Color A="1" B="11.7647057" G="1" R="11.7647057"/>
</c:Model>
<c:Transform>
<Position X="-1.42184281" Y="1.71298718" Z="-6.31712198"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children> </Children>
</Entity> </Entity>
+17 -2
View File
@@ -6,9 +6,12 @@ uniform mat4 P;
uniform vec4 Color; uniform vec4 Color;
uniform vec4 DiffuseColor; uniform vec4 DiffuseColor;
uniform vec2 ScreenDimensions; uniform vec2 ScreenDimensions;
uniform vec4 FillColor;
uniform float FillPercentage;
layout (binding = 0) uniform sampler2D DiffuseTexture; layout (binding = 0) uniform sampler2D DiffuseTexture;
layout (binding = 1) uniform sampler2D GlowMap; layout (binding = 1) uniform sampler2D GlowMap;
#define TILE_SIZE 16 #define TILE_SIZE 16
struct LightSource { struct LightSource {
@@ -136,10 +139,21 @@ void main()
//sceneColor += Input.DiffuseColor; //sceneColor += Input.DiffuseColor;
vec4 color_result = DiffuseColor * (totalLighting.Diffuse + totalLighting.Specular) * diffuseTexel * Color; vec4 color_result = DiffuseColor * (totalLighting.Diffuse + totalLighting.Specular) * diffuseTexel * Color;
float pos = ((P * vec4(Input.Position, 1)).y + 1.0)/2.0;
if(pos <= FillPercentage) {
color_result += FillColor;
}
//bloomColor = vec4(0.3, 0.8, 0.6, 1.0); //bloomColor = vec4(0.3, 0.8, 0.6, 1.0);
sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1)); sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1));
//These if statements should be removed if they are slow. //These if statements should be removed if they are slow.
color_result += glowTexel; color_result += glowTexel;
bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), 1.0); bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), 1.0);
/* /*
if(color_result.x > 1 || color_result.y > 1 || color_result.z > 1) { if(color_result.x > 1 || color_result.y > 1 || color_result.z > 1) {
@@ -150,8 +164,9 @@ void main()
//sceneColor += Input.DiffuseColor * (totalLighting.Diffuse) * diffuseTexel * Color; //sceneColor += Input.DiffuseColor * (totalLighting.Diffuse) * diffuseTexel * Color;
//sceneColor += Input.DiffuseColor + vec4(0.0, LightGrids.Data[currentTile].Amount/3, 0, 1); //sceneColor += Input.DiffuseColor + vec4(0.0, LightGrids.Data[currentTile].Amount/3, 0, 1);
//sceneColor = diffuseTexel * Input.DiffuseColor * Color;
//sceneColor += vec4(currentTile/3600.f, 0, 0, 1);
//Tiled Debug Code //Tiled Debug Code
/* /*
+9
View File
@@ -1,4 +1,5 @@
#include "Editor/EditorGUI.h" #include "Editor/EditorGUI.h"
#include "Rendering/ESetCamera.h"
EditorGUI::EditorGUI(World* world, EventBroker* eventBroker) EditorGUI::EditorGUI(World* world, EventBroker* eventBroker)
: m_World(world) : 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; return true;
} }
+1 -1
View File
@@ -48,7 +48,7 @@ void EditorRenderSystem::Update(double dt)
EntityWrapper entity(m_World, cModel.EntityID); EntityWrapper entity(m_World, cModel.EntityID);
glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, entity.World); glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, entity.World);
for (auto matGroup : model->MaterialGroups()) { 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); scene.ForwardJobs.push_back(modelJob);
} }
} }
+1 -1
View File
@@ -203,7 +203,7 @@ bool EditorSystem::OnSetCamera(const Events::SetCamera& e)
m_ActualCamera = e.CameraEntity; m_ActualCamera = e.CameraEntity;
Events::SetCamera e2; Events::SetCamera e2;
e2.CameraEntity = m_EditorCamera; e2.CameraEntity = m_EditorCamera;
m_EventBroker->Publish(e2); //m_EventBroker->Publish(e2);
} }
return true; return true;
} }
+4
View File
@@ -75,6 +75,10 @@ void DrawFinalPass::Draw(RenderScene& scene)
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(modelJob->Color)); glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(modelJob->Color));
glUniform4fv(glGetUniformLocation(shaderHandle, "DiffuseColor"), 1, glm::value_ptr(modelJob->DiffuseColor)); 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); glActiveTexture(GL_TEXTURE0);
if(modelJob->DiffuseTexture != nullptr) { if(modelJob->DiffuseTexture != nullptr) {
glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture->m_Texture); glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture->m_Texture);
+19 -5
View File
@@ -4,6 +4,7 @@ RenderSystem::RenderSystem(World* world, EventBroker* eventBroker, const IRender
: System(world, eventBroker) : System(world, eventBroker)
, m_Renderer(renderer) , m_Renderer(renderer)
, m_RenderFrame(renderFrame) , m_RenderFrame(renderFrame)
, m_World(world)
{ {
EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &RenderSystem::OnSetCamera); EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &RenderSystem::OnSetCamera);
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &RenderSystem::OnInputCommand); 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 // Don't render the local player
if (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer)) { 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; 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); glm::mat4 modelMatrix = Transform::ModelMatrix(modelComponent.EntityID, m_World);
for (auto matGroup : model->MaterialGroups()) { 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); 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); glm::mat4 modelMatrix = Transform::ModelMatrix(textComponent.EntityID, world);
std::shared_ptr<TextJob> modelJob = std::shared_ptr<TextJob>(new TextJob(modelMatrix, font, textComponent)); std::shared_ptr<TextJob> textJob = std::shared_ptr<TextJob>(new TextJob(modelMatrix, font, textComponent));
jobs.push_back(modelJob); jobs.push_back(textJob);
} }
} }
@@ -177,7 +192,6 @@ void RenderSystem::Update(double dt)
m_Camera->SetOrientation(Transform::AbsoluteOrientation(m_CurrentCamera)); m_Camera->SetOrientation(Transform::AbsoluteOrientation(m_CurrentCamera));
} }
//Only supports opaque geometry atm
RenderScene scene; RenderScene scene;
scene.Camera = m_Camera; scene.Camera = m_Camera;
+3
View File
@@ -10,6 +10,7 @@
#include "Core/EntityFileWriter.h" #include "Core/EntityFileWriter.h"
#include "Game/Systems/CapturePointSystem.h" #include "Game/Systems/CapturePointSystem.h"
#include "Game/Systems/WeaponSystem.h" #include "Game/Systems/WeaponSystem.h"
#include "Game/Systems/PlayerHUD.h"
#include "../Engine/Rendering/AnimationSystem.h" #include "../Engine/Rendering/AnimationSystem.h"
Game::Game(int argc, char* argv[]) Game::Game(int argc, char* argv[])
@@ -87,7 +88,9 @@ Game::Game(int argc, char* argv[])
// Populate Octree with collidables // Populate Octree with collidables
++updateOrderLevel; ++updateOrderLevel;
m_SystemPipeline->AddSystem<CollidableOctreeSystem>(updateOrderLevel, m_OctreeCollision); m_SystemPipeline->AddSystem<CollidableOctreeSystem>(updateOrderLevel, m_OctreeCollision);
m_SystemPipeline->AddSystem<PlayerHUD>(updateOrderLevel);
m_SystemPipeline->AddSystem<AnimationSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<AnimationSystem>(updateOrderLevel);
// Collision and TriggerSystem should update after player. // Collision and TriggerSystem should update after player.
++updateOrderLevel; ++updateOrderLevel;
m_SystemPipeline->AddSystem<CollisionSystem>(updateOrderLevel, m_OctreeCollision); m_SystemPipeline->AddSystem<CollisionSystem>(updateOrderLevel, m_OctreeCollision);
+57
View File
@@ -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;
}
}
}
}