Compare commits
52 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 397188b855 | |||
| 0addc672b4 | |||
| 80846a29ad | |||
| e15474c3d4 | |||
| 486922a7c5 | |||
| a00c145616 | |||
| aeb29cde8b | |||
| 7f328332c4 | |||
| 0ad3d8ed76 | |||
| 4596fffb91 | |||
| 46f377c94c | |||
| 68abdbb4e0 | |||
| c55b9333a9 | |||
| 826f390d28 | |||
| 78cf4a0223 | |||
| f5f6a5cf3a | |||
| 179c5c1feb | |||
| f1a9afc097 | |||
| 00268f027a | |||
| 349fab54a4 | |||
| 0e2934647c | |||
| 756107363e | |||
| 804b0cac60 | |||
| 2d1d4f02f3 | |||
| cea2faaaf8 | |||
| 1af8d4909a | |||
| d407502432 | |||
| a31e3faa1f | |||
| 6e78307249 | |||
| 260c1295ec | |||
| 1b252c95e0 | |||
| ad075f185e | |||
| a459a1c69b | |||
| ee2f7fcecf | |||
| 370dbb96ad | |||
| 0bba9e40d4 | |||
| 0e612cb3f3 | |||
| 28c3cf5e16 | |||
| 6c8fff9ed0 | |||
| dbebd5a6e9 | |||
| 31348e774e | |||
| ed803733da | |||
| 9ccf8ecc42 | |||
| bf77fba963 | |||
| d17450b554 | |||
| cc84f04542 | |||
| eb37cc2296 | |||
| 761b8e21e1 | |||
| a5f4c9daa0 | |||
| 571edbc214 | |||
| 5d53472286 | |||
| 4b2f324d60 |
+1
-1
Submodule assets updated: 4a7b5c236d...75977fd865
+4
-4
@@ -15,12 +15,12 @@ MKLINK "%ConfigPath%\Sounds\" "assets\Sounds\" /J
|
||||
:: Shaders
|
||||
MKLINK "%ConfigPath%\Shaders\" "src\Shaders\" /J
|
||||
:: DLLs
|
||||
MKLINK "%ConfigPath%\glfw3.dll" "libs\glfw-3.0.4\lib\%Configuration%\glfw3.dll" /H
|
||||
MKLINK "%ConfigPath%\fmodex.dll" "libs\FMOD\lib\fmodex.dll" /H
|
||||
COPY "libs\glfw-3.0.4\lib\%Configuration%\glfw3.dll" "%ConfigPath%\glfw3.dll"
|
||||
COPY "libs\FMOD\lib\fmodex.dll" "%ConfigPath%\fmodex.dll"
|
||||
IF %~1==Debug (
|
||||
MKLINK "%ConfigPath%\glew32d.dll" "libs\glew-1.10.0\bin\%Configuration%\Win32\glew32d.dll" /H
|
||||
COPY "libs\glew-1.10.0\bin\%Configuration%\Win32\glew32d.dll" "%ConfigPath%\glew32d.dll"
|
||||
)
|
||||
IF %~1==Release (
|
||||
MKLINK "%ConfigPath%\glew32.dll" "libs\glew-1.10.0\bin\%Configuration%\Win32\glew32.dll" /H
|
||||
COPY "libs\glew-1.10.0\bin\%Configuration%\Win32\glew32.dll" "%ConfigPath%\glew32.dll"
|
||||
)
|
||||
GOTO:eof
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef Components_BlendMap_h__
|
||||
#define Components_BlendMap_h__
|
||||
|
||||
#include "Component.h"
|
||||
#include "Entity.h"
|
||||
|
||||
namespace Components
|
||||
{
|
||||
struct BlendMap : Component
|
||||
{
|
||||
BlendMap()
|
||||
: TextureRed("Textures/ErrorTextureRed.png")
|
||||
, TextureRedNormal("Textures/NeutralNormalMap.png")
|
||||
, TextureRedSpecular("Textures/NeutralSpecularMap.png")
|
||||
, TextureGreen("Textures/ErrorTextureGreen.png")
|
||||
, TextureGreenNormal("Textures/NeutralNormalMap.png")
|
||||
, TextureGreenSpecular("Textures/NeutralSpecularMap.png")
|
||||
, TextureBlue("Textures/ErrorTextureBlue.png")
|
||||
, TextureBlueNormal("Textures/NeutralNormalMap.png")
|
||||
, TextureBlueSpecular("Textures/NeutralSpecularMap.png")
|
||||
, TextureRepeats(100.f) { }
|
||||
|
||||
std::string TextureRed;
|
||||
std::string TextureRedNormal;
|
||||
std::string TextureRedSpecular;
|
||||
std::string TextureGreen;
|
||||
std::string TextureGreenNormal;
|
||||
std::string TextureGreenSpecular;
|
||||
std::string TextureBlue;
|
||||
std::string TextureBlueNormal;
|
||||
std::string TextureBlueSpecular;
|
||||
float TextureRepeats;
|
||||
|
||||
virtual BlendMap* Clone() const override { return new BlendMap(*this); }
|
||||
};
|
||||
|
||||
}
|
||||
#endif // !Components_BlendMap_h__
|
||||
@@ -4,18 +4,18 @@
|
||||
#include <string>
|
||||
|
||||
#include "Component.h"
|
||||
#include "Color.h"
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct Model : Component
|
||||
{
|
||||
Model() : Visible(true), ShadowCaster(true) { }
|
||||
Model() : Color(glm::vec4(1.0f, 1.0f, 1.0f, 1.0f)), Visible(true), ShadowCaster(true), Transparent(false) { }
|
||||
std::string ModelFile;
|
||||
Color Color;
|
||||
glm::vec4 Color;
|
||||
bool Visible;
|
||||
bool ShadowCaster;
|
||||
bool Transparent;
|
||||
|
||||
virtual Model* Clone() const override { return new Model(*this); }
|
||||
};
|
||||
|
||||
@@ -11,9 +11,10 @@ namespace Components
|
||||
|
||||
struct Particle : Component
|
||||
{
|
||||
std::vector<Color> ColorSpectrum;
|
||||
std::vector<glm::vec3> ScaleSpectrum;
|
||||
double LifeTime;
|
||||
double SpawnTime;
|
||||
bool Fade;
|
||||
std::vector<glm::vec3> VelocitySpectrum;
|
||||
std::vector<float> AngularVelocitySpectrum;
|
||||
std::vector<glm::vec3> OrientationSpectrum; //Keep?
|
||||
|
||||
@@ -19,20 +19,22 @@ struct ParticleEmitter : Component
|
||||
, SpawnCount(0)
|
||||
, SpreadAngle(0)
|
||||
, LifeTime(0)
|
||||
, TimeSinceLastSpawn(100) { } // TEMP fulhack så att partiklarna spawnar direkt
|
||||
, TimeSinceLastSpawn(100)
|
||||
, Color(glm::vec4(0)) { }
|
||||
|
||||
EntityID ParticleTemplate;
|
||||
float SpawnFrequency;
|
||||
float Speed;
|
||||
int SpawnCount;
|
||||
std::vector<Color> ColorSpectrum;
|
||||
glm::vec4 Color;
|
||||
std::vector<glm::vec3> ScaleSpectrum;
|
||||
float SpreadAngle;
|
||||
double LifeTime;
|
||||
bool UseGoalVelocity;
|
||||
bool Fade;
|
||||
glm::vec3 GoalVelocity;
|
||||
std::vector<float> AngularVelocitySpectrum;
|
||||
std::vector<glm::vec3> OrientationSpectrum; //Keep?
|
||||
std::vector<glm::vec3> OrientationSpectrum; //Keep? noo..
|
||||
|
||||
private:
|
||||
double TimeSinceLastSpawn;
|
||||
|
||||
@@ -16,13 +16,38 @@ struct Physics : Component
|
||||
EXPLOSION = 4,
|
||||
};
|
||||
|
||||
enum class MotionTypeEnum
|
||||
{
|
||||
Dynamic,
|
||||
Fixed,
|
||||
Keyframed
|
||||
};
|
||||
|
||||
Physics()
|
||||
: Mass(1.f), Static(false), Phantom(false), CalculateCenterOfMass(true), CenterOfMass(glm::vec3(0)), InitialLinearVelocity(glm::vec3(0)), InitialAngularVelocity(glm::vec3(0)),
|
||||
LinearDamping(0.f), AngularDamping(0.05f), GravityFactor(1.f), Friction(0.5f), Restitution(0.4f), MaxLinearVelocity(200.f), MaxAngularVelocity(200.f),
|
||||
CollisionLayer(0), CollisionSystemGroup(0), CollisionSubSystemId(0), CollisionSubSystemDontCollideWith(0), CollisionEvent(false){}
|
||||
: Mass(1.f)
|
||||
//, Static(false)
|
||||
, MotionType(MotionTypeEnum::Fixed)
|
||||
, Phantom(false)
|
||||
, CalculateCenterOfMass(true)
|
||||
, CenterOfMass(glm::vec3(0))
|
||||
, InitialLinearVelocity(glm::vec3(0))
|
||||
, InitialAngularVelocity(glm::vec3(0))
|
||||
, LinearDamping(0.f)
|
||||
, AngularDamping(0.05f)
|
||||
, GravityFactor(1.f)
|
||||
, Friction(0.5f)
|
||||
, Restitution(0.4f)
|
||||
, MaxLinearVelocity(200.f)
|
||||
, MaxAngularVelocity(200.f)
|
||||
, CollisionLayer(0)
|
||||
, CollisionSystemGroup(0)
|
||||
, CollisionSubSystemId(0)
|
||||
, CollisionSubSystemDontCollideWith(0)
|
||||
, CollisionEvent(false)
|
||||
{ }
|
||||
|
||||
float Mass;
|
||||
bool Static;
|
||||
MotionTypeEnum MotionType;
|
||||
bool Phantom;
|
||||
|
||||
bool CalculateCenterOfMass;
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef Components_VehicleSpawn_h__
|
||||
#define Components_VehicleSpawn_h__
|
||||
|
||||
#include "Component.h"
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct SpawnPoint : Component
|
||||
{
|
||||
virtual SpawnPoint* Clone() const override { return new SpawnPoint(*this); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // Components_VehicleSpawn_h__
|
||||
@@ -4,15 +4,16 @@
|
||||
#include <string>
|
||||
|
||||
#include "Component.h"
|
||||
#include "Color.h"
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct Sprite : Component
|
||||
{
|
||||
Sprite() : Color(glm::vec4(1.0f, 1.0f, 1.0f, 1.0f)) { }
|
||||
|
||||
std::string SpriteFile;
|
||||
Color Color;
|
||||
glm::vec4 Color;
|
||||
|
||||
virtual Sprite* Clone() const override { return new Sprite(*this); }
|
||||
};
|
||||
|
||||
@@ -10,10 +10,9 @@ namespace Components
|
||||
struct Vehicle : Component
|
||||
{
|
||||
Vehicle()
|
||||
: MaxTorque(1000.0f), MinRPM(0.0f), OptimalRPM(2000.0f), MaxRPM(3000.0f), MaxSteeringAngle(35), TopSpeed(70.0f),
|
||||
MaxSpeedFullSteeringAngle(40.0f), SpringDamping(1.f), UpshiftRPM(2500.0f), DownshiftRPM(500.0f),
|
||||
gearsRatio0(4.5f), gearsRatio1(2.5f), gearsRatio2(1.0f), gearsRatio3(0.5f){ }
|
||||
//gearsRatio0(3.0f), gearsRatio1(2.25f), gearsRatio2(1.5f), gearsRatio3(1.0f)
|
||||
: MaxTorque(1000.0f), MinRPM(200.0f), OptimalRPM(3000.0f), MaxRPM(6000.0f), MaxSteeringAngle(35), TopSpeed(90.0f),
|
||||
MaxSpeedFullSteeringAngle(40.0f), SpringDamping(1.f), UpshiftRPM(5500.0f), DownshiftRPM(1000.0f),
|
||||
gearsRatio0(3.0f), gearsRatio1(2.25f), gearsRatio2(1.5f), gearsRatio3(1.0f){ }
|
||||
float MaxTorque;
|
||||
float MinRPM;
|
||||
float OptimalRPM;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef Components_Wall_h__
|
||||
#define Components_Wall_h__
|
||||
|
||||
#include "Component.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct Wall : Component
|
||||
{
|
||||
std::vector<EntityID> Walldebris;
|
||||
|
||||
virtual Wall* Clone() const override { return new Wall(*this); }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // Components_TankShell_h__
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef Event_CreateExplosion_h__
|
||||
#define Event_CreateExplosion_h__
|
||||
|
||||
#include "EventBroker.h"
|
||||
#include <glm/common.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
|
||||
namespace Events
|
||||
{
|
||||
struct CreateExplosion : Event
|
||||
{
|
||||
CreateExplosion()
|
||||
: Color(glm::vec4(0)) {}
|
||||
glm::vec3 Position;
|
||||
glm::vec4 Color;
|
||||
double LifeTime;
|
||||
int ParticlesToSpawn;
|
||||
std::string spritePath;
|
||||
glm::quat RelativeUpOrientation;
|
||||
float Speed;
|
||||
float SpreadAngle;
|
||||
std::vector<float> ParticleScale;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // Event_CreateExplosion_h__
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef Events_OnDead_h__
|
||||
#define Events_OnDead_h__
|
||||
#include "Entity.h"
|
||||
#include "EventBroker.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
struct OnDead : Event
|
||||
{
|
||||
EntityID Entity;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif // Events_OnDead_h__
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef Events_SpawnVehicle_h__
|
||||
#define Events_SpawnVehicle_h__
|
||||
|
||||
#include "Entity.h"
|
||||
#include "EventBroker.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
struct SpawnVehicle : Event
|
||||
{
|
||||
int PlayerID;
|
||||
std::string VehicleType;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // Events_SpawnVehicle_h__
|
||||
+23
-7
@@ -6,6 +6,9 @@
|
||||
|
||||
#include "Util/Rectangle.h"
|
||||
#include "EventBroker.h"
|
||||
#include "Events/KeyDown.h"
|
||||
#include "Events/KeyUp.h"
|
||||
#include "Events/InputCommand.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "Renderer.h"
|
||||
#include "RenderQueue.h"
|
||||
@@ -45,7 +48,7 @@ public:
|
||||
, m_Hidden(false)
|
||||
{ SetParent(std::shared_ptr<Frame>(parent)); Initialize(); }
|
||||
|
||||
::RenderQueue RenderQueue;
|
||||
::RenderQueuePair RenderQueue;
|
||||
|
||||
std::shared_ptr<Frame> Parent() const { return m_Parent; }
|
||||
void SetParent(std::shared_ptr<Frame> parent)
|
||||
@@ -79,7 +82,13 @@ public:
|
||||
std::string Name() const { return m_Name; }
|
||||
void SetName(std::string val) { m_Name = val; }
|
||||
int Layer() const { return m_Layer; }
|
||||
bool Hidden() const { return m_Hidden; }
|
||||
bool Hidden() const
|
||||
{
|
||||
if (m_Parent)
|
||||
return m_Parent->Hidden() || m_Hidden;
|
||||
else
|
||||
return m_Hidden;
|
||||
}
|
||||
void Hide() { m_Hidden = true; }
|
||||
void Show() { m_Hidden = false; }
|
||||
|
||||
@@ -123,17 +132,16 @@ public:
|
||||
Rectangle AbsoluteRectangle()
|
||||
{
|
||||
int left = Left();
|
||||
if (m_Parent)
|
||||
left = std::max(left, m_Parent->Left());
|
||||
int top = Top();
|
||||
if (m_Parent)
|
||||
top = std::max(top, m_Parent->Top());
|
||||
int width = Right() - left;
|
||||
int height = Bottom() - top;
|
||||
return Rectangle(left, top, width, height);
|
||||
}
|
||||
|
||||
virtual bool OnKeyDown(const Events::KeyDown &event) { return false; }
|
||||
virtual bool OnKeyUp(const Events::KeyUp &event) { return false; }
|
||||
//virtual bool OnMouseDown(const Events::KeyDown &event) { }
|
||||
//virtual bool OnMouseUp(const Events::KeyDown &event) { }
|
||||
|
||||
void UpdateLayered(double dt)
|
||||
{
|
||||
if (this->Hidden())
|
||||
@@ -196,14 +204,22 @@ protected:
|
||||
typedef std::multimap<std::string, std::shared_ptr<Frame>> Children_t; // name -> frame
|
||||
std::map<int, Children_t> m_Children; // layer -> Children_t
|
||||
|
||||
virtual bool OnKeyDown(const Events::KeyDown &event) { return false; }
|
||||
virtual bool OnKeyUp(const Events::KeyUp &event) { return false; }
|
||||
//virtual bool OnMouseDown(const Events::KeyDown &event) { }
|
||||
//virtual bool OnMouseUp(const Events::KeyDown &event) { }
|
||||
virtual bool OnCommand(const Events::InputCommand &event) { return false; }
|
||||
|
||||
private:
|
||||
EventRelay<Frame, Events::KeyDown> m_EKeyDown;
|
||||
EventRelay<Frame, Events::KeyUp> m_EKeyUp;
|
||||
EventRelay<Frame, Events::InputCommand> m_EInputCommand;
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EKeyDown, &Frame::OnKeyDown);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EKeyUp, &Frame::OnKeyUp);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Frame::OnCommand);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+5
-3
@@ -25,13 +25,15 @@ public:
|
||||
vp1 = new Viewport(worldFrame, "Viewport1", m_World);
|
||||
vp1->X = 0;
|
||||
vp1->Width = this->Width / 2.f;
|
||||
new PlayerHUD(vp1, "PlayerHUD", m_World, 1);
|
||||
//new VehicleSelection(vp1, "VehicleSelection", m_World, 1);
|
||||
//new PlayerHUD(vp1, "PlayerHUD", m_World, 1);
|
||||
new VehicleSelection(vp1, "VehicleSelection", m_World, 1);
|
||||
|
||||
vp2 = new Viewport(worldFrame, "Viewport2", m_World);
|
||||
vp2->X = vp1->Right();
|
||||
vp2->Width = this->Width / 2.f;
|
||||
new PlayerHUD(vp2, "PlayerHUD", m_World, 2);
|
||||
//new PlayerHUD(vp2, "PlayerHUD", m_World, 2);
|
||||
new VehicleSelection(vp2, "VehicleSelection", m_World, 2);
|
||||
|
||||
|
||||
m_FreeCamViewport = new Viewport(worldFrame, "ViewportFreeCam", m_World);
|
||||
m_FreeCamViewport->Hide();
|
||||
|
||||
@@ -32,7 +32,7 @@ public:
|
||||
job.TextureID = m_Texture->ResourceID;
|
||||
job.Texture = *m_Texture;
|
||||
job.Color = glm::vec4(m_Color.r, m_Color.g, m_Color.b, m_Color.a * m_CurrentFade);
|
||||
RenderQueue.Add(job);
|
||||
RenderQueue.Forward.Add(job);
|
||||
}
|
||||
|
||||
// Texture while fading
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
job.TextureID = m_FadeTexture->ResourceID;
|
||||
job.Texture = *m_FadeTexture;
|
||||
job.Color = glm::vec4(m_Color.r, m_Color.g, m_Color.b, m_Color.a);
|
||||
RenderQueue.Add(job);
|
||||
RenderQueue.Forward.Add(job);
|
||||
}
|
||||
|
||||
renderer->SetCamera(nullptr);
|
||||
|
||||
+72
-27
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "GUI/Frame.h"
|
||||
#include "GUI/HealthOverlay.h"
|
||||
#include "Events/SpawnVehicle.h"
|
||||
|
||||
namespace GUI
|
||||
{
|
||||
@@ -37,35 +38,8 @@ namespace GUI
|
||||
m_Background->SetTexture("Textures/GUI/VehicleSelection/1.png");
|
||||
}
|
||||
|
||||
bool OnKeyUp(const Events::KeyUp &event) override
|
||||
{
|
||||
if (event.KeyCode == GLFW_KEY_LEFT)
|
||||
{
|
||||
m_CurrentSelection--;
|
||||
}
|
||||
else if (event.KeyCode == GLFW_KEY_RIGHT)
|
||||
{
|
||||
m_CurrentSelection++;
|
||||
}
|
||||
m_CurrentSelection = (m_CurrentSelection < 0) ? 0 : ((m_CurrentSelection > 3) ? 3 : m_CurrentSelection);
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "Textures/GUI/VehicleSelection/" << m_CurrentSelection + 1 << ".png";
|
||||
m_Background->FadeToTexture(ss.str(), 1.f);
|
||||
|
||||
glm::vec2 scale = Scale();
|
||||
glm::vec2 coord = -m_SelectionCoordinates[m_CurrentSelection];
|
||||
m_TargetCoordinate = coord * scale + glm::vec2(Width / 2.f, Height / 2.f);
|
||||
glm::vec2 size = m_SelectionSizes[m_CurrentSelection];
|
||||
m_TargetSize = size * scale;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Update(double dt) override
|
||||
{
|
||||
|
||||
|
||||
glm::vec2 posDiff = m_TargetCoordinate - m_CurrentCoordinate;
|
||||
m_CurrentCoordinate += posDiff * 2.f * (float)dt;
|
||||
|
||||
@@ -94,6 +68,77 @@ namespace GUI
|
||||
float m_CurrentAlpha;
|
||||
|
||||
TextureFrame* m_Background;
|
||||
|
||||
bool OnCommand(const Events::InputCommand &event) override
|
||||
{
|
||||
if (Hidden())
|
||||
return false;
|
||||
|
||||
if (event.PlayerID != m_PlayerID)
|
||||
return false;
|
||||
|
||||
// Menu movement
|
||||
if (event.Command == "interface_horizontal" || event.Command == "interface_vertical")
|
||||
{
|
||||
// Horizontal scrolling
|
||||
if (event.Command == "interface_horizontal")
|
||||
{
|
||||
if (event.Value > 0)
|
||||
m_CurrentSelection++;
|
||||
else if (event.Value < 0)
|
||||
m_CurrentSelection--;
|
||||
}
|
||||
// Vertical scrolling to switch between "rows" in an intuitive way
|
||||
else if (event.Command == "interface_vertical")
|
||||
{
|
||||
if (event.Value > 0)
|
||||
{
|
||||
if (m_CurrentSelection == 0)
|
||||
m_CurrentSelection++;
|
||||
else if (m_CurrentSelection == 3)
|
||||
m_CurrentSelection--;
|
||||
}
|
||||
else if (event.Value < 0)
|
||||
{
|
||||
if (m_CurrentSelection == 1)
|
||||
m_CurrentSelection--;
|
||||
else if (m_CurrentSelection == 2)
|
||||
m_CurrentSelection++;
|
||||
}
|
||||
}
|
||||
|
||||
m_CurrentSelection = (m_CurrentSelection < 0) ? 0 : ((m_CurrentSelection > 3) ? 3 : m_CurrentSelection);
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "Textures/GUI/VehicleSelection/" << m_CurrentSelection + 1 << ".png";
|
||||
m_Background->FadeToTexture(ss.str(), 1.f);
|
||||
|
||||
glm::vec2 scale = Scale();
|
||||
glm::vec2 coord = -m_SelectionCoordinates[m_CurrentSelection];
|
||||
m_TargetCoordinate = coord * scale + glm::vec2(Width / 2.f, Height / 2.f);
|
||||
glm::vec2 size = m_SelectionSizes[m_CurrentSelection];
|
||||
m_TargetSize = size * scale;
|
||||
}
|
||||
|
||||
// Vehicle select
|
||||
if (event.Command == "interface_confirm" && event.Value > 0)
|
||||
{
|
||||
Events::SpawnVehicle e;
|
||||
e.PlayerID = m_PlayerID;
|
||||
if (m_CurrentSelection == 0)
|
||||
e.VehicleType = "Tank"; // HACK: Base on selected vehicle ID
|
||||
else if (m_CurrentSelection == 1)
|
||||
e.VehicleType = "Helicopter";
|
||||
else if (m_CurrentSelection == 2)
|
||||
e.VehicleType = "HRSV";
|
||||
else if (m_CurrentSelection == 3)
|
||||
e.VehicleType = "Jeep";
|
||||
EventBroker->Publish(e);
|
||||
Hide();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
glm::vec2 VehicleSelection::m_SelectionCoordinates[4] = {
|
||||
|
||||
+88
-7
@@ -11,6 +11,8 @@
|
||||
#include "Components/Model.h"
|
||||
#include "Components/Sprite.h"
|
||||
#include "Components/PointLight.h"
|
||||
#include "Components/BlendMap.h"
|
||||
|
||||
|
||||
namespace GUI
|
||||
{
|
||||
@@ -42,6 +44,10 @@ public:
|
||||
{
|
||||
EntityID entity = pair.first;
|
||||
|
||||
auto templateComponent = m_World->GetComponent<Components::Template>(entity);
|
||||
if (templateComponent)
|
||||
continue;
|
||||
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (!transform)
|
||||
continue;
|
||||
@@ -56,7 +62,33 @@ public:
|
||||
glm::mat4 modelMatrix = glm::translate(glm::mat4(), absoluteTransform.Position)
|
||||
* glm::toMat4(absoluteTransform.Orientation)
|
||||
* glm::scale(absoluteTransform.Scale);
|
||||
EnqueueModel(modelAsset, modelMatrix);
|
||||
auto blendmapComponent = m_World->GetComponent<Components::BlendMap>(entity);
|
||||
if (blendmapComponent)
|
||||
{
|
||||
BlendMapTexture RedTexture;
|
||||
RedTexture.Diffuse = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureRed);
|
||||
RedTexture.Normal = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureRedNormal);
|
||||
RedTexture.Specular = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureRedSpecular);
|
||||
|
||||
BlendMapTexture GreenTexture;
|
||||
GreenTexture.Diffuse = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureGreen);
|
||||
GreenTexture.Normal = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureGreenNormal);
|
||||
GreenTexture.Specular = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureGreenSpecular);
|
||||
|
||||
BlendMapTexture BlueTexture;
|
||||
BlueTexture.Diffuse = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureBlue);
|
||||
BlueTexture.Normal = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureBlueNormal);
|
||||
BlueTexture.Specular = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureBlueSpecular);
|
||||
|
||||
float textureRepeat = blendmapComponent->TextureRepeats;
|
||||
|
||||
EnqueueBlendMapModel(modelAsset, RedTexture, GreenTexture, BlueTexture, textureRepeat, modelMatrix, modelComponent->Color);
|
||||
}
|
||||
else
|
||||
{
|
||||
EnqueueModel(modelAsset, modelMatrix, modelComponent->Transparent, modelComponent->Color);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +103,7 @@ public:
|
||||
glm::mat4 modelMatrix = glm::translate(absoluteTransform.Position)
|
||||
* glm::toMat4(orientation2D)
|
||||
* glm::scale(absoluteTransform.Scale);
|
||||
EnqueueSprite(textureAsset, modelMatrix);
|
||||
EnqueueSprite(textureAsset, modelMatrix, spriteComponent->Color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,12 +123,21 @@ public:
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
RenderQueue.Sort();
|
||||
}
|
||||
|
||||
protected:
|
||||
std::shared_ptr<World> m_World;
|
||||
|
||||
private:
|
||||
struct BlendMapTexture
|
||||
{
|
||||
GLuint Diffuse;
|
||||
GLuint Normal;
|
||||
GLuint Specular;
|
||||
};
|
||||
|
||||
EventRelay<Frame, Events::SetViewportCamera> m_ESetViewportCamera;
|
||||
bool OnSetViewportCamera(const Events::SetViewportCamera &event)
|
||||
{
|
||||
@@ -116,7 +157,7 @@ private:
|
||||
|
||||
std::shared_ptr<Systems::TransformSystem> m_TransformSystem;
|
||||
|
||||
void EnqueueModel(Model* model, glm::mat4 modelMatrix)
|
||||
void EnqueueModel(Model* model, glm::mat4 modelMatrix, float transparent, glm::vec4 color)
|
||||
{
|
||||
for (auto texGroup : model->TextureGroups)
|
||||
{
|
||||
@@ -129,20 +170,60 @@ private:
|
||||
job.StartIndex = texGroup.StartIndex;
|
||||
job.EndIndex = texGroup.EndIndex;
|
||||
job.ModelMatrix = modelMatrix;
|
||||
|
||||
RenderQueue.Add(job);
|
||||
job.Transparent = transparent;
|
||||
job.Color = color;
|
||||
|
||||
if(job.Transparent)
|
||||
{
|
||||
RenderQueue.Forward.Add(job);
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderQueue.Deferred.Add(job);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EnqueueSprite(Texture* texture, glm::mat4 modelMatrix)
|
||||
void EnqueueBlendMapModel(Model* model, BlendMapTexture textureRed, BlendMapTexture textureGreen, BlendMapTexture textureBlue, float textureRepeat, glm::mat4 modelMatrix, glm::vec4 color)
|
||||
{
|
||||
for (auto texGroup : model->TextureGroups)
|
||||
{
|
||||
BlendMapModelJob job;
|
||||
job.TextureID = texGroup.Texture->ResourceID;
|
||||
job.DiffuseTexture = *texGroup.Texture;
|
||||
job.NormalTexture = (texGroup.NormalMap) ? *texGroup.NormalMap : 0;
|
||||
job.SpecularTexture = (texGroup.SpecularMap) ? *texGroup.SpecularMap : 0;
|
||||
job.BlendMapTextureRed = textureRed.Diffuse;
|
||||
job.BlendMapTextureRedNormal = textureRed.Normal;
|
||||
job.BlendMapTextureRedSpecular = textureRed.Specular;
|
||||
job.BlendMapTextureGreen = textureGreen.Diffuse;
|
||||
job.BlendMapTextureGreenNormal = textureGreen.Normal;
|
||||
job.BlendMapTextureGreenSpecular = textureGreen.Specular;
|
||||
job.BlendMapTextureBlue = textureBlue.Diffuse;
|
||||
job.BlendMapTextureBlueNormal = textureBlue.Normal;
|
||||
job.BlendMapTextureBlueSpecular = textureBlue.Specular;
|
||||
job.TextureRepeat = textureRepeat;
|
||||
job.VAO = model->VAO;
|
||||
job.StartIndex = texGroup.StartIndex;
|
||||
job.EndIndex = texGroup.EndIndex;
|
||||
job.ModelMatrix = modelMatrix;
|
||||
job.Color = color;
|
||||
|
||||
RenderQueue.Deferred.Add(job);
|
||||
}
|
||||
}
|
||||
|
||||
void EnqueueSprite(Texture* texture, glm::mat4 modelMatrix, glm::vec4 color)
|
||||
{
|
||||
SpriteJob job;
|
||||
job.TextureID = texture->ResourceID;
|
||||
job.Texture = *texture;
|
||||
job.ModelMatrix = modelMatrix;
|
||||
job.Color = color;
|
||||
|
||||
RenderQueue.Add(job);
|
||||
RenderQueue.Forward.Add(job);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+732
-452
File diff suppressed because it is too large
Load Diff
+6
-1
@@ -22,6 +22,7 @@
|
||||
#include "Systems/DamageSystem.h"
|
||||
#include "Systems/WheelPairSystem.h"
|
||||
#include "Systems/FollowSystem.h"
|
||||
#include "Systems/WallSystem.h"
|
||||
#include "Systems/GarageSystem.h"
|
||||
|
||||
#include "Components/Camera.h"
|
||||
@@ -77,10 +78,14 @@ private:
|
||||
void BindGamepadAxis(Gamepad::Axis axis, std::string command, float value);
|
||||
void BindGamepadButton(Gamepad::Button button, std::string command, float value);
|
||||
|
||||
EntityID CreateTank(int playerID);
|
||||
void CreateGate(glm::vec3 Position);
|
||||
void AddTankWheelPair(EntityID tankEntity, glm::vec3 position, int axleID, bool steering);
|
||||
EntityID CreateJeep(int playerID);
|
||||
EntityID CreateWall(glm::vec3 pos, glm::quat orientation);
|
||||
EntityID CreateGarage(glm::vec3 Position, glm::quat orientation, int playerID);
|
||||
void CreateTerrain();
|
||||
void CreateBase(glm::quat orientation);
|
||||
std::vector<EntityID> m_WallDebrisTemplates;
|
||||
};
|
||||
|
||||
#endif // GameWorld_h__
|
||||
|
||||
@@ -85,6 +85,7 @@ void InputManager::Update(double dt)
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
|
||||
// // Lock mouse while holding LMB
|
||||
// if (m_CurrentMouseState[GLFW_MOUSE_BUTTON_LEFT])
|
||||
// {
|
||||
|
||||
+1
-1
@@ -268,7 +268,7 @@ void OBJ::ParseMaterial()
|
||||
continue;
|
||||
}
|
||||
// Normal map (bump map)
|
||||
if (prefix == "bump")
|
||||
if (prefix == "bump" || prefix == "map_Bump" )
|
||||
{
|
||||
MaterialInfo::BumpMap bumpMap;
|
||||
|
||||
|
||||
+46
-9
@@ -14,6 +14,9 @@ struct RenderJob
|
||||
{
|
||||
friend class RenderQueue;
|
||||
|
||||
glm::mat4 ModelMatrix;
|
||||
float Depth;
|
||||
|
||||
protected:
|
||||
uint64_t Hash;
|
||||
|
||||
@@ -37,7 +40,7 @@ struct ModelJob : RenderJob
|
||||
GLuint VAO;
|
||||
unsigned int StartIndex;
|
||||
unsigned int EndIndex;
|
||||
glm::mat4 ModelMatrix;
|
||||
float Transparent;
|
||||
|
||||
void CalculateHash() override
|
||||
{
|
||||
@@ -45,6 +48,20 @@ struct ModelJob : RenderJob
|
||||
}
|
||||
};
|
||||
|
||||
struct BlendMapModelJob : ModelJob
|
||||
{
|
||||
GLuint BlendMapTextureRed;
|
||||
GLuint BlendMapTextureRedNormal;
|
||||
GLuint BlendMapTextureRedSpecular;
|
||||
GLuint BlendMapTextureGreen;
|
||||
GLuint BlendMapTextureGreenNormal;
|
||||
GLuint BlendMapTextureGreenSpecular;
|
||||
GLuint BlendMapTextureBlue;
|
||||
GLuint BlendMapTextureBlueNormal;
|
||||
GLuint BlendMapTextureBlueSpecular;
|
||||
float TextureRepeat;
|
||||
};
|
||||
|
||||
struct SpriteJob : RenderJob
|
||||
{
|
||||
unsigned int ShaderID;
|
||||
@@ -52,7 +69,6 @@ struct SpriteJob : RenderJob
|
||||
|
||||
GLuint Texture;
|
||||
glm::vec4 Color;
|
||||
glm::mat4 ModelMatrix;
|
||||
|
||||
void CalculateHash() override
|
||||
{
|
||||
@@ -67,27 +83,48 @@ public:
|
||||
void Add(T &job)
|
||||
{
|
||||
job.CalculateHash();
|
||||
m_Jobs.push_front(std::shared_ptr<T>(new T(job)));
|
||||
m_Jobs.sort();
|
||||
Jobs.push_front(std::shared_ptr<T>(new T(job)));
|
||||
}
|
||||
|
||||
void Sort()
|
||||
{
|
||||
Jobs.sort();
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
m_Jobs.clear();
|
||||
Jobs.clear();
|
||||
}
|
||||
|
||||
std::forward_list<std::shared_ptr<RenderJob>>::const_iterator begin()
|
||||
{
|
||||
return m_Jobs.begin();
|
||||
return Jobs.begin();
|
||||
}
|
||||
|
||||
std::forward_list<std::shared_ptr<RenderJob>>::const_iterator end()
|
||||
{
|
||||
return m_Jobs.end();
|
||||
return Jobs.end();
|
||||
}
|
||||
|
||||
private:
|
||||
std::forward_list<std::shared_ptr<RenderJob>> m_Jobs;
|
||||
std::forward_list<std::shared_ptr<RenderJob>> Jobs;
|
||||
};
|
||||
|
||||
struct RenderQueuePair
|
||||
{
|
||||
RenderQueue Deferred;
|
||||
RenderQueue Forward;
|
||||
|
||||
void Clear()
|
||||
{
|
||||
Deferred.Clear();
|
||||
Forward.Clear();
|
||||
}
|
||||
|
||||
void Sort()
|
||||
{
|
||||
Deferred.Sort();
|
||||
Forward.Sort();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // RenderQueue_h__
|
||||
|
||||
+253
-75
@@ -21,7 +21,7 @@ Renderer::Renderer(std::shared_ptr<::ResourceManager> resourceManager)
|
||||
CAtt = 1.0f;
|
||||
LAtt = 0.0f;
|
||||
QAtt = 3.0f;
|
||||
m_ShadowMapRes = 2048*2;
|
||||
m_ShadowMapRes = 1;
|
||||
m_SunPosition = glm::vec3(0.f, 1.0f, 0.5f);
|
||||
m_SunTarget = glm::vec3(0, 0, 0);
|
||||
m_SunProjection_height = glm::vec2(-40.f, 40.f);
|
||||
@@ -78,10 +78,6 @@ void Renderer::Initialize()
|
||||
m_Camera->SetPosition(glm::vec3(0.0f, 0.0f, 2.f));
|
||||
|
||||
glfwSwapInterval(m_VSync);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
|
||||
LoadContent();
|
||||
}
|
||||
@@ -112,6 +108,16 @@ void Renderer::LoadContent()
|
||||
m_ShaderProgramDebugAABB.Compile();
|
||||
m_ShaderProgramDebugAABB.Link();*/
|
||||
|
||||
m_FinalForwardPassProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/FinalForwardPass.vert.glsl")));
|
||||
m_FinalForwardPassProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/FinalForwardPass.frag.glsl")));
|
||||
m_FinalForwardPassProgram.Compile();
|
||||
m_FinalForwardPassProgram.Link();
|
||||
|
||||
m_BlendMapProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/BlendMap.vert.glsl")));
|
||||
m_BlendMapProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/BlendMap.frag.glsl")));
|
||||
m_BlendMapProgram.Compile();
|
||||
m_BlendMapProgram.Link();
|
||||
|
||||
m_ShaderProgramSkybox.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Skybox.vert.glsl")));
|
||||
m_ShaderProgramSkybox.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Skybox.frag.glsl")));
|
||||
m_ShaderProgramSkybox.Compile();
|
||||
@@ -125,6 +131,7 @@ void Renderer::LoadContent()
|
||||
m_ForwardRendering.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardRendering.vert.glsl")));
|
||||
m_ForwardRendering.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardRendering.frag.glsl")));
|
||||
m_ForwardRendering.Compile();
|
||||
glBindFragDataLocation(m_ForwardRendering.GetHandle(), 0, "frag_Diffuse");
|
||||
m_ForwardRendering.Link();
|
||||
|
||||
m_ShaderProgramShadows.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ShadowMap.vert.glsl")));
|
||||
@@ -160,7 +167,7 @@ void Renderer::LoadContent()
|
||||
FrameBufferTextures();
|
||||
|
||||
m_sphereModel = ResourceManager->Load<Model>("Model", "Models/Placeholders/PhysicsTest/Sphere.obj");
|
||||
m_Skybox = std::make_shared<Skybox>("Textures/Skybox/Sunset", "jpg");
|
||||
m_Skybox = std::make_shared<Skybox>("Textures/Skybox/sunset", "jpg");
|
||||
}
|
||||
|
||||
void Renderer::Draw(double dt)
|
||||
@@ -260,7 +267,7 @@ void Renderer::Draw(double dt)
|
||||
glfwSwapBuffers(m_Window);
|
||||
}
|
||||
|
||||
void Renderer::DrawFrame(RenderQueue &rq)
|
||||
void Renderer::DrawFrame(RenderQueuePair &rq)
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glViewport(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||
@@ -269,6 +276,7 @@ void Renderer::DrawFrame(RenderQueue &rq)
|
||||
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
//glClearColor(0.0f, 0.5f, 0.0f, 1.0f);
|
||||
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
@@ -304,7 +312,7 @@ void Renderer::DrawFrame(RenderQueue &rq)
|
||||
// }
|
||||
//}
|
||||
|
||||
for (auto &job : rq)
|
||||
for (auto &job : rq.Forward)
|
||||
{
|
||||
//auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||
//if (modelJob)
|
||||
@@ -357,16 +365,32 @@ void Renderer::DrawFrame(RenderQueue &rq)
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::DrawWorld(RenderQueue &rq)
|
||||
void Renderer::DrawWorld(RenderQueuePair &rq)
|
||||
{
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_TRUE);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
|
||||
DrawShadowMap(rq);
|
||||
//Sort forward rendering items by z value.
|
||||
for(auto job : rq.Forward)
|
||||
{
|
||||
glm::mat4 cameraProjection = m_Camera->ProjectionMatrix((float)m_Viewport.Width / m_Viewport.Height);
|
||||
glm::mat4 cameraMatrix = m_Camera->ViewMatrix();
|
||||
|
||||
glm::vec3 spritePos = glm::vec3((cameraMatrix * job->ModelMatrix) * glm::vec4(1, 1, 1, 1));
|
||||
job->Depth = spritePos.z;
|
||||
}
|
||||
rq.Forward.Jobs.sort(Renderer::DepthSort);
|
||||
|
||||
//DrawShadowMap(rq.Deferred);
|
||||
|
||||
/*
|
||||
Base pass
|
||||
*/
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbBasePass);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbBasePass);
|
||||
glViewport(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||
glScissor(m_Scissor.X, m_Height - m_Scissor.Y - m_Scissor.Height, m_Scissor.Width, m_Scissor.Height);
|
||||
//glViewport(0, 0, m_Width, m_Height);
|
||||
@@ -384,12 +408,15 @@ void Renderer::DrawWorld(RenderQueue &rq)
|
||||
|
||||
glCullFace(GL_BACK);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
DrawFBOScene(rq);
|
||||
DrawSkybox();
|
||||
DrawFBOScene(rq.Deferred);
|
||||
|
||||
/*
|
||||
Lighting pass
|
||||
*/
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbLightingPass);
|
||||
glViewport(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||
glScissor(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||
GLenum lightingPassAttachments[] = { GL_COLOR_ATTACHMENT0 };
|
||||
glDrawBuffers(1, lightingPassAttachments);
|
||||
|
||||
@@ -405,7 +432,7 @@ void Renderer::DrawWorld(RenderQueue &rq)
|
||||
glBindTexture(GL_TEXTURE_2D, m_fSpecularTexture);
|
||||
|
||||
glCullFace(GL_FRONT);
|
||||
DrawLightScene(rq);
|
||||
DrawLightScene(rq.Deferred);
|
||||
DrawSunLightScene();
|
||||
|
||||
/*
|
||||
@@ -414,7 +441,9 @@ void Renderer::DrawWorld(RenderQueue &rq)
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
//glViewport(m_Viewport.X, m_Viewport.Y, m_Viewport.Width, m_Viewport.Height);
|
||||
glViewport(0, 0, m_Width, m_Height);
|
||||
glScissor(0, 0, m_Width, m_Height);
|
||||
//glScissor(0, 0, m_Width, m_Height);
|
||||
glScissor(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
m_FinalPassProgram.Bind();
|
||||
@@ -432,6 +461,145 @@ void Renderer::DrawWorld(RenderQueue &rq)
|
||||
glBindVertexArray(m_ScreenQuad);
|
||||
glEnableVertexAttribArray(0);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
|
||||
/*
|
||||
Transparency
|
||||
*/
|
||||
ForwardRendering(rq.Forward);
|
||||
}
|
||||
|
||||
void Renderer::ForwardRendering(RenderQueue &rq)
|
||||
{
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbBasePass);
|
||||
|
||||
glViewport(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||
glScissor(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||
|
||||
// Clear G-buffer
|
||||
GLenum attachments[] = { GL_COLOR_ATTACHMENT0, GL_NONE , GL_NONE , GL_NONE };
|
||||
glDrawBuffers(4, attachments);
|
||||
//glClearColor(0.f, 0.f, 0.f, 1.f);
|
||||
//glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthMask(GL_FALSE);
|
||||
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
glm::mat4 cameraProjection = m_Camera->ProjectionMatrix((float)m_Viewport.Width / m_Viewport.Height);
|
||||
glm::mat4 cameraMatrix = cameraProjection * m_Camera->ViewMatrix();
|
||||
glm::mat4 MVP;
|
||||
|
||||
m_ForwardRendering.Bind();
|
||||
GLuint ShaderProgramHandle = m_ForwardRendering.GetHandle();
|
||||
for (auto &job : rq)
|
||||
{
|
||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||
if (modelJob)
|
||||
{
|
||||
glm::mat4 modelMatrix = modelJob->ModelMatrix;
|
||||
MVP = cameraMatrix * modelMatrix;
|
||||
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelMatrix));
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "P"), 1, GL_FALSE, glm::value_ptr(cameraProjection));
|
||||
glUniform4fv(glGetUniformLocation(ShaderProgramHandle, "Color"), 1, glm::value_ptr(modelJob->Color));
|
||||
|
||||
glBindVertexArray(modelJob->VAO);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture);
|
||||
/*if (modelJob->NormalTexture != 0)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glBindTexture(GL_TEXTURE_2D, modelJob->NormalTexture);
|
||||
}
|
||||
if (modelJob->SpecularTexture)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE3);
|
||||
glBindTexture(GL_TEXTURE_2D, modelJob->SpecularTexture);
|
||||
}*/
|
||||
glDrawArrays(GL_TRIANGLES, modelJob->StartIndex, modelJob->EndIndex - modelJob->StartIndex + 1);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
auto spriteJob = std::dynamic_pointer_cast<SpriteJob>(job);
|
||||
if (spriteJob)
|
||||
{
|
||||
glm::mat4 modelMatrix = spriteJob->ModelMatrix;
|
||||
MVP = cameraMatrix * modelMatrix;
|
||||
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "MVP"), 1, GL_FALSE, glm::value_ptr(glm::mat4(MVP)));
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "M"), 1, GL_FALSE, glm::value_ptr(glm::mat4(modelMatrix)));
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "V"), 1, GL_FALSE, glm::value_ptr(glm::mat4(m_Camera->ViewMatrix())));
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "P"), 1, GL_FALSE, glm::value_ptr(glm::mat4(cameraProjection)));
|
||||
glUniform4fv(glGetUniformLocation(ShaderProgramHandle, "Color"), 1, glm::value_ptr(spriteJob->Color));
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, spriteJob->Texture);
|
||||
glBindVertexArray(m_ScreenQuad);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
//glDepthMask (GL_TRUE);
|
||||
//glDisable (GL_BLEND);
|
||||
|
||||
/*
|
||||
Final pass
|
||||
*/
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
glViewport(0, 0, m_Width, m_Height);
|
||||
glScissor(0, 0, m_Width, m_Height);
|
||||
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
m_FinalForwardPassProgram.Bind();
|
||||
//ShaderProgramHandle = m_FinalForwardPassProgram.GetHandle();
|
||||
|
||||
// Ambient light
|
||||
//glUniform3fv(glGetUniformLocation(ShaderProgramHandle, "La"), 1, glm::value_ptr(glm::vec3(0.7f)));
|
||||
//glUniform1f(glGetUniformLocation(ShaderProgramHandle, "Gamma"), Gamma);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fDiffuseTexture);
|
||||
|
||||
glCullFace(GL_BACK);
|
||||
glBindVertexArray(m_ScreenQuad);
|
||||
glEnableVertexAttribArray(0);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
|
||||
//for (auto tuple : ModelsToRender) //// Todo: Add so it's TransparentModelsToRender
|
||||
//{
|
||||
// Model* model;
|
||||
// glm::mat4 modelMatrix;
|
||||
// bool visible;
|
||||
// std::tie(model, modelMatrix, visible, std::ignore) = tuple;
|
||||
// if (!visible)
|
||||
// continue;
|
||||
|
||||
// MVP = cameraMatrix * modelMatrix;
|
||||
// glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
|
||||
// glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelMatrix));
|
||||
// glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_Camera->ViewMatrix()));
|
||||
// glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_Camera->ProjectionMatrix((float)m_Width / m_Height)));
|
||||
|
||||
// glBindVertexArray(model->VAO);
|
||||
// for (auto texGroup : model->TextureGroups)
|
||||
// {
|
||||
// glActiveTexture(GL_TEXTURE0);
|
||||
// glBindTexture(GL_TEXTURE_2D, *texGroup.Texture);
|
||||
// glDrawArrays(GL_TRIANGLES, texGroup.StartIndex, texGroup.EndIndex - texGroup.StartIndex + 1);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
void Renderer::Swap()
|
||||
@@ -439,17 +607,19 @@ void Renderer::Swap()
|
||||
glfwSwapBuffers(m_Window);
|
||||
}
|
||||
|
||||
#pragma region TempRegion
|
||||
|
||||
void Renderer::DrawSkybox()
|
||||
{
|
||||
//glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
//glViewport(0, 0, m_Width, m_Height);
|
||||
//glScissor(0, 0, m_Width, m_Height);
|
||||
glViewport(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||
glScissor(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
m_ShaderProgramSkybox.Bind();
|
||||
glm::mat4 cameraMatrix = m_Camera->ProjectionMatrix((float)m_Width / m_Height) * glm::toMat4(glm::inverse(m_Camera->Orientation()));
|
||||
|
||||
//glm::mat4 cameraProjection = m_Camera->ProjectionMatrix((float)m_Viewport.Width / m_Viewport.Height);
|
||||
//glm::mat4 cameraMatrix = cameraProjection * m_Camera->ViewMatrix();
|
||||
|
||||
glm::mat4 cameraMatrix = m_Camera->ProjectionMatrix((float)m_Viewport.Width / m_Viewport.Height) * glm::inverse(glm::toMat4(m_Camera->Orientation()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgramSkybox.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(cameraMatrix));
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
m_Skybox->Draw();
|
||||
@@ -762,8 +932,6 @@ void Renderer::ClearStuff()
|
||||
Lights.clear();
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
|
||||
void Renderer::FrameBufferTextures()
|
||||
{
|
||||
m_fbBasePass = 0;
|
||||
@@ -778,7 +946,7 @@ void Renderer::FrameBufferTextures()
|
||||
//Generate and bind diffuse texture
|
||||
glGenTextures(1, &m_fDiffuseTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fDiffuseTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
@@ -857,9 +1025,6 @@ void Renderer::FrameBufferTextures()
|
||||
LOG_ERROR("DeferredLighting:Init: m_fbLightingPass incomplete: 0x%x\n", fbStatus);
|
||||
//exit(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Renderer::DrawFBO()
|
||||
@@ -945,9 +1110,8 @@ void Renderer::DrawFBO()
|
||||
//}
|
||||
}
|
||||
|
||||
void Renderer::DrawFBO2()
|
||||
void Renderer::DrawFBO2(RenderQueue &rq)
|
||||
{
|
||||
ForwardRendering();
|
||||
}
|
||||
|
||||
void Renderer::DrawFBOScene(RenderQueue &rq)
|
||||
@@ -976,17 +1140,74 @@ void Renderer::DrawFBOScene(RenderQueue &rq)
|
||||
glm::vec3 sunDirection = m_SunTarget - m_SunPosition;
|
||||
glm::vec3 sunDirection_cameraview = glm::vec3(cameraProjection * m_Camera->ViewMatrix() * glm::vec4(sunDirection, 1.0));
|
||||
|
||||
m_FirstPassProgram.Bind();
|
||||
GLuint ShaderProgramHandle = m_FirstPassProgram.GetHandle();
|
||||
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, m_ShadowDepthTexture);
|
||||
|
||||
for (auto &job : rq)
|
||||
{
|
||||
|
||||
auto blendMapJob = std::dynamic_pointer_cast<BlendMapModelJob>(job);
|
||||
if(blendMapJob)
|
||||
{
|
||||
m_BlendMapProgram.Bind();
|
||||
GLuint ShaderProgramHandle = m_BlendMapProgram.GetHandle();
|
||||
|
||||
glm::mat4 modelMatrix = blendMapJob->ModelMatrix;
|
||||
|
||||
MVP = cameraMatrix * modelMatrix;
|
||||
depthMVP = depthCameraMatrix * modelMatrix;
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "DepthMVP"), 1, GL_FALSE, glm::value_ptr(depthMVP));
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelMatrix));
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "P"), 1, GL_FALSE, glm::value_ptr(cameraProjection));
|
||||
glUniform3fv(glGetUniformLocation(ShaderProgramHandle, "SunDirection_cameraspace"), 1, glm::value_ptr(sunDirection_cameraview));
|
||||
glUniform1f(glGetUniformLocation(ShaderProgramHandle, "TextureRepeats"), blendMapJob->TextureRepeat);
|
||||
|
||||
glBindVertexArray(blendMapJob->VAO);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->DiffuseTexture);
|
||||
if (blendMapJob->NormalTexture != 0)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->NormalTexture);
|
||||
}
|
||||
if (blendMapJob->SpecularTexture)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE3);
|
||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->SpecularTexture);
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE4);
|
||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureRed);
|
||||
glActiveTexture(GL_TEXTURE5);
|
||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureRedNormal);
|
||||
glActiveTexture(GL_TEXTURE6);
|
||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureRedSpecular);
|
||||
glActiveTexture(GL_TEXTURE7);
|
||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureGreen);
|
||||
glActiveTexture(GL_TEXTURE8);
|
||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureGreenNormal);
|
||||
glActiveTexture(GL_TEXTURE9);
|
||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureGreenSpecular);
|
||||
glActiveTexture(GL_TEXTURE10);
|
||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureBlue);
|
||||
glActiveTexture(GL_TEXTURE11);
|
||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureBlueNormal);
|
||||
glActiveTexture(GL_TEXTURE12);
|
||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureBlueSpecular);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, blendMapJob->StartIndex, blendMapJob->EndIndex - blendMapJob->StartIndex + 1);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||
if (modelJob)
|
||||
{
|
||||
m_FirstPassProgram.Bind();
|
||||
GLuint ShaderProgramHandle = m_FirstPassProgram.GetHandle();
|
||||
|
||||
glm::mat4 modelMatrix = modelJob->ModelMatrix;
|
||||
|
||||
MVP = cameraMatrix * modelMatrix;
|
||||
@@ -1094,7 +1315,7 @@ void Renderer::DrawSunLightScene()
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendEquation (GL_FUNC_ADD);
|
||||
glBlendEquation(GL_FUNC_ADD);
|
||||
glBlendFunc(GL_ONE,GL_ONE);
|
||||
|
||||
glDisable (GL_DEPTH_TEST);
|
||||
@@ -1173,49 +1394,6 @@ void Renderer::UpdateSunProjection()
|
||||
//Pass the bounding box's extents to glOrtho or similar to set up the orthographic projection matrix for the shadow map.
|
||||
}
|
||||
|
||||
void Renderer::ForwardRendering()
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glViewport(0, 0, m_Width, m_Height);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glClearColor(0.0f, 0.5f, 0.0f, 1.0f);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
glm::mat4 cameraMatrix = m_Camera->ProjectionMatrix((float)m_Width / m_Height) * m_Camera->ViewMatrix();
|
||||
glm::mat4 MVP;
|
||||
|
||||
m_ForwardRendering.Bind();
|
||||
GLuint ShaderProgramHandle = m_ForwardRendering.GetHandle();
|
||||
|
||||
for (auto tuple : ModelsToRender) //// Todo: Add so it's TransparentModelsToRender
|
||||
{
|
||||
Model* model;
|
||||
glm::mat4 modelMatrix;
|
||||
bool visible;
|
||||
std::tie(model, modelMatrix, visible, std::ignore) = tuple;
|
||||
if (!visible)
|
||||
continue;
|
||||
|
||||
MVP = cameraMatrix * modelMatrix;
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelMatrix));
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_Camera->ProjectionMatrix((float)m_Width / m_Height)));
|
||||
|
||||
glBindVertexArray(model->VAO);
|
||||
for (auto texGroup : model->TextureGroups)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, *texGroup.Texture);
|
||||
glDrawArrays(GL_TRIANGLES, texGroup.StartIndex, texGroup.EndIndex - texGroup.StartIndex + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::RegisterCamera(int identifier, float FOV, float nearClip, float farClip)
|
||||
{
|
||||
m_Cameras[identifier] = std::make_shared<Camera>(FOV, nearClip, farClip);
|
||||
|
||||
+8
-5
@@ -69,8 +69,8 @@ public:
|
||||
m_Camera = camera;
|
||||
}
|
||||
|
||||
void DrawFrame(RenderQueue &rq);
|
||||
void DrawWorld(RenderQueue &rq);
|
||||
void DrawFrame(RenderQueuePair &rq);
|
||||
void DrawWorld(RenderQueuePair &rq);
|
||||
void Swap();
|
||||
|
||||
#pragma endregion
|
||||
@@ -191,6 +191,8 @@ private:
|
||||
ShaderProgram m_FinalPassProgram;
|
||||
ShaderProgram m_SunPassProgram;
|
||||
ShaderProgram m_ForwardRendering;
|
||||
ShaderProgram m_BlendMapProgram;
|
||||
ShaderProgram m_FinalForwardPassProgram;
|
||||
|
||||
ShaderProgram m_ShaderProgramNormals;
|
||||
ShaderProgram m_ShaderProgramShadows;
|
||||
@@ -207,7 +209,7 @@ private:
|
||||
void CreateShadowMap(int resolution);
|
||||
void FrameBufferTextures();
|
||||
void DrawFBO();
|
||||
void DrawFBO2();
|
||||
void DrawFBO2(RenderQueue &rq);
|
||||
void DrawFBOScene(RenderQueue &rq);
|
||||
void DrawLightScene(RenderQueue &rq);
|
||||
void DrawSunLightScene();
|
||||
@@ -215,9 +217,10 @@ private:
|
||||
glm::mat4 CreateLightMatrix(Light &_light);
|
||||
void UpdateSunProjection();
|
||||
void CreateNormalMapTangent();
|
||||
void ForwardRendering();
|
||||
void ForwardRendering(RenderQueue &rq);
|
||||
|
||||
static bool DepthSort(const std::shared_ptr<RenderJob> &i, const std::shared_ptr<RenderJob> &j) { return (i->Depth < j->Depth); }
|
||||
|
||||
|
||||
GLuint CreateQuad();
|
||||
void DrawDebugShadowMap();
|
||||
GLuint CreateAABB();
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
#version 430
|
||||
|
||||
layout (binding=0) uniform sampler2D DiffuseTexture;
|
||||
layout (binding=1) uniform sampler2D ShadowTexture;
|
||||
layout (binding=2) uniform sampler2D NormalMapTexture;
|
||||
layout (binding=3) uniform sampler2D SpecularMapTexture;
|
||||
|
||||
//TerrainTextures
|
||||
layout (binding=4) uniform sampler2D TextureRed;
|
||||
layout (binding=5) uniform sampler2D TextureRedNormal;
|
||||
layout (binding=6) uniform sampler2D TextureRedSpecular;
|
||||
layout (binding=7) uniform sampler2D TextureGreen;
|
||||
layout (binding=8) uniform sampler2D TextureGreenNormal;
|
||||
layout (binding=9) uniform sampler2D TextureGreenSpecular;
|
||||
layout (binding=10) uniform sampler2D TextureBlue;
|
||||
layout (binding=11) uniform sampler2D TextureBlueNormal;
|
||||
layout (binding=12) uniform sampler2D TextureBlueSpecular;
|
||||
|
||||
uniform float TextureRepeats; //Determines how many times the textures will loop over the terrain
|
||||
uniform vec3 SunDirection_cameraspace;
|
||||
uniform mat4 V;
|
||||
|
||||
in VertexData
|
||||
{
|
||||
vec3 Position;
|
||||
vec3 Normal;
|
||||
vec2 TextureCoord;
|
||||
vec4 ShadowCoord;
|
||||
vec3 Tangent;
|
||||
vec3 BiTangent;
|
||||
} Input;
|
||||
|
||||
out vec4 frag_Diffuse;
|
||||
out vec4 frag_Position;
|
||||
out vec4 frag_Normal;
|
||||
out vec4 frag_Specular;
|
||||
|
||||
float Shadow(vec4 ShadowCoord, vec3 normal)
|
||||
{
|
||||
return 1.0;
|
||||
|
||||
if (Input.ShadowCoord.x < 0.0 || Input.ShadowCoord.x > 1.0 || Input.ShadowCoord.y < 0.0 || Input.ShadowCoord.y > 1.0)
|
||||
return 0.9;
|
||||
|
||||
//Variable bias
|
||||
vec3 n = normalize(normal);
|
||||
vec3 l = normalize(SunDirection_cameraspace);
|
||||
float cosTheta = clamp(dot(n, l), 0.0, 1.0);
|
||||
float bias = tan(acos(cosTheta));
|
||||
bias = clamp(bias, 0.0, 0.00003);
|
||||
|
||||
//Fixed bias
|
||||
bias = 0;
|
||||
|
||||
if( texture(ShadowTexture, Input.ShadowCoord.xy).z < ShadowCoord.z + bias)
|
||||
{
|
||||
return 0.6;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 BlendMap = texture(DiffuseTexture, Input.TextureCoord);
|
||||
|
||||
vec4 TextureRedTexel = texture(TextureRed, Input.TextureCoord * TextureRepeats);
|
||||
vec4 TextureRedTexelNormal = texture(TextureRedNormal, Input.TextureCoord * TextureRepeats);
|
||||
//vec4 TextureRedTexelSpecular = texture(TextureRedSpecular, Input.TextureCoord * TextureRepeats);
|
||||
|
||||
vec4 TextureGreenTexel = texture(TextureGreen, Input.TextureCoord * TextureRepeats);
|
||||
vec4 TextureGreenTexelNormal = texture(TextureGreenNormal, Input.TextureCoord * TextureRepeats);
|
||||
//vec4 TextureGreenTexelSpecular = texture(TextureGreenSpecular, Input.TextureCoord * TextureRepeats);
|
||||
|
||||
vec4 TextureBlueTexel = texture(TextureBlue, Input.TextureCoord * TextureRepeats);
|
||||
vec4 TextureBlueTexelNormal = texture(TextureBlueNormal, Input.TextureCoord * TextureRepeats);
|
||||
//vec4 TextureBlueTexelSpecular = texture(TextureBlueSpecular, Input.TextureCoord * TextureRepeats);
|
||||
|
||||
//Mix the Terrain-textures together
|
||||
TextureRedTexel *= BlendMap.r;
|
||||
TextureGreenTexel = mix(TextureRedTexel, TextureGreenTexel, BlendMap.g);
|
||||
vec4 finalBlendTexel = mix(TextureGreenTexel, TextureBlueTexel, BlendMap.b);
|
||||
|
||||
TextureRedTexelNormal *= BlendMap.r;
|
||||
TextureGreenTexelNormal = mix(TextureRedTexelNormal, TextureGreenTexelNormal, BlendMap.g);
|
||||
vec4 finalBlendTexelNormal = mix(TextureGreenTexelNormal, TextureBlueTexelNormal, BlendMap.b);
|
||||
|
||||
//TextureRedTexelSpecular *= BlendMap.r;
|
||||
//TextureGreenTexelSpecular = mix(TextureRedTexelSpecular, TextureGreenTexelSpecular, BlendMap.g);
|
||||
//vec4 finalBlendTexelSpecular = mix(TextureGreenTexelSpecular, TextureBlueTexelSpecular, BlendMap.b);
|
||||
|
||||
// G-buffer Position
|
||||
frag_Position = vec4(Input.Position.xyz, 1.0);
|
||||
|
||||
// G-buffer Normal
|
||||
mat3 TBN = mat3(Input.Tangent, Input.BiTangent, Input.Normal);
|
||||
frag_Normal = normalize(vec4(TBN * vec3(finalBlendTexelNormal), 0.0));
|
||||
//frag_Diffuse = normalize(vec4(TBN * vec3(finalBlendTexelNormal), 0.0));
|
||||
//frag_Normal = vec4(Input.Normal, 0.0);
|
||||
|
||||
// Diffuse Texture
|
||||
frag_Diffuse = finalBlendTexel;
|
||||
|
||||
//G-buffer Specular
|
||||
frag_Specular = texture(SpecularMapTexture, Input.TextureCoord);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
#version 430
|
||||
|
||||
uniform mat4 MVP;
|
||||
uniform mat4 M;
|
||||
uniform mat4 V;
|
||||
uniform mat4 P;
|
||||
uniform mat4 DepthMVP;
|
||||
|
||||
layout (location = 0) in vec3 Position;
|
||||
layout (location = 1) in vec3 Normal;
|
||||
layout (location = 2) in vec2 TextureCoord;
|
||||
layout (location = 3) in vec3 Tangent;
|
||||
layout (location = 4) in vec3 BiTangent;
|
||||
|
||||
out VertexData
|
||||
{
|
||||
vec3 Position;
|
||||
vec3 Normal;
|
||||
vec2 TextureCoord;
|
||||
vec4 ShadowCoord;
|
||||
vec3 Tangent;
|
||||
vec3 BiTangent;
|
||||
} Output;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = MVP * vec4(Position, 1.0);
|
||||
|
||||
Output.Position = vec3(V * M * vec4(Position, 1.0));
|
||||
Output.Normal = normalize(vec3(inverse(transpose(V * M)) * vec4(Normal, 0.0)));
|
||||
Output.TextureCoord = TextureCoord;
|
||||
Output.ShadowCoord = DepthMVP * vec4(Position, 1.0);
|
||||
Output.Tangent = normalize(vec3(inverse(transpose(V * M)) * vec4(Tangent, 0.0)));
|
||||
Output.BiTangent = normalize(vec3(inverse(transpose(V * M)) * vec4(BiTangent, 0.0)));
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#version 430
|
||||
|
||||
//uniform vec3 La;
|
||||
|
||||
layout (binding=0) uniform sampler2D DiffuseTexture;
|
||||
|
||||
in VertexData
|
||||
{
|
||||
vec3 Position;
|
||||
vec2 TextureCoord;
|
||||
} Input;
|
||||
|
||||
out vec4 FragmentColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 DiffuseTexel = texture(DiffuseTexture, Input.TextureCoord);
|
||||
//vec4 LightingTexel = texture(LightingTexture, Input.TextureCoord);
|
||||
|
||||
//FragmentColor = LightingTexel + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0);
|
||||
//FragmentColor = DiffuseTexel;
|
||||
|
||||
FragmentColor = DiffuseTexel;
|
||||
//FragmentColor = vec4(pow(_FragmentColor.rgb, vec3(1.0 / Gamma)), _FragmentColor.a);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#version 430
|
||||
|
||||
layout(location = 0) in vec3 Position;
|
||||
|
||||
out VertexData
|
||||
{
|
||||
vec3 Position;
|
||||
vec2 TextureCoord;
|
||||
} Output;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(Position, 1.0);
|
||||
Output.Position = Position;
|
||||
Output.TextureCoord = (vec2(Position) + 1) / 2;
|
||||
}
|
||||
@@ -5,7 +5,6 @@ uniform float Gamma;
|
||||
|
||||
layout (binding=0) uniform sampler2D DiffuseTexture;
|
||||
layout (binding=1) uniform sampler2D LightingTexture;
|
||||
layout (binding=2) uniform sampler2D ShadowTexture;
|
||||
|
||||
in VertexData
|
||||
{
|
||||
@@ -19,12 +18,10 @@ void main()
|
||||
{
|
||||
vec4 DiffuseTexel = texture(DiffuseTexture, Input.TextureCoord);
|
||||
vec4 LightingTexel = texture(LightingTexture, Input.TextureCoord);
|
||||
vec4 ShadowTexel = texture(ShadowTexture, Input.TextureCoord);
|
||||
|
||||
//FragmentColor = LightingTexel + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0);
|
||||
//FragmentColor = DiffuseTexel;
|
||||
|
||||
FragmentColor = DiffuseTexel * (vec4(La, 0.0) + vec4(LightingTexel.rgb, 0.0)) + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0);
|
||||
//FragmentColor = vec4(pow(_FragmentColor.rgb, vec3(1.0 / Gamma)), _FragmentColor.a);
|
||||
|
||||
}
|
||||
@@ -10,11 +10,11 @@ in VertexData {
|
||||
vec2 TextureCoord;
|
||||
} Input;
|
||||
|
||||
out vec4 fragmentColor;
|
||||
out vec4 frag_Diffuse;
|
||||
|
||||
void main() {
|
||||
// Texture
|
||||
vec4 texel = texture(texture0, Input.TextureCoord);
|
||||
|
||||
fragmentColor = texel * Color;
|
||||
frag_Diffuse = texel * Color;
|
||||
}
|
||||
@@ -5,13 +5,6 @@ layout (binding=1) uniform sampler2D ShadowTexture;
|
||||
layout (binding=2) uniform sampler2D NormalMapTexture;
|
||||
layout (binding=3) uniform sampler2D SpecularMapTexture;
|
||||
|
||||
//TerrainTextures
|
||||
layout (binding=4) uniform sampler2D AsphaltTexture;
|
||||
layout (binding=5) uniform sampler2D GrassTexture;
|
||||
layout (binding=6) uniform sampler2D SandTexture;
|
||||
layout (binding=7) uniform sampler2D BlendMap;
|
||||
|
||||
uniform float texScale; //Determines how many times the textures will loop over the terrain
|
||||
uniform vec3 SunDirection_cameraspace;
|
||||
uniform mat4 V;
|
||||
|
||||
@@ -59,25 +52,6 @@ float Shadow(vec4 ShadowCoord, vec3 normal)
|
||||
|
||||
void main()
|
||||
{
|
||||
//Fixa så den bara gör detta om modellen har en blend map
|
||||
//vvvvvv
|
||||
|
||||
vec4 Blend = texture2D(BlendMap, Input.TextureCoord.st );
|
||||
vec4 AsphaltTexel = texture2D(AsphaltTexture, Input.TextureCoord.st * texScale);
|
||||
vec4 GrassTexel = texture2D(GrassTexture, Input.TextureCoord.st * texScale);
|
||||
vec4 SandTexel = texture2D(SandTexture, Input.TextureCoord.st * texScale);
|
||||
|
||||
//Mix the Terrain-textures together
|
||||
AsphaltTexel *= Blend.r;
|
||||
GrassTexel = mix(AsphaltTexel, GrassTexel, Blend.g);
|
||||
vec4 tex = mix(GrassTexel, SandTexel, Blend.b);
|
||||
|
||||
//^^^^^^
|
||||
//Fixa så den bara gör detta om modellen har en blend map
|
||||
|
||||
|
||||
|
||||
|
||||
// G-buffer Position
|
||||
frag_Position = vec4(Input.Position.xyz, 1.0);
|
||||
|
||||
|
||||
@@ -12,5 +12,4 @@ out vec4 FragColor;
|
||||
void main()
|
||||
{
|
||||
FragColor = texture(CubemapTexture, Input.TextureCoord);
|
||||
//FragColor = vec4(1.0, 1.0, 1.0, 0.0);
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "DamageSystem.h"
|
||||
#include "World.h"
|
||||
|
||||
void Systems::DamageSystem::RegisterComponents( ComponentFactory* cf )
|
||||
{
|
||||
cf->Register<Components::Health>([]() { return new Components::Health(); });
|
||||
@@ -15,8 +14,16 @@ void Systems::DamageSystem::Initialize()
|
||||
|
||||
bool Systems::DamageSystem::OnDamage( const Events::Damage &event )
|
||||
{
|
||||
if(!m_World->ValidEntity(event.Entity))
|
||||
return false;
|
||||
auto health = m_World->GetComponent<Components::Health>(event.Entity);
|
||||
health->Amount -= event.Amount;
|
||||
if(health->Amount <= 0)
|
||||
{
|
||||
Events::OnDead e;
|
||||
e.Entity = event.Entity;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
LOG_INFO("Damaged entity %i, Health left: %f", event.Entity, health->Amount);
|
||||
return true;
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "System.h"
|
||||
#include "Components/Health.h"
|
||||
#include "Events/Damage.h"
|
||||
#include "Events/OnDead.h"
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
@@ -5,12 +5,14 @@
|
||||
void Systems::GarageSystem::RegisterComponents( ComponentFactory* cf )
|
||||
{
|
||||
cf->Register<Components::Garage>([]() { return new Components::Garage(); });
|
||||
cf->Register<Components::SpawnPoint>([]() { return new Components::SpawnPoint(); });
|
||||
}
|
||||
|
||||
void Systems::GarageSystem::Initialize()
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EEnterTrigger, &Systems::GarageSystem::OnEnterTrigger);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ELeaveTrigger, &Systems::GarageSystem::OnLeaveTrigger);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ECommand, &Systems::GarageSystem::OnCommand);
|
||||
}
|
||||
|
||||
void Systems::GarageSystem::Update(double dt)
|
||||
@@ -34,11 +36,13 @@ bool Systems::GarageSystem::OnEnterTrigger(const Events::EnterTrigger &event)
|
||||
|
||||
std::string name = m_World->GetProperty<std::string>(event.Trigger, "Name");
|
||||
|
||||
if (name == "BoundsTrigger" || name == "ElevatorShaftTrigger")
|
||||
if (name == "BoundsTrigger")
|
||||
{
|
||||
ToggleGarage(garageComponent);
|
||||
}
|
||||
|
||||
m_EntitiesInTrigger[event.Trigger].insert(event.Entity);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -59,6 +63,40 @@ bool Systems::GarageSystem::OnLeaveTrigger(const Events::LeaveTrigger &event)
|
||||
ToggleGarage(garageComponent);
|
||||
}
|
||||
|
||||
m_EntitiesInTrigger[event.Trigger].erase(event.Entity);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Systems::GarageSystem::OnCommand(const Events::InputCommand &event)
|
||||
{
|
||||
if (event.Command == "use" && event.Value > 0)
|
||||
{
|
||||
for (auto &pair : m_EntitiesInTrigger)
|
||||
{
|
||||
EntityID trigger = pair.first;
|
||||
auto entities = pair.second;
|
||||
|
||||
std::string name = m_World->GetProperty<std::string>(trigger, "Name");
|
||||
if (name != "ElevatorShaftTrigger")
|
||||
continue;
|
||||
|
||||
auto triggerBaseParent = m_World->GetEntityBaseParent(trigger);
|
||||
auto triggerPlayerComponent = m_World->GetComponent<Components::Player>(triggerBaseParent);
|
||||
|
||||
for (EntityID entity : entities)
|
||||
{
|
||||
auto entityPlayerComponent = m_World->GetComponent<Components::Player>(triggerBaseParent);
|
||||
if (triggerPlayerComponent == entityPlayerComponent)
|
||||
{
|
||||
EntityID garage = m_World->GetEntityParent(trigger);
|
||||
auto garageComponent = m_World->GetComponent<Components::Garage>(garage);
|
||||
ToggleGarage(garageComponent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
#ifndef GarageSystem_h__
|
||||
#define GarageSystem_h__
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "System.h"
|
||||
#include "Components/Transform.h"
|
||||
#include "Components/Trigger.h"
|
||||
#include "Components/Garage.h"
|
||||
#include "Components/SpawnPoint.h"
|
||||
#include "Events/EnterTrigger.h"
|
||||
#include "Events/LeaveTrigger.h"
|
||||
#include "Events/SpawnVehicle.h"
|
||||
#include "Events/InputCommand.h"
|
||||
|
||||
#include "Components/Player.h"
|
||||
#include "Events/Move.h"
|
||||
@@ -30,12 +34,17 @@ namespace Systems
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||
|
||||
private:
|
||||
std::map<EntityID, std::set<EntityID>> m_EntitiesInTrigger;
|
||||
|
||||
EventRelay<GarageSystem, Events::EnterTrigger> m_EEnterTrigger;
|
||||
bool OnEnterTrigger(const Events::EnterTrigger &event);
|
||||
EventRelay<GarageSystem, Events::LeaveTrigger> m_ELeaveTrigger;
|
||||
bool OnLeaveTrigger(const Events::LeaveTrigger &event);
|
||||
EventRelay<GarageSystem, Events::InputCommand> m_ECommand;
|
||||
bool OnCommand(const Events::InputCommand &event);
|
||||
|
||||
void ToggleGarage(Components::Garage* garageComponent);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+30
-47
@@ -46,8 +46,8 @@ void Systems::InputSystem::Update(double dt)
|
||||
|
||||
bool Systems::InputSystem::OnKeyDown(const Events::KeyDown &event)
|
||||
{
|
||||
auto bindingIt = m_KeyBindings.find(event.KeyCode);
|
||||
if (bindingIt != m_KeyBindings.end())
|
||||
auto range = m_KeyBindings.equal_range(event.KeyCode);
|
||||
for (auto bindingIt = range.first; bindingIt != range.second; bindingIt++)
|
||||
{
|
||||
std::string command;
|
||||
float value;
|
||||
@@ -61,8 +61,8 @@ bool Systems::InputSystem::OnKeyDown(const Events::KeyDown &event)
|
||||
|
||||
bool Systems::InputSystem::OnKeyUp(const Events::KeyUp &event)
|
||||
{
|
||||
auto bindingIt = m_KeyBindings.find(event.KeyCode);
|
||||
if (bindingIt != m_KeyBindings.end())
|
||||
auto range = m_KeyBindings.equal_range(event.KeyCode);
|
||||
for (auto bindingIt = range.first; bindingIt != range.second; bindingIt++)
|
||||
{
|
||||
std::string command;
|
||||
float value;
|
||||
@@ -76,8 +76,8 @@ bool Systems::InputSystem::OnKeyUp(const Events::KeyUp &event)
|
||||
|
||||
bool Systems::InputSystem::OnMousePress(const Events::MousePress &event)
|
||||
{
|
||||
auto bindingIt = m_MouseButtonBindings.find(event.Button);
|
||||
if (bindingIt != m_MouseButtonBindings.end())
|
||||
auto range = m_MouseButtonBindings.equal_range(event.Button);
|
||||
for (auto bindingIt = range.first; bindingIt != range.second; bindingIt++)
|
||||
{
|
||||
std::string command;
|
||||
float value;
|
||||
@@ -91,8 +91,8 @@ bool Systems::InputSystem::OnMousePress(const Events::MousePress &event)
|
||||
|
||||
bool Systems::InputSystem::OnMouseRelease(const Events::MouseRelease &event)
|
||||
{
|
||||
auto bindingIt = m_MouseButtonBindings.find(event.Button);
|
||||
if (bindingIt != m_MouseButtonBindings.end())
|
||||
auto range = m_MouseButtonBindings.equal_range(event.Button);
|
||||
for (auto bindingIt = range.first; bindingIt != range.second; bindingIt++)
|
||||
{
|
||||
std::string command;
|
||||
float value;
|
||||
@@ -106,8 +106,8 @@ bool Systems::InputSystem::OnMouseRelease(const Events::MouseRelease &event)
|
||||
|
||||
bool Systems::InputSystem::OnGamepadAxis(const Events::GamepadAxis &event)
|
||||
{
|
||||
auto bindingIt = m_GamepadAxisBindings.find(event.Axis);
|
||||
if (bindingIt != m_GamepadAxisBindings.end())
|
||||
auto range = m_GamepadAxisBindings.equal_range(event.Axis);
|
||||
for (auto bindingIt = range.first; bindingIt != range.second; bindingIt++)
|
||||
{
|
||||
std::string command;
|
||||
float value;
|
||||
@@ -121,8 +121,8 @@ bool Systems::InputSystem::OnGamepadAxis(const Events::GamepadAxis &event)
|
||||
|
||||
bool Systems::InputSystem::OnGamepadButtonDown(const Events::GamepadButtonDown &event)
|
||||
{
|
||||
auto bindingIt = m_GamepadButtonBindings.find(event.Button);
|
||||
if (bindingIt != m_GamepadButtonBindings.end())
|
||||
auto range = m_GamepadButtonBindings.equal_range(event.Button);
|
||||
for (auto bindingIt = range.first; bindingIt != range.second; bindingIt++)
|
||||
{
|
||||
std::string command;
|
||||
float value;
|
||||
@@ -136,8 +136,8 @@ bool Systems::InputSystem::OnGamepadButtonDown(const Events::GamepadButtonDown &
|
||||
|
||||
bool Systems::InputSystem::OnGamepadButtonUp(const Events::GamepadButtonUp &event)
|
||||
{
|
||||
auto bindingIt = m_GamepadButtonBindings.find(event.Button);
|
||||
if (bindingIt != m_GamepadButtonBindings.end())
|
||||
auto range = m_GamepadButtonBindings.equal_range(event.Button);
|
||||
for (auto bindingIt = range.first; bindingIt != range.second; bindingIt++)
|
||||
{
|
||||
std::string command;
|
||||
float value;
|
||||
@@ -149,18 +149,13 @@ bool Systems::InputSystem::OnGamepadButtonUp(const Events::GamepadButtonUp &even
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Systems::InputSystem::OnBindKey(const Events::BindKey &event)
|
||||
{
|
||||
if (event.Command.empty())
|
||||
{
|
||||
m_KeyBindings.erase(event.KeyCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_KeyBindings[event.KeyCode] = std::make_tuple(event.Command, event.Value);
|
||||
LOG_DEBUG("Input: Bound key %i:%c to %s", event.KeyCode, (char)event.KeyCode, event.Command.c_str());
|
||||
}
|
||||
return false;
|
||||
|
||||
m_KeyBindings.insert(std::make_pair(event.KeyCode, std::make_tuple(event.Command, event.Value)));
|
||||
LOG_DEBUG("Input: Bound key %i to %s", event.KeyCode, event.Command.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -168,14 +163,10 @@ bool Systems::InputSystem::OnBindKey(const Events::BindKey &event)
|
||||
bool Systems::InputSystem::OnBindMouseButton(const Events::BindMouseButton &event)
|
||||
{
|
||||
if (event.Command.empty())
|
||||
{
|
||||
m_MouseButtonBindings.erase(event.Button);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_MouseButtonBindings[event.Button] = std::make_tuple(event.Command, event.Value);
|
||||
LOG_DEBUG("Input: Bound mouse button %i to %s", event.Button, event.Command.c_str());
|
||||
}
|
||||
return false;
|
||||
|
||||
m_MouseButtonBindings.insert(std::make_pair(event.Button, std::make_tuple(event.Command, event.Value)));
|
||||
LOG_DEBUG("Input: Bound mouse button %i to %s", event.Button, event.Command.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -183,14 +174,10 @@ bool Systems::InputSystem::OnBindMouseButton(const Events::BindMouseButton &even
|
||||
bool Systems::InputSystem::OnBindGamepadAxis(const Events::BindGamepadAxis &event)
|
||||
{
|
||||
if (event.Command.empty())
|
||||
{
|
||||
m_GamepadAxisBindings.erase(event.Axis);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_GamepadAxisBindings[event.Axis] = std::make_tuple(event.Command, event.Value);
|
||||
LOG_DEBUG("Input: Bound gamepad axis %i to %s", event.Axis, event.Command.c_str());
|
||||
}
|
||||
return false;
|
||||
|
||||
m_GamepadAxisBindings.insert(std::make_pair(event.Axis, std::make_tuple(event.Command, event.Value)));
|
||||
LOG_DEBUG("Input: Bound gamepad axis %i to %s", event.Axis, event.Command.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -198,14 +185,10 @@ bool Systems::InputSystem::OnBindGamepadAxis(const Events::BindGamepadAxis &even
|
||||
bool Systems::InputSystem::OnBindGamepadButton(const Events::BindGamepadButton &event)
|
||||
{
|
||||
if (event.Command.empty())
|
||||
{
|
||||
m_GamepadButtonBindings.erase(event.Button);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_GamepadButtonBindings[event.Button] = std::make_tuple(event.Command, event.Value);
|
||||
LOG_DEBUG("Input: Bound gamepad axis %i to %s", event.Button, event.Command.c_str());
|
||||
}
|
||||
return false;
|
||||
|
||||
m_GamepadButtonBindings.insert(std::make_pair(event.Button, std::make_tuple(event.Command, event.Value)));
|
||||
LOG_DEBUG("Input: Bound gamepad axis %i to %s", event.Button, event.Command.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -40,10 +40,10 @@ private:
|
||||
std::unordered_map<std::string, std::unordered_map<Gamepad::Axis, float>> m_CommandGamepadAxisValues; // command string -> gamepad axis value for command
|
||||
std::unordered_map<std::string, std::unordered_map<Gamepad::Button, float>> m_CommandGamepadButtonValues; // command string -> gamepad button value for command
|
||||
// Input binding tables
|
||||
std::unordered_map<int, std::tuple<std::string, float>> m_KeyBindings; // GLFW_KEY... -> command string & value
|
||||
std::unordered_map<int, std::tuple<std::string, float>> m_MouseButtonBindings; // GLFW_MOUSE_BUTTON... -> command string
|
||||
std::unordered_map<Gamepad::Axis, std::tuple<std::string, float>> m_GamepadAxisBindings; // Gamepad::Axis -> command string & value
|
||||
std::unordered_map<Gamepad::Button, std::tuple<std::string, float>> m_GamepadButtonBindings; // Gamepad::Button -> command string
|
||||
std::unordered_multimap<int, std::tuple<std::string, float>> m_KeyBindings; // GLFW_KEY... -> command string & value
|
||||
std::unordered_multimap<int, std::tuple<std::string, float>> m_MouseButtonBindings; // GLFW_MOUSE_BUTTON... -> command string
|
||||
std::unordered_multimap<Gamepad::Axis, std::tuple<std::string, float>> m_GamepadAxisBindings; // Gamepad::Axis -> command string & value
|
||||
std::unordered_multimap<Gamepad::Button, std::tuple<std::string, float>> m_GamepadButtonBindings; // Gamepad::Button -> command string
|
||||
|
||||
// Input events
|
||||
EventRelay<InputSystem, Events::KeyDown> m_EKeyDown;
|
||||
|
||||
+117
-121
@@ -8,7 +8,7 @@ void Systems::ParticleSystem::Initialize()
|
||||
{
|
||||
m_TransformSystem = m_World->GetSystem<Systems::TransformSystem>();
|
||||
tempSpawnedExplosions = false;
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EKeyUp, &Systems::ParticleSystem::OnKeyUp);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EExplosion, &ParticleSystem::CreateExplosion);
|
||||
}
|
||||
|
||||
void Systems::ParticleSystem::Update(double dt)
|
||||
@@ -22,11 +22,14 @@ void Systems::ParticleSystem::Update(double dt)
|
||||
double timeLived = glfwGetTime() - spawnTime;
|
||||
auto eComp = m_World->GetComponent<Components::ParticleEmitter>(explosionID);
|
||||
|
||||
if(timeLived > eComp->LifeTime)
|
||||
if(timeLived > eComp->LifeTime && m_ParticlesToEmitter[explosionID] == NULL)
|
||||
{
|
||||
auto e = m_World->GetComponent<Components::ParticleEmitter>(explosionID);
|
||||
m_World->RemoveEntity(e->ParticleTemplate);
|
||||
m_World->RemoveEntity(explosionID);
|
||||
it = m_ExplosionEmitters.erase(it);
|
||||
//LOG_INFO("Deleted explosion emitter successfully");
|
||||
//LOG_INFO("Deleted explosion emitter successfully. nr of emitters%i", m_ExplosionEmitters.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -46,69 +49,82 @@ void Systems::ParticleSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
{
|
||||
emitterComponent->TimeSinceLastSpawn += dt;
|
||||
auto emitterTransformComponent = m_World->GetComponent<Components::Transform>(entity);
|
||||
if(emitterComponent->TimeSinceLastSpawn > emitterComponent->SpawnFrequency)
|
||||
// if(emitterComponent->TimeSinceLastSpawn > emitterComponent->SpawnFrequency)
|
||||
// {
|
||||
// SpawnParticles(entity);
|
||||
// emitterComponent->TimeSinceLastSpawn = 0;
|
||||
// }
|
||||
}
|
||||
|
||||
auto particleComponent = m_World->GetComponent<Components::Particle>(entity);
|
||||
if(particleComponent)
|
||||
{
|
||||
|
||||
|
||||
EntityID particleID = entity;
|
||||
double timeLived = glfwGetTime() - particleComponent->SpawnTime;
|
||||
|
||||
if(timeLived > particleComponent->LifeTime)
|
||||
{
|
||||
SpawnParticles(entity);
|
||||
emitterComponent->TimeSinceLastSpawn = 0;
|
||||
m_World->RemoveEntity(particleID);
|
||||
m_ParticlesToEmitter.erase(particleID);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
std::list<ParticleData>::iterator it;
|
||||
for(it = m_ParticleEmitter[entity].begin(); it != m_ParticleEmitter[entity].end();)
|
||||
else
|
||||
{
|
||||
EntityID particleID = (it)->ParticleID;
|
||||
auto transformComponent = m_World->GetComponent<Components::Transform>(particleID);
|
||||
auto particleComponent = m_World->GetComponent<Components::Particle>(particleID);
|
||||
|
||||
double timeLived = glfwGetTime() - it->SpawnTime;
|
||||
if(timeLived > particleComponent->LifeTime)
|
||||
auto eComponent = m_World->GetComponent<Components::ParticleEmitter>(m_ParticlesToEmitter[particleID]);
|
||||
auto sprite = m_World->GetComponent<Components::Sprite>(entity);
|
||||
// FIX: calculate once
|
||||
float timeProgress = timeLived / particleComponent->LifeTime;
|
||||
// ColorInterpolation(timeProgress, particleComponent->ColorSpectrum, color);
|
||||
// Scale interpolation
|
||||
if(particleComponent->ScaleSpectrum.size() > 1)
|
||||
VectorInterpolation(timeProgress, particleComponent->ScaleSpectrum, transformComponent->Scale);
|
||||
// Velocity interpolation
|
||||
if(particleComponent->VelocitySpectrum.size() > 1)
|
||||
VectorInterpolation(timeProgress, particleComponent->VelocitySpectrum, transformComponent->Velocity);
|
||||
|
||||
if(particleComponent->Fade == true)
|
||||
{
|
||||
m_World->RemoveEntity(particleID);
|
||||
it = m_ParticleEmitter[entity].erase(it);
|
||||
std::vector<float> spectrum;
|
||||
spectrum.push_back(1);
|
||||
spectrum.push_back(0);
|
||||
float alpha;
|
||||
ScalarInterpolation(timeProgress, spectrum, alpha);
|
||||
sprite->Color.w = alpha;
|
||||
}
|
||||
else
|
||||
|
||||
|
||||
|
||||
/*// Angular velocity interpolation
|
||||
if (particleComponent->AngularVelocitySpectrum.size() != 0)
|
||||
{
|
||||
// FIX: calculate once
|
||||
float timeProgress = timeLived / particleComponent->LifeTime;
|
||||
// ColorInterpolation(timeProgress, particleComponent->ColorSpectrum, color);
|
||||
// Scale interpolation
|
||||
if(particleComponent->ScaleSpectrum.size() > 1)
|
||||
VectorInterpolation(timeProgress, particleComponent->ScaleSpectrum, transformComponent->Scale);
|
||||
// Velocity interpolation
|
||||
if(particleComponent->VelocitySpectrum.size() > 1)
|
||||
VectorInterpolation(timeProgress, particleComponent->VelocitySpectrum, transformComponent->Velocity);
|
||||
|
||||
// Angular velocity interpolation
|
||||
if (particleComponent->AngularVelocitySpectrum.size() != 0)
|
||||
if(particleComponent->AngularVelocitySpectrum.size() > 1)
|
||||
{
|
||||
if(particleComponent->AngularVelocitySpectrum.size() > 1)
|
||||
{
|
||||
ScalarInterpolation(timeProgress, particleComponent->AngularVelocitySpectrum, it->AngularVelocity);
|
||||
transformComponent->Orientation = glm::angleAxis(it->AngularVelocity, it->Orientation);
|
||||
}
|
||||
else
|
||||
{
|
||||
transformComponent->Orientation *= glm::angleAxis(it->AngularVelocity, it->Orientation);
|
||||
//it->Orientation = glm::angleAxis(it->AngularVelocity, it->Orientation);
|
||||
}
|
||||
ScalarInterpolation(timeProgress, particleComponent->AngularVelocitySpectrum, it->AngularVelocity);
|
||||
transformComponent->Orientation = glm::angleAxis(it->AngularVelocity, it->Orientation);
|
||||
}
|
||||
|
||||
//Angular velocity interpolation
|
||||
if(particleComponent->OrientationSpectrum.size() > 1)
|
||||
else
|
||||
{
|
||||
VectorInterpolation(timeProgress, particleComponent->OrientationSpectrum, it->Orientation);
|
||||
glm::vec3 v1 = (particleComponent->OrientationSpectrum[0]);
|
||||
glm::vec3 v2 = (it->Orientation);
|
||||
glm::vec3 v3 = glm::normalize(glm::cross(v1,v2));
|
||||
float angle = glm::acos(glm::dot(v1, v2) / (glm::length(v1) * glm::length(v2)));
|
||||
|
||||
transformComponent->Orientation = glm::angleAxis(angle, v3);
|
||||
transformComponent->Orientation *= glm::angleAxis(it->AngularVelocity, it->Orientation);
|
||||
//it->Orientation = glm::angleAxis(it->AngularVelocity, it->Orientation);
|
||||
}
|
||||
|
||||
|
||||
transformComponent->Position += transformComponent->Velocity * (float)dt;
|
||||
|
||||
it++;
|
||||
}
|
||||
|
||||
//Angular velocity interpolation
|
||||
if(particleComponent->OrientationSpectrum.size() > 1)
|
||||
{
|
||||
VectorInterpolation(timeProgress, particleComponent->OrientationSpectrum, it->Orientation);
|
||||
glm::vec3 v1 = (particleComponent->OrientationSpectrum[0]);
|
||||
glm::vec3 v2 = (it->Orientation);
|
||||
glm::vec3 v3 = glm::normalize(glm::cross(v1,v2));
|
||||
float angle = glm::acos(glm::dot(v1, v2) / (glm::length(v1) * glm::length(v2)));
|
||||
|
||||
transformComponent->Orientation = glm::angleAxis(angle, v3);
|
||||
}*/
|
||||
transformComponent->Position += transformComponent->Velocity * (float)dt;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,12 +143,11 @@ void Systems::ParticleSystem::SpawnParticles(EntityID emitterID)
|
||||
glm::vec3 ePosition = m_TransformSystem->AbsolutePosition(emitterID);
|
||||
glm::quat eOrientation = eTransform->Orientation;
|
||||
glm::vec3 paticleSpeed = glm::vec3(eComponent->Speed);
|
||||
|
||||
for(int i = 0; i < eComponent->SpawnCount; i++)
|
||||
{
|
||||
auto particleEntity = m_World->CloneEntity(eComponent->ParticleTemplate);
|
||||
|
||||
auto particleTransform = m_World->GetComponent<Components::Transform>(particleEntity);
|
||||
auto ent = m_World->CloneEntity(eComponent->ParticleTemplate);
|
||||
m_ParticlesToEmitter.insert(std::make_pair(ent, emitterID));
|
||||
auto particleTransform = m_World->GetComponent<Components::Transform>(ent);
|
||||
particleTransform->Position = ePosition;
|
||||
|
||||
particleTransform->Orientation = eOrientation;
|
||||
@@ -143,16 +158,21 @@ void Systems::ParticleSystem::SpawnParticles(EntityID emitterID)
|
||||
glm::normalize(glm::angleAxis(RandomizeAngle(spreadAngle), glm::vec3(0, 1, 0))) *
|
||||
glm::normalize(glm::angleAxis(RandomizeAngle(spreadAngle), glm::vec3(0, 0, 1)));
|
||||
|
||||
auto particleComponent = m_World->AddComponent<Components::Particle>(particleEntity);
|
||||
particleComponent->LifeTime = eComponent->LifeTime - 0.5;
|
||||
particleComponent->ScaleSpectrum = eComponent->ScaleSpectrum;
|
||||
particleComponent->VelocitySpectrum.push_back(particleTransform->Velocity);
|
||||
auto particle = m_World->AddComponent<Components::Particle>(ent);
|
||||
particle->LifeTime = eComponent->LifeTime;
|
||||
particle->ScaleSpectrum = eComponent->ScaleSpectrum;
|
||||
particle->VelocitySpectrum.push_back(particleTransform->Velocity);
|
||||
particle->Fade = eComponent->Fade;
|
||||
|
||||
auto sprite = m_World->GetComponent<Components::Sprite>(ent);
|
||||
if(eComponent->Color != glm::vec4(0))
|
||||
sprite->Color = eComponent->Color;
|
||||
|
||||
if (eComponent->ScaleSpectrum.size() > 0)
|
||||
{
|
||||
if (eComponent->ScaleSpectrum.size() > 1)
|
||||
{
|
||||
particleComponent->ScaleSpectrum = eComponent->ScaleSpectrum;
|
||||
particle->ScaleSpectrum = eComponent->ScaleSpectrum;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -165,22 +185,20 @@ void Systems::ParticleSystem::SpawnParticles(EntityID emitterID)
|
||||
}
|
||||
|
||||
if(eComponent->UseGoalVelocity)
|
||||
particleComponent->VelocitySpectrum.push_back(eComponent->GoalVelocity);
|
||||
particleComponent->OrientationSpectrum = eComponent->OrientationSpectrum;
|
||||
if(particleComponent->OrientationSpectrum.size() != 0)
|
||||
particleTransform->Orientation = glm::angleAxis(0.f, particleComponent->OrientationSpectrum[0]);
|
||||
particleComponent->AngularVelocitySpectrum = eComponent->AngularVelocitySpectrum;
|
||||
particle->VelocitySpectrum.push_back(eComponent->GoalVelocity);
|
||||
particle->OrientationSpectrum = eComponent->OrientationSpectrum;
|
||||
if(particle->OrientationSpectrum.size() != 0)
|
||||
particleTransform->Orientation = glm::angleAxis(0.f, particle->OrientationSpectrum[0]);
|
||||
particle->AngularVelocitySpectrum = eComponent->AngularVelocitySpectrum;
|
||||
|
||||
|
||||
ParticleData data;
|
||||
data.ParticleID = particleEntity;
|
||||
data.SpawnTime = glfwGetTime();
|
||||
if (particleComponent->AngularVelocitySpectrum.size() != 0)
|
||||
data.AngularVelocity = particleComponent->AngularVelocitySpectrum[0];
|
||||
if (particleComponent->OrientationSpectrum.size() != 0)
|
||||
data.Orientation = particleComponent->OrientationSpectrum[0];
|
||||
else data.Orientation = eOrientation * glm::vec3(0,0,-1);
|
||||
m_ParticleEmitter[emitterID].push_back(data);
|
||||
particle->SpawnTime = glfwGetTime();
|
||||
// if (particle->AngularVelocitySpectrum.size() != 0)
|
||||
// data.AngularVelocity = particle->AngularVelocitySpectrum[0];
|
||||
// if (particle->OrientationSpectrum.size() != 0)
|
||||
// data.Orientation = particle->OrientationSpectrum[0];
|
||||
// else data.Orientation = eOrientation * glm::vec3(0,0,-1);
|
||||
//m_ParticleEmitter[emitterID].push_back(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,23 +218,13 @@ void Systems::ParticleSystem::VectorInterpolation(double timeProgress, std::vect
|
||||
dAxisValue = glm::abs(spectrum[0].y - spectrum[1].y);
|
||||
if (spectrum[0].y > spectrum[1].y)
|
||||
dAxisValue *= -1;
|
||||
v.y = spectrum[0].y + dAxisValue * timeProgress;
|
||||
v.y = spectrum[0].y + dAxisValue * timeProgress;
|
||||
dAxisValue = glm::abs(spectrum[0].z - spectrum[1].z);
|
||||
if(spectrum[0].z > spectrum[1].z)
|
||||
dAxisValue *= -1;
|
||||
v.z = spectrum[0].z + dAxisValue * timeProgress;
|
||||
}
|
||||
|
||||
// void Systems::ParticleSystem::ColorInterpolation(double timeProgress, std::vector<Color> spectrum, Color &c)
|
||||
// {
|
||||
// float dColor = glm::abs(spectrum[0].r - spectrum[1].r);
|
||||
// c.r = spectrum[0].r + dColor * timeProgress;
|
||||
// dColor = glm::abs(spectrum[0].g - spectrum[1].g);
|
||||
// c.g = spectrum[0].g + dColor * timeProgress;
|
||||
// dColor = glm::abs(spectrum[0].b - spectrum[1].b);
|
||||
// c.b = spectrum[0].b + dColor * timeProgress;
|
||||
// }
|
||||
|
||||
void Systems::ParticleSystem::ScalarInterpolation(double timeProgress, std::vector<float> spectrum, float &alpha)
|
||||
{
|
||||
float dAlpha = glm::abs(spectrum[0] - spectrum[1]);
|
||||
@@ -225,53 +233,41 @@ void Systems::ParticleSystem::ScalarInterpolation(double timeProgress, std::vect
|
||||
alpha = spectrum[0] + dAlpha * timeProgress;
|
||||
}
|
||||
|
||||
void Systems::ParticleSystem::CreateExplosion(glm::vec3 _pos, double _lifeTime, int _particlesToSpawn, std::string _spritePath, glm::quat _relativeUpOri, float _speed, float _spreadAngle, float _particleScale)
|
||||
bool Systems::ParticleSystem::CreateExplosion(const Events::CreateExplosion &e)
|
||||
{
|
||||
LOG_INFO("Spawning an explosion");
|
||||
auto explosion = m_World->CreateEntity();
|
||||
auto emitter = m_World->AddComponent<Components::ParticleEmitter>(explosion);
|
||||
emitter->LifeTime = _lifeTime;
|
||||
emitter->SpawnCount = _particlesToSpawn;
|
||||
emitter->Speed = _speed;
|
||||
emitter->SpreadAngle = _spreadAngle;
|
||||
emitter->SpawnFrequency = _lifeTime + 20; //temp
|
||||
// emitter->UseGoalVelocity = true;
|
||||
// emitter->GoalVelocity = glm::vec3(0,-_speed, 0);
|
||||
emitter->LifeTime = e.LifeTime;
|
||||
emitter->SpawnCount = e.ParticlesToSpawn;
|
||||
emitter->Speed = e.Speed;
|
||||
emitter->SpreadAngle = e.SpreadAngle;
|
||||
//emitter->ScaleSpectrum.push_back(glm::vec3(e.ParticleScale));
|
||||
emitter->SpawnFrequency = e.LifeTime + 20; //temp
|
||||
emitter->Fade = true;
|
||||
emitter->Color = e.Color;
|
||||
std::vector<glm::vec3> scale;
|
||||
scale.push_back(glm::vec3(e.ParticleScale[0]));
|
||||
if(e.ParticleScale.size() >= 2)
|
||||
scale.push_back(glm::vec3(e.ParticleScale[1]));
|
||||
emitter->ScaleSpectrum = scale;
|
||||
// emitter->GoalVelocity = glm::vec3(0,-_speed, 0);
|
||||
m_World->CommitEntity(explosion);
|
||||
|
||||
auto particleEnt = m_World->CreateEntity();
|
||||
auto templateComponent = m_World->AddComponent<Components::Template>(particleEnt);
|
||||
auto TEMP = m_World->AddComponent<Components::Transform>(particleEnt);
|
||||
TEMP->Scale = glm::vec3(0);
|
||||
auto spriteComponent = m_World->AddComponent<Components::Sprite>(particleEnt);
|
||||
spriteComponent->SpriteFile = _spritePath;
|
||||
spriteComponent->SpriteFile = e.spritePath;
|
||||
m_World->CommitEntity(particleEnt);
|
||||
emitter->ParticleTemplate = particleEnt;
|
||||
|
||||
|
||||
auto transform = m_World->AddComponent<Components::Transform>(explosion);
|
||||
transform->Position = _pos;
|
||||
transform->Orientation = _relativeUpOri;
|
||||
|
||||
transform->Position = e.Position;
|
||||
transform->Orientation = e.RelativeUpOrientation;
|
||||
|
||||
SpawnParticles(explosion);
|
||||
m_ExplosionEmitters[explosion] = glfwGetTime();
|
||||
}
|
||||
|
||||
bool Systems::ParticleSystem::OnKeyUp(const Events::KeyUp &e)
|
||||
{
|
||||
if(!tempSpawnedExplosions)
|
||||
{
|
||||
if (e.KeyCode == GLFW_KEY_B)
|
||||
{
|
||||
tempSpawnedExplosions = true;
|
||||
CreateExplosion(
|
||||
glm::vec3(0, 10, 0),
|
||||
0.5,
|
||||
60,
|
||||
"Textures/Sprites/NewtonTreeDeleteASAPPlease.png",
|
||||
glm::angleAxis(glm::pi<float>()/2, glm::vec3(1,0,0)),
|
||||
40,
|
||||
glm::pi<float>(),
|
||||
0.5f
|
||||
);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -9,21 +9,13 @@
|
||||
#include "Components/Sprite.h"
|
||||
#include "EventBroker.h"
|
||||
#include "Events/KeyUp.h"
|
||||
#include "Events/CreateExplosion.h"
|
||||
#include "Color.h"
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
struct ParticleData
|
||||
{
|
||||
EntityID ParticleID;
|
||||
double SpawnTime;
|
||||
float AngularVelocity;
|
||||
glm::vec3 Orientation;
|
||||
Color color;
|
||||
};
|
||||
|
||||
class ParticleSystem : public System
|
||||
{
|
||||
public:
|
||||
@@ -36,7 +28,7 @@ public:
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||
void Initialize() override;
|
||||
|
||||
void CreateExplosion(glm::vec3 _pos, double _lifeTime, int _particlesToSpawn, std::string _spritePath, glm::quat _relativeUpOri, float _speed, float _spreadAngle, float _particleScale);
|
||||
//void CreateExplosion(glm::vec3 _pos, double _lifeTime, int _particlesToSpawn, std::string _spritePath, glm::quat _relativeUpOri, float _speed, float _spreadAngle, float _particleScale);
|
||||
|
||||
virtual bool OnCommand(const Events::KeyUp &event) { return false; }
|
||||
|
||||
@@ -45,19 +37,21 @@ private:
|
||||
float RandomizeAngle(float spreadAngle);
|
||||
//void ScaleInterpolation(double timeProgress, std::vector<float> spectrum, glm::vec3 &scale);
|
||||
void VectorInterpolation(double timeProgress, std::vector<glm::vec3> spectrum, glm::vec3 &velocity);
|
||||
//void ColorInterpolation(double timeProgress, std::vector<Color> spectrum, Color &color);
|
||||
void ScalarInterpolation(double timeProgress, std::vector<float> spectrum, float &alpha);
|
||||
void Billboard();
|
||||
std::map<EntityID, std::list<ParticleData>> m_ParticleEmitter;
|
||||
std::map<EntityID, double> m_TimeSinceLastSpawn;
|
||||
std::map<EntityID, double> m_ExplosionEmitters;
|
||||
//std::map<EntityID, std::list<ParticleData>> m_ParticleEmitter;
|
||||
|
||||
std::shared_ptr<Systems::TransformSystem> m_TransformSystem;
|
||||
|
||||
bool tempSpawnedExplosions;
|
||||
|
||||
EventRelay<ParticleSystem, Events::KeyUp> m_EKeyUp;
|
||||
bool OnKeyUp(const Events::KeyUp &e);
|
||||
|
||||
// EventRelay<ParticleSystem, Events::KeyUp> m_EKeyUp;
|
||||
// bool OnKeyUp(const Events::KeyUp &e);
|
||||
EventRelay<ParticleSystem, Events::CreateExplosion> m_EExplosion;
|
||||
bool CreateExplosion(const Events::CreateExplosion &e);
|
||||
|
||||
std::map<EntityID, double> m_ExplosionEmitters;
|
||||
std::map<EntityID, EntityID> m_ParticlesToEmitter;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ void Systems::PhysicsSystem::Initialize()
|
||||
worldInfo.m_broadPhaseBorderBehaviour = hkpWorldCinfo::BROADPHASE_BORDER_FIX_ENTITY;
|
||||
|
||||
// You must specify the size of the broad phase - objects should not be simulated outside this region
|
||||
worldInfo.setBroadPhaseWorldSize(1500.0f);
|
||||
worldInfo.setBroadPhaseWorldSize(1000.0f);
|
||||
m_PhysicsWorld = new hkpWorld(worldInfo);
|
||||
|
||||
// When the simulation type is SIMULATION_TYPE_MULTITHREADED, in the debug build, the sdk performs checks
|
||||
@@ -151,6 +151,10 @@ void Systems::PhysicsSystem::Update(double dt)
|
||||
EntityID entity = pair.first;
|
||||
EntityID parent = pair.second;
|
||||
|
||||
auto templateComponent = m_World->GetComponent<Components::Template>(entity);
|
||||
if(templateComponent)
|
||||
continue;
|
||||
|
||||
if (m_RigidBodies.find(entity) == m_RigidBodies.end())
|
||||
continue;
|
||||
|
||||
@@ -218,6 +222,10 @@ void Systems::PhysicsSystem::Update(double dt)
|
||||
|
||||
void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||
{
|
||||
auto templateComponent = m_World->GetComponent<Components::Template>(entity);
|
||||
if(templateComponent)
|
||||
return;
|
||||
|
||||
auto transformComponent = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (!transformComponent)
|
||||
return;
|
||||
@@ -229,6 +237,19 @@ void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID p
|
||||
if(m_Vehicles.find(car) != m_Vehicles.end())
|
||||
{
|
||||
m_PhysicsWorld->markForWrite();
|
||||
|
||||
/*auto player = m_World->GetComponent<Components::Player>(car);
|
||||
if(player)
|
||||
{
|
||||
if(player->ID == 1)
|
||||
{
|
||||
LOG_INFO("Speed: %f, Gear: %i, RPM: %f", m_Vehicles[car]->calcKMPH(), m_Vehicles[car]->m_currentGear, m_Vehicles[car]->m_rpm);
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
m_Vehicles[car]->getChassis()->activate();
|
||||
|
||||
hkVector4 hardPoint = m_Vehicles[car]->m_suspension->m_wheelParams[wheelComponent->ID].m_hardpointChassisSpace;
|
||||
@@ -297,14 +318,14 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
||||
auto physicsComponent = m_World->GetComponent<Components::Physics>(entity);
|
||||
if (physicsComponent && m_Shapes[entity].size() > 0)
|
||||
{
|
||||
if(entityParent != 0 && !physicsComponent->Static)
|
||||
if(entityParent != 0 && physicsComponent->MotionType == Components::Physics::MotionTypeEnum::Dynamic)
|
||||
{
|
||||
LOG_ERROR("Entity: %i, Only the baseparent can have a dynamic PhysicsComponent", entity);
|
||||
return;
|
||||
}
|
||||
|
||||
hkpShape* shape;
|
||||
if(! physicsComponent->Static) // Not static
|
||||
if(physicsComponent->MotionType == Components::Physics::MotionTypeEnum::Dynamic)
|
||||
{
|
||||
hkArray<hkpShape*> shapeArray;
|
||||
for (auto &shapeData : m_Shapes[entity])
|
||||
@@ -368,6 +389,7 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
||||
rigidBodyInfo.m_inertiaTensor = massProperties.m_inertiaTensor;
|
||||
if(physicsComponent->CalculateCenterOfMass)
|
||||
physicsComponent->CenterOfMass = HKVECTOR4_TO_GLMVEC3(massProperties.m_centerOfMass);
|
||||
|
||||
rigidBodyInfo.m_centerOfMass = GLMVEC3_TO_HKVECTOR4(physicsComponent->CenterOfMass);
|
||||
rigidBodyInfo.m_mass = massProperties.m_mass;
|
||||
rigidBodyInfo.m_linearVelocity = GLMVEC3_TO_HKVECTOR4(physicsComponent->InitialLinearVelocity);
|
||||
@@ -381,7 +403,7 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
||||
rigidBodyInfo.m_maxLinearVelocity = physicsComponent->MaxLinearVelocity;
|
||||
rigidBodyInfo.m_maxAngularVelocity = physicsComponent->MaxAngularVelocity;
|
||||
rigidBodyInfo.m_collisionFilterInfo = hkpGroupFilter::calcFilterInfo(physicsComponent->CollisionLayer, physicsComponent->CollisionSystemGroup, physicsComponent->CollisionSubSystemId, physicsComponent->CollisionSubSystemDontCollideWith);
|
||||
rigidBodyInfo.m_enableDeactivation = false;
|
||||
rigidBodyInfo.m_enableDeactivation = true;;
|
||||
}
|
||||
// Create RigidBody
|
||||
hkpRigidBody* rigidBody = new hkpRigidBody(rigidBodyInfo);
|
||||
@@ -400,7 +422,6 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VehicleSetup vehicleSetup;
|
||||
// Create the basic vehicle.
|
||||
m_Vehicles[entity] = new hkpVehicleInstance(m_RigidBodies[entity]);
|
||||
@@ -438,7 +459,7 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
||||
rigidBody->removeReference();
|
||||
}
|
||||
}
|
||||
else // Static
|
||||
else if(physicsComponent->MotionType == Components::Physics::MotionTypeEnum::Fixed || physicsComponent->MotionType == Components::Physics::MotionTypeEnum::Keyframed)
|
||||
{
|
||||
// Create the hkpStaticCompoundShape and add the instances.
|
||||
// "meshShape" should not be modified by the user in any way after adding it as an instance.
|
||||
@@ -490,7 +511,15 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
||||
hkpRigidBodyCinfo rigidBodyInfo;
|
||||
{
|
||||
rigidBodyInfo.m_shape = shape;
|
||||
rigidBodyInfo.m_motionType = hkpMotion::MOTION_KEYFRAMED;
|
||||
if(physicsComponent->MotionType == Components::Physics::MotionTypeEnum::Fixed)
|
||||
{
|
||||
rigidBodyInfo.m_motionType = hkpMotion::MOTION_FIXED;
|
||||
}
|
||||
else if(physicsComponent->MotionType == Components::Physics::MotionTypeEnum::Keyframed)
|
||||
{
|
||||
rigidBodyInfo.m_motionType = hkpMotion::MOTION_KEYFRAMED;
|
||||
}
|
||||
|
||||
auto absoluteTransform = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(entity);
|
||||
hkVector4 position = GLMVEC3_TO_HKVECTOR4(absoluteTransform.Position);
|
||||
hkQuaternion rotation = GLMQUAT_TO_HKQUATERNION(absoluteTransform.Orientation);
|
||||
@@ -513,7 +542,7 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
||||
rigidBodyInfo.m_maxLinearVelocity = physicsComponent->MaxLinearVelocity;
|
||||
rigidBodyInfo.m_maxAngularVelocity = physicsComponent->MaxAngularVelocity;
|
||||
rigidBodyInfo.m_collisionFilterInfo = hkpGroupFilter::calcFilterInfo(physicsComponent->CollisionLayer, physicsComponent->CollisionSystemGroup, physicsComponent->CollisionSubSystemId, physicsComponent->CollisionSubSystemDontCollideWith);
|
||||
rigidBodyInfo.m_enableDeactivation = false;
|
||||
rigidBodyInfo.m_enableDeactivation = true;
|
||||
}
|
||||
// Create RigidBody
|
||||
hkpRigidBody* rigidBody = new hkpRigidBody(rigidBodyInfo);
|
||||
@@ -621,6 +650,8 @@ void Systems::PhysicsSystem::OnEntityCommit( EntityID entity )
|
||||
std::vector<hkReal>* vertices = new std::vector<hkReal>;
|
||||
std::vector<hkUint16>* vertexIndices = new std::vector<hkUint16>;
|
||||
auto meshShape = ResourceManager->Load<OBJ>("OBJ", meshShapeComponent->ResourceName);
|
||||
if(!meshShape)
|
||||
return;
|
||||
|
||||
for (auto &vertex : meshShape->Vertices)
|
||||
{
|
||||
@@ -732,7 +763,7 @@ bool Systems::PhysicsSystem::OnTankSteer(const Events::TankSteer &event)
|
||||
}
|
||||
else
|
||||
{
|
||||
deviceStatus->m_positionX = steeringX;
|
||||
deviceStatus->m_positionX = event.PositionX;
|
||||
deviceStatus->m_positionY = event.PositionY;
|
||||
}
|
||||
|
||||
@@ -752,6 +783,7 @@ bool Systems::PhysicsSystem::OnSetVelocity( const Events::SetVelocity &event )
|
||||
{
|
||||
|
||||
m_PhysicsWorld->markForWrite();
|
||||
m_RigidBodies[event.Entity]->activate();
|
||||
m_RigidBodies[event.Entity]->setLinearVelocity(GLMVEC3_TO_HKVECTOR4(event.Velocity));
|
||||
auto transformComponent = m_World->GetComponent<Components::Transform>(event.Entity);
|
||||
transformComponent->Velocity = event.Velocity;
|
||||
@@ -795,7 +827,6 @@ void Systems::PhysicsSystem::OnComponentRemoved(EntityID entity, std::string typ
|
||||
m_RigidBodies.erase(entity);
|
||||
m_PhysicsWorld->unmarkForWrite();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "Components/HingeConstraint.h"
|
||||
#include "Components/WheelPair.h"
|
||||
#include "Components/TowerSteering.h"
|
||||
#include "Components/Player.h"
|
||||
#include "Events/TankSteer.h"
|
||||
#include "Events/SetVelocity.h"
|
||||
#include "Events/ApplyForce.h"
|
||||
|
||||
@@ -15,6 +15,7 @@ void Systems::RenderSystem::RegisterComponents(ComponentFactory* cf)
|
||||
cf->Register<Components::PointLight>([]() { return new Components::PointLight(); });
|
||||
cf->Register<Components::DirectionalLight>([]() { return new Components::DirectionalLight(); });
|
||||
cf->Register<Components::Viewport>([]() { return new Components::Viewport(); });
|
||||
cf->Register<Components::BlendMap>([]() { return new Components::BlendMap(); });
|
||||
}
|
||||
|
||||
void Systems::RenderSystem::OnEntityCommit(EntityID entity)
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "Renderer.h"
|
||||
#include "RenderQueue.h"
|
||||
#include "Events/SetViewportCamera.h"
|
||||
#include "Components/BlendMap.h"
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "TankSteeringSystem.h"
|
||||
#include "World.h"
|
||||
|
||||
void Systems::TankSteeringSystem::RegisterComponents( ComponentFactory* cf )
|
||||
void Systems::TankSteeringSystem::RegisterComponents(ComponentFactory* cf)
|
||||
{
|
||||
cf->Register<Components::TankSteering>([]() { return new Components::TankSteering(); });
|
||||
cf->Register<Components::TowerSteering>([]() { return new Components::TowerSteering(); });
|
||||
@@ -12,6 +12,7 @@ void Systems::TankSteeringSystem::RegisterComponents( ComponentFactory* cf )
|
||||
void Systems::TankSteeringSystem::Initialize()
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ECollision, &Systems::TankSteeringSystem::OnCollision);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ESpawnVehicle, &Systems::TankSteeringSystem::OnSpawnVehicle);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
@@ -102,7 +103,7 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit
|
||||
Events::ApplyPointImpulse ePointImpulse ;
|
||||
ePointImpulse.Entity = entity;
|
||||
ePointImpulse.Position = absoluteTransform.Position;
|
||||
ePointImpulse.Impulse = glm::normalize(absoluteTransform.Orientation * glm::vec3(0, 0, 1)) * clonePhysicsComponent->Mass * 1670.f;
|
||||
ePointImpulse.Impulse = glm::normalize(absoluteTransform.Orientation * glm::vec3(0, 0, 1)) * clonePhysicsComponent->Mass * 6.f * 1670.f;
|
||||
EventBroker->Publish(ePointImpulse);
|
||||
}
|
||||
|
||||
@@ -110,7 +111,7 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit
|
||||
}
|
||||
}
|
||||
|
||||
bool Systems::TankSteeringSystem::OnCollision( const Events::Collision &e )
|
||||
bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e)
|
||||
{
|
||||
if(m_World->ValidEntity(e.Entity1) && m_World->ValidEntity(e.Entity2))
|
||||
{
|
||||
@@ -138,9 +139,47 @@ bool Systems::TankSteeringSystem::OnCollision( const Events::Collision &e )
|
||||
return false;
|
||||
}
|
||||
|
||||
if(m_World->GetComponent<Components::Template>(shellEntity))
|
||||
return false;
|
||||
|
||||
auto physicsComponents = m_World->GetComponentsOfType<Components::Physics>();
|
||||
auto shellTransform = m_World->GetComponent<Components::Transform>(shellEntity);
|
||||
//auto otherTransform = m_World->GetComponent<Components::Transform>(otherEntity);
|
||||
|
||||
{
|
||||
Events::CreateExplosion e;
|
||||
e.LifeTime = 3;
|
||||
e.ParticleScale.push_back(8);
|
||||
e.ParticlesToSpawn = 20;
|
||||
e.Position = shellTransform->Position;
|
||||
e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1,0,0));
|
||||
e.Speed = 3;
|
||||
e.SpreadAngle = glm::pi<float>();
|
||||
e.spritePath = "Textures/Sprites/Smoke1.png";
|
||||
e.Color = glm::vec4(0.6,0.6,0.6,1);
|
||||
EventBroker->Publish(e);
|
||||
e.LifeTime = 0.7;
|
||||
e.ParticleScale.push_back(12);
|
||||
e.ParticlesToSpawn = 10;
|
||||
e.Position = shellTransform->Position;
|
||||
e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1,0,0));
|
||||
e.Speed = 17;
|
||||
e.SpreadAngle = glm::pi<float>();
|
||||
e.spritePath = "Textures/Sprites/Fire.png";
|
||||
EventBroker->Publish(e);
|
||||
e.LifeTime = 0.2;
|
||||
e.ParticleScale.push_back(1);
|
||||
e.ParticleScale.push_back(15);
|
||||
e.ParticlesToSpawn = 5;
|
||||
e.Position = shellTransform->Position;
|
||||
e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1,0,0));
|
||||
e.Speed = 6;
|
||||
e.SpreadAngle = glm::pi<float>();
|
||||
e.spritePath = "Textures/Sprites/Blast1.png";
|
||||
e.Color = glm::vec4(2, 2, 2, 0.2);
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
for (auto &physComponent : *physicsComponents)
|
||||
{
|
||||
EntityID physicsEntity = std::dynamic_pointer_cast<Components::Physics>(physComponent)->Entity;
|
||||
@@ -169,8 +208,6 @@ bool Systems::TankSteeringSystem::OnCollision( const Events::Collision &e )
|
||||
EventBroker->Publish(d);
|
||||
}
|
||||
|
||||
|
||||
|
||||
m_World->RemoveEntity(shellEntity);
|
||||
}
|
||||
}
|
||||
@@ -251,6 +288,319 @@ bool Systems::TankSteeringSystem::OnCollision( const Events::Collision &e )
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Systems::TankSteeringSystem::OnSpawnVehicle(const Events::SpawnVehicle &event)
|
||||
{
|
||||
if (event.VehicleType != "Tank")
|
||||
return false;
|
||||
|
||||
auto spawnPointComponents = m_World->GetComponentsOfType<Components::SpawnPoint>();
|
||||
if (!spawnPointComponents)
|
||||
{
|
||||
LOG_ERROR("Found no spawn points!");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto &spawnPointComponent : *spawnPointComponents)
|
||||
{
|
||||
auto spawnPoint = spawnPointComponent->Entity;
|
||||
auto spawnPointBaseParent = m_World->GetEntityBaseParent(spawnPoint);
|
||||
auto playerComponent = m_World->GetComponent<Components::Player>(spawnPointBaseParent);
|
||||
if (!playerComponent || playerComponent->ID != event.PlayerID)
|
||||
continue;
|
||||
|
||||
Components::Transform absoluteTransform = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(spawnPoint);
|
||||
|
||||
// Create a tank
|
||||
EntityID tank = CreateTank(event.PlayerID);
|
||||
auto tankTransform = m_World->GetComponent<Components::Transform>(tank);
|
||||
tankTransform->Position = absoluteTransform.Position;
|
||||
tankTransform->Orientation = absoluteTransform.Orientation;
|
||||
// Set the viewport correctly
|
||||
Events::SetViewportCamera e;
|
||||
e.CameraEntity = m_World->GetProperty<EntityID>(tank, "Camera");
|
||||
if (event.PlayerID == 1)
|
||||
e.ViewportFrame = "Viewport1";
|
||||
else if (event.PlayerID == 2)
|
||||
e.ViewportFrame = "Viewport2";
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
EntityID Systems::TankSteeringSystem::CreateTank(int playerID)
|
||||
{
|
||||
auto tank = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(tank);
|
||||
transform->Position = glm::vec3(0, 5, 0);
|
||||
//transform->Orientation = glm::angleAxis(0.f, glm::vec3(0, 1, 0));
|
||||
auto physics = m_World->AddComponent<Components::Physics>(tank);
|
||||
physics->Mass = 63000 - 16000;
|
||||
physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic;
|
||||
auto vehicle = m_World->AddComponent<Components::Vehicle>(tank);
|
||||
vehicle->MaxTorque = 8000.f;
|
||||
vehicle->MaxSteeringAngle = 90.f;
|
||||
vehicle->MaxSpeedFullSteeringAngle = 4.f;
|
||||
auto player = m_World->AddComponent<Components::Player>(tank);
|
||||
player->ID = playerID;
|
||||
auto tankSteering = m_World->AddComponent<Components::TankSteering>(tank);
|
||||
m_World->AddComponent<Components::Input>(tank);
|
||||
auto health = m_World->AddComponent<Components::Health>(tank);
|
||||
health->Amount = 100.f;
|
||||
|
||||
{
|
||||
auto shape = m_World->CreateEntity(tank);
|
||||
auto transform = m_World->AddComponent<Components::Transform>(shape);
|
||||
auto meshShape = m_World->AddComponent<Components::MeshShape>(shape);
|
||||
meshShape->ResourceName = "Models/Tank/TankCollisionShape.obj";
|
||||
m_World->CommitEntity(shape);
|
||||
}
|
||||
{
|
||||
auto shapeTower = m_World->CreateEntity(tank);
|
||||
auto transform = m_World->AddComponent<Components::Transform>(shapeTower);
|
||||
transform->Position = glm::vec3(0, 1.10633f, 1.03024f);
|
||||
auto box = m_World->AddComponent<Components::BoxShape>(shapeTower);
|
||||
box->Width = 1.298f;
|
||||
box->Height = 0.502f;
|
||||
box->Depth = 1.211f;
|
||||
m_World->CommitEntity(shapeTower);
|
||||
}
|
||||
|
||||
{
|
||||
auto chassis = m_World->CreateEntity(tank);
|
||||
auto transform = m_World->AddComponent<Components::Transform>(chassis);
|
||||
transform->Position = glm::vec3(0, 0, 0);
|
||||
auto model = m_World->AddComponent<Components::Model>(chassis);
|
||||
model->ModelFile = "Models/Tank/tankBody.obj";
|
||||
}
|
||||
{
|
||||
auto tower = m_World->CreateEntity(tank);
|
||||
m_World->SetProperty(tower, "Name", "tower");
|
||||
auto transform = m_World->AddComponent<Components::Transform>(tower);
|
||||
transform->Position = glm::vec3(0.f, 0.68f, 0.9f);
|
||||
auto model = m_World->AddComponent<Components::Model>(tower);
|
||||
model->ModelFile = "Models/Tank/tankTop.obj";
|
||||
auto towerSteering = m_World->AddComponent<Components::TowerSteering>(tower);
|
||||
towerSteering->Axis = glm::vec3(0.f, 1.f, 0.f);
|
||||
towerSteering->TurnSpeed = glm::pi<float>() / 4.f;
|
||||
{
|
||||
auto barrel = m_World->CreateEntity(tower);
|
||||
auto transform = m_World->AddComponent<Components::Transform>(barrel);
|
||||
transform->Position = glm::vec3(-0.012f, 0.3f, -0.95);
|
||||
auto model = m_World->AddComponent<Components::Model>(barrel);
|
||||
model->ModelFile = "Models/Tank/tankBarrel.obj";
|
||||
auto barrelSteering = m_World->AddComponent<Components::BarrelSteering>(barrel);
|
||||
barrelSteering->Axis = glm::vec3(1.f, 0.f, 0.f);
|
||||
barrelSteering->TurnSpeed = glm::pi<float>() / 4.f;
|
||||
barrelSteering->ShotSpeed = 70.f;
|
||||
barrelSteering->LowerRotationLimit = glm::radians(-10.f);
|
||||
barrelSteering->UpperRotationLimit = glm::radians(40.f);
|
||||
{
|
||||
auto shot = m_World->CreateEntity(barrel);
|
||||
auto transform = m_World->AddComponent<Components::Transform>(shot);
|
||||
transform->Position = glm::vec3(0.35f, 0.f, -2.f);
|
||||
transform->Orientation = glm::angleAxis(-glm::pi<float>() / 2.f, glm::vec3(1, 0, 0));
|
||||
transform->Scale = glm::vec3(3.f);
|
||||
m_World->AddComponent<Components::Template>(shot);
|
||||
auto physics = m_World->AddComponent<Components::Physics>(shot);
|
||||
physics->Mass = 25.f;
|
||||
physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic;
|
||||
physics->CollisionEvent = true;
|
||||
auto modelComponent = m_World->AddComponent<Components::Model>(shot);
|
||||
modelComponent->ModelFile = "Models/Placeholders/rocket/Rocket.obj";
|
||||
auto tankShellComponent = m_World->AddComponent<Components::TankShell>(shot);
|
||||
tankShellComponent->Damage = 20.f;
|
||||
tankShellComponent->ExplosionRadius = 30.f;
|
||||
tankShellComponent->ExplosionStrength = 300000.f;
|
||||
{
|
||||
auto shape = m_World->CreateEntity(shot);
|
||||
auto transform = m_World->AddComponent<Components::Transform>(shape);
|
||||
auto boxShape = m_World->AddComponent<Components::BoxShape>(shape);
|
||||
boxShape->Width = 0.5f;
|
||||
boxShape->Height = 0.5f;
|
||||
boxShape->Depth = 0.5f;
|
||||
m_World->CommitEntity(shape);
|
||||
}
|
||||
m_World->CommitEntity(shot);
|
||||
barrelSteering->ShotTemplate = shot;
|
||||
|
||||
|
||||
auto cameraTower = m_World->CreateEntity(barrel);
|
||||
{
|
||||
auto transform = m_World->AddComponent<Components::Transform>(cameraTower);
|
||||
transform->Position.z = 16.f;
|
||||
transform->Position.y = 4.f;
|
||||
transform->Orientation = glm::quat(glm::vec3(-glm::radians(5.f), 0.f, 0.f));
|
||||
auto cameraComp = m_World->AddComponent<Components::Camera>(cameraTower);
|
||||
cameraComp->FarClip = 2000.f;
|
||||
/*auto follow = m_World->AddComponent<Components::Follow>(cameraTower);
|
||||
follow->Entity = barrel;
|
||||
follow->Distance = 15.f;
|
||||
follow->FollowAxis = glm::vec3(1, 1, 1);*/
|
||||
}
|
||||
|
||||
m_World->SetProperty(tank, "Camera", cameraTower);
|
||||
}
|
||||
m_World->CommitEntity(barrel);
|
||||
tankSteering->Barrel = barrel;
|
||||
}
|
||||
m_World->CommitEntity(tower);
|
||||
tankSteering->Turret = tower;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//{
|
||||
// auto lightentity = m_World->CreateEntity(tank);
|
||||
// auto transform = m_World->AddComponent<Components::Transform>(lightentity);
|
||||
// transform->Position = glm::vec3(0, 0, 0);
|
||||
// auto light = m_World->AddComponent<Components::PointLight>(lightentity);
|
||||
// //light->Diffuse = glm::vec3(128.f/255.f, 172.f/255.f, 242.f/255.f);
|
||||
// //light->Specular = glm::vec3(1.f);
|
||||
// /*light->ConstantAttenuation = 0.3f;
|
||||
// light->LinearAttenuation = 0.003f;
|
||||
// light->QuadraticAttenuation = 0.002f;*/
|
||||
//}
|
||||
|
||||
// auto wheelpair = m_World->CreateEntity(tank);
|
||||
// SetProperty(wheelpair, "Name", "WheelPair");
|
||||
// AddComponent(wheelpair, "WheelPairThingy");
|
||||
|
||||
#pragma region Wheels
|
||||
//Create wheels
|
||||
float wheelOffset = -0.83f;
|
||||
const float suspensionStrength = 15.f;
|
||||
const float springLength = 0.3f;
|
||||
|
||||
AddTankWheelPair(tank, glm::vec3(1.68f, wheelOffset, -1.715f), 0, true);
|
||||
AddTankWheelPair(tank, glm::vec3(-1.68f, wheelOffset, -1.715f), 0, true);
|
||||
AddTankWheelPair(tank, glm::vec3(1.68f, wheelOffset, 2.375), 1, false);
|
||||
AddTankWheelPair(tank, glm::vec3(-1.68f, wheelOffset, 2.375), 1, false);
|
||||
#pragma endregion
|
||||
|
||||
{
|
||||
auto entity = m_World->CreateEntity(tank);
|
||||
auto transformComponent = m_World->AddComponent<Components::Transform>(entity);
|
||||
transformComponent->Position = glm::vec3(-2, -1.7, 2.0);
|
||||
transformComponent->Scale = glm::vec3(3, 3, 3);
|
||||
transformComponent->Orientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1, 0, 0));
|
||||
auto emitterComponent = m_World->AddComponent<Components::ParticleEmitter>(entity);
|
||||
emitterComponent->SpawnCount = 2;
|
||||
emitterComponent->SpawnFrequency = 0.005;
|
||||
emitterComponent->SpreadAngle = glm::pi<float>();
|
||||
emitterComponent->UseGoalVelocity = false;
|
||||
emitterComponent->LifeTime = 0.5;
|
||||
//emitterComponent->AngularVelocitySpectrum.push_back(glm::pi<float>() / 100);
|
||||
emitterComponent->ScaleSpectrum.push_back(glm::vec3(0.05));
|
||||
m_World->CommitEntity(entity);
|
||||
|
||||
auto particleEntity = m_World->CreateEntity(entity);
|
||||
auto TEMP = m_World->AddComponent<Components::Transform>(particleEntity);
|
||||
TEMP->Scale = glm::vec3(0);
|
||||
auto spriteComponent = m_World->AddComponent<Components::Sprite>(particleEntity);
|
||||
spriteComponent->SpriteFile = "Models/Textures/Sprites/Dust.png";
|
||||
emitterComponent->ParticleTemplate = particleEntity;
|
||||
|
||||
m_World->CommitEntity(particleEntity);
|
||||
}
|
||||
|
||||
m_World->CommitEntity(tank);
|
||||
|
||||
return tank;
|
||||
}
|
||||
|
||||
void Systems::TankSteeringSystem::AddTankWheelPair(EntityID tankEntity, glm::vec3 position, int axleID, bool front)
|
||||
{
|
||||
const float separation = 1.77f;
|
||||
const float suspensionStrength = 15.f;
|
||||
const float springLength = 0.3f;
|
||||
|
||||
bool steering = front;
|
||||
|
||||
auto wheelFront = m_World->CreateEntity(tankEntity);
|
||||
{
|
||||
auto transform = m_World->AddComponent<Components::Transform>(wheelFront);
|
||||
transform->Position = position - glm::vec3(0, 0, separation / 2.f); // glm::vec3(1.68f, -0.83f - wheelOffset, -0.83f);
|
||||
//transform->Orientation = glm::angleAxis(glm::pi<float>(), glm::vec3(0, 1, 0));
|
||||
#ifdef DEBUG
|
||||
auto model = m_World->AddComponent<Components::Model>(wheelFront);
|
||||
model->ModelFile = "Models/Tank/Fix/WheelPhysics.obj";
|
||||
#endif
|
||||
auto Wheel = m_World->AddComponent<Components::Wheel>(wheelFront);
|
||||
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f);
|
||||
Wheel->AxleID = axleID;
|
||||
Wheel->Mass = 2000;
|
||||
Wheel->Radius = 0.6f;
|
||||
Wheel->Steering = steering;
|
||||
Wheel->SuspensionStrength = suspensionStrength;
|
||||
Wheel->Friction = 4.f;
|
||||
Wheel->ConnectedToHandbrake = true;
|
||||
Wheel->TorqueRatio = 0.125f;
|
||||
Wheel->Width = 0.6f;
|
||||
m_World->CommitEntity(wheelFront);
|
||||
}
|
||||
|
||||
auto wheelBack = m_World->CreateEntity(tankEntity);
|
||||
{
|
||||
auto transform = m_World->AddComponent<Components::Transform>(wheelBack);
|
||||
transform->Position = position + glm::vec3(0, 0, separation / 2.f); // glm::vec3(1.68f, -0.83f - wheelOffset, -2.6f);
|
||||
//transform->Orientation = glm::angleAxis(glm::pi<float>(), glm::vec3(0, 1, 0));
|
||||
#ifdef DEBUG
|
||||
auto model = m_World->AddComponent<Components::Model>(wheelBack);
|
||||
model->ModelFile = "Models/Tank/Fix/WheelPhysics.obj";
|
||||
#endif
|
||||
auto Wheel = m_World->AddComponent<Components::Wheel>(wheelBack);
|
||||
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f);
|
||||
Wheel->AxleID = axleID;
|
||||
Wheel->Mass = 2000;
|
||||
Wheel->Radius = 0.6f;
|
||||
Wheel->Steering = steering;
|
||||
Wheel->SuspensionStrength = suspensionStrength;
|
||||
Wheel->Friction = 4.f;
|
||||
Wheel->ConnectedToHandbrake = true;
|
||||
Wheel->TorqueRatio = 0.125f;
|
||||
Wheel->Width = 0.6f;
|
||||
m_World->CommitEntity(wheelBack);
|
||||
}
|
||||
|
||||
auto wheelPair = m_World->CreateEntity(tankEntity);
|
||||
{
|
||||
{
|
||||
auto transform = m_World->AddComponent<Components::Transform>(wheelPair);
|
||||
transform->Position = position;
|
||||
//transform->Orientation = glm::quat(glm::vec3(0, glm::pi<float>() / 4.f, 0));
|
||||
|
||||
auto pair = m_World->AddComponent<Components::WheelPair>(wheelPair);
|
||||
pair->FakeWheelFront = wheelFront;
|
||||
pair->FakeWheelBack = wheelBack;
|
||||
}
|
||||
|
||||
auto modelEntity = m_World->CreateEntity(wheelPair);
|
||||
{
|
||||
auto transform = m_World->AddComponent<Components::Transform>(modelEntity);
|
||||
//transform->Position = glm::vec3(0.f, 0.35f, 0.f);
|
||||
if (front)
|
||||
{
|
||||
transform->Position = glm::vec3(0.f, 0.03f, 0.f);
|
||||
transform->Orientation = glm::quat(glm::vec3(0, glm::pi<float>(), 0));
|
||||
}
|
||||
else
|
||||
{
|
||||
transform->Position = glm::vec3(0.f, 0.17f, 0.f);
|
||||
transform->Scale = glm::vec3(1.f, 1.2f, 1.2f);
|
||||
}
|
||||
|
||||
auto model = m_World->AddComponent<Components::Model>(modelEntity);
|
||||
model->ModelFile = "Models/Tank/tankWheel.obj";
|
||||
}
|
||||
m_World->CommitEntity(modelEntity);
|
||||
}
|
||||
m_World->CommitEntity(wheelPair);
|
||||
}
|
||||
|
||||
void Systems::TankSteeringSystem::TankSteeringInputController::Update( double dt )
|
||||
{
|
||||
PositionX = m_Horizontal;
|
||||
@@ -315,5 +665,3 @@ bool Systems::TankSteeringSystem::TankSteeringInputController::OnCommand(const E
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "Events/SetVelocity.h"
|
||||
#include "Events/ApplyForce.h"
|
||||
#include "Events/ApplyPointImpulse.h"
|
||||
#include "Events/CreateExplosion.h"
|
||||
#include "Events/Collision.h"
|
||||
#include "Components/Transform.h"
|
||||
#include "Components/TankSteering.h"
|
||||
@@ -32,6 +33,18 @@
|
||||
#include "Components/Vehicle.h"
|
||||
#include "Components/Player.h"
|
||||
|
||||
#include "Events/SpawnVehicle.h"
|
||||
#include "Components/SpawnPoint.h"
|
||||
|
||||
#include "Components/Wheel.h"
|
||||
#include "Components/MeshShape.h"
|
||||
#include "Components/Camera.h"
|
||||
#include "Components/BoxShape.h"
|
||||
#include "Components/WheelPair.h"
|
||||
#include "Components/Input.h"
|
||||
|
||||
#include "Events/SetViewportCamera.h"
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
@@ -49,13 +62,18 @@ namespace Systems
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||
|
||||
private:
|
||||
std::map<EntityID, double> m_TimeSinceLastShot;
|
||||
|
||||
EventRelay<TankSteeringSystem, Events::Collision> m_ECollision;
|
||||
bool OnCollision(const Events::Collision &e);
|
||||
EventRelay<TankSteeringSystem, Events::SpawnVehicle> m_ESpawnVehicle;
|
||||
bool OnSpawnVehicle(const Events::SpawnVehicle &e);
|
||||
|
||||
class TankSteeringInputController;
|
||||
std::array<std::shared_ptr<TankSteeringInputController>, 4> m_TankInputControllers;
|
||||
|
||||
std::map<EntityID, double> m_TimeSinceLastShot;
|
||||
EntityID CreateTank(int playerID);
|
||||
void AddTankWheelPair(EntityID tankEntity, glm::vec3 position, int axleID, bool front);
|
||||
};
|
||||
|
||||
class TankSteeringSystem::TankSteeringInputController : InputController<TankSteeringSystem>
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "WallSystem.h"
|
||||
#include "World.h"
|
||||
|
||||
void Systems::WallSystem::RegisterComponents( ComponentFactory* cf )
|
||||
{
|
||||
cf->Register<Components::Wall>([]() { return new Components::Wall(); });
|
||||
}
|
||||
|
||||
void Systems::WallSystem::Initialize()
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_eDamage, &Systems::WallSystem::Damage);
|
||||
}
|
||||
|
||||
bool Systems::WallSystem::Damage( const Events::Damage &event )
|
||||
{
|
||||
auto wallComponent = m_World->GetComponent<Components::Wall>(event.Entity);
|
||||
if(!wallComponent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
LOG_INFO("WallSystem::Damage");
|
||||
auto wallhealthcomponent = m_World->GetComponent<Components::Health>(event.Entity);
|
||||
if(wallhealthcomponent->Amount > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
LOG_INFO("You are dead");
|
||||
auto transformComponent = m_World->GetComponent<Components::Transform>(event.Entity);
|
||||
|
||||
for(auto d : wallComponent->Walldebris)
|
||||
{
|
||||
auto debris = m_World->CloneEntity(d);
|
||||
|
||||
auto transform = m_World->GetComponent<Components::Transform>(debris);
|
||||
transform->Position += transformComponent->Position;
|
||||
|
||||
// DO STUFF! :D
|
||||
float distance = glm::distance(transform->Position, transformComponent->Position);
|
||||
float radius = 5.f;
|
||||
float strength = (1.f - pow(distance / radius, 2)) * 500.f;
|
||||
glm::vec3 direction = glm::normalize(transformComponent->Position - transform->Position);
|
||||
|
||||
Events::ApplyPointImpulse e;
|
||||
e.Entity = debris;
|
||||
e.Impulse = direction * strength;
|
||||
e.Position = transformComponent->Position;
|
||||
EventBroker->Publish(e);
|
||||
|
||||
}
|
||||
|
||||
m_World->RemoveEntity(event.Entity);
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
#ifndef WallSystem_h__
|
||||
#define WallSystem_h__
|
||||
|
||||
|
||||
#include "System.h"
|
||||
#include "Events/OnDead.h"
|
||||
#include "Events/Damage.h"
|
||||
#include "Events/ApplyPointImpulse.h"
|
||||
#include "Components/Model.h"
|
||||
#include "Components/Wall.h"
|
||||
#include "Components/Transform.h"
|
||||
#include "Components/Physics.h"
|
||||
#include "Components/MeshShape.h"
|
||||
#include "Components/Tankshell.h"
|
||||
#include "Components/Health.h"
|
||||
|
||||
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
class WallSystem : public System
|
||||
{
|
||||
public:
|
||||
|
||||
WallSystem(World* world, std::shared_ptr<::EventBroker> eventBroker, std::shared_ptr<::ResourceManager> resourceManager)
|
||||
: System(world, eventBroker, resourceManager) { }
|
||||
|
||||
|
||||
void Initialize() override;
|
||||
void RegisterComponents(ComponentFactory* cf) override;
|
||||
|
||||
|
||||
|
||||
EventRelay<WallSystem, Events::Damage> m_eDamage;
|
||||
bool Damage(const Events::Damage &event);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif // WallSystem_h__
|
||||
@@ -124,6 +124,7 @@
|
||||
<ClCompile Include="..\..\src\Systems\TimerSystem.cpp" />
|
||||
<ClCompile Include="..\..\src\Systems\TransformSystem.cpp" />
|
||||
<ClCompile Include="..\..\src\Systems\TriggerSystem.cpp" />
|
||||
<ClCompile Include="..\..\src\Systems\WallSystem.cpp" />
|
||||
<ClCompile Include="..\..\src\Systems\WheelPairSystem.cpp" />
|
||||
<ClCompile Include="..\..\src\Texture.cpp" />
|
||||
<ClCompile Include="..\..\src\World.cpp" />
|
||||
@@ -133,6 +134,7 @@
|
||||
<ClInclude Include="..\..\src\Color.h" />
|
||||
<ClInclude Include="..\..\src\Component.h" />
|
||||
<ClInclude Include="..\..\src\Components\BarrelSteering.h" />
|
||||
<ClInclude Include="..\..\src\Components\BlendMap.h" />
|
||||
<ClInclude Include="..\..\src\Components\BoxShape.h" />
|
||||
<ClInclude Include="..\..\src\Components\Camera.h" />
|
||||
<ClInclude Include="..\..\src\Components\DirectionalLight.h" />
|
||||
@@ -170,7 +172,9 @@
|
||||
<ClInclude Include="..\..\src\Components\Trigger.h" />
|
||||
<ClInclude Include="..\..\src\Components\TriggerRotate.h" />
|
||||
<ClInclude Include="..\..\src\Components\Vehicle.h" />
|
||||
<ClInclude Include="..\..\src\Components\SpawnPoint.h" />
|
||||
<ClInclude Include="..\..\src\Components\Viewport.h" />
|
||||
<ClInclude Include="..\..\src\Components\Wall.h" />
|
||||
<ClInclude Include="..\..\src\Components\Wheel.h" />
|
||||
<ClInclude Include="..\..\src\Components\WheelPair.h" />
|
||||
<ClInclude Include="..\..\src\CubemapTexture.h" />
|
||||
@@ -183,6 +187,7 @@
|
||||
<ClInclude Include="..\..\src\Events\BindKey.h" />
|
||||
<ClInclude Include="..\..\src\Events\BindMouseButton.h" />
|
||||
<ClInclude Include="..\..\src\Events\Collision.h" />
|
||||
<ClInclude Include="..\..\src\Events\CreateExplosion.h" />
|
||||
<ClInclude Include="..\..\src\Events\ComponentCreated.h" />
|
||||
<ClInclude Include="..\..\src\Events\Damage.h" />
|
||||
<ClInclude Include="..\..\src\Events\DisableCollisions.h" />
|
||||
@@ -197,12 +202,14 @@
|
||||
<ClInclude Include="..\..\src\Events\MouseMove.h" />
|
||||
<ClInclude Include="..\..\src\Events\MousePress.h" />
|
||||
<ClInclude Include="..\..\src\Events\MouseRelease.h" />
|
||||
<ClInclude Include="..\..\src\Events\OnDead.h" />
|
||||
<ClInclude Include="..\..\src\Events\Move.h" />
|
||||
<ClInclude Include="..\..\src\Events\PlayBGM.h" />
|
||||
<ClInclude Include="..\..\src\Events\PlaySFX.h" />
|
||||
<ClInclude Include="..\..\src\Events\Rotate.h" />
|
||||
<ClInclude Include="..\..\src\Events\SetVelocity.h" />
|
||||
<ClInclude Include="..\..\src\Events\SetViewportCamera.h" />
|
||||
<ClInclude Include="..\..\src\Events\SpawnVehicle.h" />
|
||||
<ClInclude Include="..\..\src\Events\StopSound.h" />
|
||||
<ClInclude Include="..\..\src\Events\TankSteer.h" />
|
||||
<ClInclude Include="..\..\src\Events\EnterTrigger.h" />
|
||||
@@ -245,6 +252,7 @@
|
||||
<ClInclude Include="..\..\src\Systems\TimerSystem.h" />
|
||||
<ClInclude Include="..\..\src\Systems\TransformSystem.h" />
|
||||
<ClInclude Include="..\..\src\Systems\TriggerSystem.h" />
|
||||
<ClInclude Include="..\..\src\Systems\WallSystem.h" />
|
||||
<ClInclude Include="..\..\src\Systems\WheelPairSystem.h" />
|
||||
<ClInclude Include="..\..\src\Texture.h" />
|
||||
<ClInclude Include="..\..\src\Util\GLError.h" />
|
||||
@@ -255,6 +263,10 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\src\Shaders\AABB.frag.glsl" />
|
||||
<None Include="..\..\src\Shaders\BlendMap.frag.glsl" />
|
||||
<None Include="..\..\src\Shaders\BlendMap.vert.glsl" />
|
||||
<None Include="..\..\src\Shaders\FinalForwardPass.frag.glsl" />
|
||||
<None Include="..\..\src\Shaders\FinalForwardPass.vert.glsl" />
|
||||
<None Include="..\..\src\Shaders\FinalPass.frag.glsl" />
|
||||
<None Include="..\..\src\Shaders\FinalPass.vert.glsl" />
|
||||
<None Include="..\..\src\Shaders\ForwardRendering.frag.glsl" />
|
||||
|
||||
@@ -78,6 +78,9 @@
|
||||
<ClCompile Include="..\..\src\Systems\FollowSystem.cpp">
|
||||
<Filter>Game\Systems</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\Systems\WallSystem.cpp">
|
||||
<Filter>Gameplay\Systems</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\Systems\GarageSystem.cpp">
|
||||
<Filter>Game\Systems</Filter>
|
||||
</ClCompile>
|
||||
@@ -182,10 +185,12 @@
|
||||
<Filter Include="Game\Components">
|
||||
<UniqueIdentifier>{cb06b441-90b8-46ed-b347-4190dac7185b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Particle System\Events">
|
||||
<UniqueIdentifier>{ddd3c442-7c2f-4690-9308-fcef62deee0b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Game\Systems">
|
||||
<UniqueIdentifier>{3c2ea0e5-41a1-4b11-a891-1d59ead7223c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
|
||||
</Filter>
|
||||
<Filter Include="Base\Events">
|
||||
<UniqueIdentifier>{3cbe68d9-2446-45ee-8637-ffb805997dcd}</UniqueIdentifier>
|
||||
</Filter>
|
||||
@@ -428,6 +433,9 @@
|
||||
<ClInclude Include="..\..\src\Components\Player.h">
|
||||
<Filter>Game\Components</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Events\CreateExplosion.h">
|
||||
<Filter>Particle System\Events</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Events\Collision.h">
|
||||
<Filter>Physics\Events</Filter>
|
||||
</ClInclude>
|
||||
@@ -512,6 +520,12 @@
|
||||
<ClInclude Include="..\..\src\Events\Move.h">
|
||||
<Filter>Base\Events</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Components\BlendMap.h">
|
||||
<Filter>Rendering\Components</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Systems\WallSystem.h">
|
||||
<Filter>Gameplay\Systems</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Events\LeaveTrigger.h">
|
||||
<Filter>Physics\Events</Filter>
|
||||
</ClInclude>
|
||||
@@ -545,6 +559,18 @@
|
||||
<ClInclude Include="..\..\src\GUI\VehicleSelection.h">
|
||||
<Filter>GUI</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Events\OnDead.h">
|
||||
<Filter>Gameplay\Events</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Events\SpawnVehicle.h">
|
||||
<Filter>Game\Events</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Components\Wall.h">
|
||||
<Filter>Game\Components</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\Components\SpawnPoint.h">
|
||||
<Filter>Game\Components</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\src\Shaders\Fragment2.glsl">
|
||||
@@ -607,5 +633,17 @@
|
||||
<None Include="..\..\src\Shaders\SunPass.vert.glsl">
|
||||
<Filter>Shaders</Filter>
|
||||
</None>
|
||||
<None Include="..\..\src\Shaders\BlendMap.frag.glsl">
|
||||
<Filter>Shaders</Filter>
|
||||
</None>
|
||||
<None Include="..\..\src\Shaders\BlendMap.vert.glsl">
|
||||
<Filter>Shaders</Filter>
|
||||
</None>
|
||||
<None Include="..\..\src\Shaders\FinalForwardPass.frag.glsl">
|
||||
<Filter>Shaders</Filter>
|
||||
</None>
|
||||
<None Include="..\..\src\Shaders\FinalForwardPass.vert.glsl">
|
||||
<Filter>Shaders</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user