Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f59a9e1d2b | |||
| 5796d07b56 | |||
| c790b952fb | |||
| be3d75a5cf | |||
| b3c935c7cc | |||
| f05b09ca7a | |||
| e76740d72b | |||
| d3927de7cc | |||
| 5aaefc6e53 | |||
| fe090504cf | |||
| a9d5c5d9d2 | |||
| 5f11d1e066 | |||
| 672d6f884d | |||
| 5ea0f04b20 | |||
| fb400bb743 | |||
| aa2475dfd6 | |||
| 36c4837813 | |||
| 741ed01930 | |||
| 2fa3637018 | |||
| 52e5e2527a | |||
| 36253a8afd | |||
| 5c343cb254 | |||
| b73595eed0 | |||
| bb3a8dba6a | |||
| f9e640ffc6 | |||
| f2c7a9f27a | |||
| ac20e41a5d | |||
| 4f99f6ef74 | |||
| d0a083a1e3 | |||
| d5f06fa8c2 | |||
| 8bb8ebbea3 | |||
| ec7ab417e6 | |||
| 20d46f63c8 | |||
| 2e89227061 | |||
| 958850903a | |||
| 5146d21173 | |||
| b7d88808e2 | |||
| f8f536802f | |||
| 60df30fa59 | |||
| 70b0ca8776 | |||
| 90d848e8d9 | |||
| c544f349fd | |||
| 0c1a2d3160 | |||
| 1ad087dc75 |
+1
-1
Submodule assets updated: bc6e7df04c...6ffc1ab82a
@@ -48,13 +48,13 @@ bool RayVsTriangle(const Ray& ray,
|
|||||||
bool trueOnNegativeDistance = false);
|
bool trueOnNegativeDistance = false);
|
||||||
//Return true if the ray hits any of the triangles in the model. Stops checking when a hit is detected.
|
//Return true if the ray hits any of the triangles in the model. Stops checking when a hit is detected.
|
||||||
bool RayVsModel(const Ray& ray,
|
bool RayVsModel(const Ray& ray,
|
||||||
const std::vector<glm::vec3>& modelVertices,
|
const RawModel::Vertex* modelVertices,
|
||||||
const std::vector<unsigned int>& modelIndices,
|
const std::vector<unsigned int>& modelIndices,
|
||||||
const glm::mat4& modelMatrix);
|
const glm::mat4& modelMatrix);
|
||||||
//Return true if the ray hits any of the triangles in the model.
|
//Return true if the ray hits any of the triangles in the model.
|
||||||
//Also returns the position of the intersection point. Will loop through all the whole model indices.
|
//Also returns the position of the intersection point. Will loop through all the whole model indices.
|
||||||
bool RayVsModel(const Ray& ray,
|
bool RayVsModel(const Ray& ray,
|
||||||
const std::vector<glm::vec3>& modelVertices,
|
const RawModel::Vertex* modelVertices,
|
||||||
const std::vector<unsigned int>& modelIndices,
|
const std::vector<unsigned int>& modelIndices,
|
||||||
const glm::mat4& modelMatrix,
|
const glm::mat4& modelMatrix,
|
||||||
glm::vec3& outHitPosition);
|
glm::vec3& outHitPosition);
|
||||||
@@ -62,7 +62,7 @@ bool RayVsModel(const Ray& ray,
|
|||||||
//Also returns the distance from the ray origin to the closest
|
//Also returns the distance from the ray origin to the closest
|
||||||
//intersection point, and the barycentric u,v-coordinates. Will loop through all the whole model indices.
|
//intersection point, and the barycentric u,v-coordinates. Will loop through all the whole model indices.
|
||||||
bool RayVsModel(const Ray& ray,
|
bool RayVsModel(const Ray& ray,
|
||||||
const std::vector<glm::vec3>& modelVertices,
|
const RawModel::Vertex* modelVertices,
|
||||||
const std::vector<unsigned int>& modelIndices,
|
const std::vector<unsigned int>& modelIndices,
|
||||||
const glm::mat4& modelMatrix,
|
const glm::mat4& modelMatrix,
|
||||||
float& outDistance,
|
float& outDistance,
|
||||||
@@ -70,7 +70,7 @@ bool RayVsModel(const Ray& ray,
|
|||||||
float& outVCoord);
|
float& outVCoord);
|
||||||
|
|
||||||
bool AABBvsTriangles(const AABB& box,
|
bool AABBvsTriangles(const AABB& box,
|
||||||
const std::vector<glm::vec3>& modelVertices,
|
const RawModel::Vertex* modelVertices,
|
||||||
const std::vector<unsigned int>& modelIndices,
|
const std::vector<unsigned int>& modelIndices,
|
||||||
const glm::mat4& modelMatrix,
|
const glm::mat4& modelMatrix,
|
||||||
glm::vec3& boxVelocity,
|
glm::vec3& boxVelocity,
|
||||||
@@ -80,7 +80,7 @@ bool AABBvsTriangles(const AABB& box,
|
|||||||
|
|
||||||
//Detects collision, but does not resolve.
|
//Detects collision, but does not resolve.
|
||||||
bool AABBvsTriangles(const AABB& box,
|
bool AABBvsTriangles(const AABB& box,
|
||||||
const std::vector<glm::vec3>& modelVertices,
|
const RawModel::Vertex* modelVertices,
|
||||||
const std::vector<unsigned int>& modelIndices,
|
const std::vector<unsigned int>& modelIndices,
|
||||||
const glm::mat4& modelMatrix);
|
const glm::mat4& modelMatrix);
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ enum Output
|
|||||||
};
|
};
|
||||||
//Detects intersection and containment.
|
//Detects intersection and containment.
|
||||||
Output AABBvsTrianglesWContainment(const AABB& box,
|
Output AABBvsTrianglesWContainment(const AABB& box,
|
||||||
const std::vector<glm::vec3>& modelVertices,
|
const RawModel::Vertex* modelVertices,
|
||||||
const std::vector<unsigned int>& modelIndices,
|
const std::vector<unsigned int>& modelIndices,
|
||||||
const glm::mat4& modelMatrix);
|
const glm::mat4& modelMatrix);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef ECaptured_h__
|
#ifndef Events_Captured_h__
|
||||||
#define ECaptured_h__
|
#define Events_Captured_h__
|
||||||
|
|
||||||
#include "EventBroker.h"
|
#include "EventBroker.h"
|
||||||
#include "../Core/Entity.h"
|
#include "../Core/Entity.h"
|
||||||
|
|||||||
@@ -2,8 +2,11 @@
|
|||||||
#define PerformanceTimer_h__
|
#define PerformanceTimer_h__
|
||||||
|
|
||||||
#include "../Common.h"
|
#include "../Common.h"
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
#include <boost/timer/timer.hpp>
|
#include <boost/timer/timer.hpp>
|
||||||
using boost::timer::cpu_timer;
|
using boost::timer::cpu_timer;
|
||||||
|
#endif //DEBUG
|
||||||
|
|
||||||
class PerformanceTimer
|
class PerformanceTimer
|
||||||
{
|
{
|
||||||
@@ -17,9 +20,11 @@ public:
|
|||||||
static void CreateExcelData();
|
static void CreateExcelData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#ifdef DEBUG
|
||||||
static std::map<std::string, cpu_timer> timers;
|
static std::map<std::string, cpu_timer> timers;
|
||||||
static cpu_timer m_Timer;
|
static cpu_timer m_Timer;
|
||||||
static std::string currentTimerRunning;
|
static std::string currentTimerRunning;
|
||||||
|
#endif //DEBUG
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -10,28 +10,32 @@
|
|||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <boost/shared_array.hpp>
|
#include <boost/shared_array.hpp>
|
||||||
|
|
||||||
|
#include "Core/World.h"
|
||||||
|
#include "Core/EntityFile.h"
|
||||||
|
#include "Core/EventBroker.h"
|
||||||
|
#include "Core/ConfigFile.h"
|
||||||
|
#include "Core/EPlayerDeath.h"
|
||||||
|
#include "Core/EPlayerDamage.h"
|
||||||
|
#include "Core/EPlayerSpawned.h"
|
||||||
|
#include "Core/EAmmoPickup.h"
|
||||||
|
#include "Game/Events/EDoubleJump.h"
|
||||||
|
#include "Game/Events/EDashAbility.h"
|
||||||
|
#include "Game/Events/EReset.h"
|
||||||
|
#include "Input/EInputCommand.h"
|
||||||
|
#include "imgui/imgui.h"
|
||||||
#include "Network/Network.h"
|
#include "Network/Network.h"
|
||||||
#include "Network/MessageType.h"
|
#include "Network/MessageType.h"
|
||||||
#include "Network/PlayerDefinition.h"
|
#include "Network/PlayerDefinition.h"
|
||||||
#include "Network/UDPClient.h"
|
#include "Network/UDPClient.h"
|
||||||
#include "Network/TCPClient.h"
|
#include "Network/TCPClient.h"
|
||||||
#include "Network/SnapshotDefinitions.h"
|
#include "Network/SnapshotDefinitions.h"
|
||||||
#include "Core/World.h"
|
|
||||||
#include "Core/EntityFile.h"
|
|
||||||
#include "Core/EventBroker.h"
|
|
||||||
#include "Core/ConfigFile.h"
|
|
||||||
#include "Core/EPlayerDeath.h"
|
|
||||||
#include "Input/EInputCommand.h"
|
|
||||||
#include "Core/EPlayerDamage.h"
|
|
||||||
#include "../Game/Events/EDoubleJump.h"
|
|
||||||
#include "Network/EInterpolate.h"
|
|
||||||
#include "Network/SnapshotFilter.h"
|
|
||||||
#include "Core/EPlayerSpawned.h"
|
|
||||||
#include "Core/EAmmoPickup.h"
|
|
||||||
#include "Network/ESearchForServers.h"
|
|
||||||
#include "../Game/Events/EDashAbility.h"
|
|
||||||
#include "Network/EDisplayServerlist.h"
|
#include "Network/EDisplayServerlist.h"
|
||||||
#include "Network/EConnectRequest.h"
|
#include "Network/EConnectRequest.h"
|
||||||
|
#include "Network/EPlayerDisconnected.h"
|
||||||
|
#include "Network/ESearchForServers.h"
|
||||||
|
#include "Network/EInterpolate.h"
|
||||||
|
#include "Network/SnapshotFilter.h"
|
||||||
|
|
||||||
class Client : public Network
|
class Client : public Network
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -40,7 +44,7 @@ public:
|
|||||||
~Client();
|
~Client();
|
||||||
|
|
||||||
void Connect(std::string address, int port);
|
void Connect(std::string address, int port);
|
||||||
void Update() override;
|
void Update(double dt) override;
|
||||||
private:
|
private:
|
||||||
UDPClient m_Unreliable;
|
UDPClient m_Unreliable;
|
||||||
TCPClient m_Reliable;
|
TCPClient m_Reliable;
|
||||||
@@ -74,10 +78,10 @@ private:
|
|||||||
// Network logic
|
// Network logic
|
||||||
PlayerDefinition m_PlayerDefinitions[8];
|
PlayerDefinition m_PlayerDefinitions[8];
|
||||||
SnapshotDefinitions m_NextSnapshot;
|
SnapshotDefinitions m_NextSnapshot;
|
||||||
double m_DurationOfPingTime;
|
double m_DurationOfPingTime = 0;
|
||||||
std::clock_t m_StartPingTime;
|
double m_StartPingTime = 0;
|
||||||
std::clock_t m_TimeSinceSentInputs;
|
double m_TimeSinceSentInputs = 0;
|
||||||
unsigned int m_SendInputIntervalMs;
|
double m_SendInputInterval = 0.033;
|
||||||
std::vector<Events::InputCommand> m_InputCommandBuffer;
|
std::vector<Events::InputCommand> m_InputCommandBuffer;
|
||||||
|
|
||||||
// Private member functions
|
// Private member functions
|
||||||
@@ -100,6 +104,7 @@ private:
|
|||||||
void parseDoubleJump(Packet& packet);
|
void parseDoubleJump(Packet& packet);
|
||||||
void parseDashEffect(Packet& packet);
|
void parseDashEffect(Packet& packet);
|
||||||
void parseAmmoPickup(Packet& packet);
|
void parseAmmoPickup(Packet& packet);
|
||||||
|
void parseRemoveWorld(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 identifyPacketLoss();
|
void identifyPacketLoss();
|
||||||
@@ -109,7 +114,6 @@ private:
|
|||||||
void sendLocalPlayerTransform();
|
void sendLocalPlayerTransform();
|
||||||
void becomePlayer();
|
void becomePlayer();
|
||||||
void displayServerlist();
|
void displayServerlist();
|
||||||
void removeWorld();
|
|
||||||
void createMainMenu();
|
void createMainMenu();
|
||||||
// Mapping Logic
|
// Mapping Logic
|
||||||
// Returns if local EntityID exist in map
|
// Returns if local EntityID exist in map
|
||||||
@@ -138,8 +142,8 @@ private:
|
|||||||
UDPClient m_ServerlistRequest;
|
UDPClient m_ServerlistRequest;
|
||||||
std::vector<ServerInfo> m_Serverlist;
|
std::vector<ServerInfo> m_Serverlist;
|
||||||
bool m_SearchingForServers = false;
|
bool m_SearchingForServers = false;
|
||||||
std::clock_t m_StartSearchTime;
|
double m_TimeSearched = 0;
|
||||||
double m_SearchingTime = 200; // Config I guess
|
double m_SearchingTime = 0.2; // Config I guess
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ enum class MessageType
|
|||||||
OnDashEffect,
|
OnDashEffect,
|
||||||
ServerlistRequest,
|
ServerlistRequest,
|
||||||
AmmoPickup,
|
AmmoPickup,
|
||||||
|
RemoveWorld,
|
||||||
Invalid
|
Invalid
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public:
|
|||||||
Network(World* world, EventBroker* eventBroker);
|
Network(World* world, EventBroker* eventBroker);
|
||||||
virtual ~Network() { };
|
virtual ~Network() { };
|
||||||
|
|
||||||
virtual void Update() = 0;
|
virtual void Update(double dt) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
World* m_World;
|
World* m_World;
|
||||||
@@ -40,6 +40,7 @@ protected:
|
|||||||
void saveToFile();
|
void saveToFile();
|
||||||
void updateNetworkData();
|
void updateNetworkData();
|
||||||
void popNetworkSegmentOfHeader(Packet& packet);
|
void popNetworkSegmentOfHeader(Packet& packet);
|
||||||
|
void removeWorld();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "Network/MessageType.h"
|
#include "Network/MessageType.h"
|
||||||
#include "Network/PlayerDefinition.h"
|
#include "Network/PlayerDefinition.h"
|
||||||
#include "Core/World.h"
|
#include "Core/World.h"
|
||||||
|
#include "Core/EntityFile.h"
|
||||||
#include "Core/EventBroker.h"
|
#include "Core/EventBroker.h"
|
||||||
#include "../Network/Network.h"
|
#include "../Network/Network.h"
|
||||||
#include "Input/EInputCommand.h"
|
#include "Input/EInputCommand.h"
|
||||||
@@ -24,6 +25,8 @@
|
|||||||
#include "Core/EPlayerDeath.h"
|
#include "Core/EPlayerDeath.h"
|
||||||
#include "Network/EPlayerConnected.h"
|
#include "Network/EPlayerConnected.h"
|
||||||
#include "Network/EKillDeath.h"
|
#include "Network/EKillDeath.h"
|
||||||
|
#include "Core/EWin.h"
|
||||||
|
#include "Game/Events/EReset.h"
|
||||||
|
|
||||||
class Server : public Network
|
class Server : public Network
|
||||||
{
|
{
|
||||||
@@ -31,7 +34,7 @@ public:
|
|||||||
Server(World* world, EventBroker* eventBroker, int port);
|
Server(World* world, EventBroker* eventBroker, int port);
|
||||||
~Server();
|
~Server();
|
||||||
|
|
||||||
void Update() override;
|
void Update(double dt) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Network channels
|
// Network channels
|
||||||
@@ -41,6 +44,7 @@ private:
|
|||||||
// 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;
|
||||||
|
bool m_GameIsOver = false;
|
||||||
// Sending messages to client logic
|
// Sending messages to client logic
|
||||||
std::map<PlayerID, PlayerDefinition> m_ConnectedPlayers;
|
std::map<PlayerID, PlayerDefinition> m_ConnectedPlayers;
|
||||||
std::vector<PlayerID> m_PlayersToDisconnect;
|
std::vector<PlayerID> m_PlayersToDisconnect;
|
||||||
@@ -48,14 +52,14 @@ private:
|
|||||||
char readBuffer[BUFFERSIZE] = { 0 };
|
char readBuffer[BUFFERSIZE] = { 0 };
|
||||||
size_t bytesRead = 0;
|
size_t bytesRead = 0;
|
||||||
// time for previouse message
|
// time for previouse message
|
||||||
std::clock_t previousePingMessage = std::clock();
|
double previousPingMessage = 0;
|
||||||
std::clock_t previousSnapshotMessage = std::clock();
|
double previousSnapshotMessage = 0;
|
||||||
std::clock_t timOutTimer = std::clock();
|
double timeOutTimer = 0;
|
||||||
|
|
||||||
// How often we send messages (milliseconds)
|
// How often we send messages (seconds)
|
||||||
float pingIntervalMs;
|
double pingInterval = 1;
|
||||||
float snapshotInterval;
|
double snapshotInterval = 0.05;
|
||||||
int checkTimeOutInterval = 100;
|
double checkTimeOutInterval = 0.1;
|
||||||
int m_NextPlayerID = 0;
|
int m_NextPlayerID = 0;
|
||||||
std::vector<Events::InputCommand> m_InputCommandsToBroadcast;
|
std::vector<Events::InputCommand> m_InputCommandsToBroadcast;
|
||||||
//Timers
|
//Timers
|
||||||
@@ -71,6 +75,7 @@ private:
|
|||||||
void reliableBroadcast(Packet& packet);
|
void reliableBroadcast(Packet& packet);
|
||||||
void unreliableBroadcast(Packet& packet);
|
void unreliableBroadcast(Packet& packet);
|
||||||
void sendSnapshot();
|
void sendSnapshot();
|
||||||
|
void createWorldSnapshot(Packet& packet);
|
||||||
void addPlayersToPacket(Packet& packet, EntityID entityID);
|
void addPlayersToPacket(Packet& packet, EntityID entityID);
|
||||||
void addChildrenToPacket(Packet& packet, EntityID entityID);
|
void addChildrenToPacket(Packet& packet, EntityID entityID);
|
||||||
void addInputCommandsToPacket(Packet& packet);
|
void addInputCommandsToPacket(Packet& packet);
|
||||||
@@ -83,6 +88,7 @@ private:
|
|||||||
void kick(PlayerID player);
|
void kick(PlayerID player);
|
||||||
PlayerID getPlayerIDFromEndpoint();
|
PlayerID getPlayerIDFromEndpoint();
|
||||||
PlayerID getPlayerIDFromEntityID(EntityID entityID);
|
PlayerID getPlayerIDFromEntityID(EntityID entityID);
|
||||||
|
void resetMap();
|
||||||
void parsePlayerTransform(Packet& packet);
|
void parsePlayerTransform(Packet& packet);
|
||||||
void parseOnInputCommand(Packet& packet);
|
void parseOnInputCommand(Packet& packet);
|
||||||
void parseClientPing();
|
void parseClientPing();
|
||||||
@@ -110,6 +116,8 @@ private:
|
|||||||
bool OnAmmoPickup(const Events::AmmoPickup& e);
|
bool OnAmmoPickup(const Events::AmmoPickup& e);
|
||||||
EventRelay<Server, Events::PlayerDeath> m_EPlayerDeath;
|
EventRelay<Server, Events::PlayerDeath> m_EPlayerDeath;
|
||||||
bool OnPlayerDeath(const Events::PlayerDeath& e);
|
bool OnPlayerDeath(const Events::PlayerDeath& e);
|
||||||
|
EventRelay<Server, Events::Win> m_EWin;
|
||||||
|
bool OnWin(const Events::Win& e);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
class DrawFinalPass
|
class DrawFinalPass
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass, ShadowPass* shadowPass);
|
DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass, ShadowPass* shadowPass, ConfigFile* config);
|
||||||
~DrawFinalPass();
|
~DrawFinalPass();
|
||||||
void InitializeTextures();
|
void InitializeTextures();
|
||||||
void InitializeFrameBuffers();
|
void InitializeFrameBuffers();
|
||||||
@@ -25,17 +25,77 @@ public:
|
|||||||
void Draw(RenderScene& scene, BlurHUD* blurHUDPass);
|
void Draw(RenderScene& scene, BlurHUD* blurHUDPass);
|
||||||
void ClearBuffer();
|
void ClearBuffer();
|
||||||
void OnWindowResize();
|
void OnWindowResize();
|
||||||
|
void setMSAA(unsigned int numberOfSamples);
|
||||||
|
|
||||||
//Return the texture that is used in later stages to apply the bloom effect
|
//Return the texture that is used in later stages to apply the bloom effect
|
||||||
GLuint BloomTexture() const { return m_BloomTexture; }
|
GLuint BloomTexture() {
|
||||||
|
if (m_MSAA){
|
||||||
|
m_AntiAliasedFrameBuffer->Bind();
|
||||||
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
m_AntiAliasedFrameBuffer->Unbind();
|
||||||
|
m_FinalPassFrameBuffer->Read();
|
||||||
|
glReadBuffer(GL_COLOR_ATTACHMENT1);
|
||||||
|
m_AntiAliasedFrameBuffer->Draw();
|
||||||
|
glBlitFramebuffer(
|
||||||
|
0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height,
|
||||||
|
0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height,
|
||||||
|
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||||
|
return m_AntiAliasedTexture;
|
||||||
|
}
|
||||||
|
return m_BloomTexture; }
|
||||||
//Return the texture with diffuse and lighting of the scene.
|
//Return the texture with diffuse and lighting of the scene.
|
||||||
GLuint SceneTexture() const { return m_SceneTexture; }
|
GLuint DrawFinalPass::SceneTexture() {
|
||||||
|
if (m_MSAA) {
|
||||||
|
m_AntiAliasedFrameBuffer->Bind();
|
||||||
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
m_AntiAliasedFrameBuffer->Unbind();
|
||||||
|
m_FinalPassFrameBuffer->Read();
|
||||||
|
glReadBuffer(GL_COLOR_ATTACHMENT0);
|
||||||
|
m_AntiAliasedFrameBuffer->Draw();
|
||||||
|
glBlitFramebuffer(
|
||||||
|
0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height,
|
||||||
|
0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height,
|
||||||
|
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||||
|
return m_AntiAliasedTexture;
|
||||||
|
}
|
||||||
|
return m_SceneTexture;
|
||||||
|
}
|
||||||
//Return the SceneTexture with the blurred HUD bits.
|
//Return the SceneTexture with the blurred HUD bits.
|
||||||
GLuint CombinedSceneTexture() const { return m_CombinedTexture; }
|
GLuint CombinedSceneTexture() {
|
||||||
|
if (m_MSAA) {
|
||||||
|
m_AntiAliasedFrameBuffer->Bind();
|
||||||
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
m_AntiAliasedFrameBuffer->Unbind();
|
||||||
|
m_FinalPassFrameBuffer->Read();
|
||||||
|
m_AntiAliasedFrameBuffer->Draw();
|
||||||
|
glBlitFramebuffer(
|
||||||
|
0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height,
|
||||||
|
0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height,
|
||||||
|
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||||
|
return m_AntiAliasedTexture;
|
||||||
|
}
|
||||||
|
return m_CombinedTexture; }
|
||||||
//Return the blurred scene texture.
|
//Return the blurred scene texture.
|
||||||
GLuint FullBlurredTexture() const { return m_FullBlurredTexture; }
|
GLuint FullBlurredTexture() {
|
||||||
|
if (m_MSAA) {
|
||||||
|
m_AntiAliasedFrameBuffer->Bind();
|
||||||
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
m_AntiAliasedFrameBuffer->Unbind();
|
||||||
|
m_FinalPassFrameBuffer->Read();
|
||||||
|
m_AntiAliasedFrameBuffer->Draw();
|
||||||
|
glBlitFramebuffer(
|
||||||
|
0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height,
|
||||||
|
0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height,
|
||||||
|
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||||
|
return m_AntiAliasedTexture;
|
||||||
|
}
|
||||||
|
return m_FullBlurredTexture; }
|
||||||
//Return the framebuffer used in the scene rendering stage.
|
//Return the framebuffer used in the scene rendering stage.
|
||||||
FrameBuffer* FinalPassFrameBuffer() { return &m_FinalPassFrameBuffer; }
|
FrameBuffer* FinalPassFrameBuffer() { return m_FinalPassFrameBuffer; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, RenderScene& scene);
|
void DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, RenderScene& scene);
|
||||||
@@ -56,18 +116,21 @@ private:
|
|||||||
Texture* m_GreyTexture;
|
Texture* m_GreyTexture;
|
||||||
Texture* m_ErrorTexture;
|
Texture* m_ErrorTexture;
|
||||||
|
|
||||||
FrameBuffer m_FinalPassFrameBuffer;
|
FrameBuffer* m_FinalPassFrameBuffer = nullptr;
|
||||||
FrameBuffer m_ShieldDepthFrameBuffer;
|
FrameBuffer* m_ShieldDepthFrameBuffer = nullptr;
|
||||||
|
FrameBuffer* m_AntiAliasedFrameBuffer = nullptr;
|
||||||
GLuint m_BloomTexture = 0;
|
GLuint m_BloomTexture = 0;
|
||||||
GLuint m_SceneTexture = 0;
|
GLuint m_SceneTexture = 0;
|
||||||
GLuint m_DepthBuffer = 0;
|
GLuint m_DepthBuffer = 0;
|
||||||
GLuint m_ShieldBuffer = 0;
|
GLuint m_ShieldBuffer = 0;
|
||||||
GLuint m_CubeMapTexture = 0;
|
GLuint m_CubeMapTexture = 0;
|
||||||
GLuint m_FullBlurredTexture;
|
GLuint m_FullBlurredTexture = 0;
|
||||||
GLuint m_CombinedTexture; //This can be removed for less memory usage, just set m_sceneTexture to the return from m_BlurHUDPass.CombineTextures
|
GLuint m_CombinedTexture = 0; //This can be removed for less memory usage, just set m_sceneTexture to the return from m_BlurHUDPass.CombineTextures
|
||||||
|
GLuint m_AntiAliasedTexture = 0; //Is only used when MSAA is active;
|
||||||
|
|
||||||
//maqke this component based i guess?
|
//maqke this component based i guess?
|
||||||
GLuint m_ShieldPixelRate = 16;
|
GLuint m_ShieldPixelRate = 16;
|
||||||
|
unsigned int m_MSAA = 0;
|
||||||
|
|
||||||
const IRenderer* m_Renderer;
|
const IRenderer* m_Renderer;
|
||||||
const LightCullingPass* m_LightCullingPass;
|
const LightCullingPass* m_LightCullingPass;
|
||||||
|
|||||||
@@ -7,12 +7,13 @@
|
|||||||
class BufferResource
|
class BufferResource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment, GLuint mipMapLod);
|
BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment, GLuint mipMapLod, bool multiSampling);
|
||||||
|
|
||||||
GLuint* m_ResourceHandle;
|
GLuint* m_ResourceHandle;
|
||||||
GLenum m_ResourceType;
|
GLenum m_ResourceType;
|
||||||
GLenum m_Attachment;
|
GLenum m_Attachment;
|
||||||
GLuint m_MipMapLod = 0;
|
GLuint m_MipMapLod = 0;
|
||||||
|
bool m_MultiSampling = false;
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -21,24 +22,33 @@ template <GLenum RESOURCETYPE>
|
|||||||
class ResourceType : public BufferResource
|
class ResourceType : public BufferResource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ResourceType(GLuint* resourceHandle, GLenum attachment, GLuint mipMapLod)
|
ResourceType(GLuint* resourceHandle, GLenum attachment, GLuint mipMapLod, bool multiSampling)
|
||||||
: BufferResource(resourceHandle, RESOURCETYPE, attachment, mipMapLod) { }
|
: BufferResource(resourceHandle, RESOURCETYPE, attachment, mipMapLod, multiSampling) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class Texture2D : public ResourceType<GL_TEXTURE_2D>
|
class Texture2D : public ResourceType<GL_TEXTURE_2D>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Texture2D(GLuint* resourceHandle, GLenum attachment, GLuint mipMapLod = 0)
|
Texture2D(GLuint* resourceHandle, GLenum attachment, GLuint mipMapLod = 0)
|
||||||
: ResourceType(resourceHandle, attachment, mipMapLod) { };
|
: ResourceType(resourceHandle, attachment, mipMapLod, false) { };
|
||||||
|
|
||||||
~Texture2D();
|
~Texture2D();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Texture2DMultiSample : public ResourceType<GL_TEXTURE_2D_MULTISAMPLE>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Texture2DMultiSample(GLuint* resourceHandle, GLenum attachment, GLuint mipMapLod = 0)
|
||||||
|
: ResourceType(resourceHandle, attachment, mipMapLod, true) { };
|
||||||
|
|
||||||
|
~Texture2DMultiSample();
|
||||||
|
};
|
||||||
|
|
||||||
class RenderBuffer : public ResourceType<GL_RENDERBUFFER>
|
class RenderBuffer : public ResourceType<GL_RENDERBUFFER>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RenderBuffer(GLuint* resourceHandle, GLenum attachment)
|
RenderBuffer(GLuint* resourceHandle, GLenum attachment, bool multiSampling = false)
|
||||||
: ResourceType(resourceHandle, attachment, 0)
|
: ResourceType(resourceHandle, attachment, 0, multiSampling)
|
||||||
{ };
|
{ };
|
||||||
|
|
||||||
~RenderBuffer();
|
~RenderBuffer();
|
||||||
@@ -48,12 +58,13 @@ class Texture2DArray : public ResourceType<GL_TEXTURE_2D_ARRAY>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Texture2DArray(GLuint* resourceHandle, GLenum attachment)
|
Texture2DArray(GLuint* resourceHandle, GLenum attachment)
|
||||||
: ResourceType(resourceHandle, attachment, 0)
|
: ResourceType(resourceHandle, attachment, 0, false)
|
||||||
{ };
|
{ };
|
||||||
|
|
||||||
~Texture2DArray();
|
~Texture2DArray();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class FrameBuffer
|
class FrameBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -65,9 +76,13 @@ public:
|
|||||||
void Generate();
|
void Generate();
|
||||||
void Bind();
|
void Bind();
|
||||||
void Unbind();
|
void Unbind();
|
||||||
|
void Read();
|
||||||
|
void Draw();
|
||||||
GLuint GetHandle();
|
GLuint GetHandle();
|
||||||
|
bool MultiSampling() { return m_MultiSampling; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool m_MultiSampling = true;
|
||||||
GLuint m_BufferHandle;
|
GLuint m_BufferHandle;
|
||||||
std::vector<std::shared_ptr<BufferResource>> m_Resources;
|
std::vector<std::shared_ptr<BufferResource>> m_Resources;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,18 +16,15 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
~Model();
|
~Model();
|
||||||
const std::vector<RawModel::MaterialProperties>& MaterialGroups() const { return m_Materials; }
|
const std::vector<RawModel::MaterialProperties>& MaterialGroups() const { return m_RawModel->m_Materials; }
|
||||||
//const RawModel::Vertex* Vertices() const { return m_RawModel->Vertices(); }
|
const glm::mat4& Matrix() const { return m_RawModel->m_Matrix; }
|
||||||
unsigned int NumberOfVertices() const { return m_Vertices.size(); }
|
const RawModel::Vertex* Vertices() const { return m_RawModel->Vertices(); }
|
||||||
|
unsigned int NumberOfVertices() const { return m_RawModel->NumVertices(); }
|
||||||
const AABB& Box() const { return m_Box; }
|
const AABB& Box() const { return m_Box; }
|
||||||
bool IsSkinned() const { return m_IsSkinned; }
|
bool IsSkinned() const { return m_RawModel->IsSkinned(); }
|
||||||
GLuint VAO;
|
GLuint VAO;
|
||||||
GLuint ElementBuffer;
|
GLuint ElementBuffer;
|
||||||
//RawModel* m_RawModel;
|
RawModel* m_RawModel;
|
||||||
|
|
||||||
Skeleton* m_Skeleton = nullptr;
|
|
||||||
std::vector<glm::vec3> m_Vertices;
|
|
||||||
std::vector<unsigned int> m_Indices;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AABB m_Box;
|
AABB m_Box;
|
||||||
@@ -37,9 +34,6 @@ private:
|
|||||||
GLuint TangentNormalsBuffer;
|
GLuint TangentNormalsBuffer;
|
||||||
GLuint BiTangentNormalsBuffer;
|
GLuint BiTangentNormalsBuffer;
|
||||||
GLuint TextureCoordBuffer;
|
GLuint TextureCoordBuffer;
|
||||||
|
|
||||||
std::vector<RawModel::MaterialProperties> m_Materials;
|
|
||||||
bool m_IsSkinned;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ struct ModelJob : RenderJob
|
|||||||
IsShielded = isShielded;
|
IsShielded = isShielded;
|
||||||
|
|
||||||
if (model->IsSkinned()) {
|
if (model->IsSkinned()) {
|
||||||
Skeleton = Model->m_Skeleton;
|
Skeleton = Model->m_RawModel->m_Skeleton;
|
||||||
|
|
||||||
if (Skeleton != nullptr) {
|
if (Skeleton != nullptr) {
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
|
|
||||||
#include <boost/endian/buffers.hpp>
|
|
||||||
#include "../Common.h"
|
#include "../Common.h"
|
||||||
#include "../GLM.h"
|
#include "../GLM.h"
|
||||||
#include "../Core/ResourceManager.h"
|
#include "../Core/ResourceManager.h"
|
||||||
@@ -21,10 +20,14 @@
|
|||||||
#include "Skeleton.h"
|
#include "Skeleton.h"
|
||||||
#include "ShaderProgram.h"
|
#include "ShaderProgram.h"
|
||||||
|
|
||||||
|
#include "boost\endian\buffers.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class RawModelCustom : public Resource
|
class RawModelCustom : public Resource
|
||||||
{
|
{
|
||||||
friend class ResourceManager;
|
friend class ResourceManager;
|
||||||
friend class Model;
|
|
||||||
protected:
|
protected:
|
||||||
RawModelCustom(std::string fileName);
|
RawModelCustom(std::string fileName);
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ private:
|
|||||||
bool m_ResizeWindow = false;
|
bool m_ResizeWindow = false;
|
||||||
int m_SSAO_Quality = 0;
|
int m_SSAO_Quality = 0;
|
||||||
int m_GLOW_Quality = 2;
|
int m_GLOW_Quality = 2;
|
||||||
|
unsigned int m_MSAA_Level = 0;
|
||||||
|
|
||||||
PickingPass* m_PickingPass;
|
PickingPass* m_PickingPass;
|
||||||
LightCullingPass* m_LightCullingPass;
|
LightCullingPass* m_LightCullingPass;
|
||||||
|
|||||||
@@ -20,11 +20,14 @@ public:
|
|||||||
, Parent(parent)
|
, Parent(parent)
|
||||||
, Name(name)
|
, Name(name)
|
||||||
, OffsetMatrix(offsetMatrix)
|
, OffsetMatrix(offsetMatrix)
|
||||||
{ }
|
{
|
||||||
|
BindTransformMatrix = glm::inverse(offsetMatrix);
|
||||||
|
}
|
||||||
|
|
||||||
std::string Name;
|
std::string Name;
|
||||||
glm::mat4 OffsetMatrix;
|
glm::mat4 OffsetMatrix;
|
||||||
int ID;
|
int ID;
|
||||||
|
glm::mat4 BindTransformMatrix;
|
||||||
|
|
||||||
Bone* Parent;
|
Bone* Parent;
|
||||||
std::vector<Bone*> Children;
|
std::vector<Bone*> Children;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ struct SpriteJob : RenderJob
|
|||||||
IncandescenceTexture = CommonFunctions::TryLoadResource<TextureSprite, true>(cSprite["GlowMap"]);
|
IncandescenceTexture = CommonFunctions::TryLoadResource<TextureSprite, true>(cSprite["GlowMap"]);
|
||||||
|
|
||||||
Linear = (bool)cSprite["Linear"];
|
Linear = (bool)cSprite["Linear"];
|
||||||
|
ClampToBorder = (bool)cSprite["ClampToBorder"];
|
||||||
|
|
||||||
StartIndex = matProp.material->StartIndex;
|
StartIndex = matProp.material->StartIndex;
|
||||||
EndIndex = matProp.material->EndIndex;
|
EndIndex = matProp.material->EndIndex;
|
||||||
@@ -93,6 +94,7 @@ struct SpriteJob : RenderJob
|
|||||||
float ScaleX = 1;
|
float ScaleX = 1;
|
||||||
float ScaleY = 1;
|
float ScaleY = 1;
|
||||||
bool Linear = false;
|
bool Linear = false;
|
||||||
|
bool ClampToBorder = false;
|
||||||
|
|
||||||
glm::vec4 FillColor = glm::vec4(0);
|
glm::vec4 FillColor = glm::vec4(0);
|
||||||
float FillPercentage = 0.0;
|
float FillPercentage = 0.0;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ Texture* TryLoadResource(std::string path)
|
|||||||
|
|
||||||
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type);
|
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type);
|
||||||
void GenerateMultiSampleTexture(GLuint* texture, int numSamples, glm::vec2 dimensions, GLint internalFormat);
|
void GenerateMultiSampleTexture(GLuint* texture, int numSamples, glm::vec2 dimensions, GLint internalFormat);
|
||||||
void GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps);
|
void GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type, GLint numMipMaps, GLint MAGFilter, GLint MINFilter);
|
||||||
void DeleteTexture(GLuint* texture);
|
void DeleteTexture(GLuint* texture);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "../Engine/Core/EPause.h"
|
#include "../Engine/Core/EPause.h"
|
||||||
#include "../Engine/Core/EComponentAttached.h"
|
#include "../Engine/Core/EComponentAttached.h"
|
||||||
#include "../Core/EPlayerSpawned.h"
|
#include "../Core/EPlayerSpawned.h"
|
||||||
|
#include "../Rendering/ESetCamera.h"
|
||||||
|
|
||||||
|
|
||||||
typedef std::pair<ALuint, std::vector<ALuint>> QueuedBuffers;
|
typedef std::pair<ALuint, std::vector<ALuint>> QueuedBuffers;
|
||||||
@@ -91,7 +92,6 @@ private:
|
|||||||
void matchBGMLoop();
|
void matchBGMLoop();
|
||||||
Source* m_CurrentBGM = nullptr;
|
Source* m_CurrentBGM = nullptr;
|
||||||
Source* m_CurrentBGMCombo = nullptr;
|
Source* m_CurrentBGMCombo = nullptr;
|
||||||
bool m_DrumLoopHasBeenStarted = false;
|
|
||||||
|
|
||||||
// Logic
|
// Logic
|
||||||
World* m_World = nullptr;
|
World* m_World = nullptr;
|
||||||
@@ -139,6 +139,8 @@ private:
|
|||||||
bool OnPlayQueueOnEntity(const Events::PlayQueueOnEntity &e);
|
bool OnPlayQueueOnEntity(const Events::PlayQueueOnEntity &e);
|
||||||
EventRelay<SoundManager, Events::ChangeBGM> m_EChangeBGM;
|
EventRelay<SoundManager, Events::ChangeBGM> m_EChangeBGM;
|
||||||
bool OnChangeBGM(const Events::ChangeBGM &e);
|
bool OnChangeBGM(const Events::ChangeBGM &e);
|
||||||
|
EventRelay<SoundManager, Events::SetCamera> m_ESetCamera;
|
||||||
|
bool OnSetCamera(const Events::SetCamera& e);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef Events_Reset_h__
|
||||||
|
#define Events_Reset_h__
|
||||||
|
|
||||||
|
#include "Core/EventBroker.h"
|
||||||
|
#include "Core/EntityWrapper.h"
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
struct Reset : Event
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "Engine/Collision/ETrigger.h"
|
#include "Engine/Collision/ETrigger.h"
|
||||||
#include "Core/ECaptured.h"
|
#include "Core/ECaptured.h"
|
||||||
#include "Core/EWin.h"
|
#include "Core/EWin.h"
|
||||||
|
#include "Game/Events/EReset.h"
|
||||||
|
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -23,6 +24,7 @@ public:
|
|||||||
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) override;
|
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& capturePoint, double dt) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void Init();
|
||||||
//methods which will take care of specific events
|
//methods which will take care of specific events
|
||||||
EventRelay<CapturePointSystem, Events::TriggerTouch> m_ETriggerTouch;
|
EventRelay<CapturePointSystem, Events::TriggerTouch> m_ETriggerTouch;
|
||||||
bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e);
|
bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e);
|
||||||
@@ -30,6 +32,8 @@ private:
|
|||||||
bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e);
|
bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e);
|
||||||
EventRelay<CapturePointSystem, Events::Captured> m_ECaptured;
|
EventRelay<CapturePointSystem, Events::Captured> m_ECaptured;
|
||||||
bool CapturePointSystem::OnCaptured(const Events::Captured& e);
|
bool CapturePointSystem::OnCaptured(const Events::Captured& e);
|
||||||
|
EventRelay<CapturePointSystem, Events::Reset> m_EReset;
|
||||||
|
bool CapturePointSystem::OnReset(const Events::Reset& e);
|
||||||
void ChangeCapturePointModelsVisibility(EntityWrapper &capturePointModels, bool isOwner);
|
void ChangeCapturePointModelsVisibility(EntityWrapper &capturePointModels, bool isOwner);
|
||||||
|
|
||||||
bool m_WinnerWasFound = false;
|
bool m_WinnerWasFound = false;
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
#include "Core/EPlayerSpawned.h"
|
#include "Core/EPlayerSpawned.h"
|
||||||
#include "Network/EPlayerConnected.h"
|
#include "Network/EPlayerConnected.h"
|
||||||
#include "Network/EPlayerDisconnected.h"
|
#include "Network/EPlayerDisconnected.h"
|
||||||
|
#include "Game/Events/EReset.h"
|
||||||
|
#include "Engine/Input/EInputCommand.h"
|
||||||
#include "GLM.h"
|
#include "GLM.h"
|
||||||
|
|
||||||
class ScoreScreenSystem : public PureSystem
|
class ScoreScreenSystem : public PureSystem
|
||||||
@@ -25,6 +27,10 @@ public:
|
|||||||
bool OnPlayerConnected(const Events::PlayerConnected& e);
|
bool OnPlayerConnected(const Events::PlayerConnected& e);
|
||||||
EventRelay<ScoreScreenSystem, Events::PlayerDisconnected> m_EPlayerDisconnected;
|
EventRelay<ScoreScreenSystem, Events::PlayerDisconnected> m_EPlayerDisconnected;
|
||||||
bool OnPlayerDisconnected(const Events::PlayerDisconnected& e);
|
bool OnPlayerDisconnected(const Events::PlayerDisconnected& e);
|
||||||
|
EventRelay<ScoreScreenSystem, Events::Reset> m_EReset;
|
||||||
|
bool OnReset(const Events::Reset& e);
|
||||||
|
EventRelay<ScoreScreenSystem, Events::InputCommand> m_EInputCommand;
|
||||||
|
bool OnInputCommand(const Events::InputCommand& e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct PlayerData {
|
struct PlayerData {
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#include "Events/ESpawnerSpawn.h"
|
#include "Events/ESpawnerSpawn.h"
|
||||||
#include "Core/TransformSystem.h"
|
#include "Core/TransformSystem.h"
|
||||||
#include "Core/EntityFile.h"
|
#include "Core/EntityFile.h"
|
||||||
#include "Rendering/Model.h"
|
|
||||||
|
|
||||||
class SpawnerSystem : public System
|
class SpawnerSystem : public System
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "Core/System.h"
|
#include "Core/System.h"
|
||||||
#include "Input/EInputCommand.h"
|
#include "Input/EInputCommand.h"
|
||||||
#include "Network/EPlayerDisconnected.h"
|
#include "Network/EPlayerDisconnected.h"
|
||||||
|
#include "Game/Events/EReset.h"
|
||||||
|
|
||||||
class SpectatorCameraSystem : public ImpureSystem
|
class SpectatorCameraSystem : public ImpureSystem
|
||||||
{
|
{
|
||||||
@@ -15,11 +16,14 @@ public:
|
|||||||
private:
|
private:
|
||||||
int m_PickedTeam;
|
int m_PickedTeam;
|
||||||
bool m_CamSetToTeamPick;
|
bool m_CamSetToTeamPick;
|
||||||
|
void reset();
|
||||||
|
|
||||||
EventRelay<SpectatorCameraSystem, Events::InputCommand> m_EInputCommand;
|
EventRelay<SpectatorCameraSystem, Events::InputCommand> m_EInputCommand;
|
||||||
bool OnInputCommand(const Events::InputCommand& e);
|
bool OnInputCommand(const Events::InputCommand& e);
|
||||||
EventRelay<SpectatorCameraSystem, Events::PlayerDisconnected> m_EDisconnect;
|
EventRelay<SpectatorCameraSystem, Events::PlayerDisconnected> m_EDisconnect;
|
||||||
bool OnDisconnect(const Events::PlayerDisconnected& e);
|
bool OnDisconnect(const Events::PlayerDisconnected& e);
|
||||||
|
EventRelay<SpectatorCameraSystem, Events::Reset> m_EReset;
|
||||||
|
bool OnReset(const Events::Reset& e);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -86,3 +86,6 @@ NumIterations=9
|
|||||||
|
|
||||||
[GLOW3]
|
[GLOW3]
|
||||||
NumIterations=13
|
NumIterations=13
|
||||||
|
|
||||||
|
[MSAA]
|
||||||
|
Level = 0;
|
||||||
|
|||||||
@@ -2,4 +2,5 @@
|
|||||||
<CapturePointGameMode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="CapturePointGameMode.xsd">
|
<CapturePointGameMode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="CapturePointGameMode.xsd">
|
||||||
<RespawnTime>0.0</RespawnTime>
|
<RespawnTime>0.0</RespawnTime>
|
||||||
<MaxRespawnTime>8.0</MaxRespawnTime>
|
<MaxRespawnTime>8.0</MaxRespawnTime>
|
||||||
|
<ResetCountdown>10.0</ResetCountdown>
|
||||||
</CapturePointGameMode>
|
</CapturePointGameMode>
|
||||||
@@ -12,6 +12,9 @@
|
|||||||
<xs:element name="MaxRespawnTime" type="t:double" minOccurs="0">
|
<xs:element name="MaxRespawnTime" type="t:double" minOccurs="0">
|
||||||
<xs:annotation><xs:documentation>Players will be spawned when RespawnTime reaches this.</xs:documentation></xs:annotation>
|
<xs:annotation><xs:documentation>Players will be spawned when RespawnTime reaches this.</xs:documentation></xs:annotation>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
<xs:element name="ResetCountdown" type="t:double" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>The map will be reset when time reaches 0.</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
</xs:all>
|
</xs:all>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
|||||||
@@ -10,5 +10,6 @@
|
|||||||
<KeepRatioY>false</KeepRatioY>
|
<KeepRatioY>false</KeepRatioY>
|
||||||
<KeepRatio>false</KeepRatio>
|
<KeepRatio>false</KeepRatio>
|
||||||
<Linear>true</Linear>
|
<Linear>true</Linear>
|
||||||
|
<ClampToBorder>false</ClampToBorder>
|
||||||
<BlurBackground>false</BlurBackground>
|
<BlurBackground>false</BlurBackground>
|
||||||
</Sprite>
|
</Sprite>
|
||||||
|
|||||||
@@ -39,6 +39,9 @@
|
|||||||
<xs:element name="Linear" type="t:bool" minOccurs="0">
|
<xs:element name="Linear" type="t:bool" minOccurs="0">
|
||||||
<xs:annotation><xs:documentation>If it should use Linear or Nearest sampling method.</xs:documentation></xs:annotation>
|
<xs:annotation><xs:documentation>If it should use Linear or Nearest sampling method.</xs:documentation></xs:annotation>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
<xs:element name="ClampToBorder" type="t:bool" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>If it should clamp to border or repeat the texture.</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
<xs:element name="BlurBackground" type="t:bool" minOccurs="0">
|
<xs:element name="BlurBackground" type="t:bool" minOccurs="0">
|
||||||
<xs:annotation><xs:documentation>Wether the background should be blurred begind this sprite.</xs:documentation></xs:annotation>
|
<xs:annotation><xs:documentation>Wether the background should be blurred begind this sprite.</xs:documentation></xs:annotation>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
|||||||
+12219
-10153
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,126 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Entity name="BlueCapturepointBorde" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0.271661639" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
|
||||||
|
<Children>
|
||||||
|
<Entity name="Bottom">
|
||||||
|
<Components>
|
||||||
|
<c:FloatingEffect>
|
||||||
|
<Period>6</Period>
|
||||||
|
<Time>3</Time>
|
||||||
|
<Axis X="0" Y="1" Z="0"/>
|
||||||
|
<Amplitude>0.10000000149011612</Amplitude>
|
||||||
|
</c:FloatingEffect>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-0" Y="-8.74227801e-09" Z="-0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
|
||||||
|
<Color A="0.392156869" B="10" G="0.784313738" R="0"/>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0.5" Z="0"/>
|
||||||
|
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="LowerMid">
|
||||||
|
<Components>
|
||||||
|
<c:FloatingEffect>
|
||||||
|
<Period>6</Period>
|
||||||
|
<Time>2</Time>
|
||||||
|
<Axis X="0" Y="1" Z="0"/>
|
||||||
|
<Amplitude>0.10000000149011612</Amplitude>
|
||||||
|
</c:FloatingEffect>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0.0866025388" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
|
||||||
|
<Color A="0.313725501" B="10" G="0.784313738" R="0"/>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0.899999976" Z="0"/>
|
||||||
|
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="UpperMid">
|
||||||
|
<Components>
|
||||||
|
<c:FloatingEffect>
|
||||||
|
<Period>6</Period>
|
||||||
|
<Time>1</Time>
|
||||||
|
<Axis X="0" Y="1" Z="0"/>
|
||||||
|
<Amplitude>0.10000000149011612</Amplitude>
|
||||||
|
</c:FloatingEffect>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0.0866025463" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
|
||||||
|
<Color A="0.196078435" B="10" G="0.784313738" R="0"/>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="1.29999995" Z="0"/>
|
||||||
|
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="Top">
|
||||||
|
<Components>
|
||||||
|
<c:FloatingEffect>
|
||||||
|
<Period>6</Period>
|
||||||
|
<Axis X="0" Y="1" Z="0"/>
|
||||||
|
<Amplitude>0.10000000149011612</Amplitude>
|
||||||
|
</c:FloatingEffect>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
|
||||||
|
<Color A="0.117647059" B="10" G="0.784313738" R="0"/>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="1.70000005" Z="0"/>
|
||||||
|
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
|
||||||
|
</Entity>
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Entity name="RedCapturepointBorde" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0.271661639" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
|
||||||
|
<Children>
|
||||||
|
<Entity name="Bottom">
|
||||||
|
<Components>
|
||||||
|
<c:FloatingEffect>
|
||||||
|
<Period>6</Period>
|
||||||
|
<Time>3</Time>
|
||||||
|
<Axis X="0" Y="1" Z="0"/>
|
||||||
|
<Amplitude>0.10000000149011612</Amplitude>
|
||||||
|
</c:FloatingEffect>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-0" Y="-8.74227801e-09" Z="-0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
|
||||||
|
<Color A="0.392156869" B="0" G="0.235294119" R="21.9607849"/>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0.5" Z="0"/>
|
||||||
|
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="LowerMid">
|
||||||
|
<Components>
|
||||||
|
<c:FloatingEffect>
|
||||||
|
<Period>6</Period>
|
||||||
|
<Time>2</Time>
|
||||||
|
<Axis X="0" Y="1" Z="0"/>
|
||||||
|
<Amplitude>0.10000000149011612</Amplitude>
|
||||||
|
</c:FloatingEffect>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0.0866025388" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
|
||||||
|
<Color A="0.313725501" B="0" G="0.235294119" R="21.9607849"/>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0.899999976" Z="0"/>
|
||||||
|
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="UpperMid">
|
||||||
|
<Components>
|
||||||
|
<c:FloatingEffect>
|
||||||
|
<Period>6</Period>
|
||||||
|
<Time>1</Time>
|
||||||
|
<Axis X="0" Y="1" Z="0"/>
|
||||||
|
<Amplitude>0.10000000149011612</Amplitude>
|
||||||
|
</c:FloatingEffect>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0.0866025463" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
|
||||||
|
<Color A="0.196078435" B="0" G="0.235294119" R="21.9607849"/>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="1.29999995" Z="0"/>
|
||||||
|
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="Top">
|
||||||
|
<Components>
|
||||||
|
<c:FloatingEffect>
|
||||||
|
<Period>6</Period>
|
||||||
|
<Axis X="0" Y="1" Z="0"/>
|
||||||
|
<Amplitude>0.10000000149011612</Amplitude>
|
||||||
|
</c:FloatingEffect>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
|
||||||
|
<Color A="0.117647059" B="0" G="0.235294119" R="21.9607849"/>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="1.70000005" Z="0"/>
|
||||||
|
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
|
||||||
|
</Entity>
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Entity name="SpectatorCapturepointBorde" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||||
|
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0.271661639" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
|
||||||
|
<Children>
|
||||||
|
<Entity name="Bottom">
|
||||||
|
<Components>
|
||||||
|
<c:FloatingEffect>
|
||||||
|
<Period>6</Period>
|
||||||
|
<Time>3</Time>
|
||||||
|
<Axis X="0" Y="1" Z="0"/>
|
||||||
|
<Amplitude>0.10000000149011612</Amplitude>
|
||||||
|
</c:FloatingEffect>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-0" Y="-8.74227801e-09" Z="-0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
|
||||||
|
<Color A="0.392156869" B="8.03921604" G="8.03921604" R="8.03921604"/>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0.5" Z="0"/>
|
||||||
|
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="LowerMid">
|
||||||
|
<Components>
|
||||||
|
<c:FloatingEffect>
|
||||||
|
<Period>6</Period>
|
||||||
|
<Time>2</Time>
|
||||||
|
<Axis X="0" Y="1" Z="0"/>
|
||||||
|
<Amplitude>0.10000000149011612</Amplitude>
|
||||||
|
</c:FloatingEffect>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0.0866025388" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
|
||||||
|
<Color A="0.313725501" B="10" G="8.03921604" R="8.03921604"/>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0.899999976" Z="0"/>
|
||||||
|
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="UpperMid">
|
||||||
|
<Components>
|
||||||
|
<c:FloatingEffect>
|
||||||
|
<Period>6</Period>
|
||||||
|
<Time>1</Time>
|
||||||
|
<Axis X="0" Y="1" Z="0"/>
|
||||||
|
<Amplitude>0.10000000149011612</Amplitude>
|
||||||
|
</c:FloatingEffect>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0.0866025463" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
|
||||||
|
<Color A="0.196078435" B="8.03921604" G="8.03921604" R="8.03921604"/>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="1.29999995" Z="0"/>
|
||||||
|
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
<Entity name="Top">
|
||||||
|
<Components>
|
||||||
|
<c:FloatingEffect>
|
||||||
|
<Period>6</Period>
|
||||||
|
<Axis X="0" Y="1" Z="0"/>
|
||||||
|
<Amplitude>0.10000000149011612</Amplitude>
|
||||||
|
</c:FloatingEffect>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Props/CapturePoint/DoubleSidedCylinder.mesh</Resource>
|
||||||
|
<Color A="0.117647059" B="8.03921604" G="8.03921604" R="8.03921604"/>
|
||||||
|
<Transparent>true</Transparent>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="1.70000005" Z="0"/>
|
||||||
|
<Scale X="8.19999981" Y="0.0199999996" Z="8.19999981"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
|
||||||
|
</Entity>
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,14 +1,11 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
uniform mat4 M;
|
|
||||||
uniform mat4 V;
|
|
||||||
uniform mat4 P;
|
|
||||||
uniform vec4 Color;
|
uniform vec4 Color;
|
||||||
|
|
||||||
uniform sampler2D texture0;
|
uniform sampler2D texture0;
|
||||||
|
|
||||||
in VertexData{
|
in VertexData{
|
||||||
vec3 Position;
|
vec3 Position;
|
||||||
|
vec4 ViewSpacePosition;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
vec2 TextureCoordinate;
|
vec2 TextureCoordinate;
|
||||||
vec4 DiffuseColor;
|
vec4 DiffuseColor;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#define MAX_SPLITS 4
|
#define MAX_SPLITS 4
|
||||||
|
|
||||||
|
uniform mat4 PVM;
|
||||||
uniform mat4 M;
|
uniform mat4 M;
|
||||||
uniform mat4 V;
|
uniform mat4 V;
|
||||||
uniform mat4 P;
|
uniform mat4 P;
|
||||||
@@ -23,6 +24,7 @@ uniform float ColorDistanceScalar;
|
|||||||
|
|
||||||
in VertexData{
|
in VertexData{
|
||||||
vec3 Position;
|
vec3 Position;
|
||||||
|
vec4 ViewSpacePosition;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
vec3 Tangent;
|
vec3 Tangent;
|
||||||
vec3 BiTangent;
|
vec3 BiTangent;
|
||||||
@@ -34,6 +36,7 @@ in VertexData{
|
|||||||
|
|
||||||
out VertexData{
|
out VertexData{
|
||||||
vec3 Position;
|
vec3 Position;
|
||||||
|
vec4 ViewSpacePosition;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
vec3 Tangent;
|
vec3 Tangent;
|
||||||
vec3 BiTangent;
|
vec3 BiTangent;
|
||||||
@@ -101,6 +104,7 @@ void PassThingsThrough(int index)
|
|||||||
// pass through vertex data
|
// pass through vertex data
|
||||||
Output.Normal = Input[index].Normal;
|
Output.Normal = Input[index].Normal;
|
||||||
Output.Position = Input[index].Position;
|
Output.Position = Input[index].Position;
|
||||||
|
Output.ViewSpacePosition = Input[index].ViewSpacePosition;
|
||||||
Output.TextureCoordinate = Input[index].TextureCoordinate;
|
Output.TextureCoordinate = Input[index].TextureCoordinate;
|
||||||
Output.Tangent = Input[index].Tangent;
|
Output.Tangent = Input[index].Tangent;
|
||||||
Output.BiTangent = Input[index].BiTangent;
|
Output.BiTangent = Input[index].BiTangent;
|
||||||
@@ -175,7 +179,7 @@ void main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// convert to window space
|
// convert to window space
|
||||||
gl_Position = P * V * M * vec4(ExplodedPosition, 1.0);
|
gl_Position = PVM * vec4(ExplodedPosition, 1.0);
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
#define MIN_AMBIENT_LIGHT 0.3
|
#define MIN_AMBIENT_LIGHT 0.3
|
||||||
#define MAX_SPLITS 4
|
#define MAX_SPLITS 4
|
||||||
|
|
||||||
uniform mat4 VM;
|
|
||||||
uniform mat4 M;
|
uniform mat4 M;
|
||||||
uniform mat4 V;
|
uniform mat4 V;
|
||||||
uniform mat4 P;
|
uniform mat4 P;
|
||||||
@@ -65,6 +63,7 @@ layout (std430, binding = 4) buffer LightIndexBuffer
|
|||||||
|
|
||||||
in VertexData{
|
in VertexData{
|
||||||
vec3 Position;
|
vec3 Position;
|
||||||
|
vec4 ViewSpacePosition;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
vec3 Tangent;
|
vec3 Tangent;
|
||||||
vec3 BiTangent;
|
vec3 BiTangent;
|
||||||
@@ -302,11 +301,10 @@ void main()
|
|||||||
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);
|
||||||
vec4 position = VM * vec4(Input.Position, 1.0);
|
|
||||||
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(-Input.ViewSpacePosition);
|
||||||
vec3 I = normalize(vec3(M * vec4(Input.Position, 1.0)) - CameraPosition);
|
vec3 I = normalize(vec3(M * vec4(Input.Position, 1.0)) - CameraPosition);
|
||||||
vec3 R = reflect(-I, Input.Normal);
|
vec3 R = reflect(-I, Input.Normal);
|
||||||
//R = vec3(P * vec4(R, 1.0));
|
//R = vec3(P * vec4(R, 1.0));
|
||||||
@@ -333,7 +331,7 @@ void main()
|
|||||||
LightResult light_result;
|
LightResult light_result;
|
||||||
//These if statements should be removed.
|
//These if statements should be removed.
|
||||||
if(light.Type == 1) { // point
|
if(light.Type == 1) { // point
|
||||||
light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, position, normal, light.Falloff);
|
light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, Input.ViewSpacePosition, normal, light.Falloff);
|
||||||
} else if (light.Type == 2) { //Directional
|
} else if (light.Type == 2) { //Directional
|
||||||
int DepthMapIndex = getShadowIndex(FarDistance);
|
int DepthMapIndex = getShadowIndex(FarDistance);
|
||||||
light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal);
|
light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#version 430
|
#version 430
|
||||||
uniform mat4 PVM;
|
uniform mat4 PVM;
|
||||||
|
uniform mat4 VM;
|
||||||
#define MAX_SPLITS 4
|
#define MAX_SPLITS 4
|
||||||
uniform mat4 TIM;
|
uniform mat4 TIM;
|
||||||
|
|
||||||
@@ -17,6 +18,7 @@ layout(location = 4) in vec2 TextureCoords;
|
|||||||
|
|
||||||
out VertexData{
|
out VertexData{
|
||||||
vec3 Position;
|
vec3 Position;
|
||||||
|
vec4 ViewSpacePosition;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
vec3 Tangent;
|
vec3 Tangent;
|
||||||
vec3 BiTangent;
|
vec3 BiTangent;
|
||||||
@@ -31,6 +33,7 @@ void main()
|
|||||||
gl_Position = PVM * vec4(Position, 1.0);
|
gl_Position = PVM * vec4(Position, 1.0);
|
||||||
//mat4 TIM = transpose(inverse(M));
|
//mat4 TIM = transpose(inverse(M));
|
||||||
Output.Position = Position;
|
Output.Position = Position;
|
||||||
|
Output.ViewSpacePosition = VM * vec4(Position, 1.0);
|
||||||
Output.TextureCoordinate = TextureCoords;
|
Output.TextureCoordinate = TextureCoords;
|
||||||
Output.Normal = vec3(TIM * vec4(Normal, 0.0));
|
Output.Normal = vec3(TIM * vec4(Normal, 0.0));
|
||||||
Output.Tangent = vec3(TIM * vec4(Tangent, 0.0));
|
Output.Tangent = vec3(TIM * vec4(Tangent, 0.0));
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ layout (std430, binding = 4) buffer LightIndexBuffer
|
|||||||
|
|
||||||
in VertexData{
|
in VertexData{
|
||||||
vec3 Position;
|
vec3 Position;
|
||||||
|
vec4 ViewSpacePosition;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
vec3 Tangent;
|
vec3 Tangent;
|
||||||
vec3 BiTangent;
|
vec3 BiTangent;
|
||||||
@@ -141,11 +142,10 @@ void main()
|
|||||||
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);
|
||||||
vec4 position = VM * vec4(Input.Position, 1.0);
|
|
||||||
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(-Input.ViewSpacePosition);
|
||||||
vec3 I = normalize(vec3(M * vec4(Input.Position, 1.0)) - CameraPosition);
|
vec3 I = normalize(vec3(M * vec4(Input.Position, 1.0)) - CameraPosition);
|
||||||
vec3 R = reflect(-I, Input.Normal);
|
vec3 R = reflect(-I, Input.Normal);
|
||||||
//R = vec3(P * vec4(R, 1.0));
|
//R = vec3(P * vec4(R, 1.0));
|
||||||
@@ -170,7 +170,7 @@ void main()
|
|||||||
LightResult light_result;
|
LightResult light_result;
|
||||||
//These if statements should be removed.
|
//These if statements should be removed.
|
||||||
if(light.Type == 1) { // point
|
if(light.Type == 1) { // point
|
||||||
light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, position, normal, light.Falloff);
|
light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, Input.ViewSpacePosition, normal, light.Falloff);
|
||||||
} 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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#define MAX_SPLITS 4
|
#define MAX_SPLITS 4
|
||||||
|
|
||||||
uniform mat4 PVM;
|
uniform mat4 PVM;
|
||||||
|
uniform mat4 VM;
|
||||||
uniform mat4 TIM;
|
uniform mat4 TIM;
|
||||||
uniform mat4 M;
|
uniform mat4 M;
|
||||||
uniform mat4 V;
|
uniform mat4 V;
|
||||||
@@ -21,6 +22,7 @@ layout(location = 6) in vec4 BoneWeights;
|
|||||||
|
|
||||||
out VertexData{
|
out VertexData{
|
||||||
vec3 Position;
|
vec3 Position;
|
||||||
|
vec4 ViewSpacePosition;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
vec3 Tangent;
|
vec3 Tangent;
|
||||||
vec3 BiTangent;
|
vec3 BiTangent;
|
||||||
@@ -34,16 +36,15 @@ void main()
|
|||||||
{
|
{
|
||||||
mat4 boneTransform = mat4(1);
|
mat4 boneTransform = mat4(1);
|
||||||
|
|
||||||
if(BoneWeights[0] > 0.0f){
|
|
||||||
boneTransform = BoneWeights[0] * Bones[int(BoneIndices[0])]
|
boneTransform = BoneWeights[0] * Bones[int(BoneIndices[0])]
|
||||||
+ BoneWeights[1] * Bones[int(BoneIndices[1])]
|
+ BoneWeights[1] * Bones[int(BoneIndices[1])]
|
||||||
+ BoneWeights[2] * Bones[int(BoneIndices[2])]
|
+ BoneWeights[2] * Bones[int(BoneIndices[2])]
|
||||||
+ BoneWeights[3] * Bones[int(BoneIndices[3])];
|
+ BoneWeights[3] * Bones[int(BoneIndices[3])];
|
||||||
}
|
|
||||||
|
|
||||||
gl_Position = PVM*boneTransform * vec4(Position, 1.0);
|
gl_Position = PVM*boneTransform * vec4(Position, 1.0);
|
||||||
|
|
||||||
Output.Position = (boneTransform * vec4(Position, 1.0)).xyz;
|
Output.Position = (boneTransform * vec4(Position, 1.0)).xyz;
|
||||||
|
Output.ViewSpacePosition = VM * vec4(Position, 1.0);
|
||||||
Output.TextureCoordinate = TextureCoords;
|
Output.TextureCoordinate = TextureCoords;
|
||||||
Output.Normal = vec3(M * boneTransform * vec4(Normal, 0.0));
|
Output.Normal = vec3(M * boneTransform * vec4(Normal, 0.0));
|
||||||
Output.Tangent = vec3(M * vec4(Tangent, 0.0));
|
Output.Tangent = vec3(M * vec4(Tangent, 0.0));
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
#define MIN_AMBIENT_LIGHT 0.3
|
#define MIN_AMBIENT_LIGHT 0.3
|
||||||
#define MAX_SPLITS 4
|
#define MAX_SPLITS 4
|
||||||
|
|
||||||
uniform mat4 VM;
|
|
||||||
uniform mat4 M;
|
uniform mat4 M;
|
||||||
uniform mat4 V;
|
uniform mat4 V;
|
||||||
uniform mat4 P;
|
uniform mat4 P;
|
||||||
@@ -82,6 +80,7 @@ layout (std430, binding = 4) buffer LightIndexBuffer
|
|||||||
|
|
||||||
in VertexData{
|
in VertexData{
|
||||||
vec3 Position;
|
vec3 Position;
|
||||||
|
vec4 ViewSpacePosition;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
vec3 Tangent;
|
vec3 Tangent;
|
||||||
vec3 BiTangent;
|
vec3 BiTangent;
|
||||||
@@ -362,13 +361,12 @@ void main()
|
|||||||
GlowUVRepeat1, GlowUVRepeat2, GlowUVRepeat3);
|
GlowUVRepeat1, GlowUVRepeat2, GlowUVRepeat3);
|
||||||
vec4 specularTexel = CalcBlendedTexel(splatTexel, SpecularMapTexture1, SpecularMapTexture2, SpecularMapTexture3,
|
vec4 specularTexel = CalcBlendedTexel(splatTexel, SpecularMapTexture1, SpecularMapTexture2, SpecularMapTexture3,
|
||||||
SpecularUVRepeat1, SpecularUVRepeat2, SpecularUVRepeat3);
|
SpecularUVRepeat1, SpecularUVRepeat2, SpecularUVRepeat3);
|
||||||
vec4 position = VM * vec4(Input.Position, 1.0);
|
|
||||||
//vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, SplatMapTexture);
|
//vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, SplatMapTexture);
|
||||||
vec4 normal = V * CalcBlendedNormal(splatTexel, NormalMapTexture1, NormalMapTexture2, NormalMapTexture3,
|
vec4 normal = V * CalcBlendedNormal(splatTexel, NormalMapTexture1, NormalMapTexture2, NormalMapTexture3,
|
||||||
NormalUVRepeat1, NormalUVRepeat2, NormalUVRepeat3);
|
NormalUVRepeat1, NormalUVRepeat2, NormalUVRepeat3);
|
||||||
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(-Input.ViewSpacePosition);
|
||||||
|
|
||||||
vec2 tilePos;
|
vec2 tilePos;
|
||||||
tilePos.x = int(gl_FragCoord.x/TILE_SIZE);
|
tilePos.x = int(gl_FragCoord.x/TILE_SIZE);
|
||||||
@@ -391,7 +389,7 @@ void main()
|
|||||||
LightResult light_result;
|
LightResult light_result;
|
||||||
//These if statements should be removed.
|
//These if statements should be removed.
|
||||||
if(light.Type == 1) { // point
|
if(light.Type == 1) { // point
|
||||||
light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, position, normal, light.Falloff);
|
light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, Input.ViewSpacePosition, normal, light.Falloff);
|
||||||
} else if (light.Type == 2) { //Directional
|
} else if (light.Type == 2) { //Directional
|
||||||
int DepthMapIndex = getShadowIndex(FarDistance);
|
int DepthMapIndex = getShadowIndex(FarDistance);
|
||||||
light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal);
|
light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal);
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
#define MIN_AMBIENT_LIGHT 0.3
|
#define MIN_AMBIENT_LIGHT 0.3
|
||||||
#define MAX_SPLITS 4
|
#define MAX_SPLITS 4
|
||||||
|
|
||||||
uniform mat4 VM;
|
|
||||||
uniform mat4 M;
|
uniform mat4 M;
|
||||||
uniform mat4 V;
|
uniform mat4 V;
|
||||||
uniform mat4 P;
|
uniform mat4 P;
|
||||||
@@ -80,6 +78,7 @@ layout (std430, binding = 4) buffer LightIndexBuffer
|
|||||||
|
|
||||||
in VertexData{
|
in VertexData{
|
||||||
vec3 Position;
|
vec3 Position;
|
||||||
|
vec4 ViewSpacePosition;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
vec3 Tangent;
|
vec3 Tangent;
|
||||||
vec3 BiTangent;
|
vec3 BiTangent;
|
||||||
@@ -193,13 +192,12 @@ void main()
|
|||||||
GlowUVRepeat1, GlowUVRepeat2, GlowUVRepeat3);
|
GlowUVRepeat1, GlowUVRepeat2, GlowUVRepeat3);
|
||||||
vec4 specularTexel = CalcBlendedTexel(splatTexel, SpecularMapTexture1, SpecularMapTexture2, SpecularMapTexture3,
|
vec4 specularTexel = CalcBlendedTexel(splatTexel, SpecularMapTexture1, SpecularMapTexture2, SpecularMapTexture3,
|
||||||
SpecularUVRepeat1, SpecularUVRepeat2, SpecularUVRepeat3);
|
SpecularUVRepeat1, SpecularUVRepeat2, SpecularUVRepeat3);
|
||||||
vec4 position = VM * vec4(Input.Position, 1.0);
|
|
||||||
//vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, SplatMapTexture);
|
//vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, SplatMapTexture);
|
||||||
vec4 normal = V * CalcBlendedNormal(splatTexel, NormalMapTexture1, NormalMapTexture2, NormalMapTexture3,
|
vec4 normal = V * CalcBlendedNormal(splatTexel, NormalMapTexture1, NormalMapTexture2, NormalMapTexture3,
|
||||||
NormalUVRepeat1, NormalUVRepeat2, NormalUVRepeat3);
|
NormalUVRepeat1, NormalUVRepeat2, NormalUVRepeat3);
|
||||||
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(-Input.ViewSpacePosition);
|
||||||
|
|
||||||
vec2 tilePos;
|
vec2 tilePos;
|
||||||
tilePos.x = int(gl_FragCoord.x/TILE_SIZE);
|
tilePos.x = int(gl_FragCoord.x/TILE_SIZE);
|
||||||
@@ -220,7 +218,7 @@ void main()
|
|||||||
LightResult light_result;
|
LightResult light_result;
|
||||||
//These if statements should be removed.
|
//These if statements should be removed.
|
||||||
if(light.Type == 1) { // point
|
if(light.Type == 1) { // point
|
||||||
light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, position, normal, light.Falloff);
|
light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, Input.ViewSpacePosition, normal, light.Falloff);
|
||||||
} 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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,10 @@ out VertexData{
|
|||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
mat4 boneTransform = mat4(1);
|
mat4 boneTransform = mat4(1);
|
||||||
if(BoneWeights[0] > 0.0f){
|
|
||||||
boneTransform = BoneWeights[0] * Bones[int(BoneIndices[0])]
|
boneTransform = BoneWeights[0] * Bones[int(BoneIndices[0])]
|
||||||
+ BoneWeights[1] * Bones[int(BoneIndices[1])]
|
+ BoneWeights[1] * Bones[int(BoneIndices[1])]
|
||||||
+ BoneWeights[2] * Bones[int(BoneIndices[2])]
|
+ BoneWeights[2] * Bones[int(BoneIndices[2])]
|
||||||
+ BoneWeights[3] * Bones[int(BoneIndices[3])];
|
+ BoneWeights[3] * Bones[int(BoneIndices[3])];
|
||||||
}
|
|
||||||
|
|
||||||
gl_Position = PVM*boneTransform * vec4(Position, 1.0);
|
gl_Position = PVM*boneTransform * vec4(Position, 1.0);
|
||||||
Output.Position = (boneTransform * vec4(Position, 1.0)).xyz;
|
Output.Position = (boneTransform * vec4(Position, 1.0)).xyz;
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
uniform mat4 M;
|
uniform mat4 PVM;
|
||||||
uniform mat4 V;
|
|
||||||
uniform mat4 P;
|
|
||||||
|
|
||||||
layout (location = 0) in vec3 Position;
|
layout (location = 0) in vec3 Position;
|
||||||
layout (location = 4) in vec2 TextureCoords;
|
layout (location = 4) in vec2 TextureCoords;
|
||||||
@@ -13,6 +11,6 @@ out VertexData{
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = P * V * M * vec4(Position, 1.0);
|
gl_Position = PVM * vec4(Position, 1.0);
|
||||||
Output.TextureCoordinate = TextureCoords;
|
Output.TextureCoordinate = TextureCoords;
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
uniform mat4 M;
|
uniform mat4 PVM;
|
||||||
uniform mat4 V;
|
|
||||||
uniform mat4 P;
|
|
||||||
uniform mat4 Bones[100];
|
uniform mat4 Bones[100];
|
||||||
|
|
||||||
layout (location = 0) in vec3 Position;
|
layout (location = 0) in vec3 Position;
|
||||||
@@ -17,13 +15,11 @@ out VertexData{
|
|||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
mat4 boneTransform = mat4(1);
|
mat4 boneTransform = mat4(1);
|
||||||
if(BoneWeights[0] > 0.0f){
|
|
||||||
boneTransform = BoneWeights[0] * Bones[int(BoneIndices[0])]
|
boneTransform = BoneWeights[0] * Bones[int(BoneIndices[0])]
|
||||||
+ BoneWeights[1] * Bones[int(BoneIndices[1])]
|
+ BoneWeights[1] * Bones[int(BoneIndices[1])]
|
||||||
+ BoneWeights[2] * Bones[int(BoneIndices[2])]
|
+ BoneWeights[2] * Bones[int(BoneIndices[2])]
|
||||||
+ BoneWeights[3] * Bones[int(BoneIndices[3])];
|
+ BoneWeights[3] * Bones[int(BoneIndices[3])];
|
||||||
}
|
|
||||||
|
|
||||||
gl_Position = P * V * M * boneTransform * vec4(Position, 1.0);
|
gl_Position = PVM * boneTransform * vec4(Position, 1.0);
|
||||||
Output.TextureCoordinate = TextureCoords;
|
Output.TextureCoordinate = TextureCoords;
|
||||||
}
|
}
|
||||||
@@ -146,14 +146,14 @@ bool RayVsTriangle(const Ray& ray,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool RayVsModel(const Ray& ray,
|
bool RayVsModel(const Ray& ray,
|
||||||
const std::vector<glm::vec3>& modelVertices,
|
const RawModel::Vertex* modelVertices,
|
||||||
const std::vector<unsigned int>& modelIndices,
|
const std::vector<unsigned int>& modelIndices,
|
||||||
const glm::mat4& modelMatrix)
|
const glm::mat4& modelMatrix)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < modelIndices.size();) {
|
for (int i = 0; i < modelIndices.size();) {
|
||||||
glm::vec3 v0 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]], modelMatrix);
|
glm::vec3 v0 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix);
|
||||||
glm::vec3 v1 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]], modelMatrix);
|
glm::vec3 v1 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix);
|
||||||
glm::vec3 v2 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]], modelMatrix);
|
glm::vec3 v2 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix);
|
||||||
if (RayVsTriangle(ray, v0, v1, v2)) {
|
if (RayVsTriangle(ray, v0, v1, v2)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -194,7 +194,7 @@ bool RayVsTriangle(const Ray& ray,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool RayVsModel(const Ray& ray,
|
bool RayVsModel(const Ray& ray,
|
||||||
const std::vector<glm::vec3>& modelVertices,
|
const RawModel::Vertex* modelVertices,
|
||||||
const std::vector<unsigned int>& modelIndices,
|
const std::vector<unsigned int>& modelIndices,
|
||||||
const glm::mat4& modelMatrix,
|
const glm::mat4& modelMatrix,
|
||||||
float& outDistance,
|
float& outDistance,
|
||||||
@@ -204,9 +204,9 @@ bool RayVsModel(const Ray& ray,
|
|||||||
outDistance = INFINITY;
|
outDistance = INFINITY;
|
||||||
bool hit = false;
|
bool hit = false;
|
||||||
for (int i = 0; i < modelIndices.size();) {
|
for (int i = 0; i < modelIndices.size();) {
|
||||||
glm::vec3 v0 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]], modelMatrix);
|
glm::vec3 v0 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix);
|
||||||
glm::vec3 v1 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]], modelMatrix);
|
glm::vec3 v1 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix);
|
||||||
glm::vec3 v2 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]], modelMatrix);
|
glm::vec3 v2 = TransformSystem::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix);
|
||||||
float dist = outDistance;
|
float dist = outDistance;
|
||||||
float u;
|
float u;
|
||||||
float v;
|
float v;
|
||||||
@@ -221,7 +221,7 @@ bool RayVsModel(const Ray& ray,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool RayVsModel(const Ray& ray,
|
bool RayVsModel(const Ray& ray,
|
||||||
const std::vector<glm::vec3>& modelVertices,
|
const RawModel::Vertex* modelVertices,
|
||||||
const std::vector<unsigned int>& modelIndices,
|
const std::vector<unsigned int>& modelIndices,
|
||||||
const glm::mat4& modelMatrix,
|
const glm::mat4& modelMatrix,
|
||||||
glm::vec3& outHitPosition)
|
glm::vec3& outHitPosition)
|
||||||
@@ -548,7 +548,7 @@ BoxTriRes AABBvsTriangle(const AABB& box,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Output AABBvsTriangles(const AABB& box,
|
Output AABBvsTriangles(const AABB& box,
|
||||||
const std::vector<glm::vec3>& modelVertices,
|
const RawModel::Vertex* modelVertices,
|
||||||
const std::vector<unsigned int>& modelIndices,
|
const std::vector<unsigned int>& modelIndices,
|
||||||
const glm::mat4& modelMatrix,
|
const glm::mat4& modelMatrix,
|
||||||
glm::vec3& boxVelocity,
|
glm::vec3& boxVelocity,
|
||||||
@@ -565,9 +565,9 @@ Output AABBvsTriangles(const AABB& box,
|
|||||||
glm::vec3 originalBoxVelocity(boxVelocity);
|
glm::vec3 originalBoxVelocity(boxVelocity);
|
||||||
for (int i = 0; i < modelIndices.size(); ) {
|
for (int i = 0; i < modelIndices.size(); ) {
|
||||||
std::array<glm::vec3, 3> triVertices = {
|
std::array<glm::vec3, 3> triVertices = {
|
||||||
TransformSystem::TransformPoint(modelVertices[modelIndices[i++]], modelMatrix),
|
TransformSystem::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix),
|
||||||
TransformSystem::TransformPoint(modelVertices[modelIndices[i++]], modelMatrix),
|
TransformSystem::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix),
|
||||||
TransformSystem::TransformPoint(modelVertices[modelIndices[i++]], modelMatrix)
|
TransformSystem::TransformPoint(modelVertices[modelIndices[i++]].Position, modelMatrix)
|
||||||
};
|
};
|
||||||
glm::vec3 outVec;
|
glm::vec3 outVec;
|
||||||
bool collideWithGround = isOnGround;
|
bool collideWithGround = isOnGround;
|
||||||
@@ -595,7 +595,7 @@ Output AABBvsTriangles(const AABB& box,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool AABBvsTriangles(const AABB& box,
|
bool AABBvsTriangles(const AABB& box,
|
||||||
const std::vector<glm::vec3>& modelVertices,
|
const RawModel::Vertex* modelVertices,
|
||||||
const std::vector<unsigned int>& modelIndices,
|
const std::vector<unsigned int>& modelIndices,
|
||||||
const glm::mat4& modelMatrix,
|
const glm::mat4& modelMatrix,
|
||||||
glm::vec3& boxVelocity,
|
glm::vec3& boxVelocity,
|
||||||
@@ -615,7 +615,7 @@ bool AABBvsTriangles(const AABB& box,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool AABBvsTriangles(const AABB& box,
|
bool AABBvsTriangles(const AABB& box,
|
||||||
const std::vector<glm::vec3>& modelVertices,
|
const RawModel::Vertex* modelVertices,
|
||||||
const std::vector<unsigned int>& modelIndices,
|
const std::vector<unsigned int>& modelIndices,
|
||||||
const glm::mat4& modelMatrix)
|
const glm::mat4& modelMatrix)
|
||||||
{
|
{
|
||||||
@@ -633,7 +633,7 @@ bool AABBvsTriangles(const AABB& box,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Output AABBvsTrianglesWContainment(const AABB& box,
|
Output AABBvsTrianglesWContainment(const AABB& box,
|
||||||
const std::vector<glm::vec3>& modelVertices,
|
const RawModel::Vertex* modelVertices,
|
||||||
const std::vector<unsigned int>& modelIndices,
|
const std::vector<unsigned int>& modelIndices,
|
||||||
const glm::mat4& modelMatrix)
|
const glm::mat4& modelMatrix)
|
||||||
{
|
{
|
||||||
@@ -741,7 +741,7 @@ boost::optional<EntityAABB> EntityFirstHitByRay(const Ray& ray, std::vector<Enti
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
float u, v;
|
float u, v;
|
||||||
if (RayVsModel(ray, model->m_Vertices, model->m_Indices, TransformSystem::ModelMatrix(entityBox.Entity), outDistance, u, v)) {
|
if (RayVsModel(ray, model->Vertices(), model->m_RawModel->m_Indices, TransformSystem::ModelMatrix(entityBox.Entity), outDistance, u, v)) {
|
||||||
outIntersectPos = ray.Origin() + outDistance * ray.Direction();
|
outIntersectPos = ray.Origin() + outDistance * ray.Direction();
|
||||||
return entityBox;
|
return entityBox;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,15 +41,15 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
|
|||||||
// Don't collide against invisible models.
|
// Don't collide against invisible models.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Model* model;
|
RawModel* model;
|
||||||
std::string res = (std::string)boxB.Entity["Model"]["Resource"];
|
std::string res = (std::string)boxB.Entity["Model"]["Resource"];
|
||||||
try {
|
try {
|
||||||
model = ResourceManager::Load<Model, true>(res);
|
model = ResourceManager::Load<RawModel, true>(res);
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
float u, v;
|
float u, v;
|
||||||
hit = Collision::RayVsModel(ray, model->m_Vertices, model->m_Indices, TransformSystem::ModelMatrix(boxB.Entity), dist, u, v);
|
hit = Collision::RayVsModel(ray, model->Vertices(), model->m_Indices, TransformSystem::ModelMatrix(boxB.Entity), dist, u, v);
|
||||||
} else {
|
} else {
|
||||||
hit = Collision::RayVsAABB(ray, boxB, dist);
|
hit = Collision::RayVsAABB(ray, boxB, dist);
|
||||||
}
|
}
|
||||||
@@ -86,9 +86,9 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
|
|||||||
// Don't collide against invisible models.
|
// Don't collide against invisible models.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Model* model;
|
RawModel* model;
|
||||||
try {
|
try {
|
||||||
model = ResourceManager::Load<Model, true>(boxB.Entity["Model"]["Resource"]);
|
model = ResourceManager::Load<RawModel, true>(boxB.Entity["Model"]["Resource"]);
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
|
|||||||
glm::vec3 inOutVelocity = (glm::vec3)cPhysics["Velocity"];
|
glm::vec3 inOutVelocity = (glm::vec3)cPhysics["Velocity"];
|
||||||
bool isOnGround = (bool)cPhysics["IsOnGround"];
|
bool isOnGround = (bool)cPhysics["IsOnGround"];
|
||||||
float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"];
|
float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"];
|
||||||
if (Collision::AABBvsTriangles(boxA, model->m_Vertices, model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) {
|
if (Collision::AABBvsTriangles(boxA, model->Vertices(), model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) {
|
||||||
//Move the position to previous position if it is not moving in the xz-plane, else resolve with the resolution vector.
|
//Move the position to previous position if it is not moving in the xz-plane, else resolve with the resolution vector.
|
||||||
(Field<glm::vec3>)cTransform["Position"] += resolutionVector;
|
(Field<glm::vec3>)cTransform["Position"] += resolutionVector;
|
||||||
boxA = *Collision::EntityAbsoluteAABB(entity);
|
boxA = *Collision::EntityAbsoluteAABB(entity);
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ void TriggerSystem::UpdateComponent(EntityWrapper& triggerEntity, ComponentWrapp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Model* triggerModel = nullptr;
|
RawModel* triggerModel = nullptr;
|
||||||
glm::mat4 triggerModelMat;
|
glm::mat4 triggerModelMat;
|
||||||
if (triggerEntity.HasComponent("Model")) {
|
if (triggerEntity.HasComponent("Model")) {
|
||||||
try {
|
try {
|
||||||
triggerModel = ResourceManager::Load<Model, true>(triggerEntity["Model"]["Resource"]);
|
triggerModel = ResourceManager::Load<RawModel, true>(triggerEntity["Model"]["Resource"]);
|
||||||
triggerModelMat = TransformSystem::ModelMatrix(triggerEntity);
|
triggerModelMat = TransformSystem::ModelMatrix(triggerEntity);
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
}
|
}
|
||||||
@@ -38,7 +38,7 @@ void TriggerSystem::UpdateComponent(EntityWrapper& triggerEntity, ComponentWrapp
|
|||||||
? Collision::Output::OutContained
|
? Collision::Output::OutContained
|
||||||
: Collision::AABBvsTrianglesWContainment(
|
: Collision::AABBvsTrianglesWContainment(
|
||||||
colliderBox,
|
colliderBox,
|
||||||
triggerModel->m_Vertices,
|
triggerModel->Vertices(),
|
||||||
triggerModel->m_Indices,
|
triggerModel->m_Indices,
|
||||||
triggerModelMat);
|
triggerModelMat);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
#include "Core/PerformanceTimer.h"
|
#include "Core/PerformanceTimer.h"
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
|
||||||
cpu_timer PerformanceTimer::m_Timer;
|
cpu_timer PerformanceTimer::m_Timer;
|
||||||
std::map<std::string, cpu_timer> PerformanceTimer::timers;
|
std::map<std::string, cpu_timer> PerformanceTimer::timers;
|
||||||
std::string PerformanceTimer::currentTimerRunning = "";
|
std::string PerformanceTimer::currentTimerRunning = "";
|
||||||
@@ -74,3 +77,15 @@ void PerformanceTimer::CreateExcelData()
|
|||||||
}
|
}
|
||||||
someFileStream.close();
|
someFileStream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
void PerformanceTimer::StartTimer(std::string nameOfTimer) {};
|
||||||
|
void PerformanceTimer::StartTimerAndStopPrevious(std::string nameOfTimer) {};
|
||||||
|
void PerformanceTimer::StopTimer(std::string nameOfTimer) {};
|
||||||
|
void PerformanceTimer::SetFrameNumber(int frameNumber) {};
|
||||||
|
|
||||||
|
void PerformanceTimer::ResetAllTimers() {};
|
||||||
|
void PerformanceTimer::CreateExcelData() {};
|
||||||
|
|
||||||
|
#endif //DEBUG
|
||||||
|
|||||||
@@ -1,162 +0,0 @@
|
|||||||
#include "Core/TransformSystem.h"
|
|
||||||
|
|
||||||
std::unordered_map<EntityWrapper, glm::vec3> TransformSystem::PositionCache;
|
|
||||||
std::unordered_map<EntityWrapper, glm::quat> TransformSystem::OrientationCache;
|
|
||||||
std::unordered_map<EntityWrapper, glm::vec3> TransformSystem::ScaleCache;
|
|
||||||
std::unordered_map<EntityWrapper, glm::mat4> TransformSystem::MatrixCache;
|
|
||||||
|
|
||||||
int TransformSystem::RecalculatedPositions = 0;
|
|
||||||
int TransformSystem::RecalculatedOrientations = 0;
|
|
||||||
int TransformSystem::RecalculatedScales = 0;
|
|
||||||
|
|
||||||
TransformSystem::TransformSystem(SystemParams params)
|
|
||||||
: System(params)
|
|
||||||
{
|
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EEntityDeleted, &TransformSystem::OnEntityDeleted);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TransformSystem::OnEntityDeleted(const Events::EntityDeleted& e)
|
|
||||||
{
|
|
||||||
// Clean up deleted entity
|
|
||||||
PositionCache.erase(e.DeletedEntity);
|
|
||||||
OrientationCache.erase(e.DeletedEntity);
|
|
||||||
ScaleCache.erase(e.DeletedEntity);
|
|
||||||
MatrixCache.erase(e.DeletedEntity);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//glm::mat4 Transform::AbsoluteTransformation(EntityWrapper entity)
|
|
||||||
//{
|
|
||||||
// glm::mat4 t = glm::mat4(1.f);
|
|
||||||
//
|
|
||||||
// while (entity.Valid()) {
|
|
||||||
// t = glm::translate((const glm::vec3&)entity["Transform"]["Position"]) * glm::toMat4(glm::quat((const glm::vec3&)entity["Transform"]["Orientation"])) * glm::scale((const glm::vec3&)entity["Transform"]["Scale"]) * t;
|
|
||||||
// entity = entity.Parent();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return t;
|
|
||||||
//}
|
|
||||||
|
|
||||||
glm::vec3 TransformSystem::AbsolutePosition(World* world, EntityID entity)
|
|
||||||
{
|
|
||||||
return TransformSystem::AbsolutePosition(EntityWrapper(world, entity));
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec3 TransformSystem::AbsolutePosition(EntityWrapper entity)
|
|
||||||
{
|
|
||||||
if (!entity.Valid()) {
|
|
||||||
return glm::vec3();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto cacheIt = PositionCache.find(entity);
|
|
||||||
ComponentWrapper cTransform = entity["Transform"];
|
|
||||||
ComponentWrapper::SubscriptProxy cTransformPosition = cTransform["Position"];
|
|
||||||
if (cacheIt != PositionCache.end() && !cTransformPosition.Dirty(DirtySetType::Transform)) {
|
|
||||||
return cacheIt->second;
|
|
||||||
} else {
|
|
||||||
EntityWrapper parent = entity.Parent();
|
|
||||||
// Calculate position
|
|
||||||
glm::vec3 position = AbsolutePosition(parent) + TransformSystem::AbsoluteOrientation(parent) * (TransformSystem::AbsoluteScale(parent) * (const glm::vec3&)cTransformPosition);
|
|
||||||
// Cache it
|
|
||||||
PositionCache[entity] = position;
|
|
||||||
RecalculatedPositions++;
|
|
||||||
// Unset dirty flag
|
|
||||||
cTransformPosition.SetDirty(DirtySetType::Transform, false);
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec3 TransformSystem::AbsoluteOrientationEuler(EntityWrapper entity)
|
|
||||||
{
|
|
||||||
glm::vec3 orientation;
|
|
||||||
|
|
||||||
while (entity.Valid()) {
|
|
||||||
ComponentWrapper transform = entity["Transform"];
|
|
||||||
orientation += (Field<glm::vec3>)transform["Orientation"];
|
|
||||||
entity = entity.Parent();
|
|
||||||
}
|
|
||||||
|
|
||||||
return orientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::quat TransformSystem::AbsoluteOrientation(World* world, EntityID entity)
|
|
||||||
{
|
|
||||||
return TransformSystem::AbsoluteOrientation(EntityWrapper(world, entity));
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::quat TransformSystem::AbsoluteOrientation(EntityWrapper entity)
|
|
||||||
{
|
|
||||||
if (!entity.Valid()) {
|
|
||||||
return glm::quat();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto cacheIt = OrientationCache.find(entity);
|
|
||||||
ComponentWrapper cTransform = entity["Transform"];
|
|
||||||
ComponentWrapper::SubscriptProxy cTransformOrientation = cTransform["Orientation"];
|
|
||||||
if (cacheIt != OrientationCache.end() && !cTransformOrientation.Dirty(DirtySetType::Transform)) {
|
|
||||||
return cacheIt->second;
|
|
||||||
} else {
|
|
||||||
EntityWrapper parent = entity.Parent();
|
|
||||||
// Calculate orientation
|
|
||||||
glm::quat orientation = AbsoluteOrientation(parent) * glm::quat((const glm::vec3&)cTransformOrientation);
|
|
||||||
// Cache it
|
|
||||||
OrientationCache[entity] = orientation;
|
|
||||||
RecalculatedOrientations++;
|
|
||||||
// Unset dirty flag
|
|
||||||
cTransformOrientation.SetDirty(DirtySetType::Transform, false);
|
|
||||||
return orientation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec3 TransformSystem::AbsoluteScale(World* world, EntityID entity)
|
|
||||||
{
|
|
||||||
return TransformSystem::AbsoluteScale(EntityWrapper(world, entity));
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec3 TransformSystem::AbsoluteScale(EntityWrapper entity)
|
|
||||||
{
|
|
||||||
if (!entity.Valid()) {
|
|
||||||
return glm::vec3(1.f);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto cacheIt = ScaleCache.find(entity);
|
|
||||||
ComponentWrapper cTransform = entity["Transform"];
|
|
||||||
ComponentWrapper::SubscriptProxy cTransformScale = cTransform["Scale"];
|
|
||||||
if (cacheIt != ScaleCache.end() && !cTransformScale.Dirty(DirtySetType::Transform)) {
|
|
||||||
return cacheIt->second;
|
|
||||||
} else {
|
|
||||||
EntityWrapper parent = entity.Parent();
|
|
||||||
// Calculate scale
|
|
||||||
glm::vec3 scale = AbsoluteScale(parent) * (const glm::vec3&)cTransformScale;
|
|
||||||
// Cache it
|
|
||||||
ScaleCache[entity] = scale;
|
|
||||||
RecalculatedPositions++;
|
|
||||||
// Unset dirty flag
|
|
||||||
cTransformScale.SetDirty(DirtySetType::Transform, false);
|
|
||||||
return scale;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::mat4 TransformSystem::ModelMatrix(EntityID entityID, World* world)
|
|
||||||
{
|
|
||||||
return ModelMatrix(EntityWrapper(world, entityID));
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::mat4 TransformSystem::ModelMatrix(EntityWrapper entity)
|
|
||||||
{
|
|
||||||
auto cacheIt = MatrixCache.find(entity);
|
|
||||||
ComponentWrapper cTransform = entity["Transform"];
|
|
||||||
bool isDirty = cTransform["Position"].Dirty(DirtySetType::Transform) || cTransform["Orientation"].Dirty(DirtySetType::Transform) || cTransform["Scale"].Dirty(DirtySetType::Transform);
|
|
||||||
if (cacheIt != MatrixCache.end() && !isDirty) {
|
|
||||||
return cacheIt->second;
|
|
||||||
} else {
|
|
||||||
glm::mat4 matrix = glm::translate(AbsolutePosition(entity)) * glm::toMat4(AbsoluteOrientation(entity)) * glm::scale(AbsoluteScale(entity));
|
|
||||||
MatrixCache[entity] = matrix;
|
|
||||||
return matrix;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec3 TransformSystem::TransformPoint(const glm::vec3& point, const glm::mat4& matrix)
|
|
||||||
{
|
|
||||||
return glm::vec3(matrix * glm::vec4(point.x, point.y, point.z, 1));
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "Network/Client.h"
|
#include "Network/Client.h"
|
||||||
#include "Network/EPlayerDisconnected.h"
|
|
||||||
using namespace boost::asio::ip;
|
using namespace boost::asio::ip;
|
||||||
|
|
||||||
Client::Client(World* world, EventBroker* eventBroker)
|
Client::Client(World* world, EventBroker* eventBroker)
|
||||||
@@ -12,7 +12,7 @@ Client::Client(World* world, EventBroker* eventBroker)
|
|||||||
|
|
||||||
auto config = ResourceManager::Load<ConfigFile>("Config.ini");
|
auto config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||||
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_SendInputInterval = config->Get<int>("Networking.SendInputIntervalMs", 33) / 1000.0;
|
||||||
LOG_INFO("Client initialized");
|
LOG_INFO("Client initialized");
|
||||||
|
|
||||||
m_ServerlistRequest.Connect(m_PlayerName, "192.168.1.255", 32554);
|
m_ServerlistRequest.Connect(m_PlayerName, "192.168.1.255", 32554);
|
||||||
@@ -48,7 +48,7 @@ void Client::Connect(std::string address, int port)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::Update()
|
void Client::Update(double dt)
|
||||||
{
|
{
|
||||||
m_EventBroker->Process<Client>();
|
m_EventBroker->Process<Client>();
|
||||||
while (m_Unreliable.IsSocketAvailable()) {
|
while (m_Unreliable.IsSocketAvailable()) {
|
||||||
@@ -85,7 +85,9 @@ void Client::Update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_SearchingForServers) {
|
if (m_SearchingForServers) {
|
||||||
if (m_SearchingTime < (1000* (std::clock() - m_StartSearchTime) / (double)CLOCKS_PER_SEC)) {
|
m_TimeSearched += dt;
|
||||||
|
if (m_SearchingTime < m_TimeSearched) {
|
||||||
|
m_TimeSearched = 0;
|
||||||
m_SearchingForServers = false;
|
m_SearchingForServers = false;
|
||||||
//displayServerlist();
|
//displayServerlist();
|
||||||
Events::DisplayServerlist e;
|
Events::DisplayServerlist e;
|
||||||
@@ -96,16 +98,25 @@ void Client::Update()
|
|||||||
|
|
||||||
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)) {
|
m_TimeSinceSentInputs += dt;
|
||||||
|
if (m_SendInputInterval < m_TimeSinceSentInputs) {
|
||||||
sendInputCommands();
|
sendInputCommands();
|
||||||
m_TimeSinceSentInputs = std::clock();
|
m_TimeSinceSentInputs = 0;
|
||||||
}
|
}
|
||||||
// HACK: Send absolute player positions for now to avoid desync until we have reliable messages
|
// HACK: Send absolute player positions for now to avoid desync until we have reliable messages
|
||||||
sendLocalPlayerTransform();
|
sendLocalPlayerTransform();
|
||||||
|
|
||||||
hasServerTimedOut();
|
hasServerTimedOut();
|
||||||
}
|
}
|
||||||
//Network::Update();
|
|
||||||
|
if (ImGui::BeginPopupModal("Disconnected", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
|
||||||
|
ImGui::Text("You have been disconnected from server.\n\n");
|
||||||
|
ImGui::SetCursorPosX(ImGui::GetContentRegionAvailWidth() - 120);
|
||||||
|
if (ImGui::Button("OK", ImVec2(120, 0))) {
|
||||||
|
ImGui::CloseCurrentPopup();
|
||||||
|
}
|
||||||
|
ImGui::EndPopup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::parseMessageType(Packet& packet)
|
void Client::parseMessageType(Packet& packet)
|
||||||
@@ -159,6 +170,9 @@ void Client::parseMessageType(Packet& packet)
|
|||||||
case MessageType::AmmoPickup:
|
case MessageType::AmmoPickup:
|
||||||
parseAmmoPickup(packet);
|
parseAmmoPickup(packet);
|
||||||
break;
|
break;
|
||||||
|
case MessageType::RemoveWorld:
|
||||||
|
parseRemoveWorld(packet);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -336,6 +350,13 @@ void Client::parseAmmoPickup(Packet & packet)
|
|||||||
m_EventBroker->Publish(e);
|
m_EventBroker->Publish(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Client::parseRemoveWorld(Packet & packet)
|
||||||
|
{
|
||||||
|
removeWorld();
|
||||||
|
Events::Reset e;
|
||||||
|
m_EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
|
||||||
void Client::updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID)
|
void Client::updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID)
|
||||||
{
|
{
|
||||||
for (auto field : componentInfo.FieldsInOrder) {
|
for (auto field : componentInfo.FieldsInOrder) {
|
||||||
@@ -583,7 +604,7 @@ bool Client::OnConnectRequest(const Events::ConnectRequest& e)
|
|||||||
bool Client::OnSearchForServers(const Events::SearchForServers& e)
|
bool Client::OnSearchForServers(const Events::SearchForServers& e)
|
||||||
{
|
{
|
||||||
m_SearchingForServers = true;
|
m_SearchingForServers = true;
|
||||||
m_StartSearchTime = std::clock();
|
m_TimeSearched = 0;
|
||||||
m_Serverlist.clear();
|
m_Serverlist.clear();
|
||||||
Packet packet(MessageType::ServerlistRequest);
|
Packet packet(MessageType::ServerlistRequest);
|
||||||
m_ServerlistRequest.Broadcast(packet, 13); // TODO: Config
|
m_ServerlistRequest.Broadcast(packet, 13); // TODO: Config
|
||||||
@@ -663,6 +684,7 @@ void Client::hasServerTimedOut()
|
|||||||
if (timeSincePing > m_TimeoutMs) {
|
if (timeSincePing > m_TimeoutMs) {
|
||||||
// Clear everything and go to menu.
|
// Clear everything and go to menu.
|
||||||
LOG_INFO("Server has timed out, returning to menu, Beep Boop.");
|
LOG_INFO("Server has timed out, returning to menu, Beep Boop.");
|
||||||
|
ImGui::OpenPopup("Disconnected");
|
||||||
disconnect();
|
disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -706,19 +728,6 @@ void Client::displayServerlist()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::removeWorld()
|
|
||||||
{
|
|
||||||
std::vector<EntityID> childrenToBeDeleted;
|
|
||||||
auto rootEntites = m_World->GetDirectChildren(EntityID_Invalid);
|
|
||||||
for (auto it = rootEntites.first; it != rootEntites.second; it++) {
|
|
||||||
childrenToBeDeleted.push_back(it->second);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < childrenToBeDeleted.size(); ++i) {
|
|
||||||
m_World->DeleteEntity(childrenToBeDeleted[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Client::createMainMenu()
|
void Client::createMainMenu()
|
||||||
{
|
{
|
||||||
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/StartMenu.xml");
|
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/StartMenu.xml");
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ Network::Network(World* world, EventBroker* eventBroker)
|
|||||||
m_TimeoutMs = config->Get<int>("Networking.TimeoutMs", 20000);
|
m_TimeoutMs = config->Get<int>("Networking.TimeoutMs", 20000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Network::Update()
|
void Network::Update(double dt)
|
||||||
{
|
{
|
||||||
updateNetworkData();
|
updateNetworkData();
|
||||||
}
|
}
|
||||||
@@ -92,3 +92,15 @@ void Network::popNetworkSegmentOfHeader(Packet & packet)
|
|||||||
packet.ReadPrimitive<int>();
|
packet.ReadPrimitive<int>();
|
||||||
packet.ReadPrimitive<int>();
|
packet.ReadPrimitive<int>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Network::removeWorld()
|
||||||
|
{
|
||||||
|
std::vector<EntityID> childrenToBeDeleted;
|
||||||
|
auto rootEntites = m_World->GetDirectChildren(EntityID_Invalid);
|
||||||
|
for (auto it = rootEntites.first; it != rootEntites.second; it++) {
|
||||||
|
childrenToBeDeleted.push_back(it->second);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < childrenToBeDeleted.size(); ++i) {
|
||||||
|
m_World->DeleteEntity(childrenToBeDeleted[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,8 +5,8 @@ Server::Server(World* world, EventBroker* eventBroker, int port)
|
|||||||
, m_ServerlistRequest(13)
|
, 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 = config->Get<float>("Networking.SnapshotInterval", 0.05);
|
||||||
pingIntervalMs = config->Get<float>("Networking.PingIntervalMs", 1000);
|
pingInterval = config->Get<float>("Networking.PingIntervalMs", 1000) / 1000.0;
|
||||||
m_ServerName = config->Get<std::string>("Networking.Name", "Unnamed");
|
m_ServerName = config->Get<std::string>("Networking.Name", "Unnamed");
|
||||||
|
|
||||||
// Subscribe to events
|
// Subscribe to events
|
||||||
@@ -17,6 +17,7 @@ Server::Server(World* world, EventBroker* eventBroker, int port)
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &Server::OnPlayerDamage);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &Server::OnPlayerDamage);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EAmmoPickup, &Server::OnAmmoPickup);
|
EVENT_SUBSCRIBE_MEMBER(m_EAmmoPickup, &Server::OnAmmoPickup);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDeath, &Server::OnPlayerDeath);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDeath, &Server::OnPlayerDeath);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EWin, &Server::OnWin);
|
||||||
// BindWW
|
// BindWW
|
||||||
if (port == 0) {
|
if (port == 0) {
|
||||||
port = config->Get<float>("Networking.Port", 27666);
|
port = config->Get<float>("Networking.Port", 27666);
|
||||||
@@ -30,7 +31,7 @@ Server::~Server()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::Update()
|
void Server::Update(double dt)
|
||||||
{
|
{
|
||||||
m_Reliable.AcceptNewConnections(m_NextPlayerID, m_ConnectedPlayers);
|
m_Reliable.AcceptNewConnections(m_NextPlayerID, m_ConnectedPlayers);
|
||||||
|
|
||||||
@@ -86,26 +87,44 @@ void Server::Update()
|
|||||||
}
|
}
|
||||||
m_PlayersToDisconnect.clear();
|
m_PlayersToDisconnect.clear();
|
||||||
|
|
||||||
std::clock_t currentTime = std::clock();
|
|
||||||
// Send snapshot
|
// Send snapshot
|
||||||
if (snapshotInterval < (1000 * (currentTime - previousSnapshotMessage) / (double)CLOCKS_PER_SEC)) {
|
previousSnapshotMessage += dt;
|
||||||
|
if (snapshotInterval < previousSnapshotMessage) {
|
||||||
sendSnapshot();
|
sendSnapshot();
|
||||||
previousSnapshotMessage = currentTime;
|
previousSnapshotMessage = 0;
|
||||||
}
|
}
|
||||||
// Send pings each
|
// Send pings each
|
||||||
if (pingIntervalMs < (1000 * (currentTime - previousePingMessage) / (double)CLOCKS_PER_SEC)) {
|
previousPingMessage += dt;
|
||||||
|
if (pingInterval < previousPingMessage) {
|
||||||
sendPing();
|
sendPing();
|
||||||
previousePingMessage = currentTime;
|
previousPingMessage = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Time out logic
|
// Time out logic
|
||||||
if (checkTimeOutInterval < (1000 * (currentTime - timOutTimer) / (double)CLOCKS_PER_SEC)) {
|
timeOutTimer += dt;
|
||||||
|
if (checkTimeOutInterval < timeOutTimer) {
|
||||||
checkForTimeOuts();
|
checkForTimeOuts();
|
||||||
timOutTimer = currentTime;
|
timeOutTimer = 0;
|
||||||
}
|
}
|
||||||
m_EventBroker->Process<Server>();
|
m_EventBroker->Process<Server>();
|
||||||
if (isReadingData) {
|
if (isReadingData) {
|
||||||
Network::Update();
|
Network::Update(dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_GameIsOver) {
|
||||||
|
auto pool = m_World->GetComponents("CapturePointGameMode");
|
||||||
|
if (pool != nullptr && pool->size() > 0) {
|
||||||
|
// Take the first CapturePointGameMode component found.
|
||||||
|
ComponentWrapper& modeComponent = *pool->begin();
|
||||||
|
// Decrease timer.
|
||||||
|
Field<double> timer = modeComponent["ResetCountdown"];
|
||||||
|
timer -= dt;
|
||||||
|
if (timer < 0) {
|
||||||
|
resetMap();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resetMap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,10 +192,16 @@ void Server::sendSnapshot()
|
|||||||
Packet packet(MessageType::Snapshot);
|
Packet packet(MessageType::Snapshot);
|
||||||
addInputCommandsToPacket(packet);
|
addInputCommandsToPacket(packet);
|
||||||
addPlayersToPacket(packet, EntityID_Invalid);
|
addPlayersToPacket(packet, EntityID_Invalid);
|
||||||
//addChildrenToPacket(packet, EntityID_Invalid);
|
|
||||||
unreliableBroadcast(packet);
|
unreliableBroadcast(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send snapshot fields
|
||||||
|
void Server::createWorldSnapshot(Packet& packet)
|
||||||
|
{
|
||||||
|
addInputCommandsToPacket(packet);
|
||||||
|
addChildrenToPacket(packet, EntityID_Invalid);
|
||||||
|
}
|
||||||
|
|
||||||
void Server::addInputCommandsToPacket(Packet& packet)
|
void Server::addInputCommandsToPacket(Packet& packet)
|
||||||
{
|
{
|
||||||
// Number of input commands
|
// Number of input commands
|
||||||
@@ -379,8 +404,7 @@ void Server::parseTCPConnect(Packet & packet)
|
|||||||
m_Reliable.Send(connnectPacket, m_ConnectedPlayers.at(playerID));
|
m_Reliable.Send(connnectPacket, m_ConnectedPlayers.at(playerID));
|
||||||
|
|
||||||
Packet firstSnapshot(MessageType::Snapshot);
|
Packet firstSnapshot(MessageType::Snapshot);
|
||||||
addInputCommandsToPacket(firstSnapshot);
|
createWorldSnapshot(firstSnapshot);
|
||||||
addChildrenToPacket(firstSnapshot, EntityID_Invalid);
|
|
||||||
m_Reliable.Send(firstSnapshot);
|
m_Reliable.Send(firstSnapshot);
|
||||||
|
|
||||||
// Send notification that a player has connected
|
// Send notification that a player has connected
|
||||||
@@ -542,6 +566,13 @@ bool Server::OnPlayerDeath(const Events::PlayerDeath& e)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Server::OnWin(const Events::Win & e)
|
||||||
|
{
|
||||||
|
// Postpone the gameover reset
|
||||||
|
m_GameIsOver = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void Server::parseClientPing()
|
void Server::parseClientPing()
|
||||||
{
|
{
|
||||||
LOG_INFO("%i: Parsing ping", m_PacketID);
|
LOG_INFO("%i: Parsing ping", m_PacketID);
|
||||||
@@ -664,3 +695,19 @@ PlayerID Server::getPlayerIDFromEntityID(EntityID entityID)
|
|||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Server::resetMap()
|
||||||
|
{
|
||||||
|
m_GameIsOver = false;
|
||||||
|
Events::Reset reset;
|
||||||
|
m_EventBroker->Publish(reset);
|
||||||
|
Packet removeMap(MessageType::RemoveWorld);
|
||||||
|
reliableBroadcast(removeMap);
|
||||||
|
removeWorld();
|
||||||
|
// Hardcoded for now.
|
||||||
|
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/CP_Rocky2.xml");
|
||||||
|
entityFile->MergeInto(m_World);
|
||||||
|
Packet newWorld(MessageType::Snapshot);
|
||||||
|
createWorldSnapshot(newWorld);
|
||||||
|
reliableBroadcast(newWorld);
|
||||||
|
}
|
||||||
@@ -37,7 +37,7 @@ void AnimationSystem::CreateBlendTrees()
|
|||||||
continue;;
|
continue;;
|
||||||
}
|
}
|
||||||
|
|
||||||
Skeleton* skeleton = model->m_Skeleton;
|
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
|
||||||
if (skeleton == nullptr) {
|
if (skeleton == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -79,7 +79,7 @@ void AnimationSystem::UpdateAnimations(double dt)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Skeleton* skeleton = model->m_Skeleton;
|
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
|
||||||
if (skeleton == nullptr) {
|
if (skeleton == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -175,7 +175,7 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Skeleton* skeleton = model->m_Skeleton;
|
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
|
||||||
if (skeleton == nullptr) {
|
if (skeleton == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -294,7 +294,7 @@ bool AnimationSystem::OnEntityDeleted(Events::EntityDeleted& e)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Skeleton* skeleton = model->m_Skeleton;
|
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
|
||||||
if (skeleton == nullptr) {
|
if (skeleton == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -325,7 +325,7 @@ bool AnimationSystem::OnSetBlendWeight(Events::SetBlendWeight& e)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Skeleton* skeleton = model->m_Skeleton;
|
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
|
||||||
if (skeleton == nullptr) {
|
if (skeleton == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ void AutoBlendQueue::Insert(AutoBlendJob autoBlendJob)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Skeleton* skeleton = model->m_Skeleton;
|
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
|
||||||
if (skeleton == nullptr) {
|
if (skeleton == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ bool AutoBlendQueue::HasActiveBlendJob()
|
|||||||
return HasActiveBlendJob();
|
return HasActiveBlendJob();
|
||||||
}
|
}
|
||||||
|
|
||||||
Skeleton* skeleton = model->m_Skeleton;
|
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
|
||||||
if (skeleton == nullptr) {
|
if (skeleton == nullptr) {
|
||||||
m_BlendQueue.pop_front();
|
m_BlendQueue.pop_front();
|
||||||
return HasActiveBlendJob();
|
return HasActiveBlendJob();
|
||||||
@@ -173,7 +173,7 @@ std::shared_ptr<BlendTree> AutoBlendQueue::GetBlendTree()
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Skeleton* skeleton = model->m_Skeleton;
|
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
|
||||||
if (skeleton == nullptr) {
|
if (skeleton == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,13 +68,13 @@ void BlurHUD::InitializeBuffers()
|
|||||||
}
|
}
|
||||||
m_GaussianFrameBuffer_horiz.Generate();
|
m_GaussianFrameBuffer_horiz.Generate();
|
||||||
|
|
||||||
CommonFunctions::GenerateTexture(&m_DepthStencil_vert, GL_CLAMP_TO_BORDER, GL_NEAREST,
|
//CommonFunctions::GenerateTexture(&m_DepthStencil_vert, GL_CLAMP_TO_BORDER, GL_NEAREST,
|
||||||
res2, GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
|
// res2, GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
|
||||||
CommonFunctions::GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_NEAREST,
|
CommonFunctions::GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_NEAREST,
|
||||||
res2, GL_RGBA16F, GL_RGBA, GL_FLOAT);
|
res2, GL_RGBA16F, GL_RGBA, GL_FLOAT);
|
||||||
|
|
||||||
if (m_GaussianFrameBuffer_vert.GetHandle() == 0) {
|
if (m_GaussianFrameBuffer_vert.GetHandle() == 0) {
|
||||||
m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_DepthStencil_vert, GL_DEPTH_STENCIL_ATTACHMENT)));
|
m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_DepthStencil_horiz, GL_DEPTH_STENCIL_ATTACHMENT)));
|
||||||
m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0)));
|
m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0)));
|
||||||
}
|
}
|
||||||
m_GaussianFrameBuffer_vert.Generate();
|
m_GaussianFrameBuffer_vert.Generate();
|
||||||
@@ -260,22 +260,22 @@ void BlurHUD::FillStencil(RenderScene& scene)
|
|||||||
glDrawElements(GL_TRIANGLES, spriteJob->EndIndex - spriteJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(spriteJob->StartIndex*sizeof(unsigned int)));
|
glDrawElements(GL_TRIANGLES, spriteJob->EndIndex - spriteJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(spriteJob->StartIndex*sizeof(unsigned int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
state.BindFramebuffer(m_GaussianFrameBuffer_vert.GetHandle());
|
//state.BindFramebuffer(m_GaussianFrameBuffer_vert.GetHandle());
|
||||||
for (auto& job : scene.Jobs.SpriteJob) {
|
//for (auto& job : scene.Jobs.SpriteJob) {
|
||||||
auto spriteJob = std::dynamic_pointer_cast<SpriteJob>(job);
|
// auto spriteJob = std::dynamic_pointer_cast<SpriteJob>(job);
|
||||||
if (!spriteJob) {
|
// if (!spriteJob) {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
if(!spriteJob->BlurBackground) {
|
// if(!spriteJob->BlurBackground) {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
glm::mat4 MVP = VP * spriteJob->Matrix;
|
// glm::mat4 MVP = VP * spriteJob->Matrix;
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(MVP));
|
// glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(MVP));
|
||||||
|
|
||||||
glBindVertexArray(spriteJob->Model->VAO);
|
// glBindVertexArray(spriteJob->Model->VAO);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, spriteJob->Model->ElementBuffer);
|
// glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, spriteJob->Model->ElementBuffer);
|
||||||
glDrawElements(GL_TRIANGLES, spriteJob->EndIndex - spriteJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(spriteJob->StartIndex*sizeof(unsigned int)));
|
// glDrawElements(GL_TRIANGLES, spriteJob->EndIndex - spriteJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(spriteJob->StartIndex*sizeof(unsigned int)));
|
||||||
}
|
//}
|
||||||
glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ void BoneAttachmentSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Skeleton* skeleton = model->m_Skeleton;
|
Skeleton* skeleton = model->m_RawModel->m_Skeleton;
|
||||||
|
|
||||||
if(skeleton == nullptr) {
|
if(skeleton == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -76,12 +76,12 @@ void DrawBloomPass::InitializeShaderPrograms()
|
|||||||
void DrawBloomPass::InitializeBuffers()
|
void DrawBloomPass::InitializeBuffers()
|
||||||
{
|
{
|
||||||
CommonFunctions::GenerateMipMapTexture(
|
CommonFunctions::GenerateMipMapTexture(
|
||||||
&m_GaussianTexture_horiz, GL_CLAMP_TO_BORDER, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height)
|
&m_GaussianTexture_horiz, GL_CLAMP_TO_BORDER, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height),
|
||||||
, GL_RGB, GL_FLOAT, m_BloomLod);
|
GL_RGB16F, GL_RGB, GL_FLOAT, m_BloomLod, GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST);
|
||||||
CommonFunctions::GenerateMipMapTexture(
|
CommonFunctions::GenerateMipMapTexture(
|
||||||
&m_GaussianTexture_vert, GL_CLAMP_TO_BORDER, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height)
|
&m_GaussianTexture_vert, GL_CLAMP_TO_BORDER, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height),
|
||||||
, GL_RGB, GL_FLOAT, m_BloomLod);
|
GL_RGB16F, GL_RGB, GL_FLOAT, m_BloomLod, GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST);
|
||||||
CommonFunctions::GenerateTexture(&m_FinalGaussianTexture, GL_CLAMP_TO_BORDER, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
CommonFunctions::GenerateTexture(&m_FinalGaussianTexture, GL_CLAMP_TO_BORDER, GL_NEAREST, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||||
|
|
||||||
if (m_GaussianCombineBuffer.GetHandle() == 0) {
|
if (m_GaussianCombineBuffer.GetHandle() == 0) {
|
||||||
m_GaussianCombineBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_FinalGaussianTexture, GL_COLOR_ATTACHMENT0)));
|
m_GaussianCombineBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_FinalGaussianTexture, GL_COLOR_ATTACHMENT0)));
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "Rendering/DrawFinalPass.h"
|
#include "Rendering/DrawFinalPass.h"
|
||||||
DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass, ShadowPass* shadowPass)
|
DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass, ShadowPass* shadowPass, ConfigFile* config)
|
||||||
: m_Renderer(renderer)
|
: m_Renderer(renderer)
|
||||||
, m_LightCullingPass(lightCullingPass)
|
, m_LightCullingPass(lightCullingPass)
|
||||||
, m_CubeMapPass(cubeMapPass)
|
, m_CubeMapPass(cubeMapPass)
|
||||||
@@ -8,6 +8,11 @@ DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCulling
|
|||||||
{
|
{
|
||||||
//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_ShieldPixelRate = 8;
|
m_ShieldPixelRate = 8;
|
||||||
|
m_FinalPassFrameBuffer = new FrameBuffer();
|
||||||
|
m_ShieldDepthFrameBuffer = new FrameBuffer();
|
||||||
|
|
||||||
|
setMSAA(config->Get<int>("MSAA.Level", 0));
|
||||||
|
|
||||||
InitializeTextures();
|
InitializeTextures();
|
||||||
InitializeShaderPrograms();
|
InitializeShaderPrograms();
|
||||||
InitializeFrameBuffers();
|
InitializeFrameBuffers();
|
||||||
@@ -19,6 +24,9 @@ DrawFinalPass::~DrawFinalPass(){
|
|||||||
CommonFunctions::DeleteTexture(&m_DepthBuffer);
|
CommonFunctions::DeleteTexture(&m_DepthBuffer);
|
||||||
CommonFunctions::DeleteTexture(&m_ShieldBuffer);
|
CommonFunctions::DeleteTexture(&m_ShieldBuffer);
|
||||||
CommonFunctions::DeleteTexture(&m_CubeMapTexture);
|
CommonFunctions::DeleteTexture(&m_CubeMapTexture);
|
||||||
|
|
||||||
|
delete m_FinalPassFrameBuffer;
|
||||||
|
delete m_ShieldDepthFrameBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawFinalPass::InitializeTextures()
|
void DrawFinalPass::InitializeTextures()
|
||||||
@@ -32,6 +40,55 @@ void DrawFinalPass::InitializeTextures()
|
|||||||
|
|
||||||
void DrawFinalPass::InitializeFrameBuffers()
|
void DrawFinalPass::InitializeFrameBuffers()
|
||||||
{
|
{
|
||||||
|
if (m_MSAA) {
|
||||||
|
CommonFunctions::GenerateTexture(&m_AntiAliasedTexture, GL_CLAMP_TO_BORDER, GL_NEAREST,
|
||||||
|
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||||
|
|
||||||
|
if (m_AntiAliasedFrameBuffer == nullptr) {
|
||||||
|
m_AntiAliasedFrameBuffer = new FrameBuffer();
|
||||||
|
m_AntiAliasedFrameBuffer->AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_AntiAliasedTexture, GL_COLOR_ATTACHMENT0)));
|
||||||
|
}
|
||||||
|
m_AntiAliasedFrameBuffer->Generate();
|
||||||
|
|
||||||
|
if (m_SceneTexture != 0) {
|
||||||
|
glDeleteRenderbuffers(1, &m_SceneTexture);
|
||||||
|
}
|
||||||
|
glGenRenderbuffers(1, &m_SceneTexture);
|
||||||
|
GLERROR("FBO 1");
|
||||||
|
glBindRenderbuffer(GL_RENDERBUFFER, m_SceneTexture);
|
||||||
|
GLERROR("FBO 11");
|
||||||
|
glRenderbufferStorageMultisample(GL_RENDERBUFFER, m_MSAA, GL_RGB16F, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
GLERROR("FBO 111");
|
||||||
|
|
||||||
|
if (m_BloomTexture != 0) {
|
||||||
|
glDeleteRenderbuffers(1, &m_BloomTexture);
|
||||||
|
}
|
||||||
|
glGenRenderbuffers(1, &m_BloomTexture);
|
||||||
|
GLERROR("FBO 2");
|
||||||
|
glBindRenderbuffer(GL_RENDERBUFFER, m_BloomTexture);
|
||||||
|
GLERROR("FBO 22");
|
||||||
|
glRenderbufferStorageMultisample(GL_RENDERBUFFER, m_MSAA, GL_RGB16F, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
GLERROR("FBO 222");
|
||||||
|
|
||||||
|
if (m_DepthBuffer != 0) {
|
||||||
|
glDeleteRenderbuffers(1, &m_DepthBuffer);
|
||||||
|
}
|
||||||
|
glGenRenderbuffers(1, &m_DepthBuffer);
|
||||||
|
GLERROR("FBO 3");
|
||||||
|
glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer);
|
||||||
|
GLERROR("FBO 33");
|
||||||
|
glRenderbufferStorageMultisample(GL_RENDERBUFFER, m_MSAA, GL_DEPTH24_STENCIL8, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
GLERROR("FBO 333");
|
||||||
|
|
||||||
|
//CommonFunctions::GenerateMultiSampleTexture(&m_SceneTexture, m_MSAA, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F);
|
||||||
|
//CommonFunctions::GenerateMultiSampleTexture(&m_BloomTexture, m_MSAA, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F);
|
||||||
|
|
||||||
|
//CommonFunctions::GenerateMultiSampleTexture(&m_DepthBuffer, m_MSAA,
|
||||||
|
//glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH24_STENCIL8);
|
||||||
|
|
||||||
|
//CommonFunctions::GenerateMultiSampleTexture(&m_ShieldBuffer, m_MSAA,
|
||||||
|
//glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH_COMPONENT32F);
|
||||||
|
} else {
|
||||||
CommonFunctions::GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_BORDER, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
CommonFunctions::GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_BORDER, 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);
|
||||||
CommonFunctions::GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_BORDER, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
CommonFunctions::GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_BORDER, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||||
@@ -40,18 +97,31 @@ void DrawFinalPass::InitializeFrameBuffers()
|
|||||||
|
|
||||||
CommonFunctions::GenerateTexture(&m_DepthBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST,
|
CommonFunctions::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);
|
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
|
||||||
|
}
|
||||||
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_DepthBuffer, GL_DEPTH_STENCIL_ATTACHMENT)));
|
|
||||||
//m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_StencilTexture, GL_STENCIL_ATTACHMENT)));
|
|
||||||
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SceneTexture, GL_COLOR_ATTACHMENT0)));
|
|
||||||
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_BloomTexture, GL_COLOR_ATTACHMENT1)));
|
|
||||||
m_FinalPassFrameBuffer.Generate();
|
|
||||||
GLERROR("FBO generation");
|
|
||||||
|
|
||||||
CommonFunctions::GenerateTexture(&m_ShieldBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST,
|
CommonFunctions::GenerateTexture(&m_ShieldBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST,
|
||||||
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT);
|
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT);
|
||||||
m_ShieldDepthFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_ShieldBuffer, GL_DEPTH_ATTACHMENT)));
|
|
||||||
m_ShieldDepthFrameBuffer.Generate();
|
if (m_FinalPassFrameBuffer->GetHandle() == 0) {
|
||||||
|
if (m_MSAA) {
|
||||||
|
m_FinalPassFrameBuffer->AddResource(std::shared_ptr<BufferResource>(new RenderBuffer(&m_DepthBuffer, GL_DEPTH_STENCIL_ATTACHMENT)));
|
||||||
|
//m_FinalPassFrameBuffer->AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_StencilTexture, GL_STENCIL_ATTACHMENT)));
|
||||||
|
m_FinalPassFrameBuffer->AddResource(std::shared_ptr<BufferResource>(new RenderBuffer(&m_SceneTexture, GL_COLOR_ATTACHMENT0)));
|
||||||
|
m_FinalPassFrameBuffer->AddResource(std::shared_ptr<BufferResource>(new RenderBuffer(&m_BloomTexture, GL_COLOR_ATTACHMENT1)));
|
||||||
|
} else {
|
||||||
|
m_FinalPassFrameBuffer->AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_DepthBuffer, GL_DEPTH_STENCIL_ATTACHMENT)));
|
||||||
|
//m_FinalPassFrameBuffer->AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_StencilTexture, GL_STENCIL_ATTACHMENT)));
|
||||||
|
m_FinalPassFrameBuffer->AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SceneTexture, GL_COLOR_ATTACHMENT0)));
|
||||||
|
m_FinalPassFrameBuffer->AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_BloomTexture, GL_COLOR_ATTACHMENT1)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_FinalPassFrameBuffer->Generate();
|
||||||
|
GLERROR("FBO generation");
|
||||||
|
|
||||||
|
if (m_ShieldDepthFrameBuffer->GetHandle() == 0) {
|
||||||
|
m_ShieldDepthFrameBuffer->AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_ShieldBuffer, GL_DEPTH_ATTACHMENT)));
|
||||||
|
}
|
||||||
|
m_ShieldDepthFrameBuffer->Generate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawFinalPass::InitializeShaderPrograms()
|
void DrawFinalPass::InitializeShaderPrograms()
|
||||||
@@ -245,14 +315,14 @@ void DrawFinalPass::InitializeShaderPrograms()
|
|||||||
void DrawFinalPass::Draw(RenderScene& scene, BlurHUD* blurHUDPass)
|
void DrawFinalPass::Draw(RenderScene& scene, BlurHUD* blurHUDPass)
|
||||||
{
|
{
|
||||||
GLERROR("Pre");
|
GLERROR("Pre");
|
||||||
DrawFinalPassState* stateDethp = new DrawFinalPassState(m_ShieldDepthFrameBuffer.GetHandle());
|
DrawFinalPassState* stateDethp = new DrawFinalPassState(m_ShieldDepthFrameBuffer->GetHandle());
|
||||||
//Draw shields to stencil
|
//Draw shields to stencil
|
||||||
DrawToDepthStencilBuffer(scene.Jobs.ShieldObjects, scene);
|
DrawToDepthStencilBuffer(scene.Jobs.ShieldObjects, scene);
|
||||||
GLERROR("StencilPass");
|
GLERROR("StencilPass");
|
||||||
delete stateDethp;
|
delete stateDethp;
|
||||||
|
|
||||||
|
|
||||||
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->Disable(GL_DEPTH_TEST);
|
||||||
@@ -293,16 +363,21 @@ void DrawFinalPass::Draw(RenderScene& scene, BlurHUD* blurHUDPass)
|
|||||||
delete state;
|
delete state;
|
||||||
if (scene.ShouldBlur) {
|
if (scene.ShouldBlur) {
|
||||||
//This needs to be drawn only when the full scene is being renderd, and then let be, otherwise sprite and other shit will show on it.
|
//This needs to be drawn only when the full scene is being renderd, and then let be, otherwise sprite and other shit will show on it.
|
||||||
m_FullBlurredTexture = blurHUDPass->Draw(m_SceneTexture, scene);
|
GLuint sceneTexture = SceneTexture();
|
||||||
|
m_FullBlurredTexture = blurHUDPass->Draw(sceneTexture, scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawFinalPassState* stateSprite = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle());
|
DrawFinalPassState* stateSprite;
|
||||||
if(scene.ShouldBlur) {
|
if(scene.ShouldBlur) {
|
||||||
//Combine nonblur and blur texture
|
//Combine nonblur and blur texture
|
||||||
|
GLuint sceneTexture = SceneTexture();
|
||||||
|
stateSprite = new DrawFinalPassState(m_FinalPassFrameBuffer->GetHandle());
|
||||||
stateSprite->Disable(GL_DEPTH_TEST);
|
stateSprite->Disable(GL_DEPTH_TEST);
|
||||||
stateSprite->Disable(GL_STENCIL_TEST);
|
stateSprite->Disable(GL_STENCIL_TEST);
|
||||||
m_CombinedTexture = blurHUDPass->CombineTextures(m_SceneTexture, m_FullBlurredTexture);
|
m_CombinedTexture = blurHUDPass->CombineTextures(sceneTexture, m_FullBlurredTexture);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
stateSprite = new DrawFinalPassState(m_FinalPassFrameBuffer->GetHandle());
|
||||||
}
|
}
|
||||||
//Draw Transparen objects
|
//Draw Transparen objects
|
||||||
//state->BlendFunc(GL_ONE, GL_ONE);
|
//state->BlendFunc(GL_ONE, GL_ONE);
|
||||||
@@ -325,33 +400,67 @@ void DrawFinalPass::Draw(RenderScene& scene, BlurHUD* blurHUDPass)
|
|||||||
void DrawFinalPass::ClearBuffer()
|
void DrawFinalPass::ClearBuffer()
|
||||||
{
|
{
|
||||||
GLERROR("PRE");
|
GLERROR("PRE");
|
||||||
m_ShieldDepthFrameBuffer.Bind();
|
m_ShieldDepthFrameBuffer->Bind();
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
m_ShieldDepthFrameBuffer.Unbind();
|
m_ShieldDepthFrameBuffer->Unbind();
|
||||||
m_FinalPassFrameBuffer.Bind();
|
m_FinalPassFrameBuffer->Bind();
|
||||||
GLERROR("Bind HighRes");
|
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");
|
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");
|
GLERROR("END");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DrawFinalPass::OnWindowResize()
|
void DrawFinalPass::OnWindowResize()
|
||||||
{
|
{
|
||||||
//InitializeFrameBuffers();
|
if (m_FinalPassFrameBuffer->MultiSampling() != (bool)m_MSAA) {
|
||||||
CommonFunctions::GenerateTexture(&m_DepthBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST,
|
delete m_FinalPassFrameBuffer;
|
||||||
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
|
delete m_ShieldDepthFrameBuffer;
|
||||||
CommonFunctions::GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_BORDER, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
m_FinalPassFrameBuffer = new FrameBuffer();
|
||||||
CommonFunctions::GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_BORDER, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
m_ShieldDepthFrameBuffer = new FrameBuffer();
|
||||||
m_FinalPassFrameBuffer.Generate();
|
}
|
||||||
|
|
||||||
|
if (m_MSAA) {
|
||||||
|
if (m_AntiAliasedFrameBuffer != nullptr) {
|
||||||
|
delete m_AntiAliasedFrameBuffer;
|
||||||
|
m_AntiAliasedFrameBuffer = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
InitializeFrameBuffers();
|
||||||
GLERROR("Error changing texture resolutions");
|
GLERROR("Error changing texture resolutions");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawFinalPass::setMSAA(unsigned int numberOfSamples) {
|
||||||
|
if (m_MSAA == numberOfSamples) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(bool)numberOfSamples) {
|
||||||
|
if (m_AntiAliasedFrameBuffer != nullptr) {
|
||||||
|
delete m_AntiAliasedFrameBuffer;
|
||||||
|
m_AntiAliasedFrameBuffer = nullptr;
|
||||||
|
}
|
||||||
|
delete m_FinalPassFrameBuffer;
|
||||||
|
m_FinalPassFrameBuffer = new FrameBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((bool)numberOfSamples && !(bool)m_MSAA) {
|
||||||
|
delete m_FinalPassFrameBuffer;
|
||||||
|
m_FinalPassFrameBuffer = new FrameBuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_MSAA = numberOfSamples;
|
||||||
|
|
||||||
|
InitializeFrameBuffers();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
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 forwardHandle = m_ForwardPlusProgram->GetHandle();
|
GLuint forwardHandle = m_ForwardPlusProgram->GetHandle();
|
||||||
@@ -530,7 +639,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
if (modelJob->BlendTree != nullptr) {
|
if (modelJob->BlendTree != nullptr) {
|
||||||
frameBones = modelJob->BlendTree->GetFinalPose();
|
frameBones = modelJob->BlendTree->GetFinalPose();
|
||||||
} else if (modelJob->Skeleton != nullptr) {
|
} else {
|
||||||
frameBones = modelJob->Skeleton->GetTPose();
|
frameBones = modelJob->Skeleton->GetTPose();
|
||||||
}
|
}
|
||||||
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
@@ -1215,11 +1324,6 @@ void DrawFinalPass::DrawToDepthStencilBuffer(std::list<std::shared_ptr<RenderJob
|
|||||||
if (lastShader != m_FillDepthStencilBufferSkinnedProgram->GetHandle()) {
|
if (lastShader != m_FillDepthStencilBufferSkinnedProgram->GetHandle()) {
|
||||||
m_FillDepthStencilBufferSkinnedProgram->Bind();
|
m_FillDepthStencilBufferSkinnedProgram->Bind();
|
||||||
lastShader = m_FillDepthStencilBufferSkinnedProgram->GetHandle();
|
lastShader = m_FillDepthStencilBufferSkinnedProgram->GetHandle();
|
||||||
glUniform1i(glGetUniformLocation(shaderSkinnedHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
|
||||||
glUniform2f(glGetUniformLocation(shaderSkinnedHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
|
||||||
glUniform4fv(glGetUniformLocation(shaderSkinnedHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
|
||||||
GLERROR("Bind Uniforms 1");
|
GLERROR("Bind Uniforms 1");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1238,11 +1342,6 @@ void DrawFinalPass::DrawToDepthStencilBuffer(std::list<std::shared_ptr<RenderJob
|
|||||||
if (lastShader != m_FillDepthStencilBufferProgram->GetHandle()) {
|
if (lastShader != m_FillDepthStencilBufferProgram->GetHandle()) {
|
||||||
m_FillDepthStencilBufferProgram->Bind();
|
m_FillDepthStencilBufferProgram->Bind();
|
||||||
lastShader = m_FillDepthStencilBufferProgram->GetHandle();
|
lastShader = m_FillDepthStencilBufferProgram->GetHandle();
|
||||||
glUniform1i(glGetUniformLocation(shaderHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
|
||||||
glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
|
||||||
glUniform4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
|
||||||
GLERROR("Bind Uniforms 2");
|
GLERROR("Bind Uniforms 2");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1298,7 +1397,14 @@ void DrawFinalPass::DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, Rend
|
|||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
|
||||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
}
|
}
|
||||||
|
if (spriteJob->ClampToBorder) {
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
glBindTexture(GL_TEXTURE_2D, m_ErrorTexture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, m_ErrorTexture->m_Texture);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,13 @@
|
|||||||
#include "Rendering/FrameBuffer.h"
|
#include "Rendering/FrameBuffer.h"
|
||||||
|
|
||||||
|
|
||||||
BufferResource::BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment, GLuint mipMapLod)
|
BufferResource::BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment, GLuint mipMapLod, bool multiSampling)
|
||||||
{
|
{
|
||||||
m_ResourceHandle = resourceHandle;
|
m_ResourceHandle = resourceHandle;
|
||||||
m_ResourceType = resourceType;
|
m_ResourceType = resourceType;
|
||||||
m_Attachment = attachment;
|
m_Attachment = attachment;
|
||||||
m_MipMapLod = mipMapLod;
|
m_MipMapLod = mipMapLod;
|
||||||
|
m_MultiSampling = multiSampling;
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture2D::~Texture2D()
|
Texture2D::~Texture2D()
|
||||||
@@ -15,14 +16,23 @@ Texture2D::~Texture2D()
|
|||||||
if (m_ResourceHandle != 0) {
|
if (m_ResourceHandle != 0) {
|
||||||
glDeleteTextures(1, m_ResourceHandle);
|
glDeleteTextures(1, m_ResourceHandle);
|
||||||
}
|
}
|
||||||
|
*m_ResourceHandle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Texture2DMultiSample::~Texture2DMultiSample()
|
||||||
|
{
|
||||||
|
if (m_ResourceHandle != 0) {
|
||||||
|
glDeleteTextures(1, m_ResourceHandle);
|
||||||
|
}
|
||||||
|
*m_ResourceHandle = 0;
|
||||||
|
}
|
||||||
|
|
||||||
RenderBuffer::~RenderBuffer()
|
RenderBuffer::~RenderBuffer()
|
||||||
{
|
{
|
||||||
if (m_ResourceHandle != 0) {
|
if (m_ResourceHandle != 0) {
|
||||||
glDeleteRenderbuffers(1, m_ResourceHandle);
|
glDeleteRenderbuffers(1, m_ResourceHandle);
|
||||||
}
|
}
|
||||||
|
*m_ResourceHandle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture2DArray::~Texture2DArray()
|
Texture2DArray::~Texture2DArray()
|
||||||
@@ -30,6 +40,7 @@ Texture2DArray::~Texture2DArray()
|
|||||||
if (m_ResourceHandle != 0) {
|
if (m_ResourceHandle != 0) {
|
||||||
glDeleteTextures(1, m_ResourceHandle);
|
glDeleteTextures(1, m_ResourceHandle);
|
||||||
}
|
}
|
||||||
|
*m_ResourceHandle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -42,6 +53,14 @@ FrameBuffer::~FrameBuffer()
|
|||||||
|
|
||||||
void FrameBuffer::AddResource(std::shared_ptr<BufferResource> resource)
|
void FrameBuffer::AddResource(std::shared_ptr<BufferResource> resource)
|
||||||
{
|
{
|
||||||
|
//m_MultiSampling is true when initialized
|
||||||
|
if (m_MultiSampling != resource->m_MultiSampling) {
|
||||||
|
if (m_MultiSampling == false) {
|
||||||
|
GLERROR("All renderbuffers is/is not using multisampling");
|
||||||
|
} else {
|
||||||
|
m_MultiSampling = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
m_Resources.push_back(resource);
|
m_Resources.push_back(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,20 +74,23 @@ void FrameBuffer::Generate()
|
|||||||
}
|
}
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_BufferHandle);
|
glBindFramebuffer(GL_FRAMEBUFFER, m_BufferHandle);
|
||||||
GLERROR("1");
|
GLERROR("1");
|
||||||
|
|
||||||
for (auto it = m_Resources.begin(); it != m_Resources.end(); it++) {
|
for (auto it = m_Resources.begin(); it != m_Resources.end(); it++) {
|
||||||
switch ((*it)->m_ResourceType) {
|
switch ((*it)->m_ResourceType) {
|
||||||
|
case GL_TEXTURE_2D_MULTISAMPLE:
|
||||||
|
glFramebufferTexture2D(GL_FRAMEBUFFER, (*it)->m_Attachment, GL_TEXTURE_2D_MULTISAMPLE, 0, 0);
|
||||||
|
GLERROR("FrameBuffer generate: GL_TEXTURE_2D_MULTISAMPLE");
|
||||||
|
break;
|
||||||
case GL_TEXTURE_2D:
|
case GL_TEXTURE_2D:
|
||||||
glFramebufferTexture(GL_FRAMEBUFFER, (*it)->m_Attachment, *(*it)->m_ResourceHandle, (*it)->m_MipMapLod);
|
glFramebufferTexture(GL_FRAMEBUFFER, (*it)->m_Attachment, *(*it)->m_ResourceHandle, (*it)->m_MipMapLod);
|
||||||
GLERROR("FrameBuffer generate: glFramebufferTexture2D");
|
GLERROR("FrameBuffer generate: GL_TEXTURE_2D");
|
||||||
break;
|
break;
|
||||||
case GL_RENDERBUFFER:
|
case GL_RENDERBUFFER:
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle);
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle);
|
||||||
GLERROR("FrameBuffer generate: glFramebufferRenderbuffer");
|
GLERROR("FrameBuffer generate: GL_RENDERBUFFER");
|
||||||
break;
|
break;
|
||||||
case GL_TEXTURE_2D_ARRAY:
|
case GL_TEXTURE_2D_ARRAY:
|
||||||
glFramebufferTexture(GL_FRAMEBUFFER, (*it)->m_Attachment, *(*it)->m_ResourceHandle, 0);
|
glFramebufferTexture(GL_FRAMEBUFFER, (*it)->m_Attachment, *(*it)->m_ResourceHandle, 0);
|
||||||
GLERROR("FrameBuffer generate: glFramebufferTexture2DArray");
|
GLERROR("FrameBuffer generate: GL_TEXTURE_2D_ARRAY");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
GLERROR("2");
|
GLERROR("2");
|
||||||
@@ -77,8 +99,8 @@ void FrameBuffer::Generate()
|
|||||||
attachments.push_back((*it)->m_Attachment);
|
attachments.push_back((*it)->m_Attachment);
|
||||||
}
|
}
|
||||||
GLERROR("Attachment");
|
GLERROR("Attachment");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLERROR("3");
|
GLERROR("3");
|
||||||
|
|
||||||
GLenum* bufferTextures = attachments.data();
|
GLenum* bufferTextures = attachments.data();
|
||||||
@@ -89,7 +111,7 @@ void FrameBuffer::Generate()
|
|||||||
|
|
||||||
if (GLenum frameBufferStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
if (GLenum frameBufferStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
||||||
GLERROR("Framebuffer incomplete");
|
GLERROR("Framebuffer incomplete");
|
||||||
//LOG_ERROR("FrameBuffer incomplete: 0x%x\n", frameBufferStatus);
|
LOG_ERROR("FrameBuffer incomplete: 0x%x\n", glCheckFramebufferStatus(GL_FRAMEBUFFER));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
GLERROR("END");
|
GLERROR("END");
|
||||||
@@ -110,3 +132,11 @@ GLuint FrameBuffer::GetHandle()
|
|||||||
{
|
{
|
||||||
return m_BufferHandle;
|
return m_BufferHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FrameBuffer::Read() {
|
||||||
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_BufferHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrameBuffer::Draw() {
|
||||||
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_BufferHandle);
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,10 +2,8 @@
|
|||||||
|
|
||||||
Model::Model(std::string fileName)
|
Model::Model(std::string fileName)
|
||||||
{
|
{
|
||||||
//fileName = "Models/Core/ScreenQuad.mesh";
|
|
||||||
//Try loading the model asyncronously, if it throws any exceptions then let it propagate back to caller.
|
//Try loading the model asyncronously, if it throws any exceptions then let it propagate back to caller.
|
||||||
auto m_RawModel = ResourceManager::Load<RawModel, true>(fileName);
|
m_RawModel = ResourceManager::Load<RawModel, true>(fileName);
|
||||||
//throw FailedLoadingException("Test");
|
|
||||||
|
|
||||||
for (auto& materialProperty : m_RawModel->m_Materials) {
|
for (auto& materialProperty : m_RawModel->m_Materials) {
|
||||||
switch (materialProperty.type) {
|
switch (materialProperty.type) {
|
||||||
@@ -101,24 +99,14 @@ Model::Model(std::string fileName)
|
|||||||
|
|
||||||
glm::vec3 mini(INFINITY);
|
glm::vec3 mini(INFINITY);
|
||||||
glm::vec3 maxi(-INFINITY);
|
glm::vec3 maxi(-INFINITY);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < m_RawModel->NumVertices(); i++) {
|
for (unsigned int i = 0; i < m_RawModel->NumVertices(); i++) {
|
||||||
const auto& v = m_RawModel->Vertices()[i];
|
const auto& v = m_RawModel->Vertices()[i];
|
||||||
mini = glm::min(mini, v.Position);
|
mini = glm::min(mini, v.Position);
|
||||||
maxi = glm::max(maxi, v.Position);
|
maxi = glm::max(maxi, v.Position);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Box = AABB(mini, maxi);
|
m_Box = AABB(mini, maxi);
|
||||||
|
|
||||||
//m_Skeleton = m_RawModel->m_Skeleton;
|
|
||||||
delete m_RawModel->m_Skeleton;
|
|
||||||
m_Materials = m_RawModel->m_Materials;
|
|
||||||
//m_Indices = m_RawModel->m_Indices;
|
|
||||||
m_IsSkinned = m_RawModel->IsSkinned();
|
|
||||||
// Copy vertex positions for collisions later
|
|
||||||
for (auto& v : m_RawModel->m_Vertices) {
|
|
||||||
//m_Vertices.push_back(v.Position);
|
|
||||||
}
|
|
||||||
|
|
||||||
ResourceManager::Release("RawModel", fileName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Model::~Model()
|
Model::~Model()
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
if (modelJob->BlendTree != nullptr) {
|
if (modelJob->BlendTree != nullptr) {
|
||||||
frameBones = modelJob->BlendTree->GetFinalPose();
|
frameBones = modelJob->BlendTree->GetFinalPose();
|
||||||
} else if (modelJob->Skeleton != nullptr) {
|
} else {
|
||||||
frameBones = modelJob->Skeleton->GetTPose();
|
frameBones = modelJob->Skeleton->GetTPose();
|
||||||
}
|
}
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
|||||||
@@ -493,13 +493,12 @@ void RawModelCustom::ReadAnimationKeyFrame(std::size_t& offset, char* fileData,
|
|||||||
|
|
||||||
RawModelCustom::~RawModelCustom()
|
RawModelCustom::~RawModelCustom()
|
||||||
{
|
{
|
||||||
// Ownership of skeleton and materials get transferred to Model
|
if (m_Skeleton != nullptr) {
|
||||||
// if (m_Skeleton != nullptr) {
|
delete m_Skeleton;
|
||||||
// delete m_Skeleton;
|
}
|
||||||
// }
|
for (auto material : m_Materials) {
|
||||||
//for (auto material : m_Materials) {
|
delete material.material;
|
||||||
// delete material.material;
|
}
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -362,6 +362,11 @@ void RenderSystem::fillPointLights(std::list<std::shared_ptr<RenderJob>>& jobs,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EntityWrapper entity(world, pointlightC.EntityID);
|
||||||
|
if (!isEntityVisible(entity)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
std::shared_ptr<PointLightJob> pointLightJob = std::shared_ptr<PointLightJob>(new PointLightJob(transformC, pointlightC, m_World));
|
std::shared_ptr<PointLightJob> pointLightJob = std::shared_ptr<PointLightJob>(new PointLightJob(transformC, pointlightC, m_World));
|
||||||
jobs.push_back(pointLightJob);
|
jobs.push_back(pointLightJob);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,8 +168,10 @@ void Renderer::Draw(RenderFrame& frame)
|
|||||||
|
|
||||||
ImGui::SliderInt("SSAO Quality", &m_SSAO_Quality, 0, 3);
|
ImGui::SliderInt("SSAO Quality", &m_SSAO_Quality, 0, 3);
|
||||||
ImGui::SliderInt("Glow Quality", &m_GLOW_Quality, 0, 3);
|
ImGui::SliderInt("Glow Quality", &m_GLOW_Quality, 0, 3);
|
||||||
|
ImGui::SliderInt("MSAA Level", (int*)&m_MSAA_Level, 0, 16);
|
||||||
m_SSAOPass->ChangeQuality(m_SSAO_Quality);
|
m_SSAOPass->ChangeQuality(m_SSAO_Quality);
|
||||||
m_DrawBloomPass->ChangeQuality(m_GLOW_Quality);
|
m_DrawBloomPass->ChangeQuality(m_GLOW_Quality);
|
||||||
|
m_DrawFinalPass->setMSAA(m_MSAA_Level);
|
||||||
GLERROR("SSAO Settings");
|
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);
|
||||||
@@ -228,7 +230,8 @@ void Renderer::Draw(RenderFrame& frame)
|
|||||||
|
|
||||||
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(), frame.Gamma, frame.Exposure);
|
GLuint test = m_DrawFinalPass->SceneTexture();
|
||||||
|
m_DrawColorCorrectionPass->Draw(test, m_DrawBloomPass->GaussianTexture(), frame.Gamma, frame.Exposure);
|
||||||
PerformanceTimer::StopTimer("Renderer-Color Correction Pass");
|
PerformanceTimer::StopTimer("Renderer-Color Correction Pass");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,7 +310,7 @@ void Renderer::InitializeRenderPasses()
|
|||||||
m_SSAOPass = new SSAOPass(this, m_Config);
|
m_SSAOPass = new SSAOPass(this, m_Config);
|
||||||
m_ShadowPass = new ShadowPass(this);
|
m_ShadowPass = new ShadowPass(this);
|
||||||
m_BlurHUDPass = new BlurHUD(this);
|
m_BlurHUDPass = new BlurHUD(this);
|
||||||
m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass, m_SSAOPass, m_ShadowPass);
|
m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass, m_SSAOPass, m_ShadowPass, m_Config);
|
||||||
m_DrawScreenQuadPass = new DrawScreenQuadPass(this);
|
m_DrawScreenQuadPass = new DrawScreenQuadPass(this);
|
||||||
m_DrawBloomPass = new DrawBloomPass(this, m_Config);
|
m_DrawBloomPass = new DrawBloomPass(this, m_Config);
|
||||||
m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this);
|
m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this);
|
||||||
|
|||||||
@@ -226,8 +226,8 @@ void ShadowPass::Draw(RenderScene & scene)
|
|||||||
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_DepthMap, 0, i);
|
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_DepthMap, 0, i);
|
||||||
|
|
||||||
|
|
||||||
GLuint shaderHandle;
|
GLuint shaderHandle = 0;
|
||||||
|
GLuint lastModel = 0;
|
||||||
for (auto &job : scene.Jobs.DirectionalLight) {
|
for (auto &job : scene.Jobs.DirectionalLight) {
|
||||||
|
|
||||||
auto directionalLightJob = std::dynamic_pointer_cast<DirectionalLightJob>(job);
|
auto directionalLightJob = std::dynamic_pointer_cast<DirectionalLightJob>(job);
|
||||||
@@ -240,19 +240,6 @@ void ShadowPass::Draw(RenderScene & scene)
|
|||||||
//RadiusToLightspace(m_shadowFrusta[i]);
|
//RadiusToLightspace(m_shadowFrusta[i]);
|
||||||
m_LightProjection[i] = glm::ortho(m_shadowFrusta[i].LRBT[LEFT], m_shadowFrusta[i].LRBT[RIGHT], m_shadowFrusta[i].LRBT[BOTTOM], m_shadowFrusta[i].LRBT[TOP], m_NearFarPlane[NEAR], m_NearFarPlane[FAR]);
|
m_LightProjection[i] = glm::ortho(m_shadowFrusta[i].LRBT[LEFT], m_shadowFrusta[i].LRBT[RIGHT], m_shadowFrusta[i].LRBT[BOTTOM], m_shadowFrusta[i].LRBT[TOP], m_NearFarPlane[NEAR], m_NearFarPlane[FAR]);
|
||||||
|
|
||||||
|
|
||||||
m_ShadowProgram->Bind();
|
|
||||||
shaderHandle = m_ShadowProgram->GetHandle();
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection[i]));
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView[i]));
|
|
||||||
|
|
||||||
m_ShadowProgramSkinned->Bind();
|
|
||||||
shaderHandle = m_ShadowProgramSkinned->GetHandle();
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection[i]));
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView[i]));
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GLERROR("ShadowLight ERROR");
|
GLERROR("ShadowLight ERROR");
|
||||||
|
|
||||||
for (auto &objectJob : scene.Jobs.OpaqueObjects) {
|
for (auto &objectJob : scene.Jobs.OpaqueObjects) {
|
||||||
@@ -264,27 +251,33 @@ void ShadowPass::Draw(RenderScene & scene)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(modelJob->Model->IsSkinned()) {
|
if(modelJob->Model->IsSkinned()) {
|
||||||
|
if (shaderHandle != m_ShadowProgramSkinned->GetHandle()) {
|
||||||
m_ShadowProgramSkinned->Bind();
|
m_ShadowProgramSkinned->Bind();
|
||||||
shaderHandle = m_ShadowProgramSkinned->GetHandle();
|
shaderHandle = m_ShadowProgramSkinned->GetHandle();
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
if (modelJob->BlendTree != nullptr) {
|
if (modelJob->BlendTree != nullptr) {
|
||||||
frameBones = modelJob->BlendTree->GetFinalPose();
|
frameBones = modelJob->BlendTree->GetFinalPose();
|
||||||
} else if (modelJob->Skeleton != nullptr) {
|
} else {
|
||||||
frameBones = modelJob->Skeleton->GetTPose();
|
frameBones = modelJob->Skeleton->GetTPose();
|
||||||
}
|
}
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
if (shaderHandle != m_ShadowProgram->GetHandle()) {
|
||||||
m_ShadowProgram->Bind();
|
m_ShadowProgram->Bind();
|
||||||
shaderHandle = m_ShadowProgram->GetHandle();
|
shaderHandle = m_ShadowProgram->GetHandle();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(m_LightProjection[i] * m_LightView[i] * modelJob->Matrix));
|
||||||
glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), 1.f);
|
glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), 1.f);
|
||||||
|
|
||||||
|
if (lastModel != modelJob->ModelID) {
|
||||||
glBindVertexArray(modelJob->Model->VAO);
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
|
}
|
||||||
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex * sizeof(unsigned int)));
|
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex * sizeof(unsigned int)));
|
||||||
|
|
||||||
GLERROR("Shadow Draw ERROR");
|
GLERROR("Shadow Draw ERROR");
|
||||||
@@ -301,8 +294,10 @@ void ShadowPass::Draw(RenderScene & scene)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (modelJob->Model->IsSkinned()) {
|
if (modelJob->Model->IsSkinned()) {
|
||||||
|
if (shaderHandle != m_ShadowProgramSkinned->GetHandle()) {
|
||||||
m_ShadowProgramSkinned->Bind();
|
m_ShadowProgramSkinned->Bind();
|
||||||
shaderHandle = m_ShadowProgramSkinned->GetHandle();
|
shaderHandle = m_ShadowProgramSkinned->GetHandle();
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
if (modelJob->BlendTree != nullptr) {
|
if (modelJob->BlendTree != nullptr) {
|
||||||
@@ -313,11 +308,13 @@ void ShadowPass::Draw(RenderScene & scene)
|
|||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
if (shaderHandle != m_ShadowProgram->GetHandle()) {
|
||||||
m_ShadowProgram->Bind();
|
m_ShadowProgram->Bind();
|
||||||
shaderHandle = m_ShadowProgram->GetHandle();
|
shaderHandle = m_ShadowProgram->GetHandle();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(m_LightProjection[i] * m_LightView[i] * modelJob->Matrix));
|
||||||
glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), modelJob->Color.a);
|
glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), modelJob->Color.a);
|
||||||
|
|
||||||
if (m_TexturedShadows) {
|
if (m_TexturedShadows) {
|
||||||
@@ -345,9 +342,10 @@ void ShadowPass::Draw(RenderScene & scene)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (lastModel != modelJob->ModelID) {
|
||||||
glBindVertexArray(modelJob->Model->VAO);
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
|
}
|
||||||
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex * sizeof(unsigned int)));
|
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex * sizeof(unsigned int)));
|
||||||
|
|
||||||
GLERROR("Shadow Draw ERROR");
|
GLERROR("Shadow Draw ERROR");
|
||||||
|
|||||||
@@ -33,33 +33,33 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, const Animation* anim
|
|||||||
PoseData poseData;
|
PoseData poseData;
|
||||||
|
|
||||||
if (animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) {
|
if (animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) {
|
||||||
std::vector<Animation::Keyframe> boneKeyFrames = animation->JointAnimations.at(bone->ID);
|
const std::vector<Animation::Keyframe>& boneKeyFrames = animation->JointAnimations.at(bone->ID);
|
||||||
|
|
||||||
Animation::Keyframe currentFrame;
|
const Animation::Keyframe* currentFrame;
|
||||||
Animation::Keyframe nextFrame;
|
const Animation::Keyframe* nextFrame;
|
||||||
|
|
||||||
if (boneKeyFrames.size() > 1) { // 2+ keyframes for the current bone
|
if (boneKeyFrames.size() > 1) { // 2+ keyframes for the current bone
|
||||||
for (int index = boneKeyFrames.size()-1; index >= 0; index--) { // find the bone keyframes that surrounds the current frame
|
for (int index = boneKeyFrames.size()-1; index >= 0; index--) { // find the bone keyframes that surrounds the current frame
|
||||||
if (time >= boneKeyFrames.at(index).Time) {
|
if (time >= boneKeyFrames.at(index).Time) {
|
||||||
currentFrame = boneKeyFrames.at(index);
|
currentFrame = &boneKeyFrames.at(index);
|
||||||
nextFrame = boneKeyFrames.at((index + 1) % boneKeyFrames.size());
|
nextFrame = &boneKeyFrames.at((index + 1) % boneKeyFrames.size());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float progress;
|
float progress;
|
||||||
|
|
||||||
if (nextFrame.Index == 0) {
|
if (nextFrame->Index == 0) {
|
||||||
nextFrame = currentFrame;
|
nextFrame = currentFrame;
|
||||||
progress = (time - currentFrame.Time) / (animation->Duration - currentFrame.Time);
|
progress = (time - currentFrame->Time) / (animation->Duration - currentFrame->Time);
|
||||||
} else {
|
} else {
|
||||||
progress = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time);
|
progress = (time - currentFrame->Time) / (nextFrame->Time - currentFrame->Time);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
progress = glm::clamp(progress, 0.0f, 1.0f);
|
progress = glm::clamp(progress, 0.0f, 1.0f);
|
||||||
Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties;
|
const Animation::Keyframe::BoneProperty& currentBoneProperty = currentFrame->BoneProperties;
|
||||||
Animation::Keyframe::BoneProperty nextBoneProperty = nextFrame.BoneProperties;
|
const Animation::Keyframe::BoneProperty& nextBoneProperty = nextFrame->BoneProperties;
|
||||||
|
|
||||||
glm::vec3 position = currentBoneProperty.Position * (1.f - progress) + nextBoneProperty.Position * progress;
|
glm::vec3 position = currentBoneProperty.Position * (1.f - progress) + nextBoneProperty.Position * progress;
|
||||||
glm::quat rotation = glm::normalize(glm::slerp(currentBoneProperty.Rotation, nextBoneProperty.Rotation, progress));
|
glm::quat rotation = glm::normalize(glm::slerp(currentBoneProperty.Rotation, nextBoneProperty.Rotation, progress));
|
||||||
@@ -77,10 +77,10 @@ void Skeleton::AccumulateBoneTransforms(bool noRootMotion, const Animation* anim
|
|||||||
boneMatrices[bone->ID] = poseData;
|
boneMatrices[bone->ID] = poseData;
|
||||||
|
|
||||||
} else { // 1 keyframes for the current bone
|
} else { // 1 keyframes for the current bone
|
||||||
currentFrame = boneKeyFrames.at(0);
|
currentFrame = &boneKeyFrames.at(0);
|
||||||
poseData.Translation = currentFrame.BoneProperties.Position;
|
poseData.Translation = currentFrame->BoneProperties.Position;
|
||||||
poseData.Orientation = currentFrame.BoneProperties.Rotation;
|
poseData.Orientation = currentFrame->BoneProperties.Rotation;
|
||||||
poseData.Scale = currentFrame.BoneProperties.Scale;
|
poseData.Scale = currentFrame->BoneProperties.Scale;
|
||||||
boneMatrices[bone->ID] = poseData;
|
boneMatrices[bone->ID] = poseData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,33 +117,33 @@ Skeleton::PoseData Skeleton::GetAdditiveBonePose(const Bone* bone, const Animati
|
|||||||
glm::vec3 scale = glm::vec3(1);
|
glm::vec3 scale = glm::vec3(1);
|
||||||
|
|
||||||
if (animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) {
|
if (animation->JointAnimations.find(bone->ID) != animation->JointAnimations.end()) {
|
||||||
std::vector<Animation::Keyframe> boneKeyFrames = animation->JointAnimations.at(bone->ID);
|
const std::vector<Animation::Keyframe>& boneKeyFrames = animation->JointAnimations.at(bone->ID);
|
||||||
|
|
||||||
Animation::Keyframe currentFrame;
|
const Animation::Keyframe* currentFrame;
|
||||||
Animation::Keyframe nextFrame;
|
const Animation::Keyframe* nextFrame;
|
||||||
|
|
||||||
if (boneKeyFrames.size() > 1) { // 2+ keyframes for the current bone
|
if (boneKeyFrames.size() > 1) { // 2+ keyframes for the current bone
|
||||||
for (int index = boneKeyFrames.size()-1; index >= 0; index--) { // find the bone keyframes that surrounds the current frame
|
for (int index = boneKeyFrames.size()-1; index >= 0; index--) { // find the bone keyframes that surrounds the current frame
|
||||||
if (time >= boneKeyFrames.at(index).Time) {
|
if (time >= boneKeyFrames.at(index).Time) {
|
||||||
currentFrame = boneKeyFrames.at(index);
|
currentFrame = &boneKeyFrames.at(index);
|
||||||
nextFrame = boneKeyFrames.at((index + 1) % boneKeyFrames.size());
|
nextFrame = &boneKeyFrames.at((index + 1) % boneKeyFrames.size());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float progress;
|
float progress;
|
||||||
|
|
||||||
if (nextFrame.Index == 0) {
|
if (nextFrame->Index == 0) {
|
||||||
nextFrame = currentFrame;
|
nextFrame = currentFrame;
|
||||||
progress = (time - currentFrame.Time) / (animation->Duration - currentFrame.Time);
|
progress = (time - currentFrame->Time) / (animation->Duration - currentFrame->Time);
|
||||||
} else {
|
} else {
|
||||||
progress = (time - currentFrame.Time) / (nextFrame.Time - currentFrame.Time);
|
progress = (time - currentFrame->Time) / (nextFrame->Time - currentFrame->Time);
|
||||||
}
|
}
|
||||||
|
|
||||||
progress = glm::clamp(progress, 0.0f, 1.0f);
|
progress = glm::clamp(progress, 0.0f, 1.0f);
|
||||||
|
|
||||||
Animation::Keyframe::BoneProperty currentBoneProperty = currentFrame.BoneProperties;
|
const Animation::Keyframe::BoneProperty& currentBoneProperty = currentFrame->BoneProperties;
|
||||||
Animation::Keyframe::BoneProperty nextBoneProperty = nextFrame.BoneProperties;
|
const Animation::Keyframe::BoneProperty& nextBoneProperty = nextFrame->BoneProperties;
|
||||||
|
|
||||||
position = currentBoneProperty.Position * (1.f - progress) + nextBoneProperty.Position * progress;
|
position = currentBoneProperty.Position * (1.f - progress) + nextBoneProperty.Position * progress;
|
||||||
rotation = glm::slerp(currentBoneProperty.Rotation, nextBoneProperty.Rotation, progress);
|
rotation = glm::slerp(currentBoneProperty.Rotation, nextBoneProperty.Rotation, progress);
|
||||||
@@ -151,10 +151,10 @@ Skeleton::PoseData Skeleton::GetAdditiveBonePose(const Bone* bone, const Animati
|
|||||||
|
|
||||||
|
|
||||||
} else { // 1 keyframes for the current bone
|
} else { // 1 keyframes for the current bone
|
||||||
currentFrame = boneKeyFrames.at(0);
|
currentFrame = &boneKeyFrames.at(0);
|
||||||
position = currentFrame.BoneProperties.Position;
|
position = currentFrame->BoneProperties.Position;
|
||||||
rotation = currentFrame.BoneProperties.Rotation;
|
rotation = currentFrame->BoneProperties.Rotation;
|
||||||
scale = currentFrame.BoneProperties.Scale;
|
scale = currentFrame->BoneProperties.Scale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,10 +270,10 @@ void Skeleton::AccumulateFinalPose(std::map<int, glm::mat4>& boneMatrices, std::
|
|||||||
boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix;
|
boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix;
|
||||||
} else {
|
} else {
|
||||||
if (bone->Parent) {
|
if (bone->Parent) {
|
||||||
boneMatrix = parentMatrix * (glm::inverse(bone->OffsetMatrix) * bone->Parent->OffsetMatrix);
|
boneMatrix = parentMatrix * bone->BindTransformMatrix * bone->Parent->OffsetMatrix;
|
||||||
boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix;
|
boneMatrices[bone->ID] = boneMatrix * bone->OffsetMatrix;
|
||||||
} else {
|
} else {
|
||||||
boneMatrix = glm::inverse(bone->OffsetMatrix);
|
boneMatrix = bone->BindTransformMatrix;
|
||||||
boneMatrices[bone->ID] = parentMatrix;
|
boneMatrices[bone->ID] = parentMatrix;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,25 +17,26 @@ void CommonFunctions::GenerateMultiSampleTexture(GLuint* texture, int numSamples
|
|||||||
{
|
{
|
||||||
glDeleteTextures(1, texture);
|
glDeleteTextures(1, texture);
|
||||||
glGenTextures(1, texture);
|
glGenTextures(1, texture);
|
||||||
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, *texture);
|
glBindTexture(GL_TEXTURE_2D, *texture);
|
||||||
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, numSamples, internalFormat, dimensions.x, dimensions.y, false);
|
GLERROR("Texture initialization failed 1");
|
||||||
|
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, numSamples, internalFormat, dimensions.x, dimensions.y, GL_FALSE);
|
||||||
GLERROR("Texture initialization failed");
|
GLERROR("Texture initialization failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CommonFunctions::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps)
|
void CommonFunctions::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type, GLint numMipMaps, GLint MAGFilter, GLint MINFilter)
|
||||||
{
|
{
|
||||||
glDeleteTextures(1, texture);
|
glDeleteTextures(1, texture);
|
||||||
glGenTextures(1, texture);
|
glGenTextures(1, texture);
|
||||||
glBindTexture(GL_TEXTURE_2D, *texture);
|
glBindTexture(GL_TEXTURE_2D, *texture);
|
||||||
glTexStorage2D(GL_TEXTURE_2D, numMipMaps, GL_RGBA8, dimensions.x, dimensions.y);
|
glTexStorage2D(GL_TEXTURE_2D, numMipMaps, internalFormat, dimensions.x, dimensions.y);
|
||||||
//glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, dimensions.x, dimensions.y, format, type, NULL);
|
//glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, dimensions.x, dimensions.y, format, type, NULL);
|
||||||
GLERROR("MipMap Texture glTexSubImage2D failed");
|
GLERROR("MipMap Texture glTexSubImage2D failed");
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, MAGFilter);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, MINFilter);
|
||||||
GLERROR("MipMap Texture initialization failed");
|
GLERROR("MipMap Texture initialization failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,10 +30,7 @@ SoundManager::SoundManager(World* world, EventBroker* eventBroker)
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &SoundManager::OnPlayerSpawned);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &SoundManager::OnPlayerSpawned);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayQueueOnEntity, &SoundManager::OnPlayQueueOnEntity);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayQueueOnEntity, &SoundManager::OnPlayQueueOnEntity);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EChangeBGM, &SoundManager::OnChangeBGM);
|
EVENT_SUBSCRIBE_MEMBER(m_EChangeBGM, &SoundManager::OnChangeBGM);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &SoundManager::OnSetCamera);
|
||||||
Events::ChangeBGM e;
|
|
||||||
e.FilePath = "Audio/bgm/MenuMusic.wav";
|
|
||||||
m_EventBroker->Publish(e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundManager::~SoundManager()
|
SoundManager::~SoundManager()
|
||||||
@@ -67,7 +64,6 @@ void SoundManager::Update(double dt)
|
|||||||
deleteInactiveEmitters();
|
deleteInactiveEmitters();
|
||||||
updateEmitters(dt);
|
updateEmitters(dt);
|
||||||
updateListener(dt);
|
updateListener(dt);
|
||||||
if (m_DrumLoopHasBeenStarted)
|
|
||||||
matchBGMLoop();
|
matchBGMLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,15 +359,6 @@ bool SoundManager::OnPlayerSpawned(const Events::PlayerSpawned &e)
|
|||||||
{
|
{
|
||||||
if (e.PlayerID == -1) { // Local player
|
if (e.PlayerID == -1) { // Local player
|
||||||
m_LocalPlayer = e.Player;
|
m_LocalPlayer = e.Player;
|
||||||
if (m_DrumLoopHasBeenStarted) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
m_CurrentBGMCombo = createSource("Audio/BGM/Layer2.wav");
|
|
||||||
m_CurrentBGMCombo->Type = SoundType::BGM;
|
|
||||||
alSourcei(m_CurrentBGMCombo->ALsource, AL_LOOPING, 1);
|
|
||||||
setGain(m_CurrentBGMCombo, 0);
|
|
||||||
playSound(m_CurrentBGMCombo);
|
|
||||||
m_DrumLoopHasBeenStarted = true;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -394,8 +381,10 @@ bool SoundManager::OnPlayQueueOnEntity(const Events::PlayQueueOnEntity &e)
|
|||||||
bool SoundManager::OnChangeBGM(const Events::ChangeBGM &e)
|
bool SoundManager::OnChangeBGM(const Events::ChangeBGM &e)
|
||||||
{
|
{
|
||||||
if (m_CurrentBGM != nullptr) {
|
if (m_CurrentBGM != nullptr) {
|
||||||
|
if (getSourceState(m_CurrentBGM->ALsource) == AL_PLAYING) {
|
||||||
stopSound(m_CurrentBGM);
|
stopSound(m_CurrentBGM);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
m_CurrentBGM = createSource(e.FilePath);
|
m_CurrentBGM = createSource(e.FilePath);
|
||||||
m_CurrentBGM->Type = SoundType::BGM;
|
m_CurrentBGM->Type = SoundType::BGM;
|
||||||
alSourcei(m_CurrentBGM->ALsource, AL_LOOPING, 1);
|
alSourcei(m_CurrentBGM->ALsource, AL_LOOPING, 1);
|
||||||
@@ -403,6 +392,34 @@ bool SoundManager::OnChangeBGM(const Events::ChangeBGM &e)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SoundManager::OnSetCamera(const Events::SetCamera& e)
|
||||||
|
{
|
||||||
|
if (e.CameraEntity.Name() == "Overview_Camera_Start_Menu") {
|
||||||
|
if (m_CurrentBGMCombo != nullptr) {
|
||||||
|
if (getSourceState(m_CurrentBGMCombo->ALsource) == AL_PLAYING) {
|
||||||
|
stopSound(m_CurrentBGMCombo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Events::ChangeBGM changeBGM;
|
||||||
|
changeBGM.FilePath = "Audio/BGM/MenuMusic.wav";
|
||||||
|
m_EventBroker->Publish(changeBGM);
|
||||||
|
} else if (e.CameraEntity.Name() == "PickTeamCamera") {
|
||||||
|
Events::ChangeBGM changeBGM;
|
||||||
|
changeBGM.FilePath = "Audio/BGM/Layer1.wav";
|
||||||
|
m_EventBroker->Publish(changeBGM);
|
||||||
|
if (m_CurrentBGMCombo != nullptr) {
|
||||||
|
if (getSourceState(m_CurrentBGMCombo->ALsource) == AL_PLAYING) {
|
||||||
|
stopSound(m_CurrentBGMCombo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_CurrentBGMCombo = createSource("Audio/BGM/Layer2.wav");
|
||||||
|
m_CurrentBGMCombo->Type = SoundType::BGM;
|
||||||
|
alSourcei(m_CurrentBGMCombo->ALsource, AL_LOOPING, 1);
|
||||||
|
setGain(m_CurrentBGMCombo, 0);
|
||||||
|
playSound(m_CurrentBGMCombo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ALenum SoundManager::getSourceState(ALuint source)
|
ALenum SoundManager::getSourceState(ALuint source)
|
||||||
{
|
{
|
||||||
ALenum state;
|
ALenum state;
|
||||||
|
|||||||
+2
-2
@@ -232,10 +232,10 @@ void Game::Tick()
|
|||||||
PerformanceTimer::StartTimerAndStopPrevious("Network");
|
PerformanceTimer::StartTimerAndStopPrevious("Network");
|
||||||
m_EventBroker->Process<MultiplayerSnapshotFilter>();
|
m_EventBroker->Process<MultiplayerSnapshotFilter>();
|
||||||
if (m_NetworkClient != nullptr) {
|
if (m_NetworkClient != nullptr) {
|
||||||
m_NetworkClient->Update();
|
m_NetworkClient->Update(dt);
|
||||||
}
|
}
|
||||||
if (m_NetworkServer != nullptr) {
|
if (m_NetworkServer != nullptr) {
|
||||||
m_NetworkServer->Update();
|
m_NetworkServer->Update(dt);
|
||||||
}
|
}
|
||||||
//m_SoundManager->Update(dt);
|
//m_SoundManager->Update(dt);
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,26 @@ CapturePointSystem::CapturePointSystem(SystemParams params)
|
|||||||
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);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EReset, &CapturePointSystem::OnReset);
|
||||||
|
Init();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CapturePointSystem::Init()
|
||||||
|
{
|
||||||
|
m_WinnerWasFound = false;
|
||||||
|
//need to track these variables for the captureSystem to work as per design!
|
||||||
|
m_RedTeamNextPossibleCapturePoint = m_NotACapturePoint;
|
||||||
|
m_BlueTeamNextPossibleCapturePoint = m_NotACapturePoint;
|
||||||
|
m_RedTeamHomeCapturePoint = m_NotACapturePoint;
|
||||||
|
m_BlueTeamHomeCapturePoint = m_NotACapturePoint;
|
||||||
|
m_NumberOfCapturePoints = 0;
|
||||||
|
m_ResetTimers = false;
|
||||||
|
m_RecentlyCapturedNeedNextCapturePointNow = false;
|
||||||
|
m_CapturePointNumberToEntityMap.clear();
|
||||||
|
//vectors which will keep track of enter/leave changes
|
||||||
|
m_ETriggerTouchVector.clear();
|
||||||
|
m_ETriggerLeaveVector.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//here all capturepoints will update their component
|
//here all capturepoints will update their component
|
||||||
@@ -24,6 +42,9 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
|||||||
if (m_WinnerWasFound) {
|
if (m_WinnerWasFound) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!capturePointEntity.Valid()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const int capturePointNumber = cCapturePoint["CapturePointNumber"];
|
const int capturePointNumber = cCapturePoint["CapturePointNumber"];
|
||||||
const bool hasTeamComponent = capturePointEntity.HasComponent("Team");
|
const bool hasTeamComponent = capturePointEntity.HasComponent("Team");
|
||||||
|
|
||||||
@@ -60,7 +81,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
|||||||
}
|
}
|
||||||
|
|
||||||
//if we havent received all capturepoints yet, just return
|
//if we havent received all capturepoints yet, just return
|
||||||
if (m_NumberOfCapturePoints == 0 || m_NumberOfCapturePoints != m_CapturePointNumberToEntityMap.size()) {
|
if (m_NumberOfCapturePoints == 0 || m_NumberOfCapturePoints > m_CapturePointNumberToEntityMap.size()) {
|
||||||
m_CapturePointNumberToEntityMap.insert(std::make_pair(capturePointNumber, capturePointEntity));
|
m_CapturePointNumberToEntityMap.insert(std::make_pair(capturePointNumber, capturePointEntity));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -232,10 +253,10 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CapturePointSystem::ChangeCapturePointModelsVisibility(EntityWrapper &capturePointModels, bool isOwner) {
|
void CapturePointSystem::ChangeCapturePointModelsVisibility(EntityWrapper &capturePointModels, bool isOwner)
|
||||||
|
{
|
||||||
(Field<bool>)capturePointModels["Model"]["Visible"] = isOwner;
|
(Field<bool>)capturePointModels["Model"]["Visible"] = isOwner;
|
||||||
for (auto& capModel : capturePointModels.ChildrenWithComponent("Transform"))
|
for (auto& capModel : capturePointModels.ChildrenWithComponent("Transform")) {
|
||||||
{
|
|
||||||
if (capModel.HasComponent("Model")) {
|
if (capModel.HasComponent("Model")) {
|
||||||
(Field<bool>)capModel["Model"]["Visible"] = isOwner;
|
(Field<bool>)capModel["Model"]["Visible"] = isOwner;
|
||||||
}
|
}
|
||||||
@@ -269,3 +290,9 @@ bool CapturePointSystem::OnCaptured(const Events::Captured& e)
|
|||||||
m_ResetTimers = true;
|
m_ResetTimers = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CapturePointSystem::OnReset(const Events::Reset& e)
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@@ -9,6 +9,8 @@ ScoreScreenSystem::ScoreScreenSystem(SystemParams params)
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &ScoreScreenSystem::OnPlayerSpawn);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &ScoreScreenSystem::OnPlayerSpawn);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerConnected, &ScoreScreenSystem::OnPlayerConnected);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerConnected, &ScoreScreenSystem::OnPlayerConnected);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDisconnected, &ScoreScreenSystem::OnPlayerDisconnected);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDisconnected, &ScoreScreenSystem::OnPlayerDisconnected);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EReset, &ScoreScreenSystem::OnReset);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &ScoreScreenSystem::OnInputCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& scoreScreen, double dt)
|
void ScoreScreenSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& scoreScreen, double dt)
|
||||||
@@ -156,3 +158,25 @@ bool ScoreScreenSystem::OnPlayerDisconnected(const Events::PlayerDisconnected& e
|
|||||||
m_DisconnectedIdentities.push_back(e.PlayerID);
|
m_DisconnectedIdentities.push_back(e.PlayerID);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ScoreScreenSystem::OnReset(const Events::Reset & e)
|
||||||
|
{
|
||||||
|
for (auto& it : m_PlayerIdentities) {
|
||||||
|
it.second.Deaths = 0;
|
||||||
|
it.second.Kills = 0;
|
||||||
|
it.second.Team = 1;
|
||||||
|
it.second.Player = EntityWrapper::Invalid;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ScoreScreenSystem::OnInputCommand(const Events::InputCommand & e)
|
||||||
|
{
|
||||||
|
if (e.Command != "PickTeam" || e.PlayerID == -1 || e.Value == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_PlayerIdentities.at(e.PlayerID).Team = e.Value;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -30,11 +30,6 @@ bool SoundSystem::OnPlayerSpawned(const Events::PlayerSpawned &e)
|
|||||||
Events::PlayAnonuncerVoice go;
|
Events::PlayAnonuncerVoice go;
|
||||||
go.FilePath = "Audio/Announcer/" + m_Announcer + "/Go.wav";
|
go.FilePath = "Audio/Announcer/" + m_Announcer + "/Go.wav";
|
||||||
m_EventBroker->Publish(go);
|
m_EventBroker->Publish(go);
|
||||||
{
|
|
||||||
Events::ChangeBGM ev;
|
|
||||||
ev.FilePath = "Audio/BGM/Layer1.wav";
|
|
||||||
m_EventBroker->Publish(ev);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,15 +103,15 @@ bool SpawnerSystem::spawnedEntityIsColliding(EntityWrapper spawnedEntity, Entity
|
|||||||
if (!spawnedBox.Entity.HasComponent("Model")) {
|
if (!spawnedBox.Entity.HasComponent("Model")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Model* model = nullptr;
|
RawModel* model = nullptr;
|
||||||
try {
|
try {
|
||||||
model = ResourceManager::Load<Model, true>(otherEntity["Model"]["Resource"]);
|
model = ResourceManager::Load<RawModel, true>(otherEntity["Model"]["Resource"]);
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model != nullptr && Collision::AABBvsTriangles(
|
if (model != nullptr && Collision::AABBvsTriangles(
|
||||||
spawnedBox,
|
spawnedBox,
|
||||||
model->m_Vertices,
|
model->Vertices(),
|
||||||
model->m_Indices,
|
model->m_Indices,
|
||||||
TransformSystem::ModelMatrix(otherEntity))) {
|
TransformSystem::ModelMatrix(otherEntity))) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ SpectatorCameraSystem::SpectatorCameraSystem(SystemParams params)
|
|||||||
{
|
{
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &SpectatorCameraSystem::OnInputCommand);
|
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &SpectatorCameraSystem::OnInputCommand);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EDisconnect, &SpectatorCameraSystem::OnDisconnect);
|
EVENT_SUBSCRIBE_MEMBER(m_EDisconnect, &SpectatorCameraSystem::OnDisconnect);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EReset, &SpectatorCameraSystem::OnReset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpectatorCameraSystem::Update(double dt)
|
void SpectatorCameraSystem::Update(double dt)
|
||||||
@@ -27,6 +28,14 @@ void SpectatorCameraSystem::Update(double dt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SpectatorCameraSystem::reset()
|
||||||
|
{
|
||||||
|
m_CamSetToTeamPick = false;
|
||||||
|
// They will also be set to menu, so unlock mouse just in case they were in game with locked mouse.
|
||||||
|
Events::UnlockMouse unlock;
|
||||||
|
m_EventBroker->Publish(unlock);
|
||||||
|
}
|
||||||
|
|
||||||
bool SpectatorCameraSystem::OnInputCommand(const Events::InputCommand& e)
|
bool SpectatorCameraSystem::OnInputCommand(const Events::InputCommand& e)
|
||||||
{
|
{
|
||||||
// Only the client should do this, and only if player is not spawned.
|
// Only the client should do this, and only if player is not spawned.
|
||||||
@@ -52,7 +61,11 @@ bool SpectatorCameraSystem::OnInputCommand(const Events::InputCommand& e)
|
|||||||
// TODO: 1 Signifies spectator, should probably have real enum here later.
|
// TODO: 1 Signifies spectator, should probably have real enum here later.
|
||||||
// Spectators should never end up at the class select, instead put them at the SpectatorCamera.
|
// Spectators should never end up at the class select, instead put them at the SpectatorCamera.
|
||||||
if (swapToClass && m_PickedTeam != 1) {
|
if (swapToClass && m_PickedTeam != 1) {
|
||||||
camName = "PickClassCamera";
|
if (m_PickedTeam == 2) {
|
||||||
|
camName = "PickClassCameraRed";
|
||||||
|
} else if (m_PickedTeam == 3) {
|
||||||
|
camName = "PickClassCameraBlue";
|
||||||
|
}
|
||||||
} else if (e.Command == "SwapToTeamPick") {
|
} else if (e.Command == "SwapToTeamPick") {
|
||||||
camName = "PickTeamCamera";
|
camName = "PickTeamCamera";
|
||||||
} else {
|
} else {
|
||||||
@@ -95,10 +108,13 @@ bool SpectatorCameraSystem::OnDisconnect(const Events::PlayerDisconnected& e)
|
|||||||
// If local player gets disconnected, they should be set to
|
// If local player gets disconnected, they should be set to
|
||||||
// the spectator camera next time a map loads that has one.
|
// the spectator camera next time a map loads that has one.
|
||||||
if (e.Entity == LocalPlayer.ID) {
|
if (e.Entity == LocalPlayer.ID) {
|
||||||
m_CamSetToTeamPick = false;
|
reset();
|
||||||
// They will also be set to menu, so unlock mouse just in case they were in game with locked mouse.
|
|
||||||
Events::UnlockMouse unlock;
|
|
||||||
m_EventBroker->Publish(unlock);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SpectatorCameraSystem::OnReset(const Events::Reset & e)
|
||||||
|
{
|
||||||
|
reset();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ bool Material::findColorTexture(MaterialNode& material_node, MFnDependencyNode&
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if (AllConnections[i].node().hasFn(MFn::kLayeredTexture)) {
|
} else if (AllConnections[i].node().hasFn(MFn::kLayeredTexture)) {
|
||||||
MGlobal::displayInfo(MString() + "find splat map");
|
MGlobal::displayInfo(MString() + "found color splat map");
|
||||||
return findSplatTextures(material_node, material_node.ColorMaps, MFnDependencyNode(AllConnections[i].node()));
|
return findSplatTextures(material_node, material_node.ColorMaps, MFnDependencyNode(AllConnections[i].node()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -162,9 +162,9 @@ bool Material::findNormalTexture(MaterialNode& material_node, MFnDependencyNode&
|
|||||||
|
|
||||||
material_node.NormalMaps.push_back(newTexture);
|
material_node.NormalMaps.push_back(newTexture);
|
||||||
return true;
|
return true;
|
||||||
} else if (AllConnections[i].node().hasFn(MFn::kLayeredTexture)) {
|
} else if (AllBumpConnections[j].node().hasFn(MFn::kLayeredTexture)) {
|
||||||
MGlobal::displayInfo(MString() + "find splat map");
|
MGlobal::displayInfo(MString() + "found normal splat map");
|
||||||
return findSplatTextures(material_node, material_node.NormalMaps, MFnDependencyNode(AllConnections[i].node()));
|
return findSplatTextures(material_node, material_node.NormalMaps, MFnDependencyNode(AllBumpConnections[j].node()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -218,7 +218,7 @@ bool Material::findSpecularTexture(MaterialNode& material_node, MFnDependencyNod
|
|||||||
material_node.type = MaterialNode::MaterialType::SingleTextures;
|
material_node.type = MaterialNode::MaterialType::SingleTextures;
|
||||||
return true;
|
return true;
|
||||||
} else if (AllConnections[i].node().hasFn(MFn::kLayeredTexture)) {
|
} else if (AllConnections[i].node().hasFn(MFn::kLayeredTexture)) {
|
||||||
MGlobal::displayInfo(MString() + "find splat map");
|
MGlobal::displayInfo(MString() + "found specular splat map");
|
||||||
return findSplatTextures(material_node, material_node.SpecularMaps, MFnDependencyNode(AllConnections[i].node()));
|
return findSplatTextures(material_node, material_node.SpecularMaps, MFnDependencyNode(AllConnections[i].node()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -270,7 +270,7 @@ bool Material::findIncandescenceTexture(MaterialNode& material_node, MFnDependen
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else if (AllConnections[i].node().hasFn(MFn::kLayeredTexture)) {
|
} else if (AllConnections[i].node().hasFn(MFn::kLayeredTexture)) {
|
||||||
MGlobal::displayInfo(MString() + "find splat map");
|
MGlobal::displayInfo(MString() + "found incandescens splat map");
|
||||||
return findSplatTextures(material_node, material_node.IncandescenceMaps, MFnDependencyNode(AllConnections[i].node()));
|
return findSplatTextures(material_node, material_node.IncandescenceMaps, MFnDependencyNode(AllConnections[i].node()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user