Compare commits
58 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cedcffcf97 | |||
| da1c7b3093 | |||
| ef87102d1f | |||
| 9a41bda4cf | |||
| fc18932068 | |||
| b874ea8641 | |||
| 2609a0253d | |||
| de309d3b9d | |||
| f7ef6707a7 | |||
| feeff5b164 | |||
| 7394436e7a | |||
| f41e0b29be | |||
| 607e83134d | |||
| 5af4f9d8e7 | |||
| af68236e71 | |||
| 6f9ce8a0c1 | |||
| 6465fe6ed6 | |||
| e2831c5593 | |||
| 8d23c531af | |||
| 91b0ac5fbd | |||
| d77119bb2d | |||
| 27669b7383 | |||
| fc7d62a5ad | |||
| c42e1e0967 | |||
| fe9dbf0b0f | |||
| 4ffb03fdd5 | |||
| fe3e0bac5b | |||
| fa4f007604 | |||
| e5ff88d3c9 | |||
| 845a30ed0f | |||
| 833006744a | |||
| 6fab971734 | |||
| 2c18068059 | |||
| 09aec08d0e | |||
| 4cf8c3d8d7 | |||
| 37414ce124 | |||
| adceccf402 | |||
| 4c1a284636 | |||
| 23dc8e07b2 | |||
| c7d31cac2d | |||
| a1e932d261 | |||
| 070f1bd394 | |||
| 993d804cef | |||
| 201480b17f | |||
| 2f259c3773 | |||
| 97fcdb342d | |||
| 949ee76f55 | |||
| c4d3c515e4 | |||
| 7cc58dc94c | |||
| 5e3af7ac5d | |||
| 46987beefb | |||
| 4fd0108443 | |||
| 950ecba1c0 | |||
| fdc8f753cb | |||
| 4432891437 | |||
| a006db9e63 | |||
| 17da9a8036 | |||
| 717af2c4a4 |
+1
-1
Submodule assets updated: 1e7adc749e...10a611659d
@@ -29,6 +29,7 @@ struct EntityWrapper
|
|||||||
EntityWrapper Parent();
|
EntityWrapper Parent();
|
||||||
EntityWrapper FirstChildByName(const std::string& name);
|
EntityWrapper FirstChildByName(const std::string& name);
|
||||||
EntityWrapper FirstParentWithComponent(const std::string& componentType);
|
EntityWrapper FirstParentWithComponent(const std::string& componentType);
|
||||||
|
std::vector<EntityWrapper> ChildrenWithComponent(const std::string& componentType);
|
||||||
bool IsChildOf(EntityWrapper potentialParent);
|
bool IsChildOf(EntityWrapper potentialParent);
|
||||||
bool Valid() const;
|
bool Valid() const;
|
||||||
|
|
||||||
@@ -39,6 +40,7 @@ struct EntityWrapper
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
EntityWrapper firstChildByNameRecursive(const std::string& name, EntityID parent);
|
EntityWrapper firstChildByNameRecursive(const std::string& name, EntityID parent);
|
||||||
|
void childrenWithComponentRecursive(const std::string& componentType, EntityWrapper& entity, std::vector<EntityWrapper>& childrenWithComponent);
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace std
|
namespace std
|
||||||
|
|||||||
@@ -24,6 +24,19 @@
|
|||||||
#include "Network/EInterpolate.h"
|
#include "Network/EInterpolate.h"
|
||||||
#include "Network/SnapshotFilter.h"
|
#include "Network/SnapshotFilter.h"
|
||||||
#include "Core/EPlayerSpawned.h"
|
#include "Core/EPlayerSpawned.h"
|
||||||
|
#include "Network/ESearchForServers.h"
|
||||||
|
|
||||||
|
struct ServerInfo
|
||||||
|
{
|
||||||
|
ServerInfo(std::string a, int b, std::string c, int d)
|
||||||
|
{
|
||||||
|
Address = a; Port = b; Name = c; PlayersConnected = d;
|
||||||
|
}
|
||||||
|
std::string Address = "";
|
||||||
|
int Port = 0;
|
||||||
|
std::string Name = "";
|
||||||
|
int PlayersConnected = 0;
|
||||||
|
};
|
||||||
|
|
||||||
class Client : public Network
|
class Client : public Network
|
||||||
{
|
{
|
||||||
@@ -82,18 +95,22 @@ public:
|
|||||||
void parseTCPConnect(Packet& packet);
|
void parseTCPConnect(Packet& packet);
|
||||||
void parsePlayerConnected(Packet& packet);
|
void parsePlayerConnected(Packet& packet);
|
||||||
void parsePing();
|
void parsePing();
|
||||||
|
void parseServerlist(Packet& packet);
|
||||||
void parseKick();
|
void parseKick();
|
||||||
void parsePlayersSpawned(Packet& packet);
|
void parsePlayersSpawned(Packet& packet);
|
||||||
void parseEntityDeletion(Packet& packet);
|
void parseEntityDeletion(Packet& packet);
|
||||||
|
void parsePlayerDamage(Packet& packet);
|
||||||
void parseComponentDeletion(Packet& packet);
|
void parseComponentDeletion(Packet& packet);
|
||||||
void InterpolateFields(Packet & packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType);
|
void InterpolateFields(Packet & packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType);
|
||||||
void parseSnapshot(Packet& packet);
|
void parseSnapshot(Packet& packet);
|
||||||
|
void UpdateLocalCapturePointHUD(EntityWrapper capturePointHUD);
|
||||||
void identifyPacketLoss();
|
void identifyPacketLoss();
|
||||||
void hasServerTimedOut();
|
void hasServerTimedOut();
|
||||||
EntityID createPlayer();
|
EntityID createPlayer();
|
||||||
void sendInputCommands();
|
void sendInputCommands();
|
||||||
void sendLocalPlayerTransform();
|
void sendLocalPlayerTransform();
|
||||||
void becomePlayer();
|
void becomePlayer();
|
||||||
|
void displayServerlist();
|
||||||
// Mapping Logic
|
// Mapping Logic
|
||||||
// Returns if local EntityID exist in map
|
// Returns if local EntityID exist in map
|
||||||
bool clientServerMapsHasEntity(EntityID clientEntityID);
|
bool clientServerMapsHasEntity(EntityID clientEntityID);
|
||||||
@@ -109,10 +126,16 @@ public:
|
|||||||
bool OnPlayerDamage(const Events::PlayerDamage& e);
|
bool OnPlayerDamage(const Events::PlayerDamage& e);
|
||||||
EventRelay<Client, Events::PlayerSpawned> m_EPlayerSpawned;
|
EventRelay<Client, Events::PlayerSpawned> m_EPlayerSpawned;
|
||||||
bool OnPlayerSpawned(const Events::PlayerSpawned& e);
|
bool OnPlayerSpawned(const Events::PlayerSpawned& e);
|
||||||
void parsePlayerDamage(Packet& packet);
|
EventRelay< Client, Events::SearchForServers> m_ESearchForServers;
|
||||||
|
bool OnSearchForServers(const Events::SearchForServers& e);
|
||||||
private:
|
private:
|
||||||
UDPClient m_Unreliable;
|
UDPClient m_Unreliable;
|
||||||
|
UDPClient m_ServerlistRequest;
|
||||||
TCPClient m_Reliable;
|
TCPClient m_Reliable;
|
||||||
|
std::vector<ServerInfo> m_Serverlist;
|
||||||
|
bool m_SearchingForServers = false;
|
||||||
|
std::clock_t m_StartSearchTime;
|
||||||
|
double m_SearchingTime = 2000; // Config I guess
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#ifndef Events_SearchForServers_h__
|
||||||
|
#define Events_SearchForServers_h__
|
||||||
|
|
||||||
|
#include "Core/Event.h"
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
struct SearchForServers : public Event { };
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
#ifndef HybridClient_h__
|
|
||||||
#define HybridClient_h__
|
|
||||||
|
|
||||||
class HybridClient
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
HybridClient();
|
|
||||||
~HybridClient();
|
|
||||||
private:
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#ifndef HybridServer_h__
|
|
||||||
#define HybridServer_h__
|
|
||||||
|
|
||||||
class HybridServer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
HybridServer();
|
|
||||||
~HybridServer();
|
|
||||||
private:
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -19,6 +19,7 @@ enum class MessageType
|
|||||||
EntityDeleted,
|
EntityDeleted,
|
||||||
ComponentDeleted,
|
ComponentDeleted,
|
||||||
PlayerTransform,
|
PlayerTransform,
|
||||||
|
ServerlistRequest,
|
||||||
Invalid
|
Invalid
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "Network/TCPServer.h"
|
#include "Network/TCPServer.h"
|
||||||
#include "Network/UDPServer.h"
|
#include "Network/UDPServer.h"
|
||||||
|
#include "Network/UDPClient.h" //LOL
|
||||||
#include "Network/MessageType.h"
|
#include "Network/MessageType.h"
|
||||||
#include "Network/PlayerDefinition.h"
|
#include "Network/PlayerDefinition.h"
|
||||||
#include "Core/World.h"
|
#include "Core/World.h"
|
||||||
@@ -32,6 +33,7 @@ private:
|
|||||||
// Network channels
|
// Network channels
|
||||||
TCPServer m_Reliable;
|
TCPServer m_Reliable;
|
||||||
UDPServer m_Unreliable;
|
UDPServer m_Unreliable;
|
||||||
|
UDPServer m_ServerlistRequest;
|
||||||
// dont forget to set these in the childrens receive logic
|
// dont forget to set these in the childrens receive logic
|
||||||
boost::asio::ip::address m_Address;
|
boost::asio::ip::address m_Address;
|
||||||
int m_Port = 27666;
|
int m_Port = 27666;
|
||||||
@@ -82,6 +84,7 @@ private:
|
|||||||
void parseUDPConnect(Packet & packet);
|
void parseUDPConnect(Packet & packet);
|
||||||
void parseTCPConnect(Packet & packet);
|
void parseTCPConnect(Packet & packet);
|
||||||
void parseDisconnect();
|
void parseDisconnect();
|
||||||
|
void parseServerlistRequest(boost::asio::ip::udp::endpoint endpoint);
|
||||||
bool shouldSendToClient(EntityWrapper childEntity);
|
bool shouldSendToClient(EntityWrapper childEntity);
|
||||||
|
|
||||||
// Debug event
|
// Debug event
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ public:
|
|||||||
void Send(Packet & packet, PlayerDefinition & playerDefinition);
|
void Send(Packet & packet, PlayerDefinition & playerDefinition);
|
||||||
void Send(Packet & packet);
|
void Send(Packet & packet);
|
||||||
void Disconnect();
|
void Disconnect();
|
||||||
|
int Port() { return m_Port; }
|
||||||
|
std::string Address() { return m_Address; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// TCP logic
|
// TCP logic
|
||||||
boost::asio::io_service m_IOService;
|
boost::asio::io_service m_IOService;
|
||||||
@@ -26,6 +29,10 @@ private:
|
|||||||
int& nextPlayerID, std::map<PlayerID, PlayerDefinition>& connectedPlayers,
|
int& nextPlayerID, std::map<PlayerID, PlayerDefinition>& connectedPlayers,
|
||||||
const boost::system::error_code& error);
|
const boost::system::error_code& error);
|
||||||
int readBuffer(PlayerDefinition& playerDefinition);
|
int readBuffer(PlayerDefinition& playerDefinition);
|
||||||
|
int GetPort();
|
||||||
|
std::string GetAddress();
|
||||||
|
int m_Port = 0;
|
||||||
|
std::string m_Address = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -14,6 +14,7 @@ public:
|
|||||||
void Disconnect();
|
void Disconnect();
|
||||||
void Receive(Packet& packet);
|
void Receive(Packet& packet);
|
||||||
void Send(Packet & packet);
|
void Send(Packet & packet);
|
||||||
|
void Broadcast(Packet& packet, int port);
|
||||||
bool IsSocketAvailable();
|
bool IsSocketAvailable();
|
||||||
private:
|
private:
|
||||||
// Assio UDP logic
|
// Assio UDP logic
|
||||||
|
|||||||
@@ -8,11 +8,14 @@ class UDPServer : public NetworkServer
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
UDPServer();
|
UDPServer();
|
||||||
|
UDPServer(int port);
|
||||||
~UDPServer();
|
~UDPServer();
|
||||||
void AcceptNewConnections(int& nextPlayerID, std::map<PlayerID, PlayerDefinition>& connectedPlayers);
|
void AcceptNewConnections(int& nextPlayerID, std::map<PlayerID, PlayerDefinition>& connectedPlayers);
|
||||||
void Receive(Packet & packet, PlayerDefinition & playerDefinition);
|
void Receive(Packet & packet, PlayerDefinition & playerDefinition);
|
||||||
void Send(Packet & packet, PlayerDefinition & playerDefinition);
|
void Send(Packet & packet, PlayerDefinition & playerDefinition);
|
||||||
void Send(Packet & packet);
|
void Send(Packet & packet);
|
||||||
|
void Send(Packet & packet, boost::asio::ip::udp::endpoint endpoint);
|
||||||
|
void Broadcast(Packet & packet, int port);
|
||||||
bool IsSocketAvailable();
|
bool IsSocketAvailable();
|
||||||
private:
|
private:
|
||||||
// UDP logic
|
// UDP logic
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#ifndef CubeMapPass_h__
|
||||||
|
#define CubeMapPass_h__
|
||||||
|
|
||||||
|
#include "IRenderer.h"
|
||||||
|
#include "ShaderProgram.h"
|
||||||
|
|
||||||
|
class CubeMapPass
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CubeMapPass(IRenderer* renderer);
|
||||||
|
~CubeMapPass() { }
|
||||||
|
|
||||||
|
void LoadTextures(std::string input);
|
||||||
|
void FillCubeMap(glm::vec3 originPosition);
|
||||||
|
void GenerateCubeMapTexture();
|
||||||
|
|
||||||
|
//GLuint CubeMapTexture() const { return m_CubeMapTexture; }
|
||||||
|
GLuint m_CubeMapTexture = -1;
|
||||||
|
|
||||||
|
private:
|
||||||
|
IRenderer* m_Renderer;
|
||||||
|
std::string m_PreviusCubeMapTexture;
|
||||||
|
|
||||||
|
std::vector<Texture*> m_CubeMapTextures;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "IRenderer.h"
|
#include "IRenderer.h"
|
||||||
#include "DrawFinalPassState.h"
|
#include "DrawFinalPassState.h"
|
||||||
#include "LightCullingPass.h"
|
#include "LightCullingPass.h"
|
||||||
|
#include "CubeMapPass.h"
|
||||||
#include "FrameBuffer.h"
|
#include "FrameBuffer.h"
|
||||||
#include "ShaderProgram.h"
|
#include "ShaderProgram.h"
|
||||||
#include "Util/UnorderedMapVec2.h"
|
#include "Util/UnorderedMapVec2.h"
|
||||||
@@ -13,12 +14,12 @@
|
|||||||
class DrawFinalPass
|
class DrawFinalPass
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass);
|
DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass);
|
||||||
~DrawFinalPass() { }
|
~DrawFinalPass() { }
|
||||||
void InitializeTextures();
|
void InitializeTextures();
|
||||||
void InitializeFrameBuffers();
|
void InitializeFrameBuffers();
|
||||||
void InitializeShaderPrograms();
|
void InitializeShaderPrograms();
|
||||||
void Draw(RenderScene& scene);
|
void Draw(RenderScene& scene, GLuint SSAOTexture);
|
||||||
void ClearBuffer();
|
void ClearBuffer();
|
||||||
void OnWindowResize();
|
void OnWindowResize();
|
||||||
|
|
||||||
@@ -37,7 +38,7 @@ private:
|
|||||||
void GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const;
|
void GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const;
|
||||||
|
|
||||||
void DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, RenderScene& scene);
|
void DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, RenderScene& scene);
|
||||||
void DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
void DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene, GLuint SSAOTexture);
|
||||||
void DrawShieldToStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
void DrawShieldToStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
||||||
void DrawShieldedModelRenderQueue(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
void DrawShieldedModelRenderQueue(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
||||||
void DrawToDepthBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
void DrawToDepthBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
||||||
@@ -62,12 +63,14 @@ private:
|
|||||||
GLuint m_SceneTextureLowRes;
|
GLuint m_SceneTextureLowRes;
|
||||||
GLuint m_DepthBuffer;
|
GLuint m_DepthBuffer;
|
||||||
GLuint m_DepthBufferLowRes;
|
GLuint m_DepthBufferLowRes;
|
||||||
|
GLuint m_CubeMapTexture;
|
||||||
|
|
||||||
//maqke this component based i guess?
|
//maqke this component based i guess?
|
||||||
GLuint m_ShieldPixelRate = 16;
|
GLuint m_ShieldPixelRate = 16;
|
||||||
|
|
||||||
const IRenderer* m_Renderer;
|
const IRenderer* m_Renderer;
|
||||||
const LightCullingPass* m_LightCullingPass;
|
const LightCullingPass* m_LightCullingPass;
|
||||||
|
const CubeMapPass* m_CubeMapPass;
|
||||||
|
|
||||||
ShaderProgram* m_ForwardPlusProgram;
|
ShaderProgram* m_ForwardPlusProgram;
|
||||||
ShaderProgram* m_ExplosionEffectProgram;
|
ShaderProgram* m_ExplosionEffectProgram;
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ struct ModelJob : RenderJob
|
|||||||
|
|
||||||
void CalculateHash() override
|
void CalculateHash() override
|
||||||
{
|
{
|
||||||
Hash = TextureID + ModelID << 10 + ShaderID << 20;
|
Hash = ShaderID << 20 + ModelID << 10 + TextureID;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
#include "DrawScreenQuadPass.h"
|
#include "DrawScreenQuadPass.h"
|
||||||
#include "DrawBloomPass.h"
|
#include "DrawBloomPass.h"
|
||||||
#include "DrawColorCorrectionPass.h"
|
#include "DrawColorCorrectionPass.h"
|
||||||
|
#include "SSAOPass.h"
|
||||||
|
#include "CubeMapPass.h"
|
||||||
#include "../Core/EventBroker.h"
|
#include "../Core/EventBroker.h"
|
||||||
#include "ImGuiRenderPass.h"
|
#include "ImGuiRenderPass.h"
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
@@ -57,7 +59,14 @@ private:
|
|||||||
Model* m_UnitSphere;
|
Model* m_UnitSphere;
|
||||||
|
|
||||||
int m_DebugTextureToDraw = 0;
|
int m_DebugTextureToDraw = 0;
|
||||||
|
int m_CubeMapTexture = 0;
|
||||||
bool m_ResizeWindow = false;
|
bool m_ResizeWindow = false;
|
||||||
|
float m_SSAO_Radius = 1.0f;
|
||||||
|
float m_SSAO_Bias = 0.05f;
|
||||||
|
float m_SSAO_Contrast = 1.5f;
|
||||||
|
float m_SSAO_IntensityScale = 1.0f;
|
||||||
|
int m_SSAO_NumOfSamples = 24;
|
||||||
|
int m_SSAO_NumOfTurns = 7;
|
||||||
|
|
||||||
PickingPass* m_PickingPass;
|
PickingPass* m_PickingPass;
|
||||||
LightCullingPass* m_LightCullingPass;
|
LightCullingPass* m_LightCullingPass;
|
||||||
@@ -66,6 +75,8 @@ private:
|
|||||||
DrawScreenQuadPass* m_DrawScreenQuadPass;
|
DrawScreenQuadPass* m_DrawScreenQuadPass;
|
||||||
DrawBloomPass* m_DrawBloomPass;
|
DrawBloomPass* m_DrawBloomPass;
|
||||||
DrawColorCorrectionPass* m_DrawColorCorrectionPass;
|
DrawColorCorrectionPass* m_DrawColorCorrectionPass;
|
||||||
|
SSAOPass* m_SSAOPass;
|
||||||
|
CubeMapPass* m_CubeMapPass;
|
||||||
|
|
||||||
//----------------------Functions----------------------//
|
//----------------------Functions----------------------//
|
||||||
void InitializeWindow();
|
void InitializeWindow();
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
#ifndef SSAOPass_h__
|
||||||
|
#define SSAOPass_h__
|
||||||
|
|
||||||
|
#include "IRenderer.h"
|
||||||
|
#include "SSAOPassState.h"
|
||||||
|
//#include "LightCullingPass.h" Finalpass om den skall skickas in
|
||||||
|
#include "FrameBuffer.h"
|
||||||
|
#include "ShaderProgram.h"
|
||||||
|
#include "DrawBloomPass.h"
|
||||||
|
//#include "Util/UnorderedMapVec2.h"
|
||||||
|
#include "Texture.h"
|
||||||
|
|
||||||
|
class SSAOPass
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SSAOPass(IRenderer* rendere);
|
||||||
|
~SSAOPass() {
|
||||||
|
delete m_DrawBloomPass;
|
||||||
|
};
|
||||||
|
|
||||||
|
void Draw(GLuint depthBuffer, Camera* camera);
|
||||||
|
void Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int NumOfTurns);
|
||||||
|
void ClearBuffer();
|
||||||
|
void OnWindowResize();
|
||||||
|
|
||||||
|
//Return the SSAO of the texture sent to Draw
|
||||||
|
GLuint SSAOTexture() const { return m_DrawBloomPass->GaussianTexture(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
void InitializeTexture();
|
||||||
|
void InitializeFrameBuffer();
|
||||||
|
void InitializeShaderProgram();
|
||||||
|
void InitializeBuffer();
|
||||||
|
|
||||||
|
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
||||||
|
|
||||||
|
//void blurHorizontal(GLuint depthBuffer);
|
||||||
|
//void blurVertical(GLuint depthBuffer);
|
||||||
|
|
||||||
|
Model* m_ScreenQuad;
|
||||||
|
|
||||||
|
const IRenderer* m_Renderer;
|
||||||
|
|
||||||
|
float m_Radius;
|
||||||
|
float m_Bias;
|
||||||
|
float m_Contrast;
|
||||||
|
float m_IntensityScale;
|
||||||
|
int m_NumOfSamples;
|
||||||
|
int m_NumOfTurns;
|
||||||
|
|
||||||
|
GLuint m_SSAOTexture;
|
||||||
|
FrameBuffer m_SSAOFramBuffer;
|
||||||
|
|
||||||
|
GLuint m_SSAOViewSpaceZTexture;
|
||||||
|
FrameBuffer m_SSAOViewSpaceZFramBuffer;
|
||||||
|
|
||||||
|
ShaderProgram* m_SSAOProgram;
|
||||||
|
ShaderProgram* m_SSAOViewSpaceZProgram;
|
||||||
|
|
||||||
|
DrawBloomPass* m_DrawBloomPass;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef SSAOPassState_h__
|
||||||
|
#define SSAOPassState_h__
|
||||||
|
|
||||||
|
#include "Rendering/RenderState.h"
|
||||||
|
|
||||||
|
class SSAOPassState : public RenderState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SSAOPassState();
|
||||||
|
~SSAOPassState();
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
struct SpriteJob : RenderJob
|
struct SpriteJob : RenderJob
|
||||||
{
|
{
|
||||||
SpriteJob(ComponentWrapper cSprite, Camera* camera, glm::mat4 matrix, World* world, glm::vec4 fillColor, float fillPercentage, bool depthSorted)
|
SpriteJob(ComponentWrapper cSprite, Camera* camera, glm::mat4 matrix, World* world, glm::vec4 fillColor, float fillPercentage, bool depthSorted, bool isIndicator)
|
||||||
: RenderJob()
|
: RenderJob()
|
||||||
{
|
{
|
||||||
Model = ResourceManager::Load<::Model>("Models/Core/UnitQuad.mesh");
|
Model = ResourceManager::Load<::Model>("Models/Core/UnitQuad.mesh");
|
||||||
@@ -30,7 +30,7 @@ struct SpriteJob : RenderJob
|
|||||||
|
|
||||||
StartIndex = matProp.material->StartIndex;
|
StartIndex = matProp.material->StartIndex;
|
||||||
EndIndex = matProp.material->EndIndex;
|
EndIndex = matProp.material->EndIndex;
|
||||||
Matrix = matrix;
|
Matrix = matrix;
|
||||||
Color = cSprite["Color"];
|
Color = cSprite["Color"];
|
||||||
Entity = cSprite.EntityID;
|
Entity = cSprite.EntityID;
|
||||||
Position = Transform::AbsolutePosition(world, cSprite.EntityID);
|
Position = Transform::AbsolutePosition(world, cSprite.EntityID);
|
||||||
@@ -41,7 +41,8 @@ struct SpriteJob : RenderJob
|
|||||||
}
|
}
|
||||||
World = world;
|
World = world;
|
||||||
Pickable = world->HasComponent(cSprite.EntityID, "Button");
|
Pickable = world->HasComponent(cSprite.EntityID, "Button");
|
||||||
|
IsIndicator = isIndicator;
|
||||||
|
|
||||||
FillColor = fillColor;
|
FillColor = fillColor;
|
||||||
FillPercentage = fillPercentage;
|
FillPercentage = fillPercentage;
|
||||||
};
|
};
|
||||||
@@ -61,7 +62,9 @@ struct SpriteJob : RenderJob
|
|||||||
unsigned int StartIndex = 0;
|
unsigned int StartIndex = 0;
|
||||||
unsigned int EndIndex = 0;
|
unsigned int EndIndex = 0;
|
||||||
World* World;
|
World* World;
|
||||||
|
|
||||||
bool Pickable;
|
bool Pickable;
|
||||||
|
bool IsIndicator = false;
|
||||||
|
|
||||||
glm::vec4 FillColor = glm::vec4(0);
|
glm::vec4 FillColor = glm::vec4(0);
|
||||||
float FillPercentage = 0.0;
|
float FillPercentage = 0.0;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public:
|
|||||||
void Bind(GLenum textureUnit = GL_TEXTURE0);
|
void Bind(GLenum textureUnit = GL_TEXTURE0);
|
||||||
|
|
||||||
GLuint m_Texture = 0;
|
GLuint m_Texture = 0;
|
||||||
|
unsigned char* Data = nullptr;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ private:
|
|||||||
double AmmoGain;
|
double AmmoGain;
|
||||||
double RespawnTimer;
|
double RespawnTimer;
|
||||||
double DecreaseThisRespawnTimer;
|
double DecreaseThisRespawnTimer;
|
||||||
|
EntityID parentID;
|
||||||
};
|
};
|
||||||
std::vector<NewAmmoPickup> m_ETriggerTouchVector;
|
std::vector<NewAmmoPickup> m_ETriggerTouchVector;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,11 +14,13 @@
|
|||||||
#include <glm/gtx/vector_angle.hpp>
|
#include <glm/gtx/vector_angle.hpp>
|
||||||
|
|
||||||
#include "Rendering/Util/CommonFunctions.h"
|
#include "Rendering/Util/CommonFunctions.h"
|
||||||
|
//#define INDICATOR_TEST
|
||||||
|
|
||||||
class DamageIndicatorSystem : public System
|
class DamageIndicatorSystem : public ImpureSystem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DamageIndicatorSystem(SystemParams params);
|
DamageIndicatorSystem(SystemParams params);
|
||||||
|
virtual void Update(double dt) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EventRelay<DamageIndicatorSystem, Events::PlayerDamage> m_EPlayerDamage;
|
EventRelay<DamageIndicatorSystem, Events::PlayerDamage> m_EPlayerDamage;
|
||||||
@@ -28,6 +30,20 @@ private:
|
|||||||
bool OnSetCamera(const Events::SetCamera& e);
|
bool OnSetCamera(const Events::SetCamera& e);
|
||||||
|
|
||||||
EntityID m_CurrentCamera = -1;
|
EntityID m_CurrentCamera = -1;
|
||||||
|
struct DamageIndicatorStruct {
|
||||||
|
EntityWrapper spriteEntity;
|
||||||
|
glm::vec3 enemyPosition;
|
||||||
|
DamageIndicatorStruct(EntityWrapper sprite, glm::vec3 pos)
|
||||||
|
: spriteEntity(sprite)
|
||||||
|
, enemyPosition(pos) {}
|
||||||
|
};
|
||||||
|
std::vector<DamageIndicatorStruct> updateDamageIndicatorVector;
|
||||||
|
float CalculateAngle(EntityWrapper player, glm::vec3 enemyPos);
|
||||||
|
|
||||||
|
//for tests
|
||||||
|
#ifdef INDICATOR_TEST
|
||||||
|
glm::vec3 DamageIndicatorTest(EntityWrapper player);
|
||||||
|
int m_TestVar = 0;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ private:
|
|||||||
double HealthGain;
|
double HealthGain;
|
||||||
double RespawnTimer;
|
double RespawnTimer;
|
||||||
double DecreaseThisRespawnTimer;
|
double DecreaseThisRespawnTimer;
|
||||||
|
EntityID parentID;
|
||||||
};
|
};
|
||||||
std::vector<NewHealthPickup> m_ETriggerTouchVector;
|
std::vector<NewHealthPickup> m_ETriggerTouchVector;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -39,5 +39,5 @@ private:
|
|||||||
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
||||||
|
|
||||||
void updateMovementControllers(double dt);
|
void updateMovementControllers(double dt);
|
||||||
void updateVelocity(double dt);
|
void updateVelocity(EntityWrapper player, double dt);
|
||||||
};
|
};
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
|
#ifndef AssaultWeaponBehaviour_h__
|
||||||
|
#define AssaultWeaponBehaviour_h__
|
||||||
|
|
||||||
#include "Sound/EPlaySoundOnEntity.h"
|
#include "Sound/EPlaySoundOnEntity.h"
|
||||||
#include "Collision/Collision.h"
|
#include "Collision/Collision.h"
|
||||||
#include "Rendering/AnimationSystem.h"
|
|
||||||
#include "Core/ConfigFile.h"
|
#include "Core/ConfigFile.h"
|
||||||
#include "WeaponBehaviour.h"
|
#include "WeaponBehaviour.h"
|
||||||
#include "../SpawnerSystem.h"
|
#include "../SpawnerSystem.h"
|
||||||
#include "Core/EPlayerDamage.h"
|
#include "Core/EPlayerDamage.h"
|
||||||
#include "Core/EShoot.h"
|
#include "Core/EShoot.h"
|
||||||
|
|
||||||
|
|
||||||
class AssaultWeaponBehaviour : public WeaponBehaviour
|
class AssaultWeaponBehaviour : public WeaponBehaviour
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -22,16 +23,13 @@ public:
|
|||||||
private:
|
private:
|
||||||
EntityWrapper m_FirstPersonModel;
|
EntityWrapper m_FirstPersonModel;
|
||||||
EntityWrapper m_ThirdPersonModel;
|
EntityWrapper m_ThirdPersonModel;
|
||||||
|
|
||||||
// State
|
// State
|
||||||
bool m_Firing = false;
|
bool m_Firing = false;
|
||||||
bool m_Reloading = false;
|
bool m_Reloading = false;
|
||||||
double m_ReloadTimer = 0.0;
|
double m_ReloadTimer = 0.0;
|
||||||
EntityWrapper m_FirstPersonReloadImpersonator;
|
|
||||||
EntityWrapper m_ThirdPersonReloadImpersonator;
|
|
||||||
double m_TimeSinceLastFire = 0.0;
|
double m_TimeSinceLastFire = 0.0;
|
||||||
|
EntityWrapper m_FirstPersonReloadImpostor;
|
||||||
EventRelay<WeaponBehaviour, Events::AnimationComplete> m_EAnimationComplete;
|
|
||||||
bool OnAnimationComplete(Events::AnimationComplete& e);
|
|
||||||
|
|
||||||
bool hasAmmo();
|
bool hasAmmo();
|
||||||
void fireRound();
|
void fireRound();
|
||||||
@@ -47,3 +45,5 @@ private:
|
|||||||
bool shoot(double damage);
|
bool shoot(double damage);
|
||||||
void showHitMarker();
|
void showHitMarker();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#include "WeaponBehaviour.h"
|
||||||
|
|
||||||
|
class DefenderWeaponBehaviour : public WeaponBehaviour
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DefenderWeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree<EntityAABB>* collisionOctree, EntityWrapper weaponEntity);
|
||||||
|
|
||||||
|
virtual void Fire() override;
|
||||||
|
//virtual void CeaseFire() override;
|
||||||
|
//virtual void Reload() override;
|
||||||
|
|
||||||
|
//virtual void Update(double dt) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
double m_TimeSinceLastFire = 0.0;
|
||||||
|
};
|
||||||
@@ -8,17 +8,21 @@
|
|||||||
|
|
||||||
class WeaponBehaviour : public System
|
class WeaponBehaviour : public System
|
||||||
{
|
{
|
||||||
|
friend class WeaponSystem;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree<EntityAABB>* collisionOctree, EntityWrapper player)
|
WeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree<EntityAABB>* collisionOctree, EntityWrapper player, EntityWrapper firstPersonWeapon, EntityWrapper thirdPersonWeapon)
|
||||||
: System(systemParams)
|
: System(systemParams)
|
||||||
, m_Renderer(renderer)
|
, m_Renderer(renderer)
|
||||||
, m_CollisionOctree(collisionOctree)
|
, m_CollisionOctree(collisionOctree)
|
||||||
, m_Player(player)
|
, m_Player(player)
|
||||||
|
, m_FirstPerson(firstPersonWeapon)
|
||||||
|
, m_ThirdPerson(thirdPersonWeapon)
|
||||||
{ }
|
{ }
|
||||||
virtual ~WeaponBehaviour() = default;
|
virtual ~WeaponBehaviour() = default;
|
||||||
|
|
||||||
WeaponBehaviour(const WeaponBehaviour&) = delete;
|
WeaponBehaviour(const WeaponBehaviour&) = delete;
|
||||||
WeaponBehaviour& operator=(const WeaponBehaviour &) = delete;
|
WeaponBehaviour& operator=(const WeaponBehaviour&) = delete;
|
||||||
|
|
||||||
virtual void Fire() = 0;
|
virtual void Fire() = 0;
|
||||||
virtual void CeaseFire() { }
|
virtual void CeaseFire() { }
|
||||||
@@ -29,6 +33,8 @@ protected:
|
|||||||
IRenderer* m_Renderer;
|
IRenderer* m_Renderer;
|
||||||
Octree<EntityAABB>* m_CollisionOctree;
|
Octree<EntityAABB>* m_CollisionOctree;
|
||||||
EntityWrapper m_Player;
|
EntityWrapper m_Player;
|
||||||
|
EntityWrapper m_FirstPerson;
|
||||||
|
EntityWrapper m_ThirdPerson;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -44,5 +44,7 @@
|
|||||||
<xs:include schemaLocation="Components/Menu.xsd"/>
|
<xs:include schemaLocation="Components/Menu.xsd"/>
|
||||||
<xs:include schemaLocation="Components/KillFeed.xsd"/>
|
<xs:include schemaLocation="Components/KillFeed.xsd"/>
|
||||||
<xs:include schemaLocation="Components/Page.xsd"/>
|
<xs:include schemaLocation="Components/Page.xsd"/>
|
||||||
|
<xs:include schemaLocation="Components/SpriteIndicator.xsd"/>
|
||||||
<xs:include schemaLocation="Components/Button.xsd"/>
|
<xs:include schemaLocation="Components/Button.xsd"/>
|
||||||
|
<xs:include schemaLocation="Components/WeaponAttachment.xsd"/>
|
||||||
</xs:schema>
|
</xs:schema>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<SpriteIndicator xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="SpriteIndicator.xsd">
|
||||||
|
<MinScale>10</MinScale>
|
||||||
|
<VisibleForSingleTeamOnly>false</VisibleForSingleTeamOnly>
|
||||||
|
</SpriteIndicator>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
|
||||||
|
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
|
||||||
|
|
||||||
|
<xs:element name="SpriteIndicator">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:documentation>Billbord a Sprite around global Y axis</xs:documentation>
|
||||||
|
</xs:annotation>
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:all>
|
||||||
|
<xs:element name="MinScale" type="t:double" minOccurs="0"/>
|
||||||
|
<xs:element name="VisibleForSingleTeamOnly" type="t:bool" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>Add a Team component to this Entity or Parent to make it visible only for that team</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
</xs:all>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:schema>
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
|
||||||
<Trigger xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Trigger.xsd">
|
|
||||||
</Trigger>
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
|
|
||||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
|
|
||||||
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
|
|
||||||
|
|
||||||
<xs:element name="Weapon">
|
|
||||||
<xs:complexType>
|
|
||||||
<xs:all>
|
|
||||||
<xs:element name="MagSize" type="t:int" minOccurs="0"/>
|
|
||||||
<xs:element name="MaxAmmo" type="t:int" minOccurs="0"/>
|
|
||||||
<xs:element name="CurrentAmmoInMag" type="t:int" minOccurs="0"/>
|
|
||||||
<xs:element name="CurrentAmmo" type="t:int" minOccurs="0"/>
|
|
||||||
<xs:element name="RPM" type="t:double" minOccurs="0"/>
|
|
||||||
</xs:all>
|
|
||||||
</xs:complexType>
|
|
||||||
</xs:element>
|
|
||||||
</xs:schema>
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<WeaponAttachment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="WeaponAttachment.xsd">
|
||||||
|
<Person><FirstPerson/></Person>
|
||||||
|
</WeaponAttachment>
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
|
||||||
|
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
|
||||||
|
|
||||||
|
<xs:complexType name="PersonEnum" mixed="true">
|
||||||
|
<xs:complexContent>
|
||||||
|
<xs:extension base="t:enum">
|
||||||
|
<xs:choice>
|
||||||
|
<xs:element name="FirstPerson" type="t:int" fixed="0" minOccurs="0"/>
|
||||||
|
<xs:element name="ThirdPerson" type="t:int" fixed="1" minOccurs="0"/>
|
||||||
|
</xs:choice>
|
||||||
|
</xs:extension>
|
||||||
|
</xs:complexContent>
|
||||||
|
</xs:complexType>
|
||||||
|
|
||||||
|
<xs:complexType name="WeaponSlotEnum" mixed="true">
|
||||||
|
<xs:complexContent>
|
||||||
|
<xs:extension base="t:enum">
|
||||||
|
<xs:choice>
|
||||||
|
<xs:element name="Primary" type="t:int" fixed="1" minOccurs="0"/>
|
||||||
|
<xs:element name="Secondary" type="t:int" fixed="2" minOccurs="0"/>
|
||||||
|
</xs:choice>
|
||||||
|
</xs:extension>
|
||||||
|
</xs:complexContent>
|
||||||
|
</xs:complexType>
|
||||||
|
|
||||||
|
<xs:element name="WeaponAttachment">
|
||||||
|
<xs:annotation><xs:documentation>Combine with a spawner to define a weapon attachment point</xs:documentation></xs:annotation>
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:all>
|
||||||
|
<xs:element name="Person" type="PersonEnum" minOccurs="0"/>
|
||||||
|
<xs:element name="Slot" type="WeaponSlotEnum" minOccurs="0"/>
|
||||||
|
</xs:all>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:schema>
|
||||||
@@ -2,18 +2,18 @@
|
|||||||
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
<Components>
|
<Components>
|
||||||
<c:AABB/>
|
|
||||||
<c:AmmoPickup/>
|
<c:AmmoPickup/>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models/Props/PickUps/AmmoPickUp.mesh</Resource>
|
<Resource>Models/Props/PickUps/AmmoPickUp.mesh</Resource>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:RaptorCopter>
|
<c:RaptorCopter>
|
||||||
<Speed>0.1</Speed>
|
<Speed>8</Speed>
|
||||||
<Axis X="0" Y="1" Z="0"/>
|
<Axis X="0" Y="0.100000001" Z="0"/>
|
||||||
</c:RaptorCopter>
|
</c:RaptorCopter>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="1" Z="0"/>
|
<Position X="0" Y="2.36784196" Z="0"/>
|
||||||
<Scale X="0.3" Y="0.3" Z="0.3"/>
|
<Scale X="0.600000024" Y="0.600000024" Z="0.600000024"/>
|
||||||
|
<Orientation X="0" Y="18717.9453" Z="0"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
<c:Trigger/>
|
<c:Trigger/>
|
||||||
</Components>
|
</Components>
|
||||||
|
|||||||
@@ -2,18 +2,18 @@
|
|||||||
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
<Components>
|
<Components>
|
||||||
<c:AABB/>
|
|
||||||
<c:HealthPickup/>
|
<c:HealthPickup/>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models/Props/PickUps/HealthPickUp.mesh</Resource>
|
<Resource>Models/Props/PickUps/HealthPickUp.mesh</Resource>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:RaptorCopter>
|
<c:RaptorCopter>
|
||||||
<Speed>0.1</Speed>
|
<Speed>8</Speed>
|
||||||
<Axis X="0" Y="1" Z="0"/>
|
<Axis X="0" Y="0.100000001" Z="0"/>
|
||||||
</c:RaptorCopter>
|
</c:RaptorCopter>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="1" Z="0"/>
|
<Position X="0" Y="2.36784196" Z="0"/>
|
||||||
<Scale X="0.3" Y="0.3" Z="0.3"/>
|
<Scale X="0.600000024" Y="0.600000024" Z="0.600000024"/>
|
||||||
|
<Orientation X="0" Y="18767.0273" Z="0"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
<c:Trigger/>
|
<c:Trigger/>
|
||||||
</Components>
|
</Components>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
<c:DashAbility/>
|
<c:DashAbility/>
|
||||||
<c:Health/>
|
<c:Health/>
|
||||||
<c:Physics>
|
<c:Physics>
|
||||||
|
<PrevOrigin X="0" Y="0.772000015" Z="0"/>
|
||||||
<Velocity X="2.30999646e-23" Y="0" Z="1.05272533e-23"/>
|
<Velocity X="2.30999646e-23" Y="0" Z="1.05272533e-23"/>
|
||||||
</c:Physics>
|
</c:Physics>
|
||||||
<c:Player>
|
<c:Player>
|
||||||
@@ -60,6 +61,7 @@
|
|||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Weapons/Crosshair/SmallThickHoleDot.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Weapons/Crosshair/SmallThickHoleDot.png</DiffuseTexture>
|
||||||
<DepthSort>false</DepthSort>
|
<DepthSort>false</DepthSort>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="0" Z="0.200000003"/>
|
<Position X="0" Y="0" Z="0.200000003"/>
|
||||||
@@ -110,6 +112,7 @@
|
|||||||
</c:Fill>
|
</c:Fill>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/HealthHUD3.png</DiffuseTexture>
|
<DiffuseTexture>Textures/HealthHUD3.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
<Color A="0.588235319" B="0" G="0" R="0"/>
|
<Color A="0.588235319" B="0" G="0" R="0"/>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:HealthHUD/>
|
<c:HealthHUD/>
|
||||||
@@ -135,6 +138,7 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
<Color A="0.300000012" B="1" G="1" R="1"/>
|
<Color A="0.300000012" B="1" G="1" R="1"/>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
@@ -152,6 +156,7 @@
|
|||||||
</c:Fill>
|
</c:Fill>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="0" Z="0.00999999978"/>
|
<Position X="0" Y="0" Z="0.00999999978"/>
|
||||||
@@ -167,6 +172,7 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
<Color A="0.300000012" B="1" G="1" R="1"/>
|
<Color A="0.300000012" B="1" G="1" R="1"/>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
@@ -185,6 +191,7 @@
|
|||||||
</c:Fill>
|
</c:Fill>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="0" Z="0.00999999978"/>
|
<Position X="0" Y="0" Z="0.00999999978"/>
|
||||||
@@ -200,6 +207,7 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
<Color A="0.699999988" B="1" G="0.200000003" R="0"/>
|
<Color A="0.699999988" B="1" G="0.200000003" R="0"/>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
@@ -217,6 +225,7 @@
|
|||||||
</c:Fill>
|
</c:Fill>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="0" Z="0.00999999978"/>
|
<Position X="0" Y="0" Z="0.00999999978"/>
|
||||||
@@ -232,6 +241,7 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
<Color A="0.300000012" B="1" G="1" R="1"/>
|
<Color A="0.300000012" B="1" G="1" R="1"/>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
@@ -249,6 +259,7 @@
|
|||||||
</c:Fill>
|
</c:Fill>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="0" Z="0.00999999978"/>
|
<Position X="0" Y="0" Z="0.00999999978"/>
|
||||||
@@ -264,6 +275,7 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
<Color A="0.699999988" B="0" G="0.200000003" R="1"/>
|
<Color A="0.699999988" B="0" G="0.200000003" R="1"/>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
@@ -279,6 +291,7 @@
|
|||||||
</c:Fill>
|
</c:Fill>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="0" Z="0.00999999978"/>
|
<Position X="0" Y="0" Z="0.00999999978"/>
|
||||||
@@ -291,8 +304,7 @@
|
|||||||
</Children>
|
</Children>
|
||||||
</Entity>
|
</Entity>
|
||||||
</Children>
|
</Children>
|
||||||
</Entity>
|
</Entity> <Entity name="KillFeed">
|
||||||
<Entity name="KillFeed">
|
|
||||||
<Components>
|
<Components>
|
||||||
<c:KillFeed/>
|
<c:KillFeed/>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
@@ -304,6 +316,7 @@
|
|||||||
<Entity name="KillFeed1">
|
<Entity name="KillFeed1">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Text>
|
<c:Text>
|
||||||
|
<Content></Content>
|
||||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||||
<Alignment>
|
<Alignment>
|
||||||
<Right/>
|
<Right/>
|
||||||
@@ -316,6 +329,7 @@
|
|||||||
<Entity name="KillFeed2">
|
<Entity name="KillFeed2">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Text>
|
<c:Text>
|
||||||
|
<Content></Content>
|
||||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||||
<Alignment>
|
<Alignment>
|
||||||
<Right/>
|
<Right/>
|
||||||
@@ -330,6 +344,7 @@
|
|||||||
<Entity name="KillFeed3">
|
<Entity name="KillFeed3">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Text>
|
<c:Text>
|
||||||
|
<Content></Content>
|
||||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||||
<Alignment>
|
<Alignment>
|
||||||
<Right/>
|
<Right/>
|
||||||
@@ -349,13 +364,14 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Animation>
|
<c:Animation>
|
||||||
<AnimationName1>Idle</AnimationName1>
|
<AnimationName1>Idle</AnimationName1>
|
||||||
<Time1>1.6050530664521858</Time1>
|
<Time1>0.97725610639912475</Time1>
|
||||||
<Speed1>1</Speed1>
|
<Speed1>1</Speed1>
|
||||||
|
<AnimationName2></AnimationName2>
|
||||||
|
<AnimationName3></AnimationName3>
|
||||||
</c:Animation>
|
</c:Animation>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models/Characters/Assault/FirstPerson.mesh</Resource>
|
<Resource>Models/Characters/Assault/FirstPerson.mesh</Resource>
|
||||||
<Color A="1" B="1" G="0.309803933" R="0"/>
|
<Color A="1" B="1" G="0.309803933" R="0"/>
|
||||||
<Transparent>true</Transparent>
|
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Transform/>
|
<c:Transform/>
|
||||||
</Components>
|
</Components>
|
||||||
@@ -367,11 +383,10 @@
|
|||||||
</c:BoneAttachment>
|
</c:BoneAttachment>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models/Weapons/Blue/AssaultWeaponBlue.mesh</Resource>
|
<Resource>Models/Weapons/Blue/AssaultWeaponBlue.mesh</Resource>
|
||||||
<Transparent>true</Transparent>
|
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0.12043035" Y="-0.234149337" Z="-0.181454644"/>
|
<Position X="0.12043038" Y="-0.244988307" Z="-0.181454808"/>
|
||||||
<Orientation X="0.0104045281" Y="-0.00268131681" Z="0.0428438708"/>
|
<Orientation X="0.010404544" Y="-0.00268173823" Z="0.0428441577"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children>
|
<Children>
|
||||||
@@ -408,6 +423,7 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
<Color A="0.588235319" B="0" G="0" R="0"/>
|
<Color A="0.588235319" B="0" G="0" R="0"/>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
@@ -477,8 +493,10 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Animation>
|
<c:Animation>
|
||||||
<AnimationName1>Idle</AnimationName1>
|
<AnimationName1>Idle</AnimationName1>
|
||||||
<Time1>1.620305457513453</Time1>
|
<Time1>0.87583812735846323</Time1>
|
||||||
<Speed1>1</Speed1>
|
<Speed1>1</Speed1>
|
||||||
|
<AnimationName2></AnimationName2>
|
||||||
|
<AnimationName3></AnimationName3>
|
||||||
</c:Animation>
|
</c:Animation>
|
||||||
<c:AnimationOffset>
|
<c:AnimationOffset>
|
||||||
<AnimationName>AimRifle</AnimationName>
|
<AnimationName>AimRifle</AnimationName>
|
||||||
@@ -501,8 +519,8 @@
|
|||||||
<Resource>Models/Weapons/Blue/AssaultWeaponBlue.mesh</Resource>
|
<Resource>Models/Weapons/Blue/AssaultWeaponBlue.mesh</Resource>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0.160351232" Y="1.02591991" Z="-0.215102971"/>
|
<Position X="0.163429111" Y="1.0235405" Z="-0.215489209"/>
|
||||||
<Orientation X="-0.0627480298" Y="-0.0432248674" Z="0.119431816"/>
|
<Orientation X="-0.0631071255" Y="-0.0576644838" Z="0.118255548"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children>
|
<Children>
|
||||||
@@ -572,6 +590,26 @@
|
|||||||
</Components>
|
</Components>
|
||||||
<Children/>
|
<Children/>
|
||||||
</Entity>
|
</Entity>
|
||||||
|
<Entity name="Indicator">
|
||||||
|
<Components>
|
||||||
|
<c:Sprite>
|
||||||
|
<DiffuseTexture>Textures/Icons/Arrow.png</DiffuseTexture>
|
||||||
|
<DepthSort>false</DepthSort>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
<Color A="1" B="1" G="0.309803933" R="0"/>
|
||||||
|
</c:Sprite>
|
||||||
|
<c:HiddenForLocalPlayer/>
|
||||||
|
<c:SpriteIndicator>
|
||||||
|
<MinScale>50</MinScale>
|
||||||
|
<VisibleForSingleTeamOnly>true</VisibleForSingleTeamOnly>
|
||||||
|
</c:SpriteIndicator>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="1.84019077" Z="0"/>
|
||||||
|
<Scale X="0.300000012" Y="0.300000012" Z="0.300000012"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
</Children>
|
</Children>
|
||||||
|
|
||||||
</Entity>
|
</Entity>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
<c:DashAbility/>
|
<c:DashAbility/>
|
||||||
<c:Health/>
|
<c:Health/>
|
||||||
<c:Physics>
|
<c:Physics>
|
||||||
|
<PrevOrigin X="0" Y="0.772000015" Z="0"/>
|
||||||
<Velocity X="2.30999646e-23" Y="0" Z="1.05272533e-23"/>
|
<Velocity X="2.30999646e-23" Y="0" Z="1.05272533e-23"/>
|
||||||
</c:Physics>
|
</c:Physics>
|
||||||
<c:Player>
|
<c:Player>
|
||||||
@@ -60,6 +61,7 @@
|
|||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Weapons/Crosshair/SmallThickHoleDot.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Weapons/Crosshair/SmallThickHoleDot.png</DiffuseTexture>
|
||||||
<DepthSort>false</DepthSort>
|
<DepthSort>false</DepthSort>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="0" Z="0.200000003"/>
|
<Position X="0" Y="0" Z="0.200000003"/>
|
||||||
@@ -110,6 +112,7 @@
|
|||||||
</c:Fill>
|
</c:Fill>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/HealthHUD3.png</DiffuseTexture>
|
<DiffuseTexture>Textures/HealthHUD3.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
<Color A="0.588235319" B="0" G="0" R="0"/>
|
<Color A="0.588235319" B="0" G="0" R="0"/>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:HealthHUD/>
|
<c:HealthHUD/>
|
||||||
@@ -135,6 +138,7 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
<Color A="0.300000012" B="1" G="1" R="1"/>
|
<Color A="0.300000012" B="1" G="1" R="1"/>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
@@ -152,6 +156,7 @@
|
|||||||
</c:Fill>
|
</c:Fill>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="0" Z="0.00999999978"/>
|
<Position X="0" Y="0" Z="0.00999999978"/>
|
||||||
@@ -167,6 +172,7 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
<Color A="0.300000012" B="1" G="1" R="1"/>
|
<Color A="0.300000012" B="1" G="1" R="1"/>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
@@ -185,6 +191,7 @@
|
|||||||
</c:Fill>
|
</c:Fill>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="0" Z="0.00999999978"/>
|
<Position X="0" Y="0" Z="0.00999999978"/>
|
||||||
@@ -200,6 +207,7 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
<Color A="0.699999988" B="1" G="0.200000003" R="0"/>
|
<Color A="0.699999988" B="1" G="0.200000003" R="0"/>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
@@ -217,6 +225,7 @@
|
|||||||
</c:Fill>
|
</c:Fill>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="0" Z="0.00999999978"/>
|
<Position X="0" Y="0" Z="0.00999999978"/>
|
||||||
@@ -232,6 +241,7 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
<Color A="0.300000012" B="1" G="1" R="1"/>
|
<Color A="0.300000012" B="1" G="1" R="1"/>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
@@ -249,6 +259,7 @@
|
|||||||
</c:Fill>
|
</c:Fill>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="0" Z="0.00999999978"/>
|
<Position X="0" Y="0" Z="0.00999999978"/>
|
||||||
@@ -264,6 +275,7 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
<Color A="0.699999988" B="0" G="0.200000003" R="1"/>
|
<Color A="0.699999988" B="0" G="0.200000003" R="1"/>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
@@ -279,6 +291,7 @@
|
|||||||
</c:Fill>
|
</c:Fill>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="0" Z="0.00999999978"/>
|
<Position X="0" Y="0" Z="0.00999999978"/>
|
||||||
@@ -304,6 +317,7 @@
|
|||||||
<Entity name="KillFeed1">
|
<Entity name="KillFeed1">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Text>
|
<c:Text>
|
||||||
|
<Content></Content>
|
||||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||||
<Alignment>
|
<Alignment>
|
||||||
<Right/>
|
<Right/>
|
||||||
@@ -316,6 +330,7 @@
|
|||||||
<Entity name="KillFeed2">
|
<Entity name="KillFeed2">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Text>
|
<c:Text>
|
||||||
|
<Content></Content>
|
||||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||||
<Alignment>
|
<Alignment>
|
||||||
<Right/>
|
<Right/>
|
||||||
@@ -330,6 +345,7 @@
|
|||||||
<Entity name="KillFeed3">
|
<Entity name="KillFeed3">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Text>
|
<c:Text>
|
||||||
|
<Content></Content>
|
||||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||||
<Alignment>
|
<Alignment>
|
||||||
<Right/>
|
<Right/>
|
||||||
@@ -349,13 +365,14 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Animation>
|
<c:Animation>
|
||||||
<AnimationName1>Idle</AnimationName1>
|
<AnimationName1>Idle</AnimationName1>
|
||||||
<Time1>1.6050530664521858</Time1>
|
<Time1>1.2667383999985162</Time1>
|
||||||
<Speed1>1</Speed1>
|
<Speed1>1</Speed1>
|
||||||
|
<AnimationName2></AnimationName2>
|
||||||
|
<AnimationName3></AnimationName3>
|
||||||
</c:Animation>
|
</c:Animation>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models/Characters/Assault/FirstPerson.mesh</Resource>
|
<Resource>Models/Characters/Assault/FirstPerson.mesh</Resource>
|
||||||
<Color A="1" B="0" G="0" R="1"/>
|
<Color A="1" B="0" G="0" R="1"/>
|
||||||
<Transparent>true</Transparent>
|
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Transform/>
|
<c:Transform/>
|
||||||
</Components>
|
</Components>
|
||||||
@@ -367,11 +384,10 @@
|
|||||||
</c:BoneAttachment>
|
</c:BoneAttachment>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models/Weapons/Red/AssaultWeaponRed.mesh</Resource>
|
<Resource>Models/Weapons/Red/AssaultWeaponRed.mesh</Resource>
|
||||||
<Transparent>true</Transparent>
|
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0.12043035" Y="-0.234149337" Z="-0.181454644"/>
|
<Position X="0.120430425" Y="-0.242105931" Z="-0.181454822"/>
|
||||||
<Orientation X="0.0104045281" Y="-0.00268131681" Z="0.0428438708"/>
|
<Orientation X="0.010404665" Y="-0.00268179877" Z="0.0428443067"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children>
|
<Children>
|
||||||
@@ -408,6 +424,7 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
<Color A="0.588235319" B="0" G="0" R="0"/>
|
<Color A="0.588235319" B="0" G="0" R="0"/>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
@@ -477,8 +494,10 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Animation>
|
<c:Animation>
|
||||||
<AnimationName1>Idle</AnimationName1>
|
<AnimationName1>Idle</AnimationName1>
|
||||||
<Time1>1.620305457513453</Time1>
|
<Time1>0.26532318661337229</Time1>
|
||||||
<Speed1>1</Speed1>
|
<Speed1>1</Speed1>
|
||||||
|
<AnimationName2></AnimationName2>
|
||||||
|
<AnimationName3></AnimationName3>
|
||||||
</c:Animation>
|
</c:Animation>
|
||||||
<c:AnimationOffset>
|
<c:AnimationOffset>
|
||||||
<AnimationName>AimRifle</AnimationName>
|
<AnimationName>AimRifle</AnimationName>
|
||||||
@@ -501,8 +520,8 @@
|
|||||||
<Resource>Models/Weapons/Red/AssaultWeaponRed.mesh</Resource>
|
<Resource>Models/Weapons/Red/AssaultWeaponRed.mesh</Resource>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0.160351232" Y="1.02591991" Z="-0.215102971"/>
|
<Position X="0.159282878" Y="1.0300566" Z="-0.216084003"/>
|
||||||
<Orientation X="-0.0627480298" Y="-0.0432248674" Z="0.119431816"/>
|
<Orientation X="-0.0626799241" Y="-0.0390551724" Z="0.119761385"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children>
|
<Children>
|
||||||
@@ -572,6 +591,26 @@
|
|||||||
</Components>
|
</Components>
|
||||||
<Children/>
|
<Children/>
|
||||||
</Entity>
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Sprite>
|
||||||
|
<DiffuseTexture>Textures/Icons/Arrow.png</DiffuseTexture>
|
||||||
|
<DepthSort>false</DepthSort>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
<Color A="1" B="0" G="0" R="1"/>
|
||||||
|
</c:Sprite>
|
||||||
|
<c:HiddenForLocalPlayer/>
|
||||||
|
<c:SpriteIndicator>
|
||||||
|
<MinScale>50</MinScale>
|
||||||
|
<VisibleForSingleTeamOnly>true</VisibleForSingleTeamOnly>
|
||||||
|
</c:SpriteIndicator>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="1.84000003" Z="0"/>
|
||||||
|
<Scale X="0.300000012" Y="0.300000012" Z="0.300000012"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
</Children>
|
</Children>
|
||||||
|
|
||||||
</Entity>
|
</Entity>
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
<xs:element ref="c:Menu" minOccurs="0"/>
|
<xs:element ref="c:Menu" minOccurs="0"/>
|
||||||
<xs:element ref="c:Page" minOccurs="0"/>
|
<xs:element ref="c:Page" minOccurs="0"/>
|
||||||
<xs:element ref="c:Button" minOccurs="0"/>
|
<xs:element ref="c:Button" minOccurs="0"/>
|
||||||
|
<xs:element ref="c:WeaponAttachment" minOccurs="0"/>
|
||||||
</xs:all>
|
</xs:all>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ void main()
|
|||||||
vec4 bloomColor = texture(BloomTexture, Input.TextureCoordinate);
|
vec4 bloomColor = texture(BloomTexture, Input.TextureCoordinate);
|
||||||
vec4 hdrColorLowRes = texture(SceneTextureLowRes, Input.TextureCoordinate);
|
vec4 hdrColorLowRes = texture(SceneTextureLowRes, Input.TextureCoordinate);
|
||||||
vec4 bloomColorLowRes = texture(BloomTextureLowRes, Input.TextureCoordinate);
|
vec4 bloomColorLowRes = texture(BloomTextureLowRes, Input.TextureCoordinate);
|
||||||
|
|
||||||
|
//hdrColor = hdrColor * SSAO;
|
||||||
hdrColor += bloomColor;
|
hdrColor += bloomColor;
|
||||||
hdrColorLowRes;
|
hdrColorLowRes;
|
||||||
|
|
||||||
@@ -33,7 +35,6 @@ void main()
|
|||||||
|
|
||||||
//gamme correction
|
//gamme correction
|
||||||
result = pow(result, vec3(1.0 / Gamma));
|
result = pow(result, vec3(1.0 / Gamma));
|
||||||
|
|
||||||
fragmentColor = vec4(result, 1.0);
|
fragmentColor = vec4(result, 1.0);
|
||||||
//fragmentColor = hdrColor;
|
//fragmentColor = hdrColor;
|
||||||
//fragmentColor = bloomColor;
|
//fragmentColor = bloomColor;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
|
#define MIN_AMBIENT_LIGHT 0.3
|
||||||
|
|
||||||
uniform mat4 M;
|
uniform mat4 M;
|
||||||
uniform mat4 V;
|
uniform mat4 V;
|
||||||
uniform mat4 P;
|
uniform mat4 P;
|
||||||
@@ -10,15 +12,18 @@ uniform vec4 FillColor;
|
|||||||
uniform vec4 AmbientColor;
|
uniform vec4 AmbientColor;
|
||||||
uniform float FillPercentage;
|
uniform float FillPercentage;
|
||||||
uniform float GlowIntensity = 10;
|
uniform float GlowIntensity = 10;
|
||||||
|
uniform vec3 CameraPosition;
|
||||||
|
|
||||||
uniform vec2 DiffuseUVRepeat;
|
uniform vec2 DiffuseUVRepeat;
|
||||||
uniform vec2 NormalUVRepeat;
|
uniform vec2 NormalUVRepeat;
|
||||||
uniform vec2 SpecularUVRepeat;
|
uniform vec2 SpecularUVRepeat;
|
||||||
uniform vec2 GlowUVRepeat;
|
uniform vec2 GlowUVRepeat;
|
||||||
layout (binding = 0) uniform sampler2D DiffuseTexture;
|
layout (binding = 0) uniform sampler2D AOTexture;
|
||||||
layout (binding = 1) uniform sampler2D NormalMapTexture;
|
layout (binding = 1) uniform sampler2D DiffuseTexture;
|
||||||
layout (binding = 2) uniform sampler2D SpecularMapTexture;
|
layout (binding = 2) uniform sampler2D NormalMapTexture;
|
||||||
layout (binding = 3) uniform sampler2D GlowMapTexture;
|
layout (binding = 3) uniform sampler2D SpecularMapTexture;
|
||||||
|
layout (binding = 4) uniform sampler2D GlowMapTexture;
|
||||||
|
layout (binding = 5) uniform samplerCube CubeMap;
|
||||||
|
|
||||||
#define TILE_SIZE 16
|
#define TILE_SIZE 16
|
||||||
|
|
||||||
@@ -73,7 +78,7 @@ struct LightResult {
|
|||||||
};
|
};
|
||||||
|
|
||||||
float CalcAttenuation(float radius, float dist, float falloff) {
|
float CalcAttenuation(float radius, float dist, float falloff) {
|
||||||
return 1.0 - smoothstep(radius * 0.3, radius, dist);
|
return 1.0 - smoothstep(radius * falloff, radius, dist);
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 CalcSpecular(vec4 lightColor, vec4 viewVec, vec4 lightVec, vec4 normal) {
|
vec4 CalcSpecular(vec4 lightColor, vec4 viewVec, vec4 lightVec, vec4 normal) {
|
||||||
@@ -120,6 +125,8 @@ vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textu
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy), 0).r;
|
||||||
|
ao = (clamp(1.0 - (1.0 - ao), 0.0, 1.0) + MIN_AMBIENT_LIGHT) / (1.0 + MIN_AMBIENT_LIGHT);
|
||||||
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate * DiffuseUVRepeat);
|
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate * DiffuseUVRepeat);
|
||||||
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat);
|
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat);
|
||||||
vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate * SpecularUVRepeat);
|
vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate * SpecularUVRepeat);
|
||||||
@@ -127,14 +134,18 @@ void main()
|
|||||||
vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate * NormalUVRepeat, NormalMapTexture);
|
vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate * NormalUVRepeat, NormalMapTexture);
|
||||||
normal = normalize(normal);
|
normal = normalize(normal);
|
||||||
//vec4 normal = normalize(V * vec4(Input.Normal, 0.0));
|
//vec4 normal = normalize(V * vec4(Input.Normal, 0.0));
|
||||||
vec4 viewVec = normalize(-position);
|
vec4 viewVec = normalize(-position);
|
||||||
|
vec3 I = normalize(vec3(M * vec4(Input.Position, 1.0)) - CameraPosition);
|
||||||
|
vec3 R = reflect(-I, Input.Normal);
|
||||||
|
//R = vec3(P * vec4(R, 1.0));
|
||||||
|
vec4 reflectionColor = texture(CubeMap, R);
|
||||||
|
|
||||||
vec2 tilePos;
|
vec2 tilePos;
|
||||||
tilePos.x = int(gl_FragCoord.x/TILE_SIZE);
|
tilePos.x = int(gl_FragCoord.x/TILE_SIZE);
|
||||||
tilePos.y = int(gl_FragCoord.y/TILE_SIZE);
|
tilePos.y = int(gl_FragCoord.y/TILE_SIZE);
|
||||||
|
|
||||||
LightResult totalLighting;
|
LightResult totalLighting;
|
||||||
totalLighting.Diffuse = vec4(AmbientColor.rgb, 1.0);
|
totalLighting.Diffuse = vec4(AmbientColor.rgb * ao, 1.0);
|
||||||
int currentTile = int(floor(gl_FragCoord.x/TILE_SIZE) + (floor(gl_FragCoord.y/TILE_SIZE) * int(ScreenDimensions.x/TILE_SIZE)));
|
int currentTile = int(floor(gl_FragCoord.x/TILE_SIZE) + (floor(gl_FragCoord.y/TILE_SIZE) * int(ScreenDimensions.x/TILE_SIZE)));
|
||||||
|
|
||||||
int start = int(LightGrids.Data[currentTile].Start);
|
int start = int(LightGrids.Data[currentTile].Start);
|
||||||
@@ -152,12 +163,14 @@ void main()
|
|||||||
} else if (light.Type == 2) { //Directional
|
} else if (light.Type == 2) { //Directional
|
||||||
light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal);
|
light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal);
|
||||||
}
|
}
|
||||||
totalLighting.Diffuse += light_result.Diffuse;
|
totalLighting.Diffuse += vec4(light_result.Diffuse.rgb * ao, light_result.Diffuse.a);
|
||||||
totalLighting.Specular += light_result.Specular;
|
totalLighting.Specular += vec4(light_result.Specular.rgb * ao, light_result.Specular.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed);
|
vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed);
|
||||||
color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel));
|
color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel));
|
||||||
|
float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0;
|
||||||
|
color_result = color_result * clamp(1/specularTexel, 0, 1)*2 + reflectionColor * clamp(specularTexel, 0, 1)/2;
|
||||||
//vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color;
|
//vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color;
|
||||||
|
|
||||||
|
|
||||||
@@ -167,9 +180,10 @@ void main()
|
|||||||
color_result += FillColor;
|
color_result += FillColor;
|
||||||
}
|
}
|
||||||
sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1));
|
sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1));
|
||||||
|
//sceneColor = vec4(reflectionColor.xyz, 1);
|
||||||
color_result += glowTexel*GlowIntensity;
|
color_result += glowTexel*GlowIntensity;
|
||||||
|
|
||||||
bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), 1.0);
|
bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), clamp(color_result.a, 0, 1));
|
||||||
|
|
||||||
//Tiled Debug Code
|
//Tiled Debug Code
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -23,12 +23,12 @@ out VertexData{
|
|||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = P*V*M * vec4(Position, 1.0);
|
gl_Position = P*V*M * vec4(Position, 1.0);
|
||||||
|
mat4 TIM = transpose(inverse(M));
|
||||||
Output.Position = Position;
|
Output.Position = Position;
|
||||||
Output.TextureCoordinate = TextureCoords;
|
Output.TextureCoordinate = TextureCoords;
|
||||||
Output.Normal = vec3(M * vec4(Normal, 0.0));
|
Output.Normal = vec3(TIM * vec4(Normal, 0.0));
|
||||||
Output.Tangent = vec3(M * vec4(Tangent, 0.0));
|
Output.Tangent = vec3(TIM * vec4(Tangent, 0.0));
|
||||||
Output.BiTangent = vec3(M * vec4(BiTangent, 0.0));
|
Output.BiTangent = vec3(TIM * vec4(BiTangent, 0.0));
|
||||||
Output.ExplosionColor = vec4(1.0);
|
Output.ExplosionColor = vec4(1.0);
|
||||||
Output.ExplosionPercentageElapsed = 0.0;
|
Output.ExplosionPercentageElapsed = 0.0;
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
|
#define MIN_AMBIENT_LIGHT 0.3
|
||||||
|
|
||||||
uniform mat4 M;
|
uniform mat4 M;
|
||||||
uniform mat4 V;
|
uniform mat4 V;
|
||||||
uniform mat4 P;
|
uniform mat4 P;
|
||||||
@@ -23,19 +25,20 @@ uniform vec2 SpecularUVRepeat3;
|
|||||||
uniform vec2 GlowUVRepeat1;
|
uniform vec2 GlowUVRepeat1;
|
||||||
uniform vec2 GlowUVRepeat2;
|
uniform vec2 GlowUVRepeat2;
|
||||||
uniform vec2 GlowUVRepeat3;
|
uniform vec2 GlowUVRepeat3;
|
||||||
layout (binding = 0) uniform sampler2D SplatMapTexture;
|
layout (binding = 0) uniform sampler2D AOTexture;
|
||||||
layout (binding = 1) uniform sampler2D DiffuseTexture1;
|
layout (binding = 1) uniform sampler2D SplatMapTexture;
|
||||||
layout (binding = 2) uniform sampler2D DiffuseTexture2;
|
layout (binding = 2) uniform sampler2D DiffuseTexture1;
|
||||||
layout (binding = 3) uniform sampler2D DiffuseTexture3;
|
layout (binding = 3) uniform sampler2D DiffuseTexture2;
|
||||||
layout (binding = 4) uniform sampler2D NormalMapTexture1;
|
layout (binding = 4) uniform sampler2D DiffuseTexture3;
|
||||||
layout (binding = 5) uniform sampler2D NormalMapTexture2;
|
layout (binding = 5) uniform sampler2D NormalMapTexture1;
|
||||||
layout (binding = 6) uniform sampler2D NormalMapTexture3;
|
layout (binding = 6) uniform sampler2D NormalMapTexture2;
|
||||||
layout (binding = 7) uniform sampler2D SpecularMapTexture1;
|
layout (binding = 7) uniform sampler2D NormalMapTexture3;
|
||||||
layout (binding = 8) uniform sampler2D SpecularMapTexture2;
|
layout (binding = 8) uniform sampler2D SpecularMapTexture1;
|
||||||
layout (binding = 9) uniform sampler2D SpecularMapTexture3;
|
layout (binding = 9) uniform sampler2D SpecularMapTexture2;
|
||||||
layout (binding = 10) uniform sampler2D GlowMapTexture1;
|
layout (binding = 10) uniform sampler2D SpecularMapTexture3;
|
||||||
layout (binding = 11) uniform sampler2D GlowMapTexture2;
|
layout (binding = 11) uniform sampler2D GlowMapTexture1;
|
||||||
layout (binding = 12) uniform sampler2D GlowMapTexture3;
|
layout (binding = 12) uniform sampler2D GlowMapTexture2;
|
||||||
|
layout (binding = 13) uniform sampler2D GlowMapTexture3;
|
||||||
|
|
||||||
#define TILE_SIZE 16
|
#define TILE_SIZE 16
|
||||||
|
|
||||||
@@ -174,6 +177,9 @@ vec4 CalcBlendedNormal(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B,
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy), 0).r;
|
||||||
|
ao = (clamp(1.0 - (1.0 - ao), 0.0, 1.0) + MIN_AMBIENT_LIGHT) / (1.0 + MIN_AMBIENT_LIGHT);
|
||||||
|
|
||||||
vec4 splatTexel = texture2D(SplatMapTexture, Input.TextureCoordinate);
|
vec4 splatTexel = texture2D(SplatMapTexture, Input.TextureCoordinate);
|
||||||
|
|
||||||
vec4 diffuseTexel = CalcBlendedTexel(splatTexel, DiffuseTexture1, DiffuseTexture2, DiffuseTexture3,
|
vec4 diffuseTexel = CalcBlendedTexel(splatTexel, DiffuseTexture1, DiffuseTexture2, DiffuseTexture3,
|
||||||
@@ -195,7 +201,7 @@ void main()
|
|||||||
tilePos.y = int(gl_FragCoord.y/TILE_SIZE);
|
tilePos.y = int(gl_FragCoord.y/TILE_SIZE);
|
||||||
|
|
||||||
LightResult totalLighting;
|
LightResult totalLighting;
|
||||||
totalLighting.Diffuse = vec4(AmbientColor.rgb, 1.0);
|
totalLighting.Diffuse = vec4(AmbientColor.rgb * ao, 1.0);
|
||||||
int currentTile = int(floor(gl_FragCoord.x/TILE_SIZE) + (floor(gl_FragCoord.y/TILE_SIZE) * int(ScreenDimensions.x/TILE_SIZE)));
|
int currentTile = int(floor(gl_FragCoord.x/TILE_SIZE) + (floor(gl_FragCoord.y/TILE_SIZE) * int(ScreenDimensions.x/TILE_SIZE)));
|
||||||
|
|
||||||
int start = int(LightGrids.Data[currentTile].Start);
|
int start = int(LightGrids.Data[currentTile].Start);
|
||||||
@@ -213,8 +219,8 @@ void main()
|
|||||||
} else if (light.Type == 2) { //Directional
|
} else if (light.Type == 2) { //Directional
|
||||||
light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal);
|
light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal);
|
||||||
}
|
}
|
||||||
totalLighting.Diffuse += light_result.Diffuse;
|
totalLighting.Diffuse += vec4(light_result.Diffuse.rgb * ao, light_result.Diffuse.a);
|
||||||
totalLighting.Specular += light_result.Specular;
|
totalLighting.Specular += vec4(light_result.Specular.rgb * ao, light_result.Specular.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed);
|
vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed);
|
||||||
|
|||||||
@@ -0,0 +1,114 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
//Number of samples per pixel
|
||||||
|
uniform int uNumOfSamples;
|
||||||
|
//#define NUM_SAMPLES (11)
|
||||||
|
|
||||||
|
//Number of turns around the cirle
|
||||||
|
uniform int uNumOfTurns;
|
||||||
|
//#define NUM_TURNS (7)
|
||||||
|
|
||||||
|
layout (binding = 0) uniform sampler2D ViewSpaceZ;
|
||||||
|
|
||||||
|
uniform vec4 uProjInfo;
|
||||||
|
|
||||||
|
uniform float uProjScale;
|
||||||
|
//#define ProjScale 500
|
||||||
|
|
||||||
|
uniform float uRadius;
|
||||||
|
//#define Radius 1.0f
|
||||||
|
|
||||||
|
uniform float uBias;
|
||||||
|
//#define Bias 0.012f
|
||||||
|
|
||||||
|
uniform float uContrast;
|
||||||
|
//#define IntensityDivR6 1
|
||||||
|
|
||||||
|
uniform float uIntensityScale;
|
||||||
|
|
||||||
|
out float AO;
|
||||||
|
|
||||||
|
vec3 getVSPosition(ivec2 ScreenSpaceCoord) {
|
||||||
|
float z = texelFetch(ViewSpaceZ, ScreenSpaceCoord, 0).r;
|
||||||
|
//Get the xy view space coordinates and add the z value from ViewSpaceZ buffer.
|
||||||
|
return vec3((uProjInfo[0] + (ScreenSpaceCoord.x * uProjInfo[1])) * z, (uProjInfo[2] + (ScreenSpaceCoord.y * uProjInfo[3])) * z, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 getVSFaceNormal(vec3 ViewSpacePosition) {
|
||||||
|
// Get tangets vector for the plane and ViewSpacePositin... don't ask how this functions works. It's pure magic.
|
||||||
|
// They do this and it just works... I would guess that they approximate the function of a plane from pixels close to the pixel were on now.
|
||||||
|
return normalize(cross(dFdx(ViewSpacePosition), dFdy(ViewSpacePosition)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vec3 getSampleViewSpacePos(ivec2 ScreenSpaceCoord, int SampleIndex, float RotationAngle, float ScreenSpaceSampleRadius){
|
||||||
|
// Pure Magic...
|
||||||
|
float alpha = float(SampleIndex) * (1.0 / uNumOfSamples);
|
||||||
|
|
||||||
|
// Angle to where to sample
|
||||||
|
float angle = alpha * (uNumOfTurns * 6.28) + RotationAngle;
|
||||||
|
|
||||||
|
//Lenght to were to sample
|
||||||
|
ScreenSpaceSampleRadius = ScreenSpaceSampleRadius * alpha;
|
||||||
|
|
||||||
|
vec2 screenSpaceSampleOffsetVecor = vec2(cos(angle), sin(angle));
|
||||||
|
|
||||||
|
// Get texel coordinate on where to sample by going screenSpaceSampleOffsetVecor direction in ScreenSpaceSampleRadius units from ScreenSpaceCoord (the point being shaded);
|
||||||
|
ivec2 screenSpaceSampleTexel = ivec2(ScreenSpaceSampleRadius * screenSpaceSampleOffsetVecor) + ScreenSpaceCoord;
|
||||||
|
|
||||||
|
return getVSPosition(screenSpaceSampleTexel);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
float sampleAO(ivec2 ScreenSpaceCoord, vec3 Origin, vec3 OriginNormal, float ScreenSpaceSampleRadius, int SampleIndex, float RotationAngle, float Radius) {
|
||||||
|
float radius2 = Radius * Radius;
|
||||||
|
vec3 sampleViewSpacePosition = getSampleViewSpacePos(ScreenSpaceCoord, SampleIndex, RotationAngle, ScreenSpaceSampleRadius);
|
||||||
|
|
||||||
|
vec3 sampleVector = Origin - sampleViewSpacePosition;
|
||||||
|
|
||||||
|
// vv = sampleVectorLenght ^ 2
|
||||||
|
float vv = dot(sampleVector, sampleVector);
|
||||||
|
// vn = angle between sampleVector and Normal
|
||||||
|
float vn = dot(sampleVector, OriginNormal);
|
||||||
|
|
||||||
|
const float epsilon = 0.0001f;
|
||||||
|
|
||||||
|
// vv < radius2 if the vector is shorter then the radius;
|
||||||
|
// vn - bias, offset the angle to reduse self occlusion.
|
||||||
|
// epsilon is here to make divison by 0 impossible.
|
||||||
|
return float(vv < radius2) * max((vn - uBias) / (epsilon + vv), 0.0);
|
||||||
|
//float f = max(radius2 - vv, 0.0);
|
||||||
|
//return f * f * f * max((vn - uBias) / (epsilon + vv), 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
ivec2 originScreenCoord = ivec2(gl_FragCoord.xy);
|
||||||
|
|
||||||
|
vec3 origin = getVSPosition(originScreenCoord);
|
||||||
|
|
||||||
|
float radius;
|
||||||
|
if(origin.z < uRadius){
|
||||||
|
radius = origin.z;
|
||||||
|
} else {
|
||||||
|
radius = uRadius;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
vec3 originNormal = getVSFaceNormal(origin);
|
||||||
|
|
||||||
|
float screenSpaceSampleRadius = -uProjScale * radius / origin.z;
|
||||||
|
|
||||||
|
float rotationAngleOffset = 30 * originScreenCoord.x ^ originScreenCoord.y + 10 * originScreenCoord.x * originScreenCoord.y;
|
||||||
|
|
||||||
|
float sum = 0.0;
|
||||||
|
for (int i = 0; i < uNumOfSamples; i++) {
|
||||||
|
sum += sampleAO(originScreenCoord, origin, originNormal, screenSpaceSampleRadius, i, rotationAngleOffset, radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
//float A = max(0.0, 1.0 - sum * (2.0f / uNumOfSamples));
|
||||||
|
float A = 1.0 - sum * (2.0f * uIntensityScale / float(uNumOfSamples));
|
||||||
|
AO = clamp(pow(A, uContrast), 0.0f, 1.0f);
|
||||||
|
//AO = vec4(originNormal, 1.0f);
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
layout (location = 0) in vec3 Position;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = vec4(Position, 1.0);
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
layout (binding = 0) uniform sampler2D DepthBuffer;
|
||||||
|
uniform vec3 ClipInfo;
|
||||||
|
|
||||||
|
out float depthLinear;
|
||||||
|
//Just for Debug, should be depthLinear
|
||||||
|
//out vec4 fragmentColor;
|
||||||
|
void main() {
|
||||||
|
float depthSample = texelFetch(DepthBuffer, ivec2(gl_FragCoord.xy), 0).r;
|
||||||
|
depthLinear = ClipInfo[0] / (ClipInfo[1] * depthSample + ClipInfo[2]);
|
||||||
|
//float depthLinear = (NearClip) / ( -depthSample + 1.0f);
|
||||||
|
//fragmentColor = vec4(depthLinear, depthLinear, depthLinear, 1.0f);
|
||||||
|
}
|
||||||
@@ -7,8 +7,8 @@ uniform mat4 M;
|
|||||||
uniform mat4 V;
|
uniform mat4 V;
|
||||||
uniform mat4 P;
|
uniform mat4 P;
|
||||||
|
|
||||||
layout (binding = 0) uniform sampler2D DiffuseTexture;
|
layout (binding = 1) uniform sampler2D DiffuseTexture;
|
||||||
layout (binding = 1) uniform sampler2D GlowMapTexture;
|
layout (binding = 2) uniform sampler2D GlowMapTexture;
|
||||||
|
|
||||||
|
|
||||||
in VertexData{
|
in VertexData{
|
||||||
|
|||||||
@@ -51,6 +51,13 @@ EntityWrapper EntityWrapper::FirstParentWithComponent(const std::string& compone
|
|||||||
return EntityWrapper::Invalid;
|
return EntityWrapper::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<EntityWrapper> EntityWrapper::ChildrenWithComponent(const std::string& componentType)
|
||||||
|
{
|
||||||
|
std::vector<EntityWrapper> childrenWithComponent;
|
||||||
|
childrenWithComponentRecursive(componentType, *this, childrenWithComponent);
|
||||||
|
return childrenWithComponent;
|
||||||
|
}
|
||||||
|
|
||||||
bool EntityWrapper::IsChildOf(EntityWrapper potentialParent)
|
bool EntityWrapper::IsChildOf(EntityWrapper potentialParent)
|
||||||
{
|
{
|
||||||
EntityWrapper entity = *this;
|
EntityWrapper entity = *this;
|
||||||
@@ -131,3 +138,18 @@ EntityWrapper EntityWrapper::firstChildByNameRecursive(const std::string& name,
|
|||||||
return EntityWrapper::Invalid;
|
return EntityWrapper::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntityWrapper::childrenWithComponentRecursive(const std::string& componentType, EntityWrapper& entity, std::vector<EntityWrapper>& childrenWithComponent)
|
||||||
|
{
|
||||||
|
auto itPair = this->World->GetChildren(entity.ID);
|
||||||
|
if (itPair.first == itPair.second) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto it = itPair.first; it != itPair.second; ++it) {
|
||||||
|
if (entity.HasComponent(componentType)) {
|
||||||
|
childrenWithComponent.push_back(entity);
|
||||||
|
}
|
||||||
|
childrenWithComponentRecursive(componentType, entity, childrenWithComponent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "Network/Client.h"
|
#include "Network/Client.h"
|
||||||
using namespace boost::asio::ip;
|
using namespace boost::asio::ip;
|
||||||
|
|
||||||
Client::Client(World* world, EventBroker* eventBroker)
|
Client::Client(World* world, EventBroker* eventBroker)
|
||||||
: Network(world, eventBroker)
|
: Network(world, eventBroker)
|
||||||
{
|
{
|
||||||
// Asumes root node is EntityID_Invalid
|
// Asumes root node is EntityID_Invalid
|
||||||
@@ -13,6 +13,8 @@ Client::Client(World* world, EventBroker* eventBroker)
|
|||||||
m_PlayerName = config->Get<std::string>("Networking.Name", "Raptorcopter");
|
m_PlayerName = config->Get<std::string>("Networking.Name", "Raptorcopter");
|
||||||
m_SendInputIntervalMs = config->Get<int>("Networking.SendInputIntervalMs", 33);
|
m_SendInputIntervalMs = config->Get<int>("Networking.SendInputIntervalMs", 33);
|
||||||
LOG_INFO("Client initialized");
|
LOG_INFO("Client initialized");
|
||||||
|
|
||||||
|
m_ServerlistRequest.Connect(m_PlayerName, "192.168.1.255", 32554);
|
||||||
}
|
}
|
||||||
|
|
||||||
Client::Client(World* world, EventBroker* eventBroker, std::unique_ptr<SnapshotFilter> snapshotFilter)
|
Client::Client(World* world, EventBroker* eventBroker, std::unique_ptr<SnapshotFilter> snapshotFilter)
|
||||||
@@ -30,6 +32,7 @@ void Client::Connect(std::string address, int port)
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Client::OnInputCommand);
|
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Client::OnInputCommand);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &Client::OnPlayerDamage);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &Client::OnPlayerDamage);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &Client::OnPlayerSpawned);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &Client::OnPlayerSpawned);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_ESearchForServers, &Client::OnSearchForServers);
|
||||||
auto config = ResourceManager::Load<ConfigFile>("Config.ini");
|
auto config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||||
m_Address = address;
|
m_Address = address;
|
||||||
if (address.empty()) {
|
if (address.empty()) {
|
||||||
@@ -66,6 +69,21 @@ void Client::Update()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (m_ServerlistRequest.IsSocketAvailable()) {
|
||||||
|
Packet packet(MessageType::Invalid);
|
||||||
|
m_ServerlistRequest.Receive(packet);
|
||||||
|
if (packet.GetMessageType() == MessageType::ServerlistRequest) {
|
||||||
|
parseServerlist(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_SearchingForServers) {
|
||||||
|
if (m_SearchingTime < (1000* (std::clock() - m_StartSearchTime) / (double)CLOCKS_PER_SEC)) {
|
||||||
|
m_SearchingForServers = false;
|
||||||
|
displayServerlist();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (m_IsConnected) {
|
if (m_IsConnected) {
|
||||||
// Don't send 1 input in 1 packet, bunch em up.
|
// Don't send 1 input in 1 packet, bunch em up.
|
||||||
if (m_SendInputIntervalMs < (1000 * (std::clock() - m_TimeSinceSentInputs) / (double)CLOCKS_PER_SEC)) {
|
if (m_SendInputIntervalMs < (1000 * (std::clock() - m_TimeSinceSentInputs) / (double)CLOCKS_PER_SEC)) {
|
||||||
@@ -173,6 +191,22 @@ void Client::parsePing()
|
|||||||
m_Reliable.Send(packet);
|
m_Reliable.Send(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Client::parseServerlist(Packet& packet)
|
||||||
|
{
|
||||||
|
// Pop size, message type, and ID
|
||||||
|
packet.ReadPrimitive<int>();
|
||||||
|
packet.ReadPrimitive<int>();
|
||||||
|
packet.ReadPrimitive<int>();
|
||||||
|
std::string address = packet.ReadString();
|
||||||
|
int port = packet.ReadPrimitive<int>();
|
||||||
|
std::string serverName = packet.ReadString();
|
||||||
|
int playersConnected = packet.ReadPrimitive<int>();
|
||||||
|
//TODO: This should not happen when a client is connected to a server
|
||||||
|
|
||||||
|
m_Serverlist.push_back({ address, port, serverName, playersConnected });
|
||||||
|
}
|
||||||
|
|
||||||
void Client::parseKick()
|
void Client::parseKick()
|
||||||
{
|
{
|
||||||
LOG_WARNING("You have been kicked from the server.");
|
LOG_WARNING("You have been kicked from the server.");
|
||||||
@@ -190,12 +224,12 @@ void Client::parseSpawnEvents()
|
|||||||
}
|
}
|
||||||
e.Player = EntityWrapper(m_World, m_ServerIDToClientID.at(m_PlayerSpawnEvents.at(i).Player.ID));
|
e.Player = EntityWrapper(m_World, m_ServerIDToClientID.at(m_PlayerSpawnEvents.at(i).Player.ID));
|
||||||
//e.Spawner = EntityWrapper(m_World, m_ServerIDToClientID.at(m_PlayerSpawnEvents.at(i).Spawner.ID));
|
//e.Spawner = EntityWrapper(m_World, m_ServerIDToClientID.at(m_PlayerSpawnEvents.at(i).Spawner.ID));
|
||||||
e.PlayerID = -1;
|
e.PlayerID = -1;
|
||||||
e.PlayerName = m_PlayerSpawnEvents.at(i).PlayerName;
|
e.PlayerName = m_PlayerSpawnEvents.at(i).PlayerName;
|
||||||
m_EventBroker->Publish(e);
|
m_EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
m_PlayerSpawnEvents = tempSpawn;
|
m_PlayerSpawnEvents = tempSpawn;
|
||||||
// m_PlayerSpawnEvents.clear();
|
// m_PlayerSpawnEvents.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::parsePlayersSpawned(Packet& packet)
|
void Client::parsePlayersSpawned(Packet& packet)
|
||||||
@@ -312,16 +346,18 @@ void Client::parseSnapshot(Packet& packet)
|
|||||||
if (serverClientMapsHasEntity(serverEntityID)) {
|
if (serverClientMapsHasEntity(serverEntityID)) {
|
||||||
EntityID localEntityID = m_ServerIDToClientID.at(serverEntityID);
|
EntityID localEntityID = m_ServerIDToClientID.at(serverEntityID);
|
||||||
EntityWrapper localEntity(m_World, localEntityID);
|
EntityWrapper localEntity(m_World, localEntityID);
|
||||||
|
|
||||||
// Update entity
|
// Update entity
|
||||||
if (m_World->HasComponent(localEntityID, componentType)) {
|
if (m_World->HasComponent(localEntityID, componentType)) {
|
||||||
|
if (localEntity.Name() == "CapturePointHUD") {
|
||||||
|
UpdateLocalCapturePointHUD(localEntity);
|
||||||
|
}
|
||||||
SharedComponentWrapper newComponent = createSharedComponent(packet, localEntityID, componentInfo);
|
SharedComponentWrapper newComponent = createSharedComponent(packet, localEntityID, componentInfo);
|
||||||
bool shouldApply = true;
|
bool shouldApply = true;
|
||||||
// Apply potential filter function
|
// Apply potential filter function
|
||||||
if (m_SnapshotFilter != nullptr) {
|
if (m_SnapshotFilter != nullptr) {
|
||||||
shouldApply = m_SnapshotFilter->FilterComponent(localEntity, newComponent);
|
shouldApply = m_SnapshotFilter->FilterComponent(localEntity, newComponent);
|
||||||
}
|
}
|
||||||
if (shouldApply) {
|
if (shouldApply) {
|
||||||
ComponentWrapper currentComponent = m_World->GetComponent(localEntityID, componentType);
|
ComponentWrapper currentComponent = m_World->GetComponent(localEntityID, componentType);
|
||||||
memcpy(currentComponent.Data, newComponent.Data, componentInfo.Stride);
|
memcpy(currentComponent.Data, newComponent.Data, componentInfo.Stride);
|
||||||
}
|
}
|
||||||
@@ -359,6 +395,18 @@ void Client::parseSnapshot(Packet& packet)
|
|||||||
parseSpawnEvents();
|
parseSpawnEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Client::UpdateLocalCapturePointHUD(EntityWrapper capturePointHUD)
|
||||||
|
{
|
||||||
|
//auto children = m_World->GetChildren(capturePointHUD.ID);
|
||||||
|
//for (auto it = children.first; it != children.second; it++) {
|
||||||
|
// it->first
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//EntityWrapper& localHUD = m_LocalPlayer.FirstChildByName("HUD").FirstChildByName("CapturePointHUD");
|
||||||
|
//m_World->GetComponentPools()
|
||||||
|
}
|
||||||
|
|
||||||
void Client::disconnect()
|
void Client::disconnect()
|
||||||
{
|
{
|
||||||
m_IsConnected = false;
|
m_IsConnected = false;
|
||||||
@@ -371,6 +419,12 @@ void Client::disconnect()
|
|||||||
|
|
||||||
bool Client::OnInputCommand(const Events::InputCommand & e)
|
bool Client::OnInputCommand(const Events::InputCommand & e)
|
||||||
{
|
{
|
||||||
|
// TEMP
|
||||||
|
if (e.Command == "SearchForServers" && e.Value > 0) {
|
||||||
|
Events::SearchForServers e;
|
||||||
|
m_EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
|
||||||
if (e.PlayerID != -1) {
|
if (e.PlayerID != -1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -433,6 +487,17 @@ bool Client::OnPlayerSpawned(const Events::PlayerSpawned& e)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Client::OnSearchForServers(const Events::SearchForServers& e)
|
||||||
|
{
|
||||||
|
m_SearchingForServers = true;
|
||||||
|
m_StartSearchTime = std::clock();
|
||||||
|
m_Serverlist.clear();
|
||||||
|
LOG_INFO("Searching for LAN servers...\n");
|
||||||
|
Packet packet(MessageType::ServerlistRequest);
|
||||||
|
m_ServerlistRequest.Broadcast(packet, 13); // TODO: Config
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void Client::parsePlayerDamage(Packet& packet)
|
void Client::parsePlayerDamage(Packet& packet)
|
||||||
{
|
{
|
||||||
Events::PlayerDamage e;
|
Events::PlayerDamage e;
|
||||||
@@ -467,7 +532,7 @@ void Client::sendLocalPlayerTransform()
|
|||||||
packet.WritePrimitive(orientation.x);
|
packet.WritePrimitive(orientation.x);
|
||||||
packet.WritePrimitive(orientation.y);
|
packet.WritePrimitive(orientation.y);
|
||||||
packet.WritePrimitive(orientation.z);
|
packet.WritePrimitive(orientation.z);
|
||||||
|
|
||||||
bool hasAssaultWeapon = m_LocalPlayer.HasComponent("AssaultWeapon");
|
bool hasAssaultWeapon = m_LocalPlayer.HasComponent("AssaultWeapon");
|
||||||
packet.WritePrimitive(hasAssaultWeapon);
|
packet.WritePrimitive(hasAssaultWeapon);
|
||||||
if (hasAssaultWeapon) {
|
if (hasAssaultWeapon) {
|
||||||
@@ -475,7 +540,7 @@ void Client::sendLocalPlayerTransform()
|
|||||||
packet.WritePrimitive((int)cAssaultWeapon["MagazineAmmo"]);
|
packet.WritePrimitive((int)cAssaultWeapon["MagazineAmmo"]);
|
||||||
packet.WritePrimitive((int)cAssaultWeapon["Ammo"]);
|
packet.WritePrimitive((int)cAssaultWeapon["Ammo"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Unreliable.Send(packet);
|
m_Unreliable.Send(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -528,6 +593,16 @@ void Client::becomePlayer()
|
|||||||
m_Reliable.Send(packet);
|
m_Reliable.Send(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Client::displayServerlist()
|
||||||
|
{
|
||||||
|
LOG_INFO("This is a serverlist:\n");
|
||||||
|
for (int i = 0; i < m_Serverlist.size(); i++) {
|
||||||
|
ServerInfo si = m_Serverlist[i];
|
||||||
|
LOG_INFO("%s:%i\t%s\t%i\n", si.Address.c_str(), si.Port, si.Name.c_str(), si.PlayersConnected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Client::clientServerMapsHasEntity(EntityID clientEntityID)
|
bool Client::clientServerMapsHasEntity(EntityID clientEntityID)
|
||||||
{
|
{
|
||||||
if (m_ClientIDToServerID.find(clientEntityID) != m_ClientIDToServerID.end()) {
|
if (m_ClientIDToServerID.find(clientEntityID) != m_ClientIDToServerID.end()) {
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
#include "Network/HybridClient.h"
|
|
||||||
|
|
||||||
|
|
||||||
HybridClient::HybridClient()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
HybridClient::~HybridClient()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#include "Network/HybridServer.h"
|
|
||||||
|
|
||||||
HybridServer::HybridServer()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
HybridServer::~HybridServer()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
#include "Network/Server.h"
|
#include "Network/Server.h"
|
||||||
|
|
||||||
Server::Server(World* world, EventBroker* eventBroker, int port)
|
Server::Server(World* world, EventBroker* eventBroker, int port)
|
||||||
: Network(world, eventBroker)
|
: Network(world, eventBroker)
|
||||||
|
, m_ServerlistRequest(13)
|
||||||
{
|
{
|
||||||
ConfigFile* config = ResourceManager::Load<ConfigFile>("Config.ini");
|
ConfigFile* config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||||
snapshotInterval = 1000 * config->Get<float>("Networking.SnapshotInterval", 0.05f);
|
snapshotInterval = 1000 * config->Get<float>("Networking.SnapshotInterval", 0.05f);
|
||||||
@@ -13,7 +14,7 @@ Server::Server(World* world, EventBroker* eventBroker, int port)
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EComponentDeleted, &Server::OnComponentDeleted);
|
EVENT_SUBSCRIBE_MEMBER(m_EComponentDeleted, &Server::OnComponentDeleted);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &Server::OnPlayerDamage);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &Server::OnPlayerDamage);
|
||||||
|
|
||||||
// Bind
|
// BindWW
|
||||||
if (port == 0) {
|
if (port == 0) {
|
||||||
port = config->Get<float>("Networking.Port", 27666);
|
port = config->Get<float>("Networking.Port", 27666);
|
||||||
}
|
}
|
||||||
@@ -58,8 +59,24 @@ void Server::Update()
|
|||||||
parseMessageType(packet);
|
parseMessageType(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (m_ServerlistRequest.IsSocketAvailable()) {
|
||||||
|
Packet packet(MessageType::Invalid);
|
||||||
|
PlayerDefinition localArea;
|
||||||
|
localArea.Endpoint = boost::asio::ip::udp::endpoint();
|
||||||
|
m_ServerlistRequest.Receive(packet, localArea);
|
||||||
|
if(packet.GetMessageType() == MessageType::ServerlistRequest) {
|
||||||
|
packet.ReadPrimitive<int>(); // Pop size
|
||||||
|
packet.ReadPrimitive<int>(); // Pop MsgType
|
||||||
|
packet.ReadPrimitive<int>(); // Pop packet ID
|
||||||
|
int port = packet.ReadPrimitive<int>();
|
||||||
|
std::string address = localArea.Endpoint.address().to_string();
|
||||||
|
parseServerlistRequest(boost::asio::ip::udp::endpoint(boost::asio::ip::address().from_string(address), port));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check if players have disconnected
|
// Check if players have disconnected
|
||||||
for (int i = 0; i < m_PlayersToDisconnect.size(); i++) {
|
for (int i = 0; i < m_PlayersToDisconnect.size(); i++) {
|
||||||
disconnect(m_PlayersToDisconnect.at(i));
|
disconnect(m_PlayersToDisconnect.at(i));
|
||||||
}
|
}
|
||||||
m_PlayersToDisconnect.clear();
|
m_PlayersToDisconnect.clear();
|
||||||
@@ -75,6 +92,7 @@ void Server::Update()
|
|||||||
sendPing();
|
sendPing();
|
||||||
previousePingMessage = currentTime;
|
previousePingMessage = currentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Time out logic
|
// Time out logic
|
||||||
if (checkTimeOutInterval < (1000 * (currentTime - timOutTimer) / (double)CLOCKS_PER_SEC)) {
|
if (checkTimeOutInterval < (1000 * (currentTime - timOutTimer) / (double)CLOCKS_PER_SEC)) {
|
||||||
checkForTimeOuts();
|
checkForTimeOuts();
|
||||||
@@ -118,7 +136,7 @@ void Server::parseMessageType(Packet& packet)
|
|||||||
parseOnPlayerDamage(packet);
|
parseOnPlayerDamage(packet);
|
||||||
break;
|
break;
|
||||||
case MessageType::PlayerTransform:
|
case MessageType::PlayerTransform:
|
||||||
parsePlayerTransform(packet);
|
parsePlayerTransform(packet);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -171,6 +189,7 @@ void Server::addPlayersToPacket(Packet & packet, EntityID entityID)
|
|||||||
for (auto it = itPair.first; it != itPair.second; it++) {
|
for (auto it = itPair.first; it != itPair.second; it++) {
|
||||||
EntityID childEntityID = it->second;
|
EntityID childEntityID = it->second;
|
||||||
// HACK: Only sync players for now, since the map turned out to be TOO LARGE to send in one snapshot and Simon's computer shits itself
|
// HACK: Only sync players for now, since the map turned out to be TOO LARGE to send in one snapshot and Simon's computer shits itself
|
||||||
|
// HACK: Also checked CapturePointHUD for now. (this would get out of sync);
|
||||||
EntityWrapper childEntity(m_World, childEntityID);
|
EntityWrapper childEntity(m_World, childEntityID);
|
||||||
if (!shouldSendToClient(childEntity)) {
|
if (!shouldSendToClient(childEntity)) {
|
||||||
continue;
|
continue;
|
||||||
@@ -273,6 +292,8 @@ void Server::sendPing()
|
|||||||
reliableBroadcast(packet);
|
reliableBroadcast(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Server::checkForTimeOuts()
|
void Server::checkForTimeOuts()
|
||||||
{
|
{
|
||||||
double startPing = 1000 * m_StartPingTime
|
double startPing = 1000 * m_StartPingTime
|
||||||
@@ -370,6 +391,17 @@ void Server::parseDisconnect()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Server::parseServerlistRequest(boost::asio::ip::udp::endpoint endpoint)
|
||||||
|
{
|
||||||
|
Packet packet(MessageType::ServerlistRequest);
|
||||||
|
packet.WriteString(m_Reliable.Address());
|
||||||
|
packet.WritePrimitive<int>(m_Reliable.Port());
|
||||||
|
packet.WriteString("SERVERNAME");
|
||||||
|
packet.WritePrimitive<int>(m_ConnectedPlayers.size());
|
||||||
|
m_ServerlistRequest.Send(packet);
|
||||||
|
}
|
||||||
|
|
||||||
void Server::disconnect(PlayerID playerID)
|
void Server::disconnect(PlayerID playerID)
|
||||||
{
|
{
|
||||||
//broadcast("A player disconnected");
|
//broadcast("A player disconnected");
|
||||||
@@ -394,6 +426,7 @@ void Server::parseOnPlayerDamage(Packet & packet)
|
|||||||
e.Victim = EntityWrapper(m_World, packet.ReadPrimitive<EntityID>());
|
e.Victim = EntityWrapper(m_World, packet.ReadPrimitive<EntityID>());
|
||||||
e.Damage = packet.ReadPrimitive<double>();
|
e.Damage = packet.ReadPrimitive<double>();
|
||||||
m_EventBroker->Publish(e);
|
m_EventBroker->Publish(e);
|
||||||
|
|
||||||
//LOG_DEBUG("Server::parseOnPlayerDamage: Command is %s. Value is %f. PlayerID is %i.", e.DamageAmount, e.PlayerDamagedID, e.TypeOfDamage.c_str());
|
//LOG_DEBUG("Server::parseOnPlayerDamage: Command is %s. Value is %f. PlayerID is %i.", e.DamageAmount, e.PlayerDamagedID, e.TypeOfDamage.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,7 +456,7 @@ bool Server::OnInputCommand(const Events::InputCommand & e)
|
|||||||
isReadingData = !isReadingData;
|
isReadingData = !isReadingData;
|
||||||
m_SaveDataTimer = std::clock();
|
m_SaveDataTimer = std::clock();
|
||||||
}
|
}
|
||||||
if (e.Command == "KickPlayer" && e.Value > 0) {
|
else if (e.Command == "KickPlayer" && e.Value > 0) {
|
||||||
kick(0);
|
kick(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -562,7 +595,8 @@ void Server::parsePlayerTransform(Packet& packet)
|
|||||||
|
|
||||||
bool Server::shouldSendToClient(EntityWrapper childEntity)
|
bool Server::shouldSendToClient(EntityWrapper childEntity)
|
||||||
{
|
{
|
||||||
return childEntity.HasComponent("Player") || childEntity.FirstParentWithComponent("Player").Valid();
|
return childEntity.HasComponent("Player") || childEntity.FirstParentWithComponent("Player").Valid()
|
||||||
|
|| childEntity.HasComponent("CapturePoint") || childEntity.FirstParentWithComponent("CapturePoint").Valid();
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerID Server::GetPlayerIDFromEndpoint()
|
PlayerID Server::GetPlayerIDFromEndpoint()
|
||||||
|
|||||||
@@ -64,26 +64,6 @@ void TCPClient::Receive(Packet& packet)
|
|||||||
|
|
||||||
size_t TCPClient::readBuffer()
|
size_t TCPClient::readBuffer()
|
||||||
{
|
{
|
||||||
//if (!m_Socket) {
|
|
||||||
// return 0;
|
|
||||||
//}
|
|
||||||
//boost::system::error_code error;
|
|
||||||
//// Read size of packet
|
|
||||||
//size_t bytesReceived = m_Socket->read_some(boost
|
|
||||||
// ::asio::buffer((void*)data, sizeof(int)),
|
|
||||||
// error);
|
|
||||||
//int sizeOfPacket = 0;
|
|
||||||
//memcpy(&sizeOfPacket, data, sizeof(int));
|
|
||||||
|
|
||||||
//// Read the rest of the message
|
|
||||||
//bytesReceived += m_Socket->read_some(boost
|
|
||||||
// ::asio::buffer((void*)(data + bytesReceived), sizeOfPacket - bytesReceived),
|
|
||||||
// error);
|
|
||||||
//if (error) {
|
|
||||||
// //LOG_ERROR("receive: %s", error.message().c_str());
|
|
||||||
//}
|
|
||||||
//return bytesReceived;
|
|
||||||
|
|
||||||
if (!m_Socket) {
|
if (!m_Socket) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
#include "Network/TCPServer.h"
|
#include "Network/TCPServer.h"
|
||||||
using namespace boost::asio::ip;
|
using namespace boost::asio::ip;
|
||||||
|
|
||||||
TCPServer::TCPServer()
|
TCPServer::TCPServer()
|
||||||
{
|
{
|
||||||
acceptor = std::unique_ptr<tcp::acceptor>(new tcp::acceptor(m_IOService, tcp::endpoint(tcp::v4(), 27666)));
|
acceptor = std::unique_ptr<tcp::acceptor>(new tcp::acceptor(m_IOService, tcp::endpoint(tcp::v4(), 27666)));
|
||||||
|
m_Port = GetPort();
|
||||||
|
m_Address = GetAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
TCPServer::~TCPServer()
|
TCPServer::~TCPServer()
|
||||||
@@ -73,40 +75,21 @@ void TCPServer::Send(Packet & packet)
|
|||||||
|
|
||||||
void TCPServer::Disconnect()
|
void TCPServer::Disconnect()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//void TCPServer::Receive(Packet & packet, PlayerDefinition & playerDefinition)
|
int TCPServer::GetPort()
|
||||||
//{
|
{
|
||||||
// int bytesRead = readBuffer(m_ReadBuffer, playerDefinition);
|
return acceptor->local_endpoint().port();
|
||||||
// if (bytesRead > 0) {
|
}
|
||||||
// packet.ReconstructFromData(m_ReadBuffer, bytesRead);
|
|
||||||
// }
|
std::string TCPServer::GetAddress()
|
||||||
// lastReceivedSocket = playerDefinition.TCPSocket;
|
{
|
||||||
//}
|
boost::asio::ip::tcp::resolver resolver(m_IOService);
|
||||||
//
|
boost::asio::ip::tcp::resolver::query query(boost::asio::ip::tcp::v4(), boost::asio::ip::host_name(), "");
|
||||||
//int TCPServer::readBuffer(char* data, PlayerDefinition & playerDefinition)
|
boost::asio::ip::tcp::resolver::iterator it = resolver.resolve(query);
|
||||||
//{
|
boost::asio::ip::tcp::endpoint endpoint = *it;
|
||||||
// if (!playerDefinition.TCPSocket) {
|
return endpoint.address().to_string().c_str();
|
||||||
// return 0;
|
}
|
||||||
// }
|
|
||||||
// boost::system::error_code error;
|
|
||||||
// // Read size of packet
|
|
||||||
// size_t bytesReceived = playerDefinition.TCPSocket->read_some(boost
|
|
||||||
// ::asio::buffer((void*)data, sizeof(int)),
|
|
||||||
// error);
|
|
||||||
// int sizeOfPacket = 0;
|
|
||||||
// memcpy(&sizeOfPacket, data, sizeof(int));
|
|
||||||
//
|
|
||||||
// // Read the rest of the message
|
|
||||||
// bytesReceived += playerDefinition.TCPSocket->read_some(boost
|
|
||||||
// ::asio::buffer((void*)(data + bytesReceived), sizeOfPacket - bytesReceived),
|
|
||||||
// error);
|
|
||||||
// if (error) {
|
|
||||||
// //LOG_ERROR("receive: %s", error.message().c_str());
|
|
||||||
// }
|
|
||||||
// return bytesReceived;
|
|
||||||
//}
|
|
||||||
|
|
||||||
void TCPServer::Receive(Packet & packet, PlayerDefinition & playerDefinition)
|
void TCPServer::Receive(Packet & packet, PlayerDefinition & playerDefinition)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ void UDPClient::Connect(std::string playerName, std::string address, int port)
|
|||||||
if (m_Socket) {
|
if (m_Socket) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_ReceiverEndpoint = udp::endpoint(boost::asio::ip::address::from_string(address), port);
|
m_ReceiverEndpoint = udp::endpoint(boost::asio::ip::address().from_string(address), port);
|
||||||
m_Socket = boost::shared_ptr<boost::asio::ip::udp::socket>(new boost::asio::ip::udp::socket(m_IOService));
|
m_Socket = boost::shared_ptr<boost::asio::ip::udp::socket>(new boost::asio::ip::udp::socket(m_IOService));
|
||||||
m_Socket->connect(m_ReceiverEndpoint);
|
m_Socket->open(boost::asio::ip::udp::v4());
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDPClient::Disconnect()
|
void UDPClient::Disconnect()
|
||||||
@@ -35,18 +35,6 @@ void UDPClient::Receive(Packet& packet)
|
|||||||
|
|
||||||
int UDPClient::readBuffer()
|
int UDPClient::readBuffer()
|
||||||
{
|
{
|
||||||
//if (!m_Socket) {
|
|
||||||
// return 0;
|
|
||||||
//}
|
|
||||||
//boost::system::error_code error;
|
|
||||||
//int bytesReceived = m_Socket->receive_from(boost
|
|
||||||
// ::asio::buffer((void*)data, BUFFERSIZE),
|
|
||||||
// m_ReceiverEndpoint,
|
|
||||||
// 0, error);
|
|
||||||
//if (error) {
|
|
||||||
// //LOG_ERROR("receive: %s", error.message().c_str());
|
|
||||||
//}
|
|
||||||
//return bytesReceived;
|
|
||||||
if (!m_Socket) {
|
if (!m_Socket) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -87,6 +75,18 @@ void UDPClient::Send(Packet& packet)
|
|||||||
packet.Data(),
|
packet.Data(),
|
||||||
packet.Size()),
|
packet.Size()),
|
||||||
m_ReceiverEndpoint, 0);
|
m_ReceiverEndpoint, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UDPClient::Broadcast(Packet& packet, int port)
|
||||||
|
{
|
||||||
|
packet.UpdateSize();
|
||||||
|
m_Socket->set_option(boost::asio::socket_base::broadcast(true));
|
||||||
|
m_Socket->send_to(boost::asio::buffer(
|
||||||
|
packet.Data(),
|
||||||
|
packet.Size()),
|
||||||
|
udp::endpoint(boost::asio::ip::address_v4().broadcast(), port)
|
||||||
|
, 0);
|
||||||
|
m_Socket->set_option(boost::asio::socket_base::broadcast(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UDPClient::IsSocketAvailable()
|
bool UDPClient::IsSocketAvailable()
|
||||||
|
|||||||
@@ -5,6 +5,11 @@ UDPServer::UDPServer()
|
|||||||
m_Socket = std::unique_ptr<boost::asio::ip::udp::socket>(new boost::asio::ip::udp::socket(m_IOService, boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), 27666)));
|
m_Socket = std::unique_ptr<boost::asio::ip::udp::socket>(new boost::asio::ip::udp::socket(m_IOService, boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), 27666)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UDPServer::UDPServer(int port)
|
||||||
|
{
|
||||||
|
m_Socket = std::unique_ptr<boost::asio::ip::udp::socket>(new boost::asio::ip::udp::socket(m_IOService, boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), port)));
|
||||||
|
}
|
||||||
|
|
||||||
UDPServer::~UDPServer()
|
UDPServer::~UDPServer()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@@ -33,6 +38,32 @@ void UDPServer::Send(Packet & packet)
|
|||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Broadcasting respond specific logic
|
||||||
|
void UDPServer::Send(Packet & packet, boost::asio::ip::udp::endpoint endpoint)
|
||||||
|
{
|
||||||
|
packet.UpdateSize();
|
||||||
|
m_Socket->send_to(
|
||||||
|
boost::asio::buffer(
|
||||||
|
packet.Data(),
|
||||||
|
packet.Size()),
|
||||||
|
endpoint,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Broadcasting
|
||||||
|
void UDPServer::Broadcast(Packet & packet, int port)
|
||||||
|
{
|
||||||
|
packet.UpdateSize();
|
||||||
|
m_Socket->set_option(boost::asio::socket_base::broadcast(true));
|
||||||
|
m_Socket->send_to(
|
||||||
|
boost::asio::buffer(
|
||||||
|
packet.Data(),
|
||||||
|
packet.Size()),
|
||||||
|
boost::asio::ip::udp::endpoint(boost::asio::ip::address_v4().broadcast(),port),
|
||||||
|
0);
|
||||||
|
m_Socket->set_option(boost::asio::socket_base::broadcast(false));
|
||||||
|
}
|
||||||
|
|
||||||
void UDPServer::Receive(Packet & packet, PlayerDefinition & playerDefinition)
|
void UDPServer::Receive(Packet & packet, PlayerDefinition & playerDefinition)
|
||||||
{
|
{
|
||||||
int bytesRead = readBuffer();
|
int bytesRead = readBuffer();
|
||||||
@@ -49,18 +80,10 @@ bool UDPServer::IsSocketAvailable()
|
|||||||
|
|
||||||
int UDPServer::readBuffer()
|
int UDPServer::readBuffer()
|
||||||
{
|
{
|
||||||
//boost::system::error_code error = boost::asio::error::host_not_found;
|
|
||||||
//unsigned int length = m_Socket->receive_from(
|
|
||||||
// boost::asio::buffer((void*)data
|
|
||||||
// , BUFFERSIZE)
|
|
||||||
// , m_ReceiverEndpoint, 0, error);
|
|
||||||
//if (error) {
|
|
||||||
// LOG_WARNING(error.message().c_str());
|
|
||||||
//}
|
|
||||||
//return length;
|
|
||||||
if (!m_Socket) {
|
if (!m_Socket) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
int addasdasd = m_Socket->available();
|
||||||
boost::system::error_code error;
|
boost::system::error_code error;
|
||||||
// Read size of packet
|
// Read size of packet
|
||||||
m_Socket->receive_from(boost
|
m_Socket->receive_from(boost
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
#include "Rendering/CubeMapPass.h"
|
||||||
|
|
||||||
|
CubeMapPass::CubeMapPass(IRenderer* renderer)
|
||||||
|
:m_Renderer(renderer)
|
||||||
|
{
|
||||||
|
LoadTextures("Nevada");
|
||||||
|
}
|
||||||
|
|
||||||
|
void CubeMapPass::LoadTextures(std::string input)
|
||||||
|
{
|
||||||
|
if (m_PreviusCubeMapTexture != input) {
|
||||||
|
m_CubeMapTextures.clear();
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
|
std::string str;
|
||||||
|
str = "Textures/Test/CubeMap/" + input + "/CubeMapTest0" + std::to_string(i) + ".png";
|
||||||
|
Texture* img = ResourceManager::Load<Texture>(str);
|
||||||
|
m_CubeMapTextures.push_back(img);
|
||||||
|
}
|
||||||
|
GenerateCubeMapTexture();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CubeMapPass::GenerateCubeMapTexture()
|
||||||
|
{
|
||||||
|
if (m_CubeMapTexture == -1) {
|
||||||
|
glGenTextures(1, &m_CubeMapTexture);
|
||||||
|
}
|
||||||
|
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapTexture);
|
||||||
|
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
|
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA32F, m_CubeMapTextures[0]->Width, m_CubeMapTextures[0]->Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_CubeMapTextures[i]->Data);
|
||||||
|
}
|
||||||
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
||||||
|
GLERROR("Generate Cubemap");
|
||||||
|
}
|
||||||
|
|
||||||
@@ -19,16 +19,20 @@ void DrawBloomPass::InitializeTextures()
|
|||||||
void DrawBloomPass::InitializeShaderPrograms()
|
void DrawBloomPass::InitializeShaderPrograms()
|
||||||
{
|
{
|
||||||
m_GaussianProgram_horiz = ResourceManager::Load<ShaderProgram>("##GaussianProgramHoriz");
|
m_GaussianProgram_horiz = ResourceManager::Load<ShaderProgram>("##GaussianProgramHoriz");
|
||||||
m_GaussianProgram_horiz->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Gaussian_horiz.vert.glsl")));
|
if (m_GaussianProgram_horiz->GetHandle() == 0) {
|
||||||
m_GaussianProgram_horiz->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Gaussian_horiz.frag.glsl")));
|
m_GaussianProgram_horiz->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Gaussian_horiz.vert.glsl")));
|
||||||
m_GaussianProgram_horiz->Compile();
|
m_GaussianProgram_horiz->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Gaussian_horiz.frag.glsl")));
|
||||||
m_GaussianProgram_horiz->Link();
|
m_GaussianProgram_horiz->Compile();
|
||||||
|
m_GaussianProgram_horiz->Link();
|
||||||
|
}
|
||||||
|
|
||||||
m_GaussianProgram_vert = ResourceManager::Load<ShaderProgram>("##GaussianProgramVert");
|
m_GaussianProgram_vert = ResourceManager::Load<ShaderProgram>("##GaussianProgramVert");
|
||||||
m_GaussianProgram_vert->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Gaussian_vert.vert.glsl")));
|
if (m_GaussianProgram_vert->GetHandle() == 0) {
|
||||||
m_GaussianProgram_vert->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Gaussian_vert.frag.glsl")));
|
m_GaussianProgram_vert->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Gaussian_vert.vert.glsl")));
|
||||||
m_GaussianProgram_vert->Compile();
|
m_GaussianProgram_vert->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Gaussian_vert.frag.glsl")));
|
||||||
m_GaussianProgram_vert->Link();
|
m_GaussianProgram_vert->Compile();
|
||||||
|
m_GaussianProgram_vert->Link();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -48,6 +52,7 @@ void DrawBloomPass::InitializeBuffers()
|
|||||||
|
|
||||||
void DrawBloomPass::ClearBuffer()
|
void DrawBloomPass::ClearBuffer()
|
||||||
{
|
{
|
||||||
|
GLERROR("PRE");
|
||||||
m_GaussianFrameBuffer_horiz.Bind();
|
m_GaussianFrameBuffer_horiz.Bind();
|
||||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
@@ -56,6 +61,7 @@ void DrawBloomPass::ClearBuffer()
|
|||||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
m_GaussianFrameBuffer_vert.Unbind();
|
m_GaussianFrameBuffer_vert.Unbind();
|
||||||
|
GLERROR("END");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawBloomPass::Draw(GLuint texture)
|
void DrawBloomPass::Draw(GLuint texture)
|
||||||
@@ -71,15 +77,12 @@ void DrawBloomPass::Draw(GLuint texture)
|
|||||||
//Horizontal pass, first use the given texture then save it to the horizontal framebuffer.
|
//Horizontal pass, first use the given texture then save it to the horizontal framebuffer.
|
||||||
m_GaussianFrameBuffer_horiz.Bind();
|
m_GaussianFrameBuffer_horiz.Bind();
|
||||||
m_GaussianProgram_horiz->Bind();
|
m_GaussianProgram_horiz->Bind();
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, texture);
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
|
|
||||||
glBindVertexArray(m_ScreenQuad->VAO);
|
glBindVertexArray(m_ScreenQuad->VAO);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1
|
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
||||||
|
|
||||||
//Iterate some times to make it more gaussian.
|
//Iterate some times to make it more gaussian.
|
||||||
for (int i = 1; i < m_iterations; i++) {
|
for (int i = 1; i < m_iterations; i++) {
|
||||||
//Vertical pass
|
//Vertical pass
|
||||||
@@ -92,7 +95,6 @@ void DrawBloomPass::Draw(GLuint texture)
|
|||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1
|
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
||||||
|
|
||||||
//horizontal pass
|
//horizontal pass
|
||||||
|
|
||||||
m_GaussianFrameBuffer_horiz.Bind();
|
m_GaussianFrameBuffer_horiz.Bind();
|
||||||
@@ -112,7 +114,6 @@ void DrawBloomPass::Draw(GLuint texture)
|
|||||||
m_GaussianProgram_vert->Bind();
|
m_GaussianProgram_vert->Bind();
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz);
|
glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz);
|
||||||
|
|
||||||
glBindVertexArray(m_ScreenQuad->VAO);
|
glBindVertexArray(m_ScreenQuad->VAO);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1
|
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
#include "Rendering/DrawFinalPass.h"
|
#include "Rendering/DrawFinalPass.h"
|
||||||
|
|
||||||
DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass)
|
DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass)
|
||||||
|
: m_Renderer(renderer)
|
||||||
|
, m_LightCullingPass(lightCullingPass)
|
||||||
|
, m_CubeMapPass(cubeMapPass)
|
||||||
{
|
{
|
||||||
//TODO: Make sure that uniforms are not sent into shader if not needed.
|
//TODO: Make sure that uniforms are not sent into shader if not needed.
|
||||||
m_Renderer = renderer;
|
|
||||||
m_LightCullingPass = lightCullingPass;
|
|
||||||
m_ShieldPixelRate = 8;
|
m_ShieldPixelRate = 8;
|
||||||
InitializeTextures();
|
InitializeTextures();
|
||||||
InitializeShaderPrograms();
|
InitializeShaderPrograms();
|
||||||
@@ -27,6 +28,7 @@ void DrawFinalPass::InitializeFrameBuffers()
|
|||||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
GLERROR("RenderBuffer generation");
|
GLERROR("RenderBuffer generation");
|
||||||
|
|
||||||
|
|
||||||
GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||||
//GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
//GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||||
GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||||
@@ -173,26 +175,28 @@ void DrawFinalPass::InitializeShaderPrograms()
|
|||||||
GLERROR("Creating DepthFill program");
|
GLERROR("Creating DepthFill program");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawFinalPass::Draw(RenderScene& scene)
|
void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture)
|
||||||
{
|
{
|
||||||
GLERROR("Pre");
|
GLERROR("Pre");
|
||||||
|
|
||||||
DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle());
|
DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle());
|
||||||
if (scene.ClearDepth) {
|
if (scene.ClearDepth) {
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
//glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
|
state->Disable(GL_DEPTH_TEST);
|
||||||
|
state->DepthMask(GL_FALSE);
|
||||||
}
|
}
|
||||||
//TODO: Do we need check for this or will it be per scene always?
|
//TODO: Do we need check for this or will it be per scene always?
|
||||||
glClearStencil(0x00);
|
glClearStencil(0x00);
|
||||||
glClear(GL_STENCIL_BUFFER_BIT);
|
glClear(GL_STENCIL_BUFFER_BIT);
|
||||||
|
|
||||||
//Fill depth buffer
|
//Fill depth buffer
|
||||||
|
|
||||||
|
|
||||||
state->StencilMask(0x00);
|
state->StencilMask(0x00);
|
||||||
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
|
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene, SSAOTexture);
|
||||||
GLERROR("OpaqueObjects");
|
GLERROR("OpaqueObjects");
|
||||||
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
|
state->BlendFunc(GL_ONE, GL_ONE);
|
||||||
|
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene, SSAOTexture);
|
||||||
GLERROR("TransparentObjects");
|
GLERROR("TransparentObjects");
|
||||||
|
state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
DrawSprites(scene.Jobs.SpriteJob, scene);
|
DrawSprites(scene.Jobs.SpriteJob, scene);
|
||||||
GLERROR("SpriteJobs");
|
GLERROR("SpriteJobs");
|
||||||
|
|
||||||
@@ -206,11 +210,11 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
|||||||
//Draw Opaque shielded objects
|
//Draw Opaque shielded objects
|
||||||
state->StencilFunc(GL_NOTEQUAL, 1, 0xFF);
|
state->StencilFunc(GL_NOTEQUAL, 1, 0xFF);
|
||||||
state->StencilMask(0x00);
|
state->StencilMask(0x00);
|
||||||
DrawModelRenderQueues(scene.Jobs.OpaqueShieldedObjects, scene); //might need changing
|
DrawModelRenderQueues(scene.Jobs.OpaqueShieldedObjects, scene, SSAOTexture); //might need changing
|
||||||
GLERROR("Shielded Opaque object");
|
GLERROR("Shielded Opaque object");
|
||||||
|
|
||||||
//Draw Transparen Shielded objects
|
//Draw Transparen Shielded objects
|
||||||
DrawModelRenderQueues(scene.Jobs.TransparentShieldedObjects, scene); //might need changing
|
DrawModelRenderQueues(scene.Jobs.TransparentShieldedObjects, scene, SSAOTexture); //might need changing
|
||||||
GLERROR("Shielded Transparent objects");
|
GLERROR("Shielded Transparent objects");
|
||||||
|
|
||||||
GLERROR("END");
|
GLERROR("END");
|
||||||
@@ -241,14 +245,14 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
|||||||
DrawShieldToStencilBuffer(scene.Jobs.ShieldObjects, scene);
|
DrawShieldToStencilBuffer(scene.Jobs.ShieldObjects, scene);
|
||||||
GLERROR("StencilPass");
|
GLERROR("StencilPass");
|
||||||
|
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
//glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
stateLowRes->Enable(GL_DEPTH_TEST);
|
stateLowRes->Enable(GL_DEPTH_TEST);
|
||||||
stateLowRes->StencilFunc(GL_LEQUAL, 1, 0xFF);
|
stateLowRes->StencilFunc(GL_LEQUAL, 1, 0xFF);
|
||||||
stateLowRes->StencilMask(0x00);
|
stateLowRes->StencilMask(0x00);
|
||||||
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
|
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene, SSAOTexture);
|
||||||
GLERROR("OpaqueObjects");
|
GLERROR("OpaqueObjects");
|
||||||
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
|
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene, SSAOTexture);
|
||||||
GLERROR("TransparentObjects");
|
GLERROR("TransparentObjects");
|
||||||
glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
@@ -258,20 +262,35 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
|||||||
|
|
||||||
void DrawFinalPass::ClearBuffer()
|
void DrawFinalPass::ClearBuffer()
|
||||||
{
|
{
|
||||||
|
GLERROR("PRE");
|
||||||
m_FinalPassFrameBufferLowRes.Bind();
|
m_FinalPassFrameBufferLowRes.Bind();
|
||||||
|
GLERROR("Bind LowRes");
|
||||||
|
|
||||||
glViewport(0, 0, m_Renderer->GetViewportSize().Width/m_ShieldPixelRate, m_Renderer->GetViewportSize().Height/m_ShieldPixelRate);
|
glViewport(0, 0, m_Renderer->GetViewportSize().Width/m_ShieldPixelRate, m_Renderer->GetViewportSize().Height/m_ShieldPixelRate);
|
||||||
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
GLERROR("ViewPort,Scissor LowRes");
|
||||||
|
|
||||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
|
GLERROR("1");
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
GLERROR("2");
|
||||||
|
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
|
GLERROR("3");
|
||||||
|
|
||||||
m_FinalPassFrameBufferLowRes.Unbind();
|
m_FinalPassFrameBufferLowRes.Unbind();
|
||||||
|
|
||||||
|
GLERROR("prebind HighRes");
|
||||||
m_FinalPassFrameBuffer.Bind();
|
m_FinalPassFrameBuffer.Bind();
|
||||||
|
GLERROR("Bind HighRes");
|
||||||
glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
GLERROR("ViewPort,Scissor LowRes");
|
||||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
m_FinalPassFrameBuffer.Unbind();
|
m_FinalPassFrameBuffer.Unbind();
|
||||||
|
GLERROR("END");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -321,7 +340,7 @@ void DrawFinalPass::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm:
|
|||||||
GLERROR("MipMap Texture initialization failed");
|
GLERROR("MipMap Texture initialization failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
|
void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene, GLuint SSAOTexture)
|
||||||
{
|
{
|
||||||
GLuint forwardHandle = m_ForwardPlusProgram->GetHandle();
|
GLuint forwardHandle = m_ForwardPlusProgram->GetHandle();
|
||||||
GLERROR("forwardHandle");
|
GLERROR("forwardHandle");
|
||||||
@@ -344,6 +363,9 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO());
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO());
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO());
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO());
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, SSAOTexture);
|
||||||
|
|
||||||
for (auto &job : jobs) {
|
for (auto &job : jobs) {
|
||||||
auto explosionEffectJob = std::dynamic_pointer_cast<ExplosionEffectJob>(job);
|
auto explosionEffectJob = std::dynamic_pointer_cast<ExplosionEffectJob>(job);
|
||||||
if (explosionEffectJob) {
|
if (explosionEffectJob) {
|
||||||
@@ -352,12 +374,17 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
case RawModel::MaterialType::SingleTextures:
|
case RawModel::MaterialType::SingleTextures:
|
||||||
{
|
{
|
||||||
if (explosionEffectJob->Model->IsSkinned()) {
|
if (explosionEffectJob->Model->IsSkinned()) {
|
||||||
|
|
||||||
m_ExplosionEffectSkinnedProgram->Bind();
|
m_ExplosionEffectSkinnedProgram->Bind();
|
||||||
GLERROR("Bind ExplosionEffectSkinned program");
|
GLERROR("Bind ExplosionEffectSkinned program");
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindExplosionUniforms(explosionSkinnedHandle, explosionEffectJob, scene);
|
BindExplosionUniforms(explosionSkinnedHandle, explosionEffectJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob);
|
BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob);
|
||||||
|
glActiveTexture(GL_TEXTURE5);
|
||||||
|
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
|
||||||
|
glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
|
||||||
|
|
||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
if (explosionEffectJob->AnimationOffset.animation != nullptr) {
|
if (explosionEffectJob->AnimationOffset.animation != nullptr) {
|
||||||
frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset);
|
frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset);
|
||||||
@@ -372,6 +399,10 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
BindExplosionUniforms(explosionHandle, explosionEffectJob, scene);
|
BindExplosionUniforms(explosionHandle, explosionEffectJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
BindExplosionTextures(explosionHandle, explosionEffectJob);
|
BindExplosionTextures(explosionHandle, explosionEffectJob);
|
||||||
|
glActiveTexture(GL_TEXTURE5);
|
||||||
|
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
|
||||||
|
glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -430,6 +461,10 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
BindModelUniforms(forwardSkinnedHandle, modelJob, scene);
|
BindModelUniforms(forwardSkinnedHandle, modelJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
BindModelTextures(forwardSkinnedHandle, modelJob);
|
BindModelTextures(forwardSkinnedHandle, modelJob);
|
||||||
|
glActiveTexture(GL_TEXTURE5);
|
||||||
|
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
|
||||||
|
glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
|
||||||
|
|
||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
if (modelJob->AnimationOffset.animation != nullptr) {
|
if (modelJob->AnimationOffset.animation != nullptr) {
|
||||||
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset);
|
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset);
|
||||||
@@ -445,6 +480,9 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
BindModelUniforms(forwardHandle, modelJob, scene);
|
BindModelUniforms(forwardHandle, modelJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
BindModelTextures(forwardHandle, modelJob);
|
BindModelTextures(forwardHandle, modelJob);
|
||||||
|
glActiveTexture(GL_TEXTURE5);
|
||||||
|
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
|
||||||
|
glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -690,14 +728,14 @@ void DrawFinalPass::DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, Rend
|
|||||||
glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(spriteJob->FillColor));
|
glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(spriteJob->FillColor));
|
||||||
glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), spriteJob->FillPercentage);
|
glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), spriteJob->FillPercentage);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
if (spriteJob->DiffuseTexture != nullptr) {
|
if (spriteJob->DiffuseTexture != nullptr) {
|
||||||
glBindTexture(GL_TEXTURE_2D, spriteJob->DiffuseTexture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, spriteJob->DiffuseTexture->m_Texture);
|
||||||
} else {
|
} else {
|
||||||
glBindTexture(GL_TEXTURE_2D, m_ErrorTexture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, m_ErrorTexture->m_Texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE2);
|
||||||
if (spriteJob->IncandescenceTexture != nullptr) {
|
if (spriteJob->IncandescenceTexture != nullptr) {
|
||||||
glBindTexture(GL_TEXTURE_2D, spriteJob->IncandescenceTexture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, spriteJob->IncandescenceTexture->m_Texture);
|
||||||
} else {
|
} else {
|
||||||
@@ -803,11 +841,13 @@ void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr<Model
|
|||||||
|
|
||||||
void DrawFinalPass::BindExplosionTextures(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job)
|
void DrawFinalPass::BindExplosionTextures(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
switch (job->Type) {
|
switch (job->Type) {
|
||||||
case RawModel::MaterialType::SingleTextures:
|
case RawModel::MaterialType::SingleTextures:
|
||||||
case RawModel::MaterialType::Basic:
|
case RawModel::MaterialType::Basic:
|
||||||
{
|
{
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
if (job->DiffuseTexture.size() > 0 && job->DiffuseTexture[0]->Texture != nullptr) {
|
if (job->DiffuseTexture.size() > 0 && job->DiffuseTexture[0]->Texture != nullptr) {
|
||||||
glBindTexture(GL_TEXTURE_2D, job->DiffuseTexture[0]->Texture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, job->DiffuseTexture[0]->Texture->m_Texture);
|
||||||
glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(job->DiffuseTexture[0]->UVRepeat));
|
glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(job->DiffuseTexture[0]->UVRepeat));
|
||||||
@@ -817,7 +857,7 @@ void DrawFinalPass::BindExplosionTextures(GLuint shaderHandle, std::shared_ptr<E
|
|||||||
glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
|
glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE2);
|
||||||
if (job->NormalTexture.size() > 0 && job->NormalTexture[0]->Texture != nullptr) {
|
if (job->NormalTexture.size() > 0 && job->NormalTexture[0]->Texture != nullptr) {
|
||||||
glBindTexture(GL_TEXTURE_2D, job->NormalTexture[0]->Texture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, job->NormalTexture[0]->Texture->m_Texture);
|
||||||
glUniform2fv(glGetUniformLocation(shaderHandle, "NormalUVRepeat"), 1, glm::value_ptr(job->NormalTexture[0]->UVRepeat));
|
glUniform2fv(glGetUniformLocation(shaderHandle, "NormalUVRepeat"), 1, glm::value_ptr(job->NormalTexture[0]->UVRepeat));
|
||||||
@@ -827,7 +867,7 @@ void DrawFinalPass::BindExplosionTextures(GLuint shaderHandle, std::shared_ptr<E
|
|||||||
glUniform2fv(glGetUniformLocation(shaderHandle, "NormalUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
|
glUniform2fv(glGetUniformLocation(shaderHandle, "NormalUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE2);
|
glActiveTexture(GL_TEXTURE3);
|
||||||
if (job->SpecularTexture.size() > 0 && job->SpecularTexture[0]->Texture != nullptr) {
|
if (job->SpecularTexture.size() > 0 && job->SpecularTexture[0]->Texture != nullptr) {
|
||||||
glBindTexture(GL_TEXTURE_2D, job->SpecularTexture[0]->Texture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, job->SpecularTexture[0]->Texture->m_Texture);
|
||||||
glUniform2fv(glGetUniformLocation(shaderHandle, "SpecularUVRepeat"), 1, glm::value_ptr(job->SpecularTexture[0]->UVRepeat));
|
glUniform2fv(glGetUniformLocation(shaderHandle, "SpecularUVRepeat"), 1, glm::value_ptr(job->SpecularTexture[0]->UVRepeat));
|
||||||
@@ -837,7 +877,7 @@ void DrawFinalPass::BindExplosionTextures(GLuint shaderHandle, std::shared_ptr<E
|
|||||||
glUniform2fv(glGetUniformLocation(shaderHandle, "SpecularUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
|
glUniform2fv(glGetUniformLocation(shaderHandle, "SpecularUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE3);
|
glActiveTexture(GL_TEXTURE4);
|
||||||
if (job->IncandescenceTexture.size() > 0 && job->IncandescenceTexture[0]->Texture != nullptr) {
|
if (job->IncandescenceTexture.size() > 0 && job->IncandescenceTexture[0]->Texture != nullptr) {
|
||||||
glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture[0]->Texture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture[0]->Texture->m_Texture);
|
||||||
glUniform2fv(glGetUniformLocation(shaderHandle, "GlowUVRepeat"), 1, glm::value_ptr(job->IncandescenceTexture[0]->UVRepeat));
|
glUniform2fv(glGetUniformLocation(shaderHandle, "GlowUVRepeat"), 1, glm::value_ptr(job->IncandescenceTexture[0]->UVRepeat));
|
||||||
@@ -850,7 +890,7 @@ void DrawFinalPass::BindExplosionTextures(GLuint shaderHandle, std::shared_ptr<E
|
|||||||
}
|
}
|
||||||
case RawModel::MaterialType::SplatMapping:
|
case RawModel::MaterialType::SplatMapping:
|
||||||
{
|
{
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_2D, job->SplatMap->Texture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, job->SplatMap->Texture->m_Texture);
|
||||||
|
|
||||||
int texturePosition = GL_TEXTURE1;
|
int texturePosition = GL_TEXTURE1;
|
||||||
@@ -925,7 +965,7 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptr<Model
|
|||||||
case RawModel::MaterialType::SingleTextures:
|
case RawModel::MaterialType::SingleTextures:
|
||||||
case RawModel::MaterialType::Basic:
|
case RawModel::MaterialType::Basic:
|
||||||
{
|
{
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
if (job->DiffuseTexture.size() > 0 && job->DiffuseTexture[0]->Texture != nullptr) {
|
if (job->DiffuseTexture.size() > 0 && job->DiffuseTexture[0]->Texture != nullptr) {
|
||||||
glBindTexture(GL_TEXTURE_2D, job->DiffuseTexture[0]->Texture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, job->DiffuseTexture[0]->Texture->m_Texture);
|
||||||
glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(job->DiffuseTexture[0]->UVRepeat));
|
glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(job->DiffuseTexture[0]->UVRepeat));
|
||||||
@@ -935,7 +975,7 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptr<Model
|
|||||||
glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
|
glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE2);
|
||||||
if (job->NormalTexture.size() > 0 && job->NormalTexture[0]->Texture != nullptr) {
|
if (job->NormalTexture.size() > 0 && job->NormalTexture[0]->Texture != nullptr) {
|
||||||
glBindTexture(GL_TEXTURE_2D, job->NormalTexture[0]->Texture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, job->NormalTexture[0]->Texture->m_Texture);
|
||||||
glUniform2fv(glGetUniformLocation(shaderHandle, "NormalUVRepeat"), 1, glm::value_ptr(job->NormalTexture[0]->UVRepeat));
|
glUniform2fv(glGetUniformLocation(shaderHandle, "NormalUVRepeat"), 1, glm::value_ptr(job->NormalTexture[0]->UVRepeat));
|
||||||
@@ -945,7 +985,7 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptr<Model
|
|||||||
glUniform2fv(glGetUniformLocation(shaderHandle, "NormalUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
|
glUniform2fv(glGetUniformLocation(shaderHandle, "NormalUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE2);
|
glActiveTexture(GL_TEXTURE3);
|
||||||
if (job->SpecularTexture.size() > 0 && job->SpecularTexture[0]->Texture != nullptr) {
|
if (job->SpecularTexture.size() > 0 && job->SpecularTexture[0]->Texture != nullptr) {
|
||||||
glBindTexture(GL_TEXTURE_2D, job->SpecularTexture[0]->Texture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, job->SpecularTexture[0]->Texture->m_Texture);
|
||||||
glUniform2fv(glGetUniformLocation(shaderHandle, "SpecularUVRepeat"), 1, glm::value_ptr(job->SpecularTexture[0]->UVRepeat));
|
glUniform2fv(glGetUniformLocation(shaderHandle, "SpecularUVRepeat"), 1, glm::value_ptr(job->SpecularTexture[0]->UVRepeat));
|
||||||
@@ -955,7 +995,7 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptr<Model
|
|||||||
glUniform2fv(glGetUniformLocation(shaderHandle, "SpecularUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
|
glUniform2fv(glGetUniformLocation(shaderHandle, "SpecularUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE3);
|
glActiveTexture(GL_TEXTURE4);
|
||||||
if (job->IncandescenceTexture.size() > 0 && job->IncandescenceTexture[0]->Texture != nullptr) {
|
if (job->IncandescenceTexture.size() > 0 && job->IncandescenceTexture[0]->Texture != nullptr) {
|
||||||
glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture[0]->Texture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture[0]->Texture->m_Texture);
|
||||||
glUniform2fv(glGetUniformLocation(shaderHandle, "GlowUVRepeat"), 1, glm::value_ptr(job->IncandescenceTexture[0]->UVRepeat));
|
glUniform2fv(glGetUniformLocation(shaderHandle, "GlowUVRepeat"), 1, glm::value_ptr(job->IncandescenceTexture[0]->UVRepeat));
|
||||||
@@ -968,10 +1008,10 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptr<Model
|
|||||||
}
|
}
|
||||||
case RawModel::MaterialType::SplatMapping:
|
case RawModel::MaterialType::SplatMapping:
|
||||||
{
|
{
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_2D, job->SplatMap->Texture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, job->SplatMap->Texture->m_Texture);
|
||||||
|
|
||||||
int texturePosition = GL_TEXTURE1;
|
int texturePosition = GL_TEXTURE2;
|
||||||
|
|
||||||
//Bind 5 diffuse textures
|
//Bind 5 diffuse textures
|
||||||
std::string UniformName = "DiffuseUVRepeat";
|
std::string UniformName = "DiffuseUVRepeat";
|
||||||
|
|||||||
@@ -21,15 +21,14 @@ void PickingPass::InitializeTextures()
|
|||||||
{
|
{
|
||||||
GenerateTexture(&m_PickingTexture, GL_CLAMP_TO_BORDER, GL_LINEAR,
|
GenerateTexture(&m_PickingTexture, GL_CLAMP_TO_BORDER, GL_LINEAR,
|
||||||
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RG8, GL_RG, GL_UNSIGNED_BYTE);
|
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RG8, GL_RG, GL_UNSIGNED_BYTE);
|
||||||
|
|
||||||
|
GenerateTexture(&m_DepthBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST,
|
||||||
|
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PickingPass::InitializeFrameBuffers()
|
void PickingPass::InitializeFrameBuffers()
|
||||||
{
|
{
|
||||||
glGenRenderbuffers(1, &m_DepthBuffer);
|
m_PickingBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_DepthBuffer, GL_DEPTH_ATTACHMENT)));
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer);
|
|
||||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
|
||||||
|
|
||||||
m_PickingBuffer.AddResource(std::shared_ptr<BufferResource>(new RenderBuffer(&m_DepthBuffer, GL_DEPTH_ATTACHMENT)));
|
|
||||||
m_PickingBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_PickingTexture, GL_COLOR_ATTACHMENT0)));
|
m_PickingBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_PickingTexture, GL_COLOR_ATTACHMENT0)));
|
||||||
m_PickingBuffer.Generate();
|
m_PickingBuffer.Generate();
|
||||||
}
|
}
|
||||||
@@ -55,6 +54,7 @@ void PickingPass::InitializeShaderPrograms()
|
|||||||
|
|
||||||
void PickingPass::Draw(RenderScene& scene)
|
void PickingPass::Draw(RenderScene& scene)
|
||||||
{
|
{
|
||||||
|
GLERROR("PRE");
|
||||||
PickingPassState* state = new PickingPassState(m_PickingBuffer.GetHandle());
|
PickingPassState* state = new PickingPassState(m_PickingBuffer.GetHandle());
|
||||||
|
|
||||||
//TODO: Render: Add code for more jobs than modeljobs.
|
//TODO: Render: Add code for more jobs than modeljobs.
|
||||||
@@ -63,7 +63,9 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
m_PickingProgram->Bind();
|
m_PickingProgram->Bind();
|
||||||
|
|
||||||
if (scene.ClearDepth) {
|
if (scene.ClearDepth) {
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
//glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
|
state->Disable(GL_DEPTH_TEST);
|
||||||
|
state->DepthMask(GL_FALSE);
|
||||||
}
|
}
|
||||||
m_Camera = scene.Camera;
|
m_Camera = scene.Camera;
|
||||||
|
|
||||||
@@ -356,6 +358,7 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
|
|
||||||
void PickingPass::ClearPicking()
|
void PickingPass::ClearPicking()
|
||||||
{
|
{
|
||||||
|
GLERROR("PRE");
|
||||||
m_PickingColorsToEntity.clear();
|
m_PickingColorsToEntity.clear();
|
||||||
m_EntityColors.clear();
|
m_EntityColors.clear();
|
||||||
m_ColorCounter[0] = 0;
|
m_ColorCounter[0] = 0;
|
||||||
@@ -365,14 +368,13 @@ void PickingPass::ClearPicking()
|
|||||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
m_PickingBuffer.Unbind();
|
m_PickingBuffer.Unbind();
|
||||||
|
GLERROR("END");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PickingPass::OnWindowResize()
|
void PickingPass::OnWindowResize()
|
||||||
{
|
{
|
||||||
InitializeTextures();
|
InitializeTextures();
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer);
|
|
||||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
|
||||||
m_PickingBuffer.Generate();
|
m_PickingBuffer.Generate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
PickingPassState::PickingPassState(GLuint frameBuffer)
|
PickingPassState::PickingPassState(GLuint frameBuffer)
|
||||||
{
|
{
|
||||||
GLERROR("---2");
|
GLERROR("PRE");
|
||||||
BindFramebuffer(frameBuffer);
|
BindFramebuffer(frameBuffer);
|
||||||
GLERROR("---3");
|
GLERROR("Bind Framebuffer");
|
||||||
Enable(GL_DEPTH_TEST);
|
Enable(GL_DEPTH_TEST);
|
||||||
Enable(GL_CULL_FACE);
|
Enable(GL_CULL_FACE);
|
||||||
Disable(GL_BLEND);
|
Disable(GL_BLEND);
|
||||||
@@ -13,6 +13,7 @@ PickingPassState::PickingPassState(GLuint frameBuffer)
|
|||||||
glm::vec4 clearColor = glm::vec4(0.f);
|
glm::vec4 clearColor = glm::vec4(0.f);
|
||||||
//ClearColor(clearColor);
|
//ClearColor(clearColor);
|
||||||
//Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
//Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
GLERROR("END");
|
||||||
}
|
}
|
||||||
|
|
||||||
PickingPassState::~PickingPassState()
|
PickingPassState::~PickingPassState()
|
||||||
|
|||||||
@@ -52,6 +52,101 @@ void RenderSystem::fillSprites(std::list<std::shared_ptr<RenderJob>>& jobs, Worl
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::mat4 modelMatrix;
|
||||||
|
|
||||||
|
// See a sprite is an SpriteIndicator
|
||||||
|
bool isIndicator = false;
|
||||||
|
if (world->HasComponent(entity.ID, "SpriteIndicator"))
|
||||||
|
{
|
||||||
|
auto indicator = entity["SpriteIndicator"];
|
||||||
|
|
||||||
|
float minScale = (float)(double)indicator["MinScale"];
|
||||||
|
bool hasTeam = indicator["VisibleForSingleTeamOnly"];
|
||||||
|
isIndicator = true;
|
||||||
|
glm::vec3 pos = Transform::AbsolutePosition(entity);
|
||||||
|
|
||||||
|
|
||||||
|
EntityWrapper entityTeam;
|
||||||
|
if (hasTeam && (entity.HasComponent("Team") || entity.FirstParentWithComponent("Team").Valid()) && m_LocalPlayer.World != nullptr) {
|
||||||
|
if (!entity.HasComponent("Team")) {
|
||||||
|
entityTeam = entity.FirstParentWithComponent("Team");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
entityTeam = entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
ComponentWrapper& entityTeamComponent = entityTeam["Team"];
|
||||||
|
ComponentWrapper& localComponent = m_LocalPlayer["Team"];
|
||||||
|
int entityTeamInt = entityTeamComponent["Team"];
|
||||||
|
int localComponentInt = localComponent["Team"];
|
||||||
|
int SpectatorInt = localComponent["Team"].Enum("Spectator");
|
||||||
|
if (entityTeamInt != localComponentInt && localComponentInt != SpectatorInt) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code for check if sprite is inside or outside of screen
|
||||||
|
//glm::vec4 projectedPos = m_Camera->ProjectionMatrix() * m_Camera->ViewMatrix() * glm::vec4(pos, 1.0f);
|
||||||
|
//projectedPos /= projectedPos.w;
|
||||||
|
//// Check if inside of outside of screen.
|
||||||
|
//if (projectedPos.x < -1.0f || projectedPos.x > 1.0f || projectedPos.y < -1.0f || projectedPos.y > 1.0f) {
|
||||||
|
// // is outside of screen
|
||||||
|
//} else {
|
||||||
|
// // is inside of screen
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
glm::vec3 zAxis = glm::vec3(0.0f, 1.0f, 0.0f);
|
||||||
|
glm::vec3 normal = pos - m_Camera->Position();
|
||||||
|
|
||||||
|
//float distance = glm::length(normal);
|
||||||
|
//if (distance < minDistance) {
|
||||||
|
// pos = pos - glm::normalize(normal) * (distance - minDistance);
|
||||||
|
//} else if (distance > maxDistance) {
|
||||||
|
// pos = pos - glm::normalize(normal) * (distance - maxDistance);
|
||||||
|
//}
|
||||||
|
normal.y = 0;
|
||||||
|
normal = glm::normalize(normal);
|
||||||
|
glm::vec3 right = glm::cross(normal, zAxis);
|
||||||
|
glm::vec3 up = glm::cross(right, normal);
|
||||||
|
|
||||||
|
modelMatrix[0][0] = right.x;
|
||||||
|
modelMatrix[0][1] = right.y;
|
||||||
|
modelMatrix[0][2] = right.z;
|
||||||
|
modelMatrix[0][3] = 0.0f;
|
||||||
|
|
||||||
|
modelMatrix[1][0] = zAxis.x;
|
||||||
|
modelMatrix[1][1] = zAxis.y;
|
||||||
|
modelMatrix[1][2] = zAxis.z;
|
||||||
|
modelMatrix[1][3] = 0.0f;
|
||||||
|
|
||||||
|
modelMatrix[2][0] = normal.x;
|
||||||
|
modelMatrix[2][1] = normal.y;
|
||||||
|
modelMatrix[2][2] = normal.z;
|
||||||
|
modelMatrix[2][3] = 0.0f;
|
||||||
|
|
||||||
|
modelMatrix[3][0] = pos.x;
|
||||||
|
modelMatrix[3][1] = pos.y;
|
||||||
|
modelMatrix[3][2] = pos.z;
|
||||||
|
modelMatrix[3][3] = 1.0f;
|
||||||
|
|
||||||
|
glm::mat4 tranformationMatrix = modelMatrix * glm::scale(Transform::AbsoluteScale(entity));
|
||||||
|
glm::vec4 tmp = tranformationMatrix * glm::vec4(glm::vec3(0.5, 0.5, 0), 1.0f);
|
||||||
|
glm::vec2 projectedTopRight = m_Camera->WorldToScreen(glm::vec3(tmp), m_Renderer->GetViewportSize());
|
||||||
|
tmp = tranformationMatrix * glm::vec4(glm::vec3(-0.5, -0.5, 0), 1.0f);
|
||||||
|
glm::vec2 projectedBottomLeft = m_Camera->WorldToScreen(glm::vec3(tmp), m_Renderer->GetViewportSize());
|
||||||
|
|
||||||
|
float diag = glm::length(projectedBottomLeft - projectedTopRight);
|
||||||
|
if (diag < minScale) {
|
||||||
|
tranformationMatrix = tranformationMatrix * glm::scale(glm::vec3(minScale / diag, minScale / diag, minScale / diag));
|
||||||
|
}
|
||||||
|
modelMatrix = tranformationMatrix;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
modelMatrix = Transform::ModelMatrix(entity.ID, world);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string diffuseResource = cSprite["DiffuseTexture"];
|
std::string diffuseResource = cSprite["DiffuseTexture"];
|
||||||
std::string glowResource = cSprite["GlowMap"];
|
std::string glowResource = cSprite["GlowMap"];
|
||||||
bool depthSorted = cSprite["DepthSort"];
|
bool depthSorted = cSprite["DepthSort"];
|
||||||
@@ -67,11 +162,7 @@ void RenderSystem::fillSprites(std::list<std::shared_ptr<RenderJob>>& jobs, Worl
|
|||||||
fillColor = (glm::vec4)fillComponent["Color"];
|
fillColor = (glm::vec4)fillComponent["Color"];
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, world);
|
std::shared_ptr<SpriteJob> spriteJob = std::shared_ptr<SpriteJob>(new SpriteJob(cSprite, m_Camera, modelMatrix, world, fillColor, fillPercentage, depthSorted, isIndicator));
|
||||||
//modelMatrix *= m_Camera->BillboardMatrix();
|
|
||||||
|
|
||||||
|
|
||||||
std::shared_ptr<SpriteJob> spriteJob = std::shared_ptr<SpriteJob>(new SpriteJob(cSprite, m_Camera, modelMatrix, world, fillColor, fillPercentage, depthSorted));
|
|
||||||
|
|
||||||
jobs.push_back(spriteJob);
|
jobs.push_back(spriteJob);
|
||||||
}
|
}
|
||||||
@@ -93,7 +184,6 @@ bool RenderSystem::isEntityVisible(EntityWrapper& entity)
|
|||||||
) {
|
) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ void Renderer::glfwFrameBufferCallback(GLFWwindow* window, int width, int height
|
|||||||
currentRenderer->m_LightCullingPass->OnWindowResize();
|
currentRenderer->m_LightCullingPass->OnWindowResize();
|
||||||
currentRenderer->m_PickingPass->OnWindowResize();
|
currentRenderer->m_PickingPass->OnWindowResize();
|
||||||
currentRenderer->m_DrawBloomPass->OnWindowResize();
|
currentRenderer->m_DrawBloomPass->OnWindowResize();
|
||||||
|
currentRenderer->m_SSAOPass->OnWindowResize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::InitializeWindow()
|
void Renderer::InitializeWindow()
|
||||||
@@ -88,9 +89,6 @@ void Renderer::InitializeShaders()
|
|||||||
//m_ExplosionEffectProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ExplosionEffect.frag.glsl")));
|
//m_ExplosionEffectProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ExplosionEffect.frag.glsl")));
|
||||||
//m_ExplosionEffectProgram->Compile();
|
//m_ExplosionEffectProgram->Compile();
|
||||||
//m_ExplosionEffectProgram->Link();
|
//m_ExplosionEffectProgram->Link();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::InputUpdate(double dt)
|
void Renderer::InputUpdate(double dt)
|
||||||
@@ -108,7 +106,23 @@ void Renderer::Update(double dt)
|
|||||||
|
|
||||||
void Renderer::Draw(RenderFrame& frame)
|
void Renderer::Draw(RenderFrame& frame)
|
||||||
{
|
{
|
||||||
ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking");
|
GLERROR("PRE");
|
||||||
|
ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking\0Ambient Occlusion");
|
||||||
|
ImGui::Combo("CubeMap", &m_CubeMapTexture, "Nevada(512)\0Sky(1024)");
|
||||||
|
if(m_CubeMapTexture == 0) {
|
||||||
|
m_CubeMapPass->LoadTextures("Nevada");
|
||||||
|
} else if (m_CubeMapTexture == 1) {
|
||||||
|
m_CubeMapPass->LoadTextures("Sky");
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::SliderFloat("SSAO sample radius", &m_SSAO_Radius, 0.01f, 5.0f);
|
||||||
|
ImGui::SliderFloat("SSAO bias", &m_SSAO_Bias, 0.0f, 0.1f);
|
||||||
|
ImGui::SliderFloat("SSAO contrast", &m_SSAO_Contrast, 0.0f, 10.0f);
|
||||||
|
ImGui::SliderFloat("SSAO IntensityScale", &m_SSAO_IntensityScale, 0.0f, 10.0f);
|
||||||
|
ImGui::SliderInt("SSAO Number of Samples", &m_SSAO_NumOfSamples, 2, 100);
|
||||||
|
ImGui::SliderInt("SSAO Number of Turns", &m_SSAO_NumOfTurns, 0, 50);
|
||||||
|
m_SSAOPass->Setting(m_SSAO_Radius, m_SSAO_Bias, m_SSAO_Contrast, m_SSAO_IntensityScale, m_SSAO_NumOfSamples, m_SSAO_NumOfTurns);
|
||||||
|
GLERROR("SSAO Settings");
|
||||||
//clear buffer 0
|
//clear buffer 0
|
||||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
@@ -118,16 +132,24 @@ void Renderer::Draw(RenderFrame& frame)
|
|||||||
m_PickingPass->ClearPicking();
|
m_PickingPass->ClearPicking();
|
||||||
m_DrawFinalPass->ClearBuffer();
|
m_DrawFinalPass->ClearBuffer();
|
||||||
m_DrawBloomPass->ClearBuffer();
|
m_DrawBloomPass->ClearBuffer();
|
||||||
|
m_SSAOPass->ClearBuffer();
|
||||||
PerformanceTimer::StopTimer("Renderer-ClearBuffers");
|
PerformanceTimer::StopTimer("Renderer-ClearBuffers");
|
||||||
|
GLERROR("ClearBuffers");
|
||||||
|
for (auto scene : frame.RenderScenes) {
|
||||||
|
PerformanceTimer::StartTimer("Renderer-Depth");
|
||||||
|
m_PickingPass->Draw(*scene);
|
||||||
|
GLERROR("Drawing pickingpass");
|
||||||
|
PerformanceTimer::StopTimer("Renderer-Depth");
|
||||||
|
}
|
||||||
|
PerformanceTimer::StartTimer("AO generation");
|
||||||
|
m_SSAOPass->Draw(m_PickingPass->DepthBuffer(), frame.RenderScenes.front()->Camera);
|
||||||
|
GLuint ao = m_SSAOPass->SSAOTexture();
|
||||||
|
PerformanceTimer::StopTimer("AO generation");
|
||||||
for (auto scene : frame.RenderScenes){
|
for (auto scene : frame.RenderScenes){
|
||||||
|
|
||||||
PerformanceTimer::StartTimer("Renderer-Depth");
|
PerformanceTimer::StartTimer("Renderer-Drawing PickingPass");
|
||||||
SortRenderJobsByDepth(*scene);
|
SortRenderJobsByDepth(*scene);
|
||||||
GLERROR("SortByDepth");
|
GLERROR("SortByDepth");
|
||||||
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Drawing PickingPass");
|
|
||||||
m_PickingPass->Draw(*scene);
|
|
||||||
GLERROR("Drawing pickingpass");
|
|
||||||
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Generate Frustrums");
|
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Generate Frustrums");
|
||||||
m_LightCullingPass->GenerateNewFrustum(*scene);
|
m_LightCullingPass->GenerateNewFrustum(*scene);
|
||||||
GLERROR("Generate frustums");
|
GLERROR("Generate frustums");
|
||||||
@@ -137,8 +159,8 @@ void Renderer::Draw(RenderFrame& frame)
|
|||||||
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Light Culling");
|
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Light Culling");
|
||||||
m_LightCullingPass->CullLights(*scene);
|
m_LightCullingPass->CullLights(*scene);
|
||||||
GLERROR("LightCulling");
|
GLERROR("LightCulling");
|
||||||
|
m_DrawFinalPass->Draw(*scene, ao);
|
||||||
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Draw Geometry+Light");
|
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Draw Geometry+Light");
|
||||||
m_DrawFinalPass->Draw(*scene);
|
|
||||||
GLERROR("Draw Geometry+Light");
|
GLERROR("Draw Geometry+Light");
|
||||||
//m_DrawScenePass->Draw(*scene);
|
//m_DrawScenePass->Draw(*scene);
|
||||||
|
|
||||||
@@ -147,14 +169,17 @@ void Renderer::Draw(RenderFrame& frame)
|
|||||||
GLERROR("Draw Text");
|
GLERROR("Draw Text");
|
||||||
PerformanceTimer::StopTimer("Renderer-Draw Text");
|
PerformanceTimer::StopTimer("Renderer-Draw Text");
|
||||||
}
|
}
|
||||||
|
|
||||||
PerformanceTimer::StartTimer("Renderer-Draw Bloom");
|
PerformanceTimer::StartTimer("Renderer-Draw Bloom");
|
||||||
m_DrawBloomPass->Draw(m_DrawFinalPass->BloomTexture());
|
m_DrawBloomPass->Draw(m_DrawFinalPass->BloomTexture());
|
||||||
PerformanceTimer::StopTimer("Renderer-Draw Bloom");
|
PerformanceTimer::StopTimer("Renderer-Draw Bloom");
|
||||||
|
|
||||||
if (m_DebugTextureToDraw == 0) {
|
if (m_DebugTextureToDraw == 0) {
|
||||||
PerformanceTimer::StartTimer("Renderer-Color Correction Pass");
|
PerformanceTimer::StartTimer("Renderer-Color Correction Pass");
|
||||||
m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture(), m_DrawFinalPass->SceneTextureLowRes(), m_DrawFinalPass->BloomTextureLowRes(), frame.Gamma, frame.Exposure);
|
m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture(), m_DrawFinalPass->SceneTextureLowRes(), m_DrawFinalPass->BloomTextureLowRes(), frame.Gamma, frame.Exposure);
|
||||||
PerformanceTimer::StopTimer("Renderer-Color Correction Pass");
|
PerformanceTimer::StopTimer("Renderer-Color Correction Pass");
|
||||||
}
|
}
|
||||||
|
|
||||||
PerformanceTimer::StartTimer("Renderer-Misc Debug Draws");
|
PerformanceTimer::StartTimer("Renderer-Misc Debug Draws");
|
||||||
if (m_DebugTextureToDraw == 1) {
|
if (m_DebugTextureToDraw == 1) {
|
||||||
m_DrawScreenQuadPass->Draw(m_DrawFinalPass->SceneTexture());
|
m_DrawScreenQuadPass->Draw(m_DrawFinalPass->SceneTexture());
|
||||||
@@ -174,7 +199,10 @@ void Renderer::Draw(RenderFrame& frame)
|
|||||||
if (m_DebugTextureToDraw == 6) {
|
if (m_DebugTextureToDraw == 6) {
|
||||||
m_DrawScreenQuadPass->Draw(m_PickingPass->PickingTexture());
|
m_DrawScreenQuadPass->Draw(m_PickingPass->PickingTexture());
|
||||||
}
|
}
|
||||||
PerformanceTimer::StopTimer("Renderer-Misc Debug Draws");
|
if (m_DebugTextureToDraw == 7) {
|
||||||
|
m_DrawScreenQuadPass->Draw(m_SSAOPass->SSAOTexture());
|
||||||
|
}
|
||||||
|
PerformanceTimer::StopTimer("Renderer-Misc Debug Draws");
|
||||||
|
|
||||||
PerformanceTimer::StartTimer("Renderer-ImGuiRenderPass");
|
PerformanceTimer::StartTimer("Renderer-ImGuiRenderPass");
|
||||||
m_ImGuiRenderPass->Draw();
|
m_ImGuiRenderPass->Draw();
|
||||||
@@ -219,8 +247,10 @@ void Renderer::InitializeRenderPasses()
|
|||||||
{
|
{
|
||||||
m_PickingPass = new PickingPass(this, m_EventBroker);
|
m_PickingPass = new PickingPass(this, m_EventBroker);
|
||||||
m_LightCullingPass = new LightCullingPass(this);
|
m_LightCullingPass = new LightCullingPass(this);
|
||||||
m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass);
|
m_CubeMapPass = new CubeMapPass(this);
|
||||||
|
m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass);
|
||||||
m_DrawScreenQuadPass = new DrawScreenQuadPass(this);
|
m_DrawScreenQuadPass = new DrawScreenQuadPass(this);
|
||||||
m_DrawBloomPass = new DrawBloomPass(this);
|
m_DrawBloomPass = new DrawBloomPass(this);
|
||||||
m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this);
|
m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this);
|
||||||
|
m_SSAOPass = new SSAOPass(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,145 @@
|
|||||||
|
#include "Rendering/SSAOPass.h"
|
||||||
|
|
||||||
|
SSAOPass::SSAOPass(IRenderer* renderer)
|
||||||
|
{
|
||||||
|
m_Renderer = renderer;
|
||||||
|
|
||||||
|
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh");
|
||||||
|
|
||||||
|
InitializeTexture();
|
||||||
|
InitializeBuffer();
|
||||||
|
InitializeShaderProgram();
|
||||||
|
Setting(0.1f, 0.012f, 1.0f, 1.0f, 13, 7);
|
||||||
|
|
||||||
|
m_DrawBloomPass = new DrawBloomPass(renderer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SSAOPass::InitializeShaderProgram()
|
||||||
|
{
|
||||||
|
m_SSAOProgram = ResourceManager::Load<ShaderProgram>("##SSAOProgram");
|
||||||
|
m_SSAOProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/SSAO.vert.glsl")));
|
||||||
|
m_SSAOProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/SSAO.frag.glsl")));
|
||||||
|
m_SSAOProgram->Compile();
|
||||||
|
m_SSAOProgram->Link();
|
||||||
|
|
||||||
|
m_SSAOViewSpaceZProgram = ResourceManager::Load<ShaderProgram>("##SSAOViewSpaceZProgram");
|
||||||
|
m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/SSAO.vert.glsl")));
|
||||||
|
m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/SSAOViewSpaceZ.frag.glsl")));
|
||||||
|
m_SSAOViewSpaceZProgram->Compile();
|
||||||
|
m_SSAOViewSpaceZProgram->Link();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SSAOPass::InitializeTexture() {
|
||||||
|
GenerateTexture(&m_SSAOTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_R8, GL_RED, GL_FLOAT);
|
||||||
|
GenerateTexture(&m_SSAOViewSpaceZTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_R32F, GL_RED, GL_FLOAT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SSAOPass::InitializeBuffer()
|
||||||
|
{
|
||||||
|
m_SSAOFramBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SSAOTexture, GL_COLOR_ATTACHMENT0)));
|
||||||
|
m_SSAOFramBuffer.Generate();
|
||||||
|
|
||||||
|
m_SSAOViewSpaceZFramBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SSAOViewSpaceZTexture, GL_COLOR_ATTACHMENT0)));
|
||||||
|
m_SSAOViewSpaceZFramBuffer.Generate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SSAOPass::ClearBuffer()
|
||||||
|
{
|
||||||
|
m_SSAOFramBuffer.Bind();
|
||||||
|
glClearColor(1.f, 1.f, 1.f, 1.f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
m_SSAOFramBuffer.Unbind();
|
||||||
|
|
||||||
|
m_SSAOViewSpaceZFramBuffer.Bind();
|
||||||
|
glClearColor(1.f, 1.f, 1.f, 1.f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
m_SSAOViewSpaceZFramBuffer.Unbind();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SSAOPass::Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int NumOfTurns) {
|
||||||
|
m_Radius = radius;
|
||||||
|
m_Bias = bias;
|
||||||
|
m_Contrast = contrast;
|
||||||
|
m_IntensityScale = intensityScale;
|
||||||
|
m_NumOfSamples = numOfSamples;
|
||||||
|
m_NumOfTurns = NumOfTurns;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SSAOPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
|
||||||
|
{
|
||||||
|
glGenTextures(1, texture);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, *texture);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, dimensions.x, dimensions.y, 0, format, type, nullptr);
|
||||||
|
GLERROR("Texture initialization failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
|
||||||
|
{
|
||||||
|
SSAOPassState state;
|
||||||
|
GLuint viewSpaceZPShaderHandle = m_SSAOViewSpaceZProgram->GetHandle();
|
||||||
|
GLuint SSAOShaderHandle = m_SSAOProgram->GetHandle();
|
||||||
|
|
||||||
|
m_SSAOViewSpaceZFramBuffer.Bind();
|
||||||
|
m_SSAOViewSpaceZProgram->Bind();
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, depthBuffer);
|
||||||
|
glm::vec3 clipInfo = glm::vec3(
|
||||||
|
(camera->NearClip() * camera->FarClip()),
|
||||||
|
(camera->NearClip() - camera->FarClip()),
|
||||||
|
(camera->FarClip())
|
||||||
|
);
|
||||||
|
/*glm::vec3 clipInfo = glm::vec3(
|
||||||
|
(camera->NearClip()),
|
||||||
|
(-1.0f),
|
||||||
|
(+1.0f)
|
||||||
|
);*/
|
||||||
|
glUniform3fv(glGetUniformLocation(viewSpaceZPShaderHandle, "ClipInfo"), 1, glm::value_ptr(clipInfo));
|
||||||
|
|
||||||
|
glBindVertexArray(m_ScreenQuad->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
||||||
|
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
|
||||||
|
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
||||||
|
|
||||||
|
glm::vec4 projInfo = glm::vec4(
|
||||||
|
((1.0 - camera->ProjectionMatrix()[0][2]) / camera->ProjectionMatrix()[0][0]),
|
||||||
|
(-2.0 / (m_Renderer->GetViewportSize().Width * camera->ProjectionMatrix()[0][0])),
|
||||||
|
((1.0 + camera->ProjectionMatrix()[1][2]) / camera->ProjectionMatrix()[1][1]),
|
||||||
|
(-2.0 / (m_Renderer->GetViewportSize().Height * camera->ProjectionMatrix()[1][1]))
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
m_SSAOFramBuffer.Bind();
|
||||||
|
m_SSAOProgram->Bind();
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_SSAOViewSpaceZTexture);
|
||||||
|
|
||||||
|
// How many pixel there are in a 1m long object 1m away from the camera
|
||||||
|
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uProjScale"), m_Renderer->GetViewportSize().Height / (-2.0f * glm::tan(camera->FOV() * 0.5f)));
|
||||||
|
|
||||||
|
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uRadius"), m_Radius);
|
||||||
|
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uBias"), m_Bias);
|
||||||
|
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uContrast"), m_Contrast);
|
||||||
|
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uIntensityScale"), m_IntensityScale);
|
||||||
|
glUniform1i(glGetUniformLocation(SSAOShaderHandle, "uNumOfSamples"), m_NumOfSamples);
|
||||||
|
glUniform1i(glGetUniformLocation(SSAOShaderHandle, "uNumOfTurns"), m_NumOfTurns);;
|
||||||
|
|
||||||
|
glUniform4fv(glGetUniformLocation(SSAOShaderHandle, "uProjInfo"), 1, glm::value_ptr(projInfo));
|
||||||
|
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
|
||||||
|
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
||||||
|
|
||||||
|
m_DrawBloomPass->ClearBuffer();
|
||||||
|
m_DrawBloomPass->Draw(m_SSAOTexture);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SSAOPass::OnWindowResize() {
|
||||||
|
m_DrawBloomPass->OnWindowResize();
|
||||||
|
InitializeTexture();
|
||||||
|
m_SSAOFramBuffer.Generate();
|
||||||
|
m_SSAOViewSpaceZFramBuffer.Generate();
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#include "Rendering/SSAOPassState.h"
|
||||||
|
|
||||||
|
|
||||||
|
SSAOPassState::SSAOPassState()
|
||||||
|
{
|
||||||
|
//BindFramebuffer(0);
|
||||||
|
Disable(GL_BLEND);
|
||||||
|
Disable(GL_DEPTH_TEST);
|
||||||
|
Disable(GL_CULL_FACE);
|
||||||
|
}
|
||||||
|
|
||||||
|
SSAOPassState::~SSAOPassState()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -98,8 +98,7 @@ void ShaderProgram::AddShader(std::shared_ptr<Shader> shader)
|
|||||||
|
|
||||||
void ShaderProgram::Compile()
|
void ShaderProgram::Compile()
|
||||||
{
|
{
|
||||||
if (m_ShaderProgramHandle == 0)
|
if (m_ShaderProgramHandle == 0) {
|
||||||
{
|
|
||||||
m_ShaderProgramHandle = glCreateProgram();
|
m_ShaderProgramHandle = glCreateProgram();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ Texture::Texture(std::string path)
|
|||||||
|
|
||||||
this->Width = img->Width;
|
this->Width = img->Width;
|
||||||
this->Height = img->Height;
|
this->Height = img->Height;
|
||||||
|
this->Data = img->Data;
|
||||||
|
|
||||||
GLint format;
|
GLint format;
|
||||||
switch (img->Format) {
|
switch (img->Format) {
|
||||||
@@ -28,6 +29,7 @@ Texture::Texture(std::string path)
|
|||||||
format = GL_RGBA;
|
format = GL_RGBA;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Construct the OpenGL texture
|
// Construct the OpenGL texture
|
||||||
glGenTextures(1, &m_Texture);
|
glGenTextures(1, &m_Texture);
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ void AmmoPickupSystem::Update(double dt)
|
|||||||
newAmmoPickupEntity["Transform"]["Position"] = ammoPickupPosition.Pos;
|
newAmmoPickupEntity["Transform"]["Position"] = ammoPickupPosition.Pos;
|
||||||
newAmmoPickupEntity["AmmoPickup"]["AmmoGain"] = ammoPickupPosition.AmmoGain;
|
newAmmoPickupEntity["AmmoPickup"]["AmmoGain"] = ammoPickupPosition.AmmoGain;
|
||||||
newAmmoPickupEntity["AmmoPickup"]["RespawnTimer"] = ammoPickupPosition.RespawnTimer;
|
newAmmoPickupEntity["AmmoPickup"]["RespawnTimer"] = ammoPickupPosition.RespawnTimer;
|
||||||
|
m_World->SetParent(newAmmoPickupEntity.ID, ammoPickupPosition.parentID);
|
||||||
|
|
||||||
//erase the current element (AmmoPickupPosition)
|
//erase the current element (AmmoPickupPosition)
|
||||||
m_ETriggerTouchVector.erase(it);
|
m_ETriggerTouchVector.erase(it);
|
||||||
@@ -69,8 +70,8 @@ bool AmmoPickupSystem::OnTriggerTouch(Events::TriggerTouch& e)
|
|||||||
|
|
||||||
//copy position, ammogain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object)
|
//copy position, ammogain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object)
|
||||||
//we need to copy all values since each value can be different for each ammoPickup
|
//we need to copy all values since each value can be different for each ammoPickup
|
||||||
m_ETriggerTouchVector.push_back({ (glm::vec3)e.Trigger["Transform"]["Position"] ,e.Trigger["AmmoPickup"]["AmmoGain"],
|
m_ETriggerTouchVector.push_back({ e.Trigger["Transform"]["Position"], e.Trigger["AmmoPickup"]["AmmoGain"],
|
||||||
e.Trigger["AmmoPickup"]["RespawnTimer"],e.Trigger["AmmoPickup"]["RespawnTimer"] });
|
e.Trigger["AmmoPickup"]["RespawnTimer"], e.Trigger["AmmoPickup"]["RespawnTimer"], m_World->GetParent(e.Trigger.ID) });
|
||||||
|
|
||||||
//delete the ammopickup
|
//delete the ammopickup
|
||||||
m_World->DeleteEntity(e.Trigger.ID);
|
m_World->DeleteEntity(e.Trigger.ID);
|
||||||
|
|||||||
@@ -1,32 +1,34 @@
|
|||||||
#include "Systems/CapturePointSystem.h"
|
#include "Systems/CapturePointSystem.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
CapturePointSystem::CapturePointSystem(SystemParams params)
|
CapturePointSystem::CapturePointSystem(SystemParams params)
|
||||||
: System(params)
|
: System(params)
|
||||||
, PureSystem("CapturePoint")
|
, PureSystem("CapturePoint")
|
||||||
{
|
{
|
||||||
//subscribe/listenTo playerdamage,healthpickup events (using the eventBroker)
|
//subscribe/listenTo playerdamage,healthpickup events (using the eventBroker)
|
||||||
if (IsClient) {
|
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch);
|
EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave);
|
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//here all capturepoints will update their component
|
//here all capturepoints will update their component
|
||||||
//NOTE: needs to run each frame, since we're possibly modifying the captureTimer for the capturePoints by dt
|
//NOTE: needs to run each frame, since we're possibly modifying the captureTimer for the capturePoints by dt
|
||||||
void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, ComponentWrapper& cCapturePoint, double dt)
|
void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, ComponentWrapper& cCapturePoint, double dt)
|
||||||
{
|
{
|
||||||
if (!IsClient) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_WinnerWasFound) {
|
if (m_WinnerWasFound) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const int capturePointNumber = cCapturePoint["CapturePointNumber"];
|
const int capturePointNumber = cCapturePoint["CapturePointNumber"];
|
||||||
const bool hasTeamComponent = capturePointEntity.HasComponent("Team");
|
const bool hasTeamComponent = capturePointEntity.HasComponent("Team");
|
||||||
|
|
||||||
|
if (m_NumberOfCapturePoints != 0) {
|
||||||
|
if (!m_CapturePointNumberToEntityMap[0].HasComponent("CapturePoint")) {
|
||||||
|
//if map has changed, the capturepoints has changed, now have to redo them
|
||||||
|
m_NumberOfCapturePoints = 0;
|
||||||
|
m_CapturePointNumberToEntityMap.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
//if point doesnt have a teamComponent yet, add one. since:
|
//if point doesnt have a teamComponent yet, add one. since:
|
||||||
//what if capture point has no team -> we cant get/use the team enum from it...
|
//what if capture point has no team -> we cant get/use the team enum from it...
|
||||||
if (!hasTeamComponent) {
|
if (!hasTeamComponent) {
|
||||||
@@ -71,8 +73,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
|||||||
std::map<std::string, int> nextPossibleCapturePoint;
|
std::map<std::string, int> nextPossibleCapturePoint;
|
||||||
nextPossibleCapturePoint["Red"] = -1;
|
nextPossibleCapturePoint["Red"] = -1;
|
||||||
nextPossibleCapturePoint["Blue"] = -1;
|
nextPossibleCapturePoint["Blue"] = -1;
|
||||||
for (int i = 0; i < m_NumberOfCapturePoints; i++)
|
for (int i = 0; i < m_NumberOfCapturePoints; i++) {
|
||||||
{
|
|
||||||
if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) {
|
if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -84,8 +85,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
|||||||
nextPossibleCapturePoint["Blue"] = i + 1;
|
nextPossibleCapturePoint["Blue"] = i + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = m_NumberOfCapturePoints - 1; i >= 0; i--)
|
for (int i = m_NumberOfCapturePoints - 1; i >= 0; i--) {
|
||||||
{
|
|
||||||
if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) {
|
if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -100,8 +100,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
|||||||
|
|
||||||
//reset timers and reset the bool that triggers this
|
//reset timers and reset the bool that triggers this
|
||||||
if (m_ResetTimers) {
|
if (m_ResetTimers) {
|
||||||
for (int i = 0; i < m_NumberOfCapturePoints; i++)
|
for (int i = 0; i < m_NumberOfCapturePoints; i++) {
|
||||||
{
|
|
||||||
ComponentWrapper& capturePoint = m_CapturePointNumberToEntityMap[i]["CapturePoint"];
|
ComponentWrapper& capturePoint = m_CapturePointNumberToEntityMap[i]["CapturePoint"];
|
||||||
if ((int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Red"] &&
|
if ((int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Red"] &&
|
||||||
(int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Blue"]) {
|
(int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Blue"]) {
|
||||||
@@ -116,8 +115,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
|||||||
}
|
}
|
||||||
|
|
||||||
//check how many players are standing inside and are healthy
|
//check how many players are standing inside and are healthy
|
||||||
for (size_t i = m_ETriggerTouchVector.size(); i > 0; i--)
|
for (size_t i = m_ETriggerTouchVector.size(); i > 0; i--) {
|
||||||
{
|
|
||||||
auto triggerTouched = m_ETriggerTouchVector[i - 1];
|
auto triggerTouched = m_ETriggerTouchVector[i - 1];
|
||||||
if (std::get<1>(triggerTouched) == capturePointEntity) {
|
if (std::get<1>(triggerTouched) == capturePointEntity) {
|
||||||
//some player has touched this - lets figure out: what team, health
|
//some player has touched this - lets figure out: what team, health
|
||||||
@@ -176,8 +174,8 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
|||||||
cCapturePoint["CaptureTimer"] = (double)cCapturePoint["CaptureTimer"] + timerDeltaChange;
|
cCapturePoint["CaptureTimer"] = (double)cCapturePoint["CaptureTimer"] + timerDeltaChange;
|
||||||
}
|
}
|
||||||
//if capturePoint is owned by the team, and the other team has been trying to take it, then increase/decrease the timer towards 0.0
|
//if capturePoint is owned by the team, and the other team has been trying to take it, then increase/decrease the timer towards 0.0
|
||||||
if ((ownedBy == currentTeam && currentTeam == redTeam && (double)cCapturePoint["CaptureTimer"] < 0.0) ||
|
if ((ownedBy == currentTeam && currentTeam == redTeam && (double)cCapturePoint["CaptureTimer"] < captureTimeToTakeOver) ||
|
||||||
(ownedBy == currentTeam && currentTeam == blueTeam && (double)cCapturePoint["CaptureTimer"] > 0.0)) {
|
(ownedBy == currentTeam && currentTeam == blueTeam && (double)cCapturePoint["CaptureTimer"] > -captureTimeToTakeOver)) {
|
||||||
cCapturePoint["CaptureTimer"] = (double)cCapturePoint["CaptureTimer"] + timerDeltaChange;
|
cCapturePoint["CaptureTimer"] = (double)cCapturePoint["CaptureTimer"] + timerDeltaChange;
|
||||||
}
|
}
|
||||||
//check if captureTimer > captureTimeToTakeOver and if so change owner and publish the eCaptured event
|
//check if captureTimer > captureTimeToTakeOver and if so change owner and publish the eCaptured event
|
||||||
@@ -195,17 +193,14 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
|||||||
|
|
||||||
//check for possible winCondition = check if the homebase is owned by the other team
|
//check for possible winCondition = check if the homebase is owned by the other team
|
||||||
bool checkForWinner = false;
|
bool checkForWinner = false;
|
||||||
if (capturePointNumber == m_RedTeamHomeCapturePoint && ownedBy != redTeam)
|
if (capturePointNumber == m_RedTeamHomeCapturePoint && ownedBy != redTeam) {
|
||||||
{
|
|
||||||
checkForWinner = true;
|
checkForWinner = true;
|
||||||
}
|
}
|
||||||
if (capturePointNumber == m_BlueTeamHomeCapturePoint && ownedBy != blueTeam)
|
if (capturePointNumber == m_BlueTeamHomeCapturePoint && ownedBy != blueTeam) {
|
||||||
{
|
|
||||||
checkForWinner = true;
|
checkForWinner = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkForWinner && !m_WinnerWasFound)
|
if (checkForWinner && !m_WinnerWasFound) {
|
||||||
{
|
|
||||||
//publish Win event
|
//publish Win event
|
||||||
Events::Win e;
|
Events::Win e;
|
||||||
e.TeamThatWon = ownedBy;
|
e.TeamThatWon = ownedBy;
|
||||||
@@ -224,8 +219,7 @@ bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e)
|
|||||||
|
|
||||||
bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e)
|
bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < m_ETriggerTouchVector.size(); i++)
|
for (size_t i = 0; i < m_ETriggerTouchVector.size(); i++) {
|
||||||
{
|
|
||||||
auto triggerTouched = m_ETriggerTouchVector[i];
|
auto triggerTouched = m_ETriggerTouchVector[i];
|
||||||
if (std::get<0>(triggerTouched) == e.Entity && std::get<1>(triggerTouched) == e.Trigger) {
|
if (std::get<0>(triggerTouched) == e.Entity && std::get<1>(triggerTouched) == e.Trigger) {
|
||||||
m_ETriggerTouchVector.erase(m_ETriggerTouchVector.begin() + i);
|
m_ETriggerTouchVector.erase(m_ETriggerTouchVector.begin() + i);
|
||||||
|
|||||||
@@ -12,51 +12,41 @@ DamageIndicatorSystem::DamageIndicatorSystem(SystemParams params)
|
|||||||
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/DamageIndicator.xml");
|
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/DamageIndicator.xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DamageIndicatorSystem::Update(double dt) {
|
||||||
|
if (!IsServer) {
|
||||||
|
for (auto& iter = updateDamageIndicatorVector.begin(); iter != updateDamageIndicatorVector.end(); iter++) {
|
||||||
|
if (!iter->spriteEntity.Valid()) {
|
||||||
|
updateDamageIndicatorVector.erase(iter);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
auto angleBetweenVectors = CalculateAngle(LocalPlayer, iter->enemyPosition);
|
||||||
|
//simply set the rotation z-wise to the angleBetweenVectors
|
||||||
|
iter->spriteEntity["Transform"]["Orientation"] = glm::vec3(0, 0, angleBetweenVectors);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool DamageIndicatorSystem::OnPlayerDamage(Events::PlayerDamage& e)
|
bool DamageIndicatorSystem::OnPlayerDamage(Events::PlayerDamage& e)
|
||||||
{
|
{
|
||||||
if (m_CurrentCamera == EntityID_Invalid) {
|
if (m_CurrentCamera == EntityID_Invalid) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (e.Victim != LocalPlayer) {
|
|
||||||
// return false;
|
|
||||||
//}
|
|
||||||
if (e.Victim.Valid() && e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) {
|
if (e.Victim.Valid() && e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!e.Inflictor.Valid() || !e.Victim.Valid()) {
|
if (!e.Inflictor.Valid() || !e.Victim.Valid()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//grab players direction
|
glm::vec3 inflictorPos = e.Inflictor["Transform"]["Position"];
|
||||||
auto playerOrientation = glm::quat((glm::vec3)e.Victim["Transform"]["Orientation"]);
|
//if testing
|
||||||
|
#ifdef INDICATOR_TEST
|
||||||
|
inflictorPos = DamageIndicatorTest(e.Victim);
|
||||||
|
#endif
|
||||||
|
|
||||||
//get the position vectors, but ignore the y-height
|
float angleBetweenVectors = CalculateAngle(e.Victim, inflictorPos);
|
||||||
auto enemyPosition = (glm::vec3)e.Inflictor["Transform"]["Position"];
|
|
||||||
auto playerPosition = (glm::vec3)e.Victim["Transform"]["Position"];
|
|
||||||
enemyPosition.y = 0.0f;
|
|
||||||
playerPosition.y = 0.0f;
|
|
||||||
|
|
||||||
//calculate the enemy to player vector
|
|
||||||
auto enemyPlayerVector = glm::normalize(playerPosition - enemyPosition);
|
|
||||||
|
|
||||||
//get angle from players current rotation, this angle is how much you rotate around the y-axis
|
|
||||||
auto playerAngle = glm::angle(playerOrientation);
|
|
||||||
auto playerRotationVector = glm::normalize(glm::rotateY(glm::vec3(0, 0, 1), playerAngle));
|
|
||||||
|
|
||||||
//dot product of players direction-vector and enemys-to-playervector will give the cos of the angle between the vectors
|
|
||||||
auto playerRotationDot = glm::dot(playerRotationVector, enemyPlayerVector);
|
|
||||||
//to get the angle between the vectors just do cos-inverse
|
|
||||||
auto angleBetweenVectors = glm::acos(playerRotationDot);
|
|
||||||
|
|
||||||
//rotate the direction-vector 90 degrees to get the players side-vector
|
|
||||||
auto playerSideVector = glm::normalize(glm::rotateY(glm::vec3(0, 0, 1), playerAngle + 1.57f));
|
|
||||||
//dot of sidevector positive = enemy is on the right side, dot sidevector negative = left side
|
|
||||||
auto playerSideVectorDot = glm::dot(playerSideVector, enemyPlayerVector);
|
|
||||||
if (playerSideVectorDot < 0) {
|
|
||||||
angleBetweenVectors = -angleBetweenVectors;
|
|
||||||
}
|
|
||||||
|
|
||||||
//load & set the "2d" sprite
|
//load & set the "2d" sprite
|
||||||
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/DamageIndicator.xml");
|
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/DamageIndicator.xml");
|
||||||
@@ -67,6 +57,10 @@ bool DamageIndicatorSystem::OnPlayerDamage(Events::PlayerDamage& e)
|
|||||||
//simply set the rotation z-wise to the angleBetweenVectors
|
//simply set the rotation z-wise to the angleBetweenVectors
|
||||||
spriteWrapper["Transform"]["Orientation"] = glm::vec3(0, 0, angleBetweenVectors);
|
spriteWrapper["Transform"]["Orientation"] = glm::vec3(0, 0, angleBetweenVectors);
|
||||||
|
|
||||||
|
if (!IsServer) {
|
||||||
|
updateDamageIndicatorVector.emplace_back(spriteWrapper, inflictorPos);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,3 +68,82 @@ bool DamageIndicatorSystem::OnSetCamera(const Events::SetCamera& e) {
|
|||||||
m_CurrentCamera = e.CameraEntity.ID;
|
m_CurrentCamera = e.CameraEntity.ID;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float DamageIndicatorSystem::CalculateAngle(EntityWrapper player, glm::vec3 enemyPos) {
|
||||||
|
//grab players direction
|
||||||
|
auto playerOrientation = glm::quat((glm::vec3)player["Transform"]["Orientation"]);
|
||||||
|
|
||||||
|
//get the position vectors, but ignore the y-height
|
||||||
|
auto enemyPosition = enemyPos;
|
||||||
|
auto playerPosition = (glm::vec3)player["Transform"]["Position"];
|
||||||
|
enemyPosition.y = 0.0f;
|
||||||
|
playerPosition.y = 0.0f;
|
||||||
|
|
||||||
|
//calculate the enemy to player vector
|
||||||
|
auto enemyPlayerVector = glm::normalize(playerPosition - enemyPosition);
|
||||||
|
|
||||||
|
//get the rotationvector relative to the z-axis
|
||||||
|
auto rotationVectorVec3 = glm::vec3(glm::toMat4(Transform::AbsoluteOrientation(player))*glm::vec4(0, 0, 1, 0));
|
||||||
|
//rotate the direction-vector 90 degrees to get the players side-vector
|
||||||
|
auto playerSideVector = glm::vec3(glm::rotateY(rotationVectorVec3, 1.57f));
|
||||||
|
|
||||||
|
//dot product of players direction-vector and enemys-to-playervector will give the cos of the angle between the vectors
|
||||||
|
auto playerRotationDot = glm::dot(rotationVectorVec3, enemyPlayerVector);
|
||||||
|
//to get the angle between the vectors just do cos-inverse
|
||||||
|
auto angleBetweenVectors = glm::acos(playerRotationDot);
|
||||||
|
|
||||||
|
//dot of sidevector positive = enemy is on the right side, dot sidevector negative = left side
|
||||||
|
auto playerSideVectorDot = glm::dot(playerSideVector, enemyPlayerVector);
|
||||||
|
if (playerSideVectorDot < 0) {
|
||||||
|
angleBetweenVectors = -angleBetweenVectors;
|
||||||
|
}
|
||||||
|
|
||||||
|
return angleBetweenVectors;
|
||||||
|
}
|
||||||
|
#ifdef INDICATOR_TEST
|
||||||
|
glm::vec3 DamageIndicatorSystem::DamageIndicatorTest(EntityWrapper player) {
|
||||||
|
auto currentPos = (glm::vec3)player["Transform"]["Position"];
|
||||||
|
|
||||||
|
auto testVar = 1;
|
||||||
|
auto testVar2 = 1;
|
||||||
|
if (m_TestVar % 4 == 0) {
|
||||||
|
testVar = -1;
|
||||||
|
testVar2 = 1;
|
||||||
|
}
|
||||||
|
if (m_TestVar % 4 == 1) {
|
||||||
|
testVar = 1;
|
||||||
|
testVar2 = 1;
|
||||||
|
}
|
||||||
|
if (m_TestVar % 4 == 2) {
|
||||||
|
testVar *= -1;
|
||||||
|
testVar2 = -1;
|
||||||
|
}
|
||||||
|
if (m_TestVar % 4 == 3) {
|
||||||
|
testVar = 1;
|
||||||
|
testVar2 = -1;
|
||||||
|
}
|
||||||
|
m_TestVar++;
|
||||||
|
|
||||||
|
auto inflictorPos = glm::vec3(currentPos.x + testVar*6.0f, currentPos.y, currentPos.z + testVar2*6.0f);
|
||||||
|
|
||||||
|
//load the explosioneffect XML
|
||||||
|
auto deathEffect = ResourceManager::Load<EntityFile>("Schema/Entities/PlayerDeathExplosionWithCamera.xml");
|
||||||
|
EntityFileParser parser(deathEffect);
|
||||||
|
EntityID deathEffectID = parser.MergeEntities(m_World);
|
||||||
|
EntityWrapper deathEffectEW = EntityWrapper(m_World, deathEffectID);
|
||||||
|
|
||||||
|
//components that we need from player
|
||||||
|
auto playerModel = player.FirstChildByName("PlayerModel");
|
||||||
|
auto playerEntityModel = playerModel["Model"];
|
||||||
|
auto playerEntityAnimation = playerModel["Animation"];
|
||||||
|
|
||||||
|
//copy the data from player to explosioneffectmodel
|
||||||
|
playerEntityModel.Copy(deathEffectEW["Model"]);
|
||||||
|
playerEntityAnimation.Copy(deathEffectEW["Animation"]);
|
||||||
|
|
||||||
|
//copy the models position,orientation
|
||||||
|
deathEffectEW["Transform"]["Position"] = inflictorPos;
|
||||||
|
deathEffectEW["Transform"]["Orientation"] = (glm::vec3)player["Transform"]["Orientation"];
|
||||||
|
return inflictorPos;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -29,6 +29,7 @@ void PickupSpawnSystem::Update(double dt)
|
|||||||
newHealthPickupEntity["Transform"]["Position"] = healthPickupPosition.Pos;
|
newHealthPickupEntity["Transform"]["Position"] = healthPickupPosition.Pos;
|
||||||
newHealthPickupEntity["HealthPickup"]["HealthGain"] = healthPickupPosition.HealthGain;
|
newHealthPickupEntity["HealthPickup"]["HealthGain"] = healthPickupPosition.HealthGain;
|
||||||
newHealthPickupEntity["HealthPickup"]["RespawnTimer"] = healthPickupPosition.RespawnTimer;
|
newHealthPickupEntity["HealthPickup"]["RespawnTimer"] = healthPickupPosition.RespawnTimer;
|
||||||
|
m_World->SetParent(newHealthPickupEntity.ID, healthPickupPosition.parentID);
|
||||||
|
|
||||||
//erase the current element (healthPickupPosition)
|
//erase the current element (healthPickupPosition)
|
||||||
m_ETriggerTouchVector.erase(it);
|
m_ETriggerTouchVector.erase(it);
|
||||||
@@ -58,7 +59,7 @@ bool PickupSpawnSystem::OnTriggerTouch(Events::TriggerTouch& e)
|
|||||||
//copy position, healthgain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object)
|
//copy position, healthgain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object)
|
||||||
//we need to copy all values since each value can be different for each healthPickup
|
//we need to copy all values since each value can be different for each healthPickup
|
||||||
m_ETriggerTouchVector.push_back({ (glm::vec3)e.Trigger["Transform"]["Position"] ,e.Trigger["HealthPickup"]["HealthGain"],
|
m_ETriggerTouchVector.push_back({ (glm::vec3)e.Trigger["Transform"]["Position"] ,e.Trigger["HealthPickup"]["HealthGain"],
|
||||||
e.Trigger["HealthPickup"]["RespawnTimer"],e.Trigger["HealthPickup"]["RespawnTimer"] });
|
e.Trigger["HealthPickup"]["RespawnTimer"],e.Trigger["HealthPickup"]["RespawnTimer"], m_World->GetParent(e.Trigger.ID) });
|
||||||
|
|
||||||
//delete the healthpickup
|
//delete the healthpickup
|
||||||
m_World->DeleteEntity(e.Trigger.ID);
|
m_World->DeleteEntity(e.Trigger.ID);
|
||||||
|
|||||||
@@ -33,9 +33,8 @@ void PlayerDeathSystem::createDeathEffect(EntityWrapper player)
|
|||||||
EntityWrapper deathEffectEW = EntityWrapper(m_World, deathEffectID);
|
EntityWrapper deathEffectEW = EntityWrapper(m_World, deathEffectID);
|
||||||
|
|
||||||
//components that we need from player
|
//components that we need from player
|
||||||
auto playerCamera = player.FirstChildByName("Camera");
|
|
||||||
auto playerModel = player.FirstChildByName("PlayerModel");
|
auto playerModel = player.FirstChildByName("PlayerModel");
|
||||||
if (!playerCamera.Valid() || !playerModel.Valid()) {
|
if (!playerModel.Valid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!playerModel.HasComponent("Model") || !playerModel.HasComponent("Animation")) {
|
if (!playerModel.HasComponent("Model") || !playerModel.HasComponent("Animation")) {
|
||||||
@@ -44,7 +43,7 @@ void PlayerDeathSystem::createDeathEffect(EntityWrapper player)
|
|||||||
auto playerEntityModel = playerModel["Model"];
|
auto playerEntityModel = playerModel["Model"];
|
||||||
auto playerEntityAnimation = playerModel["Animation"];
|
auto playerEntityAnimation = playerModel["Animation"];
|
||||||
|
|
||||||
//copy the data from player to explisioneffectmodel
|
//copy the data from player to explosioneffectmodel
|
||||||
playerEntityModel.Copy(deathEffectEW["Model"]);
|
playerEntityModel.Copy(deathEffectEW["Model"]);
|
||||||
playerEntityAnimation.Copy(deathEffectEW["Animation"]);
|
playerEntityAnimation.Copy(deathEffectEW["Animation"]);
|
||||||
//freeze the animation
|
//freeze the animation
|
||||||
|
|||||||
@@ -16,7 +16,15 @@ PlayerMovementSystem::~PlayerMovementSystem()
|
|||||||
void PlayerMovementSystem::Update(double dt)
|
void PlayerMovementSystem::Update(double dt)
|
||||||
{
|
{
|
||||||
updateMovementControllers(dt);
|
updateMovementControllers(dt);
|
||||||
updateVelocity(dt);
|
if (IsServer) {
|
||||||
|
for (auto& kv : m_PlayerInputControllers) {
|
||||||
|
updateVelocity(kv.first, dt);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (LocalPlayer.Valid()) {
|
||||||
|
updateVelocity(LocalPlayer, dt);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerMovementSystem::updateMovementControllers(double dt)
|
void PlayerMovementSystem::updateMovementControllers(double dt)
|
||||||
@@ -221,15 +229,11 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PlayerMovementSystem::updateVelocity(double dt)
|
void PlayerMovementSystem::updateVelocity(EntityWrapper player, double dt)
|
||||||
{
|
{
|
||||||
// Only apply velocity to local player
|
// Only apply velocity to local player
|
||||||
if (!LocalPlayer.Valid()) {
|
ComponentWrapper& cTransform = player["Transform"];
|
||||||
return;
|
ComponentWrapper& cPhysics = player["Physics"];
|
||||||
}
|
|
||||||
|
|
||||||
ComponentWrapper& cTransform = LocalPlayer["Transform"];
|
|
||||||
ComponentWrapper& cPhysics = LocalPlayer["Physics"];
|
|
||||||
glm::vec3& velocity = cPhysics["Velocity"];
|
glm::vec3& velocity = cPhysics["Velocity"];
|
||||||
bool isOnGround = (bool)cPhysics["IsOnGround"];
|
bool isOnGround = (bool)cPhysics["IsOnGround"];
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ SoundSystem::SoundSystem(SystemParams params)
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &SoundSystem::OnPlayerDamage);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &SoundSystem::OnPlayerDamage);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &SoundSystem::OnCaptured);
|
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &SoundSystem::OnCaptured);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &SoundSystem::OnTriggerTouch);
|
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &SoundSystem::OnTriggerTouch);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDeath, &SoundSystem::OnPlayerDeath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,6 +91,9 @@ bool SoundSystem::drumTimer(double dt)
|
|||||||
|
|
||||||
bool SoundSystem::OnCaptured(const Events::Captured & e)
|
bool SoundSystem::OnCaptured(const Events::Captured & e)
|
||||||
{
|
{
|
||||||
|
if (!LocalPlayer.Valid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
int homeTeam = (int)m_World->GetComponent(e.CapturePointID, "Team")["Team"];
|
int homeTeam = (int)m_World->GetComponent(e.CapturePointID, "Team")["Team"];
|
||||||
int team = (int)m_World->GetComponent(LocalPlayer.ID, "Team")["Team"];
|
int team = (int)m_World->GetComponent(LocalPlayer.ID, "Team")["Team"];
|
||||||
Events::PlaySoundOnEntity ev;
|
Events::PlaySoundOnEntity ev;
|
||||||
@@ -108,7 +112,12 @@ bool SoundSystem::OnCaptured(const Events::Captured & e)
|
|||||||
// Testing purposes atm...
|
// Testing purposes atm...
|
||||||
bool SoundSystem::OnPlayerDamage(const Events::PlayerDamage & e)
|
bool SoundSystem::OnPlayerDamage(const Events::PlayerDamage & e)
|
||||||
{
|
{
|
||||||
// Should check for only local players here...
|
if (!IsClient) { // Only play for clients
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (LocalPlayer.ID = e.Victim.ID) { // You're local player was the one who took dmg
|
||||||
|
return false;
|
||||||
|
}
|
||||||
std::uniform_int_distribution<int> dist(1, 12);
|
std::uniform_int_distribution<int> dist(1, 12);
|
||||||
int rand = dist(generator);
|
int rand = dist(generator);
|
||||||
std::vector<std::string> paths;
|
std::vector<std::string> paths;
|
||||||
@@ -128,8 +137,16 @@ bool SoundSystem::OnPlayerDamage(const Events::PlayerDamage & e)
|
|||||||
|
|
||||||
bool SoundSystem::OnPlayerDeath(const Events::PlayerDeath & e)
|
bool SoundSystem::OnPlayerDeath(const Events::PlayerDeath & e)
|
||||||
{
|
{
|
||||||
Events::PlaySoundOnEntity ev;
|
if (e.Player.ID != LocalPlayer.ID) {
|
||||||
ev.EmitterID = LocalPlayer.ID;
|
return false;
|
||||||
|
}
|
||||||
|
if (!IsClient) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// The local player is dead. The local player might be invalid?
|
||||||
|
// Play the sound from the listener.
|
||||||
|
// TODO: We might want to hear other players die.
|
||||||
|
Events::PlayBackgroundMusic ev;
|
||||||
ev.FilePath = "Audio/die/die2.wav";
|
ev.FilePath = "Audio/die/die2.wav";
|
||||||
m_EventBroker->Publish(ev);
|
m_EventBroker->Publish(ev);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ AssaultWeaponBehaviour::AssaultWeaponBehaviour(SystemParams systemParams, IRende
|
|||||||
{
|
{
|
||||||
m_FirstPersonModel = m_Player.FirstChildByName("Hands");
|
m_FirstPersonModel = m_Player.FirstChildByName("Hands");
|
||||||
m_ThirdPersonModel = m_Player.FirstChildByName("PlayerModel");
|
m_ThirdPersonModel = m_Player.FirstChildByName("PlayerModel");
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EAnimationComplete, &AssaultWeaponBehaviour::OnAnimationComplete);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssaultWeaponBehaviour::Fire()
|
void AssaultWeaponBehaviour::Fire()
|
||||||
@@ -36,7 +35,7 @@ void AssaultWeaponBehaviour::Reload()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't reload if we're completly out of ammo
|
// Don't reload if we're completely out of ammo
|
||||||
if (ammo == 0) {
|
if (ammo == 0) {
|
||||||
playEmptySound();
|
playEmptySound();
|
||||||
m_TimeSinceLastFire = -0.0f; // HACK: To make empty sound play with interval
|
m_TimeSinceLastFire = -0.0f; // HACK: To make empty sound play with interval
|
||||||
@@ -56,14 +55,14 @@ void AssaultWeaponBehaviour::Update(double dt)
|
|||||||
{
|
{
|
||||||
if (m_Reloading) {
|
if (m_Reloading) {
|
||||||
m_ReloadTimer -= dt;
|
m_ReloadTimer -= dt;
|
||||||
// Re-enable glow on reload impersonator half-way through the animation
|
// Re-enable glow on reload impostor half-way through the animation
|
||||||
if (IsClient) {
|
if (IsClient) {
|
||||||
if (m_ReloadTimer <= (double)m_Player["AssaultWeapon"]["ReloadTime"] / 2.0) {
|
if (m_ReloadTimer <= (double)m_Player["AssaultWeapon"]["ReloadTime"] / 2.0) {
|
||||||
if (m_FirstPersonReloadImpersonator.Valid()) {
|
if (m_FirstPersonReloadImpostor.Valid()) {
|
||||||
m_FirstPersonReloadImpersonator["Model"]["GlowMap"] = true;
|
m_FirstPersonReloadImpostor["Model"]["GlowMap"] = true;
|
||||||
}
|
}
|
||||||
if (m_ThirdPersonReloadImpersonator.Valid()) {
|
if (m_ThirdPersonReloadImpostor.Valid()) {
|
||||||
m_ThirdPersonReloadImpersonator["Model"]["GlowMap"] = true;
|
m_ThirdPersonReloadImpostor["Model"]["GlowMap"] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,21 +95,6 @@ void AssaultWeaponBehaviour::Update(double dt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AssaultWeaponBehaviour::OnAnimationComplete(Events::AnimationComplete& e)
|
|
||||||
{
|
|
||||||
if (e.Entity != m_FirstPersonModel) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//if (e.Name == "ShootRifle") {
|
|
||||||
// if (!m_Firing) {
|
|
||||||
// playIdleAnimation();
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AssaultWeaponBehaviour::hasAmmo()
|
bool AssaultWeaponBehaviour::hasAmmo()
|
||||||
{
|
{
|
||||||
ComponentWrapper& cAssaultWeapon = m_Player["AssaultWeapon"];
|
ComponentWrapper& cAssaultWeapon = m_Player["AssaultWeapon"];
|
||||||
@@ -215,6 +199,12 @@ void AssaultWeaponBehaviour::playEmptySound()
|
|||||||
|
|
||||||
void AssaultWeaponBehaviour::viewPunch()
|
void AssaultWeaponBehaviour::viewPunch()
|
||||||
{
|
{
|
||||||
|
// Since we send absolute client orientations to server, running this server side would
|
||||||
|
// cause aim desync.
|
||||||
|
if (!IsClient) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
EntityWrapper playerCamera = m_Player.FirstChildByName("Camera");
|
EntityWrapper playerCamera = m_Player.FirstChildByName("Camera");
|
||||||
if (!playerCamera.Valid()) {
|
if (!playerCamera.Valid()) {
|
||||||
return;
|
return;
|
||||||
@@ -323,8 +313,8 @@ void AssaultWeaponBehaviour::playReloadAnimation()
|
|||||||
EntityWrapper firstPersonWeaponModel = m_Player.FirstChildByName("WeaponModel");
|
EntityWrapper firstPersonWeaponModel = m_Player.FirstChildByName("WeaponModel");
|
||||||
EntityWrapper reloadSpawner = m_Player.FirstChildByName("FirstPersonReloadSpawner");
|
EntityWrapper reloadSpawner = m_Player.FirstChildByName("FirstPersonReloadSpawner");
|
||||||
if (IsClient) {
|
if (IsClient) {
|
||||||
m_FirstPersonReloadImpersonator = SpawnerSystem::Spawn(reloadSpawner, reloadSpawner);
|
m_FirstPersonReloadImpostor = SpawnerSystem::Spawn(reloadSpawner, reloadSpawner);
|
||||||
firstPersonWeaponModel["Model"].Copy(m_FirstPersonReloadImpersonator["Model"]);
|
firstPersonWeaponModel["Model"].Copy(m_FirstPersonReloadImpostor["Model"]);
|
||||||
}
|
}
|
||||||
firstPersonWeaponModel["Model"]["Visible"] = false;
|
firstPersonWeaponModel["Model"]["Visible"] = false;
|
||||||
}
|
}
|
||||||
@@ -332,8 +322,8 @@ void AssaultWeaponBehaviour::playReloadAnimation()
|
|||||||
EntityWrapper thirdPersonWeaponModel = m_Player.FirstChildByName("ThirdPersonWeaponModel");
|
EntityWrapper thirdPersonWeaponModel = m_Player.FirstChildByName("ThirdPersonWeaponModel");
|
||||||
EntityWrapper reloadSpawner = m_Player.FirstChildByName("ThirdPersonReloadSpawner");
|
EntityWrapper reloadSpawner = m_Player.FirstChildByName("ThirdPersonReloadSpawner");
|
||||||
if (IsClient) {
|
if (IsClient) {
|
||||||
m_ThirdPersonReloadImpersonator = SpawnerSystem::Spawn(reloadSpawner, reloadSpawner);
|
m_ThirdPersonReloadImpostor = SpawnerSystem::Spawn(reloadSpawner, reloadSpawner);
|
||||||
thirdPersonWeaponModel["Model"].Copy(m_ThirdPersonReloadImpersonator["Model"]);
|
thirdPersonWeaponModel["Model"].Copy(m_ThirdPersonReloadImpostor["Model"]);
|
||||||
}
|
}
|
||||||
thirdPersonWeaponModel["Model"]["Visible"] = false;
|
thirdPersonWeaponModel["Model"]["Visible"] = false;
|
||||||
}
|
}
|
||||||
@@ -371,7 +361,7 @@ bool AssaultWeaponBehaviour::shoot(double damage)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't let us shoot ourselves in the foot
|
// Don't let us shoot ourselves in the foot somehow
|
||||||
if (victim == LocalPlayer) {
|
if (victim == LocalPlayer) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
#include "Systems/Weapon/DefenderWeaponBehaviour.h"
|
||||||
|
|
||||||
|
DefenderWeaponBehaviour::DefenderWeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree<EntityAABB>* collisionOctree, EntityWrapper weaponEntity)
|
||||||
|
: WeaponBehaviour(systemParams, renderer, collisionOctree, weaponEntity) { }
|
||||||
|
|
||||||
|
void DefenderWeaponBehaviour::Fire()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ WeaponSystem::WeaponSystem(SystemParams params, IRenderer* renderer, Octree<Enti
|
|||||||
|
|
||||||
void WeaponSystem::Update(double dt)
|
void WeaponSystem::Update(double dt)
|
||||||
{
|
{
|
||||||
|
// TODO: Clear inactive weapons
|
||||||
}
|
}
|
||||||
|
|
||||||
void WeaponSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cPlayer, double dt)
|
void WeaponSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cPlayer, double dt)
|
||||||
@@ -72,20 +72,64 @@ bool WeaponSystem::OnInputCommand(Events::InputCommand& e)
|
|||||||
|
|
||||||
void WeaponSystem::selectWeapon(EntityWrapper player, ComponentInfo::EnumType slot)
|
void WeaponSystem::selectWeapon(EntityWrapper player, ComponentInfo::EnumType slot)
|
||||||
{
|
{
|
||||||
|
std::vector<EntityWrapper> weaponAttachments = player.ChildrenWithComponent("WeaponAttachment");
|
||||||
|
|
||||||
|
// Find the weapon attachments matching the slot selected
|
||||||
|
EntityWrapper firstPersonAttachment;
|
||||||
|
EntityWrapper thirdPersonAttachment;
|
||||||
|
for (auto& attachment : weaponAttachments) {
|
||||||
|
ComponentWrapper cWeaponAttachment = attachment["WeaponAttachment"];
|
||||||
|
if ((ComponentInfo::EnumType)cWeaponAttachment["Slot"] == slot) {
|
||||||
|
ComponentWrapper::SubscriptProxy person = cWeaponAttachment["Person"];
|
||||||
|
if (person == person.Enum("FirstPerson")) {
|
||||||
|
firstPersonAttachment = attachment;
|
||||||
|
} else if (person == person.Enum("ThirdPerson")) {
|
||||||
|
thirdPersonAttachment = attachment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (firstPersonAttachment.Valid() && thirdPersonAttachment.Valid()) {
|
||||||
|
LOG_WARNING("No weapon attachment found for slot %i of player #%i", slot, player.ID);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Delete old weapons
|
||||||
|
|
||||||
|
// Spawn the weapon(s)
|
||||||
|
EntityWrapper firstPersonWeapon;
|
||||||
|
EntityWrapper thirdPersonWeapon;
|
||||||
|
if (firstPersonAttachment.Valid()) {
|
||||||
|
firstPersonWeapon = SpawnerSystem::Spawn(firstPersonAttachment, firstPersonAttachment);
|
||||||
|
}
|
||||||
|
if (thirdPersonAttachment.Valid()) {
|
||||||
|
firstPersonWeapon = SpawnerSystem::Spawn(thirdPersonAttachment, thirdPersonAttachment);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the correct behaviour
|
||||||
|
if (firstPersonWeapon.Valid()) {
|
||||||
|
if (firstPersonWeapon.HasComponent("AssaultWeapon") {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Primary
|
// Primary
|
||||||
if (slot == 1) {
|
if (slot == 1) {
|
||||||
// TODO: if class...
|
// TODO: if class...
|
||||||
if (m_ActiveWeapons.count(player) == 0) {
|
nextBehaviour = std::make_shared<AssaultWeaponBehaviour>(m_SystemParams, m_Renderer, m_CollisionOctree, player);
|
||||||
m_ActiveWeapons.insert(std::make_pair(player, std::make_shared<AssaultWeaponBehaviour>(m_SystemParams, m_Renderer, m_CollisionOctree, player)));
|
|
||||||
} else {
|
|
||||||
//m_ActiveWeapons.erase(player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Secondary
|
// Secondary
|
||||||
if (slot == 2) {
|
if (slot == 2) {
|
||||||
//m_ActiveWeapons[player] = std::make_shared<PistolWeaponBehaviour>();
|
//m_ActiveWeapons[player] = std::make_shared<PistolWeaponBehaviour>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nextBehaviour != nullptr) {
|
||||||
|
// TODO: Destroy previous behaviour and make new
|
||||||
|
if (m_ActiveWeapons.count(player) == 0) {
|
||||||
|
m_ActiveWeapons[player] = nextBehaviour;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WeaponSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
|
bool WeaponSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
#include "Core/EventBroker.h"
|
#include "Core/EventBroker.h"
|
||||||
#include "Rendering/Renderer.h"
|
#include "Rendering/Renderer.h"
|
||||||
#include "Core/InputManager.h"
|
#include "Core/InputManager.h"
|
||||||
#include "GUI/Frame.h"
|
|
||||||
#include "Core/World.h"
|
#include "Core/World.h"
|
||||||
#include "Input/InputProxy.h"
|
#include "Input/InputProxy.h"
|
||||||
#include "Input/KeyboardInputHandler.h"
|
#include "Input/KeyboardInputHandler.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user