Compare commits
48 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dcede48453 | |||
| c7a37e1b9b | |||
| 85d5f209a3 | |||
| fd92f37902 | |||
| 9ed2f04036 | |||
| 866c65514d | |||
| a6941c0fb6 | |||
| ccb3d6d84f | |||
| 93c4805a22 | |||
| 56e6545f0f | |||
| 2d716e2998 | |||
| 1b20204897 | |||
| bf5106e5b6 | |||
| 8b2fc86159 | |||
| 5f1feffe0d | |||
| c06c436cd1 | |||
| 70960c9eba | |||
| 6cae09c5d8 | |||
| 7b90e54899 | |||
| d3f8ef2d9c | |||
| f9426745f7 | |||
| 5e78fdc930 | |||
| 5a6ae2a24e | |||
| d5dcb0b72c | |||
| 94178098ea | |||
| 62dd85349f | |||
| f9f20535ba | |||
| 74b86bc6d4 | |||
| 27b735325a | |||
| e39e1eda89 | |||
| 3c17ab6037 | |||
| 7f017bfaed | |||
| 9813e9a058 | |||
| cf2040f038 | |||
| e11f656b3d | |||
| 72a8ee9080 | |||
| 7d9f1a7ac7 | |||
| 90a92d05e4 | |||
| 9f1d5206bd | |||
| ac855f554b | |||
| 909ee94e26 | |||
| df32a3b07d | |||
| 2833b8df36 | |||
| 87b02711f4 | |||
| 96a608db27 | |||
| 5265fb9734 | |||
| a5105e5859 | |||
| e7eca74b03 |
+1
-1
Submodule assets updated: 75977fd865...8ab7df0d7f
@@ -0,0 +1,27 @@
|
|||||||
|
#ifndef Components_DamageModel_h__
|
||||||
|
#define Components_DamageModel_h__
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "Component.h"
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
|
||||||
|
struct DamageModel : Component
|
||||||
|
{
|
||||||
|
DamageModel()
|
||||||
|
: Color(glm::vec4(1.0f, 1.0f, 1.0f, 1.0f))
|
||||||
|
, ShadowCaster(true)
|
||||||
|
, Transparent(false)
|
||||||
|
{ }
|
||||||
|
std::string ModelFile;
|
||||||
|
glm::vec4 Color;
|
||||||
|
bool ShadowCaster;
|
||||||
|
bool Transparent;
|
||||||
|
|
||||||
|
virtual DamageModel* Clone() const override { return new DamageModel(*this); }
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif // !Components_DamageModel_h__
|
||||||
@@ -9,9 +9,12 @@ namespace Components
|
|||||||
struct Health : Component
|
struct Health : Component
|
||||||
{
|
{
|
||||||
Health()
|
Health()
|
||||||
: Amount(1.0f) { }
|
: Amount(1.0f)
|
||||||
|
, VulnerableToSplash(true)
|
||||||
|
{ }
|
||||||
|
|
||||||
float Amount;
|
float Amount;
|
||||||
|
bool VulnerableToSplash;
|
||||||
|
|
||||||
virtual Health* Clone() const override { return new Health(*this); }
|
virtual Health* Clone() const override { return new Health(*this); }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef JeepSteering_h__
|
||||||
|
#define JeepSteering_h__
|
||||||
|
|
||||||
|
#include "Component.h"
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
struct JeepSteering : Component
|
||||||
|
{
|
||||||
|
JeepSteering* Clone() const override { return new JeepSteering(*this); }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // JeepSteering_h__
|
||||||
@@ -10,12 +10,13 @@ namespace Components
|
|||||||
|
|
||||||
struct Model : Component
|
struct Model : Component
|
||||||
{
|
{
|
||||||
Model() : Color(glm::vec4(1.0f, 1.0f, 1.0f, 1.0f)), Visible(true), ShadowCaster(true), Transparent(false) { }
|
Model() : Color(glm::vec4(1.0f, 1.0f, 1.0f, 1.0f)), Visible(true), ShadowCaster(true), Transparent(false), AverageNormals(false) { }
|
||||||
std::string ModelFile;
|
std::string ModelFile;
|
||||||
glm::vec4 Color;
|
glm::vec4 Color;
|
||||||
bool Visible;
|
bool Visible;
|
||||||
bool ShadowCaster;
|
bool ShadowCaster;
|
||||||
bool Transparent;
|
bool Transparent;
|
||||||
|
bool AverageNormals;
|
||||||
|
|
||||||
virtual Model* Clone() const override { return new Model(*this); }
|
virtual Model* Clone() const override { return new Model(*this); }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ struct ParticleEmitter : Component
|
|||||||
, SpreadAngle(0)
|
, SpreadAngle(0)
|
||||||
, LifeTime(0)
|
, LifeTime(0)
|
||||||
, TimeSinceLastSpawn(100)
|
, TimeSinceLastSpawn(100)
|
||||||
|
, Emitting(false)
|
||||||
, Color(glm::vec4(0)) { }
|
, Color(glm::vec4(0)) { }
|
||||||
|
|
||||||
EntityID ParticleTemplate;
|
EntityID ParticleTemplate;
|
||||||
@@ -32,6 +33,7 @@ struct ParticleEmitter : Component
|
|||||||
double LifeTime;
|
double LifeTime;
|
||||||
bool UseGoalVelocity;
|
bool UseGoalVelocity;
|
||||||
bool Fade;
|
bool Fade;
|
||||||
|
bool Emitting;
|
||||||
glm::vec3 GoalVelocity;
|
glm::vec3 GoalVelocity;
|
||||||
std::vector<float> AngularVelocitySpectrum;
|
std::vector<float> AngularVelocitySpectrum;
|
||||||
std::vector<glm::vec3> OrientationSpectrum; //Keep? noo..
|
std::vector<glm::vec3> OrientationSpectrum; //Keep? noo..
|
||||||
|
|||||||
@@ -10,13 +10,14 @@ namespace Components
|
|||||||
|
|
||||||
struct SoundEmitter : Component
|
struct SoundEmitter : Component
|
||||||
{
|
{
|
||||||
|
|
||||||
enum class SoundType
|
enum class SoundType
|
||||||
{
|
{
|
||||||
SOUND_3D,
|
SOUND_3D,
|
||||||
SOUND_2D
|
SOUND_2D
|
||||||
};
|
};
|
||||||
|
|
||||||
SoundEmitter() : Gain(1.f), MaxDistance(1.f), MinDistance(1.f), Pitch(1.f), Loop(false) {}
|
SoundEmitter() : Gain(1.f), MaxDistance(10000.f), MinDistance(1.f), Pitch(1.f), Loop(false) {}
|
||||||
float Gain;
|
float Gain;
|
||||||
float MaxDistance;
|
float MaxDistance;
|
||||||
float MinDistance;
|
float MinDistance;
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef Components_Team_h__
|
||||||
|
#define Components_Team_h__
|
||||||
|
|
||||||
|
#include "Component.h"
|
||||||
|
#include "Entity.h"
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
|
||||||
|
struct Team : Component
|
||||||
|
{
|
||||||
|
unsigned int TeamID;
|
||||||
|
|
||||||
|
virtual Team* Clone() const override { return new Team(*this); }
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif // !Components_Team_h__
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#ifndef Tower_h__
|
||||||
|
#define Tower_h__
|
||||||
|
|
||||||
|
#include "Component.h"
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
|
||||||
|
struct Tower : Component
|
||||||
|
{
|
||||||
|
Tower()
|
||||||
|
: ID(0) { }
|
||||||
|
|
||||||
|
int ID;
|
||||||
|
EntityID GunBase;
|
||||||
|
EntityID Gun;
|
||||||
|
|
||||||
|
|
||||||
|
virtual Tower* Clone() const override { return new Tower(*this); }
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // Tower_h__
|
||||||
@@ -9,6 +9,7 @@ namespace Components
|
|||||||
struct Trigger : Component
|
struct Trigger : Component
|
||||||
{
|
{
|
||||||
bool TriggerOnce;
|
bool TriggerOnce;
|
||||||
|
int TeamID;
|
||||||
virtual Trigger* Clone() const override { return new Trigger(*this); }
|
virtual Trigger* Clone() const override { return new Trigger(*this); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#ifndef Components_Turret_h__
|
||||||
|
#define Components_Turret_h__
|
||||||
|
|
||||||
|
#include "Component.h"
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
|
||||||
|
struct Turret : Component
|
||||||
|
{
|
||||||
|
Turret()
|
||||||
|
: ShotSpeed(1.0f) { }
|
||||||
|
|
||||||
|
EntityID ShotTemplate;
|
||||||
|
float ShotSpeed;
|
||||||
|
|
||||||
|
virtual Turret* Clone() const override { return new Turret(*this); }
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // BarrelSteering_h__
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#ifndef Components_TurretShot_h__
|
||||||
|
#define Components_TurretShot_h__
|
||||||
|
|
||||||
|
#include "Component.h"
|
||||||
|
|
||||||
|
namespace Components
|
||||||
|
{
|
||||||
|
|
||||||
|
struct TurretShot : Component
|
||||||
|
{
|
||||||
|
TurretShot()
|
||||||
|
: Damage(1.0f),
|
||||||
|
ExplosionRadius(1.0f),
|
||||||
|
ExplosionStrength(100.0f) { }
|
||||||
|
|
||||||
|
float Damage;
|
||||||
|
float ExplosionRadius;
|
||||||
|
float ExplosionStrength;
|
||||||
|
|
||||||
|
virtual TurretShot* Clone() const override { return new TurretShot(*this); }
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // Components_TurretShot_h__
|
||||||
@@ -10,8 +10,8 @@ namespace Components
|
|||||||
struct Vehicle : Component
|
struct Vehicle : Component
|
||||||
{
|
{
|
||||||
Vehicle()
|
Vehicle()
|
||||||
: MaxTorque(1000.0f), MinRPM(200.0f), OptimalRPM(3000.0f), MaxRPM(6000.0f), MaxSteeringAngle(35), TopSpeed(90.0f),
|
: MaxTorque(1000.0f), MinRPM(200.0f), OptimalRPM(2500.0f), MaxRPM(4000.0f), MaxSteeringAngle(35), TopSpeed(90.0f),
|
||||||
MaxSpeedFullSteeringAngle(40.0f), SpringDamping(1.f), UpshiftRPM(5500.0f), DownshiftRPM(1000.0f),
|
MaxSpeedFullSteeringAngle(40.0f), SpringDamping(1.f), UpshiftRPM(3500.0f), DownshiftRPM(1000.0f),
|
||||||
gearsRatio0(3.0f), gearsRatio1(2.25f), gearsRatio2(1.5f), gearsRatio3(1.0f){ }
|
gearsRatio0(3.0f), gearsRatio1(2.25f), gearsRatio2(1.5f), gearsRatio3(1.0f){ }
|
||||||
float MaxTorque;
|
float MaxTorque;
|
||||||
float MinRPM;
|
float MinRPM;
|
||||||
|
|||||||
+2
-1
@@ -22,7 +22,8 @@ public:
|
|||||||
m_ResourceManager = std::make_shared<ResourceManager>();
|
m_ResourceManager = std::make_shared<ResourceManager>();
|
||||||
m_ResourceManager->RegisterType("OBJ", [](std::string resourceName) { return new OBJ(resourceName); });
|
m_ResourceManager->RegisterType("OBJ", [](std::string resourceName) { return new OBJ(resourceName); });
|
||||||
auto rm = m_ResourceManager;
|
auto rm = m_ResourceManager;
|
||||||
m_ResourceManager->RegisterType("Model", [rm](std::string resourceName) { return new Model(rm, *rm->Load<OBJ>("OBJ", resourceName)); });
|
m_ResourceManager->RegisterType("Model", [rm](std::string resourceName) { return new Model(rm, *rm->Load<OBJ>("OBJ", resourceName), false); });
|
||||||
|
m_ResourceManager->RegisterType("AveragedModel", [rm](std::string resourceName) { return new Model(rm, *rm->Load<OBJ>("OBJ", resourceName), true); });
|
||||||
m_ResourceManager->RegisterType("Texture", [](std::string resourceName) { return new Texture(resourceName); });
|
m_ResourceManager->RegisterType("Texture", [](std::string resourceName) { return new Texture(resourceName); });
|
||||||
|
|
||||||
m_FrameStack = new GUI::Frame(m_EventBroker, m_ResourceManager);
|
m_FrameStack = new GUI::Frame(m_EventBroker, m_ResourceManager);
|
||||||
|
|||||||
@@ -9,8 +9,10 @@ namespace Events
|
|||||||
{
|
{
|
||||||
struct CreateExplosion : Event
|
struct CreateExplosion : Event
|
||||||
{
|
{
|
||||||
CreateExplosion()
|
CreateExplosion() :
|
||||||
: Color(glm::vec4(0)) {}
|
Color(glm::vec4(0)),
|
||||||
|
UseGoalVector(false) {}
|
||||||
|
|
||||||
glm::vec3 Position;
|
glm::vec3 Position;
|
||||||
glm::vec4 Color;
|
glm::vec4 Color;
|
||||||
double LifeTime;
|
double LifeTime;
|
||||||
@@ -20,6 +22,10 @@ namespace Events
|
|||||||
float Speed;
|
float Speed;
|
||||||
float SpreadAngle;
|
float SpreadAngle;
|
||||||
std::vector<float> ParticleScale;
|
std::vector<float> ParticleScale;
|
||||||
|
bool UseGoalVector;
|
||||||
|
glm::vec3 GoalVelocity;
|
||||||
|
bool Emitting;
|
||||||
|
float SpawnFrequency;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef Events_FlagCaptured_h__
|
||||||
|
#define Events_FlagCaptured_h__
|
||||||
|
|
||||||
|
#include "Entity.h"
|
||||||
|
#include "EventBroker.h"
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
struct FlagCaptured : Event
|
||||||
|
{
|
||||||
|
EntityID Player;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // Events_FlagCaptured_h__
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef Events_FlagDropped_h__
|
||||||
|
#define Events_FlagDropped_h__
|
||||||
|
|
||||||
|
#include "Entity.h"
|
||||||
|
#include "EventBroker.h"
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
struct FlagDropped : Event
|
||||||
|
{
|
||||||
|
EntityID Player;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // Events_FlagDropped_h__
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef Events_FlagPickup_h__
|
||||||
|
#define Events_FlagPickup_h__
|
||||||
|
|
||||||
|
#include "Entity.h"
|
||||||
|
#include "EventBroker.h"
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
struct FlagPickup : Event
|
||||||
|
{
|
||||||
|
EntityID Player;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // Events_FlagPickup_h__
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef Events_FlagReturned_h__
|
||||||
|
#define Events_FlagReturned_h__
|
||||||
|
|
||||||
|
#include "Entity.h"
|
||||||
|
#include "EventBroker.h"
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
struct FlagReturned : Event
|
||||||
|
{
|
||||||
|
EntityID Player;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // Events_FlagReturned_h__
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef Events_GameOver_h__
|
||||||
|
#define Events_GameOver_h__
|
||||||
|
|
||||||
|
#include "Entity.h"
|
||||||
|
#include "EventBroker.h"
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
struct GameOver : Event
|
||||||
|
{
|
||||||
|
EntityID Winner;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // Events_GameOver_h__
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef Events_GameStart_h__
|
||||||
|
#define Events_GameStart_h__
|
||||||
|
|
||||||
|
#include "Entity.h"
|
||||||
|
#include "EventBroker.h"
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
struct GameStart : Event
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // Events_GameStart_h__
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#ifndef Events_JeepSteer_h__
|
||||||
|
#define Events_JeepSteer_h__
|
||||||
|
#include "Entity.h"
|
||||||
|
#include "EventBroker.h"
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
struct JeepSteer : Event
|
||||||
|
{
|
||||||
|
EntityID Entity;
|
||||||
|
float PositionX;
|
||||||
|
float PositionY;
|
||||||
|
bool Handbrake;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // Events_JeepSteer_h__
|
||||||
+10
-1
@@ -9,8 +9,17 @@ namespace Events
|
|||||||
|
|
||||||
struct PlaySFX : Event
|
struct PlaySFX : Event
|
||||||
{
|
{
|
||||||
EntityID Emitter;
|
PlaySFX() :
|
||||||
|
MinDistance(100.f),
|
||||||
|
MaxDistance(10000.f),
|
||||||
|
Volume(1.f),
|
||||||
|
Loop (false) {}
|
||||||
|
//EntityID Emitter;
|
||||||
|
glm::vec3 Position;
|
||||||
std::string Resource;
|
std::string Resource;
|
||||||
|
float MinDistance;
|
||||||
|
float MaxDistance;
|
||||||
|
float Volume;
|
||||||
bool Loop;
|
bool Loop;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+45
-15
@@ -36,6 +36,7 @@ public:
|
|||||||
: EventBroker(eventBroker)
|
: EventBroker(eventBroker)
|
||||||
, ResourceManager(resourceManager)
|
, ResourceManager(resourceManager)
|
||||||
, Rectangle()
|
, Rectangle()
|
||||||
|
, m_Parent(nullptr)
|
||||||
, m_Name("UIParent")
|
, m_Name("UIParent")
|
||||||
, m_Layer(0)
|
, m_Layer(0)
|
||||||
, m_Hidden(false)
|
, m_Hidden(false)
|
||||||
@@ -46,12 +47,28 @@ public:
|
|||||||
: m_Name(name)
|
: m_Name(name)
|
||||||
, m_Layer(0)
|
, m_Layer(0)
|
||||||
, m_Hidden(false)
|
, m_Hidden(false)
|
||||||
{ SetParent(std::shared_ptr<Frame>(parent)); Initialize(); }
|
{ SetParent(parent); Initialize(); }
|
||||||
|
|
||||||
|
~Frame()
|
||||||
|
{
|
||||||
|
/*for (auto layer : m_Children)
|
||||||
|
{
|
||||||
|
for (auto child : layer.second)
|
||||||
|
{
|
||||||
|
delete child.second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_Parent)
|
||||||
|
{
|
||||||
|
m_Parent->RemoveChild(this);
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
::RenderQueuePair RenderQueue;
|
::RenderQueuePair RenderQueue;
|
||||||
|
|
||||||
std::shared_ptr<Frame> Parent() const { return m_Parent; }
|
Frame* Parent() const { return m_Parent; }
|
||||||
void SetParent(std::shared_ptr<Frame> parent)
|
void SetParent(Frame* parent)
|
||||||
{
|
{
|
||||||
if (parent == nullptr)
|
if (parent == nullptr)
|
||||||
{
|
{
|
||||||
@@ -62,13 +79,13 @@ public:
|
|||||||
Width = parent->Width;
|
Width = parent->Width;
|
||||||
Height = parent->Height;
|
Height = parent->Height;
|
||||||
m_Layer = parent->Layer() + 1;
|
m_Layer = parent->Layer() + 1;
|
||||||
parent->AddChild(std::shared_ptr<Frame>(this));
|
parent->AddChild(this);
|
||||||
m_Parent = parent;
|
m_Parent = parent;
|
||||||
EventBroker = parent->EventBroker;
|
EventBroker = parent->EventBroker;
|
||||||
ResourceManager = parent->ResourceManager;
|
ResourceManager = parent->ResourceManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddChild(std::shared_ptr<Frame> child)
|
void AddChild(Frame* child)
|
||||||
{
|
{
|
||||||
m_Children[child->m_Layer].insert(std::make_pair(child->Name(), child));
|
m_Children[child->m_Layer].insert(std::make_pair(child->Name(), child));
|
||||||
if (m_Parent)
|
if (m_Parent)
|
||||||
@@ -77,7 +94,19 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef std::map<std::string, std::shared_ptr<Frame>>::const_iterator FrameChildrenIterator;
|
void RemoveChild(Frame* child)
|
||||||
|
{
|
||||||
|
auto it = m_Children.find(child->m_Layer);
|
||||||
|
if (it != m_Children.end())
|
||||||
|
{
|
||||||
|
m_Children.erase(it);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_Parent)
|
||||||
|
{
|
||||||
|
m_Parent->RemoveChild(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string Name() const { return m_Name; }
|
std::string Name() const { return m_Name; }
|
||||||
void SetName(std::string val) { m_Name = val; }
|
void SetName(std::string val) { m_Name = val; }
|
||||||
@@ -89,8 +118,14 @@ public:
|
|||||||
else
|
else
|
||||||
return m_Hidden;
|
return m_Hidden;
|
||||||
}
|
}
|
||||||
void Hide() { m_Hidden = true; }
|
|
||||||
void Show() { m_Hidden = false; }
|
bool Visible() const
|
||||||
|
{
|
||||||
|
return !Hidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void Hide() { m_Hidden = true; }
|
||||||
|
virtual void Show() { m_Hidden = false; }
|
||||||
|
|
||||||
int Left() const override
|
int Left() const override
|
||||||
{
|
{
|
||||||
@@ -144,9 +179,6 @@ public:
|
|||||||
|
|
||||||
void UpdateLayered(double dt)
|
void UpdateLayered(double dt)
|
||||||
{
|
{
|
||||||
if (this->Hidden())
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Update ourselves
|
// Update ourselves
|
||||||
this->Update(dt);
|
this->Update(dt);
|
||||||
|
|
||||||
@@ -157,8 +189,6 @@ public:
|
|||||||
for (auto &pairChild : children)
|
for (auto &pairChild : children)
|
||||||
{
|
{
|
||||||
auto child = pairChild.second;
|
auto child = pairChild.second;
|
||||||
if (child->Hidden())
|
|
||||||
continue;
|
|
||||||
child->Update(dt);
|
child->Update(dt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -200,8 +230,8 @@ protected:
|
|||||||
int m_Layer;
|
int m_Layer;
|
||||||
bool m_Hidden;
|
bool m_Hidden;
|
||||||
|
|
||||||
std::shared_ptr<Frame> m_Parent;
|
Frame* m_Parent;
|
||||||
typedef std::multimap<std::string, std::shared_ptr<Frame>> Children_t; // name -> frame
|
typedef std::multimap<std::string, Frame*> Children_t; // name -> frame
|
||||||
std::map<int, Children_t> m_Children; // layer -> Children_t
|
std::map<int, Children_t> m_Children; // layer -> Children_t
|
||||||
|
|
||||||
virtual bool OnKeyDown(const Events::KeyDown &event) { return false; }
|
virtual bool OnKeyDown(const Events::KeyDown &event) { return false; }
|
||||||
|
|||||||
+35
-11
@@ -2,13 +2,15 @@
|
|||||||
#define GUI_GameFrame_h__
|
#define GUI_GameFrame_h__
|
||||||
|
|
||||||
#include "GUI/Frame.h"
|
#include "GUI/Frame.h"
|
||||||
|
#include "GUI/MainMenuFrame.h"
|
||||||
#include "GUI/WorldFrame.h"
|
#include "GUI/WorldFrame.h"
|
||||||
#include "GUI/Viewport.h"
|
#include "GUI/Viewport.h"
|
||||||
#include "GUI/TextureFrame.h"
|
#include "GUI/TextureFrame.h"
|
||||||
#include "GUI/PlayerHUD.h"
|
#include "GUI/PlayerHUD.h"
|
||||||
#include "VehicleSelection.h"
|
|
||||||
|
|
||||||
#include "GameWorld.h"
|
#include "GameWorld.h"
|
||||||
|
#include "Events/GameStart.h"
|
||||||
|
#include "Events/GameOver.h"
|
||||||
|
|
||||||
namespace GUI
|
namespace GUI
|
||||||
{
|
{
|
||||||
@@ -18,37 +20,59 @@ class GameFrame : public Frame
|
|||||||
public:
|
public:
|
||||||
GameFrame(Frame* parent, std::string name)
|
GameFrame(Frame* parent, std::string name)
|
||||||
: Frame(parent, name)
|
: Frame(parent, name)
|
||||||
|
, m_GameOver(false)
|
||||||
{
|
{
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EGameStart, &GUI::GameFrame::OnGameStart);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EGameOver, &GUI::GameFrame::OnGameOver);
|
||||||
|
|
||||||
m_World = std::make_shared<GameWorld>(EventBroker, ResourceManager);
|
m_World = std::make_shared<GameWorld>(EventBroker, ResourceManager);
|
||||||
auto worldFrame = new WorldFrame(this, "GameWorldFrame", m_World);
|
m_WorldFrame = new WorldFrame(this, "GameWorldFrame", m_World);
|
||||||
{
|
{
|
||||||
vp1 = new Viewport(worldFrame, "Viewport1", m_World);
|
vp1 = new Viewport(m_WorldFrame, "Viewport1", m_World);
|
||||||
vp1->X = 0;
|
vp1->X = 0;
|
||||||
vp1->Width = this->Width / 2.f;
|
vp1->Width = this->Width / 2.f;
|
||||||
//new PlayerHUD(vp1, "PlayerHUD", 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 = new Viewport(m_WorldFrame, "Viewport2", m_World);
|
||||||
vp2->X = vp1->Right();
|
vp2->X = vp1->Right();
|
||||||
vp2->Width = this->Width / 2.f;
|
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(m_WorldFrame, "ViewportFreeCam", m_World);
|
||||||
m_FreeCamViewport = new Viewport(worldFrame, "ViewportFreeCam", m_World);
|
|
||||||
m_FreeCamViewport->Hide();
|
m_FreeCamViewport->Hide();
|
||||||
}
|
}
|
||||||
|
//m_WorldFrame->Hide();
|
||||||
|
//m_MainMenuFrame = new MainMenuFrame(this, "MainMenu");
|
||||||
|
|
||||||
m_World->Initialize();
|
m_World->Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EventRelay<Frame, Events::KeyUp> m_EKeyUp;
|
EventRelay<Frame, Events::GameStart> m_EGameStart;
|
||||||
|
bool OnGameStart(const Events::GameStart &event)
|
||||||
|
{
|
||||||
|
m_WorldFrame->Show();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
EventRelay<Frame, Events::GameOver> m_EGameOver;
|
||||||
|
bool OnGameOver(const Events::GameOver &event)
|
||||||
|
{
|
||||||
|
m_GameOver = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<GameWorld> m_World;
|
std::shared_ptr<GameWorld> m_World;
|
||||||
|
|
||||||
|
MainMenuFrame* m_MainMenuFrame;
|
||||||
|
WorldFrame* m_WorldFrame;
|
||||||
Viewport* vp1;
|
Viewport* vp1;
|
||||||
Viewport* vp2;
|
Viewport* vp2;
|
||||||
Viewport* m_FreeCamViewport;
|
Viewport* m_FreeCamViewport;
|
||||||
|
|
||||||
|
bool m_GameOver;
|
||||||
|
|
||||||
bool OnKeyUp(const Events::KeyUp &event) override
|
bool OnKeyUp(const Events::KeyUp &event) override
|
||||||
{
|
{
|
||||||
if (event.KeyCode == GLFW_KEY_1)
|
if (event.KeyCode == GLFW_KEY_1)
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
#ifndef GUI_GameOverFrame_h__
|
||||||
|
#define GUI_GameOverFrame_h__
|
||||||
|
|
||||||
|
#include "GUI/Frame.h"
|
||||||
|
#include "GUI/HealthOverlay.h"
|
||||||
|
|
||||||
|
namespace GUI
|
||||||
|
{
|
||||||
|
|
||||||
|
class GameOverFrame : public Frame
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GameOverFrame(Frame* parent, std::string name)
|
||||||
|
: Frame(parent, name)
|
||||||
|
{
|
||||||
|
//Hide();
|
||||||
|
m_Background = new TextureFrame(this, "Background");
|
||||||
|
m_Background->SetTexture("Textures/GUI/black.png");
|
||||||
|
m_Background->SetColor(glm::vec4(1.f, 1.f, 1.f, 0.6f));
|
||||||
|
m_Text = new TextureFrame(this, "Message");
|
||||||
|
m_Text->SetTexture("Textures/GUI/GloriousVictory.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Show(bool victory)
|
||||||
|
{
|
||||||
|
if (victory)
|
||||||
|
m_Text->SetTexture("Textures/GUI/GloriousVictory.png");
|
||||||
|
else
|
||||||
|
m_Text->SetTexture("Textures/GUI/ShamefulDefeat.png");
|
||||||
|
|
||||||
|
Frame::Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool m_Victory;
|
||||||
|
TextureFrame* m_Background;
|
||||||
|
TextureFrame* m_Text;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // GUI_GameOverFrame_h__
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
#ifndef GUI_MainMenuFrame_h__
|
||||||
|
#define GUI_MainMenuFrame_h__
|
||||||
|
|
||||||
|
#include "GUI/Frame.h"
|
||||||
|
#include "GUI/HealthOverlay.h"
|
||||||
|
|
||||||
|
#include "Events/GameStart.h"
|
||||||
|
|
||||||
|
namespace GUI
|
||||||
|
{
|
||||||
|
|
||||||
|
class MainMenuFrame : public Frame
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MainMenuFrame(Frame* parent, std::string name)
|
||||||
|
: Frame(parent, name)
|
||||||
|
{
|
||||||
|
m_CurrentSelection = 0;
|
||||||
|
|
||||||
|
//Hide();
|
||||||
|
m_Background = new TextureFrame(this, "Background");
|
||||||
|
m_Background->SetTexture("Textures/GUI/MainMenu/BackGround.png");
|
||||||
|
|
||||||
|
m_Buttons = new TextureFrame(this, "Message");
|
||||||
|
m_Buttons->SetTexture("Textures/GUI/MainMenu/Buttons.png");
|
||||||
|
m_CurrentCoordinate = -m_SelectionCoordinates[0] * Scale();
|
||||||
|
m_TargetCoordinate = m_CurrentCoordinate;
|
||||||
|
m_Buttons->X = m_CurrentCoordinate.x;
|
||||||
|
m_Buttons->Y = m_CurrentCoordinate.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update(double dt) override
|
||||||
|
{
|
||||||
|
if (Hidden())
|
||||||
|
return;
|
||||||
|
|
||||||
|
glm::vec2 posDiff = m_TargetCoordinate - m_CurrentCoordinate;
|
||||||
|
m_CurrentCoordinate += posDiff * 4.f * (float)dt;
|
||||||
|
|
||||||
|
m_Buttons->X = m_CurrentCoordinate.x;
|
||||||
|
m_Buttons->Y = m_CurrentCoordinate.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool m_Victory;
|
||||||
|
TextureFrame* m_Background;
|
||||||
|
TextureFrame* m_Buttons;
|
||||||
|
|
||||||
|
int m_CurrentSelection;
|
||||||
|
static glm::vec2 m_SelectionCoordinates[2];
|
||||||
|
glm::vec2 m_CurrentCoordinate;
|
||||||
|
glm::vec2 m_TargetCoordinate;
|
||||||
|
|
||||||
|
bool OnCommand(const Events::InputCommand &event) override
|
||||||
|
{
|
||||||
|
if (Hidden())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const float deadzone = 0.5f;
|
||||||
|
|
||||||
|
if (event.Command == "interface_horizontal")
|
||||||
|
{
|
||||||
|
if (event.Value > deadzone)
|
||||||
|
m_CurrentSelection++;
|
||||||
|
else if (event.Value < -deadzone)
|
||||||
|
m_CurrentSelection--;
|
||||||
|
}
|
||||||
|
m_CurrentSelection = (m_CurrentSelection < 0) ? 0 : ((m_CurrentSelection > 1) ? 1 : m_CurrentSelection);
|
||||||
|
m_TargetCoordinate = -m_SelectionCoordinates[m_CurrentSelection] * Scale();
|
||||||
|
|
||||||
|
if (event.Command == "interface_confirm" && event.Value > 0)
|
||||||
|
{
|
||||||
|
// Play
|
||||||
|
if (m_CurrentSelection == 0)
|
||||||
|
{
|
||||||
|
Hide();
|
||||||
|
Events::GameStart e;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
// Quit
|
||||||
|
else if (m_CurrentSelection == 1)
|
||||||
|
{
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
glm::vec2 MainMenuFrame::m_SelectionCoordinates[2] = {
|
||||||
|
glm::vec2(0, 0),
|
||||||
|
glm::vec2(193, 0),
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // GUI_MainMenuFrame_h__
|
||||||
@@ -3,6 +3,11 @@
|
|||||||
|
|
||||||
#include "GUI/Frame.h"
|
#include "GUI/Frame.h"
|
||||||
#include "GUI/HealthOverlay.h"
|
#include "GUI/HealthOverlay.h"
|
||||||
|
#include "GUI/VehicleSelection.h"
|
||||||
|
#include "GUI/GameOverFrame.h"
|
||||||
|
|
||||||
|
#include "Events/GameOver.h"
|
||||||
|
#include "Components/Player.h"
|
||||||
|
|
||||||
namespace GUI
|
namespace GUI
|
||||||
{
|
{
|
||||||
@@ -15,7 +20,10 @@ namespace GUI
|
|||||||
, m_World(world)
|
, m_World(world)
|
||||||
, m_PlayerID(playerID)
|
, m_PlayerID(playerID)
|
||||||
{
|
{
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EGameOver, &GUI::PlayerHUD::OnGameOver)
|
||||||
|
|
||||||
m_HealthOverlay = new HealthOverlay(this, "HealthOverlay", m_World, m_PlayerID);
|
m_HealthOverlay = new HealthOverlay(this, "HealthOverlay", m_World, m_PlayerID);
|
||||||
|
|
||||||
m_Crosshair = new TextureFrame(this, "Crosshair");
|
m_Crosshair = new TextureFrame(this, "Crosshair");
|
||||||
m_Crosshair->Width = 45;
|
m_Crosshair->Width = 45;
|
||||||
m_Crosshair->Height = 45;
|
m_Crosshair->Height = 45;
|
||||||
@@ -23,6 +31,10 @@ namespace GUI
|
|||||||
m_Crosshair->Y = this->Height / 2.f - m_Crosshair->Height / 2.f;
|
m_Crosshair->Y = this->Height / 2.f - m_Crosshair->Height / 2.f;
|
||||||
m_Crosshair->SetTexture("Textures/GUI/crosshair.png");
|
m_Crosshair->SetTexture("Textures/GUI/crosshair.png");
|
||||||
m_Crosshair->SetColor(glm::vec4(1.f, 1.f, 1.f, 0.75f));
|
m_Crosshair->SetColor(glm::vec4(1.f, 1.f, 1.f, 0.75f));
|
||||||
|
|
||||||
|
m_VehicleSelection = new VehicleSelection(this, "VehicleSelection", m_World, m_PlayerID);
|
||||||
|
|
||||||
|
m_GameOverFrame = new GameOverFrame(this, "GameOver");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -31,6 +43,42 @@ namespace GUI
|
|||||||
|
|
||||||
HealthOverlay* m_HealthOverlay;
|
HealthOverlay* m_HealthOverlay;
|
||||||
TextureFrame* m_Crosshair;
|
TextureFrame* m_Crosshair;
|
||||||
|
VehicleSelection* m_VehicleSelection;
|
||||||
|
GameOverFrame* m_GameOverFrame;
|
||||||
|
|
||||||
|
EventRelay<Frame, Events::GameOver> m_EGameOver;
|
||||||
|
bool OnGameOver(const Events::GameOver &event)
|
||||||
|
{
|
||||||
|
auto playerComponent = m_World->GetComponent<Components::Player>(event.Winner);
|
||||||
|
if (!playerComponent)
|
||||||
|
{
|
||||||
|
LOG_ERROR("Winner is not a valid player!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_PlayerID == playerComponent->ID)
|
||||||
|
m_GameOverFrame->Show(true);
|
||||||
|
else
|
||||||
|
m_GameOverFrame->Show(false);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OnCommand(const Events::InputCommand &event)
|
||||||
|
{
|
||||||
|
if (event.PlayerID != m_PlayerID)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (event.Command == "interface_confirm" && event.Value > 0)
|
||||||
|
{
|
||||||
|
if (m_GameOverFrame->Visible())
|
||||||
|
{
|
||||||
|
m_GameOverFrame->Hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ namespace GUI
|
|||||||
|
|
||||||
void Update(double dt) override
|
void Update(double dt) override
|
||||||
{
|
{
|
||||||
|
if (Hidden())
|
||||||
|
return;
|
||||||
|
|
||||||
glm::vec2 posDiff = m_TargetCoordinate - m_CurrentCoordinate;
|
glm::vec2 posDiff = m_TargetCoordinate - m_CurrentCoordinate;
|
||||||
m_CurrentCoordinate += posDiff * 2.f * (float)dt;
|
m_CurrentCoordinate += posDiff * 2.f * (float)dt;
|
||||||
|
|
||||||
@@ -77,28 +80,30 @@ namespace GUI
|
|||||||
if (event.PlayerID != m_PlayerID)
|
if (event.PlayerID != m_PlayerID)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
const float deadzone = 0.5f;
|
||||||
|
|
||||||
// Menu movement
|
// Menu movement
|
||||||
if (event.Command == "interface_horizontal" || event.Command == "interface_vertical")
|
if (event.Command == "interface_horizontal" || event.Command == "interface_vertical")
|
||||||
{
|
{
|
||||||
// Horizontal scrolling
|
// Horizontal scrolling
|
||||||
if (event.Command == "interface_horizontal")
|
if (event.Command == "interface_horizontal")
|
||||||
{
|
{
|
||||||
if (event.Value > 0)
|
if (event.Value > deadzone)
|
||||||
m_CurrentSelection++;
|
m_CurrentSelection++;
|
||||||
else if (event.Value < 0)
|
else if (event.Value < -deadzone)
|
||||||
m_CurrentSelection--;
|
m_CurrentSelection--;
|
||||||
}
|
}
|
||||||
// Vertical scrolling to switch between "rows" in an intuitive way
|
// Vertical scrolling to switch between "rows" in an intuitive way
|
||||||
else if (event.Command == "interface_vertical")
|
else if (event.Command == "interface_vertical")
|
||||||
{
|
{
|
||||||
if (event.Value > 0)
|
if (event.Value > deadzone)
|
||||||
{
|
{
|
||||||
if (m_CurrentSelection == 0)
|
if (m_CurrentSelection == 0)
|
||||||
m_CurrentSelection++;
|
m_CurrentSelection++;
|
||||||
else if (m_CurrentSelection == 3)
|
else if (m_CurrentSelection == 3)
|
||||||
m_CurrentSelection--;
|
m_CurrentSelection--;
|
||||||
}
|
}
|
||||||
else if (event.Value < 0)
|
else if (event.Value < -deadzone)
|
||||||
{
|
{
|
||||||
if (m_CurrentSelection == 1)
|
if (m_CurrentSelection == 1)
|
||||||
m_CurrentSelection--;
|
m_CurrentSelection--;
|
||||||
|
|||||||
+12
-2
@@ -55,7 +55,17 @@ public:
|
|||||||
auto modelComponent = m_World->GetComponent<Components::Model>(entity);
|
auto modelComponent = m_World->GetComponent<Components::Model>(entity);
|
||||||
if (modelComponent)
|
if (modelComponent)
|
||||||
{
|
{
|
||||||
auto modelAsset = ResourceManager->Load<Model>("Model", modelComponent->ModelFile);
|
Model* modelAsset = nullptr;
|
||||||
|
if (modelComponent->AverageNormals)
|
||||||
|
{
|
||||||
|
modelAsset = ResourceManager->Load<Model>("AveragedModel", modelComponent->ModelFile);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
modelAsset = ResourceManager->Load<Model>("Model", modelComponent->ModelFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (modelAsset)
|
if (modelAsset)
|
||||||
{
|
{
|
||||||
Components::Transform absoluteTransform = m_TransformSystem->AbsoluteTransform(entity);
|
Components::Transform absoluteTransform = m_TransformSystem->AbsoluteTransform(entity);
|
||||||
@@ -145,7 +155,7 @@ private:
|
|||||||
auto itpair = m_Children[m_Layer + 1].equal_range(event.ViewportFrame);
|
auto itpair = m_Children[m_Layer + 1].equal_range(event.ViewportFrame);
|
||||||
for (auto it = itpair.first; it != itpair.second; ++it)
|
for (auto it = itpair.first; it != itpair.second; ++it)
|
||||||
{
|
{
|
||||||
auto viewportFrame = std::dynamic_pointer_cast<GUI::Viewport>(it->second);
|
auto viewportFrame = dynamic_cast<GUI::Viewport*>(it->second);
|
||||||
if (!viewportFrame)
|
if (!viewportFrame)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
+678
-369
File diff suppressed because it is too large
Load Diff
+10
-4
@@ -23,12 +23,15 @@
|
|||||||
#include "Systems/WheelPairSystem.h"
|
#include "Systems/WheelPairSystem.h"
|
||||||
#include "Systems/FollowSystem.h"
|
#include "Systems/FollowSystem.h"
|
||||||
#include "Systems/WallSystem.h"
|
#include "Systems/WallSystem.h"
|
||||||
|
#include "Systems/TowerSystem.h"
|
||||||
#include "Systems/GarageSystem.h"
|
#include "Systems/GarageSystem.h"
|
||||||
|
#include "Systems/JeepSteeringSystem.h"
|
||||||
|
|
||||||
#include "Components/Camera.h"
|
#include "Components/Camera.h"
|
||||||
#include "Components/DirectionalLight.h"
|
#include "Components/DirectionalLight.h"
|
||||||
#include "Components/Input.h"
|
#include "Components/Input.h"
|
||||||
#include "Components/Model.h"
|
#include "Components/Model.h"
|
||||||
|
#include "Components/DamageModel.h"
|
||||||
#include "Components/ParticleEmitter.h"
|
#include "Components/ParticleEmitter.h"
|
||||||
#include "Components/Particle.h"
|
#include "Components/Particle.h"
|
||||||
#include "Components/PointLight.h"
|
#include "Components/PointLight.h"
|
||||||
@@ -56,6 +59,7 @@
|
|||||||
#include "Components/TriggerRotate.h"
|
#include "Components/TriggerRotate.h"
|
||||||
#include "Components/Move.h"
|
#include "Components/Move.h"
|
||||||
#include "Components/Rotate.h"
|
#include "Components/Rotate.h"
|
||||||
|
#include "Components/Team.h"
|
||||||
|
|
||||||
class GameWorld : public World
|
class GameWorld : public World
|
||||||
{
|
{
|
||||||
@@ -78,14 +82,16 @@ private:
|
|||||||
void BindGamepadAxis(Gamepad::Axis axis, std::string command, float value);
|
void BindGamepadAxis(Gamepad::Axis axis, std::string command, float value);
|
||||||
void BindGamepadButton(Gamepad::Button button, std::string command, float value);
|
void BindGamepadButton(Gamepad::Button button, std::string command, float value);
|
||||||
|
|
||||||
void CreateGate(glm::vec3 Position);
|
void CreateGate(EntityID parent, glm::vec3 position, glm::quat orientation, int teamID);
|
||||||
void AddTankWheelPair(EntityID tankEntity, glm::vec3 position, int axleID, bool steering);
|
void AddTankWheelPair(EntityID tankEntity, glm::vec3 position, int axleID, bool steering);
|
||||||
EntityID CreateJeep(int playerID);
|
EntityID CreateJeep(int playerID);
|
||||||
EntityID CreateWall(glm::vec3 pos, glm::quat orientation);
|
EntityID CreateWall(EntityID parent, glm::vec3 pos, glm::quat orientation);
|
||||||
EntityID CreateGarage(glm::vec3 Position, glm::quat orientation, int playerID);
|
EntityID CreateTower(EntityID parent, glm::vec3 pos, int teamID);
|
||||||
|
EntityID CreateGarage(EntityID parent, glm::vec3 Position, glm::quat orientation, int teamID);
|
||||||
void CreateTerrain();
|
void CreateTerrain();
|
||||||
void CreateBase(glm::quat orientation);
|
void CreateBase(glm::quat orientation, int playerID);
|
||||||
std::vector<EntityID> m_WallDebrisTemplates;
|
std::vector<EntityID> m_WallDebrisTemplates;
|
||||||
|
EntityID m_ShotTemplate;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GameWorld_h__
|
#endif // GameWorld_h__
|
||||||
|
|||||||
+37
-3
@@ -6,29 +6,63 @@
|
|||||||
#include "EventBroker.h"
|
#include "EventBroker.h"
|
||||||
#include "Events/InputCommand.h"
|
#include "Events/InputCommand.h"
|
||||||
#include "Events/MouseMove.h"
|
#include "Events/MouseMove.h"
|
||||||
|
#include "Events/GameStart.h"
|
||||||
|
#include "Events/GameOver.h"
|
||||||
|
|
||||||
template <typename EventContext>
|
template <typename EventContext>
|
||||||
class InputController
|
class InputController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InputController(std::shared_ptr<::EventBroker> eventBroker)
|
InputController(std::shared_ptr<::EventBroker> eventBroker)
|
||||||
: EventBroker(eventBroker) { Initialize(); }
|
: EventBroker(eventBroker)
|
||||||
|
, InGame(true)
|
||||||
|
{ Initialize(); }
|
||||||
|
|
||||||
virtual void Initialize()
|
virtual void Initialize()
|
||||||
{
|
{
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &InputController::OnCommand);
|
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &InputController::_OnCommand);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EMouseMove, &InputController::OnMouseMove);
|
EVENT_SUBSCRIBE_MEMBER(m_EMouseMove, &InputController::_OnMouseMove);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EGameStart, &InputController::OnGameStart);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EGameOver, &InputController::OnGameOver);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool OnCommand(const Events::InputCommand &event) { return false; }
|
virtual bool OnCommand(const Events::InputCommand &event) { return false; }
|
||||||
virtual bool OnMouseMove(const Events::MouseMove &event) { return false; }
|
virtual bool OnMouseMove(const Events::MouseMove &event) { return false; }
|
||||||
|
virtual bool OnGameStart(const Events::GameStart &event)
|
||||||
|
{
|
||||||
|
InGame = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
virtual bool OnGameOver(const Events::GameOver &event)
|
||||||
|
{
|
||||||
|
InGame = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<::EventBroker> EventBroker;
|
std::shared_ptr<::EventBroker> EventBroker;
|
||||||
|
bool InGame;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EventRelay<EventContext, Events::InputCommand> m_EInputCommand;
|
EventRelay<EventContext, Events::InputCommand> m_EInputCommand;
|
||||||
EventRelay<EventContext, Events::MouseMove> m_EMouseMove;
|
EventRelay<EventContext, Events::MouseMove> m_EMouseMove;
|
||||||
|
EventRelay<EventContext, Events::GameStart> m_EGameStart;
|
||||||
|
EventRelay<EventContext, Events::GameOver> m_EGameOver;
|
||||||
|
|
||||||
|
virtual bool _OnCommand(const Events::InputCommand &event)
|
||||||
|
{
|
||||||
|
if (InGame || event.Value == 0)
|
||||||
|
return OnCommand(event);
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
virtual bool _OnMouseMove(const Events::MouseMove &event)
|
||||||
|
{
|
||||||
|
if (InGame)
|
||||||
|
return OnMouseMove(event);
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // InputController_h__
|
#endif // InputController_h__
|
||||||
|
|||||||
+13
-7
@@ -1,7 +1,7 @@
|
|||||||
#include "PrecompiledHeader.h"
|
#include "PrecompiledHeader.h"
|
||||||
#include "Model.h"
|
#include "Model.h"
|
||||||
|
|
||||||
Model::Model(std::shared_ptr<ResourceManager> rm, OBJ &obj)
|
Model::Model(std::shared_ptr<ResourceManager> rm, OBJ &obj, bool average)
|
||||||
{
|
{
|
||||||
OBJ::MaterialInfo* currentMaterial = nullptr;
|
OBJ::MaterialInfo* currentMaterial = nullptr;
|
||||||
TextureGroup* currentTexGroup = nullptr;
|
TextureGroup* currentTexGroup = nullptr;
|
||||||
@@ -93,7 +93,10 @@ Model::Model(std::shared_ptr<ResourceManager> rm, OBJ &obj)
|
|||||||
if (Vertices.size() > 0)
|
if (Vertices.size() > 0)
|
||||||
{
|
{
|
||||||
CreateTangents();
|
CreateTangents();
|
||||||
//getSimilarVertexIndex();
|
if (average)
|
||||||
|
{
|
||||||
|
getSimilarVertexIndex();
|
||||||
|
}
|
||||||
CreateBuffers(Vertices, Normals, TangentNormals, BiTangentNormals, TextureCoords);
|
CreateBuffers(Vertices, Normals, TangentNormals, BiTangentNormals, TextureCoords);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -105,7 +108,7 @@ Model::Model(std::shared_ptr<ResourceManager> rm, OBJ &obj)
|
|||||||
void Model::CreateBuffers( std::vector<glm::vec3> vertices, std::vector<glm::vec3> normals, std::vector<glm::vec3> tangents, std::vector<glm::vec3> biTangents, std::vector<glm::vec2>textureCoords)
|
void Model::CreateBuffers( std::vector<glm::vec3> vertices, std::vector<glm::vec3> normals, std::vector<glm::vec3> tangents, std::vector<glm::vec3> biTangents, std::vector<glm::vec2>textureCoords)
|
||||||
{
|
{
|
||||||
|
|
||||||
LOG_INFO("Generating VertexBuffer");
|
//LOG_INFO("Generating VertexBuffer");
|
||||||
glGenBuffers(1, &VertexBuffer);
|
glGenBuffers(1, &VertexBuffer);
|
||||||
if (vertices.size() > 0)
|
if (vertices.size() > 0)
|
||||||
{
|
{
|
||||||
@@ -118,7 +121,7 @@ void Model::CreateBuffers( std::vector<glm::vec3> vertices, std::vector<glm::vec
|
|||||||
LOG_WARNING("Created empty vertex buffer!");
|
LOG_WARNING("Created empty vertex buffer!");
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO("Generating NormalBuffer");
|
//LOG_INFO("Generating NormalBuffer");
|
||||||
glGenBuffers(1, &NormalBuffer);
|
glGenBuffers(1, &NormalBuffer);
|
||||||
if (normals.size() > 0)
|
if (normals.size() > 0)
|
||||||
{
|
{
|
||||||
@@ -131,7 +134,7 @@ void Model::CreateBuffers( std::vector<glm::vec3> vertices, std::vector<glm::vec
|
|||||||
LOG_WARNING("Created empty normal buffer!");
|
LOG_WARNING("Created empty normal buffer!");
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO("Generating TangentNormalsBuffer");
|
//LOG_INFO("Generating TangentNormalsBuffer");
|
||||||
glGenBuffers(1, &TangentNormalsBuffer);
|
glGenBuffers(1, &TangentNormalsBuffer);
|
||||||
if (tangents.size() > 0)
|
if (tangents.size() > 0)
|
||||||
{
|
{
|
||||||
@@ -144,7 +147,7 @@ void Model::CreateBuffers( std::vector<glm::vec3> vertices, std::vector<glm::vec
|
|||||||
LOG_WARNING("Created empty tangent buffer!");
|
LOG_WARNING("Created empty tangent buffer!");
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO("Generating BiTangentNormalsBuffer");
|
//LOG_INFO("Generating BiTangentNormalsBuffer");
|
||||||
glGenBuffers(1, &BiTangentNormalsBuffer);
|
glGenBuffers(1, &BiTangentNormalsBuffer);
|
||||||
if (biTangents.size() > 0)
|
if (biTangents.size() > 0)
|
||||||
{
|
{
|
||||||
@@ -158,7 +161,7 @@ void Model::CreateBuffers( std::vector<glm::vec3> vertices, std::vector<glm::vec
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LOG_INFO("Generating textureCoordBuffer");
|
//LOG_INFO("Generating textureCoordBuffer");
|
||||||
glGenBuffers(1, &TextureCoordBuffer);
|
glGenBuffers(1, &TextureCoordBuffer);
|
||||||
if (textureCoords.size() > 0)
|
if (textureCoords.size() > 0)
|
||||||
{
|
{
|
||||||
@@ -223,6 +226,8 @@ void Model::getSimilarVertexIndex()
|
|||||||
{
|
{
|
||||||
glm::vec3 tempNormal, tempTangent, tempBiTangent;
|
glm::vec3 tempNormal, tempTangent, tempBiTangent;
|
||||||
|
|
||||||
|
if(glm::dot(Normals[i], Normals[t]) > .4f)
|
||||||
|
{
|
||||||
tempNormal = Normals[i] + Normals[t];
|
tempNormal = Normals[i] + Normals[t];
|
||||||
tempTangent = TangentNormals[i] + TangentNormals[t];
|
tempTangent = TangentNormals[i] + TangentNormals[t];
|
||||||
tempBiTangent = BiTangentNormals[i] + BiTangentNormals[t];
|
tempBiTangent = BiTangentNormals[i] + BiTangentNormals[t];
|
||||||
@@ -235,6 +240,7 @@ void Model::getSimilarVertexIndex()
|
|||||||
|
|
||||||
BiTangentNormals[i] = tempBiTangent;
|
BiTangentNormals[i] = tempBiTangent;
|
||||||
BiTangentNormals[t] = tempBiTangent;
|
BiTangentNormals[t] = tempBiTangent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@
|
|||||||
class Model : public Resource
|
class Model : public Resource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Model(std::shared_ptr<ResourceManager> resourceManager, OBJ &obj);
|
Model(std::shared_ptr<ResourceManager> resourceManager, OBJ &obj, bool average);
|
||||||
|
|
||||||
struct TextureGroup
|
struct TextureGroup
|
||||||
{
|
{
|
||||||
|
|||||||
+3
-3
@@ -13,7 +13,7 @@ bool OBJ::LoadFromFile(std::string filename)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO("Parsing .obj \"%s\"", m_Path.string().c_str());
|
//LOG_INFO("Parsing .obj \"%s\"", m_Path.string().c_str());
|
||||||
|
|
||||||
std::string line;
|
std::string line;
|
||||||
while (std::getline(file, line))
|
while (std::getline(file, line))
|
||||||
@@ -121,7 +121,7 @@ void OBJ::ParseMaterial()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO("Parsing .mtl \"%s\"", m_MaterialPath.string().c_str());
|
//LOG_INFO("Parsing .mtl \"%s\"", m_MaterialPath.string().c_str());
|
||||||
|
|
||||||
std::string currentMaterialName;
|
std::string currentMaterialName;
|
||||||
MaterialInfo* currentMaterial = nullptr;
|
MaterialInfo* currentMaterial = nullptr;
|
||||||
@@ -144,7 +144,7 @@ void OBJ::ParseMaterial()
|
|||||||
{
|
{
|
||||||
MaterialInfo mat;
|
MaterialInfo mat;
|
||||||
ss >> currentMaterialName;
|
ss >> currentMaterialName;
|
||||||
LOG_INFO("Parsing material %s", currentMaterialName.c_str());
|
//LOG_INFO("Parsing material %s", currentMaterialName.c_str());
|
||||||
Materials[currentMaterialName] = mat;
|
Materials[currentMaterialName] = mat;
|
||||||
currentMaterial = &Materials[currentMaterialName];
|
currentMaterial = &Materials[currentMaterialName];
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ void VehicleSetup::setupVehicleData(const hkpWorld* world, hkpVehicleData& data
|
|||||||
|
|
||||||
data.m_chassisUnitInertiaYaw = 0.8f;
|
data.m_chassisUnitInertiaYaw = 0.8f;
|
||||||
data.m_chassisUnitInertiaRoll = 1.0f;
|
data.m_chassisUnitInertiaRoll = 1.0f;
|
||||||
data.m_chassisUnitInertiaPitch = 1.0f;
|
data.m_chassisUnitInertiaPitch = 2.0f;
|
||||||
|
|
||||||
// Adds or removes torque around the yaw axis
|
// Adds or removes torque around the yaw axis
|
||||||
// based on the current steering angle. This will
|
// based on the current steering angle. This will
|
||||||
|
|||||||
+131
-91
@@ -22,7 +22,7 @@ Renderer::Renderer(std::shared_ptr<::ResourceManager> resourceManager)
|
|||||||
LAtt = 0.0f;
|
LAtt = 0.0f;
|
||||||
QAtt = 3.0f;
|
QAtt = 3.0f;
|
||||||
m_ShadowMapRes = 1;
|
m_ShadowMapRes = 1;
|
||||||
m_SunPosition = glm::vec3(0.f, 1.0f, 0.5f);
|
m_SunPosition = glm::vec3(0.f, 1.0f, 0.7f);
|
||||||
m_SunTarget = glm::vec3(0, 0, 0);
|
m_SunTarget = glm::vec3(0, 0, 0);
|
||||||
m_SunProjection_height = glm::vec2(-40.f, 40.f);
|
m_SunProjection_height = glm::vec2(-40.f, 40.f);
|
||||||
m_SunProjection_width = glm::vec2(-40.f, 40.f);
|
m_SunProjection_width = glm::vec2(-40.f, 40.f);
|
||||||
@@ -126,6 +126,7 @@ void Renderer::LoadContent()
|
|||||||
m_SunPassProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/SunPass.vert.glsl")));
|
m_SunPassProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/SunPass.vert.glsl")));
|
||||||
m_SunPassProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/SunPass.frag.glsl")));
|
m_SunPassProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/SunPass.frag.glsl")));
|
||||||
m_SunPassProgram.Compile();
|
m_SunPassProgram.Compile();
|
||||||
|
glBindFragDataLocation(m_SunPassProgram.GetHandle(), 0, "frag_Light");
|
||||||
m_SunPassProgram.Link();
|
m_SunPassProgram.Link();
|
||||||
|
|
||||||
m_ForwardRendering.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardRendering.vert.glsl")));
|
m_ForwardRendering.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardRendering.vert.glsl")));
|
||||||
@@ -142,7 +143,6 @@ void Renderer::LoadContent()
|
|||||||
m_FirstPassProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Vertex.glsl")));
|
m_FirstPassProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Vertex.glsl")));
|
||||||
m_FirstPassProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Fragment.glsl")));
|
m_FirstPassProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Fragment.glsl")));
|
||||||
m_FirstPassProgram.Compile();
|
m_FirstPassProgram.Compile();
|
||||||
|
|
||||||
glBindFragDataLocation(m_FirstPassProgram.GetHandle(), 0, "frag_Diffuse");
|
glBindFragDataLocation(m_FirstPassProgram.GetHandle(), 0, "frag_Diffuse");
|
||||||
glBindFragDataLocation(m_FirstPassProgram.GetHandle(), 1, "frag_Position");
|
glBindFragDataLocation(m_FirstPassProgram.GetHandle(), 1, "frag_Position");
|
||||||
glBindFragDataLocation(m_FirstPassProgram.GetHandle(), 2, "frag_Normal");
|
glBindFragDataLocation(m_FirstPassProgram.GetHandle(), 2, "frag_Normal");
|
||||||
@@ -151,6 +151,7 @@ void Renderer::LoadContent()
|
|||||||
m_SecondPassProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Vertex2.glsl")));
|
m_SecondPassProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Vertex2.glsl")));
|
||||||
m_SecondPassProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Fragment2.glsl")));
|
m_SecondPassProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Fragment2.glsl")));
|
||||||
m_SecondPassProgram.Compile();
|
m_SecondPassProgram.Compile();
|
||||||
|
glBindFragDataLocation(m_SecondPassProgram.GetHandle(), 0, "frag_Light");
|
||||||
m_SecondPassProgram.Link();
|
m_SecondPassProgram.Link();
|
||||||
|
|
||||||
m_SecondPassProgram_Debug.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Vertex2.glsl")));
|
m_SecondPassProgram_Debug.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Vertex2.glsl")));
|
||||||
@@ -161,13 +162,14 @@ void Renderer::LoadContent()
|
|||||||
m_FinalPassProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/FinalPass.vert.glsl")));
|
m_FinalPassProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/FinalPass.vert.glsl")));
|
||||||
m_FinalPassProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/FinalPass.frag.glsl")));
|
m_FinalPassProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/FinalPass.frag.glsl")));
|
||||||
m_FinalPassProgram.Compile();
|
m_FinalPassProgram.Compile();
|
||||||
|
glBindFragDataLocation(m_FinalPassProgram.GetHandle(), 0, "frag_Diffuse");
|
||||||
m_FinalPassProgram.Link();
|
m_FinalPassProgram.Link();
|
||||||
m_ScreenQuad = CreateQuad();
|
m_ScreenQuad = CreateQuad();
|
||||||
CreateShadowMap(m_ShadowMapRes);
|
CreateShadowMap(m_ShadowMapRes);
|
||||||
FrameBufferTextures();
|
FrameBufferTextures();
|
||||||
|
|
||||||
m_sphereModel = ResourceManager->Load<Model>("Model", "Models/Placeholders/PhysicsTest/Sphere.obj");
|
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/sky36", "jpg");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::Draw(double dt)
|
void Renderer::Draw(double dt)
|
||||||
@@ -373,6 +375,7 @@ void Renderer::DrawWorld(RenderQueuePair &rq)
|
|||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glDepthMask(GL_TRUE);
|
glDepthMask(GL_TRUE);
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
|
glDepthRange(0.0, 0.999);
|
||||||
|
|
||||||
//Sort forward rendering items by z value.
|
//Sort forward rendering items by z value.
|
||||||
for(auto job : rq.Forward)
|
for(auto job : rq.Forward)
|
||||||
@@ -386,81 +389,77 @@ void Renderer::DrawWorld(RenderQueuePair &rq)
|
|||||||
rq.Forward.Jobs.sort(Renderer::DepthSort);
|
rq.Forward.Jobs.sort(Renderer::DepthSort);
|
||||||
|
|
||||||
//DrawShadowMap(rq.Deferred);
|
//DrawShadowMap(rq.Deferred);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Base pass
|
Base pass
|
||||||
*/
|
*/
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbBasePass);
|
glBindFramebuffer(GL_FRAMEBUFFER, m_fbBasePass);
|
||||||
glViewport(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
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);
|
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);
|
//glViewport(0, 0, m_Width, m_Height);
|
||||||
|
|
||||||
// Clear G-buffer
|
// Clear G-buffer
|
||||||
GLenum windowBuffClear[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 };
|
|
||||||
glDrawBuffers(4, windowBuffClear);
|
|
||||||
glClearColor(115.f / 255, 192.f / 255, 255.f / 255, 0.f);
|
glClearColor(115.f / 255, 192.f / 255, 255.f / 255, 0.f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
// Execute the first render stage which will fill out the internal buffers with data(??)
|
// Execute the first render stage which will fill out the internal buffers with data(??)
|
||||||
m_FirstPassProgram.Bind();
|
m_FirstPassProgram.Bind();
|
||||||
GLenum windowBuffOpaque[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 };
|
|
||||||
glDrawBuffers(4, windowBuffOpaque);
|
|
||||||
|
|
||||||
glCullFace(GL_BACK);
|
glCullFace(GL_BACK);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
DrawSkybox();
|
|
||||||
DrawFBOScene(rq.Deferred);
|
DrawFBOScene(rq.Deferred);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Lighting pass
|
Lighting pass
|
||||||
*/
|
*/
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbLightingPass);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbLightingPass);
|
||||||
|
//glBindFramebuffer(GL_FRAMEBUFFER, m_fbBasePass);
|
||||||
glViewport(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.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);
|
glScissor(m_Scissor.X, m_Height - m_Scissor.Y - m_Scissor.Height, m_Scissor.Width, m_Scissor.Height);
|
||||||
GLenum lightingPassAttachments[] = { GL_COLOR_ATTACHMENT0 };
|
|
||||||
glDrawBuffers(1, lightingPassAttachments);
|
|
||||||
|
glCullFace(GL_FRONT);
|
||||||
|
glEnable(GL_BLEND);
|
||||||
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
|
glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
glDepthMask(GL_FALSE);
|
||||||
|
|
||||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
m_SecondPassProgram.Bind();
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_fPositionTexture);
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_fNormalsTexture);
|
|
||||||
glActiveTexture(GL_TEXTURE2);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_fSpecularTexture);
|
|
||||||
|
|
||||||
glCullFace(GL_FRONT);
|
|
||||||
DrawLightScene(rq.Deferred);
|
DrawLightScene(rq.Deferred);
|
||||||
|
glCullFace(GL_BACK);
|
||||||
DrawSunLightScene();
|
DrawSunLightScene();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Final pass
|
Final pass
|
||||||
*/
|
*/
|
||||||
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(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
|
||||||
|
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
glBindFramebuffer(GL_FRAMEBUFFER, m_fbFinalPass);
|
||||||
|
glViewport(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_COLOR_BUFFER_BIT);
|
||||||
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m_FinalPassProgram.Bind();
|
m_FinalPassProgram.Bind();
|
||||||
|
// Ambient light
|
||||||
// Ambient light
|
glUniform3fv(glGetUniformLocation(m_FinalPassProgram.GetHandle(), "La"), 1, glm::value_ptr(glm::vec3(1.0f)));
|
||||||
glUniform3fv(glGetUniformLocation(m_FinalPassProgram.GetHandle(), "La"), 1, glm::value_ptr(glm::vec3(0.7f)));
|
//glUniform1f(glGetUniformLocation(m_FinalPassProgram.GetHandle(), "Gamma"), Gamma);
|
||||||
glUniform1f(glGetUniformLocation(m_FinalPassProgram.GetHandle(), "Gamma"), Gamma);
|
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glBindTexture(GL_TEXTURE_2D, m_fDiffuseTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_fDiffuseTexture);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glBindTexture(GL_TEXTURE_2D, m_fLightingTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_fLightingTexture);
|
|
||||||
|
glCullFace(GL_BACK);
|
||||||
glCullFace(GL_BACK);
|
glBindVertexArray(m_ScreenQuad);
|
||||||
glBindVertexArray(m_ScreenQuad);
|
glEnableVertexAttribArray(0);
|
||||||
glEnableVertexAttribArray(0);
|
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Transparency
|
Transparency
|
||||||
@@ -470,25 +469,33 @@ void Renderer::DrawWorld(RenderQueuePair &rq)
|
|||||||
|
|
||||||
void Renderer::ForwardRendering(RenderQueue &rq)
|
void Renderer::ForwardRendering(RenderQueue &rq)
|
||||||
{
|
{
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbBasePass);
|
/*
|
||||||
|
Skybochs
|
||||||
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);
|
glDisable(GL_BLEND);
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
// Clear G-buffer
|
glDepthMask(GL_TRUE);
|
||||||
GLenum attachments[] = { GL_COLOR_ATTACHMENT0, GL_NONE , GL_NONE , GL_NONE };
|
glDepthRange(0.999, 1.0);
|
||||||
glDrawBuffers(4, attachments);
|
DrawSkybox();
|
||||||
//glClearColor(0.f, 0.f, 0.f, 1.f);
|
glDepthRange(0.0, 0.999);
|
||||||
//glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
|
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
glCullFace(GL_BACK);
|
glCullFace(GL_BACK);
|
||||||
|
|
||||||
|
//glBindFramebuffer(GL_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);
|
||||||
|
|
||||||
|
// Clear G-buffer
|
||||||
|
//GLenum attachments[] = { GL_COLOR_ATTACHMENT0, GL_NONE , GL_NONE, GL_NONE };
|
||||||
|
//glDrawBuffers(4, attachments);
|
||||||
|
//glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
//glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
|
|
||||||
glm::mat4 cameraProjection = m_Camera->ProjectionMatrix((float)m_Viewport.Width / m_Viewport.Height);
|
glm::mat4 cameraProjection = m_Camera->ProjectionMatrix((float)m_Viewport.Width / m_Viewport.Height);
|
||||||
glm::mat4 cameraMatrix = cameraProjection * m_Camera->ViewMatrix();
|
glm::mat4 cameraMatrix = cameraProjection * m_Camera->ViewMatrix();
|
||||||
glm::mat4 MVP;
|
glm::mat4 MVP;
|
||||||
@@ -497,7 +504,7 @@ void Renderer::ForwardRendering(RenderQueue &rq)
|
|||||||
GLuint ShaderProgramHandle = m_ForwardRendering.GetHandle();
|
GLuint ShaderProgramHandle = m_ForwardRendering.GetHandle();
|
||||||
for (auto &job : rq)
|
for (auto &job : rq)
|
||||||
{
|
{
|
||||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
if (modelJob)
|
if (modelJob)
|
||||||
{
|
{
|
||||||
glm::mat4 modelMatrix = modelJob->ModelMatrix;
|
glm::mat4 modelMatrix = modelJob->ModelMatrix;
|
||||||
@@ -508,12 +515,14 @@ void Renderer::ForwardRendering(RenderQueue &rq)
|
|||||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_Camera->ViewMatrix()));
|
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_Camera->ViewMatrix()));
|
||||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "P"), 1, GL_FALSE, glm::value_ptr(cameraProjection));
|
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "P"), 1, GL_FALSE, glm::value_ptr(cameraProjection));
|
||||||
glUniform4fv(glGetUniformLocation(ShaderProgramHandle, "Color"), 1, glm::value_ptr(modelJob->Color));
|
glUniform4fv(glGetUniformLocation(ShaderProgramHandle, "Color"), 1, glm::value_ptr(modelJob->Color));
|
||||||
|
glUniform3fv(glGetUniformLocation(ShaderProgramHandle, "La"), 1, glm::value_ptr(glm::vec3(1.0f)));
|
||||||
|
glUniform3fv(glGetUniformLocation(ShaderProgramHandle, "directionToSun"), 1, glm::value_ptr(glm::normalize(m_SunPosition)));
|
||||||
|
|
||||||
glBindVertexArray(modelJob->VAO);
|
glBindVertexArray(modelJob->VAO);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture);
|
glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture);
|
||||||
/*if (modelJob->NormalTexture != 0)
|
if (modelJob->NormalTexture != 0)
|
||||||
{
|
{
|
||||||
glActiveTexture(GL_TEXTURE2);
|
glActiveTexture(GL_TEXTURE2);
|
||||||
glBindTexture(GL_TEXTURE_2D, modelJob->NormalTexture);
|
glBindTexture(GL_TEXTURE_2D, modelJob->NormalTexture);
|
||||||
@@ -522,7 +531,7 @@ void Renderer::ForwardRendering(RenderQueue &rq)
|
|||||||
{
|
{
|
||||||
glActiveTexture(GL_TEXTURE3);
|
glActiveTexture(GL_TEXTURE3);
|
||||||
glBindTexture(GL_TEXTURE_2D, modelJob->SpecularTexture);
|
glBindTexture(GL_TEXTURE_2D, modelJob->SpecularTexture);
|
||||||
}*/
|
}
|
||||||
glDrawArrays(GL_TRIANGLES, modelJob->StartIndex, modelJob->EndIndex - modelJob->StartIndex + 1);
|
glDrawArrays(GL_TRIANGLES, modelJob->StartIndex, modelJob->EndIndex - modelJob->StartIndex + 1);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@@ -532,8 +541,9 @@ void Renderer::ForwardRendering(RenderQueue &rq)
|
|||||||
if (spriteJob)
|
if (spriteJob)
|
||||||
{
|
{
|
||||||
glm::mat4 modelMatrix = spriteJob->ModelMatrix;
|
glm::mat4 modelMatrix = spriteJob->ModelMatrix;
|
||||||
MVP = cameraMatrix * modelMatrix;
|
glm::mat4 billboardingMatrix = glm::inverse(glm::toMat4(glm::inverse(m_Camera->Orientation())));
|
||||||
|
MVP = cameraMatrix * modelMatrix * billboardingMatrix;
|
||||||
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "MVP"), 1, GL_FALSE, glm::value_ptr(glm::mat4(MVP)));
|
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, "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, "V"), 1, GL_FALSE, glm::value_ptr(glm::mat4(m_Camera->ViewMatrix())));
|
||||||
@@ -549,14 +559,14 @@ void Renderer::ForwardRendering(RenderQueue &rq)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//glDepthMask (GL_TRUE);
|
//glDepthMask (GL_TRUE);
|
||||||
//glDisable (GL_BLEND);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Final pass
|
Final pass
|
||||||
*/
|
*/
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
glViewport(0, 0, m_Width, m_Height);
|
glViewport(0, 0, m_Width, m_Height);
|
||||||
glScissor(0, 0, m_Width, m_Height);
|
glScissor(m_Scissor.X, m_Height - m_Scissor.Y - m_Scissor.Height, m_Scissor.Width, m_Scissor.Height);
|
||||||
|
|
||||||
glDepthMask(GL_FALSE);
|
glDepthMask(GL_FALSE);
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
@@ -570,7 +580,9 @@ void Renderer::ForwardRendering(RenderQueue &rq)
|
|||||||
//glUniform1f(glGetUniformLocation(ShaderProgramHandle, "Gamma"), Gamma);
|
//glUniform1f(glGetUniformLocation(ShaderProgramHandle, "Gamma"), Gamma);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_fDiffuseTexture);
|
glBindTexture(GL_TEXTURE_2D, m_fFinalDiffuseTexture);
|
||||||
|
// glActiveTexture(GL_TEXTURE1);
|
||||||
|
// glBindTexture(GL_TEXTURE_2D, m_fLightingTexture);
|
||||||
|
|
||||||
glCullFace(GL_BACK);
|
glCullFace(GL_BACK);
|
||||||
glBindVertexArray(m_ScreenQuad);
|
glBindVertexArray(m_ScreenQuad);
|
||||||
@@ -609,6 +621,8 @@ void Renderer::Swap()
|
|||||||
|
|
||||||
void Renderer::DrawSkybox()
|
void Renderer::DrawSkybox()
|
||||||
{
|
{
|
||||||
|
// glEnable(GL_CULL_FACE);
|
||||||
|
// glCullFace(GL_BACK);
|
||||||
//glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
//glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
glViewport(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.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);
|
glScissor(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||||
@@ -619,8 +633,10 @@ void Renderer::DrawSkybox()
|
|||||||
//glm::mat4 cameraProjection = m_Camera->ProjectionMatrix((float)m_Viewport.Width / m_Viewport.Height);
|
//glm::mat4 cameraProjection = m_Camera->ProjectionMatrix((float)m_Viewport.Width / m_Viewport.Height);
|
||||||
//glm::mat4 cameraMatrix = cameraProjection * m_Camera->ViewMatrix();
|
//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()));
|
glm::mat4 cameraMatrix = m_Camera->ProjectionMatrix((float)m_Viewport.Width / m_Viewport.Height);
|
||||||
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgramSkybox.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(cameraMatrix));
|
glm::mat4 cameraView = glm::inverse(glm::toMat4(m_Camera->Orientation()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgramSkybox.GetHandle(), "V"), 1, GL_FALSE, glm::value_ptr(cameraView));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgramSkybox.GetHandle(), "P"), 1, GL_FALSE, glm::value_ptr(cameraMatrix));
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
m_Skybox->Draw();
|
m_Skybox->Draw();
|
||||||
}
|
}
|
||||||
@@ -946,7 +962,7 @@ void Renderer::FrameBufferTextures()
|
|||||||
//Generate and bind diffuse texture
|
//Generate and bind diffuse texture
|
||||||
glGenTextures(1, &m_fDiffuseTexture);
|
glGenTextures(1, &m_fDiffuseTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_fDiffuseTexture);
|
glBindTexture(GL_TEXTURE_2D, m_fDiffuseTexture);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 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_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
@@ -998,19 +1014,47 @@ void Renderer::FrameBufferTextures()
|
|||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_2D, m_fSpecularTexture, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_2D, m_fSpecularTexture, 0);
|
||||||
//glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_2D, m_fShadowTexture, 0);
|
//glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_2D, m_fShadowTexture, 0);
|
||||||
|
|
||||||
|
GLenum FirstPass[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 };
|
||||||
|
glDrawBuffers(4, FirstPass);
|
||||||
|
|
||||||
GLenum fbStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
GLenum fbStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||||
if(fbStatus != GL_FRAMEBUFFER_COMPLETE)
|
if(fbStatus != GL_FRAMEBUFFER_COMPLETE)
|
||||||
{
|
{
|
||||||
LOG_ERROR("DeferredLighting:Init: m_fbBasePass incomplete: 0x%x\n", fbStatus);
|
LOG_ERROR("DeferredLighting:Init: m_fbBasePass incomplete: 0x%x\n", fbStatus);
|
||||||
//exit(1);
|
//exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_fbFinalPass = 0;
|
||||||
|
glGenFramebuffers(1, &m_fbFinalPass);
|
||||||
|
glGenTextures(1, &m_fFinalDiffuseTexture);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_fFinalDiffuseTexture);
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, 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);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, m_fbFinalPass);
|
||||||
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_fFinalDiffuseTexture, 0);
|
||||||
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_fDepthBuffer);
|
||||||
|
|
||||||
|
GLenum FinalPassAttachments[] = { GL_COLOR_ATTACHMENT0 };
|
||||||
|
glDrawBuffers(1, FinalPassAttachments);
|
||||||
|
|
||||||
|
fbStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||||
|
if(fbStatus != GL_FRAMEBUFFER_COMPLETE)
|
||||||
|
{
|
||||||
|
LOG_ERROR("DeferredLighting:Init: m_fbLightingPass incomplete: 0x%x\n", fbStatus);
|
||||||
|
//exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
m_fbLightingPass = 0;
|
m_fbLightingPass = 0;
|
||||||
glGenFramebuffers(1, &m_fbLightingPass);
|
glGenFramebuffers(1, &m_fbLightingPass);
|
||||||
|
|
||||||
glGenTextures(1, &m_fLightingTexture);
|
glGenTextures(1, &m_fLightingTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_fLightingTexture);
|
glBindTexture(GL_TEXTURE_2D, m_fLightingTexture);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 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_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
@@ -1019,6 +1063,9 @@ void Renderer::FrameBufferTextures()
|
|||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_fbLightingPass);
|
glBindFramebuffer(GL_FRAMEBUFFER, m_fbLightingPass);
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_fLightingTexture, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_fLightingTexture, 0);
|
||||||
|
|
||||||
|
GLenum lightingPassAttachments[] = { GL_COLOR_ATTACHMENT0 };
|
||||||
|
glDrawBuffers(1, lightingPassAttachments);
|
||||||
|
|
||||||
fbStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
fbStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||||
if(fbStatus != GL_FRAMEBUFFER_COMPLETE)
|
if(fbStatus != GL_FRAMEBUFFER_COMPLETE)
|
||||||
{
|
{
|
||||||
@@ -1267,12 +1314,7 @@ void Renderer::DrawFBOScene(RenderQueue &rq)
|
|||||||
|
|
||||||
void Renderer::DrawLightScene(RenderQueue &rq)
|
void Renderer::DrawLightScene(RenderQueue &rq)
|
||||||
{
|
{
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glBlendEquation (GL_FUNC_ADD);
|
|
||||||
glBlendFunc(GL_ONE,GL_ONE);
|
|
||||||
|
|
||||||
glDisable (GL_DEPTH_TEST);
|
|
||||||
glDepthMask (GL_FALSE);
|
|
||||||
glBindVertexArray(m_sphereModel->VAO);
|
glBindVertexArray(m_sphereModel->VAO);
|
||||||
|
|
||||||
glm::mat4 cameraProjection = m_Camera->ProjectionMatrix((float)m_Viewport.Width / m_Viewport.Height);
|
glm::mat4 cameraProjection = m_Camera->ProjectionMatrix((float)m_Viewport.Width / m_Viewport.Height);
|
||||||
@@ -1283,6 +1325,13 @@ void Renderer::DrawLightScene(RenderQueue &rq)
|
|||||||
m_SecondPassProgram.Bind();
|
m_SecondPassProgram.Bind();
|
||||||
GLuint ShaderProgramHandle = m_SecondPassProgram.GetHandle();
|
GLuint ShaderProgramHandle = m_SecondPassProgram.GetHandle();
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_fPositionTexture);
|
||||||
|
glActiveTexture(GL_TEXTURE1);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_fNormalsTexture);
|
||||||
|
glActiveTexture(GL_TEXTURE2);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_fSpecularTexture);
|
||||||
|
|
||||||
for (auto &light : Lights)
|
for (auto &light : Lights)
|
||||||
{
|
{
|
||||||
MVP = cameraMatrix * light.SphereModelMatrix;
|
MVP = cameraMatrix * light.SphereModelMatrix;
|
||||||
@@ -1305,21 +1354,10 @@ void Renderer::DrawLightScene(RenderQueue &rq)
|
|||||||
|
|
||||||
glDrawArrays(GL_TRIANGLES, 0, m_sphereModel->Vertices.size());
|
glDrawArrays(GL_TRIANGLES, 0, m_sphereModel->Vertices.size());
|
||||||
};
|
};
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
glDepthMask(GL_TRUE);
|
|
||||||
glDisable(GL_BLEND);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::DrawSunLightScene()
|
void Renderer::DrawSunLightScene()
|
||||||
{
|
{
|
||||||
glCullFace(GL_BACK);
|
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glBlendEquation(GL_FUNC_ADD);
|
|
||||||
glBlendFunc(GL_ONE,GL_ONE);
|
|
||||||
|
|
||||||
glDisable (GL_DEPTH_TEST);
|
|
||||||
glDepthMask (GL_FALSE);
|
|
||||||
//glBindVertexArray(m_sphereModel->VAO);
|
//glBindVertexArray(m_sphereModel->VAO);
|
||||||
|
|
||||||
glm::mat4 cameraProjection = m_Camera->ProjectionMatrix((float)m_Viewport.Width / m_Viewport.Height);
|
glm::mat4 cameraProjection = m_Camera->ProjectionMatrix((float)m_Viewport.Width / m_Viewport.Height);
|
||||||
@@ -1328,7 +1366,13 @@ void Renderer::DrawSunLightScene()
|
|||||||
|
|
||||||
m_SunPassProgram.Bind();
|
m_SunPassProgram.Bind();
|
||||||
GLuint ShaderProgramHandle = m_SunPassProgram.GetHandle();
|
GLuint ShaderProgramHandle = m_SunPassProgram.GetHandle();
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_fPositionTexture);
|
||||||
|
glActiveTexture(GL_TEXTURE1);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_fNormalsTexture);
|
||||||
|
glActiveTexture(GL_TEXTURE2);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_fSpecularTexture);
|
||||||
|
|
||||||
glUniform2fv(glGetUniformLocation(ShaderProgramHandle, "ViewportSize"), 1, glm::value_ptr(glm::vec2(m_Width, m_Height)));
|
glUniform2fv(glGetUniformLocation(ShaderProgramHandle, "ViewportSize"), 1, glm::value_ptr(glm::vec2(m_Width, m_Height)));
|
||||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
|
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
|
||||||
@@ -1340,10 +1384,6 @@ void Renderer::DrawSunLightScene()
|
|||||||
glBindVertexArray(m_ScreenQuad);
|
glBindVertexArray(m_ScreenQuad);
|
||||||
glEnableVertexAttribArray(0);
|
glEnableVertexAttribArray(0);
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||||
|
|
||||||
glEnable (GL_DEPTH_TEST);
|
|
||||||
glDepthMask (GL_TRUE);
|
|
||||||
glDisable (GL_BLEND);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::SetSphereModel( Model* _model )
|
void Renderer::SetSphereModel( Model* _model )
|
||||||
|
|||||||
@@ -167,6 +167,10 @@ private:
|
|||||||
GLuint m_ShadowFrameBuffer;
|
GLuint m_ShadowFrameBuffer;
|
||||||
GLuint m_ShadowDepthTexture;
|
GLuint m_ShadowDepthTexture;
|
||||||
|
|
||||||
|
|
||||||
|
GLuint m_fbFinalPass;
|
||||||
|
GLuint m_fFinalDiffuseTexture;
|
||||||
|
|
||||||
GLuint m_fbBasePass;
|
GLuint m_fbBasePass;
|
||||||
GLuint m_fDiffuseTexture;
|
GLuint m_fDiffuseTexture;
|
||||||
GLuint m_fPositionTexture;
|
GLuint m_fPositionTexture;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
//uniform vec3 La;
|
|
||||||
|
|
||||||
layout (binding=0) uniform sampler2D DiffuseTexture;
|
layout (binding=0) uniform sampler2D DiffuseTexture;
|
||||||
|
|
||||||
@@ -15,11 +14,11 @@ out vec4 FragmentColor;
|
|||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 DiffuseTexel = texture(DiffuseTexture, Input.TextureCoord);
|
vec4 DiffuseTexel = texture(DiffuseTexture, Input.TextureCoord);
|
||||||
//vec4 LightingTexel = texture(LightingTexture, Input.TextureCoord);
|
|
||||||
|
|
||||||
//FragmentColor = LightingTexel + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0);
|
//FragmentColor = LightingTexel + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0);
|
||||||
//FragmentColor = DiffuseTexel;
|
//FragmentColor = DiffuseTexel;
|
||||||
|
|
||||||
FragmentColor = DiffuseTexel;
|
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);
|
//FragmentColor = vec4(pow(_FragmentColor.rgb, vec3(1.0 / Gamma)), _FragmentColor.a);
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
//Dicksdickdickdickssssss
|
||||||
|
|
||||||
uniform vec3 La;
|
uniform vec3 La;
|
||||||
uniform float Gamma;
|
|
||||||
|
|
||||||
layout (binding=0) uniform sampler2D DiffuseTexture;
|
layout (binding=0) uniform sampler2D DiffuseTexture;
|
||||||
layout (binding=1) uniform sampler2D LightingTexture;
|
layout (binding=1) uniform sampler2D LightingTexture;
|
||||||
@@ -12,7 +12,7 @@ in VertexData
|
|||||||
vec2 TextureCoord;
|
vec2 TextureCoord;
|
||||||
} Input;
|
} Input;
|
||||||
|
|
||||||
out vec4 FragmentColor;
|
out vec4 frag_Diffuse;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
@@ -21,7 +21,12 @@ void main()
|
|||||||
|
|
||||||
//FragmentColor = LightingTexel + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0);
|
//FragmentColor = LightingTexel + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0);
|
||||||
//FragmentColor = DiffuseTexel;
|
//FragmentColor = DiffuseTexel;
|
||||||
|
//FragmentColor = DiffuseTexel;
|
||||||
|
//frag_Diffuse = vec4(LightingTexel.rgb, 0.0);
|
||||||
|
|
||||||
|
//frag_Diffuse = DiffuseTexel * ((vec4(LightingTexel.rgb, 0.0) + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0)));
|
||||||
|
frag_Diffuse = DiffuseTexel * (vec4(La, 0.0) * (vec4(LightingTexel.rgb, 0.0) + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0)));
|
||||||
|
//frag_Diffuse = LightingTexel;
|
||||||
|
|
||||||
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);
|
//FragmentColor = vec4(pow(_FragmentColor.rgb, vec3(1.0 / Gamma)), _FragmentColor.a);
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,23 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
uniform vec4 Color;
|
uniform vec4 Color;
|
||||||
|
uniform vec3 La;
|
||||||
|
uniform vec3 directionToSun;
|
||||||
|
uniform mat4 V;
|
||||||
|
|
||||||
layout(binding=0) uniform sampler2D texture0;
|
layout(binding=0) uniform sampler2D texture0;
|
||||||
|
layout(binding=1) uniform sampler2D PositionTexture;
|
||||||
|
layout(binding=2) uniform sampler2D NormalsTexture;
|
||||||
|
layout(binding=3) uniform sampler2D SpecularTexture;
|
||||||
|
|
||||||
|
const vec3 ks = vec3(1.0, 1.0, 1.0);
|
||||||
|
const vec3 kd = vec3(1.0, 1.0, 1.0);
|
||||||
|
const vec3 ka = vec3(1.0, 1.0, 1.0);
|
||||||
|
const float kshine = 1.0;
|
||||||
|
const vec3 SunDiffuseLight = vec3(1.0, 1.0, 1.0);
|
||||||
|
const vec3 SunSpecularLight = vec3(1.0, 1.0, 1.0);
|
||||||
|
const vec3 SunPos = directionToSun*vec3(100);
|
||||||
|
const float specularExponent = 100;
|
||||||
|
|
||||||
in VertexData {
|
in VertexData {
|
||||||
vec3 Position;
|
vec3 Position;
|
||||||
@@ -12,9 +27,34 @@ in VertexData {
|
|||||||
|
|
||||||
out vec4 frag_Diffuse;
|
out vec4 frag_Diffuse;
|
||||||
|
|
||||||
|
vec4 phong(vec3 position, vec3 normal, vec3 specular)
|
||||||
|
{
|
||||||
|
|
||||||
|
//Diffuse Sunlight
|
||||||
|
vec3 directionToLight = normalize(vec3(V * vec4(directionToSun, 0.0)));
|
||||||
|
float dotProdLight = dot(directionToLight, normal);
|
||||||
|
dotProdLight = max(dotProdLight, 0.0);
|
||||||
|
vec3 sId = kd * SunDiffuseLight * dotProdLight;
|
||||||
|
|
||||||
|
//Specular Sunlight
|
||||||
|
vec3 surfaceToViewer = normalize(-position);
|
||||||
|
vec3 halfWay = normalize(surfaceToViewer + directionToLight);
|
||||||
|
float dotSpecular = max(dot(halfWay, normal), 0.0);
|
||||||
|
float specularFactorSun = pow(dotSpecular, specularExponent);
|
||||||
|
vec3 sIs = specular.r * SunSpecularLight * specularFactorSun;
|
||||||
|
|
||||||
|
return vec4((sId), sIs.r);
|
||||||
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
// Texture
|
|
||||||
vec4 texel = texture(texture0, Input.TextureCoord);
|
vec4 texel = texture(texture0, Input.TextureCoord);
|
||||||
|
vec4 PositionTexel = texture(PositionTexture, Input.TextureCoord);
|
||||||
|
vec4 NormalTexel = texture(NormalsTexture, Input.TextureCoord);
|
||||||
|
vec4 SpecularTexel = texture(SpecularTexture, Input.TextureCoord);
|
||||||
|
|
||||||
|
|
||||||
frag_Diffuse = texel * Color;
|
frag_Diffuse = texel * Color;
|
||||||
|
//frag_Diffuse = texel * Color * (vec4(La, 0.0) * phong(vec3(PositionTexel), vec3(NormalTexel), vec3(SpecularTexel)));
|
||||||
|
//frag_Diffuse = DiffuseTexel * (vec4(La, 0.0) * (vec4(LightingTexel.rgb, 0.0) + vec4(LightingTexel.a, LightingTexel.a, LightingTexel.a, 0.0)));
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,7 @@ const vec3 ks = vec3(1.0, 1.0, 1.0);
|
|||||||
const vec3 kd = vec3(1.0, 1.0, 1.0);
|
const vec3 kd = vec3(1.0, 1.0, 1.0);
|
||||||
const vec3 ka = vec3(1.0, 1.0, 1.0);
|
const vec3 ka = vec3(1.0, 1.0, 1.0);
|
||||||
const float kshine = 1.0;
|
const float kshine = 1.0;
|
||||||
|
const vec3 La = vec3(0.3, 0.3, 0.3);
|
||||||
|
|
||||||
|
|
||||||
in VertexData
|
in VertexData
|
||||||
@@ -32,7 +33,7 @@ in VertexData
|
|||||||
vec2 TextureCoord;
|
vec2 TextureCoord;
|
||||||
} Input;
|
} Input;
|
||||||
|
|
||||||
out vec4 FragColor;
|
out vec4 frag_Light;
|
||||||
|
|
||||||
vec4 phong(vec3 position, vec3 normal, vec3 specular)
|
vec4 phong(vec3 position, vec3 normal, vec3 specular)
|
||||||
{
|
{
|
||||||
@@ -67,6 +68,8 @@ void main()
|
|||||||
vec4 NormalTexel = texture(NormalsTexture, TextureCoord);
|
vec4 NormalTexel = texture(NormalsTexture, TextureCoord);
|
||||||
vec4 SpecularTexel = texture(SpecularTexture, TextureCoord);
|
vec4 SpecularTexel = texture(SpecularTexture, TextureCoord);
|
||||||
|
|
||||||
FragColor = phong(vec3(PositionTexel), vec3(NormalTexel), vec3(SpecularTexel));
|
frag_Light = phong(vec3(PositionTexel), vec3(NormalTexel), vec3(SpecularTexel));
|
||||||
|
//FragColor = DiffuseTexel * vec4(1.0/La, 0.0) * (vec4(La, 0.0) + vec4(LightTexel.rgb, 0.0) + vec4(LightTexel.a, LightTexel.a, LightTexel.a, 0.0));
|
||||||
|
//FragColor = DiffuseTexel * (vec4(La, 0.0) + vec4(LightTexel.rgb, 0.0)) + vec4(LightTexel.a, LightTexel.a, LightTexel.a, 0.0);
|
||||||
//FragColor = NormalTexel;
|
//FragColor = NormalTexel;
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
uniform mat4 MVP;
|
uniform mat4 V;
|
||||||
|
uniform mat4 P;
|
||||||
|
|
||||||
layout(location = 0) in vec3 Position;
|
layout(location = 0) in vec3 Position;
|
||||||
|
|
||||||
@@ -11,6 +12,7 @@ out VertexData
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = MVP * vec4(Position, 1.0);
|
vec4 pos = V * vec4(Position, 1.0);
|
||||||
|
gl_Position = P * pos;
|
||||||
Output.TextureCoord = Position;
|
Output.TextureCoord = Position;
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ layout (binding=0) uniform sampler2D PositionTexture;
|
|||||||
layout (binding=1) uniform sampler2D NormalsTexture;
|
layout (binding=1) uniform sampler2D NormalsTexture;
|
||||||
layout (binding=2) uniform sampler2D SpecularTexture;
|
layout (binding=2) uniform sampler2D SpecularTexture;
|
||||||
|
|
||||||
|
|
||||||
uniform vec2 ViewportSize;
|
uniform vec2 ViewportSize;
|
||||||
uniform mat4 MVP;
|
uniform mat4 MVP;
|
||||||
uniform mat4 M;
|
uniform mat4 M;
|
||||||
@@ -16,10 +17,12 @@ const vec3 ks = vec3(1.0, 1.0, 1.0);
|
|||||||
const vec3 kd = vec3(1.0, 1.0, 1.0);
|
const vec3 kd = vec3(1.0, 1.0, 1.0);
|
||||||
const vec3 ka = vec3(1.0, 1.0, 1.0);
|
const vec3 ka = vec3(1.0, 1.0, 1.0);
|
||||||
const float kshine = 1.0;
|
const float kshine = 1.0;
|
||||||
const vec3 SunDiffuseLight = vec3(0.3, 0.3, 0.3);
|
const vec3 SunDiffuseLight = vec3(1.0, 1.0, 1.0);
|
||||||
const vec3 SunSpecularLight = vec3(1.0, 1.0, 1.0);
|
const vec3 SunSpecularLight = vec3(1.0, 1.0, 1.0);
|
||||||
const vec3 SunPos = directionToSun*vec3(100);
|
const vec3 SunPos = directionToSun*vec3(100);
|
||||||
const float specularExponent = 5;
|
const float specularExponent = 100;
|
||||||
|
const vec3 La = vec3(0.3, 0.3, 0.3);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
in VertexData
|
in VertexData
|
||||||
@@ -28,7 +31,7 @@ in VertexData
|
|||||||
vec2 TextureCoord;
|
vec2 TextureCoord;
|
||||||
} Input;
|
} Input;
|
||||||
|
|
||||||
out vec4 FragColor;
|
out vec4 frag_Light;
|
||||||
|
|
||||||
vec4 phong(vec3 position, vec3 normal, vec3 specular)
|
vec4 phong(vec3 position, vec3 normal, vec3 specular)
|
||||||
{
|
{
|
||||||
@@ -46,7 +49,7 @@ vec4 phong(vec3 position, vec3 normal, vec3 specular)
|
|||||||
float specularFactorSun = pow(dotSpecular, specularExponent);
|
float specularFactorSun = pow(dotSpecular, specularExponent);
|
||||||
vec3 sIs = specular.r * SunSpecularLight * specularFactorSun;
|
vec3 sIs = specular.r * SunSpecularLight * specularFactorSun;
|
||||||
|
|
||||||
return vec4((sId), sIs.r);
|
return vec4((sId + La), sIs.r);
|
||||||
}
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
@@ -56,6 +59,8 @@ void main()
|
|||||||
vec4 NormalTexel = texture(NormalsTexture, TextureCoord);
|
vec4 NormalTexel = texture(NormalsTexture, TextureCoord);
|
||||||
vec4 SpecularTexel = texture(SpecularTexture, TextureCoord);
|
vec4 SpecularTexel = texture(SpecularTexture, TextureCoord);
|
||||||
|
|
||||||
FragColor = phong(vec3(PositionTexel), vec3(normalize(NormalTexel)), vec3(SpecularTexel));
|
|
||||||
|
frag_Light = phong(vec3(PositionTexel), vec3(NormalTexel), vec3(SpecularTexel));
|
||||||
|
//FragColor = DiffuseTexel * (vec4(La, 0.0) * (vec4(LightTexel.rgb, 0.0) + vec4(LightTexel.a, LightTexel.a, LightTexel.a, 0.0)));
|
||||||
//FragColor = NormalTexel;
|
//FragColor = NormalTexel;
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
void Systems::DamageSystem::RegisterComponents( ComponentFactory* cf )
|
void Systems::DamageSystem::RegisterComponents( ComponentFactory* cf )
|
||||||
{
|
{
|
||||||
cf->Register<Components::Health>([]() { return new Components::Health(); });
|
cf->Register<Components::Health>([]() { return new Components::Health(); });
|
||||||
|
cf->Register<Components::DamageModel>([]() { return new Components::DamageModel(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Systems::DamageSystem::Initialize()
|
void Systems::DamageSystem::Initialize()
|
||||||
@@ -18,12 +19,12 @@ bool Systems::DamageSystem::OnDamage( const Events::Damage &event )
|
|||||||
return false;
|
return false;
|
||||||
auto health = m_World->GetComponent<Components::Health>(event.Entity);
|
auto health = m_World->GetComponent<Components::Health>(event.Entity);
|
||||||
health->Amount -= event.Amount;
|
health->Amount -= event.Amount;
|
||||||
if(health->Amount <= 0)
|
//if(health->Amount <= 0)
|
||||||
{
|
//{
|
||||||
Events::OnDead e;
|
// Events::OnDead e;
|
||||||
e.Entity = event.Entity;
|
// e.Entity = event.Entity;
|
||||||
EventBroker->Publish(e);
|
// EventBroker->Publish(e);
|
||||||
}
|
//}
|
||||||
LOG_INFO("Damaged entity %i, Health left: %f", event.Entity, health->Amount);
|
LOG_INFO("Damaged entity %i, Health left: %f", event.Entity, health->Amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "System.h"
|
#include "System.h"
|
||||||
#include "Components/Health.h"
|
#include "Components/Health.h"
|
||||||
|
#include "Components/DamageModel.h"
|
||||||
#include "Events/Damage.h"
|
#include "Events/Damage.h"
|
||||||
#include "Events/OnDead.h"
|
#include "Events/OnDead.h"
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ bool Systems::DebugSystem::OnKeyDown(const Events::KeyDown &event)
|
|||||||
if (event.KeyCode == GLFW_KEY_ENTER)
|
if (event.KeyCode == GLFW_KEY_ENTER)
|
||||||
{
|
{
|
||||||
Events::PlaySFX e;
|
Events::PlaySFX e;
|
||||||
e.Emitter = 0;
|
e.Position = glm::vec3(0);
|
||||||
e.Resource = "Sounds/korvring.wav";
|
e.Resource = "Sounds/korvring.wav";
|
||||||
EventBroker->Publish<Events::PlaySFX>(e);
|
EventBroker->Publish<Events::PlaySFX>(e);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#include "PrecompiledHeader.h"
|
||||||
|
#include "GameStateSystem.h"
|
||||||
|
#include "World.h"
|
||||||
|
|
||||||
|
void Systems::GameStateSystem::Initialize()
|
||||||
|
{
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EFlagCaptured, &Systems::GameStateSystem::OnFlagCaptured);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Systems::GameStateSystem::OnFlagCaptured(const Events::FlagCaptured &event)
|
||||||
|
{
|
||||||
|
m_InGame = false;
|
||||||
|
|
||||||
|
Events::GameOver e;
|
||||||
|
e.Winner = event.Player;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#ifndef GameStateSystem_h__
|
||||||
|
#define GameStateSystem_h__
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
|
#include "System.h"
|
||||||
|
#include "Components/Transform.h"
|
||||||
|
#include "Components/Player.h"
|
||||||
|
#include "Events/FlagCaptured.h"
|
||||||
|
#include "Events/GameOver.h"
|
||||||
|
|
||||||
|
namespace Systems
|
||||||
|
{
|
||||||
|
|
||||||
|
class GameStateSystem : public System
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
GameStateSystem(World* world, std::shared_ptr<::EventBroker> eventBroker, std::shared_ptr<::ResourceManager> resourceManager)
|
||||||
|
: System(world, eventBroker, resourceManager)
|
||||||
|
, m_InGame(true)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
void Initialize() override;
|
||||||
|
|
||||||
|
bool InGame() const { return m_InGame; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_InGame;
|
||||||
|
|
||||||
|
EventRelay<GameStateSystem, Events::FlagCaptured> m_EFlagCaptured;
|
||||||
|
bool OnFlagCaptured(const Events::FlagCaptured &event);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // GameStateSystem_h__
|
||||||
@@ -34,6 +34,14 @@ bool Systems::GarageSystem::OnEnterTrigger(const Events::EnterTrigger &event)
|
|||||||
if (!garageComponent)
|
if (!garageComponent)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
auto teamComponent = m_World->GetComponent<Components::Team>(event.Trigger);
|
||||||
|
auto playerComponent = m_World->GetComponent<Components::Player>(event.Entity);
|
||||||
|
|
||||||
|
if(!teamComponent || !playerComponent)
|
||||||
|
return false;
|
||||||
|
if (teamComponent->TeamID != playerComponent->ID)
|
||||||
|
return false;
|
||||||
|
|
||||||
std::string name = m_World->GetProperty<std::string>(event.Trigger, "Name");
|
std::string name = m_World->GetProperty<std::string>(event.Trigger, "Name");
|
||||||
|
|
||||||
if (name == "BoundsTrigger")
|
if (name == "BoundsTrigger")
|
||||||
@@ -56,6 +64,15 @@ bool Systems::GarageSystem::OnLeaveTrigger(const Events::LeaveTrigger &event)
|
|||||||
if (!garageComponent)
|
if (!garageComponent)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
auto teamComponent = m_World->GetComponent<Components::Team>(event.Trigger);
|
||||||
|
auto playerComponent = m_World->GetComponent<Components::Player>(event.Entity);
|
||||||
|
|
||||||
|
if(!teamComponent || !playerComponent)
|
||||||
|
return false;
|
||||||
|
if (teamComponent->TeamID != playerComponent->ID)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
|
||||||
std::string name = m_World->GetProperty<std::string>(event.Trigger, "Name");
|
std::string name = m_World->GetProperty<std::string>(event.Trigger, "Name");
|
||||||
|
|
||||||
if (name == "BoundsTrigger")
|
if (name == "BoundsTrigger")
|
||||||
@@ -76,18 +93,24 @@ bool Systems::GarageSystem::OnCommand(const Events::InputCommand &event)
|
|||||||
{
|
{
|
||||||
EntityID trigger = pair.first;
|
EntityID trigger = pair.first;
|
||||||
auto entities = pair.second;
|
auto entities = pair.second;
|
||||||
|
|
||||||
std::string name = m_World->GetProperty<std::string>(trigger, "Name");
|
std::string name = m_World->GetProperty<std::string>(trigger, "Name");
|
||||||
if (name != "ElevatorShaftTrigger")
|
if (name != "ElevatorShaftTrigger")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto triggerBaseParent = m_World->GetEntityBaseParent(trigger);
|
auto triggerTeamComponent = m_World->GetComponent<Components::Team>(trigger);
|
||||||
auto triggerPlayerComponent = m_World->GetComponent<Components::Player>(triggerBaseParent);
|
if (!triggerTeamComponent)
|
||||||
|
continue;
|
||||||
|
|
||||||
for (EntityID entity : entities)
|
for (EntityID entity : entities)
|
||||||
{
|
{
|
||||||
auto entityPlayerComponent = m_World->GetComponent<Components::Player>(triggerBaseParent);
|
auto entityPlayerComponent = m_World->GetComponent<Components::Player>(entity);
|
||||||
if (triggerPlayerComponent == entityPlayerComponent)
|
if(!entityPlayerComponent)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (entityPlayerComponent->ID != event.PlayerID)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (triggerTeamComponent->TeamID == entityPlayerComponent->ID)
|
||||||
{
|
{
|
||||||
EntityID garage = m_World->GetEntityParent(trigger);
|
EntityID garage = m_World->GetEntityParent(trigger);
|
||||||
auto garageComponent = m_World->GetComponent<Components::Garage>(garage);
|
auto garageComponent = m_World->GetComponent<Components::Garage>(garage);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "Events/Rotate.h"
|
#include "Events/Rotate.h"
|
||||||
#include "Components/Move.h"
|
#include "Components/Move.h"
|
||||||
#include "Components/Rotate.h"
|
#include "Components/Rotate.h"
|
||||||
|
#include "Components/Team.h"
|
||||||
|
|
||||||
namespace Systems
|
namespace Systems
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,356 @@
|
|||||||
|
#include "PrecompiledHeader.h"
|
||||||
|
#include "JeepSteeringSystem.h"
|
||||||
|
#include "World.h"
|
||||||
|
|
||||||
|
void Systems::JeepSteeringSystem::RegisterComponents(ComponentFactory* cf)
|
||||||
|
{
|
||||||
|
cf->Register<Components::JeepSteering>([]() { return new Components::JeepSteering(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
void Systems::JeepSteeringSystem::Initialize()
|
||||||
|
{
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_ESpawnVehicle, &Systems::JeepSteeringSystem::OnSpawnVehicle);
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
m_JeepInputControllers[i] = std::shared_ptr<JeepSteeringInputController>(new JeepSteeringInputController(EventBroker, i + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Systems::JeepSteeringSystem::Update(double dt)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
m_JeepInputControllers[i]->Update(dt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Systems::JeepSteeringSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||||
|
{
|
||||||
|
auto tankSteeringComponent = m_World->GetComponent<Components::JeepSteering>(entity);
|
||||||
|
if(!tankSteeringComponent)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto playerComponent = m_World->GetComponent<Components::Player>(entity);
|
||||||
|
if (!playerComponent)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (playerComponent->ID == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto inputController = m_JeepInputControllers[playerComponent->ID - 1];
|
||||||
|
|
||||||
|
|
||||||
|
Events::JeepSteer eSteering;
|
||||||
|
eSteering.Entity = entity;
|
||||||
|
eSteering.PositionX = inputController->PositionX;
|
||||||
|
eSteering.PositionY = inputController->PositionY;
|
||||||
|
eSteering.Handbrake = inputController->Handbrake;
|
||||||
|
EventBroker->Publish(eSteering);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Systems::JeepSteeringSystem::OnSpawnVehicle(const Events::SpawnVehicle &event)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (event.VehicleType != "Jeep")
|
||||||
|
return false;
|
||||||
|
|
||||||
|
auto spawnPointComponents = m_World->GetComponentsOfType<Components::SpawnPoint>();
|
||||||
|
if (!spawnPointComponents)
|
||||||
|
{
|
||||||
|
LOG_ERROR("Found no spawn points!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto &component : *spawnPointComponents)
|
||||||
|
{
|
||||||
|
auto spawnPoint = component->Entity;
|
||||||
|
auto spawnPointComponent = std::dynamic_pointer_cast<Components::SpawnPoint>(component);
|
||||||
|
auto teamComponent = m_World->GetComponent<Components::Team>(spawnPoint);
|
||||||
|
|
||||||
|
if(!teamComponent)
|
||||||
|
{
|
||||||
|
LOG_ERROR("SpawnPoint has no TeamComponent");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (teamComponent->TeamID != event.PlayerID)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
|
||||||
|
Components::Transform absoluteTransform = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(spawnPoint);
|
||||||
|
|
||||||
|
// Create a Jeep
|
||||||
|
EntityID Jeep = CreateJeep(event.PlayerID);
|
||||||
|
auto tankTransform = m_World->GetComponent<Components::Transform>(Jeep);
|
||||||
|
tankTransform->Position = absoluteTransform.Position;
|
||||||
|
tankTransform->Orientation = absoluteTransform.Orientation;
|
||||||
|
// Set the viewport correctly
|
||||||
|
Events::SetViewportCamera e;
|
||||||
|
e.CameraEntity = m_World->GetProperty<EntityID>(Jeep, "Camera");
|
||||||
|
if (event.PlayerID == 1)
|
||||||
|
e.ViewportFrame = "Viewport1";
|
||||||
|
else if (event.PlayerID == 2)
|
||||||
|
e.ViewportFrame = "Viewport2";
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityID Systems::JeepSteeringSystem::CreateJeep(int playerID)
|
||||||
|
{
|
||||||
|
auto jeep = m_World->CreateEntity();
|
||||||
|
auto transform = m_World->AddComponent<Components::Transform>(jeep);
|
||||||
|
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>(jeep);
|
||||||
|
physics->Mass = 2000;
|
||||||
|
physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic;
|
||||||
|
physics->CenterOfMass = glm::vec3(0, 0, 0);
|
||||||
|
auto vehicle = m_World->AddComponent<Components::Vehicle>(jeep);
|
||||||
|
vehicle->MaxTorque = 500.0f;
|
||||||
|
vehicle->MaxSteeringAngle = 40.f;
|
||||||
|
vehicle->MaxSpeedFullSteeringAngle = 12.f;
|
||||||
|
vehicle->MinRPM = 1000.0f;
|
||||||
|
vehicle->OptimalRPM = 5500.0f,
|
||||||
|
vehicle->MaxRPM = 7500.0f;
|
||||||
|
vehicle->TopSpeed = 90.0f;
|
||||||
|
vehicle->SpringDamping = 5.f;
|
||||||
|
vehicle->UpshiftRPM = 6500.0f;
|
||||||
|
vehicle->DownshiftRPM = 3500.0f;
|
||||||
|
vehicle->gearsRatio0 = 3.0f;
|
||||||
|
vehicle->gearsRatio1 = 2.25f;
|
||||||
|
vehicle->gearsRatio2 = 1.5f;
|
||||||
|
vehicle->gearsRatio3 = 1.0f;
|
||||||
|
|
||||||
|
auto player = m_World->AddComponent<Components::Player>(jeep);
|
||||||
|
player->ID = playerID;
|
||||||
|
auto jeepSteering = m_World->AddComponent<Components::JeepSteering>(jeep);
|
||||||
|
m_World->AddComponent<Components::Input>(jeep);
|
||||||
|
auto health = m_World->AddComponent<Components::Health>(jeep);
|
||||||
|
health->Amount = 100.f;
|
||||||
|
|
||||||
|
/*{
|
||||||
|
auto shape = m_World->CreateEntity(jeep);
|
||||||
|
auto transform = m_World->AddComponent<Components::Transform>(shape);
|
||||||
|
auto meshShape = m_World->AddComponent<Components::MeshShape>(shape);
|
||||||
|
meshShape->ResourceName = "Models/Jeep/Chassi/ChassiCollision.obj";
|
||||||
|
m_World->CommitEntity(shape);
|
||||||
|
}*/
|
||||||
|
{
|
||||||
|
auto chassis = m_World->CreateEntity(jeep);
|
||||||
|
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/Jeep/Chassi/Chassi.OBJ";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
auto shape = m_World->CreateEntity(jeep);
|
||||||
|
auto transform = m_World->AddComponent<Components::Transform>(shape);
|
||||||
|
transform->Position = glm::vec3(-0.0219f ,0.88937f, -0.48469f);
|
||||||
|
auto box = m_World->AddComponent<Components::BoxShape>(shape);
|
||||||
|
box->Width = 0.993f;
|
||||||
|
box->Height = 0.626f;
|
||||||
|
box->Depth = 1.316f;
|
||||||
|
m_World->CommitEntity(shape);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
auto shape = m_World->CreateEntity(jeep);
|
||||||
|
auto transform = m_World->AddComponent<Components::Transform>(shape);
|
||||||
|
transform->Position = glm::vec3(-0.02551f ,0.55419f, 1.78935f);
|
||||||
|
auto box = m_World->AddComponent<Components::BoxShape>(shape);
|
||||||
|
box->Width = 0.849f;
|
||||||
|
box->Height = 0.415f;
|
||||||
|
box->Depth = 1.058f;
|
||||||
|
m_World->CommitEntity(shape);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
auto shape = m_World->CreateEntity(jeep);
|
||||||
|
auto transform = m_World->AddComponent<Components::Transform>(shape);
|
||||||
|
transform->Position = glm::vec3(-1.63274f ,0.98825f, -0.89907f);
|
||||||
|
auto box = m_World->AddComponent<Components::BoxShape>(shape);
|
||||||
|
box->Width = 0.697f;
|
||||||
|
box->Height = 0.401f;
|
||||||
|
box->Depth = 0.868f;
|
||||||
|
m_World->CommitEntity(shape);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
auto shape = m_World->CreateEntity(jeep);
|
||||||
|
auto transform = m_World->AddComponent<Components::Transform>(shape);
|
||||||
|
transform->Position = glm::vec3(1.63274f ,0.98825f, -0.89907f);
|
||||||
|
auto box = m_World->AddComponent<Components::BoxShape>(shape);
|
||||||
|
box->Width = 0.697f;
|
||||||
|
box->Height = 0.401f;
|
||||||
|
box->Depth = 0.868f;
|
||||||
|
m_World->CommitEntity(shape);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto cameraTower = m_World->CreateEntity(jeep);
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
m_World->SetProperty(jeep, "Camera", cameraTower);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma region Wheels
|
||||||
|
//Create wheels
|
||||||
|
float wheelOffset = 0.f;//-0.83f;
|
||||||
|
const float suspensionStrength = 15.f;
|
||||||
|
const float springLength = 0.3f;
|
||||||
|
|
||||||
|
AddJeepWheels(jeep);
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
{
|
||||||
|
auto entity = m_World->CreateEntity(jeep);
|
||||||
|
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(jeep);
|
||||||
|
|
||||||
|
return jeep;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Systems::JeepSteeringSystem::AddJeepWheels(EntityID jeepEntity)
|
||||||
|
{
|
||||||
|
//Create wheels
|
||||||
|
float wheelOffset = 0.5f;
|
||||||
|
float springLength = 0.2f;
|
||||||
|
float suspensionStrength = 35.f;
|
||||||
|
{
|
||||||
|
auto wheel = m_World->CreateEntity(jeepEntity);
|
||||||
|
auto transform = m_World->AddComponent<Components::Transform>(wheel);
|
||||||
|
transform->Position = glm::vec3(1.9f, 0.5546f - wheelOffset, -0.9242f);
|
||||||
|
transform->Scale = glm::vec3(1.0f);
|
||||||
|
auto model = m_World->AddComponent<Components::Model>(wheel);
|
||||||
|
model->ModelFile = "Models/Jeep/WheelFront/wheelFront.obj";
|
||||||
|
auto Wheel = m_World->AddComponent<Components::Wheel>(wheel);
|
||||||
|
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f);
|
||||||
|
Wheel->AxleID = 0;
|
||||||
|
Wheel->Mass = 50;
|
||||||
|
Wheel->Radius = 0.837f;
|
||||||
|
Wheel->Steering = true;
|
||||||
|
Wheel->SuspensionStrength = suspensionStrength;
|
||||||
|
Wheel->Friction = 2.5f;
|
||||||
|
Wheel->ConnectedToHandbrake = true;
|
||||||
|
m_World->CommitEntity(wheel);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto wheel = m_World->CreateEntity(jeepEntity);
|
||||||
|
auto transform = m_World->AddComponent<Components::Transform>(wheel);
|
||||||
|
transform->Position = glm::vec3(-1.9f, 0.5546f - wheelOffset, -0.9242f);
|
||||||
|
transform->Scale = glm::vec3(1.0f);
|
||||||
|
transform->Orientation = glm::angleAxis(glm::pi<float>(), glm::vec3(0, 0, 1));
|
||||||
|
auto model = m_World->AddComponent<Components::Model>(wheel);
|
||||||
|
model->ModelFile = "Models/Jeep/WheelFront/wheelFront.obj";
|
||||||
|
auto Wheel = m_World->AddComponent<Components::Wheel>(wheel);
|
||||||
|
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f);
|
||||||
|
Wheel->AxleID = 0;
|
||||||
|
Wheel->Mass = 50;
|
||||||
|
Wheel->Radius = 0.837f;
|
||||||
|
Wheel->Steering = true;
|
||||||
|
Wheel->SuspensionStrength = suspensionStrength;
|
||||||
|
Wheel->Friction = 2.5f;
|
||||||
|
Wheel->ConnectedToHandbrake = true;
|
||||||
|
m_World->CommitEntity(wheel);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto wheel = m_World->CreateEntity(jeepEntity);
|
||||||
|
auto transform = m_World->AddComponent<Components::Transform>(wheel);
|
||||||
|
transform->Position = glm::vec3(0.2726f, 0.2805f - (wheelOffset/2), 1.9307f);
|
||||||
|
auto model = m_World->AddComponent<Components::Model>(wheel);
|
||||||
|
model->ModelFile = "Models/Jeep/WheelBack/wheelBack.obj";
|
||||||
|
auto Wheel = m_World->AddComponent<Components::Wheel>(wheel);
|
||||||
|
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f);
|
||||||
|
Wheel->AxleID = 1;
|
||||||
|
Wheel->Mass = 150;
|
||||||
|
Wheel->Radius = 0.737f;
|
||||||
|
Wheel->Steering = false;
|
||||||
|
Wheel->SuspensionStrength = suspensionStrength;
|
||||||
|
Wheel->Friction = 2.5f;
|
||||||
|
Wheel->ConnectedToHandbrake = true;
|
||||||
|
m_World->CommitEntity(wheel);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto wheel = m_World->CreateEntity(jeepEntity);
|
||||||
|
auto transform = m_World->AddComponent<Components::Transform>(wheel);
|
||||||
|
transform->Position = glm::vec3(-0.2726f, 0.2805f - (wheelOffset/2), 1.9307f);
|
||||||
|
transform->Orientation = glm::angleAxis(glm::pi<float>(), glm::vec3(0, 0, 1));
|
||||||
|
auto model = m_World->AddComponent<Components::Model>(wheel);
|
||||||
|
model->ModelFile = "Models/Jeep/WheelBack/wheelBack.obj";
|
||||||
|
auto Wheel = m_World->AddComponent<Components::Wheel>(wheel);
|
||||||
|
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, springLength, 0.f);
|
||||||
|
Wheel->AxleID = 1;
|
||||||
|
Wheel->Mass = 150;
|
||||||
|
Wheel->Radius = 0.737f;
|
||||||
|
Wheel->Steering = false;
|
||||||
|
Wheel->SuspensionStrength = suspensionStrength;
|
||||||
|
Wheel->Friction = 2.5f;
|
||||||
|
Wheel->ConnectedToHandbrake = true;
|
||||||
|
m_World->CommitEntity(wheel);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Systems::JeepSteeringSystem::JeepSteeringInputController::Update( double dt )
|
||||||
|
{
|
||||||
|
PositionX = m_Horizontal;
|
||||||
|
PositionY = m_Vertical;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Systems::JeepSteeringSystem::JeepSteeringInputController::OnCommand(const Events::InputCommand &event)
|
||||||
|
{
|
||||||
|
if (event.PlayerID != this->PlayerID)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
float val = event.Value;
|
||||||
|
|
||||||
|
// Tank
|
||||||
|
if (event.Command == "horizontal")
|
||||||
|
{
|
||||||
|
m_Horizontal = val;
|
||||||
|
}
|
||||||
|
else if (event.Command == "jeep_vertical")
|
||||||
|
{
|
||||||
|
m_Vertical = -val;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (event.Command == "handbrake")
|
||||||
|
{
|
||||||
|
Handbrake = val > 0;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
#include <array>
|
||||||
|
|
||||||
|
#include "System.h"
|
||||||
|
#include "Components/Transform.h"
|
||||||
|
#include "Components/Physics.h"
|
||||||
|
#include "Components/Vehicle.h"
|
||||||
|
#include "Components/Player.h"
|
||||||
|
#include "Components/Model.h"
|
||||||
|
#include "Systems/TransformSystem.h"
|
||||||
|
#include "Systems/ParticleSystem.h"
|
||||||
|
#include "InputController.h"
|
||||||
|
|
||||||
|
#include "Components/Health.h"
|
||||||
|
|
||||||
|
#include "Components/Trigger.h"
|
||||||
|
|
||||||
|
#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 "Components/JeepSteering.h"
|
||||||
|
#include "Events/JeepSteer.h"
|
||||||
|
#include "Components/Team.h"
|
||||||
|
|
||||||
|
#include "Events/SetViewportCamera.h"
|
||||||
|
|
||||||
|
namespace Systems
|
||||||
|
{
|
||||||
|
|
||||||
|
class JeepSteeringSystem : public System
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
JeepSteeringSystem(World* world, std::shared_ptr<::EventBroker> eventBroker, std::shared_ptr<::ResourceManager> resourceManager)
|
||||||
|
: System(world, eventBroker, resourceManager)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
void RegisterComponents(ComponentFactory* cf) override;
|
||||||
|
void Initialize() override;
|
||||||
|
|
||||||
|
void Update(double dt) override;
|
||||||
|
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::map<EntityID, double> m_TimeSinceLastShot;
|
||||||
|
EventRelay<JeepSteeringSystem, Events::SpawnVehicle> m_ESpawnVehicle;
|
||||||
|
bool OnSpawnVehicle(const Events::SpawnVehicle &e);
|
||||||
|
|
||||||
|
class JeepSteeringInputController;
|
||||||
|
std::array<std::shared_ptr<JeepSteeringInputController>, 4> m_JeepInputControllers;
|
||||||
|
|
||||||
|
EntityID CreateJeep(int playerID);
|
||||||
|
void AddJeepWheels(EntityID jeepEntity);
|
||||||
|
};
|
||||||
|
|
||||||
|
class JeepSteeringSystem::JeepSteeringInputController : InputController<JeepSteeringSystem>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
JeepSteeringInputController(std::shared_ptr<::EventBroker> eventBroker, int playerID)
|
||||||
|
: InputController(eventBroker)
|
||||||
|
{
|
||||||
|
PlayerID = playerID;
|
||||||
|
|
||||||
|
m_Horizontal = 0.f;
|
||||||
|
m_Vertical = 0.f;
|
||||||
|
PositionX = 0;
|
||||||
|
PositionY = 0;
|
||||||
|
Handbrake = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int PlayerID;
|
||||||
|
|
||||||
|
float PositionY;
|
||||||
|
float PositionX;
|
||||||
|
bool Handbrake;
|
||||||
|
|
||||||
|
void Update(double dt);
|
||||||
|
protected:
|
||||||
|
virtual bool OnCommand(const Events::InputCommand &event);
|
||||||
|
//virtual bool OnMouseMove(const Events::MouseMove &event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
float m_Horizontal;
|
||||||
|
float m_Vertical;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -49,11 +49,15 @@ void Systems::ParticleSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
|||||||
{
|
{
|
||||||
emitterComponent->TimeSinceLastSpawn += dt;
|
emitterComponent->TimeSinceLastSpawn += dt;
|
||||||
auto emitterTransformComponent = m_World->GetComponent<Components::Transform>(entity);
|
auto emitterTransformComponent = m_World->GetComponent<Components::Transform>(entity);
|
||||||
// if(emitterComponent->TimeSinceLastSpawn > emitterComponent->SpawnFrequency)
|
if(emitterComponent->Emitting)
|
||||||
// {
|
{
|
||||||
// SpawnParticles(entity);
|
if(emitterComponent->TimeSinceLastSpawn > emitterComponent->SpawnFrequency)
|
||||||
// emitterComponent->TimeSinceLastSpawn = 0;
|
{
|
||||||
// }
|
SpawnParticles(entity);
|
||||||
|
emitterComponent->TimeSinceLastSpawn = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto particleComponent = m_World->GetComponent<Components::Particle>(entity);
|
auto particleComponent = m_World->GetComponent<Components::Particle>(entity);
|
||||||
@@ -242,10 +246,17 @@ bool Systems::ParticleSystem::CreateExplosion(const Events::CreateExplosion &e)
|
|||||||
emitter->SpawnCount = e.ParticlesToSpawn;
|
emitter->SpawnCount = e.ParticlesToSpawn;
|
||||||
emitter->Speed = e.Speed;
|
emitter->Speed = e.Speed;
|
||||||
emitter->SpreadAngle = e.SpreadAngle;
|
emitter->SpreadAngle = e.SpreadAngle;
|
||||||
|
emitter->Emitting = e.Emitting;
|
||||||
|
emitter->SpawnFrequency = e.SpawnFrequency;
|
||||||
//emitter->ScaleSpectrum.push_back(glm::vec3(e.ParticleScale));
|
//emitter->ScaleSpectrum.push_back(glm::vec3(e.ParticleScale));
|
||||||
emitter->SpawnFrequency = e.LifeTime + 20; //temp
|
emitter->SpawnFrequency = e.LifeTime + 20; //temp
|
||||||
emitter->Fade = true;
|
emitter->Fade = true;
|
||||||
emitter->Color = e.Color;
|
emitter->Color = e.Color;
|
||||||
|
if(e.UseGoalVector)
|
||||||
|
{
|
||||||
|
emitter->UseGoalVelocity = e.UseGoalVector;
|
||||||
|
emitter->GoalVelocity = e.GoalVelocity;
|
||||||
|
}
|
||||||
std::vector<glm::vec3> scale;
|
std::vector<glm::vec3> scale;
|
||||||
scale.push_back(glm::vec3(e.ParticleScale[0]));
|
scale.push_back(glm::vec3(e.ParticleScale[0]));
|
||||||
if(e.ParticleScale.size() >= 2)
|
if(e.ParticleScale.size() >= 2)
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ void Systems::PhysicsSystem::Initialize()
|
|||||||
|
|
||||||
// Events
|
// Events
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ETankSteer, &Systems::PhysicsSystem::OnTankSteer);
|
EVENT_SUBSCRIBE_MEMBER(m_ETankSteer, &Systems::PhysicsSystem::OnTankSteer);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EJeepSteer, &Systems::PhysicsSystem::OnJeepSteer);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ESetVelocity, &Systems::PhysicsSystem::OnSetVelocity);
|
EVENT_SUBSCRIBE_MEMBER(m_ESetVelocity, &Systems::PhysicsSystem::OnSetVelocity);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EApplyForce, &Systems::PhysicsSystem::OnApplyForce);
|
EVENT_SUBSCRIBE_MEMBER(m_EApplyForce, &Systems::PhysicsSystem::OnApplyForce);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EApplyPointImpulse, &Systems::PhysicsSystem::OnApplyPointImpulse);
|
EVENT_SUBSCRIBE_MEMBER(m_EApplyPointImpulse, &Systems::PhysicsSystem::OnApplyPointImpulse);
|
||||||
@@ -180,6 +181,12 @@ void Systems::PhysicsSystem::Update(double dt)
|
|||||||
rotation = GLMQUAT_TO_HKQUATERNION(transformComponent->Orientation);
|
rotation = GLMQUAT_TO_HKQUATERNION(transformComponent->Orientation);
|
||||||
velocity = GLMVEC3_TO_HKVECTOR4(transformComponent->Velocity);
|
velocity = GLMVEC3_TO_HKVECTOR4(transformComponent->Velocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*auto absoluteTransform = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(entity);
|
||||||
|
position = GLMVEC3_TO_HKVECTOR4(absoluteTransform.Position);
|
||||||
|
rotation = GLMQUAT_TO_HKQUATERNION(absoluteTransform.Orientation);
|
||||||
|
velocity = GLMVEC3_TO_HKVECTOR4(absoluteTransform.Velocity);*/
|
||||||
|
|
||||||
m_PhysicsWorld->markForWrite();
|
m_PhysicsWorld->markForWrite();
|
||||||
m_RigidBodies[entity]->setPositionAndRotation(position, rotation);
|
m_RigidBodies[entity]->setPositionAndRotation(position, rotation);
|
||||||
|
|
||||||
@@ -271,14 +278,13 @@ void Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID p
|
|||||||
transformComponent->Position = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getPosition());
|
transformComponent->Position = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getPosition());
|
||||||
transformComponent->Orientation = HKQUATERNION_TO_GLMQUAT(m_RigidBodies[entity]->getRotation());
|
transformComponent->Orientation = HKQUATERNION_TO_GLMQUAT(m_RigidBodies[entity]->getRotation());
|
||||||
transformComponent->Velocity = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getLinearVelocity());
|
transformComponent->Velocity = HKVECTOR4_TO_GLMVEC3(m_RigidBodies[entity]->getLinearVelocity());
|
||||||
// TODO: No support for Scale, MIGHT be possible
|
|
||||||
|
|
||||||
// HACK: WTF IS THIS?
|
|
||||||
if (transformComponentParent)
|
if (transformComponentParent)
|
||||||
{
|
{
|
||||||
transformComponent->Position -= transformComponentParent->Position;
|
auto absoluteTransformParent = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(parent);
|
||||||
transformComponent->Position = transformComponent->Position * transformComponentParent->Orientation;
|
transformComponent->Position -= absoluteTransformParent.Position;
|
||||||
transformComponent->Orientation = transformComponent->Orientation * glm::inverse(transformComponentParent->Orientation);
|
transformComponent->Position = transformComponent->Position * absoluteTransformParent.Orientation;
|
||||||
|
transformComponent->Orientation = glm::inverse(absoluteTransformParent.Orientation) * transformComponent->Orientation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -736,47 +742,6 @@ void HK_CALL Systems::PhysicsSystem::HavokErrorReport(const char* msg, void*)
|
|||||||
LOG_INFO("%s", msg);
|
LOG_INFO("%s", msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Systems::PhysicsSystem::OnTankSteer(const Events::TankSteer &event)
|
|
||||||
{
|
|
||||||
auto vehicleComponent = m_World->GetComponent<Components::Vehicle>(event.Entity);
|
|
||||||
|
|
||||||
if (vehicleComponent && m_Vehicles.find(event.Entity) != m_Vehicles.end() && m_RigidBodies.find(event.Entity) != m_RigidBodies.end())
|
|
||||||
{
|
|
||||||
hkpVehicleDriverInputAnalogStatus* deviceStatus = (hkpVehicleDriverInputAnalogStatus*)m_Vehicles[event.Entity]->m_deviceStatus;
|
|
||||||
auto transformComponent = m_World->GetComponent<Components::Transform>(event.Entity);
|
|
||||||
|
|
||||||
float steeringX = event.PositionX;
|
|
||||||
|
|
||||||
glm::vec3 velocityNormalized = glm::normalize(HKVECTOR4_TO_GLMVEC3(m_RigidBodies[event.Entity]->getLinearVelocity()));
|
|
||||||
glm::vec3 forward = glm::normalize(transformComponent->Orientation * glm::vec3(0, 0, -1));
|
|
||||||
float dotProduct = glm::dot(forward, velocityNormalized);
|
|
||||||
|
|
||||||
if(dotProduct < 0)
|
|
||||||
{
|
|
||||||
steeringX = (1 - (glm::clamp(abs(m_Vehicles[event.Entity]->calcKMPH() /vehicleComponent->TopSpeed), 0.f, 0.7f))) * steeringX;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(abs(m_Vehicles[event.Entity]->calcKMPH()) < 2 && abs(m_Vehicles[event.Entity]->m_mainSteeringAngle) > 80.f * (HK_REAL_PI / 180))
|
|
||||||
{
|
|
||||||
deviceStatus->m_positionY = -0.4f;
|
|
||||||
deviceStatus->m_positionX = steeringX;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
deviceStatus->m_positionX = event.PositionX;
|
|
||||||
deviceStatus->m_positionY = event.PositionY;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(event.PositionY > 0)
|
|
||||||
{
|
|
||||||
deviceStatus->m_reverseButtonPressed = true;
|
|
||||||
}
|
|
||||||
deviceStatus->m_handbrakeButtonPressed = event.Handbrake;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Systems::PhysicsSystem::OnSetVelocity( const Events::SetVelocity &event )
|
bool Systems::PhysicsSystem::OnSetVelocity( const Events::SetVelocity &event )
|
||||||
{
|
{
|
||||||
if(m_RigidBodies.find(event.Entity) != m_RigidBodies.end())
|
if(m_RigidBodies.find(event.Entity) != m_RigidBodies.end())
|
||||||
@@ -872,3 +837,66 @@ bool Systems::PhysicsSystem::OnDisableCollisions( const Events::DisableCollision
|
|||||||
m_PhysicsWorld->unmarkForWrite();
|
m_PhysicsWorld->unmarkForWrite();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Systems::PhysicsSystem::OnTankSteer(const Events::TankSteer &event)
|
||||||
|
{
|
||||||
|
auto vehicleComponent = m_World->GetComponent<Components::Vehicle>(event.Entity);
|
||||||
|
|
||||||
|
if (vehicleComponent && m_Vehicles.find(event.Entity) != m_Vehicles.end() && m_RigidBodies.find(event.Entity) != m_RigidBodies.end())
|
||||||
|
{
|
||||||
|
hkpVehicleDriverInputAnalogStatus* deviceStatus = (hkpVehicleDriverInputAnalogStatus*)m_Vehicles[event.Entity]->m_deviceStatus;
|
||||||
|
auto transformComponent = m_World->GetComponent<Components::Transform>(event.Entity);
|
||||||
|
|
||||||
|
float steeringX = event.PositionX;
|
||||||
|
|
||||||
|
glm::vec3 velocityNormalized = glm::normalize(HKVECTOR4_TO_GLMVEC3(m_RigidBodies[event.Entity]->getLinearVelocity()));
|
||||||
|
glm::vec3 forward = glm::normalize(transformComponent->Orientation * glm::vec3(0, 0, -1));
|
||||||
|
float dotProduct = glm::dot(forward, velocityNormalized);
|
||||||
|
|
||||||
|
if(dotProduct < 0)
|
||||||
|
{
|
||||||
|
steeringX = (1 - (glm::clamp(abs(m_Vehicles[event.Entity]->calcKMPH() /vehicleComponent->TopSpeed), 0.f, 0.7f))) * steeringX;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(abs(m_Vehicles[event.Entity]->calcKMPH()) < 2 && abs(m_Vehicles[event.Entity]->m_mainSteeringAngle) > 80.f * (HK_REAL_PI / 180))
|
||||||
|
{
|
||||||
|
deviceStatus->m_positionY = -0.4f;
|
||||||
|
deviceStatus->m_positionX = steeringX;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
deviceStatus->m_positionX = event.PositionX;
|
||||||
|
deviceStatus->m_positionY = event.PositionY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(event.PositionY > 0)
|
||||||
|
{
|
||||||
|
deviceStatus->m_reverseButtonPressed = true;
|
||||||
|
}
|
||||||
|
deviceStatus->m_handbrakeButtonPressed = event.Handbrake;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Systems::PhysicsSystem::OnJeepSteer( const Events::JeepSteer &event )
|
||||||
|
{
|
||||||
|
auto vehicleComponent = m_World->GetComponent<Components::Vehicle>(event.Entity);
|
||||||
|
|
||||||
|
if (vehicleComponent && m_Vehicles.find(event.Entity) != m_Vehicles.end() && m_RigidBodies.find(event.Entity) != m_RigidBodies.end())
|
||||||
|
{
|
||||||
|
hkpVehicleDriverInputAnalogStatus* deviceStatus = (hkpVehicleDriverInputAnalogStatus*)m_Vehicles[event.Entity]->m_deviceStatus;
|
||||||
|
deviceStatus->m_positionX = event.PositionX;
|
||||||
|
deviceStatus->m_positionY = event.PositionY;
|
||||||
|
|
||||||
|
if(event.PositionY > 0)
|
||||||
|
{
|
||||||
|
deviceStatus->m_reverseButtonPressed = true;
|
||||||
|
}
|
||||||
|
deviceStatus->m_handbrakeButtonPressed = event.Handbrake;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -88,6 +88,7 @@
|
|||||||
#include "Components/Template.h"
|
#include "Components/Template.h"
|
||||||
|
|
||||||
#include "Events/EnterTrigger.h"
|
#include "Events/EnterTrigger.h"
|
||||||
|
#include "Events/JeepSteer.h"
|
||||||
|
|
||||||
namespace Systems
|
namespace Systems
|
||||||
{
|
{
|
||||||
@@ -178,6 +179,8 @@ private:
|
|||||||
// Events
|
// Events
|
||||||
EventRelay<PhysicsSystem, Events::TankSteer> m_ETankSteer;
|
EventRelay<PhysicsSystem, Events::TankSteer> m_ETankSteer;
|
||||||
bool OnTankSteer(const Events::TankSteer &event);
|
bool OnTankSteer(const Events::TankSteer &event);
|
||||||
|
EventRelay<PhysicsSystem, Events::JeepSteer> m_EJeepSteer;
|
||||||
|
bool OnJeepSteer(const Events::JeepSteer &event);
|
||||||
EventRelay<PhysicsSystem, Events::SetVelocity> m_ESetVelocity;
|
EventRelay<PhysicsSystem, Events::SetVelocity> m_ESetVelocity;
|
||||||
bool OnSetVelocity(const Events::SetVelocity &event);
|
bool OnSetVelocity(const Events::SetVelocity &event);
|
||||||
EventRelay<PhysicsSystem, Events::ApplyForce> m_EApplyForce;
|
EventRelay<PhysicsSystem, Events::ApplyForce> m_EApplyForce;
|
||||||
|
|||||||
+38
-29
@@ -11,7 +11,7 @@ void Systems::SoundSystem::Initialize()
|
|||||||
|
|
||||||
m_TransformSystem = m_World->GetSystem<Systems::TransformSystem>();
|
m_TransformSystem = m_World->GetSystem<Systems::TransformSystem>();
|
||||||
FMOD_System_Create(&m_System);
|
FMOD_System_Create(&m_System);
|
||||||
FMOD_RESULT result = FMOD_System_Init(m_System, 32, FMOD_INIT_3D_RIGHTHANDED, 0);
|
FMOD_RESULT result = FMOD_System_Init(m_System, 32, FMOD_INIT_3D_RIGHTHANDED | FMOD_INIT_ENABLE_PROFILE, 0);
|
||||||
if(result != FMOD_OK)
|
if(result != FMOD_OK)
|
||||||
{
|
{
|
||||||
LOG_ERROR("Did initialized load FMOD correctly");
|
LOG_ERROR("Did initialized load FMOD correctly");
|
||||||
@@ -20,7 +20,7 @@ void Systems::SoundSystem::Initialize()
|
|||||||
{
|
{
|
||||||
LOG_INFO("FMOD initialized successfully");
|
LOG_INFO("FMOD initialized successfully");
|
||||||
}
|
}
|
||||||
FMOD_System_Set3DSettings(m_System, 1.f, 1.f, 1.f); //dopplerScale, distancefactor, rolloffscale
|
FMOD_System_Set3DSettings(m_System, 0.f, 1.f, 1.f); //dopplerScale, distancefactor, rolloffscale
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,20 +44,35 @@ void Systems::SoundSystem::Update(double dt)
|
|||||||
std::map<EntityID, FMOD_CHANNEL*>::iterator it;
|
std::map<EntityID, FMOD_CHANNEL*>::iterator it;
|
||||||
for(it = m_DeleteChannels.begin(); it != m_DeleteChannels.end();)
|
for(it = m_DeleteChannels.begin(); it != m_DeleteChannels.end();)
|
||||||
{
|
{
|
||||||
FMOD_BOOL *isPlaying = false;
|
FMOD_BOOL isPlaying = false;
|
||||||
FMOD_Channel_IsPlaying(it->second, isPlaying);
|
FMOD_Channel_IsPlaying(it->second, &isPlaying);
|
||||||
if(isPlaying)
|
if(isPlaying)
|
||||||
{
|
{
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FMOD_Sound_Release(m_DeleteSounds[it->first]);
|
// FMOD_Sound_Release(m_DeleteSounds[it->first]);
|
||||||
m_DeleteSounds.erase(it->first);
|
// m_DeleteSounds.erase(it->first);
|
||||||
it = m_DeleteChannels.erase(it);
|
it = m_DeleteChannels.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//LOG_INFO("Antal emitters i listan: %i", m_Channels.size());
|
||||||
|
|
||||||
|
for(it = m_Channels.begin(); it != m_Channels.end();)
|
||||||
|
{
|
||||||
|
FMOD_BOOL isPlaying = false;
|
||||||
|
FMOD_Channel_IsPlaying(it->second, &isPlaying);
|
||||||
|
if(!isPlaying)
|
||||||
|
{
|
||||||
|
it = m_Channels.erase(it);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Systems::SoundSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
void Systems::SoundSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||||
@@ -86,7 +101,7 @@ void Systems::SoundSystem::UpdateEntity(double dt, EntityID entity, EntityID par
|
|||||||
if(emitter)
|
if(emitter)
|
||||||
{
|
{
|
||||||
FMOD_CHANNEL* channel = m_Channels[entity];
|
FMOD_CHANNEL* channel = m_Channels[entity];
|
||||||
FMOD_SOUND* sound = m_Sounds[entity];
|
//FMOD_SOUND* sound = m_Sounds[entity];
|
||||||
auto eTransform = m_World->GetComponent<Components::Transform>(entity);
|
auto eTransform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
|
|
||||||
glm::vec3 tPos = m_TransformSystem->AbsolutePosition(entity);
|
glm::vec3 tPos = m_TransformSystem->AbsolutePosition(entity);
|
||||||
@@ -121,34 +136,28 @@ bool Systems::SoundSystem::OnComponentCreated(const Events::ComponentCreated &ev
|
|||||||
float pitch = emitter->Pitch;
|
float pitch = emitter->Pitch;
|
||||||
//LoadSound(sound, path, maxDist, minDist);
|
//LoadSound(sound, path, maxDist, minDist);
|
||||||
m_Channels.insert(std::make_pair(emitter->Entity, channel));
|
m_Channels.insert(std::make_pair(emitter->Entity, channel));
|
||||||
m_Sounds.insert(std::make_pair(emitter->Entity, sound));
|
// m_Sounds.insert(std::make_pair(emitter->Entity, sound));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Systems::SoundSystem::PlaySFX(const Events::PlaySFX &event)
|
bool Systems::SoundSystem::PlaySFX(const Events::PlaySFX &event)
|
||||||
{
|
{
|
||||||
auto emitter = m_World->GetComponent<Components::SoundEmitter>(event.Emitter);
|
auto eEntity = m_World->CreateEntity();
|
||||||
if(!emitter)
|
auto eTransform = m_World->AddComponent<Components::Transform>(eEntity);
|
||||||
{
|
eTransform->Position = event.Position;
|
||||||
LOG_ERROR("FMOD: The Entity %i does not have a SoundEmitter-component, but is trying to play a sound", event.Emitter);FMOD_CHANNEL* channel = m_Channels[event.Emitter];
|
auto eComponent = m_World->AddComponent<Components::SoundEmitter>(eEntity);
|
||||||
return false;
|
eComponent->MinDistance = event.MinDistance;
|
||||||
}
|
eComponent->MaxDistance= event.MaxDistance;
|
||||||
|
eComponent->Loop = event.Loop;
|
||||||
|
eComponent->Gain = event.Volume;
|
||||||
|
|
||||||
emitter->type = Components::SoundEmitter::SoundType::SOUND_3D;
|
eComponent->type = Components::SoundEmitter::SoundType::SOUND_3D;
|
||||||
Sound* sound = ResourceManager->Load<Sound>("Sound3D", event.Resource);
|
Sound* sound = ResourceManager->Load<Sound>("Sound3D", event.Resource);
|
||||||
m_Sounds[event.Emitter] = *sound;
|
//m_Sounds[eEntity] = *sound;
|
||||||
FMOD_Sound_Set3DMinMaxDistance(*sound, emitter->MinDistance, emitter->MaxDistance);
|
FMOD_Sound_Set3DMinMaxDistance(*sound, eComponent->MinDistance, eComponent->MaxDistance);
|
||||||
|
|
||||||
PlaySound(&m_Channels[event.Emitter], m_Sounds[event.Emitter], 1.0, event.Loop);
|
PlaySound(&m_Channels[eEntity], *sound, 1.0, eComponent->Loop);
|
||||||
FMOD_System_Update(m_System);
|
|
||||||
|
|
||||||
FMOD_BOOL isPlaying = false;
|
|
||||||
FMOD_Channel_IsPlaying(m_Channels[event.Emitter], &isPlaying);
|
|
||||||
if(!isPlaying)
|
|
||||||
LOG_ERROR("FMOD: File %s is not playing", event.Resource.c_str());
|
|
||||||
else
|
|
||||||
LOG_INFO("Now playing sound %s", event.Resource.c_str());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +169,7 @@ bool Systems::SoundSystem::PlayBGM(const Events::PlayBGM &event)
|
|||||||
m_Channels[emitter] = m_BGMChannel;
|
m_Channels[emitter] = m_BGMChannel;
|
||||||
eComponent->type = Components::SoundEmitter::SoundType::SOUND_3D;
|
eComponent->type = Components::SoundEmitter::SoundType::SOUND_3D;
|
||||||
Sound* sound = ResourceManager->Load<Sound>("Sound2D", event.Resource);
|
Sound* sound = ResourceManager->Load<Sound>("Sound2D", event.Resource);
|
||||||
m_Sounds[emitter] = *sound;
|
//m_Sounds[emitter] = *sound;
|
||||||
|
|
||||||
FMOD_System_PlaySound(m_System, FMOD_CHANNEL_FREE, *sound, false, &m_Channels[emitter]);
|
FMOD_System_PlaySound(m_System, FMOD_CHANNEL_FREE, *sound, false, &m_Channels[emitter]);
|
||||||
return true;
|
return true;
|
||||||
@@ -199,8 +208,8 @@ void Systems::SoundSystem::OnComponentRemoved(EntityID entity, std::string type,
|
|||||||
if(emitter)
|
if(emitter)
|
||||||
{
|
{
|
||||||
m_DeleteChannels.insert(std::make_pair(entity, m_Channels[entity]));
|
m_DeleteChannels.insert(std::make_pair(entity, m_Channels[entity]));
|
||||||
m_DeleteSounds.insert(std::make_pair(entity, m_Sounds[entity]));
|
//m_DeleteSounds.insert(std::make_pair(entity, m_Sounds[entity]));
|
||||||
m_Channels.erase(entity);
|
m_Channels.erase(entity);
|
||||||
m_Sounds.erase(entity);
|
//m_Sounds.erase(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ private:
|
|||||||
std::vector<EntityID> m_Listeners;
|
std::vector<EntityID> m_Listeners;
|
||||||
std::map<EntityID, FMOD_CHANNEL*> m_Channels;
|
std::map<EntityID, FMOD_CHANNEL*> m_Channels;
|
||||||
std::map<EntityID, FMOD_CHANNEL*> m_DeleteChannels;
|
std::map<EntityID, FMOD_CHANNEL*> m_DeleteChannels;
|
||||||
std::map<EntityID, FMOD_SOUND*> m_Sounds;
|
//std::map<EntityID, FMOD_SOUND*> m_Sounds;
|
||||||
std::map<EntityID, FMOD_SOUND*> m_DeleteSounds;
|
std::map<EntityID, FMOD_SOUND*> m_DeleteSounds;
|
||||||
std::shared_ptr<Systems::TransformSystem> m_TransformSystem;
|
std::shared_ptr<Systems::TransformSystem> m_TransformSystem;
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit
|
|||||||
eSteering.Handbrake = inputController->Handbrake;
|
eSteering.Handbrake = inputController->Handbrake;
|
||||||
EventBroker->Publish(eSteering);
|
EventBroker->Publish(eSteering);
|
||||||
|
|
||||||
|
|
||||||
auto towerSteeringComponent = m_World->GetComponent<Components::TowerSteering>(tankSteeringComponent->Turret);
|
auto towerSteeringComponent = m_World->GetComponent<Components::TowerSteering>(tankSteeringComponent->Turret);
|
||||||
auto barrelSteeringComponent = m_World->GetComponent<Components::BarrelSteering>(tankSteeringComponent->Barrel);
|
auto barrelSteeringComponent = m_World->GetComponent<Components::BarrelSteering>(tankSteeringComponent->Barrel);
|
||||||
|
|
||||||
@@ -65,7 +64,7 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit
|
|||||||
{
|
{
|
||||||
auto tankTransform = m_World->GetComponent<Components::Transform>(entity);
|
auto tankTransform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
auto transformComponent = m_World->GetComponent<Components::Transform>(tankSteeringComponent->Barrel);
|
auto transformComponent = m_World->GetComponent<Components::Transform>(tankSteeringComponent->Barrel);
|
||||||
auto absoluteTransform = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(tankSteeringComponent->Barrel);
|
|
||||||
glm::quat orientation = glm::angleAxis(barrelSteeringComponent->TurnSpeed * inputController->BarrelDirection * (float)dt, barrelSteeringComponent->Axis);
|
glm::quat orientation = glm::angleAxis(barrelSteeringComponent->TurnSpeed * inputController->BarrelDirection * (float)dt, barrelSteeringComponent->Axis);
|
||||||
transformComponent->Orientation *= orientation;
|
transformComponent->Orientation *= orientation;
|
||||||
|
|
||||||
@@ -81,7 +80,7 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit
|
|||||||
transformComponent->Orientation = glm::quat(angles);
|
transformComponent->Orientation = glm::quat(angles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto absoluteTransform = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(tankSteeringComponent->Barrel);
|
||||||
|
|
||||||
if(inputController->Shoot && m_TimeSinceLastShot[tankSteeringComponent->Barrel] > 0.5)
|
if(inputController->Shoot && m_TimeSinceLastShot[tankSteeringComponent->Barrel] > 0.5)
|
||||||
{
|
{
|
||||||
@@ -90,17 +89,55 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit
|
|||||||
auto cloneTransform = m_World->GetComponent<Components::Transform>(clone);
|
auto cloneTransform = m_World->GetComponent<Components::Transform>(clone);
|
||||||
cloneTransform->Position = templateAbsoluteTransform.Position;
|
cloneTransform->Position = templateAbsoluteTransform.Position;
|
||||||
cloneTransform->Orientation = absoluteTransform.Orientation * cloneTransform->Orientation;
|
cloneTransform->Orientation = absoluteTransform.Orientation * cloneTransform->Orientation;
|
||||||
|
|
||||||
Events::SetVelocity eSetVelocity;
|
Events::SetVelocity eSetVelocity;
|
||||||
eSetVelocity.Entity = clone;
|
eSetVelocity.Entity = clone;
|
||||||
eSetVelocity.Velocity = tankTransform->Velocity + absoluteTransform.Orientation * (glm::vec3(0.f, 0.f, -1.f) * barrelSteeringComponent->ShotSpeed);
|
eSetVelocity.Velocity = tankTransform->Velocity + absoluteTransform.Orientation * (glm::vec3(0.f, 0.f, -1.f) * barrelSteeringComponent->ShotSpeed);
|
||||||
EventBroker->Publish(eSetVelocity);
|
EventBroker->Publish(eSetVelocity);
|
||||||
m_TimeSinceLastShot[tankSteeringComponent->Barrel] = 0;
|
m_TimeSinceLastShot[tankSteeringComponent->Barrel] = 0;
|
||||||
|
|
||||||
|
{
|
||||||
|
Events::CreateExplosion e;
|
||||||
|
e.LifeTime = 1.5;
|
||||||
|
e.ParticleScale.push_back(0.6);
|
||||||
|
e.ParticleScale.push_back(1.8);
|
||||||
|
e.ParticlesToSpawn = 1;
|
||||||
|
e.Position = cloneTransform->Position;
|
||||||
|
e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1,0,0));
|
||||||
|
e.Speed = 1.7;
|
||||||
|
e.SpreadAngle = glm::pi<float>()/100;
|
||||||
|
e.spritePath = "Textures/Sprites/Smoke1.png";
|
||||||
|
e.Emitting = true;
|
||||||
|
e.SpawnFrequency = 0.2;
|
||||||
|
e.Color = glm::vec4(0.6,0.6,0.6,1);
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Events::CreateExplosion e;
|
||||||
|
e.LifeTime = 0.2;
|
||||||
|
e.ParticleScale.push_back(1);
|
||||||
|
//e.ParticleScale.push_back(2);
|
||||||
|
e.ParticlesToSpawn = 1;
|
||||||
|
e.Position = cloneTransform->Position;
|
||||||
|
e.Speed = 0;
|
||||||
|
e.SpreadAngle = glm::pi<float>();
|
||||||
|
e.spritePath = "Textures/Sprites/MuzzleFlash.png";
|
||||||
|
e.Color = glm::vec4(2, 2, 2, 0.2);
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Events::PlaySFX e;
|
||||||
|
e.Resource = "Sounds/SFX/TankShot.mp3";
|
||||||
|
e.Position = cloneTransform->Position;
|
||||||
|
e.Loop = false;
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
|
||||||
auto clonePhysicsComponent = m_World->GetComponent<Components::Physics>(clone);
|
auto clonePhysicsComponent = m_World->GetComponent<Components::Physics>(clone);
|
||||||
//1,670m/s
|
//1,670m/s
|
||||||
//25kg
|
//25kg
|
||||||
Events::ApplyPointImpulse ePointImpulse ;
|
Events::ApplyPointImpulse ePointImpulse;
|
||||||
ePointImpulse.Entity = entity;
|
ePointImpulse.Entity = entity;
|
||||||
ePointImpulse.Position = absoluteTransform.Position;
|
ePointImpulse.Position = absoluteTransform.Position;
|
||||||
ePointImpulse.Impulse = glm::normalize(absoluteTransform.Orientation * glm::vec3(0, 0, 1)) * clonePhysicsComponent->Mass * 6.f * 1670.f;
|
ePointImpulse.Impulse = glm::normalize(absoluteTransform.Orientation * glm::vec3(0, 0, 1)) * clonePhysicsComponent->Mass * 6.f * 1670.f;
|
||||||
@@ -109,6 +146,15 @@ void Systems::TankSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit
|
|||||||
|
|
||||||
m_TimeSinceLastShot[tankSteeringComponent->Barrel] += dt;
|
m_TimeSinceLastShot[tankSteeringComponent->Barrel] += dt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// auto shot = m_World->GetComponent<Components::TankShell>(entity);
|
||||||
|
// if(shot)
|
||||||
|
// {
|
||||||
|
// if(inputController->Shoot && m_TimeSinceLastShot[tankSteeringComponent->Barrel] > 0.5)
|
||||||
|
// {
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e)
|
bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e)
|
||||||
@@ -152,17 +198,17 @@ bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e)
|
|||||||
e.ParticleScale.push_back(8);
|
e.ParticleScale.push_back(8);
|
||||||
e.ParticlesToSpawn = 20;
|
e.ParticlesToSpawn = 20;
|
||||||
e.Position = shellTransform->Position;
|
e.Position = shellTransform->Position;
|
||||||
e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1,0,0));
|
e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1, 0, 0));
|
||||||
e.Speed = 3;
|
e.Speed = 3;
|
||||||
e.SpreadAngle = glm::pi<float>();
|
e.SpreadAngle = glm::pi<float>();
|
||||||
e.spritePath = "Textures/Sprites/Smoke1.png";
|
e.spritePath = "Textures/Sprites/Smoke1.png";
|
||||||
e.Color = glm::vec4(0.6,0.6,0.6,1);
|
e.Color = glm::vec4(0.6, 0.6, 0.6, 1);
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
e.LifeTime = 0.7;
|
e.LifeTime = 0.7;
|
||||||
e.ParticleScale.push_back(12);
|
e.ParticleScale.push_back(12);
|
||||||
e.ParticlesToSpawn = 10;
|
e.ParticlesToSpawn = 10;
|
||||||
e.Position = shellTransform->Position;
|
e.Position = shellTransform->Position;
|
||||||
e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1,0,0));
|
e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1, 0, 0));
|
||||||
e.Speed = 17;
|
e.Speed = 17;
|
||||||
e.SpreadAngle = glm::pi<float>();
|
e.SpreadAngle = glm::pi<float>();
|
||||||
e.spritePath = "Textures/Sprites/Fire.png";
|
e.spritePath = "Textures/Sprites/Fire.png";
|
||||||
@@ -172,35 +218,85 @@ bool Systems::TankSteeringSystem::OnCollision(const Events::Collision &e)
|
|||||||
e.ParticleScale.push_back(15);
|
e.ParticleScale.push_back(15);
|
||||||
e.ParticlesToSpawn = 5;
|
e.ParticlesToSpawn = 5;
|
||||||
e.Position = shellTransform->Position;
|
e.Position = shellTransform->Position;
|
||||||
e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1,0,0));
|
e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1, 0, 0));
|
||||||
e.Speed = 6;
|
e.Speed = 6;
|
||||||
e.SpreadAngle = glm::pi<float>();
|
e.SpreadAngle = glm::pi<float>();
|
||||||
e.spritePath = "Textures/Sprites/Blast1.png";
|
e.spritePath = "Textures/Sprites/Blast1.png";
|
||||||
e.Color = glm::vec4(2, 2, 2, 0.2);
|
e.Color = glm::vec4(2, 2, 2, 0.2);
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
|
|
||||||
|
/*Events::CreateExplosion e;
|
||||||
|
e.LifeTime = 1.5;
|
||||||
|
e.ParticleScale.push_back(1);
|
||||||
|
e.ParticleScale.push_back(6);
|
||||||
|
e.ParticlesToSpawn = 20;
|
||||||
|
e.Position = shellTransform->Position;
|
||||||
|
e.SpreadAngle = glm::radians<float>(180) / 4;
|
||||||
|
e.RelativeUpOrientation = glm::angleAxis(glm::radians<float>(90), glm::vec3(1,0,0));
|
||||||
|
e.UseGoalVector = true;
|
||||||
|
e.GoalVelocity = glm::vec3(0,-12,0);
|
||||||
|
e.Speed = 12;
|
||||||
|
e.spritePath = "Textures/Sprites/Splash.png";
|
||||||
|
e.Color = glm::vec4(5.f,5.f,5.f,1);
|
||||||
|
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
e.LifeTime = 1.5;
|
||||||
|
e.ParticleScale.push_back(1);
|
||||||
|
e.ParticleScale.push_back(6);
|
||||||
|
e.ParticlesToSpawn = 20;
|
||||||
|
e.Position = shellTransform->Position;
|
||||||
|
e.SpreadAngle = glm::radians<float>(180)/ 4;
|
||||||
|
e.RelativeUpOrientation = glm::angleAxis(glm::radians<float>(90), glm::vec3(1,0,0));
|
||||||
|
e.UseGoalVector = true;
|
||||||
|
e.GoalVelocity = glm::vec3(0,-12,0);
|
||||||
|
e.Speed = 12;
|
||||||
|
e.spritePath = "Textures/Sprites/Splash.png";
|
||||||
|
e.Color = glm::vec4(1.f,1.f,1.f,1);
|
||||||
|
EventBroker->Publish(e);*/
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Events::PlaySFX e;
|
||||||
|
e.MinDistance = 150.f;
|
||||||
|
e.Position = shellTransform->Position;
|
||||||
|
e.Resource = "Sounds/SFX/Explosion.wav";
|
||||||
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Direct damage
|
||||||
|
auto health = m_World->GetComponent<Components::Health>(otherEntity);
|
||||||
|
if (health)
|
||||||
|
{
|
||||||
|
Events::Damage d;
|
||||||
|
d.Entity = otherEntity;
|
||||||
|
d.Amount = shellComponent->Damage;
|
||||||
|
EventBroker->Publish(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Splash damage
|
||||||
for (auto &physComponent : *physicsComponents)
|
for (auto &physComponent : *physicsComponents)
|
||||||
{
|
{
|
||||||
EntityID physicsEntity = std::dynamic_pointer_cast<Components::Physics>(physComponent)->Entity;
|
EntityID physicsEntity = physComponent->Entity;
|
||||||
auto physEntityTransform = m_World->GetComponent<Components::Transform>(physicsEntity);
|
// No splash damage to the direct hit target
|
||||||
|
if (physicsEntity == otherEntity)
|
||||||
|
continue;
|
||||||
|
auto physEntityTransform = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(physicsEntity);
|
||||||
|
|
||||||
float distance = glm::distance(physEntityTransform->Position, shellTransform->Position);
|
float distance = glm::distance(physEntityTransform.Position, shellTransform->Position);
|
||||||
if (distance <= shellComponent->ExplosionRadius)
|
if (distance <= shellComponent->ExplosionRadius)
|
||||||
{
|
{
|
||||||
// DO STUFF! :D
|
// DO STUFF! :D
|
||||||
float radius = shellComponent->ExplosionRadius;
|
float radius = shellComponent->ExplosionRadius;
|
||||||
float strength = (1.f - pow(distance / radius, 2)) * shellComponent->ExplosionStrength;
|
float strength = (1.f - pow(distance / radius, 2)) * shellComponent->ExplosionStrength;
|
||||||
glm::vec3 direction = glm::normalize(physEntityTransform->Position - shellTransform->Position);
|
glm::vec3 direction = glm::normalize(physEntityTransform.Position - shellTransform->Position);
|
||||||
|
|
||||||
Events::ApplyPointImpulse e;
|
Events::ApplyPointImpulse e;
|
||||||
e.Entity = physicsEntity;
|
e.Entity = physicsEntity;
|
||||||
e.Impulse = direction * strength;
|
e.Impulse = direction * strength;
|
||||||
e.Position = physEntityTransform->Position;
|
e.Position = physEntityTransform.Position;
|
||||||
EventBroker->Publish(e);
|
EventBroker->Publish(e);
|
||||||
|
|
||||||
auto health = m_World->GetComponent<Components::Health>(physicsEntity);
|
auto health = m_World->GetComponent<Components::Health>(physicsEntity);
|
||||||
if(health)
|
if (health && health->VulnerableToSplash)
|
||||||
{
|
{
|
||||||
Events::Damage d;
|
Events::Damage d;
|
||||||
d.Entity = physicsEntity;
|
d.Entity = physicsEntity;
|
||||||
@@ -292,7 +388,7 @@ bool Systems::TankSteeringSystem::OnSpawnVehicle(const Events::SpawnVehicle &eve
|
|||||||
{
|
{
|
||||||
if (event.VehicleType != "Tank")
|
if (event.VehicleType != "Tank")
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto spawnPointComponents = m_World->GetComponentsOfType<Components::SpawnPoint>();
|
auto spawnPointComponents = m_World->GetComponentsOfType<Components::SpawnPoint>();
|
||||||
if (!spawnPointComponents)
|
if (!spawnPointComponents)
|
||||||
{
|
{
|
||||||
@@ -300,12 +396,19 @@ bool Systems::TankSteeringSystem::OnSpawnVehicle(const Events::SpawnVehicle &eve
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &spawnPointComponent : *spawnPointComponents)
|
for (auto &component : *spawnPointComponents)
|
||||||
{
|
{
|
||||||
auto spawnPoint = spawnPointComponent->Entity;
|
auto spawnPoint = component->Entity;
|
||||||
auto spawnPointBaseParent = m_World->GetEntityBaseParent(spawnPoint);
|
auto spawnPointComponent = std::dynamic_pointer_cast<Components::SpawnPoint>(component);
|
||||||
auto playerComponent = m_World->GetComponent<Components::Player>(spawnPointBaseParent);
|
auto teamComponent = m_World->GetComponent<Components::Team>(spawnPoint);
|
||||||
if (!playerComponent || playerComponent->ID != event.PlayerID)
|
|
||||||
|
if(!teamComponent)
|
||||||
|
{
|
||||||
|
LOG_ERROR("SpawnPoint has no TeamComponent");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (teamComponent->TeamID != event.PlayerID)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Components::Transform absoluteTransform = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(spawnPoint);
|
Components::Transform absoluteTransform = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(spawnPoint);
|
||||||
@@ -313,8 +416,8 @@ bool Systems::TankSteeringSystem::OnSpawnVehicle(const Events::SpawnVehicle &eve
|
|||||||
// Create a tank
|
// Create a tank
|
||||||
EntityID tank = CreateTank(event.PlayerID);
|
EntityID tank = CreateTank(event.PlayerID);
|
||||||
auto tankTransform = m_World->GetComponent<Components::Transform>(tank);
|
auto tankTransform = m_World->GetComponent<Components::Transform>(tank);
|
||||||
tankTransform->Position = absoluteTransform.Position;
|
tankTransform->Position = absoluteTransform.Position;
|
||||||
tankTransform->Orientation = absoluteTransform.Orientation;
|
tankTransform->Orientation = absoluteTransform.Orientation;
|
||||||
// Set the viewport correctly
|
// Set the viewport correctly
|
||||||
Events::SetViewportCamera e;
|
Events::SetViewportCamera e;
|
||||||
e.CameraEntity = m_World->GetProperty<EntityID>(tank, "Camera");
|
e.CameraEntity = m_World->GetProperty<EntityID>(tank, "Camera");
|
||||||
@@ -341,12 +444,25 @@ EntityID Systems::TankSteeringSystem::CreateTank(int playerID)
|
|||||||
vehicle->MaxTorque = 8000.f;
|
vehicle->MaxTorque = 8000.f;
|
||||||
vehicle->MaxSteeringAngle = 90.f;
|
vehicle->MaxSteeringAngle = 90.f;
|
||||||
vehicle->MaxSpeedFullSteeringAngle = 4.f;
|
vehicle->MaxSpeedFullSteeringAngle = 4.f;
|
||||||
|
vehicle->MinRPM = 200.0f;
|
||||||
|
vehicle->OptimalRPM = 2500.0f,
|
||||||
|
vehicle->MaxRPM = 4000.0f;
|
||||||
|
vehicle->TopSpeed = 90.0f;
|
||||||
|
vehicle->SpringDamping = 1.f;
|
||||||
|
vehicle->UpshiftRPM = 3500.0f;
|
||||||
|
vehicle->DownshiftRPM = 1000.0f;
|
||||||
|
vehicle->gearsRatio0 = 3.0f;
|
||||||
|
vehicle->gearsRatio1 = 2.25f;
|
||||||
|
vehicle->gearsRatio2 = 1.5f;
|
||||||
|
vehicle->gearsRatio3 = 1.0f;
|
||||||
|
|
||||||
auto player = m_World->AddComponent<Components::Player>(tank);
|
auto player = m_World->AddComponent<Components::Player>(tank);
|
||||||
player->ID = playerID;
|
player->ID = playerID;
|
||||||
auto tankSteering = m_World->AddComponent<Components::TankSteering>(tank);
|
auto tankSteering = m_World->AddComponent<Components::TankSteering>(tank);
|
||||||
m_World->AddComponent<Components::Input>(tank);
|
m_World->AddComponent<Components::Input>(tank);
|
||||||
auto health = m_World->AddComponent<Components::Health>(tank);
|
auto health = m_World->AddComponent<Components::Health>(tank);
|
||||||
health->Amount = 100.f;
|
health->Amount = 100.f;
|
||||||
|
m_World->AddComponent<Components::Listener>(tank);
|
||||||
|
|
||||||
{
|
{
|
||||||
auto shape = m_World->CreateEntity(tank);
|
auto shape = m_World->CreateEntity(tank);
|
||||||
@@ -410,8 +526,8 @@ EntityID Systems::TankSteeringSystem::CreateTank(int playerID)
|
|||||||
modelComponent->ModelFile = "Models/Placeholders/rocket/Rocket.obj";
|
modelComponent->ModelFile = "Models/Placeholders/rocket/Rocket.obj";
|
||||||
auto tankShellComponent = m_World->AddComponent<Components::TankShell>(shot);
|
auto tankShellComponent = m_World->AddComponent<Components::TankShell>(shot);
|
||||||
tankShellComponent->Damage = 20.f;
|
tankShellComponent->Damage = 20.f;
|
||||||
tankShellComponent->ExplosionRadius = 30.f;
|
tankShellComponent->ExplosionRadius = 20.f;
|
||||||
tankShellComponent->ExplosionStrength = 300000.f;
|
tankShellComponent->ExplosionStrength = 140.f;
|
||||||
{
|
{
|
||||||
auto shape = m_World->CreateEntity(shot);
|
auto shape = m_World->CreateEntity(shot);
|
||||||
auto transform = m_World->AddComponent<Components::Transform>(shape);
|
auto transform = m_World->AddComponent<Components::Transform>(shape);
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "Components/Vehicle.h"
|
#include "Components/Vehicle.h"
|
||||||
#include "Components/Player.h"
|
#include "Components/Player.h"
|
||||||
#include "Components/Model.h"
|
#include "Components/Model.h"
|
||||||
|
#include "Components/Team.h"
|
||||||
#include "Systems/TransformSystem.h"
|
#include "Systems/TransformSystem.h"
|
||||||
#include "Systems/ParticleSystem.h"
|
#include "Systems/ParticleSystem.h"
|
||||||
#include "InputController.h"
|
#include "InputController.h"
|
||||||
@@ -22,6 +23,7 @@
|
|||||||
#include "Components/Health.h"
|
#include "Components/Health.h"
|
||||||
#include "Components/TankShell.h"
|
#include "Components/TankShell.h"
|
||||||
#include "Components/SphereShape.h"
|
#include "Components/SphereShape.h"
|
||||||
|
#include "Components/Listener.h"
|
||||||
|
|
||||||
#include "Events/EnableCollisions.h"
|
#include "Events/EnableCollisions.h"
|
||||||
#include "Events/DisableCollisions.h"
|
#include "Events/DisableCollisions.h"
|
||||||
@@ -29,6 +31,9 @@
|
|||||||
#include "Components/TriggerExplosion.h"
|
#include "Components/TriggerExplosion.h"
|
||||||
#include "Components/FrameTimer.h"
|
#include "Components/FrameTimer.h"
|
||||||
|
|
||||||
|
#include "Events/PlaySFX.h"
|
||||||
|
#include "Events/PlayBGM.h"
|
||||||
|
|
||||||
#include "Events/Damage.h"
|
#include "Events/Damage.h"
|
||||||
#include "Components/Vehicle.h"
|
#include "Components/Vehicle.h"
|
||||||
#include "Components/Player.h"
|
#include "Components/Player.h"
|
||||||
@@ -44,6 +49,7 @@
|
|||||||
#include "Components/Input.h"
|
#include "Components/Input.h"
|
||||||
|
|
||||||
#include "Events/SetViewportCamera.h"
|
#include "Events/SetViewportCamera.h"
|
||||||
|
#include "Events/GameOver.h"
|
||||||
|
|
||||||
namespace Systems
|
namespace Systems
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,328 @@
|
|||||||
|
#include "PrecompiledHeader.h"
|
||||||
|
#include "TowerSystem.h"
|
||||||
|
#include "World.h"
|
||||||
|
|
||||||
|
void Systems::TowerSystem::RegisterComponents( ComponentFactory* cf )
|
||||||
|
{
|
||||||
|
cf->Register<Components::Tower>([]() { return new Components::Tower(); });
|
||||||
|
cf->Register<Components::Turret>([]() { return new Components::Turret(); });
|
||||||
|
cf->Register<Components::TurretShot>([]() {return new Components::TurretShot(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
void Systems::TowerSystem::Initialize()
|
||||||
|
{
|
||||||
|
//EVENT_SUBSCRIBE_MEMBER(m_eDamage, &Systems::TowerSystem::Damage);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_ECollision, &Systems::TowerSystem::OnCollision);
|
||||||
|
Temp_m_TimeSinceLastShot = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Systems::TowerSystem::Update( double dt )
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Systems::TowerSystem::UpdateEntity( double dt, EntityID entity, EntityID parent )
|
||||||
|
{
|
||||||
|
auto towerComponent = m_World->GetComponent<Components::Tower>(entity);
|
||||||
|
if(!towerComponent)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Components::Transform absoluteTowerGunTransform = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(towerComponent->Gun);
|
||||||
|
|
||||||
|
auto towerGunTransformComponent = m_World->GetComponent<Components::Transform>(towerComponent->Gun);
|
||||||
|
if(!towerGunTransformComponent)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto towerGunBaseTransformComponent = m_World->GetComponent<Components::Transform>(towerComponent->GunBase);
|
||||||
|
if(!towerGunBaseTransformComponent)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto turretComponent = m_World->GetComponent<Components::Turret>(entity);
|
||||||
|
if(!turretComponent)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto players = m_World->GetComponentsOfType<Components::Player>();
|
||||||
|
if (!players)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for(auto player : *players)
|
||||||
|
{
|
||||||
|
auto playerComponent = std::dynamic_pointer_cast<Components::Player>(player);
|
||||||
|
if(towerComponent->ID != playerComponent->ID) //!= betyder att den bara targetar sitt eget lag, == fienden.
|
||||||
|
continue;
|
||||||
|
|
||||||
|
auto playerTransform = m_World->GetComponent<Components::Transform>(player->Entity);
|
||||||
|
if(!playerTransform)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Components::Transform absolutePlayerTransform = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(player->Entity);
|
||||||
|
|
||||||
|
if(glm::distance(absolutePlayerTransform.Position, absoluteTowerGunTransform.Position) > 45.f)
|
||||||
|
continue;
|
||||||
|
//Rotate the turret towards the enemy player
|
||||||
|
glm::quat baseLookAt = glm::inverse(glm::quat_cast(glm::lookAt(absoluteTowerGunTransform.Position, glm::vec3(absolutePlayerTransform.Position.x, absoluteTowerGunTransform.Position.y, absolutePlayerTransform.Position.z), glm::vec3(0, 1, 0))));
|
||||||
|
glm::quat gunLookAt = glm::inverse(glm::quat_cast(glm::lookAt(absoluteTowerGunTransform.Position, glm::vec3(absolutePlayerTransform.Position.x, absolutePlayerTransform.Position.y, absolutePlayerTransform.Position.z ), glm::vec3(0, 1, 0))));
|
||||||
|
|
||||||
|
towerGunTransformComponent->Orientation = glm::inverse(baseLookAt) * gunLookAt;
|
||||||
|
towerGunBaseTransformComponent->Orientation = baseLookAt;
|
||||||
|
|
||||||
|
#pragma region GetShotDirectionAndLaunchShot
|
||||||
|
Temp_m_TimeSinceLastShot += dt;
|
||||||
|
if(Temp_m_TimeSinceLastShot > 1)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
//Shoot code
|
||||||
|
EntityID clone = m_World->CloneEntity(turretComponent->ShotTemplate);
|
||||||
|
auto templateAbsoluteTransform = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(turretComponent->ShotTemplate);
|
||||||
|
auto cloneTransform = m_World->GetComponent<Components::Transform>(clone);
|
||||||
|
cloneTransform->Orientation = templateAbsoluteTransform.Orientation;
|
||||||
|
cloneTransform->Position = templateAbsoluteTransform.Position - (cloneTransform->Orientation* glm::vec3(0.97163f, 0.f, 0.f));
|
||||||
|
|
||||||
|
|
||||||
|
Events::SetVelocity eSetVelocity;
|
||||||
|
eSetVelocity.Entity = clone;
|
||||||
|
eSetVelocity.Velocity = gunLookAt * glm::vec3(0.f, 0.f, -1.f) * turretComponent->ShotSpeed;
|
||||||
|
EventBroker->Publish(eSetVelocity);
|
||||||
|
|
||||||
|
{
|
||||||
|
Events::CreateExplosion e;
|
||||||
|
e.LifeTime = 1.5;
|
||||||
|
e.ParticleScale.push_back(0.6);
|
||||||
|
e.ParticleScale.push_back(1.8);
|
||||||
|
e.ParticlesToSpawn = 1;
|
||||||
|
e.Position = cloneTransform->Position;
|
||||||
|
e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1,0,0));
|
||||||
|
e.Speed = 1.7;
|
||||||
|
e.SpreadAngle = glm::pi<float>()/100;
|
||||||
|
e.spritePath = "Textures/Sprites/Smoke1.png";
|
||||||
|
e.Emitting = true;
|
||||||
|
e.SpawnFrequency = 0.2;
|
||||||
|
e.Color = glm::vec4(0.6,0.6,0.6,1);
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Events::CreateExplosion e;
|
||||||
|
e.LifeTime = 0.2;
|
||||||
|
e.ParticleScale.push_back(1);
|
||||||
|
//e.ParticleScale.push_back(2);
|
||||||
|
e.ParticlesToSpawn = 1;
|
||||||
|
e.Position = cloneTransform->Position;
|
||||||
|
e.Speed = 0;
|
||||||
|
e.SpreadAngle = glm::pi<float>();
|
||||||
|
e.spritePath = "Textures/Sprites/MuzzleFlash.png";
|
||||||
|
e.Color = glm::vec4(2, 2, 2, 0.2);
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
EntityID clone = m_World->CloneEntity(turretComponent->ShotTemplate);
|
||||||
|
auto templateAbsoluteTransform = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(turretComponent->ShotTemplate);
|
||||||
|
auto cloneTransform = m_World->GetComponent<Components::Transform>(clone);
|
||||||
|
cloneTransform->Orientation = templateAbsoluteTransform.Orientation;
|
||||||
|
cloneTransform->Position = templateAbsoluteTransform.Position + (cloneTransform->Orientation * glm::vec3(0.97163f, 0.f, 0.f));
|
||||||
|
|
||||||
|
|
||||||
|
Events::SetVelocity eSetVelocity;
|
||||||
|
eSetVelocity.Entity = clone;
|
||||||
|
eSetVelocity.Velocity = gunLookAt * glm::vec3(0.f, 0.f, -1.f) * turretComponent->ShotSpeed;
|
||||||
|
EventBroker->Publish(eSetVelocity);
|
||||||
|
|
||||||
|
{
|
||||||
|
Events::CreateExplosion e;
|
||||||
|
e.LifeTime = 1.5;
|
||||||
|
e.ParticleScale.push_back(0.6);
|
||||||
|
e.ParticleScale.push_back(1.8);
|
||||||
|
e.ParticlesToSpawn = 1;
|
||||||
|
e.Position = cloneTransform->Position;
|
||||||
|
e.RelativeUpOrientation = glm::angleAxis(glm::pi<float>() / 2, glm::vec3(1,0,0));
|
||||||
|
e.Speed = 1.7;
|
||||||
|
e.SpreadAngle = glm::pi<float>()/100;
|
||||||
|
e.spritePath = "Textures/Sprites/Smoke1.png";
|
||||||
|
e.Emitting = true;
|
||||||
|
e.SpawnFrequency = 0.2;
|
||||||
|
e.Color = glm::vec4(0.6,0.6,0.6,1);
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
Events::CreateExplosion e;
|
||||||
|
e.LifeTime = 0.2;
|
||||||
|
e.ParticleScale.push_back(1);
|
||||||
|
//e.ParticleScale.push_back(2);
|
||||||
|
e.ParticlesToSpawn = 1;
|
||||||
|
e.Position = cloneTransform->Position;
|
||||||
|
e.Speed = 0;
|
||||||
|
e.SpreadAngle = glm::pi<float>();
|
||||||
|
e.spritePath = "Textures/Sprites/MuzzleFlash.png";
|
||||||
|
e.Color = glm::vec4(2, 2, 2, 0.2);
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Temp_m_TimeSinceLastShot = 0;
|
||||||
|
#pragma endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Systems::TowerSystem::OnCollision(const Events::Collision &e)
|
||||||
|
{
|
||||||
|
if(m_World->ValidEntity(e.Entity1) && m_World->ValidEntity(e.Entity2))
|
||||||
|
{
|
||||||
|
auto tankShell1 = m_World->GetComponent<Components::TurretShot>(e.Entity1);
|
||||||
|
auto tankShell2 = m_World->GetComponent<Components::TurretShot>(e.Entity2);
|
||||||
|
|
||||||
|
EntityID shellEntity = 0;
|
||||||
|
Components::TurretShot* shellComponent;
|
||||||
|
EntityID otherEntity = 0;
|
||||||
|
|
||||||
|
if (tankShell1)
|
||||||
|
{
|
||||||
|
shellEntity = e.Entity1;
|
||||||
|
otherEntity = e.Entity2;
|
||||||
|
shellComponent = tankShell1;
|
||||||
|
}
|
||||||
|
else if (tankShell2)
|
||||||
|
{
|
||||||
|
shellEntity = e.Entity2;
|
||||||
|
otherEntity = e.Entity1;
|
||||||
|
shellComponent = tankShell2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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 = 2;
|
||||||
|
e.ParticleScale.push_back(3);
|
||||||
|
e.ParticlesToSpawn = 10;
|
||||||
|
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, 0.1);
|
||||||
|
EventBroker->Publish(e);
|
||||||
|
e.LifeTime = 0.7;
|
||||||
|
e.ParticleScale.push_back(5);
|
||||||
|
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(5);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
//{
|
||||||
|
// Events::CreateExplosion e;
|
||||||
|
// e.LifeTime = 1.5;
|
||||||
|
// e.ParticleScale.push_back(1);
|
||||||
|
// e.ParticleScale.push_back(6);
|
||||||
|
// e.ParticlesToSpawn = 20;
|
||||||
|
// e.Position = shellTransform->Position;
|
||||||
|
// e.SpreadAngle = glm::radians<float>(180) / 4;
|
||||||
|
// e.RelativeUpOrientation = glm::angleAxis(glm::radians<float>(90), glm::vec3(1,0,0));
|
||||||
|
// e.UseGoalVector = true;
|
||||||
|
// e.GoalVelocity = glm::vec3(0,-12,0);
|
||||||
|
// e.Speed = 12;
|
||||||
|
// e.spritePath = "Textures/Sprites/Splash.png";
|
||||||
|
// e.Color = glm::vec4(5.f,5.f,5.f,1);
|
||||||
|
|
||||||
|
// EventBroker->Publish(e);
|
||||||
|
// e.LifeTime = 1.5;
|
||||||
|
// e.ParticleScale.push_back(1);
|
||||||
|
// e.ParticleScale.push_back(6);
|
||||||
|
// e.ParticlesToSpawn = 20;
|
||||||
|
// e.Position = shellTransform->Position;
|
||||||
|
// e.SpreadAngle = glm::radians<float>(180)/ 4;
|
||||||
|
// e.RelativeUpOrientation = glm::angleAxis(glm::radians<float>(90), glm::vec3(1,0,0));
|
||||||
|
// e.UseGoalVector = true;
|
||||||
|
// e.GoalVelocity = glm::vec3(0,-12,0);
|
||||||
|
// e.Speed = 12;
|
||||||
|
// e.spritePath = "Textures/Sprites/Splash.png";
|
||||||
|
// e.Color = glm::vec4(1.f,1.f,1.f,1);
|
||||||
|
// EventBroker->Publish(e);
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
//{
|
||||||
|
// Events::PlaySFX e;
|
||||||
|
// e.MinDistance = 150.f;
|
||||||
|
// e.Position = shellTransform->Position;
|
||||||
|
// e.Resource = "Sounds/SFX/Explosion.wav";
|
||||||
|
// EventBroker->Publish(e);
|
||||||
|
//}
|
||||||
|
|
||||||
|
// Direct damage
|
||||||
|
auto health = m_World->GetComponent<Components::Health>(otherEntity);
|
||||||
|
if (health)
|
||||||
|
{
|
||||||
|
Events::Damage d;
|
||||||
|
d.Entity = otherEntity;
|
||||||
|
d.Amount = shellComponent->Damage;
|
||||||
|
EventBroker->Publish(d);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Splash damage
|
||||||
|
//for (auto &physComponent : *physicsComponents)
|
||||||
|
//{
|
||||||
|
// EntityID physicsEntity = physComponent->Entity;
|
||||||
|
// // No splash damage to the direct hit target
|
||||||
|
// if (physicsEntity == otherEntity)
|
||||||
|
// continue;
|
||||||
|
// auto physEntityTransform = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(physicsEntity);
|
||||||
|
|
||||||
|
// float distance = glm::distance(physEntityTransform.Position, shellTransform->Position);
|
||||||
|
// if (distance <= shellComponent->ExplosionRadius)
|
||||||
|
// {
|
||||||
|
// // DO STUFF! :D
|
||||||
|
// float radius = shellComponent->ExplosionRadius;
|
||||||
|
// float strength = (1.f - pow(distance / radius, 2)) * shellComponent->ExplosionStrength;
|
||||||
|
// glm::vec3 direction = glm::normalize(physEntityTransform.Position - shellTransform->Position);
|
||||||
|
|
||||||
|
// Events::ApplyPointImpulse e;
|
||||||
|
// e.Entity = physicsEntity;
|
||||||
|
// e.Impulse = direction * strength;
|
||||||
|
// e.Position = physEntityTransform.Position;
|
||||||
|
// EventBroker->Publish(e);
|
||||||
|
|
||||||
|
// auto health = m_World->GetComponent<Components::Health>(physicsEntity);
|
||||||
|
// if (health && health->VulnerableToSplash)
|
||||||
|
// {
|
||||||
|
// Events::Damage d;
|
||||||
|
// d.Entity = physicsEntity;
|
||||||
|
// d.Amount = (1.f - pow(distance / radius, 2)) * shellComponent->Damage;
|
||||||
|
// EventBroker->Publish(d);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
m_World->RemoveEntity(shellEntity);
|
||||||
|
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
#ifndef TowerSystem_h__
|
||||||
|
#define TowerSystem_h__
|
||||||
|
|
||||||
|
|
||||||
|
#include "System.h"
|
||||||
|
#include "Systems/TransformSystem.h"
|
||||||
|
#include "Components/Player.h"
|
||||||
|
#include "Components/Tower.h"
|
||||||
|
#include "Components/Turret.h"
|
||||||
|
#include "Components/TurretShot.h"
|
||||||
|
#include "Components/Health.h"
|
||||||
|
#include "Events/SetVelocity.h"
|
||||||
|
#include "Events/CreateExplosion.h"
|
||||||
|
#include "Events/Collision.h"
|
||||||
|
#include "Events/Damage.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace Systems
|
||||||
|
{
|
||||||
|
class TowerSystem : public System
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
TowerSystem(World* world, std::shared_ptr<::EventBroker> eventBroker, std::shared_ptr<::ResourceManager> resourceManager)
|
||||||
|
: System(world, eventBroker, resourceManager) { }
|
||||||
|
|
||||||
|
|
||||||
|
void Initialize() override;
|
||||||
|
void RegisterComponents(ComponentFactory* cf) override;
|
||||||
|
|
||||||
|
virtual void Update(double dt);
|
||||||
|
virtual void UpdateEntity(double dt, EntityID entity, EntityID parent);
|
||||||
|
|
||||||
|
|
||||||
|
EventRelay<TowerSystem, Events::Collision> m_ECollision;
|
||||||
|
bool OnCollision(const Events::Collision &e);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::map<EntityID, double> m_TimeSinceLastShot;
|
||||||
|
float Temp_m_TimeSinceLastShot;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif // TowerSystem_h__
|
||||||
@@ -24,7 +24,7 @@ void Systems::TransformSystem::UpdateEntity( double dt, EntityID entity, EntityI
|
|||||||
if(m_MoveItems.find(entity) != m_MoveItems.end())
|
if(m_MoveItems.find(entity) != m_MoveItems.end())
|
||||||
{
|
{
|
||||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
|
|
||||||
glm::vec3 direction = glm::normalize(m_MoveItems[entity].GoalPosition - transform->Position);
|
glm::vec3 direction = glm::normalize(m_MoveItems[entity].GoalPosition - transform->Position);
|
||||||
glm::vec3 movement = direction * m_MoveItems[entity].Speed * (float)dt;
|
glm::vec3 movement = direction * m_MoveItems[entity].Speed * (float)dt;
|
||||||
|
|
||||||
@@ -54,6 +54,7 @@ void Systems::TransformSystem::UpdateEntity( double dt, EntityID entity, EntityI
|
|||||||
if(m_RotationItems.find(entity) != m_RotationItems.end())
|
if(m_RotationItems.find(entity) != m_RotationItems.end())
|
||||||
{
|
{
|
||||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
|
auto absolutetransform = AbsoluteTransform(entity);
|
||||||
|
|
||||||
float percentage = dt/m_RotationItems[entity].Time;
|
float percentage = dt/m_RotationItems[entity].Time;
|
||||||
m_RotationItems[entity].Time -= dt;
|
m_RotationItems[entity].Time -= dt;
|
||||||
|
|||||||
@@ -44,10 +44,18 @@ void Systems::TriggerSystem::OnEntityRemoved( EntityID entity )
|
|||||||
|
|
||||||
bool Systems::TriggerSystem::OnEnterTrigger( const Events::EnterTrigger &event )
|
bool Systems::TriggerSystem::OnEnterTrigger( const Events::EnterTrigger &event )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
auto teamComponent = m_World->GetComponent<Components::Team>(event.Trigger);
|
||||||
|
auto playerComponent = m_World->GetComponent<Components::Player>(event.Entity);
|
||||||
|
|
||||||
|
if(!teamComponent || !playerComponent)
|
||||||
|
return false;
|
||||||
|
if (teamComponent->TeamID != playerComponent->ID)
|
||||||
|
return false;
|
||||||
|
|
||||||
auto flagComponent1 = m_World->GetComponent<Components::Flag>(event.Trigger);
|
auto flagComponent1 = m_World->GetComponent<Components::Flag>(event.Trigger);
|
||||||
auto flagComponent2 = m_World->GetComponent<Components::Flag>(event.Entity);
|
auto flagComponent2 = m_World->GetComponent<Components::Flag>(event.Entity);
|
||||||
|
|
||||||
//HACK: SIMON IS DISSING AMERICA
|
//HACK: SIMON IS DISSING AMERICA
|
||||||
if(flagComponent1)
|
if(flagComponent1)
|
||||||
{
|
{
|
||||||
@@ -77,6 +85,17 @@ bool Systems::TriggerSystem::OnEnterTrigger( const Events::EnterTrigger &event )
|
|||||||
|
|
||||||
bool Systems::TriggerSystem::OnLeaveTrigger( const Events::LeaveTrigger &event )
|
bool Systems::TriggerSystem::OnLeaveTrigger( const Events::LeaveTrigger &event )
|
||||||
{
|
{
|
||||||
|
auto teamComponent = m_World->GetComponent<Components::Team>(event.Trigger);
|
||||||
|
auto playerComponent = m_World->GetComponent<Components::Player>(event.Entity);
|
||||||
|
|
||||||
|
if(!teamComponent || !playerComponent)
|
||||||
|
return false;
|
||||||
|
if (teamComponent->TeamID != playerComponent->ID)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
auto flagComponent1 = m_World->GetComponent<Components::Flag>(event.Trigger);
|
||||||
|
auto flagComponent2 = m_World->GetComponent<Components::Flag>(event.Entity);
|
||||||
|
|
||||||
auto triggerMoveComponent = m_World->GetComponent<Components::TriggerMove>(event.Trigger);
|
auto triggerMoveComponent = m_World->GetComponent<Components::TriggerMove>(event.Trigger);
|
||||||
if (triggerMoveComponent)
|
if (triggerMoveComponent)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "Components/Move.h"
|
#include "Components/Move.h"
|
||||||
#include "Components/Rotate.h"
|
#include "Components/Rotate.h"
|
||||||
#include "Components/Player.h"
|
#include "Components/Player.h"
|
||||||
|
#include "Components/Team.h"
|
||||||
#include "Events/Move.h"
|
#include "Events/Move.h"
|
||||||
#include "Events/Rotate.h"
|
#include "Events/Rotate.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|||||||
+29
-17
@@ -20,35 +20,47 @@ bool Systems::WallSystem::Damage( const Events::Damage &event )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
LOG_INFO("WallSystem::Damage");
|
LOG_INFO("WallSystem::Damage");
|
||||||
|
|
||||||
|
// Change to damage model
|
||||||
|
auto modelComponent = m_World->GetComponent<Components::Model>(event.Entity);
|
||||||
|
auto damageModel = m_World->GetComponent<Components::DamageModel>(event.Entity);
|
||||||
|
if (modelComponent)
|
||||||
|
{
|
||||||
|
modelComponent->ModelFile = damageModel->ModelFile;
|
||||||
|
modelComponent->Color = damageModel->Color;
|
||||||
|
modelComponent->ShadowCaster = damageModel->ShadowCaster;
|
||||||
|
modelComponent->Transparent = damageModel->Transparent;
|
||||||
|
}
|
||||||
|
|
||||||
auto wallhealthcomponent = m_World->GetComponent<Components::Health>(event.Entity);
|
auto wallhealthcomponent = m_World->GetComponent<Components::Health>(event.Entity);
|
||||||
if(wallhealthcomponent->Amount > 0)
|
if(wallhealthcomponent->Amount > 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
LOG_INFO("Entity %i is dead", event.Entity);
|
||||||
|
//auto transformComponent = m_World->GetComponent<Components::Transform>(event.Entity);
|
||||||
|
Components::Transform transformComponent = m_World->GetSystem<Systems::TransformSystem>()->AbsoluteTransform(event.Entity);
|
||||||
|
|
||||||
|
// Spawn debris
|
||||||
LOG_INFO("You are dead");
|
|
||||||
auto transformComponent = m_World->GetComponent<Components::Transform>(event.Entity);
|
|
||||||
|
|
||||||
for(auto d : wallComponent->Walldebris)
|
for(auto d : wallComponent->Walldebris)
|
||||||
{
|
{
|
||||||
auto debris = m_World->CloneEntity(d);
|
auto debris = m_World->CloneEntity(d);
|
||||||
|
|
||||||
auto transform = m_World->GetComponent<Components::Transform>(debris);
|
auto transform = m_World->GetComponent<Components::Transform>(debris);
|
||||||
transform->Position += transformComponent->Position;
|
transform->Orientation = transform->Orientation * transformComponent.Orientation;
|
||||||
|
transform->Position = transform->Orientation * transform->Position + transformComponent.Position;
|
||||||
// DO STUFF! :D
|
|
||||||
float distance = glm::distance(transform->Position, transformComponent->Position);
|
//DO STUFF! :D
|
||||||
float radius = 5.f;
|
float distance = glm::distance(transform->Position, transformComponent.Position);
|
||||||
float strength = (1.f - pow(distance / radius, 2)) * 500.f;
|
float radius = 5.f;
|
||||||
glm::vec3 direction = glm::normalize(transformComponent->Position - transform->Position);
|
float strength = (1.f - pow(distance / radius, 2)) * 20.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);
|
|
||||||
|
|
||||||
|
Events::ApplyPointImpulse e;
|
||||||
|
e.Entity = debris;
|
||||||
|
e.Impulse = direction * strength;
|
||||||
|
e.Position = transformComponent.Position;
|
||||||
|
EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_World->RemoveEntity(event.Entity);
|
m_World->RemoveEntity(event.Entity);
|
||||||
|
|||||||
@@ -3,10 +3,12 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "System.h"
|
#include "System.h"
|
||||||
|
#include "Systems/TransformSystem.h"
|
||||||
#include "Events/OnDead.h"
|
#include "Events/OnDead.h"
|
||||||
#include "Events/Damage.h"
|
#include "Events/Damage.h"
|
||||||
#include "Events/ApplyPointImpulse.h"
|
#include "Events/ApplyPointImpulse.h"
|
||||||
#include "Components/Model.h"
|
#include "Components/Model.h"
|
||||||
|
#include "Components/DamageModel.h"
|
||||||
#include "Components/Wall.h"
|
#include "Components/Wall.h"
|
||||||
#include "Components/Transform.h"
|
#include "Components/Transform.h"
|
||||||
#include "Components/Physics.h"
|
#include "Components/Physics.h"
|
||||||
|
|||||||
@@ -109,10 +109,12 @@
|
|||||||
<ClCompile Include="..\..\src\ShaderProgram.cpp" />
|
<ClCompile Include="..\..\src\ShaderProgram.cpp" />
|
||||||
<ClCompile Include="..\..\src\Skybox.cpp" />
|
<ClCompile Include="..\..\src\Skybox.cpp" />
|
||||||
<ClCompile Include="..\..\src\Sound.cpp" />
|
<ClCompile Include="..\..\src\Sound.cpp" />
|
||||||
|
<ClCompile Include="..\..\src\Systems\JeepSteeringSystem.cpp" />
|
||||||
<ClCompile Include="..\..\src\Systems\DamageSystem.cpp" />
|
<ClCompile Include="..\..\src\Systems\DamageSystem.cpp" />
|
||||||
<ClCompile Include="..\..\src\Systems\DebugSystem.cpp" />
|
<ClCompile Include="..\..\src\Systems\DebugSystem.cpp" />
|
||||||
<ClCompile Include="..\..\src\Systems\FollowSystem.cpp" />
|
<ClCompile Include="..\..\src\Systems\FollowSystem.cpp" />
|
||||||
<ClCompile Include="..\..\src\Systems\FreeSteeringSystem.cpp" />
|
<ClCompile Include="..\..\src\Systems\FreeSteeringSystem.cpp" />
|
||||||
|
<ClCompile Include="..\..\src\Systems\GameStateSystem.cpp" />
|
||||||
<ClCompile Include="..\..\src\Systems\GarageSystem.cpp" />
|
<ClCompile Include="..\..\src\Systems\GarageSystem.cpp" />
|
||||||
<ClCompile Include="..\..\src\Systems\HelicopterSteeringSystem.cpp" />
|
<ClCompile Include="..\..\src\Systems\HelicopterSteeringSystem.cpp" />
|
||||||
<ClCompile Include="..\..\src\Systems\InputSystem.cpp" />
|
<ClCompile Include="..\..\src\Systems\InputSystem.cpp" />
|
||||||
@@ -122,6 +124,7 @@
|
|||||||
<ClCompile Include="..\..\src\Systems\SoundSystem.cpp" />
|
<ClCompile Include="..\..\src\Systems\SoundSystem.cpp" />
|
||||||
<ClCompile Include="..\..\src\Systems\TankSteeringSystem.cpp" />
|
<ClCompile Include="..\..\src\Systems\TankSteeringSystem.cpp" />
|
||||||
<ClCompile Include="..\..\src\Systems\TimerSystem.cpp" />
|
<ClCompile Include="..\..\src\Systems\TimerSystem.cpp" />
|
||||||
|
<ClCompile Include="..\..\src\Systems\TowerSystem.cpp" />
|
||||||
<ClCompile Include="..\..\src\Systems\TransformSystem.cpp" />
|
<ClCompile Include="..\..\src\Systems\TransformSystem.cpp" />
|
||||||
<ClCompile Include="..\..\src\Systems\TriggerSystem.cpp" />
|
<ClCompile Include="..\..\src\Systems\TriggerSystem.cpp" />
|
||||||
<ClCompile Include="..\..\src\Systems\WallSystem.cpp" />
|
<ClCompile Include="..\..\src\Systems\WallSystem.cpp" />
|
||||||
@@ -137,13 +140,17 @@
|
|||||||
<ClInclude Include="..\..\src\Components\BlendMap.h" />
|
<ClInclude Include="..\..\src\Components\BlendMap.h" />
|
||||||
<ClInclude Include="..\..\src\Components\BoxShape.h" />
|
<ClInclude Include="..\..\src\Components\BoxShape.h" />
|
||||||
<ClInclude Include="..\..\src\Components\Camera.h" />
|
<ClInclude Include="..\..\src\Components\Camera.h" />
|
||||||
|
<ClInclude Include="..\..\src\Components\DamageModel.h" />
|
||||||
<ClInclude Include="..\..\src\Components\DirectionalLight.h" />
|
<ClInclude Include="..\..\src\Components\DirectionalLight.h" />
|
||||||
<ClInclude Include="..\..\src\Components\Flag.h" />
|
<ClInclude Include="..\..\src\Components\Flag.h" />
|
||||||
<ClInclude Include="..\..\src\Components\Follow.h" />
|
<ClInclude Include="..\..\src\Components\Follow.h" />
|
||||||
<ClInclude Include="..\..\src\Components\FrameTimer.h" />
|
<ClInclude Include="..\..\src\Components\FrameTimer.h" />
|
||||||
<ClInclude Include="..\..\src\Components\Garage.h" />
|
<ClInclude Include="..\..\src\Components\Garage.h" />
|
||||||
|
<ClInclude Include="..\..\src\Components\JeepSteering.h" />
|
||||||
<ClInclude Include="..\..\src\Components\Move.h" />
|
<ClInclude Include="..\..\src\Components\Move.h" />
|
||||||
<ClInclude Include="..\..\src\Components\Rotate.h" />
|
<ClInclude Include="..\..\src\Components\Rotate.h" />
|
||||||
|
<ClInclude Include="..\..\src\Components\Tower.h" />
|
||||||
|
<ClInclude Include="..\..\src\Components\Team.h" />
|
||||||
<ClInclude Include="..\..\src\Components\TriggerMove.h" />
|
<ClInclude Include="..\..\src\Components\TriggerMove.h" />
|
||||||
<ClInclude Include="..\..\src\Components\Timer.h" />
|
<ClInclude Include="..\..\src\Components\Timer.h" />
|
||||||
<ClInclude Include="..\..\src\Components\TriggerExplosion.h" />
|
<ClInclude Include="..\..\src\Components\TriggerExplosion.h" />
|
||||||
@@ -171,6 +178,8 @@
|
|||||||
<ClInclude Include="..\..\src\Components\Transform.h" />
|
<ClInclude Include="..\..\src\Components\Transform.h" />
|
||||||
<ClInclude Include="..\..\src\Components\Trigger.h" />
|
<ClInclude Include="..\..\src\Components\Trigger.h" />
|
||||||
<ClInclude Include="..\..\src\Components\TriggerRotate.h" />
|
<ClInclude Include="..\..\src\Components\TriggerRotate.h" />
|
||||||
|
<ClInclude Include="..\..\src\Components\Turret.h" />
|
||||||
|
<ClInclude Include="..\..\src\Components\TurretShot.h" />
|
||||||
<ClInclude Include="..\..\src\Components\Vehicle.h" />
|
<ClInclude Include="..\..\src\Components\Vehicle.h" />
|
||||||
<ClInclude Include="..\..\src\Components\SpawnPoint.h" />
|
<ClInclude Include="..\..\src\Components\SpawnPoint.h" />
|
||||||
<ClInclude Include="..\..\src\Components\Viewport.h" />
|
<ClInclude Include="..\..\src\Components\Viewport.h" />
|
||||||
@@ -192,9 +201,16 @@
|
|||||||
<ClInclude Include="..\..\src\Events\Damage.h" />
|
<ClInclude Include="..\..\src\Events\Damage.h" />
|
||||||
<ClInclude Include="..\..\src\Events\DisableCollisions.h" />
|
<ClInclude Include="..\..\src\Events\DisableCollisions.h" />
|
||||||
<ClInclude Include="..\..\src\Events\EnableCollisions.h" />
|
<ClInclude Include="..\..\src\Events\EnableCollisions.h" />
|
||||||
|
<ClInclude Include="..\..\src\Events\FlagCaptured.h" />
|
||||||
|
<ClInclude Include="..\..\src\Events\FlagDropped.h" />
|
||||||
|
<ClInclude Include="..\..\src\Events\FlagPickup.h" />
|
||||||
|
<ClInclude Include="..\..\src\Events\FlagReturned.h" />
|
||||||
|
<ClInclude Include="..\..\src\Events\GameOver.h" />
|
||||||
<ClInclude Include="..\..\src\Events\GamepadAxis.h" />
|
<ClInclude Include="..\..\src\Events\GamepadAxis.h" />
|
||||||
<ClInclude Include="..\..\src\Events\GamepadButton.h" />
|
<ClInclude Include="..\..\src\Events\GamepadButton.h" />
|
||||||
|
<ClInclude Include="..\..\src\Events\GameStart.h" />
|
||||||
<ClInclude Include="..\..\src\Events\InputCommand.h" />
|
<ClInclude Include="..\..\src\Events\InputCommand.h" />
|
||||||
|
<ClInclude Include="..\..\src\Events\JeepSteer.h" />
|
||||||
<ClInclude Include="..\..\src\Events\KeyDown.h" />
|
<ClInclude Include="..\..\src\Events\KeyDown.h" />
|
||||||
<ClInclude Include="..\..\src\Events\KeyUp.h" />
|
<ClInclude Include="..\..\src\Events\KeyUp.h" />
|
||||||
<ClInclude Include="..\..\src\Events\LeaveTrigger.h" />
|
<ClInclude Include="..\..\src\Events\LeaveTrigger.h" />
|
||||||
@@ -218,7 +234,9 @@
|
|||||||
<ClInclude Include="..\..\src\GUI\Frame.h" />
|
<ClInclude Include="..\..\src\GUI\Frame.h" />
|
||||||
<ClInclude Include="..\..\src\EventBroker.h" />
|
<ClInclude Include="..\..\src\EventBroker.h" />
|
||||||
<ClInclude Include="..\..\src\GUI\GameFrame.h" />
|
<ClInclude Include="..\..\src\GUI\GameFrame.h" />
|
||||||
|
<ClInclude Include="..\..\src\GUI\GameOverFrame.h" />
|
||||||
<ClInclude Include="..\..\src\GUI\HealthOverlay.h" />
|
<ClInclude Include="..\..\src\GUI\HealthOverlay.h" />
|
||||||
|
<ClInclude Include="..\..\src\GUI\MainMenuFrame.h" />
|
||||||
<ClInclude Include="..\..\src\GUI\PlayerHUD.h" />
|
<ClInclude Include="..\..\src\GUI\PlayerHUD.h" />
|
||||||
<ClInclude Include="..\..\src\GUI\VehicleSelection.h" />
|
<ClInclude Include="..\..\src\GUI\VehicleSelection.h" />
|
||||||
<ClInclude Include="..\..\src\GUI\WorldFrame.h" />
|
<ClInclude Include="..\..\src\GUI\WorldFrame.h" />
|
||||||
@@ -237,10 +255,12 @@
|
|||||||
<ClInclude Include="..\..\src\Skybox.h" />
|
<ClInclude Include="..\..\src\Skybox.h" />
|
||||||
<ClInclude Include="..\..\src\Sound.h" />
|
<ClInclude Include="..\..\src\Sound.h" />
|
||||||
<ClInclude Include="..\..\src\System.h" />
|
<ClInclude Include="..\..\src\System.h" />
|
||||||
|
<ClInclude Include="..\..\src\Systems\JeepSteeringSystem.h" />
|
||||||
<ClInclude Include="..\..\src\Systems\DamageSystem.h" />
|
<ClInclude Include="..\..\src\Systems\DamageSystem.h" />
|
||||||
<ClInclude Include="..\..\src\Systems\DebugSystem.h" />
|
<ClInclude Include="..\..\src\Systems\DebugSystem.h" />
|
||||||
<ClInclude Include="..\..\src\Systems\FollowSystem.h" />
|
<ClInclude Include="..\..\src\Systems\FollowSystem.h" />
|
||||||
<ClInclude Include="..\..\src\Systems\FreeSteeringSystem.h" />
|
<ClInclude Include="..\..\src\Systems\FreeSteeringSystem.h" />
|
||||||
|
<ClInclude Include="..\..\src\Systems\GameStateSystem.h" />
|
||||||
<ClInclude Include="..\..\src\Systems\GarageSystem.h" />
|
<ClInclude Include="..\..\src\Systems\GarageSystem.h" />
|
||||||
<ClInclude Include="..\..\src\Systems\HelicopterSteeringSystem.h" />
|
<ClInclude Include="..\..\src\Systems\HelicopterSteeringSystem.h" />
|
||||||
<ClInclude Include="..\..\src\Systems\InputSystem.h" />
|
<ClInclude Include="..\..\src\Systems\InputSystem.h" />
|
||||||
@@ -250,6 +270,7 @@
|
|||||||
<ClInclude Include="..\..\src\Systems\SoundSystem.h" />
|
<ClInclude Include="..\..\src\Systems\SoundSystem.h" />
|
||||||
<ClInclude Include="..\..\src\Systems\TankSteeringSystem.h" />
|
<ClInclude Include="..\..\src\Systems\TankSteeringSystem.h" />
|
||||||
<ClInclude Include="..\..\src\Systems\TimerSystem.h" />
|
<ClInclude Include="..\..\src\Systems\TimerSystem.h" />
|
||||||
|
<ClInclude Include="..\..\src\Systems\TowerSystem.h" />
|
||||||
<ClInclude Include="..\..\src\Systems\TransformSystem.h" />
|
<ClInclude Include="..\..\src\Systems\TransformSystem.h" />
|
||||||
<ClInclude Include="..\..\src\Systems\TriggerSystem.h" />
|
<ClInclude Include="..\..\src\Systems\TriggerSystem.h" />
|
||||||
<ClInclude Include="..\..\src\Systems\WallSystem.h" />
|
<ClInclude Include="..\..\src\Systems\WallSystem.h" />
|
||||||
|
|||||||
@@ -74,19 +74,33 @@
|
|||||||
<ClCompile Include="..\..\src\Systems\DamageSystem.cpp">
|
<ClCompile Include="..\..\src\Systems\DamageSystem.cpp">
|
||||||
<Filter>Game\Systems</Filter>
|
<Filter>Game\Systems</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\src\Systems\WheelPairSystem.cpp" />
|
|
||||||
<ClCompile Include="..\..\src\Systems\FollowSystem.cpp">
|
<ClCompile Include="..\..\src\Systems\FollowSystem.cpp">
|
||||||
<Filter>Game\Systems</Filter>
|
<Filter>Game\Systems</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\src\Systems\WallSystem.cpp">
|
|
||||||
<Filter>Gameplay\Systems</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\src\Systems\GarageSystem.cpp">
|
<ClCompile Include="..\..\src\Systems\GarageSystem.cpp">
|
||||||
<Filter>Game\Systems</Filter>
|
<Filter>Game\Systems</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\src\Sound.cpp">
|
<ClCompile Include="..\..\src\Sound.cpp">
|
||||||
<Filter>Audio</Filter>
|
<Filter>Audio</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\Systems\JeepSteeringSystem.cpp">
|
||||||
|
<Filter>Physics\Systems</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\Systems\WallSystem.cpp">
|
||||||
|
<Filter>Game\Systems</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\Systems\TowerSystem.cpp">
|
||||||
|
<Filter>Game\Systems</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\Systems\GameStateSystem.cpp">
|
||||||
|
<Filter>Game\Systems</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\Systems\WheelPairSystem.cpp">
|
||||||
|
<Filter>Physics\Systems</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\Systems\WallSystem.cpp">
|
||||||
|
<Filter>Game\Systems</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="Util">
|
<Filter Include="Util">
|
||||||
@@ -194,6 +208,9 @@
|
|||||||
<Filter Include="Base\Events">
|
<Filter Include="Base\Events">
|
||||||
<UniqueIdentifier>{3cbe68d9-2446-45ee-8637-ffb805997dcd}</UniqueIdentifier>
|
<UniqueIdentifier>{3cbe68d9-2446-45ee-8637-ffb805997dcd}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="Rendering\Events">
|
||||||
|
<UniqueIdentifier>{a025d51e-594d-4844-983b-f683726bf1bf}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
<Filter Include="Game\Events">
|
<Filter Include="Game\Events">
|
||||||
<UniqueIdentifier>{9702064a-02a2-4b3c-a2ab-47c23a9cf49c}</UniqueIdentifier>
|
<UniqueIdentifier>{9702064a-02a2-4b3c-a2ab-47c23a9cf49c}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
@@ -523,9 +540,6 @@
|
|||||||
<ClInclude Include="..\..\src\Components\BlendMap.h">
|
<ClInclude Include="..\..\src\Components\BlendMap.h">
|
||||||
<Filter>Rendering\Components</Filter>
|
<Filter>Rendering\Components</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\Systems\WallSystem.h">
|
|
||||||
<Filter>Gameplay\Systems</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\Events\LeaveTrigger.h">
|
<ClInclude Include="..\..\src\Events\LeaveTrigger.h">
|
||||||
<Filter>Physics\Events</Filter>
|
<Filter>Physics\Events</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -556,12 +570,12 @@
|
|||||||
<ClInclude Include="..\..\src\Components\Rotate.h">
|
<ClInclude Include="..\..\src\Components\Rotate.h">
|
||||||
<Filter>Base\Components</Filter>
|
<Filter>Base\Components</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Components\BlendMap.h">
|
||||||
|
<Filter>Rendering\Components</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\GUI\VehicleSelection.h">
|
<ClInclude Include="..\..\src\GUI\VehicleSelection.h">
|
||||||
<Filter>GUI</Filter>
|
<Filter>GUI</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\Events\OnDead.h">
|
|
||||||
<Filter>Gameplay\Events</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\src\Events\SpawnVehicle.h">
|
<ClInclude Include="..\..\src\Events\SpawnVehicle.h">
|
||||||
<Filter>Game\Events</Filter>
|
<Filter>Game\Events</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -571,6 +585,71 @@
|
|||||||
<ClInclude Include="..\..\src\Components\SpawnPoint.h">
|
<ClInclude Include="..\..\src\Components\SpawnPoint.h">
|
||||||
<Filter>Game\Components</Filter>
|
<Filter>Game\Components</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Events\OnDead.h" />
|
||||||
|
<ClInclude Include="..\..\src\Systems\WallSystem.h">
|
||||||
|
<Filter>Game\Systems</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Systems\TowerSystem.h">
|
||||||
|
<Filter>Game\Systems</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Components\Tower.h">
|
||||||
|
<Filter>Game\Components</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Components\Turret.h">
|
||||||
|
<Filter>Game\Components</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Components\TurretShot.h">
|
||||||
|
<Filter>Physics\Components</Filter>
|
||||||
|
<ClInclude Include="..\..\src\Components\Team.h">
|
||||||
|
<Filter>Game\Components</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Systems\JeepSteeringSystem.h">
|
||||||
|
<Filter>Physics\Systems</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Events\OnDead.h" />
|
||||||
|
<ClInclude Include="..\..\src\Systems\WallSystem.h" />
|
||||||
|
<ClInclude Include="..\..\src\GUI\GameOverFrame.h">
|
||||||
|
<Filter>GUI</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Systems\GameStateSystem.h">
|
||||||
|
<Filter>Game\Systems</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Events\FlagPickup.h">
|
||||||
|
<Filter>Game\Events</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Events\FlagCaptured.h">
|
||||||
|
<Filter>Game\Events</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Events\FlagDropped.h">
|
||||||
|
<Filter>Game\Events</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Events\FlagReturned.h">
|
||||||
|
<Filter>Game\Events</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Events\GameOver.h">
|
||||||
|
<Filter>Game\Events</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\GUI\MainMenuFrame.h">
|
||||||
|
<Filter>GUI</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Events\GameStart.h">
|
||||||
|
<Filter>Game\Events</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Events\OnDead.h">
|
||||||
|
<Filter>Game\Events</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Events\JeepSteer.h">
|
||||||
|
<Filter>Physics\Events</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Components\JeepSteering.h">
|
||||||
|
<Filter>Physics\Components</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Systems\WallSystem.h">
|
||||||
|
<Filter>Game\Systems</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\Components\DamageModel.h">
|
||||||
|
<Filter>Rendering\Components</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\..\src\Shaders\Fragment2.glsl">
|
<None Include="..\..\src\Shaders\Fragment2.glsl">
|
||||||
|
|||||||
Reference in New Issue
Block a user