Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e0a1550acd | |||
| 7d4b9927d8 | |||
| 0ee3385e96 | |||
| d7f166b8ae | |||
| 28de31d84d | |||
| e9ef0e7060 | |||
| 416f55b6ce | |||
| 0346f81234 | |||
| a6ef026db5 |
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef Events_BecomeServerOrClient_h__
|
||||||
|
#define Events_BecomeServerOrClient_h__
|
||||||
|
|
||||||
|
#include "Core/EventBroker.h"
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
struct BecomeServer : public Event { };
|
||||||
|
|
||||||
|
struct BecomeClient : public Event { };
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#ifndef EResolutionChanged_h__
|
||||||
|
#define EResolutionChanged_h__
|
||||||
|
|
||||||
|
#include "../Core/Event.h"
|
||||||
|
#include "../Core/Util/Rectangle.h"
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
// Fired when the framebuffer size changes
|
||||||
|
struct ResolutionChanged : Event
|
||||||
|
{
|
||||||
|
Rectangle OldResolution;
|
||||||
|
Rectangle NewResolution;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -27,8 +27,6 @@ struct ExplosionEffectJob : ModelJob
|
|||||||
Velocity = (glm::vec2)explosionEffectComponent["Velocity"];
|
Velocity = (glm::vec2)explosionEffectComponent["Velocity"];
|
||||||
ColorByDistance = (bool)explosionEffectComponent["ColorByDistance"];
|
ColorByDistance = (bool)explosionEffectComponent["ColorByDistance"];
|
||||||
ExponentialAccelaration = (bool)explosionEffectComponent["ExponentialAccelaration"];
|
ExponentialAccelaration = (bool)explosionEffectComponent["ExponentialAccelaration"];
|
||||||
Reverse = (bool)explosionEffectComponent["Reverse"];
|
|
||||||
ColorDistanceScalar = (double)explosionEffectComponent["ColorDistanceScalar"];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
glm::vec3 ExplosionOrigin;
|
glm::vec3 ExplosionOrigin;
|
||||||
@@ -40,14 +38,12 @@ struct ExplosionEffectJob : ModelJob
|
|||||||
glm::vec4 EndColor;
|
glm::vec4 EndColor;
|
||||||
bool Randomness = false;
|
bool Randomness = false;
|
||||||
|
|
||||||
double RandomnessScalar = 1.f;
|
float RandomnessScalar = 1.f;
|
||||||
glm::vec2 Velocity;
|
glm::vec2 Velocity;
|
||||||
bool ColorByDistance = false;
|
bool ColorByDistance = false;
|
||||||
//bool ReverseAnimation = false;
|
//bool ReverseAnimation = false;
|
||||||
//bool Wireframe = false;
|
//bool Wireframe = false;
|
||||||
bool ExponentialAccelaration = false;
|
bool ExponentialAccelaration = false;
|
||||||
bool Reverse = false;
|
|
||||||
double ColorDistanceScalar = 1.f;
|
|
||||||
|
|
||||||
std::array<float, 50> RandomNumbers = {
|
std::array<float, 50> RandomNumbers = {
|
||||||
0.3257552917701f,
|
0.3257552917701f,
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ private:
|
|||||||
struct Frustum {
|
struct Frustum {
|
||||||
Plane Planes[4];
|
Plane Planes[4];
|
||||||
};
|
};
|
||||||
Frustum* m_Frustums;
|
Frustum* m_Frustums = nullptr;
|
||||||
|
|
||||||
//This should be a component
|
//This should be a component
|
||||||
struct LightSource {
|
struct LightSource {
|
||||||
@@ -74,11 +74,11 @@ private:
|
|||||||
glm::vec2 Padding = glm::vec2(1.f, 2.f);
|
glm::vec2 Padding = glm::vec2(1.f, 2.f);
|
||||||
};
|
};
|
||||||
|
|
||||||
LightGrid* m_LightGrid;
|
LightGrid* m_LightGrid = nullptr;
|
||||||
|
|
||||||
int m_LightOffset = 0;
|
int m_LightOffset = 0;
|
||||||
|
|
||||||
float* m_LightIndex;
|
float* m_LightIndex = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "../Core/Octree.h"
|
#include "../Core/Octree.h"
|
||||||
#include "../Collision/EntityAABB.h"
|
#include "../Collision/EntityAABB.h"
|
||||||
#include "../Core/ConfigFile.h"
|
#include "../Core/ConfigFile.h"
|
||||||
|
#include "EResolutionChanged.h"
|
||||||
|
|
||||||
class RenderSystem : public ImpureSystem
|
class RenderSystem : public ImpureSystem
|
||||||
{
|
{
|
||||||
@@ -36,6 +37,8 @@ private:
|
|||||||
EntityWrapper m_LocalPlayer = EntityWrapper::Invalid;
|
EntityWrapper m_LocalPlayer = EntityWrapper::Invalid;
|
||||||
Octree<EntityAABB>* m_Octree;
|
Octree<EntityAABB>* m_Octree;
|
||||||
|
|
||||||
|
EventRelay<RenderSystem, Events::ResolutionChanged> m_EResolutionChanged;
|
||||||
|
bool OnResolutionChanged(Events::ResolutionChanged &event);
|
||||||
EventRelay<RenderSystem, Events::SetCamera> m_ESetCamera;
|
EventRelay<RenderSystem, Events::SetCamera> m_ESetCamera;
|
||||||
bool OnSetCamera(Events::SetCamera &event);
|
bool OnSetCamera(Events::SetCamera &event);
|
||||||
EventRelay<RenderSystem, Events::InputCommand> m_EInputCommand;
|
EventRelay<RenderSystem, Events::InputCommand> m_EInputCommand;
|
||||||
|
|||||||
@@ -28,10 +28,12 @@
|
|||||||
#include "Util/CommonFunctions.h"
|
#include "Util/CommonFunctions.h"
|
||||||
#include "Core/PerformanceTimer.h"
|
#include "Core/PerformanceTimer.h"
|
||||||
#include "ShadowPass.h"
|
#include "ShadowPass.h"
|
||||||
|
#include "EResolutionChanged.h"
|
||||||
|
|
||||||
class Renderer : public IRenderer
|
class Renderer : public IRenderer
|
||||||
{
|
{
|
||||||
static void glfwFrameBufferCallback(GLFWwindow* window, int width, int height);
|
static void glfwFrameBufferCallback(GLFWwindow* window, int width, int height);
|
||||||
|
static void glfwWindowSizeCallback(GLFWwindow* window, int width, int height);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Renderer(EventBroker* eventBroker, ConfigFile* config)
|
Renderer(EventBroker* eventBroker, ConfigFile* config)
|
||||||
@@ -40,13 +42,14 @@ public:
|
|||||||
{ }
|
{ }
|
||||||
~Renderer();
|
~Renderer();
|
||||||
|
|
||||||
|
virtual void SetResolution(const Rectangle& resolution) override;
|
||||||
|
|
||||||
virtual void Initialize() override;
|
virtual void Initialize() override;
|
||||||
virtual void Update(double dt) override;
|
virtual void Update(double dt) override;
|
||||||
virtual void Draw(RenderFrame& frame) override;
|
virtual void Draw(RenderFrame& frame) override;
|
||||||
|
|
||||||
virtual PickData Pick(glm::vec2 screenCoord) override;
|
virtual PickData Pick(glm::vec2 screenCoord) override;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//----------------------Variables----------------------//
|
//----------------------Variables----------------------//
|
||||||
|
|
||||||
@@ -90,11 +93,14 @@ private:
|
|||||||
void InputUpdate(double dt);
|
void InputUpdate(double dt);
|
||||||
//void PickingPass(RenderQueueCollection& rq);
|
//void PickingPass(RenderQueueCollection& rq);
|
||||||
//void DrawScreenQuad(GLuint textureToDraw);
|
//void DrawScreenQuad(GLuint textureToDraw);
|
||||||
|
void setWindowSize(Rectangle size);
|
||||||
|
void updateFramebufferSize();
|
||||||
|
|
||||||
static bool DepthSort(const std::shared_ptr<RenderJob> &i, const std::shared_ptr<RenderJob> &j) { return (i->Depth < j->Depth); }
|
static bool DepthSort(const std::shared_ptr<RenderJob> &i, const std::shared_ptr<RenderJob> &j) { return (i->Depth < j->Depth); }
|
||||||
void SortRenderJobsByDepth(RenderScene &scene);
|
void SortRenderJobsByDepth(RenderScene &scene);
|
||||||
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type);
|
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type);
|
||||||
//--------------------ShaderPrograms-------------------//
|
|
||||||
|
//--------------------ShaderPrograms-------------------//
|
||||||
ShaderProgram* m_BasicForwardProgram;
|
ShaderProgram* m_BasicForwardProgram;
|
||||||
ShaderProgram* m_ExplosionEffectProgram;
|
ShaderProgram* m_ExplosionEffectProgram;
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,11 @@ inline bool _GLERROR(const char* info, const char* file, const char* func, unsig
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef DEBUG
|
||||||
#define GLERROR(function) \
|
#define GLERROR(function) \
|
||||||
_GLERROR(function, __BASE_FILE__, __func__, __LINE__)
|
_GLERROR(function, __BASE_FILE__, __func__, __LINE__)
|
||||||
|
#else
|
||||||
|
#define GLERROR(function) false
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -29,6 +29,7 @@
|
|||||||
#include "Network/Network.h"
|
#include "Network/Network.h"
|
||||||
#include "Network/Server.h"
|
#include "Network/Server.h"
|
||||||
#include "Network/Client.h"
|
#include "Network/Client.h"
|
||||||
|
#include "Network/EBecomeServerOrClient.h"
|
||||||
|
|
||||||
// Sound
|
// Sound
|
||||||
#include "Sound/SoundManager.h"
|
#include "Sound/SoundManager.h"
|
||||||
@@ -70,6 +71,11 @@ private:
|
|||||||
bool m_IsServer = false;
|
bool m_IsServer = false;
|
||||||
|
|
||||||
int parseArgs(int argc, char* argv[]);
|
int parseArgs(int argc, char* argv[]);
|
||||||
|
|
||||||
|
EventRelay<Game, Events::BecomeServer> m_EBecomeServer;
|
||||||
|
bool OnBecomeServer(const Events::BecomeServer& e);
|
||||||
|
EventRelay<Game, Events::BecomeClient> m_EBecomeClient;
|
||||||
|
bool OnBecomeClient(const Events::BecomeClient& e);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "Core/System.h"
|
#include "Core/System.h"
|
||||||
#include "Engine/GLM.h"
|
|
||||||
|
|
||||||
class ExplosionEffectSystem : public PureSystem
|
class ExplosionEffectSystem : public PureSystem
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "Input/EInputCommand.h"
|
#include "Input/EInputCommand.h"
|
||||||
#include "Network/ESearchForServers.h"
|
#include "Network/ESearchForServers.h"
|
||||||
#include "Network/EConnectRequest.h"
|
#include "Network/EConnectRequest.h"
|
||||||
|
#include "Network/EBecomeServerOrClient.h"
|
||||||
|
|
||||||
|
|
||||||
class MainMenuSystem : public ImpureSystem
|
class MainMenuSystem : public ImpureSystem
|
||||||
|
|||||||
@@ -1,21 +1,19 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
<ExplosionEffect xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ExplosionEffect.xsd">
|
<ExplosionEffect xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ExplosionEffect.xsd">
|
||||||
<ExplosionOrigin X="0" Y="0" Z="0"/>
|
<ExplosionOrigin X="0" Y="0" Z="0"/>
|
||||||
<TimeSinceDeath>0.0</TimeSinceDeath>
|
<TimeSinceDeath>0</TimeSinceDeath>
|
||||||
<ExplosionDuration>2.0</ExplosionDuration>
|
<ExplosionDuration>2</ExplosionDuration>
|
||||||
<Speed>1</Speed>
|
<Speed>1</Speed>
|
||||||
<Delay>0</Delay>
|
<Delay>0</Delay>
|
||||||
<!--<Gravity>1</Gravity>-->
|
<!--<Gravity>1</Gravity>-->
|
||||||
<!--<GravityForce>1</GravityForce>-->
|
<!--<GravityForce>1</GravityForce>-->
|
||||||
<!--<ObjectRadius>2</ObjectRadius>-->
|
<!--<ObjectRadius>2</ObjectRadius>-->
|
||||||
<EndColor R="0" G="0" B="0" A="0"/>
|
<EndColor R="0" G="0" B="0" A="0"/>
|
||||||
<Randomness>false</Randomness>
|
<Randomness>0</Randomness>
|
||||||
<RandomnessScalar>1.0</RandomnessScalar>
|
<RandomnessScalar>1</RandomnessScalar>
|
||||||
<Velocity X="2" Y="2"/>
|
<Velocity X="2" Y="2"/>
|
||||||
<ColorByDistance>false</ColorByDistance>
|
<ColorByDistance>0</ColorByDistance>
|
||||||
|
<!--<ReverseAnimation>0</ReverseAnimation>-->
|
||||||
<!--<Wireframe>0</Wireframe>-->
|
<!--<Wireframe>0</Wireframe>-->
|
||||||
<ExponentialAccelaration>false</ExponentialAccelaration>
|
<ExponentialAccelaration>0</ExponentialAccelaration>
|
||||||
<Pulsate>false</Pulsate>
|
|
||||||
<Reverse>false</Reverse>
|
|
||||||
<ColorDistanceScalar>1.0</ColorDistanceScalar>
|
|
||||||
</ExplosionEffect>
|
</ExplosionEffect>
|
||||||
@@ -44,21 +44,15 @@
|
|||||||
<xs:element name="ColorByDistance" type="t:bool" minOccurs="0">
|
<xs:element name="ColorByDistance" type="t:bool" minOccurs="0">
|
||||||
<xs:annotation><xs:documentation>Change the color by its moved distance instead of by its time</xs:documentation></xs:annotation>
|
<xs:annotation><xs:documentation>Change the color by its moved distance instead of by its time</xs:documentation></xs:annotation>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
<!--<xs:element name="ReverseAnimation" type="t:bool" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>Implosions are cooler</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>-->
|
||||||
<!--<xs:element name="Wireframe" type="t:bool" minOccurs="0">
|
<!--<xs:element name="Wireframe" type="t:bool" minOccurs="0">
|
||||||
<xs:annotation><xs:documentation>Enable/disable wireframe</xs:documentation></xs:annotation>
|
<xs:annotation><xs:documentation>Enable/disable wireframe</xs:documentation></xs:annotation>
|
||||||
</xs:element>-->
|
</xs:element>-->
|
||||||
<xs:element name="ExponentialAccelaration" type="t:bool" minOccurs="0">
|
<xs:element name="ExponentialAccelaration" type="t:bool" minOccurs="0">
|
||||||
<xs:annotation><xs:documentation>Linear/Exponential accelaration</xs:documentation></xs:annotation>
|
<xs:annotation><xs:documentation>Linear/Exponential accelaration</xs:documentation></xs:annotation>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
<xs:element name="Pulsate" type="t:bool" minOccurs="0">
|
|
||||||
<xs:annotation><xs:documentation>Pulsate the effect</xs:documentation></xs:annotation>
|
|
||||||
</xs:element>
|
|
||||||
<xs:element name="Reverse" type="t:bool" minOccurs="0">
|
|
||||||
<xs:annotation><xs:documentation>Reverse the effect</xs:documentation></xs:annotation>
|
|
||||||
</xs:element>
|
|
||||||
<xs:element name="ColorDistanceScalar" type="t:double" minOccurs="0">
|
|
||||||
<xs:annotation><xs:documentation>Scale the distance of the color change</xs:documentation></xs:annotation>
|
|
||||||
</xs:element>
|
|
||||||
</xs:all>
|
</xs:all>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
|||||||
@@ -319,23 +319,80 @@
|
|||||||
</Entity>
|
</Entity>
|
||||||
</Children>
|
</Children>
|
||||||
</Entity>
|
</Entity>
|
||||||
</Children>
|
<Entity name="ButtonPos_5">
|
||||||
</Entity>
|
|
||||||
<Entity name="Popup_Origin">
|
|
||||||
<Components>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="-0.103822395" Y="0" Z="0"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children>
|
|
||||||
<Entity name="PlaySpawner">
|
|
||||||
<Components>
|
<Components>
|
||||||
<c:Spawner>
|
<c:Transform>
|
||||||
<EntityFile>Schema/Entities/ServerList.xml</EntityFile>
|
<Position X="0" Y="-0.280000001" Z="0"/>
|
||||||
</c:Spawner>
|
</c:Transform>
|
||||||
<c:Transform/>
|
|
||||||
</Components>
|
</Components>
|
||||||
<Children/>
|
<Children>
|
||||||
|
<Entity name="Button_5">
|
||||||
|
<Components>
|
||||||
|
<c:Button/>
|
||||||
|
<c:Sprite>
|
||||||
|
<DiffuseTexture>Textures/Core/White.png</DiffuseTexture>
|
||||||
|
<BlurBackground>true</BlurBackground>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
<DepthSort>false</DepthSort>
|
||||||
|
<Color A="0.392156869" B="0" G="0" R="0"/>
|
||||||
|
</c:Sprite>
|
||||||
|
<c:Transform>
|
||||||
|
<Scale X="0.200000003" Y="0.0500000007" Z="1"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="Text">
|
||||||
|
<Components>
|
||||||
|
<c:Text>
|
||||||
|
<Content>Host</Content>
|
||||||
|
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||||
|
<Alignment>
|
||||||
|
<Right/>
|
||||||
|
</Alignment>
|
||||||
|
</c:Text>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.0920000002" Y="-0.0150000006" Z="0.00499999989"/>
|
||||||
|
<Scale X="0.0199999996" Y="0.0199999996" Z="1"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="ButtonCorner_Origin">
|
||||||
|
<Components>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity name="TopRight">
|
||||||
|
<Components>
|
||||||
|
<c:Sprite>
|
||||||
|
<DiffuseTexture>Textures/HUD/ButtonCorner_16.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
</c:Sprite>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.0970000029" Y="0.0220000017" Z="0.00499999989"/>
|
||||||
|
<Scale X="0.00499999989" Y="0.00499999989" Z="1"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="BottomRight">
|
||||||
|
<Components>
|
||||||
|
<c:Sprite>
|
||||||
|
<DiffuseTexture>Textures/HUD/ButtonCorner_16.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
</c:Sprite>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0.0970000029" Y="-0.0219999999" Z="0.00499999989"/>
|
||||||
|
<Orientation X="0" Y="0" Z="4.71199989"/>
|
||||||
|
<Scale X="0.00499999989" Y="0.00499999989" Z="1"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
</Entity>
|
</Entity>
|
||||||
</Children>
|
</Children>
|
||||||
</Entity>
|
</Entity>
|
||||||
|
|||||||
+6087
-6008
File diff suppressed because it is too large
Load Diff
@@ -15,11 +15,6 @@ uniform float RandomnessScalar;
|
|||||||
uniform vec2 Velocity;
|
uniform vec2 Velocity;
|
||||||
uniform bool ColorByDistance;
|
uniform bool ColorByDistance;
|
||||||
uniform bool ExponentialAccelaration;
|
uniform bool ExponentialAccelaration;
|
||||||
uniform bool Reverse;
|
|
||||||
uniform float ColorDistanceScalar;
|
|
||||||
//uniform bool Gravity;
|
|
||||||
//uniform bool Rotation;
|
|
||||||
//uniform bool MaxRadius;
|
|
||||||
|
|
||||||
in VertexData{
|
in VertexData{
|
||||||
vec3 Position;
|
vec3 Position;
|
||||||
@@ -46,43 +41,32 @@ out VertexData{
|
|||||||
layout(triangles) in;
|
layout(triangles) in;
|
||||||
layout(triangle_strip, max_vertices = 3) out;
|
layout(triangle_strip, max_vertices = 3) out;
|
||||||
|
|
||||||
float EqualTo(float x, float y) {
|
|
||||||
return 1.0 - abs(sign(x - y));
|
|
||||||
}
|
|
||||||
|
|
||||||
float NotEqualTo(float x, float y) {
|
|
||||||
return abs(sign(x - y));
|
|
||||||
}
|
|
||||||
|
|
||||||
float GreaterThan(float x, float y) {
|
|
||||||
return max(sign(x - y), 0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
float LessThan(float x, float y) {
|
|
||||||
return max(sign(y - x), 0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
float GreaterEqualTo(float x, float y) {
|
|
||||||
return 1.0 - LessThan(x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
float LessEqualTo(float x, float y) {
|
|
||||||
return 1.0 - GreaterThan(x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
// returns a "random" number based on input parameter
|
// returns a "random" number based on input parameter
|
||||||
float GetRandomNumber(int polygon_index)
|
float GetRandomNumber(int polygon_index)
|
||||||
{
|
{
|
||||||
return RandomNumbers[int(mod(polygon_index, 50))];
|
int randomIndex = int(mod(polygon_index, 50));
|
||||||
|
|
||||||
|
return RandomNumbers[randomIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 CalcCenterOfTriangle(vec3 vertex0, vec3 vertex1, vec3 vertex2)
|
float randomNumber = 0.0;
|
||||||
|
float randomDistance = 0.0;
|
||||||
|
|
||||||
|
void main()
|
||||||
{
|
{
|
||||||
// calculate middle of vectors
|
// calculate middle of vectors
|
||||||
vec3 dir1 = normalize(vertex1 - vertex0);
|
vec3 v1 = Input[1].Position - Input[0].Position;
|
||||||
vec3 dir2 = normalize(vertex2 - vertex0);
|
vec3 v2 = Input[2].Position - Input[0].Position;
|
||||||
|
vec3 v3 = Input[2].Position - (v1 / 2);
|
||||||
|
vec3 v4 = Input[1].Position - (v2 / 2);
|
||||||
|
|
||||||
vec3 vecA = vertex2 - vertex1; //o2 - o1
|
// calculate intersection
|
||||||
|
|
||||||
|
// normalize direction
|
||||||
|
vec3 dir1 = normalize(v1);
|
||||||
|
vec3 dir2 = normalize(v2);
|
||||||
|
|
||||||
|
vec3 vecA = Input[2].Position - Input[1].Position; //o2 - o1
|
||||||
vec3 vecB = cross(dir1, dir2);
|
vec3 vecB = cross(dir1, dir2);
|
||||||
|
|
||||||
mat3 matrisA = mat3(vecA, dir2, vecB);
|
mat3 matrisA = mat3(vecA, dir2, vecB);
|
||||||
@@ -93,89 +77,133 @@ vec3 CalcCenterOfTriangle(vec3 vertex0, vec3 vertex1, vec3 vertex2)
|
|||||||
float s = determinant(matrisA) / lengthA;
|
float s = determinant(matrisA) / lengthA;
|
||||||
|
|
||||||
// center position of triangle
|
// center position of triangle
|
||||||
return vertex1 + (s * dir1);
|
vec3 centerOfTriangle = Input[1].Position + (s * dir1);
|
||||||
}
|
|
||||||
|
|
||||||
void PassThingsThrough(int index)
|
|
||||||
{
|
|
||||||
// pass through vertex data
|
|
||||||
Output.Normal = Input[index].Normal;
|
|
||||||
Output.Position = Input[index].Position;
|
|
||||||
Output.TextureCoordinate = Input[index].TextureCoordinate;
|
|
||||||
Output.Tangent = Input[index].Tangent;
|
|
||||||
Output.BiTangent = Input[index].BiTangent;
|
|
||||||
Output.ExplosionColor = EndColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
vec3 centerOfTriangle = CalcCenterOfTriangle(Input[0].Position, Input[1].Position, Input[2].Position);
|
|
||||||
|
|
||||||
// center position of triangle to origin vector
|
// center position of triangle to origin vector
|
||||||
vec3 origin2TriangleCenterVector = centerOfTriangle - ExplosionOrigin;
|
vec3 origin2TriangleCenterVector = centerOfTriangle - ExplosionOrigin;
|
||||||
vec3 normalizedOrigin2TriangleCenterVector = normalize(origin2TriangleCenterVector);
|
vec3 normalizedOrigin2TriangleCenterVector = normalize(origin2TriangleCenterVector);
|
||||||
|
|
||||||
// distance between origin and the center of the current triangle
|
|
||||||
float origin2TriangleCenterDistance = length(origin2TriangleCenterVector);
|
|
||||||
|
|
||||||
// time percentage until end of explosion (0.0-1.0)
|
// time percentage until end of explosion (0.0-1.0)
|
||||||
float timePercetage = TimeSinceDeath / ExplosionDuration;
|
float timePercetage = TimeSinceDeath / ExplosionDuration;
|
||||||
|
|
||||||
// get a random number if randomness is enabled, otherwise the random distance will be zero and won't affect the other algorithms
|
// get a random number if randomness is enabled, otherwise the random number will be zero and won't affect the other algorithms
|
||||||
float randomDistance = float(Randomness) * GetRandomNumber(gl_PrimitiveIDIn) * RandomnessScalar;
|
if (Randomness == true)
|
||||||
|
{
|
||||||
|
randomDistance = GetRandomNumber(gl_PrimitiveIDIn) * RandomnessScalar;
|
||||||
|
}
|
||||||
|
|
||||||
vec2 randomVelocity = Velocity * (randomDistance + 1.0);
|
vec2 randomVelocity = Velocity * (randomDistance + 1.0);
|
||||||
|
|
||||||
// accelaration to use on current frame. is a interpolation between start and end value
|
// accelaration to use on current frame. is a interpolation between start and end value
|
||||||
float currentVelocity = mix(randomVelocity.x, randomVelocity.y, timePercetage);
|
float currentVelocity = mix(randomVelocity.x, randomVelocity.y, timePercetage);
|
||||||
|
|
||||||
// if the accelaration should be exponential
|
if (ExponentialAccelaration == true)
|
||||||
currentVelocity = currentVelocity * max(currentVelocity * float(ExponentialAccelaration), 1.0);
|
{
|
||||||
|
currentVelocity = pow(currentVelocity, 2) / 2.0;
|
||||||
|
}
|
||||||
|
|
||||||
// the distance the blast has moved since the beginning, i.e. its radius
|
// distance between origin and the center of the current triangle
|
||||||
float blastWave = TimeSinceDeath * currentVelocity;
|
float origin2TriangleCenterDistance = length(origin2TriangleCenterVector);
|
||||||
|
|
||||||
// the distance from origin to the triangle center with eventual randomness added
|
// the distance from origin to the triangle center with eventual randomness added
|
||||||
float origin2TriangleCenterDistanceWithRandomness = origin2TriangleCenterDistance + randomDistance;
|
float fullDistanceWithRandomness = origin2TriangleCenterDistance + randomDistance;
|
||||||
|
|
||||||
vec3 triangleCenter2ExplosionRadius = (normalizedOrigin2TriangleCenterVector * blastWave) - (normalizedOrigin2TriangleCenterVector * origin2TriangleCenterDistanceWithRandomness);
|
// vector from the triangle center to the explosion's shockwave
|
||||||
|
vec3 triangleCenter2ExplosionRadius = (normalizedOrigin2TriangleCenterVector * (TimeSinceDeath * currentVelocity)) - (normalizedOrigin2TriangleCenterVector * fullDistanceWithRandomness);
|
||||||
|
|
||||||
// if the triangle is inside the blast's radius...
|
// if the triangle is inside the blast radius...
|
||||||
float isInsideBlastRadius = LessEqualTo(origin2TriangleCenterDistanceWithRandomness, blastWave);
|
if (fullDistanceWithRandomness <= (TimeSinceDeath * currentVelocity))
|
||||||
|
|
||||||
// calculate the max distance (s) the triangle will move
|
|
||||||
float accelaration = (randomVelocity.y - randomVelocity.x) / ExplosionDuration;
|
|
||||||
float maxDistance = (randomVelocity.x * ExplosionDuration) + (0.5 * accelaration * ExplosionDuration * ExplosionDuration);
|
|
||||||
|
|
||||||
// if explosion color should be affected by distance instead of time...
|
|
||||||
if (ColorByDistance == true)
|
|
||||||
{
|
{
|
||||||
Output.ExplosionPercentageElapsed = (length(triangleCenter2ExplosionRadius) / maxDistance) * isInsideBlastRadius * ColorDistanceScalar;
|
float maxRadius = max(TimeSinceDeath * currentVelocity, (ExplosionDuration * currentVelocity));
|
||||||
|
|
||||||
|
float a = (randomVelocity.y - randomVelocity.x) / ExplosionDuration;
|
||||||
|
//float t = sqrt((2 * origin2TriangleCenterDistance) / a);
|
||||||
|
|
||||||
|
// if explosion color should be affected by distance instead of time...
|
||||||
|
if (ColorByDistance == true)
|
||||||
|
{
|
||||||
|
// calculate the max distance (s) the triangle will move
|
||||||
|
float s = (randomVelocity.x * ExplosionDuration) + (0.5 * a * pow(ExplosionDuration, 2));
|
||||||
|
float te = (length(triangleCenter2ExplosionRadius) / s);
|
||||||
|
|
||||||
|
Output.ExplosionColor = EndColor;
|
||||||
|
Output.ExplosionPercentageElapsed = te;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Output.ExplosionColor = EndColor;
|
||||||
|
Output.ExplosionPercentageElapsed = timePercetage;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// for every vertex on the triangle...
|
||||||
|
for (int i = 0; i < gl_in.length(); i++)
|
||||||
|
{
|
||||||
|
// move the triangle to the blast radius
|
||||||
|
vec3 ExplodedPosition = Input[i].Position + triangleCenter2ExplosionRadius;
|
||||||
|
|
||||||
|
// pass through vertex data
|
||||||
|
Output.Normal = Input[i].Normal;
|
||||||
|
Output.Position = Input[i].Position;
|
||||||
|
Output.TextureCoordinate = Input[i].TextureCoordinate;
|
||||||
|
Output.Tangent = Input[i].Tangent;
|
||||||
|
Output.BiTangent = Input[i].BiTangent;
|
||||||
|
for (int j = 0; j < MAX_SPLITS; j++)
|
||||||
|
{
|
||||||
|
Output.PositionLightSpace[j] = Input[i].PositionLightSpace[j];
|
||||||
|
}
|
||||||
|
|
||||||
|
// convert to model space for the gravity to always be in -y
|
||||||
|
vec4 ExplodedPositionInModelSpace = M * vec4(ExplodedPosition, 1.0);
|
||||||
|
|
||||||
|
// if there is gravity, apply it
|
||||||
|
//if (Gravity == true)
|
||||||
|
//{
|
||||||
|
// // ---DO THIS----> //ExplodedPositionInModelSpace.y = ExplodedPositionInModelSpace.y - TimeSinceHit;
|
||||||
|
//
|
||||||
|
// ExplodedPositionInModelSpace.y = ExplodedPositionInModelSpace.y - pow(TimeSinceDeath, 2);
|
||||||
|
//}
|
||||||
|
|
||||||
|
// convert to screen space
|
||||||
|
gl_Position = P*V * ExplodedPositionInModelSpace;
|
||||||
|
EmitVertex();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Output.ExplosionPercentageElapsed = timePercetage;
|
// if explosion color should be affected by distance instead of time...
|
||||||
}
|
if (ColorByDistance == true)
|
||||||
|
{
|
||||||
|
Output.ExplosionColor = EndColor;
|
||||||
|
Output.ExplosionPercentageElapsed = 0.0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Output.ExplosionColor = EndColor;
|
||||||
|
Output.ExplosionPercentageElapsed = timePercetage;
|
||||||
|
|
||||||
vec3 ExplodedPosition;
|
}
|
||||||
for (int i = 0; i < gl_in.length(); i++)
|
|
||||||
{
|
|
||||||
// move the triangle to the blast radius
|
|
||||||
ExplodedPosition = Input[i].Position + (triangleCenter2ExplosionRadius * isInsideBlastRadius);
|
|
||||||
|
|
||||||
// pass through vertex data
|
// for every vertex on the triangle...
|
||||||
PassThingsThrough(i);
|
for(int i = 0; i < gl_in.length(); i++)
|
||||||
for (int j = 0; j < MAX_SPLITS; j++)
|
{
|
||||||
{
|
// pass through vertex data
|
||||||
Output.PositionLightSpace[j] = Input[i].PositionLightSpace[j];
|
Output.Normal = Input[i].Normal;
|
||||||
}
|
Output.Position = Input[i].Position;
|
||||||
|
Output.TextureCoordinate = Input[i].TextureCoordinate;
|
||||||
|
Output.Tangent = Input[i].Tangent;
|
||||||
|
Output.BiTangent = Input[i].BiTangent;
|
||||||
for (int j = 0; j < MAX_SPLITS; j++)
|
for (int j = 0; j < MAX_SPLITS; j++)
|
||||||
{
|
{
|
||||||
Output.PositionLightSpace[j] = Input[i].PositionLightSpace[j];
|
Output.PositionLightSpace[j] = Input[i].PositionLightSpace[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert to window space
|
// no change in position, pass through vertex
|
||||||
gl_Position = P * V * M * vec4(ExplodedPosition, 1.0);
|
gl_Position = gl_in[i].gl_Position;
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//EndPrimitive();
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,8 @@ Server::Server(World* world, EventBroker* eventBroker, int port)
|
|||||||
port = config->Get<float>("Networking.Port", 27666);
|
port = config->Get<float>("Networking.Port", 27666);
|
||||||
}
|
}
|
||||||
m_Port = port;
|
m_Port = port;
|
||||||
LOG_INFO("Server initialized and bound to port %i", port);
|
printf("Server initialized and bound to port %i\n", port);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Server::~Server()
|
Server::~Server()
|
||||||
|
|||||||
@@ -1319,12 +1319,7 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<E
|
|||||||
|
|
||||||
glUniform3fv(glGetUniformLocation(shaderHandle, "ExplosionOrigin"), 1, glm::value_ptr(job->ExplosionOrigin));
|
glUniform3fv(glGetUniformLocation(shaderHandle, "ExplosionOrigin"), 1, glm::value_ptr(job->ExplosionOrigin));
|
||||||
GLERROR("Bind 6 uniform");
|
GLERROR("Bind 6 uniform");
|
||||||
if (job->Reverse == false) {
|
glUniform1f(glGetUniformLocation(shaderHandle, "TimeSinceDeath"), job->TimeSinceDeath);
|
||||||
glUniform1f(glGetUniformLocation(shaderHandle, "TimeSinceDeath"), job->TimeSinceDeath);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
glUniform1f(glGetUniformLocation(shaderHandle, "TimeSinceDeath"), (job->ExplosionDuration - job->TimeSinceDeath));
|
|
||||||
}
|
|
||||||
GLERROR("Bind 7 uniform");
|
GLERROR("Bind 7 uniform");
|
||||||
glUniform1f(glGetUniformLocation(shaderHandle, "ExplosionDuration"), job->ExplosionDuration);
|
glUniform1f(glGetUniformLocation(shaderHandle, "ExplosionDuration"), job->ExplosionDuration);
|
||||||
GLERROR("Bind 8 uniform");
|
GLERROR("Bind 8 uniform");
|
||||||
@@ -1342,10 +1337,6 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<E
|
|||||||
GLERROR("Bind 14 uniform");
|
GLERROR("Bind 14 uniform");
|
||||||
glUniform1i(glGetUniformLocation(shaderHandle, "ExponentialAccelaration"), job->ExponentialAccelaration);
|
glUniform1i(glGetUniformLocation(shaderHandle, "ExponentialAccelaration"), job->ExponentialAccelaration);
|
||||||
GLERROR("Bind 15 uniform");
|
GLERROR("Bind 15 uniform");
|
||||||
glUniform1i(glGetUniformLocation(shaderHandle, "Reverse"), job->Reverse);
|
|
||||||
GLERROR("Bind 15-2 uniform");
|
|
||||||
glUniform1f(glGetUniformLocation(shaderHandle, "ColorDistanceScalar"), job->ColorDistanceScalar);
|
|
||||||
GLERROR("Bind 15-3 uniform");
|
|
||||||
|
|
||||||
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color));
|
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color));
|
||||||
GLERROR("Bind 16 uniform");
|
GLERROR("Bind 16 uniform");
|
||||||
|
|||||||
@@ -42,6 +42,15 @@ void LightCullingPass::SetSSBOSizes()
|
|||||||
{
|
{
|
||||||
m_NumberOfTiles = (int)(m_Renderer->GetViewportSize().Width/TILE_SIZE) * (int)(m_Renderer->GetViewportSize().Height/TILE_SIZE);
|
m_NumberOfTiles = (int)(m_Renderer->GetViewportSize().Width/TILE_SIZE) * (int)(m_Renderer->GetViewportSize().Height/TILE_SIZE);
|
||||||
|
|
||||||
|
if (m_Frustums != nullptr) {
|
||||||
|
delete[] m_Frustums;
|
||||||
|
}
|
||||||
|
if (m_LightGrid != nullptr) {
|
||||||
|
delete[] m_LightGrid;
|
||||||
|
}
|
||||||
|
if (m_LightIndex != nullptr) {
|
||||||
|
delete[] m_LightIndex;
|
||||||
|
}
|
||||||
m_Frustums = new Frustum[m_NumberOfTiles];
|
m_Frustums = new Frustum[m_NumberOfTiles];
|
||||||
m_LightGrid = new LightGrid[m_NumberOfTiles];
|
m_LightGrid = new LightGrid[m_NumberOfTiles];
|
||||||
m_LightIndex = new float[m_NumberOfTiles*MAX_LIGHTS_PER_TILE];
|
m_LightIndex = new float[m_NumberOfTiles*MAX_LIGHTS_PER_TILE];
|
||||||
|
|||||||
@@ -9,10 +9,11 @@ RenderSystem::RenderSystem(SystemParams params, const IRenderer* renderer, Rende
|
|||||||
, m_Octree(frustumCullOctree)
|
, m_Octree(frustumCullOctree)
|
||||||
{
|
{
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &RenderSystem::OnSetCamera);
|
EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &RenderSystem::OnSetCamera);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EResolutionChanged, &RenderSystem::OnResolutionChanged);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &RenderSystem::OnInputCommand);
|
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &RenderSystem::OnInputCommand);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &RenderSystem::OnPlayerSpawned);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &RenderSystem::OnPlayerSpawned);
|
||||||
|
|
||||||
m_Camera = new Camera((float)m_Renderer->Resolution().Width / m_Renderer->Resolution().Height, glm::radians(45.f), 0.01f, 5000.f);
|
m_Camera = new Camera((float)m_Renderer->GetViewportSize().Width / m_Renderer->GetViewportSize().Height, glm::radians(45.f), 0.01f, 5000.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderSystem::~RenderSystem()
|
RenderSystem::~RenderSystem()
|
||||||
@@ -20,6 +21,13 @@ RenderSystem::~RenderSystem()
|
|||||||
delete m_Camera;
|
delete m_Camera;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RenderSystem::OnResolutionChanged(Events::ResolutionChanged& e)
|
||||||
|
{
|
||||||
|
// Update camera aspect ration on resolution change
|
||||||
|
m_Camera->SetAspectRatio((float)e.NewResolution.Width / e.NewResolution.Height);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool RenderSystem::OnSetCamera(Events::SetCamera& e)
|
bool RenderSystem::OnSetCamera(Events::SetCamera& e)
|
||||||
{
|
{
|
||||||
ComponentWrapper cTransform = e.CameraEntity["Transform"];
|
ComponentWrapper cTransform = e.CameraEntity["Transform"];
|
||||||
|
|||||||
@@ -36,16 +36,24 @@ void Renderer::Initialize()
|
|||||||
m_ImGuiRenderPass = new ImGuiRenderPass(this, m_EventBroker);
|
m_ImGuiRenderPass = new ImGuiRenderPass(this, m_EventBroker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer::glfwWindowSizeCallback(GLFWwindow* window, int width, int height)
|
||||||
|
{
|
||||||
|
m_WindowToRenderer[window]->setWindowSize(Rectangle(width, height));
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::glfwFrameBufferCallback(GLFWwindow* window, int width, int height)
|
void Renderer::glfwFrameBufferCallback(GLFWwindow* window, int width, int height)
|
||||||
{
|
{
|
||||||
glViewport(0, 0, width, height);
|
m_WindowToRenderer[window]->updateFramebufferSize();
|
||||||
Renderer* currentRenderer = m_WindowToRenderer[window];
|
}
|
||||||
currentRenderer->m_ViewportSize = Rectangle(width, height);
|
|
||||||
currentRenderer->m_PickingPass->OnWindowResize();
|
void Renderer::SetResolution(const Rectangle& resolution)
|
||||||
currentRenderer->m_DrawFinalPass->OnWindowResize();
|
{
|
||||||
currentRenderer->m_LightCullingPass->OnWindowResize();
|
m_Resolution = resolution;
|
||||||
currentRenderer->m_DrawBloomPass->OnWindowResize();
|
|
||||||
currentRenderer->m_SSAOPass->OnWindowResize();
|
if (m_Window != nullptr) {
|
||||||
|
setWindowSize(resolution);
|
||||||
|
updateFramebufferSize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::InitializeWindow()
|
void Renderer::InitializeWindow()
|
||||||
@@ -67,6 +75,7 @@ void Renderer::InitializeWindow()
|
|||||||
LOG_ERROR("GLFW: Failed to create window");
|
LOG_ERROR("GLFW: Failed to create window");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
glfwSetWindowSizeCallback(m_Window, &glfwWindowSizeCallback);
|
||||||
glfwSetFramebufferSizeCallback(m_Window, &glfwFrameBufferCallback);
|
glfwSetFramebufferSizeCallback(m_Window, &glfwFrameBufferCallback);
|
||||||
glfwMakeContextCurrent(m_Window);
|
glfwMakeContextCurrent(m_Window);
|
||||||
|
|
||||||
@@ -111,6 +120,30 @@ void Renderer::InputUpdate(double dt)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer::setWindowSize(Rectangle size)
|
||||||
|
{
|
||||||
|
glfwSetWindowSize(m_Window, size.Width, size.Height);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::updateFramebufferSize()
|
||||||
|
{
|
||||||
|
Events::ResolutionChanged e;
|
||||||
|
e.OldResolution = m_ViewportSize;
|
||||||
|
|
||||||
|
int width, height;
|
||||||
|
glfwGetFramebufferSize(m_Window, &width, &height);
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
m_ViewportSize = Rectangle(width, height);
|
||||||
|
m_PickingPass->OnWindowResize();
|
||||||
|
m_DrawFinalPass->OnWindowResize();
|
||||||
|
m_LightCullingPass->OnWindowResize();
|
||||||
|
m_DrawBloomPass->OnWindowResize();
|
||||||
|
m_SSAOPass->OnWindowResize();
|
||||||
|
|
||||||
|
e.NewResolution = m_ViewportSize;
|
||||||
|
m_EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::Update(double dt)
|
void Renderer::Update(double dt)
|
||||||
{
|
{
|
||||||
m_EventBroker->Process<Renderer>();
|
m_EventBroker->Process<Renderer>();
|
||||||
@@ -263,6 +296,7 @@ void Renderer::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filterin
|
|||||||
GLERROR("Texture initialization failed");
|
GLERROR("Texture initialization failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Renderer::InitializeRenderPasses()
|
void Renderer::InitializeRenderPasses()
|
||||||
{
|
{
|
||||||
m_PickingPass = new PickingPass(this, m_EventBroker);
|
m_PickingPass = new PickingPass(this, m_EventBroker);
|
||||||
|
|||||||
+44
-17
@@ -58,7 +58,6 @@ Game::Game(int argc, char* argv[])
|
|||||||
ResourceManager::RegisterType<EntityFile>("EntityFile");
|
ResourceManager::RegisterType<EntityFile>("EntityFile");
|
||||||
ResourceManager::RegisterType<EntityXMLFile>("EntityXMLFile");
|
ResourceManager::RegisterType<EntityXMLFile>("EntityXMLFile");
|
||||||
ResourceManager::RegisterType<Font>("FontFile");
|
ResourceManager::RegisterType<Font>("FontFile");
|
||||||
|
|
||||||
m_Config = ResourceManager::Load<ConfigFile>("Config.ini");
|
m_Config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||||
ResourceManager::UseThreading = m_Config->Get<bool>("Multithreading.ResourceLoading", true);
|
ResourceManager::UseThreading = m_Config->Get<bool>("Multithreading.ResourceLoading", true);
|
||||||
DisableMemoryPool::Value = m_Config->Get<bool>("Debug.DisableMemoryPool", false);
|
DisableMemoryPool::Value = m_Config->Get<bool>("Debug.DisableMemoryPool", false);
|
||||||
@@ -66,6 +65,8 @@ Game::Game(int argc, char* argv[])
|
|||||||
|
|
||||||
// Create the core event broker
|
// Create the core event broker
|
||||||
m_EventBroker = new EventBroker();
|
m_EventBroker = new EventBroker();
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EBecomeServer, &Game::OnBecomeServer);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EBecomeClient, &Game::OnBecomeClient);
|
||||||
|
|
||||||
// Create the renderer
|
// Create the renderer
|
||||||
m_Renderer = new Renderer(m_EventBroker, m_Config);
|
m_Renderer = new Renderer(m_EventBroker, m_Config);
|
||||||
@@ -76,7 +77,7 @@ Game::Game(int argc, char* argv[])
|
|||||||
0,
|
0,
|
||||||
m_Config->Get<int>("Video.Width", 1280),
|
m_Config->Get<int>("Video.Width", 1280),
|
||||||
m_Config->Get<int>("Video.Height", 720)
|
m_Config->Get<int>("Video.Height", 720)
|
||||||
));
|
));
|
||||||
m_Renderer->Initialize();
|
m_Renderer->Initialize();
|
||||||
//m_Renderer->Camera()->SetFOV(glm::radians(m_Config->Get<float>("Video.FOV", 90.f)));
|
//m_Renderer->Camera()->SetFOV(glm::radians(m_Config->Get<float>("Video.FOV", 90.f)));
|
||||||
m_RenderFrame = new RenderFrame();
|
m_RenderFrame = new RenderFrame();
|
||||||
@@ -99,21 +100,7 @@ Game::Game(int argc, char* argv[])
|
|||||||
// Create the sound manager
|
// Create the sound manager
|
||||||
m_SoundManager = new SoundManager(m_World, m_EventBroker);
|
m_SoundManager = new SoundManager(m_World, m_EventBroker);
|
||||||
|
|
||||||
// Initialize network
|
|
||||||
if (m_Config->Get<bool>("Networking.StartNetwork", false)) {
|
|
||||||
if (m_IsServer) {
|
|
||||||
m_NetworkServer = new Server(m_World, m_EventBroker, m_NetworkPort);
|
|
||||||
m_Renderer->SetWindowTitle(m_Renderer->WindowTitle() + " SERVER");
|
|
||||||
} else if (m_IsClient) {
|
|
||||||
m_NetworkClient = new Client(m_World, m_EventBroker, std::make_unique<MultiplayerSnapshotFilter>(m_EventBroker));
|
|
||||||
m_NetworkClient->Connect(m_NetworkAddress, m_NetworkPort);
|
|
||||||
m_Renderer->SetWindowTitle(m_Renderer->WindowTitle() + " CLIENT");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// If network is disabled, pretend we're a server
|
|
||||||
m_IsClient = true;
|
|
||||||
m_IsServer = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create Octrees
|
// Create Octrees
|
||||||
// TODO: Perhaps the world bounds should be set in some non-arbitrary way instead of this.
|
// TODO: Perhaps the world bounds should be set in some non-arbitrary way instead of this.
|
||||||
@@ -188,6 +175,8 @@ Game::~Game()
|
|||||||
delete m_OctreeCollision;
|
delete m_OctreeCollision;
|
||||||
delete m_OctreeTrigger;
|
delete m_OctreeTrigger;
|
||||||
delete m_SoundManager;
|
delete m_SoundManager;
|
||||||
|
m_EventBroker->Unsubscribe(m_EBecomeServer);
|
||||||
|
m_EventBroker->Unsubscribe(m_EBecomeClient);
|
||||||
if (m_NetworkClient != nullptr) {
|
if (m_NetworkClient != nullptr) {
|
||||||
delete m_NetworkClient;
|
delete m_NetworkClient;
|
||||||
}
|
}
|
||||||
@@ -210,6 +199,7 @@ void Game::Tick()
|
|||||||
double dt = currentTime - m_LastTime;
|
double dt = currentTime - m_LastTime;
|
||||||
m_LastTime = currentTime;
|
m_LastTime = currentTime;
|
||||||
|
|
||||||
|
m_EventBroker->Process<Game>();
|
||||||
// Handle input in a weird looking but responsive way
|
// Handle input in a weird looking but responsive way
|
||||||
m_EventBroker->Process<InputManager>();
|
m_EventBroker->Process<InputManager>();
|
||||||
m_EventBroker->Swap();
|
m_EventBroker->Swap();
|
||||||
@@ -284,3 +274,40 @@ int Game::parseArgs(int argc, char* argv[])
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Game::OnBecomeServer(const Events::BecomeServer& e)
|
||||||
|
{
|
||||||
|
|
||||||
|
// if (m_IsServer) {
|
||||||
|
// m_NetworkServer = new Server(m_World, m_EventBroker, m_NetworkPort);
|
||||||
|
// m_Renderer->SetWindowTitle(m_Renderer->WindowTitle() + " SERVER");
|
||||||
|
// } else if (m_IsClient) {
|
||||||
|
// m_NetworkClient = new Client(m_World, m_EventBroker, std::make_unique<MultiplayerSnapshotFilter>(m_EventBroker));
|
||||||
|
// m_NetworkClient->Connect(m_NetworkAddress, m_NetworkPort);
|
||||||
|
// m_Renderer->SetWindowTitle(m_Renderer->WindowTitle() + " CLIENT");
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (m_NetworkServer != nullptr) {
|
||||||
|
delete m_NetworkServer;
|
||||||
|
}
|
||||||
|
if (m_NetworkClient != nullptr) {
|
||||||
|
delete m_NetworkClient;
|
||||||
|
}
|
||||||
|
m_NetworkServer = new Server(m_World, m_EventBroker, m_NetworkPort);
|
||||||
|
m_Renderer->SetWindowTitle(m_Renderer->WindowTitle() + " SERVER");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Game::OnBecomeClient(const Events::BecomeClient& e)
|
||||||
|
{
|
||||||
|
if (m_NetworkServer != nullptr) {
|
||||||
|
delete m_NetworkServer;
|
||||||
|
}
|
||||||
|
if (m_NetworkClient != nullptr) {
|
||||||
|
delete m_NetworkClient;
|
||||||
|
}
|
||||||
|
m_NetworkClient = new Client(m_World, m_EventBroker, std::make_unique<MultiplayerSnapshotFilter>(m_EventBroker));
|
||||||
|
m_NetworkClient->Connect(m_NetworkAddress, m_NetworkPort);
|
||||||
|
m_Renderer->SetWindowTitle(m_Renderer->WindowTitle() + " CLIENT");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,15 +7,12 @@ void ExplosionEffectSystem::UpdateComponent(EntityWrapper& entity, ComponentWrap
|
|||||||
delay = std::max(0.0, delay - dt);
|
delay = std::max(0.0, delay - dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (delay <= 0) {
|
if (delay <= 0) {
|
||||||
double& timeSinceDeath = component["TimeSinceDeath"];
|
double& timeSinceDeath = component["TimeSinceDeath"];
|
||||||
timeSinceDeath += (double)component["Speed"] * dt;
|
timeSinceDeath += (double)component["Speed"] * dt;
|
||||||
if (timeSinceDeath < 0) {
|
if (timeSinceDeath < 0 || timeSinceDeath > (double)component["ExplosionDuration"]) {
|
||||||
timeSinceDeath = 0.0;
|
timeSinceDeath = 0.0;
|
||||||
}
|
}
|
||||||
else if (timeSinceDeath >(double)component["ExplosionDuration"]) {
|
}
|
||||||
timeSinceDeath = (double)component["ExplosionDuration"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ bool MainMenuSystem::OnButtonClick(const Events::ButtonClicked& e)
|
|||||||
if (e.EntityName == "ServerIdentityConnect") {
|
if (e.EntityName == "ServerIdentityConnect") {
|
||||||
EntityWrapper entity = e.Entity;
|
EntityWrapper entity = e.Entity;
|
||||||
EntityWrapper serverIdentityEntity = entity.FirstParentWithComponent("ServerIdentity");
|
EntityWrapper serverIdentityEntity = entity.FirstParentWithComponent("ServerIdentity");
|
||||||
if(serverIdentityEntity.Valid()) {
|
if (serverIdentityEntity.Valid()) {
|
||||||
Events::ConnectRequest event;
|
Events::ConnectRequest event;
|
||||||
event.IP = (std::string)serverIdentityEntity["ServerIdentity"]["IP"];
|
event.IP = (std::string)serverIdentityEntity["ServerIdentity"]["IP"];
|
||||||
event.Port = (int)serverIdentityEntity["ServerIdentity"]["Port"];
|
event.Port = (int)serverIdentityEntity["ServerIdentity"]["Port"];
|
||||||
@@ -44,7 +44,13 @@ bool MainMenuSystem::OnButtonPress(const Events::ButtonPressed& e)
|
|||||||
|
|
||||||
bool MainMenuSystem::OnInputCommand(const Events::InputCommand& e)
|
bool MainMenuSystem::OnInputCommand(const Events::InputCommand& e)
|
||||||
{
|
{
|
||||||
if(e.Command == "Play" && e.Value == 1) {
|
if (e.Command == "Host" && e.Value == 1) {
|
||||||
|
printf("Sending event...\n");
|
||||||
|
m_EventBroker->Publish(Events::BecomeServer());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (e.Command == "Play" && e.Value == 1) {
|
||||||
|
m_EventBroker->Publish(Events::BecomeClient());
|
||||||
auto menus = m_World->GetComponents("Menu");
|
auto menus = m_World->GetComponents("Menu");
|
||||||
if (menus == nullptr) {
|
if (menus == nullptr) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -64,7 +70,7 @@ bool MainMenuSystem::OnInputCommand(const Events::InputCommand& e)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if(!m_OpenSubMenu.HasComponent("ServerList")) {
|
} else if (!m_OpenSubMenu.HasComponent("ServerList")) {
|
||||||
//Menu is open, but not the right one, delete the old one and open a new one.
|
//Menu is open, but not the right one, delete the old one and open a new one.
|
||||||
m_World->DeleteEntity(m_OpenSubMenu.ID);
|
m_World->DeleteEntity(m_OpenSubMenu.ID);
|
||||||
m_OpenSubMenu = EntityWrapper::Invalid;
|
m_OpenSubMenu = EntityWrapper::Invalid;
|
||||||
@@ -85,7 +91,7 @@ bool MainMenuSystem::OnInputCommand(const Events::InputCommand& e)
|
|||||||
m_World->DeleteEntity(m_OpenSubMenu.ID);
|
m_World->DeleteEntity(m_OpenSubMenu.ID);
|
||||||
m_OpenSubMenu = EntityWrapper::Invalid;
|
m_OpenSubMenu = EntityWrapper::Invalid;
|
||||||
}
|
}
|
||||||
} else if (e.Command == "RefreshServerList" && e.Value == 1){
|
} else if (e.Command == "RefreshServerList" && e.Value == 1) {
|
||||||
Events::SearchForServers event;
|
Events::SearchForServers event;
|
||||||
m_EventBroker->Publish(event);
|
m_EventBroker->Publish(event);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user