Compare commits
62 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e45d0e8232 | |||
| 62d1cb9a69 | |||
| 06bddd9d54 | |||
| 5f959ded89 | |||
| 0fbc482f9c | |||
| 2eb863757b | |||
| 7febb7681c | |||
| 33627f917c | |||
| 0869afd529 | |||
| 56a13d03fc | |||
| dad18a200f | |||
| 937bf823f3 | |||
| e35b09cc68 | |||
| b172526e62 | |||
| 551745b0a6 | |||
| d6e3a47182 | |||
| 8b89df0095 | |||
| 038a706e28 | |||
| a8a4b5d2a2 | |||
| 777f382772 | |||
| 78129cf432 | |||
| e734d0c953 | |||
| c9fef65c4f | |||
| 7e6288c597 | |||
| 4322a5d8da | |||
| b094b9feca | |||
| 67dfbfff01 | |||
| 0a94373f3f | |||
| 79d0ef4529 | |||
| dd63f4a1b4 | |||
| 50dbbb4ed4 | |||
| 329a15e08b | |||
| 28de31d84d | |||
| e9ef0e7060 | |||
| 416f55b6ce | |||
| 0346f81234 | |||
| c3255519bf | |||
| bdcb33d992 | |||
| a6ef026db5 | |||
| a2244e87ad | |||
| a0d60160dd | |||
| 15c54d2be6 | |||
| f26b24ef6b | |||
| b0e9cd3965 | |||
| 5e747f53db | |||
| 592edf7dba | |||
| 3a213be679 | |||
| 4e6ff16e58 | |||
| 087facc22e | |||
| f9935cad42 | |||
| 37355b1afc | |||
| ad49af2f8c | |||
| 5a7034dfcd | |||
| 9721cb6a7d | |||
| 90b2c70215 | |||
| c36c7d1ea6 | |||
| 3209e36176 | |||
| 7ced9e6767 | |||
| 3828616b60 | |||
| 9cbc582be2 | |||
| 68a88ed756 | |||
| 078d6eb712 |
+1
-1
Submodule assets updated: 3af64d8b1f...007b54bd67
@@ -84,6 +84,18 @@ bool AABBvsTriangles(const AABB& box,
|
|||||||
const std::vector<unsigned int>& modelIndices,
|
const std::vector<unsigned int>& modelIndices,
|
||||||
const glm::mat4& modelMatrix);
|
const glm::mat4& modelMatrix);
|
||||||
|
|
||||||
|
enum Output
|
||||||
|
{
|
||||||
|
OutContained,
|
||||||
|
OutSeparated,
|
||||||
|
OutIntersecting
|
||||||
|
};
|
||||||
|
//Detects intersection and containment.
|
||||||
|
Output AABBvsTrianglesWContainment(const AABB& box,
|
||||||
|
const RawModel::Vertex* modelVertices,
|
||||||
|
const std::vector<unsigned int>& modelIndices,
|
||||||
|
const glm::mat4& modelMatrix);
|
||||||
|
|
||||||
//Return true if the boxes are intersecting.
|
//Return true if the boxes are intersecting.
|
||||||
bool AABBVsAABB(const AABB& a, const AABB& b);
|
bool AABBVsAABB(const AABB& a, const AABB& b);
|
||||||
//Return true if the boxes are intersecting.
|
//Return true if the boxes are intersecting.
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public:
|
|||||||
void Connect(std::string address, int port);
|
void Connect(std::string address, int port);
|
||||||
void Update() override;
|
void Update() override;
|
||||||
private:
|
private:
|
||||||
//UDPClient m_Unreliable;
|
UDPClient m_Unreliable;
|
||||||
TCPClient m_Reliable;
|
TCPClient m_Reliable;
|
||||||
std::vector<Events::PlayerSpawned> m_PlayerSpawnEvents;
|
std::vector<Events::PlayerSpawned> m_PlayerSpawnEvents;
|
||||||
void parseSpawnEvents();
|
void parseSpawnEvents();
|
||||||
@@ -81,7 +81,7 @@ private:
|
|||||||
std::vector<Events::InputCommand> m_InputCommandBuffer;
|
std::vector<Events::InputCommand> m_InputCommandBuffer;
|
||||||
|
|
||||||
// Private member functions
|
// Private member functions
|
||||||
size_t receive(char* data);
|
size_t receive(char* data);
|
||||||
void disconnect();
|
void disconnect();
|
||||||
void parseMessageType(Packet& packet);
|
void parseMessageType(Packet& packet);
|
||||||
void updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID);
|
void updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID);
|
||||||
@@ -139,7 +139,7 @@ private:
|
|||||||
std::vector<ServerInfo> m_Serverlist;
|
std::vector<ServerInfo> m_Serverlist;
|
||||||
bool m_SearchingForServers = false;
|
bool m_SearchingForServers = false;
|
||||||
std::clock_t m_StartSearchTime;
|
std::clock_t m_StartSearchTime;
|
||||||
double m_SearchingTime = 2000; // Config I guess
|
double m_SearchingTime = 200; // Config I guess
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ protected:
|
|||||||
void logReceivedData(int bytesReceived);
|
void logReceivedData(int bytesReceived);
|
||||||
void saveToFile();
|
void saveToFile();
|
||||||
void updateNetworkData();
|
void updateNetworkData();
|
||||||
|
void popNetworkSegmentOfHeader(Packet& packet);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -16,7 +16,9 @@ public:
|
|||||||
Packet(char* data, const size_t sizeOfPacket);
|
Packet(char* data, const size_t sizeOfPacket);
|
||||||
Packet(MessageType type);
|
Packet(MessageType type);
|
||||||
~Packet();
|
~Packet();
|
||||||
void Init(MessageType type, unsigned int& packetID);
|
void Init(MessageType type, unsigned int& packetID,
|
||||||
|
int groupIndex, int groupSize,
|
||||||
|
int packetGroup);
|
||||||
|
|
||||||
// Add primitive types like int, float, char...
|
// Add primitive types like int, float, char...
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@@ -25,7 +27,8 @@ public:
|
|||||||
// Check if we are trying to add more than the package can fit.
|
// Check if we are trying to add more than the package can fit.
|
||||||
if (m_MaxPacketSize < m_Offset + sizeof(T)) {
|
if (m_MaxPacketSize < m_Offset + sizeof(T)) {
|
||||||
if (m_MaxPacketSize >= 32000) {
|
if (m_MaxPacketSize >= 32000) {
|
||||||
LOG_WARNING("Package::WritePrimitive(): New size is huge %i bytes\n", m_MaxPacketSize*2);
|
// This will spam couse 8 players are over 100 000 bytes
|
||||||
|
//LOG_WARNING("Package::WritePrimitive(): New size is huge %i bytes\n", m_MaxPacketSize*2);
|
||||||
}
|
}
|
||||||
resizeData();
|
resizeData();
|
||||||
}
|
}
|
||||||
@@ -57,13 +60,19 @@ public:
|
|||||||
void UpdateSize();
|
void UpdateSize();
|
||||||
char* ReadData(int SizeOfData);
|
char* ReadData(int SizeOfData);
|
||||||
void ChangePacketID(unsigned int& packetID);
|
void ChangePacketID(unsigned int& packetID);
|
||||||
|
void ChangeGroupIndex(int groupIndex);
|
||||||
|
void ChangeGroupSize(int groupSize);
|
||||||
|
void ChangeGroup(int group);
|
||||||
size_t Size() { return m_Offset; };
|
size_t Size() { return m_Offset; };
|
||||||
char* Data() { return m_Data; };
|
char* Data() { return m_Data; };
|
||||||
MessageType GetMessageType();
|
MessageType GetMessageType();
|
||||||
|
size_t Group();
|
||||||
size_t DataReadSize() { return m_ReturnDataOffset; }
|
size_t DataReadSize() { return m_ReturnDataOffset; }
|
||||||
size_t MaxSize() { return m_MaxPacketSize; }
|
size_t MaxSize() { return m_MaxPacketSize; }
|
||||||
size_t HeaderSize() { return m_HeaderSize; }
|
size_t HeaderSize() { return m_HeaderSize; }
|
||||||
|
size_t GroupIndex();
|
||||||
|
size_t GroupSize();
|
||||||
|
size_t PacketID();
|
||||||
private:
|
private:
|
||||||
char* m_Data;
|
char* m_Data;
|
||||||
size_t m_ReturnDataOffset = 0;
|
size_t m_ReturnDataOffset = 0;
|
||||||
@@ -72,6 +81,13 @@ private:
|
|||||||
size_t m_HeaderSize = 0;
|
size_t m_HeaderSize = 0;
|
||||||
void resizeData();
|
void resizeData();
|
||||||
void resizeData(int size);
|
void resizeData(int size);
|
||||||
|
|
||||||
|
size_t packetSizeOffset = 0;
|
||||||
|
size_t groupOffset = 0;
|
||||||
|
size_t groupIndexOffset = 0;
|
||||||
|
size_t groupSizeOffset = 0;
|
||||||
|
size_t messageTypeOffset = 0;
|
||||||
|
size_t packetIDOffset = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -14,6 +14,7 @@ struct PlayerDefinition {
|
|||||||
unsigned short TCPPort;
|
unsigned short TCPPort;
|
||||||
// use for tcp connections
|
// use for tcp connections
|
||||||
boost::shared_ptr<boost::asio::ip::tcp::socket> TCPSocket;
|
boost::shared_ptr<boost::asio::ip::tcp::socket> TCPSocket;
|
||||||
|
int PacketGroup = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
// Network channels
|
// Network channels
|
||||||
TCPServer m_Reliable;
|
TCPServer m_Reliable;
|
||||||
//UDPServer m_Unreliable;
|
UDPServer m_Unreliable;
|
||||||
UDPServer m_ServerlistRequest;
|
UDPServer m_ServerlistRequest;
|
||||||
// dont forget to set these in the childrens receive logic
|
// dont forget to set these in the childrens receive logic
|
||||||
boost::asio::ip::address m_Address;
|
boost::asio::ip::address m_Address;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#ifndef UDPClient_h__
|
#ifndef UDPClient_h__
|
||||||
#define UDPClient_h__
|
#define UDPClient_h__
|
||||||
|
#include <map>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include "Network/NetworkClient.h"
|
#include "Network/NetworkClient.h"
|
||||||
@@ -13,16 +15,27 @@ public:
|
|||||||
bool Connect(std::string playerName, std::string address, int port);
|
bool Connect(std::string playerName, std::string address, int port);
|
||||||
void Disconnect();
|
void Disconnect();
|
||||||
void Receive(Packet& packet);
|
void Receive(Packet& packet);
|
||||||
void Send(Packet & packet);
|
void ReceivePackets();
|
||||||
|
void Send(Packet& packet);
|
||||||
void Broadcast(Packet& packet, int port);
|
void Broadcast(Packet& packet, int port);
|
||||||
bool IsSocketAvailable();
|
bool IsSocketAvailable();
|
||||||
|
// Returns false if no packets are available
|
||||||
|
bool GetNextPacket(Packet& packet);
|
||||||
private:
|
private:
|
||||||
|
typedef std::map<unsigned int, std::vector<std::pair<int, boost::shared_ptr<char>>>> PacketMap;
|
||||||
// Assio UDP logic
|
// Assio UDP logic
|
||||||
boost::asio::io_service m_IOService;
|
boost::asio::io_service m_IOService;
|
||||||
boost::asio::ip::udp::endpoint m_ReceiverEndpoint;
|
boost::asio::ip::udp::endpoint m_ReceiverEndpoint;
|
||||||
boost::shared_ptr<boost::asio::ip::udp::socket> m_Socket;
|
boost::shared_ptr<boost::asio::ip::udp::socket> m_Socket;
|
||||||
|
int m_LastReceivedSnapshotGroup = 0;
|
||||||
int readBuffer();
|
int readBuffer();
|
||||||
|
void readPartOfPacket();
|
||||||
PacketID m_SendPacketID = 0;
|
PacketID m_SendPacketID = 0;
|
||||||
|
//map:(packetGroup, vector:(pair:(groupIndex, packetData)))
|
||||||
|
PacketMap m_PacketSegmentMap;
|
||||||
|
bool hasReceivedPacket(int packetGroup, int groupIndex);
|
||||||
|
// 2^19
|
||||||
|
const int m_SizeOfSocketBuffer = 524288;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "NetworkServer.h"
|
#include "NetworkServer.h"
|
||||||
#include <boost/asio/ip/udp.hpp>
|
#include <boost/asio/ip/udp.hpp>
|
||||||
|
#define MAXPACKETSIZE 64000
|
||||||
|
|
||||||
class UDPServer : public NetworkServer
|
class UDPServer : public NetworkServer
|
||||||
{
|
{
|
||||||
@@ -13,6 +14,7 @@ public:
|
|||||||
void AcceptNewConnections(int& nextPlayerID, std::map<PlayerID, PlayerDefinition>& connectedPlayers);
|
void AcceptNewConnections(int& nextPlayerID, std::map<PlayerID, PlayerDefinition>& connectedPlayers);
|
||||||
void Receive(Packet & packet, PlayerDefinition & playerDefinition);
|
void Receive(Packet & packet, PlayerDefinition & playerDefinition);
|
||||||
void Send(Packet & packet, PlayerDefinition & playerDefinition);
|
void Send(Packet & packet, PlayerDefinition & playerDefinition);
|
||||||
|
void SendToConnectedPlayers(Packet & packet, std::map<PlayerID, PlayerDefinition>& playersTosendTo);
|
||||||
void Send(Packet & packet);
|
void Send(Packet & packet);
|
||||||
void Send(Packet & packet, boost::asio::ip::udp::endpoint endpoint);
|
void Send(Packet & packet, boost::asio::ip::udp::endpoint endpoint);
|
||||||
void Broadcast(Packet & packet, int port);
|
void Broadcast(Packet & packet, int port);
|
||||||
|
|||||||
@@ -33,12 +33,14 @@ public:
|
|||||||
if (m_Quality == 0) {
|
if (m_Quality == 0) {
|
||||||
return m_BlackTexture->m_Texture;
|
return m_BlackTexture->m_Texture;
|
||||||
} else {
|
} else {
|
||||||
return m_GaussianTexture_vert;
|
return m_FinalGaussianTexture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void GaussianLodPass(GLuint mipMap, GLuint texture);
|
||||||
|
void CombineGaussianBlur();
|
||||||
Texture* m_BlackTexture;
|
Texture* m_BlackTexture;
|
||||||
Model* m_ScreenQuad;
|
Model* m_ScreenQuad;
|
||||||
|
|
||||||
@@ -47,15 +49,19 @@ private:
|
|||||||
//const LightCullingPass* m_LightCullingPass
|
//const LightCullingPass* m_LightCullingPass
|
||||||
int m_Iterations;
|
int m_Iterations;
|
||||||
int m_Quality = 0;
|
int m_Quality = 0;
|
||||||
|
int m_BloomLod = 5;
|
||||||
|
|
||||||
GLuint m_GaussianTexture_horiz = 0;
|
GLuint m_GaussianTexture_horiz = 0;
|
||||||
GLuint m_GaussianTexture_vert = 0;
|
GLuint m_GaussianTexture_vert = 0;
|
||||||
|
GLuint m_FinalGaussianTexture = 0;
|
||||||
|
|
||||||
FrameBuffer m_GaussianFrameBuffer_horiz;
|
FrameBuffer* m_GaussianFrameBuffer_horiz = nullptr;
|
||||||
FrameBuffer m_GaussianFrameBuffer_vert;
|
FrameBuffer* m_GaussianFrameBuffer_vert = nullptr;
|
||||||
|
FrameBuffer m_GaussianCombineBuffer;
|
||||||
|
|
||||||
ShaderProgram* m_GaussianProgram_horiz;
|
ShaderProgram* m_GaussianProgram_horiz;
|
||||||
ShaderProgram* m_GaussianProgram_vert;
|
ShaderProgram* m_GaussianProgram_vert;
|
||||||
|
ShaderProgram* m_GaussianCombineProgram;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#ifndef EResolutionChanged_h__
|
||||||
|
#define EResolutionChanged_h__
|
||||||
|
|
||||||
|
#include "../Core/Event.h"
|
||||||
|
#include "../Core/Util/Rectangle.h"
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
// Fired when the framebuffer size changes
|
||||||
|
struct ResolutionChanged : Event
|
||||||
|
{
|
||||||
|
Rectangle OldResolution;
|
||||||
|
Rectangle NewResolution;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -7,11 +7,12 @@
|
|||||||
class BufferResource
|
class BufferResource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment);
|
BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment, GLuint mipMapLod);
|
||||||
|
|
||||||
GLuint* m_ResourceHandle;
|
GLuint* m_ResourceHandle;
|
||||||
GLenum m_ResourceType;
|
GLenum m_ResourceType;
|
||||||
GLenum m_Attachment;
|
GLenum m_Attachment;
|
||||||
|
GLuint m_MipMapLod = 0;
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -20,15 +21,15 @@ template <GLenum RESOURCETYPE>
|
|||||||
class ResourceType : public BufferResource
|
class ResourceType : public BufferResource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ResourceType(GLuint* resourceHandle, GLenum attachment)
|
ResourceType(GLuint* resourceHandle, GLenum attachment, GLuint mipMapLod)
|
||||||
: BufferResource(resourceHandle, RESOURCETYPE, attachment) { }
|
: BufferResource(resourceHandle, RESOURCETYPE, attachment, mipMapLod) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class Texture2D : public ResourceType<GL_TEXTURE_2D>
|
class Texture2D : public ResourceType<GL_TEXTURE_2D>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Texture2D(GLuint* resourceHandle, GLenum attachment)
|
Texture2D(GLuint* resourceHandle, GLenum attachment, GLuint mipMapLod = 0)
|
||||||
: ResourceType(resourceHandle, attachment) { };
|
: ResourceType(resourceHandle, attachment, mipMapLod) { };
|
||||||
|
|
||||||
~Texture2D();
|
~Texture2D();
|
||||||
};
|
};
|
||||||
@@ -37,7 +38,7 @@ class RenderBuffer : public ResourceType<GL_RENDERBUFFER>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RenderBuffer(GLuint* resourceHandle, GLenum attachment)
|
RenderBuffer(GLuint* resourceHandle, GLenum attachment)
|
||||||
: ResourceType(resourceHandle, attachment)
|
: ResourceType(resourceHandle, attachment, 0)
|
||||||
{ };
|
{ };
|
||||||
|
|
||||||
~RenderBuffer();
|
~RenderBuffer();
|
||||||
@@ -47,7 +48,7 @@ class Texture2DArray : public ResourceType<GL_TEXTURE_2D_ARRAY>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Texture2DArray(GLuint* resourceHandle, GLenum attachment)
|
Texture2DArray(GLuint* resourceHandle, GLenum attachment)
|
||||||
: ResourceType(resourceHandle, attachment)
|
: ResourceType(resourceHandle, attachment, 0)
|
||||||
{ };
|
{ };
|
||||||
|
|
||||||
~Texture2DArray();
|
~Texture2DArray();
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ private:
|
|||||||
struct Frustum {
|
struct Frustum {
|
||||||
Plane Planes[4];
|
Plane Planes[4];
|
||||||
};
|
};
|
||||||
Frustum* m_Frustums;
|
Frustum* m_Frustums = nullptr;
|
||||||
|
|
||||||
//This should be a component
|
//This should be a component
|
||||||
struct LightSource {
|
struct LightSource {
|
||||||
@@ -74,11 +74,11 @@ private:
|
|||||||
glm::vec2 Padding = glm::vec2(1.f, 2.f);
|
glm::vec2 Padding = glm::vec2(1.f, 2.f);
|
||||||
};
|
};
|
||||||
|
|
||||||
LightGrid* m_LightGrid;
|
LightGrid* m_LightGrid = nullptr;
|
||||||
|
|
||||||
int m_LightOffset = 0;
|
int m_LightOffset = 0;
|
||||||
|
|
||||||
float* m_LightIndex;
|
float* m_LightIndex = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "../Core/Octree.h"
|
#include "../Core/Octree.h"
|
||||||
#include "../Collision/EntityAABB.h"
|
#include "../Collision/EntityAABB.h"
|
||||||
#include "../Core/ConfigFile.h"
|
#include "../Core/ConfigFile.h"
|
||||||
|
#include "EResolutionChanged.h"
|
||||||
|
|
||||||
class RenderSystem : public ImpureSystem
|
class RenderSystem : public ImpureSystem
|
||||||
{
|
{
|
||||||
@@ -36,6 +37,8 @@ private:
|
|||||||
EntityWrapper m_LocalPlayer = EntityWrapper::Invalid;
|
EntityWrapper m_LocalPlayer = EntityWrapper::Invalid;
|
||||||
Octree<EntityAABB>* m_Octree;
|
Octree<EntityAABB>* m_Octree;
|
||||||
|
|
||||||
|
EventRelay<RenderSystem, Events::ResolutionChanged> m_EResolutionChanged;
|
||||||
|
bool OnResolutionChanged(Events::ResolutionChanged &event);
|
||||||
EventRelay<RenderSystem, Events::SetCamera> m_ESetCamera;
|
EventRelay<RenderSystem, Events::SetCamera> m_ESetCamera;
|
||||||
bool OnSetCamera(Events::SetCamera &event);
|
bool OnSetCamera(Events::SetCamera &event);
|
||||||
EventRelay<RenderSystem, Events::InputCommand> m_EInputCommand;
|
EventRelay<RenderSystem, Events::InputCommand> m_EInputCommand;
|
||||||
|
|||||||
@@ -28,10 +28,12 @@
|
|||||||
#include "Util/CommonFunctions.h"
|
#include "Util/CommonFunctions.h"
|
||||||
#include "Core/PerformanceTimer.h"
|
#include "Core/PerformanceTimer.h"
|
||||||
#include "ShadowPass.h"
|
#include "ShadowPass.h"
|
||||||
|
#include "EResolutionChanged.h"
|
||||||
|
|
||||||
class Renderer : public IRenderer
|
class Renderer : public IRenderer
|
||||||
{
|
{
|
||||||
static void glfwFrameBufferCallback(GLFWwindow* window, int width, int height);
|
static void glfwFrameBufferCallback(GLFWwindow* window, int width, int height);
|
||||||
|
static void glfwWindowSizeCallback(GLFWwindow* window, int width, int height);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Renderer(EventBroker* eventBroker, ConfigFile* config)
|
Renderer(EventBroker* eventBroker, ConfigFile* config)
|
||||||
@@ -40,13 +42,14 @@ public:
|
|||||||
{ }
|
{ }
|
||||||
~Renderer();
|
~Renderer();
|
||||||
|
|
||||||
|
virtual void SetResolution(const Rectangle& resolution) override;
|
||||||
|
|
||||||
virtual void Initialize() override;
|
virtual void Initialize() override;
|
||||||
virtual void Update(double dt) override;
|
virtual void Update(double dt) override;
|
||||||
virtual void Draw(RenderFrame& frame) override;
|
virtual void Draw(RenderFrame& frame) override;
|
||||||
|
|
||||||
virtual PickData Pick(glm::vec2 screenCoord) override;
|
virtual PickData Pick(glm::vec2 screenCoord) override;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//----------------------Variables----------------------//
|
//----------------------Variables----------------------//
|
||||||
|
|
||||||
@@ -90,11 +93,14 @@ private:
|
|||||||
void InputUpdate(double dt);
|
void InputUpdate(double dt);
|
||||||
//void PickingPass(RenderQueueCollection& rq);
|
//void PickingPass(RenderQueueCollection& rq);
|
||||||
//void DrawScreenQuad(GLuint textureToDraw);
|
//void DrawScreenQuad(GLuint textureToDraw);
|
||||||
|
void setWindowSize(Rectangle size);
|
||||||
|
void updateFramebufferSize();
|
||||||
|
|
||||||
static bool DepthSort(const std::shared_ptr<RenderJob> &i, const std::shared_ptr<RenderJob> &j) { return (i->Depth < j->Depth); }
|
static bool DepthSort(const std::shared_ptr<RenderJob> &i, const std::shared_ptr<RenderJob> &j) { return (i->Depth < j->Depth); }
|
||||||
void SortRenderJobsByDepth(RenderScene &scene);
|
void SortRenderJobsByDepth(RenderScene &scene);
|
||||||
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type);
|
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type);
|
||||||
//--------------------ShaderPrograms-------------------//
|
|
||||||
|
//--------------------ShaderPrograms-------------------//
|
||||||
ShaderProgram* m_BasicForwardProgram;
|
ShaderProgram* m_BasicForwardProgram;
|
||||||
ShaderProgram* m_ExplosionEffectProgram;
|
ShaderProgram* m_ExplosionEffectProgram;
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ private:
|
|||||||
|
|
||||||
GLuint m_DepthMap;
|
GLuint m_DepthMap;
|
||||||
FrameBuffer m_DepthBuffer;
|
FrameBuffer m_DepthBuffer;
|
||||||
ShaderProgram* m_ShadowProgram;
|
ShaderProgram* m_ShadowProgram;
|
||||||
|
ShaderProgram* m_ShadowProgramSkinned;
|
||||||
|
|
||||||
std::array<glm::mat4, MAX_SPLITS> m_LightProjection;
|
std::array<glm::mat4, MAX_SPLITS> m_LightProjection;
|
||||||
std::array<glm::mat4, MAX_SPLITS> m_LightView;
|
std::array<glm::mat4, MAX_SPLITS> m_LightView;
|
||||||
|
|||||||
@@ -21,14 +21,15 @@ struct SpriteJob : RenderJob
|
|||||||
SpriteJob(ComponentWrapper cSprite, Camera* camera, glm::mat4 matrix, World* world, glm::vec4 fillColor, float fillPercentage, bool depthSorted, bool isIndicator)
|
SpriteJob(ComponentWrapper cSprite, Camera* camera, glm::mat4 matrix, World* world, glm::vec4 fillColor, float fillPercentage, bool depthSorted, bool isIndicator)
|
||||||
: RenderJob()
|
: RenderJob()
|
||||||
{
|
{
|
||||||
Model = ResourceManager::Load<::Model>("Models/Core/UnitQuad.mesh");
|
Model = ResourceManager::Load<::Model>((std::string)cSprite["Model"]);
|
||||||
::RawModel::MaterialProperties matProp = Model->MaterialGroups().front();
|
::RawModel::MaterialProperties matProp = Model->MaterialGroups().front();
|
||||||
TextureID = 0;
|
TextureID = 0;
|
||||||
|
|
||||||
DiffuseTexture = CommonFunctions::TryLoadResource<TextureSprite, true>(cSprite["DiffuseTexture"]);
|
DiffuseTexture = CommonFunctions::TryLoadResource<TextureSprite, true>(cSprite["DiffuseTexture"]);
|
||||||
|
|
||||||
IncandescenceTexture = CommonFunctions::TryLoadResource<TextureSprite, true>(cSprite["GlowMap"]);
|
IncandescenceTexture = CommonFunctions::TryLoadResource<TextureSprite, true>(cSprite["GlowMap"]);
|
||||||
|
|
||||||
|
Linear = (bool)cSprite["Linear"];
|
||||||
|
|
||||||
StartIndex = matProp.material->StartIndex;
|
StartIndex = matProp.material->StartIndex;
|
||||||
EndIndex = matProp.material->EndIndex;
|
EndIndex = matProp.material->EndIndex;
|
||||||
Matrix = matrix;
|
Matrix = matrix;
|
||||||
@@ -48,6 +49,26 @@ struct SpriteJob : RenderJob
|
|||||||
|
|
||||||
FillColor = fillColor;
|
FillColor = fillColor;
|
||||||
FillPercentage = fillPercentage;
|
FillPercentage = fillPercentage;
|
||||||
|
|
||||||
|
glm::vec3 scale = Transform::AbsoluteScale(world, cSprite.EntityID);
|
||||||
|
|
||||||
|
if((bool)cSprite["KeepRatio"] == true) {
|
||||||
|
if(scale.y >= scale.x) {
|
||||||
|
ScaleY = (scale.x)/(scale.y);
|
||||||
|
ScaleX = 1.f;
|
||||||
|
} else {
|
||||||
|
ScaleY = 1.f;
|
||||||
|
ScaleX = (scale.x)/(scale.y);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ((bool)cSprite["KeepRatioX"] == true) {
|
||||||
|
ScaleX = scale.x;
|
||||||
|
}
|
||||||
|
if ((bool)cSprite["KeepRatioY"] == true) {
|
||||||
|
ScaleY = scale.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned int TextureID;
|
unsigned int TextureID;
|
||||||
@@ -69,6 +90,9 @@ struct SpriteJob : RenderJob
|
|||||||
bool Pickable;
|
bool Pickable;
|
||||||
bool IsIndicator = false;
|
bool IsIndicator = false;
|
||||||
bool BlurBackground = false;
|
bool BlurBackground = false;
|
||||||
|
float ScaleX = 1;
|
||||||
|
float ScaleY = 1;
|
||||||
|
bool Linear = false;
|
||||||
|
|
||||||
glm::vec4 FillColor = glm::vec4(0);
|
glm::vec4 FillColor = glm::vec4(0);
|
||||||
float FillPercentage = 0.0;
|
float FillPercentage = 0.0;
|
||||||
|
|||||||
@@ -16,7 +16,11 @@ inline bool _GLERROR(const char* info, const char* file, const char* func, unsig
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
#define GLERROR(function) \
|
#define GLERROR(function) \
|
||||||
_GLERROR(function, __BASE_FILE__, __func__, __LINE__)
|
_GLERROR(function, __BASE_FILE__, __func__, __LINE__)
|
||||||
|
#else
|
||||||
|
#define GLERROR(function) false
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -30,6 +30,7 @@ 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);
|
||||||
|
void ChangeCapturePointModelsVisibility(EntityWrapper &capturePointModels, bool isOwner);
|
||||||
|
|
||||||
bool m_WinnerWasFound = false;
|
bool m_WinnerWasFound = false;
|
||||||
//need to track these variables for the captureSystem to work as per design!
|
//need to track these variables for the captureSystem to work as per design!
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "Core/System.h"
|
#include "Core/System.h"
|
||||||
#include "Input/EInputCommand.h"
|
#include "Input/EInputCommand.h"
|
||||||
|
#include "Network/EPlayerDisconnected.h"
|
||||||
|
|
||||||
class SpectatorCameraSystem : public ImpureSystem
|
class SpectatorCameraSystem : public ImpureSystem
|
||||||
{
|
{
|
||||||
@@ -17,6 +18,8 @@ private:
|
|||||||
|
|
||||||
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;
|
||||||
|
bool OnDisconnect(const Events::PlayerDisconnected& e);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -29,4 +29,6 @@ K=TakeDamage,1500
|
|||||||
F2=PerformanceTimingResetAllTimers
|
F2=PerformanceTimingResetAllTimers
|
||||||
F3=PerformanceTimingCreateExcelData
|
F3=PerformanceTimingCreateExcelData
|
||||||
Comma=SwapToClassPick
|
Comma=SwapToClassPick
|
||||||
Period=SwapToTeamPick
|
Period=SwapToTeamPick
|
||||||
|
Enter=PickClass,1
|
||||||
|
F5=DisconnectFromServer
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
<Camera xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Camera.xsd">
|
<Camera xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Camera.xsd">
|
||||||
<FOV>45</FOV>
|
<FOV>59</FOV> <!-- 90 horizontal FOV at 1080p -->
|
||||||
<NearClip>0.01</NearClip>
|
<NearClip>0.01</NearClip>
|
||||||
<FarClip>5000</FarClip>
|
<FarClip>5000</FarClip>
|
||||||
</Camera>
|
</Camera>
|
||||||
@@ -9,5 +9,5 @@
|
|||||||
<SpecularMap>true</SpecularMap>
|
<SpecularMap>true</SpecularMap>
|
||||||
<GlowMap>true</GlowMap>
|
<GlowMap>true</GlowMap>
|
||||||
<Shadow>true</Shadow>
|
<Shadow>true</Shadow>
|
||||||
<GlowIntensity>3.0</GlowIntensity>
|
<GlowIntensity>1.0</GlowIntensity>
|
||||||
</Model>
|
</Model>
|
||||||
@@ -1,9 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
<Sprite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Sprite.xsd">
|
<Sprite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Sprite.xsd">
|
||||||
|
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||||
<DiffuseTexture></DiffuseTexture>
|
<DiffuseTexture></DiffuseTexture>
|
||||||
<GlowMap></GlowMap>
|
<GlowMap></GlowMap>
|
||||||
<Color R="1" G="1" B="1" A="1"/>
|
<Color R="1" G="1" B="1" A="1"/>
|
||||||
<Visible>true</Visible>
|
<Visible>true</Visible>
|
||||||
<DepthSort>true</DepthSort>
|
<DepthSort>true</DepthSort>
|
||||||
|
<KeepRatioX>false</KeepRatioX>
|
||||||
|
<KeepRatioY>false</KeepRatioY>
|
||||||
|
<KeepRatio>false</KeepRatio>
|
||||||
|
<Linear>false</Linear>
|
||||||
<BlurBackground>false</BlurBackground>
|
<BlurBackground>false</BlurBackground>
|
||||||
</Sprite>
|
</Sprite>
|
||||||
|
|||||||
@@ -9,14 +9,17 @@
|
|||||||
</xs:annotation>
|
</xs:annotation>
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:all>
|
<xs:all>
|
||||||
|
<xs:element name="Model" type="t:string" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>The model the sprite will use.</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
<xs:element name="DiffuseTexture" type="t:string" minOccurs="0">
|
<xs:element name="DiffuseTexture" type="t:string" minOccurs="0">
|
||||||
<xs:annotation><xs:documentation>Diffuse Texture file</xs:documentation></xs:annotation>
|
<xs:annotation><xs:documentation>Diffuse Texture file.</xs:documentation></xs:annotation>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
<xs:element name="GlowMap" type="t:string" minOccurs="0">
|
<xs:element name="GlowMap" type="t:string" minOccurs="0">
|
||||||
<xs:annotation><xs:documentation>GlowMap file</xs:documentation></xs:annotation>
|
<xs:annotation><xs:documentation>GlowMap file.</xs:documentation></xs:annotation>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
<xs:element name="Color" type="t:Color" minOccurs="0">
|
<xs:element name="Color" type="t:Color" minOccurs="0">
|
||||||
<xs:annotation><xs:documentation>Color tint</xs:documentation></xs:annotation>
|
<xs:annotation><xs:documentation>Color tint.</xs:documentation></xs:annotation>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
<xs:element name="Visible" type="t:bool" minOccurs="0">
|
<xs:element name="Visible" type="t:bool" minOccurs="0">
|
||||||
<xs:annotation><xs:documentation>Whether the model is visible or not</xs:documentation></xs:annotation>
|
<xs:annotation><xs:documentation>Whether the model is visible or not</xs:documentation></xs:annotation>
|
||||||
@@ -24,6 +27,18 @@
|
|||||||
<xs:element name="DepthSort" type="t:bool" minOccurs="0">
|
<xs:element name="DepthSort" type="t:bool" minOccurs="0">
|
||||||
<xs:annotation><xs:documentation>Whether the sprite should be sorted with depth or not. Only use false for textures that are on HUD</xs:documentation></xs:annotation>
|
<xs:annotation><xs:documentation>Whether the sprite should be sorted with depth or not. Only use false for textures that are on HUD</xs:documentation></xs:annotation>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
<xs:element name="KeepRatioX" type="t:bool" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>Wether the sprite should repeat in x instead of stretch when scaled.</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name="KeepRatioY" type="t:bool" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>Wether the sprite should repeat in y instead of stretch when scaled.</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name="KeepRatio" type="t:bool" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>Keep a 1:1 ratio between X and Y.</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
<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: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>
|
||||||
|
|||||||
+3653
-3653
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@
|
|||||||
</c:RaptorCopter>
|
</c:RaptorCopter>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="-4" Z="0"/>
|
<Position X="0" Y="-4" Z="0"/>
|
||||||
<Orientation X="0" Y="55.3495064" Z="0"/>
|
<Orientation X="0" Y="58.3794823" Z="0"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
|
|
||||||
@@ -34,13 +34,49 @@
|
|||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children>
|
<Children>
|
||||||
|
<Entity name="AssaultClassPick">
|
||||||
|
<Components>
|
||||||
|
<c:Button/>
|
||||||
|
<c:Sprite>
|
||||||
|
<DepthSort>false</DepthSort>
|
||||||
|
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
<DiffuseTexture>Textures/Icons/Classes/Assault-01.png</DiffuseTexture>
|
||||||
|
</c:Sprite>
|
||||||
|
<c:InputCmdButton>
|
||||||
|
<Command>PickClass</Command>
|
||||||
|
<PressValue>1</PressValue>
|
||||||
|
</c:InputCmdButton>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="-0.150000006" Y="-0.0500000007" Z="0"/>
|
||||||
|
<Scale X="0.0799999982" Y="0.0799999982" Z="1"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity name="AssaultText">
|
||||||
|
<Components>
|
||||||
|
<c:Text>
|
||||||
|
<Content>Assault</Content>
|
||||||
|
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||||
|
<Color A="1" B="0" G="1" R="0.784313738"/>
|
||||||
|
</c:Text>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0.800000012" Z="0"/>
|
||||||
|
<Scale X="0.310000002" Y="0.310000002" Z="1"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
<Entity name="DefenderClassPick">
|
<Entity name="DefenderClassPick">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Button/>
|
<c:Button/>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Icons/Classes/Defender-01.png</DiffuseTexture>
|
|
||||||
<GlowMap></GlowMap>
|
|
||||||
<DepthSort>false</DepthSort>
|
<DepthSort>false</DepthSort>
|
||||||
|
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
<DiffuseTexture>Textures/Icons/Classes/Defender-01.png</DiffuseTexture>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:InputCmdButton>
|
<c:InputCmdButton>
|
||||||
<Command>PickClass</Command>
|
<Command>PickClass</Command>
|
||||||
@@ -72,9 +108,10 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Button/>
|
<c:Button/>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Icons/Classes/Sniper-01.png</DiffuseTexture>
|
|
||||||
<GlowMap></GlowMap>
|
|
||||||
<DepthSort>false</DepthSort>
|
<DepthSort>false</DepthSort>
|
||||||
|
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
<DiffuseTexture>Textures/Icons/Classes/Sniper-01.png</DiffuseTexture>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:InputCmdButton>
|
<c:InputCmdButton>
|
||||||
<Command>PickClass</Command>
|
<Command>PickClass</Command>
|
||||||
@@ -102,40 +139,6 @@
|
|||||||
</Entity>
|
</Entity>
|
||||||
</Children>
|
</Children>
|
||||||
</Entity>
|
</Entity>
|
||||||
<Entity name="AssaultClassPick">
|
|
||||||
<Components>
|
|
||||||
<c:Button/>
|
|
||||||
<c:Sprite>
|
|
||||||
<DiffuseTexture>Textures/Icons/Classes/Assault-01.png</DiffuseTexture>
|
|
||||||
<GlowMap></GlowMap>
|
|
||||||
<DepthSort>false</DepthSort>
|
|
||||||
</c:Sprite>
|
|
||||||
<c:InputCmdButton>
|
|
||||||
<Command>PickClass</Command>
|
|
||||||
<PressValue>1</PressValue>
|
|
||||||
</c:InputCmdButton>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="-0.150000006" Y="-0.0500000007" Z="0"/>
|
|
||||||
<Scale X="0.0799999982" Y="0.0799999982" Z="1"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children>
|
|
||||||
<Entity name="AssaultText">
|
|
||||||
<Components>
|
|
||||||
<c:Text>
|
|
||||||
<Content>Assault</Content>
|
|
||||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
|
||||||
<Color A="1" B="0" G="1" R="0.784313738"/>
|
|
||||||
</c:Text>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="0" Y="0.800000012" Z="0"/>
|
|
||||||
<Scale X="0.310000002" Y="0.310000002" Z="1"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children/>
|
|
||||||
</Entity>
|
|
||||||
</Children>
|
|
||||||
</Entity>
|
|
||||||
<Entity name="ClassPickText">
|
<Entity name="ClassPickText">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Text>
|
<c:Text>
|
||||||
@@ -154,9 +157,10 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Button/>
|
<c:Button/>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
|
||||||
<GlowMap></GlowMap>
|
|
||||||
<DepthSort>false</DepthSort>
|
<DepthSort>false</DepthSort>
|
||||||
|
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
<Color A="1" B="0" G="1" R="0.509803951"/>
|
<Color A="1" B="0" G="1" R="0.509803951"/>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:InputCmdButton>
|
<c:InputCmdButton>
|
||||||
@@ -232,9 +236,10 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Button/>
|
<c:Button/>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
|
||||||
<GlowMap></GlowMap>
|
|
||||||
<DepthSort>false</DepthSort>
|
<DepthSort>false</DepthSort>
|
||||||
|
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
<Color A="1" B="0" G="1" R="0.509803951"/>
|
<Color A="1" B="0" G="1" R="0.509803951"/>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:InputCmdButton>
|
<c:InputCmdButton>
|
||||||
@@ -266,10 +271,11 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Button/>
|
<c:Button/>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||||
<GlowMap></GlowMap>
|
<GlowMap></GlowMap>
|
||||||
<DepthSort>false</DepthSort>
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
<Color A="1" B="0" G="0.294117659" R="0.980392158"/>
|
<Color A="1" B="0" G="0.294117659" R="0.980392158"/>
|
||||||
|
<Linear>true</Linear>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:InputCmdButton>
|
<c:InputCmdButton>
|
||||||
<Command>PickTeam</Command>
|
<Command>PickTeam</Command>
|
||||||
@@ -300,10 +306,12 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Button/>
|
<c:Button/>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
|
||||||
<GlowMap></GlowMap>
|
|
||||||
<DepthSort>false</DepthSort>
|
<DepthSort>false</DepthSort>
|
||||||
|
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
<Color A="1" B="0.980392158" G="0.294117659" R="0"/>
|
<Color A="1" B="0.980392158" G="0.294117659" R="0"/>
|
||||||
|
<Linear>true</Linear>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:InputCmdButton>
|
<c:InputCmdButton>
|
||||||
<Command>PickTeam</Command>
|
<Command>PickTeam</Command>
|
||||||
@@ -334,9 +342,10 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Button/>
|
<c:Button/>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
|
||||||
<GlowMap></GlowMap>
|
|
||||||
<DepthSort>false</DepthSort>
|
<DepthSort>false</DepthSort>
|
||||||
|
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
<Color A="1" B="0" G="1" R="0.509803951"/>
|
<Color A="1" B="0" G="1" R="0.509803951"/>
|
||||||
<Visible>false</Visible>
|
<Visible>false</Visible>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
@@ -422,9 +431,10 @@
|
|||||||
<Entity name="BackgroundHexagon">
|
<Entity name="BackgroundHexagon">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
|
||||||
<GlowMap></GlowMap>
|
|
||||||
<DepthSort>false</DepthSort>
|
<DepthSort>false</DepthSort>
|
||||||
|
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
<Color A="0.300000012" B="1" G="1" R="1"/>
|
<Color A="0.300000012" B="1" G="1" R="1"/>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
@@ -441,9 +451,10 @@
|
|||||||
<CapturePointNumber>3</CapturePointNumber>
|
<CapturePointNumber>3</CapturePointNumber>
|
||||||
</c:CapturePointHUD>
|
</c:CapturePointHUD>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
|
||||||
<GlowMap></GlowMap>
|
|
||||||
<DepthSort>false</DepthSort>
|
<DepthSort>false</DepthSort>
|
||||||
|
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="0" Z="0.00999999978"/>
|
<Position X="0" Y="0" Z="0.00999999978"/>
|
||||||
@@ -458,9 +469,10 @@
|
|||||||
<Entity name="BackgroundHexagon">
|
<Entity name="BackgroundHexagon">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
|
||||||
<GlowMap></GlowMap>
|
|
||||||
<DepthSort>false</DepthSort>
|
<DepthSort>false</DepthSort>
|
||||||
|
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
<Color A="0.699999988" B="1" G="0.200000003" R="0"/>
|
<Color A="0.699999988" B="1" G="0.200000003" R="0"/>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
@@ -477,9 +489,10 @@
|
|||||||
<CapturePointNumber>4</CapturePointNumber>
|
<CapturePointNumber>4</CapturePointNumber>
|
||||||
</c:CapturePointHUD>
|
</c:CapturePointHUD>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
|
||||||
<GlowMap></GlowMap>
|
|
||||||
<DepthSort>false</DepthSort>
|
<DepthSort>false</DepthSort>
|
||||||
|
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="0" Z="0.00999999978"/>
|
<Position X="0" Y="0" Z="0.00999999978"/>
|
||||||
@@ -494,9 +507,10 @@
|
|||||||
<Entity name="BackgroundHexagon">
|
<Entity name="BackgroundHexagon">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
|
||||||
<GlowMap></GlowMap>
|
|
||||||
<DepthSort>false</DepthSort>
|
<DepthSort>false</DepthSort>
|
||||||
|
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
<Color A="0.300000012" B="1" G="1" R="1"/>
|
<Color A="0.300000012" B="1" G="1" R="1"/>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
@@ -513,9 +527,10 @@
|
|||||||
<CapturePointNumber>2</CapturePointNumber>
|
<CapturePointNumber>2</CapturePointNumber>
|
||||||
</c:CapturePointHUD>
|
</c:CapturePointHUD>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
|
||||||
<GlowMap></GlowMap>
|
|
||||||
<DepthSort>false</DepthSort>
|
<DepthSort>false</DepthSort>
|
||||||
|
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="0" Z="0.00999999978"/>
|
<Position X="0" Y="0" Z="0.00999999978"/>
|
||||||
@@ -530,9 +545,10 @@
|
|||||||
<Entity name="BackgroundHexagon">
|
<Entity name="BackgroundHexagon">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
|
||||||
<GlowMap></GlowMap>
|
|
||||||
<DepthSort>false</DepthSort>
|
<DepthSort>false</DepthSort>
|
||||||
|
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
<Color A="0.300000012" B="1" G="1" R="1"/>
|
<Color A="0.300000012" B="1" G="1" R="1"/>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
@@ -550,9 +566,10 @@
|
|||||||
<CapturePointNumber>1</CapturePointNumber>
|
<CapturePointNumber>1</CapturePointNumber>
|
||||||
</c:CapturePointHUD>
|
</c:CapturePointHUD>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
|
||||||
<GlowMap></GlowMap>
|
|
||||||
<DepthSort>false</DepthSort>
|
<DepthSort>false</DepthSort>
|
||||||
|
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="0" Z="0.00999999978"/>
|
<Position X="0" Y="0" Z="0.00999999978"/>
|
||||||
@@ -567,9 +584,10 @@
|
|||||||
<Entity name="BackgroundHexagon">
|
<Entity name="BackgroundHexagon">
|
||||||
<Components>
|
<Components>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
|
||||||
<GlowMap></GlowMap>
|
|
||||||
<DepthSort>false</DepthSort>
|
<DepthSort>false</DepthSort>
|
||||||
|
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
<Color A="0.699999988" B="0" G="0" R="1"/>
|
<Color A="0.699999988" B="0" G="0" R="1"/>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
@@ -584,9 +602,10 @@
|
|||||||
</c:Fill>
|
</c:Fill>
|
||||||
<c:CapturePointHUD/>
|
<c:CapturePointHUD/>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
|
||||||
<GlowMap></GlowMap>
|
|
||||||
<DepthSort>false</DepthSort>
|
<DepthSort>false</DepthSort>
|
||||||
|
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="0" Z="0.00999999978"/>
|
<Position X="0" Y="0" Z="0.00999999978"/>
|
||||||
@@ -604,9 +623,10 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Button/>
|
<c:Button/>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
|
||||||
<GlowMap></GlowMap>
|
|
||||||
<DepthSort>false</DepthSort>
|
<DepthSort>false</DepthSort>
|
||||||
|
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
<Color A="1" B="0" G="1" R="0.509803951"/>
|
<Color A="1" B="0" G="1" R="0.509803951"/>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:InputCmdButton>
|
<c:InputCmdButton>
|
||||||
@@ -651,9 +671,10 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Button/>
|
<c:Button/>
|
||||||
<c:Sprite>
|
<c:Sprite>
|
||||||
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
|
||||||
<GlowMap></GlowMap>
|
|
||||||
<DepthSort>false</DepthSort>
|
<DepthSort>false</DepthSort>
|
||||||
|
<Model>Models/Core/UnitQuad.mesh</Model>
|
||||||
|
<GlowMap></GlowMap>
|
||||||
|
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
|
||||||
<Color A="1" B="0" G="1" R="0.509803951"/>
|
<Color A="1" B="0" G="1" R="0.509803951"/>
|
||||||
</c:Sprite>
|
</c:Sprite>
|
||||||
<c:InputCmdButton>
|
<c:InputCmdButton>
|
||||||
|
|||||||
@@ -99,7 +99,7 @@
|
|||||||
</c:Team>
|
</c:Team>
|
||||||
<c:PlayerSpawn/>
|
<c:PlayerSpawn/>
|
||||||
<c:Spawner>
|
<c:Spawner>
|
||||||
<EntityFile>Schema/Entities/Player.xml</EntityFile>
|
<EntityFile>Schema/Entities/PlayerRed.xml</EntityFile>
|
||||||
</c:Spawner>
|
</c:Spawner>
|
||||||
<c:Transform/>
|
<c:Transform/>
|
||||||
</Components>
|
</Components>
|
||||||
@@ -225,6 +225,11 @@
|
|||||||
</Team>
|
</Team>
|
||||||
</c:Team>
|
</c:Team>
|
||||||
<c:Trigger/>
|
<c:Trigger/>
|
||||||
|
<c:Model>
|
||||||
|
<Resource></Resource>
|
||||||
|
<Color A="0.300000012" B="0" G="0" R="1"/>
|
||||||
|
<Visible>false</Visible>
|
||||||
|
</c:Model>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="0" Z="-4.10000038"/>
|
<Position X="0" Y="0" Z="-4.10000038"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
@@ -239,7 +244,17 @@
|
|||||||
<Scale X="2.70000005" Y="3.4000001" Z="4.60000038"/>
|
<Scale X="2.70000005" Y="3.4000001" Z="4.60000038"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children/>
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Model>
|
||||||
|
<Resource></Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Transform/>
|
||||||
|
</Components>
|
||||||
|
<Children/>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
</Entity>
|
</Entity>
|
||||||
<Entity name="Blue">
|
<Entity name="Blue">
|
||||||
<Components>
|
<Components>
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
layout (binding = 0) uniform sampler2D Texture;
|
||||||
|
uniform int MaxMipMap;
|
||||||
|
|
||||||
|
|
||||||
|
in VertexData{
|
||||||
|
vec2 TextureCoordinate;
|
||||||
|
}Input;
|
||||||
|
|
||||||
|
out vec4 fragmentColor;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec4 result = vec4(0.0, 0.0, 0.0, 0.0);
|
||||||
|
|
||||||
|
for(int i = 0; i < MaxMipMap; i++) {
|
||||||
|
result += textureLod(Texture, Input.TextureCoordinate, i);
|
||||||
|
}
|
||||||
|
fragmentColor = result;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
layout (location = 0) in vec3 Position;
|
||||||
|
|
||||||
|
out VertexData{
|
||||||
|
vec2 TextureCoordinate;
|
||||||
|
}Output;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = vec4(Position, 1.0);
|
||||||
|
Output.TextureCoordinate = (vec2(Position) + 1) / 2;
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
#extension GL_EXT_gpu_shader4 : enable
|
#extension GL_EXT_gpu_shader4 : enable
|
||||||
|
|
||||||
layout (binding = 0) uniform sampler2D Texture;
|
layout (binding = 0) uniform sampler2D Texture;
|
||||||
|
uniform int Lod;
|
||||||
|
|
||||||
in VertexData{
|
in VertexData{
|
||||||
vec2 TextureCoordinate;
|
vec2 TextureCoordinate;
|
||||||
@@ -10,12 +11,14 @@ in VertexData{
|
|||||||
out vec4 fragmentColor;
|
out vec4 fragmentColor;
|
||||||
|
|
||||||
uniform float weight[5] = float[](0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);
|
uniform float weight[5] = float[](0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);
|
||||||
|
//uniform float weight[3] = float[](0.265495, 0.226535, 0.140718);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec2 tex_offset = 1.0 / textureSize2D(Texture, 0);
|
vec2 tex_offset = 1.0 / textureSize(Texture, Lod);
|
||||||
vec3 center = texture(Texture, Input.TextureCoordinate).rgb;
|
vec3 center = texture(Texture, Input.TextureCoordinate).rgb;
|
||||||
vec3 result = center * weight[0];
|
vec3 result = center * weight[0];
|
||||||
|
|
||||||
for(int i = 1; i < 5; ++i) {
|
for(int i = 1; i < 5; ++i) {
|
||||||
vec4 eastFragments = texture(Texture, Input.TextureCoordinate + vec2(tex_offset.x * i, 0.0));
|
vec4 eastFragments = texture(Texture, Input.TextureCoordinate + vec2(tex_offset.x * i, 0.0));
|
||||||
vec4 westFragments = texture(Texture, Input.TextureCoordinate - vec2(tex_offset.x * i, 0.0));
|
vec4 westFragments = texture(Texture, Input.TextureCoordinate - vec2(tex_offset.x * i, 0.0));
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#extension GL_EXT_gpu_shader4 : enable
|
#extension GL_EXT_gpu_shader4 : enable
|
||||||
|
|
||||||
layout (binding = 0) uniform sampler2D Texture;
|
layout (binding = 0) uniform sampler2D Texture;
|
||||||
|
uniform int Lod;
|
||||||
|
|
||||||
in VertexData{
|
in VertexData{
|
||||||
vec2 TextureCoordinate;
|
vec2 TextureCoordinate;
|
||||||
@@ -10,12 +11,14 @@ in VertexData{
|
|||||||
out vec4 fragmentColor;
|
out vec4 fragmentColor;
|
||||||
|
|
||||||
uniform float weight[5] = float[](0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);
|
uniform float weight[5] = float[](0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);
|
||||||
|
//uniform float weight[3] = float[](0.265495, 0.226535, 0.140718);
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec2 tex_offset = 1.0 / textureSize2D(Texture, 0);
|
vec2 tex_offset = 1.0 / textureSize(Texture, Lod);
|
||||||
vec3 center = texture(Texture, Input.TextureCoordinate).rgb;
|
vec3 center = texture(Texture, Input.TextureCoordinate).rgb;
|
||||||
vec3 result = center * weight[0];
|
vec3 result = center * weight[0];
|
||||||
|
|
||||||
for(int i = 1; i < 5; ++i) {
|
for(int i = 1; i < 5; ++i) {
|
||||||
vec4 northFragments = texture(Texture, Input.TextureCoordinate + vec2(0.0, tex_offset.y * i));
|
vec4 northFragments = texture(Texture, Input.TextureCoordinate + vec2(0.0, tex_offset.y * i));
|
||||||
vec4 southFragments = texture(Texture, Input.TextureCoordinate - vec2(0.0, tex_offset.y * i));
|
vec4 southFragments = texture(Texture, Input.TextureCoordinate - vec2(0.0, tex_offset.y * i));
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
uniform mat4 M;
|
||||||
|
uniform mat4 V;
|
||||||
|
uniform mat4 P;
|
||||||
|
uniform mat4 Bones[100];
|
||||||
|
|
||||||
|
layout (location = 0) in vec3 Position;
|
||||||
|
layout (location = 4) in vec2 TextureCoords;
|
||||||
|
layout(location = 5) in vec4 BoneIndices;
|
||||||
|
layout(location = 6) in vec4 BoneWeights;
|
||||||
|
|
||||||
|
out VertexData{
|
||||||
|
vec2 TextureCoordinate;
|
||||||
|
}Output;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
mat4 boneTransform = mat4(1);
|
||||||
|
if(BoneWeights[0] > 0.0f){
|
||||||
|
boneTransform = BoneWeights[0] * Bones[int(BoneIndices[0])]
|
||||||
|
+ BoneWeights[1] * Bones[int(BoneIndices[1])]
|
||||||
|
+ BoneWeights[2] * Bones[int(BoneIndices[2])]
|
||||||
|
+ BoneWeights[3] * Bones[int(BoneIndices[3])];
|
||||||
|
}
|
||||||
|
|
||||||
|
gl_Position = P * V * M * boneTransform * vec4(Position, 1.0);
|
||||||
|
Output.TextureCoordinate = TextureCoords;
|
||||||
|
}
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
uniform vec4 Color;
|
uniform vec4 Color;
|
||||||
uniform vec4 FillColor;
|
uniform vec4 FillColor;
|
||||||
uniform float FillPercentage;
|
uniform float FillPercentage;
|
||||||
|
uniform float ScaleX;
|
||||||
|
uniform float ScaleY;
|
||||||
uniform mat4 P;
|
uniform mat4 P;
|
||||||
|
|
||||||
layout (binding = 1) uniform sampler2D DiffuseTexture;
|
layout (binding = 1) uniform sampler2D DiffuseTexture;
|
||||||
@@ -21,15 +23,16 @@ out vec4 bloomColor;
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate);
|
vec4 diffuseTexel = texture2D(DiffuseTexture, vec2(Input.TextureCoordinate.x*ScaleX, Input.TextureCoordinate.y*ScaleY));
|
||||||
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate);
|
vec4 glowTexel = texture2D(GlowMapTexture, vec2(Input.TextureCoordinate.x*ScaleX, Input.TextureCoordinate.y*ScaleY));
|
||||||
|
|
||||||
vec4 color_result = Color * diffuseTexel;
|
vec4 color_result = Color * diffuseTexel;
|
||||||
|
|
||||||
float pos = ((P * vec4(Input.Position, 1)).y + 1.0)/2.0;
|
float pos = ((P * vec4(Input.Position, 1)).y + 1.0)/2.0;
|
||||||
if(pos <= FillPercentage) {
|
float fillResult = floor(pos*FillPercentage);
|
||||||
color_result = FillColor*diffuseTexel.a;
|
|
||||||
}
|
color_result = FillColor*diffuseTexel.a*fillResult + color_result*(1-fillResult);
|
||||||
|
|
||||||
sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1));
|
sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1));
|
||||||
|
|
||||||
//bloomColor = vec4(clamp((glowTexel.xyz*3) - 1.0, 0, 100), 1.0);
|
//bloomColor = vec4(clamp((glowTexel.xyz*3) - 1.0, 0, 100), 1.0);
|
||||||
|
|||||||
@@ -360,7 +360,14 @@ constexpr bool FaceIsGround(float faceNormalY)
|
|||||||
//An array containing 3 int pairs { 0, 2 }, { 0, 1 }, { 1, 2 }
|
//An array containing 3 int pairs { 0, 2 }, { 0, 1 }, { 1, 2 }
|
||||||
constexpr std::array<std::pair<int, int>, 3> dimensionPairs({ std::pair<int, int>(0, 2), std::pair<int, int>(0, 1), std::pair<int, int>(1, 2) });
|
constexpr std::array<std::pair<int, int>, 3> dimensionPairs({ std::pair<int, int>(0, 2), std::pair<int, int>(0, 1), std::pair<int, int>(1, 2) });
|
||||||
|
|
||||||
bool AABBvsTriangle(const AABB& box,
|
enum class BoxTriRes
|
||||||
|
{
|
||||||
|
Front,
|
||||||
|
Behind,
|
||||||
|
Intersect
|
||||||
|
};
|
||||||
|
|
||||||
|
BoxTriRes AABBvsTriangle(const AABB& box,
|
||||||
const std::array<glm::vec3, 3>& triPos,
|
const std::array<glm::vec3, 3>& triPos,
|
||||||
const glm::vec3& originalBoxVelocity,
|
const glm::vec3& originalBoxVelocity,
|
||||||
float verticalStepHeight,
|
float verticalStepHeight,
|
||||||
@@ -374,7 +381,7 @@ bool AABBvsTriangle(const AABB& box,
|
|||||||
//Less checks, and we should be able to walk out from models if we are trapped inside.
|
//Less checks, and we should be able to walk out from models if we are trapped inside.
|
||||||
glm::vec3 triNormal = glm::cross(triPos[1] - triPos[0], triPos[2] - triPos[0]);
|
glm::vec3 triNormal = glm::cross(triPos[1] - triPos[0], triPos[2] - triPos[0]);
|
||||||
if (!vectorHasLength(triNormal) || (glm::dot(triNormal, originalBoxVelocity) > 0)) {
|
if (!vectorHasLength(triNormal) || (glm::dot(triNormal, originalBoxVelocity) > 0)) {
|
||||||
return false;
|
return BoxTriRes::Behind;
|
||||||
}
|
}
|
||||||
triNormal = glm::normalize(triNormal);
|
triNormal = glm::normalize(triNormal);
|
||||||
|
|
||||||
@@ -409,6 +416,9 @@ bool AABBvsTriangle(const AABB& box,
|
|||||||
const glm::vec3& min = box.MinCorner();
|
const glm::vec3& min = box.MinCorner();
|
||||||
const glm::vec3& max = box.MaxCorner();
|
const glm::vec3& max = box.MaxCorner();
|
||||||
|
|
||||||
|
// If there is no intersection, whether the box center is in front of or behind the triangle.
|
||||||
|
BoxTriRes noIntersection = glm::dot(triNormal, origin - triPos[0]) > 0 ? BoxTriRes::Front : BoxTriRes::Behind;
|
||||||
|
|
||||||
//For each projection in xy-, xz-, and yx-planes.
|
//For each projection in xy-, xz-, and yx-planes.
|
||||||
for (std::pair<int, int> dim : dimensionPairs) {
|
for (std::pair<int, int> dim : dimensionPairs) {
|
||||||
//2D Triangle.
|
//2D Triangle.
|
||||||
@@ -426,7 +436,7 @@ bool AABBvsTriangle(const AABB& box,
|
|||||||
bool pushedFromTriangleLine;
|
bool pushedFromTriangleLine;
|
||||||
//if projections don't overlap, return false.
|
//if projections don't overlap, return false.
|
||||||
if (!rectangleVsTriangle(boxMin, boxMax, t2D, resolutionVector, resolutionDist, pushedFromTriangleLine)) {
|
if (!rectangleVsTriangle(boxMin, boxMax, t2D, resolutionVector, resolutionDist, pushedFromTriangleLine)) {
|
||||||
return false;
|
return noIntersection;
|
||||||
} else if (resolveCollision) {
|
} else if (resolveCollision) {
|
||||||
//Overwrite the smallest resolution if this is smaller.
|
//Overwrite the smallest resolution if this is smaller.
|
||||||
if (resolutionDist < resolveShortest.DistanceSq) {
|
if (resolutionDist < resolveShortest.DistanceSq) {
|
||||||
@@ -462,11 +472,11 @@ bool AABBvsTriangle(const AABB& box,
|
|||||||
float t = glm::dot(triNormal, triPos[0] - origin) / glm::dot(triNormal, diagonal);
|
float t = glm::dot(triNormal, triPos[0] - origin) / glm::dot(triNormal, diagonal);
|
||||||
//If intersection point between plane and diagonal is within the box.
|
//If intersection point between plane and diagonal is within the box.
|
||||||
if (glm::abs(t) > 1) {
|
if (glm::abs(t) > 1) {
|
||||||
return false;
|
return noIntersection;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!resolveCollision) {
|
if (!resolveCollision) {
|
||||||
return true;
|
return BoxTriRes::Intersect;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 cornerResolution = (1+t) * diagonal;
|
glm::vec3 cornerResolution = (1+t) * diagonal;
|
||||||
@@ -499,7 +509,7 @@ bool AABBvsTriangle(const AABB& box,
|
|||||||
case ResolveDimZ:
|
case ResolveDimZ:
|
||||||
//If we get here, the resolution is along one coordinate axis.
|
//If we get here, the resolution is along one coordinate axis.
|
||||||
//set velocity to 0 in y if it is along y-axis.
|
//set velocity to 0 in y if it is along y-axis.
|
||||||
return true;
|
return BoxTriRes::Intersect;
|
||||||
case Line:
|
case Line:
|
||||||
projNorm = glm::normalize(outResolution);
|
projNorm = glm::normalize(outResolution);
|
||||||
break;
|
break;
|
||||||
@@ -534,10 +544,10 @@ bool AABBvsTriangle(const AABB& box,
|
|||||||
boxVelocity = boxVelocity - glm::dot(boxVelocity, projNorm) * projNorm;
|
boxVelocity = boxVelocity - glm::dot(boxVelocity, projNorm) * projNorm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return BoxTriRes::Intersect;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AABBvsTriangles(const AABB& box,
|
Output AABBvsTriangles(const AABB& box,
|
||||||
const RawModel::Vertex* 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,
|
||||||
@@ -547,8 +557,8 @@ bool AABBvsTriangles(const AABB& box,
|
|||||||
glm::vec3& outResolutionVector,
|
glm::vec3& outResolutionVector,
|
||||||
bool resolveCollision)
|
bool resolveCollision)
|
||||||
{
|
{
|
||||||
bool hit = false;
|
bool intersect = false;
|
||||||
|
Output out = Output::OutContained;
|
||||||
bool everHitTheGround = false;
|
bool everHitTheGround = false;
|
||||||
AABB newBox = box;
|
AABB newBox = box;
|
||||||
outResolutionVector = glm::vec3(0.f);
|
outResolutionVector = glm::vec3(0.f);
|
||||||
@@ -561,20 +571,27 @@ bool AABBvsTriangles(const AABB& box,
|
|||||||
};
|
};
|
||||||
glm::vec3 outVec;
|
glm::vec3 outVec;
|
||||||
bool collideWithGround = isOnGround;
|
bool collideWithGround = isOnGround;
|
||||||
if (AABBvsTriangle(newBox, triVertices, originalBoxVelocity, verticalStepHeight, collideWithGround, boxVelocity, outVec, resolveCollision)) {
|
switch (AABBvsTriangle(newBox, triVertices, originalBoxVelocity, verticalStepHeight, collideWithGround, boxVelocity, outVec, resolveCollision)) {
|
||||||
hit = true;
|
case Collision::BoxTriRes::Front:
|
||||||
|
out = Output::OutSeparated;
|
||||||
|
break;
|
||||||
|
case Collision::BoxTriRes::Intersect:
|
||||||
|
intersect = true;
|
||||||
outResolutionVector += outVec;
|
outResolutionVector += outVec;
|
||||||
newBox = AABB::FromOriginSize(newBox.Origin() + outVec, newBox.Size());
|
newBox = AABB::FromOriginSize(newBox.Origin() + outVec, newBox.Size());
|
||||||
if (collideWithGround) {
|
if (collideWithGround) {
|
||||||
everHitTheGround = isOnGround = true;
|
everHitTheGround = isOnGround = true;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!everHitTheGround) {
|
if (!everHitTheGround) {
|
||||||
isOnGround = false;
|
isOnGround = false;
|
||||||
}
|
}
|
||||||
return hit;
|
return intersect ? Output::OutIntersecting : out;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AABBvsTriangles(const AABB& box,
|
bool AABBvsTriangles(const AABB& box,
|
||||||
@@ -594,13 +611,31 @@ bool AABBvsTriangles(const AABB& box,
|
|||||||
verticalStepHeight,
|
verticalStepHeight,
|
||||||
isOnGround,
|
isOnGround,
|
||||||
outResolutionVector,
|
outResolutionVector,
|
||||||
true);
|
true) == Output::OutIntersecting;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AABBvsTriangles(const AABB& box,
|
bool AABBvsTriangles(const AABB& box,
|
||||||
const RawModel::Vertex* 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 vel, outres;
|
||||||
|
bool g;
|
||||||
|
return AABBvsTriangles(box,
|
||||||
|
modelVertices,
|
||||||
|
modelIndices,
|
||||||
|
modelMatrix,
|
||||||
|
vel,
|
||||||
|
0.f,
|
||||||
|
g,
|
||||||
|
outres,
|
||||||
|
false) == Output::OutIntersecting;
|
||||||
|
}
|
||||||
|
|
||||||
|
Output AABBvsTrianglesWContainment(const AABB& box,
|
||||||
|
const RawModel::Vertex* modelVertices,
|
||||||
|
const std::vector<unsigned int>& modelIndices,
|
||||||
|
const glm::mat4& modelMatrix)
|
||||||
{
|
{
|
||||||
glm::vec3 vel, outres;
|
glm::vec3 vel, outres;
|
||||||
bool g;
|
bool g;
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
|
|||||||
bool hit;
|
bool hit;
|
||||||
float dist;
|
float dist;
|
||||||
if (boxB.Entity.HasComponent("Model")) {
|
if (boxB.Entity.HasComponent("Model")) {
|
||||||
|
if (!((bool)boxB.Entity["Model"]["Visible"])) {
|
||||||
|
// Don't collide against invisible models.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
RawModel* model;
|
RawModel* model;
|
||||||
std::string res = (std::string)boxB.Entity["Model"]["Resource"];
|
std::string res = (std::string)boxB.Entity["Model"]["Resource"];
|
||||||
try {
|
try {
|
||||||
@@ -77,7 +81,11 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (boxB.Entity.HasComponent("Model") && Collision::AABBVsAABB(boxA, boxB)) {
|
if (boxB.Entity.HasComponent("Model") && Collision::AABBVsAABB(boxA, boxB)) {
|
||||||
//Here we know boxB is a entity with Collideable, AABB, and Model.
|
// Here we know boxB is a entity with Collideable, AABB, and Model.
|
||||||
|
if (!((bool)boxB.Entity["Model"]["Visible"])) {
|
||||||
|
// Don't collide against invisible models.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
RawModel* model;
|
RawModel* model;
|
||||||
try {
|
try {
|
||||||
model = ResourceManager::Load<RawModel, true>(boxB.Entity["Model"]["Resource"]);
|
model = ResourceManager::Load<RawModel, true>(boxB.Entity["Model"]["Resource"]);
|
||||||
|
|||||||
@@ -10,6 +10,16 @@ void TriggerSystem::UpdateComponent(EntityWrapper& triggerEntity, ComponentWrapp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RawModel* triggerModel = nullptr;
|
||||||
|
glm::mat4 triggerModelMat;
|
||||||
|
if (triggerEntity.HasComponent("Model")) {
|
||||||
|
try {
|
||||||
|
triggerModel = ResourceManager::Load<RawModel, true>(triggerEntity["Model"]["Resource"]);
|
||||||
|
triggerModelMat = Transform::ModelMatrix(triggerEntity);
|
||||||
|
} catch (const std::exception&) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_OctreeOut.clear();
|
m_OctreeOut.clear();
|
||||||
m_Octree->ObjectsInSameRegion(*triggerBox, m_OctreeOut);
|
m_Octree->ObjectsInSameRegion(*triggerBox, m_OctreeOut);
|
||||||
|
|
||||||
@@ -22,7 +32,17 @@ void TriggerSystem::UpdateComponent(EntityWrapper& triggerEntity, ComponentWrapp
|
|||||||
if (colliderFitsInTrigger) {
|
if (colliderFitsInTrigger) {
|
||||||
completelyInsideBox = AABB::FromOriginSize((*triggerBox).Origin(), (*triggerBox).Size() - 2.0f * colliderBox.Size());
|
completelyInsideBox = AABB::FromOriginSize((*triggerBox).Origin(), (*triggerBox).Size() - 2.0f * colliderBox.Size());
|
||||||
}
|
}
|
||||||
if (colliderFitsInTrigger && Collision::AABBVsAABB(completelyInsideBox, colliderBox)) {
|
|
||||||
|
// We know the entity is inside the trigger box, but perhaps not the model yet.
|
||||||
|
Collision::Output out = triggerModel == nullptr
|
||||||
|
? Collision::Output::OutContained
|
||||||
|
: Collision::AABBvsTrianglesWContainment(
|
||||||
|
colliderBox,
|
||||||
|
triggerModel->Vertices(),
|
||||||
|
triggerModel->m_Indices,
|
||||||
|
triggerModelMat);
|
||||||
|
|
||||||
|
if (colliderFitsInTrigger && Collision::AABBVsAABB(completelyInsideBox, colliderBox) && out == Collision::Output::OutContained) {
|
||||||
// Entity is completely inside the trigger.
|
// Entity is completely inside the trigger.
|
||||||
// If it was only touching before, it is erased.
|
// If it was only touching before, it is erased.
|
||||||
m_EntitiesTouchingTrigger[triggerEntity].erase(colliderEntity);
|
m_EntitiesTouchingTrigger[triggerEntity].erase(colliderEntity);
|
||||||
@@ -32,7 +52,8 @@ void TriggerSystem::UpdateComponent(EntityWrapper& triggerEntity, ComponentWrapp
|
|||||||
completeSet.insert(colliderEntity);
|
completeSet.insert(colliderEntity);
|
||||||
publish<Events::TriggerEnter>(colliderEntity, triggerEntity);
|
publish<Events::TriggerEnter>(colliderEntity, triggerEntity);
|
||||||
}
|
}
|
||||||
} else {
|
continue;
|
||||||
|
} else if (out != Collision::Output::OutSeparated) {
|
||||||
// Entity is only touching the trigger.
|
// Entity is only touching the trigger.
|
||||||
auto& touchSet = m_EntitiesTouchingTrigger[triggerEntity];
|
auto& touchSet = m_EntitiesTouchingTrigger[triggerEntity];
|
||||||
auto& completeSet = m_EntitiesCompletelyInTrigger[triggerEntity];
|
auto& completeSet = m_EntitiesCompletelyInTrigger[triggerEntity];
|
||||||
@@ -47,17 +68,17 @@ void TriggerSystem::UpdateComponent(EntityWrapper& triggerEntity, ComponentWrapp
|
|||||||
touchSet.insert(colliderEntity);
|
touchSet.insert(colliderEntity);
|
||||||
}
|
}
|
||||||
// Else, it was touching the trigger last frame too and nothing is done.
|
// Else, it was touching the trigger last frame too and nothing is done.
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Entity is not touching the trigger,
|
|
||||||
// Throw event if it was previously.
|
|
||||||
if (throwLeaveIfWasInTrigger(m_EntitiesTouchingTrigger[triggerEntity], colliderEntity, triggerEntity)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// This only occurs if the entity was completely inside the trigger one frame,
|
|
||||||
// then completely outside the trigger, e.g. when dying and respawning.
|
|
||||||
throwLeaveIfWasInTrigger(m_EntitiesCompletelyInTrigger[triggerEntity], colliderEntity, triggerEntity);
|
|
||||||
}
|
}
|
||||||
|
// Only get here if entity is not touching the trigger,
|
||||||
|
// throw event if it was touching previously.
|
||||||
|
if (throwLeaveIfWasInTrigger(m_EntitiesTouchingTrigger[triggerEntity], colliderEntity, triggerEntity)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// This only occurs if the entity was completely inside the trigger one frame,
|
||||||
|
// then completely outside the trigger, e.g. when dying and respawning.
|
||||||
|
throwLeaveIfWasInTrigger(m_EntitiesCompletelyInTrigger[triggerEntity], colliderEntity, triggerEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ bool EditorRenderSystem::OnSetCamera(Events::SetCamera& e)
|
|||||||
{
|
{
|
||||||
ComponentWrapper cTransform = e.CameraEntity["Transform"];
|
ComponentWrapper cTransform = e.CameraEntity["Transform"];
|
||||||
ComponentWrapper cCamera = e.CameraEntity["Camera"];
|
ComponentWrapper cCamera = e.CameraEntity["Camera"];
|
||||||
m_EditorCamera->SetFOV(static_cast<float>((double)cCamera["FOV"]));
|
m_EditorCamera->SetFOV(glm::radians(static_cast<float>((double)cCamera["FOV"])));
|
||||||
m_EditorCamera->SetNearClip(static_cast<float>((double)cCamera["NearClip"]));
|
m_EditorCamera->SetNearClip(static_cast<float>((double)cCamera["NearClip"]));
|
||||||
m_EditorCamera->SetFarClip(static_cast<float>((double)cCamera["FarClip"]));
|
m_EditorCamera->SetFarClip(static_cast<float>((double)cCamera["FarClip"]));
|
||||||
m_EditorCamera->SetPosition(cTransform["Position"]);
|
m_EditorCamera->SetPosition(cTransform["Position"]);
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame
|
|||||||
Enable();
|
Enable();
|
||||||
} else {
|
} else {
|
||||||
Disable();
|
Disable();
|
||||||
|
m_EventBroker->Publish(Events::UnlockMouse());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +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)
|
||||||
@@ -50,16 +51,19 @@ void Client::Connect(std::string address, int port)
|
|||||||
void Client::Update()
|
void Client::Update()
|
||||||
{
|
{
|
||||||
m_EventBroker->Process<Client>();
|
m_EventBroker->Process<Client>();
|
||||||
//while (m_Unreliable.IsSocketAvailable()) {
|
while (m_Unreliable.IsSocketAvailable()) {
|
||||||
// // Packet will get real data in receive
|
m_Unreliable.ReceivePackets();
|
||||||
// Packet packet(MessageType::Invalid);
|
}
|
||||||
// m_Unreliable.Receive(packet);
|
// Packet will get real data in GetNextPacket()
|
||||||
// if (packet.GetMessageType() == MessageType::Connect) {
|
Packet parsedPacket(MessageType::Invalid);
|
||||||
// parseUDPConnect(packet);
|
while (m_Unreliable.GetNextPacket(parsedPacket)) {
|
||||||
// } else {
|
if (parsedPacket.GetMessageType() == MessageType::Connect) {
|
||||||
// parseMessageType(packet);
|
parseUDPConnect(parsedPacket);
|
||||||
// }
|
} else {
|
||||||
//}
|
parseMessageType(parsedPacket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (m_Reliable.IsSocketAvailable()) {
|
while (m_Reliable.IsSocketAvailable()) {
|
||||||
// Packet will get real data in receive
|
// Packet will get real data in receive
|
||||||
Packet packet(MessageType::Invalid);
|
Packet packet(MessageType::Invalid);
|
||||||
@@ -106,8 +110,9 @@ void Client::Update()
|
|||||||
|
|
||||||
void Client::parseMessageType(Packet& packet)
|
void Client::parseMessageType(Packet& packet)
|
||||||
{
|
{
|
||||||
// Pop packetSize
|
// Pop packetSize, sequenceNumber and packetsInSequence.
|
||||||
packet.ReadPrimitive<int>();
|
popNetworkSegmentOfHeader(packet);
|
||||||
|
|
||||||
int messageType = packet.ReadPrimitive<int>();
|
int messageType = packet.ReadPrimitive<int>();
|
||||||
if (messageType == -1)
|
if (messageType == -1)
|
||||||
return;
|
return;
|
||||||
@@ -162,26 +167,29 @@ void Client::parseMessageType(Packet& packet)
|
|||||||
void Client::parseUDPConnect(Packet& packet)
|
void Client::parseUDPConnect(Packet& packet)
|
||||||
{
|
{
|
||||||
// Map ServerEntityID and your PlayerID
|
// Map ServerEntityID and your PlayerID
|
||||||
|
// TODO: If this is not received send a new connect message.
|
||||||
LOG_INFO("I be connected PogChamp");
|
LOG_INFO("I be connected PogChamp");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::parseTCPConnect(Packet& packet)
|
void Client::parseTCPConnect(Packet& packet)
|
||||||
{
|
{
|
||||||
LOG_INFO("Received TCP connect from server");
|
LOG_INFO("Received TCP connect from server");
|
||||||
// Pop size of message int
|
// Pop packetSize, group, groupIndex and groupSize.
|
||||||
packet.ReadPrimitive<int>();
|
popNetworkSegmentOfHeader(packet);
|
||||||
|
|
||||||
int messageType = packet.ReadPrimitive<int>();
|
int messageType = packet.ReadPrimitive<int>();
|
||||||
// Read packet ID
|
// Read packet ID
|
||||||
m_PreviousPacketID = m_PacketID; // Set previous packet id
|
m_PreviousPacketID = m_PacketID; // Set previous packet id
|
||||||
m_PacketID = packet.ReadPrimitive<int>(); //Read new packet id
|
m_PacketID = packet.ReadPrimitive<int>(); //Read new packet id
|
||||||
// parse player id and other stuff
|
// parse player id and other stuff
|
||||||
m_PlayerID = packet.ReadPrimitive<int>();
|
m_PlayerID = packet.ReadPrimitive<int>();
|
||||||
m_PlayerID = packet.ReadPrimitive<int>();
|
|
||||||
LOG_INFO("A Player connected");
|
LOG_INFO("A Player connected");
|
||||||
|
// TODO: If this is not received send a new connect message.
|
||||||
Packet UnreliablePacket(MessageType::Connect, m_SendPacketID);
|
Packet UnreliablePacket(MessageType::Connect, m_SendPacketID);
|
||||||
// Add player id and other stuff
|
// Add player id and other stuff
|
||||||
packet.WritePrimitive(m_PlayerID);
|
packet.WritePrimitive(m_PlayerID);
|
||||||
// m_Unreliable.Send(packet);
|
m_Unreliable.Send(packet);
|
||||||
|
|
||||||
// LOG_INFO("Sent UDP Connect Server");
|
// LOG_INFO("Sent UDP Connect Server");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,10 +216,11 @@ void Client::parsePing()
|
|||||||
|
|
||||||
void Client::parseServerlist(Packet& packet)
|
void Client::parseServerlist(Packet& packet)
|
||||||
{
|
{
|
||||||
// Pop size, message type, and ID
|
// Pop packetSize, group, groupIndex and groupSize.
|
||||||
packet.ReadPrimitive<int>();
|
popNetworkSegmentOfHeader(packet);
|
||||||
packet.ReadPrimitive<int>();
|
packet.ReadPrimitive<int>();
|
||||||
packet.ReadPrimitive<int>();
|
packet.ReadPrimitive<int>();
|
||||||
|
|
||||||
std::string address = packet.ReadString();
|
std::string address = packet.ReadString();
|
||||||
int port = packet.ReadPrimitive<int>();
|
int port = packet.ReadPrimitive<int>();
|
||||||
std::string serverName = packet.ReadString();
|
std::string serverName = packet.ReadString();
|
||||||
@@ -224,7 +233,7 @@ void Client::parseServerlist(Packet& packet)
|
|||||||
void Client::parseKick()
|
void Client::parseKick()
|
||||||
{
|
{
|
||||||
LOG_WARNING("You have been kicked from the server.");
|
LOG_WARNING("You have been kicked from the server.");
|
||||||
m_IsConnected = false;
|
disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::parseSpawnEvents()
|
void Client::parseSpawnEvents()
|
||||||
@@ -463,7 +472,12 @@ void Client::disconnect()
|
|||||||
m_PacketID = 0;
|
m_PacketID = 0;
|
||||||
Packet packet(MessageType::Disconnect, m_SendPacketID);
|
Packet packet(MessageType::Disconnect, m_SendPacketID);
|
||||||
m_Reliable.Send(packet);
|
m_Reliable.Send(packet);
|
||||||
|
m_Unreliable.Disconnect();
|
||||||
m_Reliable.Disconnect();
|
m_Reliable.Disconnect();
|
||||||
|
Events::PlayerDisconnected e;
|
||||||
|
e.Entity = m_LocalPlayer.ID;
|
||||||
|
e.PlayerID = -1;
|
||||||
|
m_EventBroker->Publish(e);
|
||||||
createMainMenu();
|
createMainMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,8 +489,8 @@ bool Client::OnInputCommand(const Events::InputCommand & e)
|
|||||||
|
|
||||||
if (e.Command == "ConnectToServer") { // Connect for now
|
if (e.Command == "ConnectToServer") { // Connect for now
|
||||||
if (e.Value > 0) {
|
if (e.Value > 0) {
|
||||||
//m_Reliable.Connect(m_PlayerName, m_Address, m_Port);
|
m_Reliable.Connect(m_PlayerName, m_Address, m_Port);
|
||||||
// m_Unreliable.Connect(m_PlayerName, m_Address, m_Port);
|
m_Unreliable.Connect(m_PlayerName, m_Address, m_Port);
|
||||||
}
|
}
|
||||||
//LOG_DEBUG("Client::OnInputCommand: Command is %s. Value is %f. PlayerID is %i.", e.Command.c_str(), e.Value, e.PlayerID);
|
//LOG_DEBUG("Client::OnInputCommand: Command is %s. Value is %f. PlayerID is %i.", e.Command.c_str(), e.Value, e.PlayerID);
|
||||||
return true;
|
return true;
|
||||||
@@ -553,6 +567,7 @@ bool Client::OnConnectRequest(const Events::ConnectRequest& e)
|
|||||||
{
|
{
|
||||||
removeWorld();
|
removeWorld();
|
||||||
if (m_Reliable.Connect(m_PlayerName, e.IP, e.Port)) {
|
if (m_Reliable.Connect(m_PlayerName, e.IP, e.Port)) {
|
||||||
|
m_Unreliable.Connect(m_PlayerName, e.IP, e.Port);
|
||||||
// The client sent a successful connect message
|
// The client sent a successful connect message
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -629,7 +644,7 @@ void Client::sendLocalPlayerTransform()
|
|||||||
packet.WritePrimitive((int)cAssaultWeapon["Ammo"]);
|
packet.WritePrimitive((int)cAssaultWeapon["Ammo"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Reliable.Send(packet);
|
m_Unreliable.Send(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::identifyPacketLoss()
|
void Client::identifyPacketLoss()
|
||||||
@@ -691,7 +706,6 @@ void Client::displayServerlist()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Client::removeWorld()
|
void Client::removeWorld()
|
||||||
{
|
{
|
||||||
std::vector<EntityID> childrenToBeDeleted;
|
std::vector<EntityID> childrenToBeDeleted;
|
||||||
|
|||||||
@@ -83,3 +83,12 @@ void Network::updateNetworkData()
|
|||||||
m_NetworkData.DataReceivedThisInterval = 0;
|
m_NetworkData.DataReceivedThisInterval = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Network::popNetworkSegmentOfHeader(Packet & packet)
|
||||||
|
{
|
||||||
|
// Pop packetSize, group, groupIndex and groupSize.
|
||||||
|
packet.ReadPrimitive<int>();
|
||||||
|
packet.ReadPrimitive<int>();
|
||||||
|
packet.ReadPrimitive<int>();
|
||||||
|
packet.ReadPrimitive<int>();
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,16 +3,22 @@
|
|||||||
Packet::Packet(MessageType type, unsigned int& packetID)
|
Packet::Packet(MessageType type, unsigned int& packetID)
|
||||||
{
|
{
|
||||||
m_Data = new char[m_MaxPacketSize];
|
m_Data = new char[m_MaxPacketSize];
|
||||||
Init(type, packetID);
|
Init(type, packetID, 1, 1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create message
|
// Create message
|
||||||
Packet::Packet(char* data, const size_t sizeOfPacket)
|
Packet::Packet(char* data, const size_t sizeOfPacket)
|
||||||
{
|
{
|
||||||
|
// Create message header
|
||||||
|
// allocate memory for size of packet, sequenceNumber and totalPacketesInSequence
|
||||||
|
m_ReturnDataOffset = 0;
|
||||||
|
m_Offset = 0;
|
||||||
// Resize message
|
// Resize message
|
||||||
m_MaxPacketSize = sizeOfPacket;
|
m_MaxPacketSize = sizeOfPacket;
|
||||||
// Copy data newly allocated memory
|
// Copy data newly allocated memory
|
||||||
m_Data = new char[sizeOfPacket];
|
m_Data = new char[sizeOfPacket];
|
||||||
|
unsigned int dummy = 0;
|
||||||
|
Init(MessageType::Invalid, dummy, 0, 0, 0);
|
||||||
memcpy(m_Data, data, sizeOfPacket);
|
memcpy(m_Data, data, sizeOfPacket);
|
||||||
m_Offset = sizeOfPacket;
|
m_Offset = sizeOfPacket;
|
||||||
}
|
}
|
||||||
@@ -21,7 +27,7 @@ Packet::Packet(MessageType type)
|
|||||||
{
|
{
|
||||||
m_Data = new char[m_MaxPacketSize];
|
m_Data = new char[m_MaxPacketSize];
|
||||||
unsigned int dummy = 0;
|
unsigned int dummy = 0;
|
||||||
Init(type, dummy);
|
Init(type, dummy, 1, 1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Packet::~Packet()
|
Packet::~Packet()
|
||||||
@@ -29,16 +35,30 @@ Packet::~Packet()
|
|||||||
delete[] m_Data;
|
delete[] m_Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Packet::Init(MessageType type, unsigned int & packetID)
|
void Packet::Init(MessageType type, unsigned int & packetID,
|
||||||
|
int groupIndex, int groupSize, int group)
|
||||||
{
|
{
|
||||||
m_ReturnDataOffset = 0;
|
m_ReturnDataOffset = 0;
|
||||||
m_Offset = 0;
|
m_Offset = 0;
|
||||||
// Create message header
|
// Create message header
|
||||||
// allocate memory for size of packet(only used in tcp)
|
// allocate memory for size of packet, sequenceNumber and totalPacketesInSequence
|
||||||
|
packetSizeOffset = m_Offset;
|
||||||
WritePrimitive<int>(0);
|
WritePrimitive<int>(0);
|
||||||
|
// packetGroup is the group the packet is in
|
||||||
|
groupOffset = m_Offset;
|
||||||
|
WritePrimitive<int>(group);
|
||||||
|
// What index the packet has in the packetGroup
|
||||||
|
groupIndexOffset = m_Offset;
|
||||||
|
WritePrimitive(groupIndex);
|
||||||
|
// The total amount of packets in a packetGroup
|
||||||
|
groupSizeOffset = m_Offset;
|
||||||
|
WritePrimitive(groupSize);
|
||||||
// Add message type
|
// Add message type
|
||||||
int messageType = static_cast<int>(type);
|
int messageType = static_cast<int>(type);
|
||||||
|
messageTypeOffset = m_Offset;
|
||||||
WritePrimitive<int>(messageType);
|
WritePrimitive<int>(messageType);
|
||||||
|
// Packet ID
|
||||||
|
packetIDOffset = m_Offset;
|
||||||
WritePrimitive<int>(packetID);
|
WritePrimitive<int>(packetID);
|
||||||
packetID++;
|
packetID++;
|
||||||
m_HeaderSize = m_Offset;
|
m_HeaderSize = m_Offset;
|
||||||
@@ -104,8 +124,7 @@ void Packet::ReconstructFromData(char * data, size_t sizeOfData)
|
|||||||
|
|
||||||
void Packet::UpdateSize()
|
void Packet::UpdateSize()
|
||||||
{
|
{
|
||||||
int whatisoffset = m_Offset;
|
memcpy(m_Data + packetSizeOffset, &m_Offset, sizeof(int));
|
||||||
memcpy(m_Data, &m_Offset, sizeof(int));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char * Packet::ReadData(int sizeOfData)
|
char * Packet::ReadData(int sizeOfData)
|
||||||
@@ -123,14 +142,47 @@ void Packet::ChangePacketID(unsigned int & packetID)
|
|||||||
{
|
{
|
||||||
packetID = packetID + 1;
|
packetID = packetID + 1;
|
||||||
// Overwrite old PacketID
|
// Overwrite old PacketID
|
||||||
memcpy(m_Data + 2*sizeof(int), &packetID, sizeof(int));
|
memcpy(m_Data + packetIDOffset, &packetID, sizeof(int));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Packet::ChangeGroupIndex(int groupIndex)
|
||||||
|
{
|
||||||
|
memcpy(m_Data + groupIndexOffset, &groupIndex, sizeof(int));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Packet::ChangeGroupSize(int groupSize)
|
||||||
|
{
|
||||||
|
memcpy(m_Data + groupSizeOffset, &groupSize, sizeof(int));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Packet::ChangeGroup(int group)
|
||||||
|
{
|
||||||
|
memcpy(m_Data + groupOffset, &group, sizeof(int));
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageType Packet::GetMessageType()
|
MessageType Packet::GetMessageType()
|
||||||
{
|
{
|
||||||
MessageType messagType;
|
return *reinterpret_cast<MessageType*>(m_Data + messageTypeOffset);
|
||||||
memcpy(&messagType, m_Data + sizeof(int), sizeof(int));
|
}
|
||||||
return messagType;
|
|
||||||
|
size_t Packet::Group()
|
||||||
|
{
|
||||||
|
return *reinterpret_cast<size_t*>(m_Data + groupOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t Packet::GroupIndex()
|
||||||
|
{
|
||||||
|
return *reinterpret_cast<size_t*>(m_Data + groupIndexOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t Packet::GroupSize()
|
||||||
|
{
|
||||||
|
return *reinterpret_cast<size_t*>(m_Data + groupSizeOffset);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t Packet::PacketID()
|
||||||
|
{
|
||||||
|
return *reinterpret_cast<size_t*>(m_Data + packetIDOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Packet::resizeData()
|
void Packet::resizeData()
|
||||||
|
|||||||
@@ -49,19 +49,19 @@ void Server::Update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//PlayerDefinition pd;
|
PlayerDefinition pd;
|
||||||
//while (m_Unreliable.IsSocketAvailable()) {
|
while (m_Unreliable.IsSocketAvailable()) {
|
||||||
// // Packet will get real data in receive
|
// Packet will get real data in receive
|
||||||
// Packet packet(MessageType::Invalid);
|
Packet packet(MessageType::Invalid);
|
||||||
// m_Unreliable.Receive(packet, pd);
|
m_Unreliable.Receive(packet, pd);
|
||||||
// m_Address = pd.Endpoint.address();
|
m_Address = pd.Endpoint.address();
|
||||||
// m_Port = pd.Endpoint.port();
|
m_Port = pd.Endpoint.port();
|
||||||
// if (packet.GetMessageType() == MessageType::Connect) {
|
if (packet.GetMessageType() == MessageType::Connect) {
|
||||||
// parseUDPConnect(packet);
|
parseUDPConnect(packet);
|
||||||
// } else {
|
} else {
|
||||||
// parseMessageType(packet);
|
parseMessageType(packet);
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
while (m_ServerlistRequest.IsSocketAvailable()) {
|
while (m_ServerlistRequest.IsSocketAvailable()) {
|
||||||
Packet packet(MessageType::Invalid);
|
Packet packet(MessageType::Invalid);
|
||||||
@@ -69,9 +69,11 @@ void Server::Update()
|
|||||||
localArea.Endpoint = boost::asio::ip::udp::endpoint();
|
localArea.Endpoint = boost::asio::ip::udp::endpoint();
|
||||||
m_ServerlistRequest.Receive(packet, localArea);
|
m_ServerlistRequest.Receive(packet, localArea);
|
||||||
if (packet.GetMessageType() == MessageType::ServerlistRequest) {
|
if (packet.GetMessageType() == MessageType::ServerlistRequest) {
|
||||||
packet.ReadPrimitive<int>(); // Pop size
|
// Pop header
|
||||||
packet.ReadPrimitive<int>(); // Pop MsgType
|
popNetworkSegmentOfHeader(packet);
|
||||||
packet.ReadPrimitive<int>(); // Pop packet ID
|
packet.ReadPrimitive<int>();
|
||||||
|
packet.ReadPrimitive<int>();
|
||||||
|
|
||||||
int port = packet.ReadPrimitive<int>();
|
int port = packet.ReadPrimitive<int>();
|
||||||
std::string address = localArea.Endpoint.address().to_string();
|
std::string address = localArea.Endpoint.address().to_string();
|
||||||
parseServerlistRequest(boost::asio::ip::udp::endpoint(boost::asio::ip::address().from_string(address), port));
|
parseServerlistRequest(boost::asio::ip::udp::endpoint(boost::asio::ip::address().from_string(address), port));
|
||||||
@@ -109,9 +111,9 @@ void Server::Update()
|
|||||||
|
|
||||||
void Server::parseMessageType(Packet& packet)
|
void Server::parseMessageType(Packet& packet)
|
||||||
{
|
{
|
||||||
// Pop packetSize which is used by TCP Client to
|
// Pop packetSize, sequenceNumber and packetsInSequence.
|
||||||
// create a packet of the correct size
|
// create a packet of the correct size
|
||||||
packet.ReadPrimitive<int>();
|
popNetworkSegmentOfHeader(packet);
|
||||||
|
|
||||||
int messageType = packet.ReadPrimitive<int>(); // Read what type off message was sent from server
|
int messageType = packet.ReadPrimitive<int>(); // Read what type off message was sent from server
|
||||||
// Read packet ID
|
// Read packet ID
|
||||||
@@ -162,10 +164,7 @@ void Server::reliableBroadcast(Packet& packet)
|
|||||||
|
|
||||||
void Server::unreliableBroadcast(Packet& packet)
|
void Server::unreliableBroadcast(Packet& packet)
|
||||||
{
|
{
|
||||||
for (auto& kv : m_ConnectedPlayers) {
|
m_Unreliable.SendToConnectedPlayers(packet, m_ConnectedPlayers);
|
||||||
packet.ChangePacketID(kv.second.PacketID);
|
|
||||||
// m_Unreliable.Send(packet, kv.second);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send snapshot fields
|
// Send snapshot fields
|
||||||
@@ -174,7 +173,8 @@ void Server::sendSnapshot()
|
|||||||
Packet packet(MessageType::Snapshot);
|
Packet packet(MessageType::Snapshot);
|
||||||
addInputCommandsToPacket(packet);
|
addInputCommandsToPacket(packet);
|
||||||
addPlayersToPacket(packet, EntityID_Invalid);
|
addPlayersToPacket(packet, EntityID_Invalid);
|
||||||
reliableBroadcast(packet);
|
//addChildrenToPacket(packet, EntityID_Invalid);
|
||||||
|
unreliableBroadcast(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::addInputCommandsToPacket(Packet& packet)
|
void Server::addInputCommandsToPacket(Packet& packet)
|
||||||
@@ -299,8 +299,6 @@ void Server::sendPing()
|
|||||||
reliableBroadcast(packet);
|
reliableBroadcast(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Server::checkForTimeOuts()
|
void Server::checkForTimeOuts()
|
||||||
{
|
{
|
||||||
double startPing = 1000 * m_StartPingTime
|
double startPing = 1000 * m_StartPingTime
|
||||||
@@ -317,38 +315,35 @@ void Server::checkForTimeOuts()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (size_t i = 0; i < playersToRemove.size(); i++) {
|
for (int i = playersToRemove.size() - 1; i >= 0; i--) {
|
||||||
disconnect(playersToRemove.at(i));
|
disconnect(playersToRemove.at(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//void Server::parseUDPConnect(Packet & packet)
|
void Server::parseUDPConnect(Packet & packet)
|
||||||
//{
|
{
|
||||||
// // Pop size of message int
|
//Pop packetSize, sequenceNumber and packetsInSequence.
|
||||||
// packet.ReadPrimitive<int>();
|
popNetworkSegmentOfHeader(packet);
|
||||||
// int messageType = packet.ReadPrimitive<int>();
|
int messageType = packet.ReadPrimitive<int>();
|
||||||
// // Read packet ID
|
// Read packet ID
|
||||||
// m_PreviousPacketID = m_PacketID; // Set previous packet id
|
m_PreviousPacketID = m_PacketID; // Set previous packet id
|
||||||
// m_PacketID = packet.ReadPrimitive<int>(); //Read new packet id
|
m_PacketID = packet.ReadPrimitive<int>(); //Read new packet id
|
||||||
// // parse player id and other stuff
|
// parse player id and other stuff
|
||||||
// PlayerID playerID = packet.ReadPrimitive<int>();
|
PlayerID playerID = packet.ReadPrimitive<int>();
|
||||||
// if (!EntityWrapper(m_World, playerID).Valid()) {
|
boost::asio::ip::udp::endpoint endpoint(m_Address, m_Port);
|
||||||
//
|
m_ConnectedPlayers.at(playerID).Endpoint = endpoint;
|
||||||
// }
|
LOG_INFO("parseUDPConnect: Spectator \"%s\" connected on IP: %s", m_ConnectedPlayers.at(playerID).Name.c_str(), m_ConnectedPlayers.at(playerID).Endpoint.address().to_string().c_str());
|
||||||
// // Do something here?
|
// Send a message to the player that connected
|
||||||
// boost::asio::ip::udp::endpoint endpoint(m_Address, m_Port);
|
Packet connnectPacket(MessageType::Connect, m_ConnectedPlayers.at(playerID).PacketID);
|
||||||
// m_ConnectedPlayers.at(playerID).Endpoint = endpoint;
|
m_Unreliable.Send(connnectPacket);
|
||||||
// LOG_INFO("parseUDPConnect: Spectator \"%s\" connected on IP: %s", m_ConnectedPlayers.at(playerID).Name.c_str(), m_ConnectedPlayers.at(playerID).Endpoint.address().to_string().c_str());
|
LOG_INFO("UDP Connect sent to client");
|
||||||
// // Send a message to the player that connected
|
}
|
||||||
// Packet connnectPacket(MessageType::Connect, m_ConnectedPlayers.at(playerID).PacketID);
|
|
||||||
// m_Unreliable.Send(connnectPacket);
|
|
||||||
// LOG_INFO("UDP Connect sent to client");
|
|
||||||
//}
|
|
||||||
|
|
||||||
void Server::parseTCPConnect(Packet & packet)
|
void Server::parseTCPConnect(Packet & packet)
|
||||||
{
|
{
|
||||||
// Pop size of message int
|
// Pop packetSize, sequenceNumber and packetsInSequence.
|
||||||
packet.ReadPrimitive<int>();
|
popNetworkSegmentOfHeader(packet);
|
||||||
|
|
||||||
int messageType = packet.ReadPrimitive<int>();
|
int messageType = packet.ReadPrimitive<int>();
|
||||||
// Read packet ID
|
// Read packet ID
|
||||||
m_PreviousPacketID = m_PacketID; // Set previous packet id
|
m_PreviousPacketID = m_PacketID; // Set previous packet id
|
||||||
@@ -356,9 +351,9 @@ void Server::parseTCPConnect(Packet & packet)
|
|||||||
|
|
||||||
LOG_INFO("Parsing connections");
|
LOG_INFO("Parsing connections");
|
||||||
// Check if player is already connected
|
// Check if player is already connected
|
||||||
// Ska vara till lagd i TCPServer receive
|
|
||||||
PlayerID playerID = getPlayerIDFromEndpoint();
|
PlayerID playerID = getPlayerIDFromEndpoint();
|
||||||
if (playerID == -1) {
|
if (playerID == -1) {
|
||||||
|
LOG_INFO("Server::parseTCPConnect: Not connected");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Create a new player
|
// Create a new player
|
||||||
@@ -381,7 +376,7 @@ void Server::parseTCPConnect(Packet & packet)
|
|||||||
Packet connnectPacket(MessageType::Connect, m_ConnectedPlayers.at(playerID).PacketID);
|
Packet connnectPacket(MessageType::Connect, m_ConnectedPlayers.at(playerID).PacketID);
|
||||||
// Write playerID to packet
|
// Write playerID to packet
|
||||||
connnectPacket.WritePrimitive(playerID);
|
connnectPacket.WritePrimitive(playerID);
|
||||||
m_Reliable.Send(connnectPacket);
|
m_Reliable.Send(connnectPacket, m_ConnectedPlayers.at(playerID));
|
||||||
|
|
||||||
Packet firstSnapshot(MessageType::Snapshot);
|
Packet firstSnapshot(MessageType::Snapshot);
|
||||||
addInputCommandsToPacket(firstSnapshot);
|
addInputCommandsToPacket(firstSnapshot);
|
||||||
@@ -668,4 +663,4 @@ PlayerID Server::getPlayerIDFromEntityID(EntityID entityID)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -3,25 +3,14 @@
|
|||||||
using namespace boost::asio::ip;
|
using namespace boost::asio::ip;
|
||||||
|
|
||||||
TCPClient::TCPClient()
|
TCPClient::TCPClient()
|
||||||
{
|
{ }
|
||||||
}
|
|
||||||
|
|
||||||
TCPClient::~TCPClient()
|
TCPClient::~TCPClient()
|
||||||
{
|
{ }
|
||||||
}
|
|
||||||
|
|
||||||
bool TCPClient::Connect(std::string playerName, std::string address, int port)
|
bool TCPClient::Connect(std::string playerName, std::string address, int port)
|
||||||
{
|
{
|
||||||
if (m_Socket) {
|
if (!m_Socket) {
|
||||||
if (m_IsConnected) {
|
|
||||||
Packet packet(MessageType::Connect, m_SendPacketID);
|
|
||||||
packet.WriteString(playerName);
|
|
||||||
Send(packet);
|
|
||||||
LOG_INFO("Connect message sent again!");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (!m_IsConnected) {
|
|
||||||
boost::system::error_code error = boost::asio::error::host_not_found;
|
boost::system::error_code error = boost::asio::error::host_not_found;
|
||||||
m_Endpoint = tcp::endpoint(boost::asio::ip::address::from_string(address), port);
|
m_Endpoint = tcp::endpoint(boost::asio::ip::address::from_string(address), port);
|
||||||
m_Socket = std::unique_ptr<tcp::socket>(new tcp::socket(m_IOService));
|
m_Socket = std::unique_ptr<tcp::socket>(new tcp::socket(m_IOService));
|
||||||
@@ -36,9 +25,7 @@ bool TCPClient::Connect(std::string playerName, std::string address, int port)
|
|||||||
Send(packet);
|
Send(packet);
|
||||||
LOG_INFO("Connect message sent!");
|
LOG_INFO("Connect message sent!");
|
||||||
return true;
|
return true;
|
||||||
}
|
} else { // If error
|
||||||
// If error
|
|
||||||
else {
|
|
||||||
m_Socket->close();
|
m_Socket->close();
|
||||||
m_Socket = nullptr;
|
m_Socket = nullptr;
|
||||||
return false;
|
return false;
|
||||||
@@ -47,14 +34,10 @@ bool TCPClient::Connect(std::string playerName, std::string address, int port)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TCPClient::Disconnect()
|
void TCPClient::Disconnect()
|
||||||
{
|
{
|
||||||
if (!m_IsConnected) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_Socket->shutdown(boost::asio::ip::tcp::socket::shutdown_both);
|
m_Socket->shutdown(boost::asio::ip::tcp::socket::shutdown_both);
|
||||||
m_Socket->close();
|
m_Socket->close();
|
||||||
m_Socket = nullptr;
|
m_Socket = nullptr;
|
||||||
m_IsConnected = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCPClient::Receive(Packet& packet)
|
void TCPClient::Receive(Packet& packet)
|
||||||
@@ -66,7 +49,7 @@ void TCPClient::Receive(Packet& packet)
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t TCPClient::readBuffer()
|
size_t TCPClient::readBuffer()
|
||||||
{
|
{
|
||||||
if (!m_Socket) {
|
if (!m_Socket) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -92,7 +75,7 @@ size_t TCPClient::readBuffer()
|
|||||||
while (sizeOfPacket > bytesReceived) {
|
while (sizeOfPacket > bytesReceived) {
|
||||||
// Read the rest of the message
|
// Read the rest of the message
|
||||||
bytesReceived += m_Socket->read_some(boost
|
bytesReceived += m_Socket->read_some(boost
|
||||||
::asio::buffer((void*)(m_ReadBuffer), sizeOfPacket - bytesReceived),
|
::asio::buffer((void*)(m_ReadBuffer + bytesReceived), sizeOfPacket - bytesReceived),
|
||||||
error);
|
error);
|
||||||
if (error) {
|
if (error) {
|
||||||
//LOG_ERROR("receive: %s", error.message().c_str());
|
//LOG_ERROR("receive: %s", error.message().c_str());
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ void TCPServer::Send(Packet & packet, PlayerDefinition & playerDefinition)
|
|||||||
{
|
{
|
||||||
packet.UpdateSize();
|
packet.UpdateSize();
|
||||||
try {
|
try {
|
||||||
|
// Crashed once TCPSocket was NULL
|
||||||
int bytesSent = playerDefinition.TCPSocket->send(
|
int bytesSent = playerDefinition.TCPSocket->send(
|
||||||
boost::asio::buffer(packet.Data(), packet.Size()),
|
boost::asio::buffer(packet.Data(), packet.Size()),
|
||||||
0);
|
0);
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
#include "Network/UDPClient.h"
|
#include "Network/UDPClient.h"
|
||||||
|
#include "boost/asio/basic_datagram_socket.hpp"
|
||||||
|
|
||||||
using namespace boost::asio::ip;
|
using namespace boost::asio::ip;
|
||||||
|
|
||||||
UDPClient::UDPClient()
|
UDPClient::UDPClient()
|
||||||
{
|
{ }
|
||||||
}
|
|
||||||
|
|
||||||
UDPClient::~UDPClient()
|
UDPClient::~UDPClient()
|
||||||
{
|
{ }
|
||||||
}
|
|
||||||
|
|
||||||
bool UDPClient::Connect(std::string playerName, std::string address, int port)
|
bool UDPClient::Connect(std::string playerName, std::string address, int port)
|
||||||
{
|
{
|
||||||
@@ -18,22 +17,35 @@ bool UDPClient::Connect(std::string playerName, std::string address, int port)
|
|||||||
m_ReceiverEndpoint = udp::endpoint(boost::asio::ip::address().from_string(address), port);
|
m_ReceiverEndpoint = udp::endpoint(boost::asio::ip::address().from_string(address), port);
|
||||||
m_Socket = boost::shared_ptr<boost::asio::ip::udp::socket>(new boost::asio::ip::udp::socket(m_IOService));
|
m_Socket = boost::shared_ptr<boost::asio::ip::udp::socket>(new boost::asio::ip::udp::socket(m_IOService));
|
||||||
m_Socket->open(boost::asio::ip::udp::v4());
|
m_Socket->open(boost::asio::ip::udp::v4());
|
||||||
|
boost::asio::socket_base::receive_buffer_size option(m_SizeOfSocketBuffer);
|
||||||
|
m_Socket->set_option(option);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDPClient::Disconnect()
|
void UDPClient::Disconnect()
|
||||||
{
|
{
|
||||||
|
m_Socket->shutdown(boost::asio::ip::tcp::socket::shutdown_both);
|
||||||
|
m_Socket->close();
|
||||||
|
m_Socket = nullptr;
|
||||||
|
|
||||||
|
m_LastReceivedSnapshotGroup = 0;
|
||||||
|
m_PacketSegmentMap.clear();
|
||||||
|
PacketID m_SendPacketID = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDPClient::Receive(Packet& packet)
|
void UDPClient::Receive(Packet& packet)
|
||||||
{
|
{
|
||||||
int bytesRead = readBuffer();
|
int bytesRead = readBuffer();
|
||||||
if (bytesRead > 0) {
|
if (bytesRead > 0) {
|
||||||
packet.ReconstructFromData(m_ReadBuffer, bytesRead);
|
packet.ReconstructFromData(m_ReadBuffer, bytesRead);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UDPClient::ReceivePackets()
|
||||||
|
{
|
||||||
|
readPartOfPacket();
|
||||||
|
}
|
||||||
|
|
||||||
int UDPClient::readBuffer()
|
int UDPClient::readBuffer()
|
||||||
{
|
{
|
||||||
if (!m_Socket) {
|
if (!m_Socket) {
|
||||||
@@ -41,9 +53,9 @@ int UDPClient::readBuffer()
|
|||||||
}
|
}
|
||||||
boost::system::error_code error;
|
boost::system::error_code error;
|
||||||
// Read size of packet
|
// Read size of packet
|
||||||
m_Socket->receive(boost
|
m_Socket->receive(boost
|
||||||
::asio::buffer((void*)m_ReadBuffer, sizeof(int)),
|
::asio::buffer((void*)m_ReadBuffer, sizeof(int)),
|
||||||
boost::asio::ip::udp::socket::message_peek, error);
|
boost::asio::ip::udp::socket::message_peek, error);
|
||||||
int sizeOfPacket = 0;
|
int sizeOfPacket = 0;
|
||||||
memcpy(&sizeOfPacket, m_ReadBuffer, sizeof(int));
|
memcpy(&sizeOfPacket, m_ReadBuffer, sizeof(int));
|
||||||
if (sizeOfPacket > m_Socket->available()) {
|
if (sizeOfPacket > m_Socket->available()) {
|
||||||
@@ -72,6 +84,72 @@ int UDPClient::readBuffer()
|
|||||||
return bytesReceived;
|
return bytesReceived;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UDPClient::readPartOfPacket()
|
||||||
|
{
|
||||||
|
if (!m_Socket) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
boost::system::error_code error;
|
||||||
|
// Peek header
|
||||||
|
m_Socket->receive(boost
|
||||||
|
::asio::buffer((void*)m_ReadBuffer, 5 * sizeof(int)),
|
||||||
|
boost::asio::ip::udp::socket::message_peek, error);
|
||||||
|
|
||||||
|
int sizeOfPacket = 0;
|
||||||
|
memcpy(&sizeOfPacket, m_ReadBuffer, sizeof(int));
|
||||||
|
if (sizeOfPacket == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int packetGroup = *reinterpret_cast<int*>(m_ReadBuffer + sizeof(int));
|
||||||
|
int packetGroupIndex = *reinterpret_cast<int*>(m_ReadBuffer + 2 * sizeof(int));
|
||||||
|
int packetGroupSize = *reinterpret_cast<int*>(m_ReadBuffer + 3 * sizeof(int));
|
||||||
|
//LOG_INFO("Packet group: %i. Group index: %i. Group size: %i. Packet size: %i.", packetGroup, packetGroupIndex, packetGroupSize, sizeOfPacket);
|
||||||
|
if (sizeOfPacket > m_Socket->available()) {
|
||||||
|
LOG_WARNING("UDPClient::readBuffer(): We haven't got the whole packet yet.");
|
||||||
|
// return;
|
||||||
|
}
|
||||||
|
// if the buffer is to small increase the size of it
|
||||||
|
boost::shared_ptr<char> packetData(new char[sizeOfPacket]);
|
||||||
|
|
||||||
|
// Read the message
|
||||||
|
size_t bytesReceived = m_Socket->receive_from(boost
|
||||||
|
::asio::buffer((void*)(packetData.get()),
|
||||||
|
sizeOfPacket),
|
||||||
|
m_ReceiverEndpoint, 0, error);
|
||||||
|
if (error) {
|
||||||
|
LOG_ERROR("UDPClient::readPartOfPacket: %s", error.message().c_str());
|
||||||
|
}
|
||||||
|
// Might want to do this earlier when i figure out a good way to
|
||||||
|
// remove data from network buffer.
|
||||||
|
if (hasReceivedPacket(packetGroup, packetGroupIndex)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// If group exists
|
||||||
|
PacketMap::iterator it;
|
||||||
|
it = m_PacketSegmentMap.find(packetGroup);
|
||||||
|
if (it != m_PacketSegmentMap.end()) {
|
||||||
|
it->second.push_back(std::make_pair(packetGroupIndex, std::move(packetData)));
|
||||||
|
} else { // Create group and add element
|
||||||
|
m_PacketSegmentMap[packetGroup].push_back(std::make_pair(packetGroupIndex, std::move(packetData)));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UDPClient::hasReceivedPacket(int packetGroup, int groupIndex)
|
||||||
|
{
|
||||||
|
PacketMap::iterator it;
|
||||||
|
it = m_PacketSegmentMap.find(packetGroup);
|
||||||
|
if (it != m_PacketSegmentMap.end()) {
|
||||||
|
const std::vector<std::pair<int, boost::shared_ptr<char>>>& loopPacketGroup = it->second;
|
||||||
|
for (size_t i = 0; i < loopPacketGroup.size(); i++) {
|
||||||
|
if (loopPacketGroup.at(i).first == groupIndex) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void UDPClient::Send(Packet& packet)
|
void UDPClient::Send(Packet& packet)
|
||||||
{
|
{
|
||||||
packet.UpdateSize();
|
packet.UpdateSize();
|
||||||
@@ -79,7 +157,7 @@ void UDPClient::Send(Packet& packet)
|
|||||||
packet.Data(),
|
packet.Data(),
|
||||||
packet.Size()),
|
packet.Size()),
|
||||||
m_ReceiverEndpoint, 0);
|
m_ReceiverEndpoint, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDPClient::Broadcast(Packet& packet, int port)
|
void UDPClient::Broadcast(Packet& packet, int port)
|
||||||
{
|
{
|
||||||
@@ -95,8 +173,55 @@ void UDPClient::Broadcast(Packet& packet, int port)
|
|||||||
|
|
||||||
bool UDPClient::IsSocketAvailable()
|
bool UDPClient::IsSocketAvailable()
|
||||||
{
|
{
|
||||||
if (!m_Socket) {
|
if (!m_Socket) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return m_Socket->available();
|
return m_Socket->available();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UDPClient::GetNextPacket(Packet & packet)
|
||||||
|
{
|
||||||
|
// A duplicate packet should not be present in the vector!
|
||||||
|
// Soo we will assume that this is true and only look if size
|
||||||
|
// of vector is correct.
|
||||||
|
PacketMap::iterator it = m_PacketSegmentMap.begin();
|
||||||
|
while (it != m_PacketSegmentMap.end()) {
|
||||||
|
// pair(Group index, packetData)
|
||||||
|
std::vector<std::pair<int, boost::shared_ptr<char>>>& currentVector = it->second;
|
||||||
|
Packet headerInfoPacket(currentVector.at(0).second.get(), packet.HeaderSize());
|
||||||
|
int groupSize = headerInfoPacket.GroupSize();
|
||||||
|
//LOG_INFO("UDPClient::GetNextPacket: Packet group : %i.Group index : %i.Group size : %i. lastReceivedSnapshotGroup: %i. MessageType(Ples 4): %i", headerInfoPacket.Group(), headerInfoPacket.GroupIndex(), groupSize, lastReceivedSnapshotGroup, headerInfoPacket.GetMessageType());
|
||||||
|
//LOG_INFO("UDPClient::GetNextPacket: Packet group : %i.lastReceivedSnapshotGroup: %i. MessageType(Ples 4): %i", headerInfoPacket.Group(), lastReceivedSnapshotGroup, headerInfoPacket.GetMessageType());
|
||||||
|
int mapSize = m_PacketSegmentMap.size();
|
||||||
|
if (mapSize > 5) {
|
||||||
|
it = m_PacketSegmentMap.erase(it);
|
||||||
|
LOG_INFO("The map is increasing in size, size is %i", mapSize);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (headerInfoPacket.GetMessageType() == MessageType::Snapshot && m_LastReceivedSnapshotGroup > headerInfoPacket.Group()) {
|
||||||
|
it = m_PacketSegmentMap.erase(it);
|
||||||
|
continue;
|
||||||
|
//LOG_INFO("Deleted old entry");
|
||||||
|
}
|
||||||
|
if (currentVector.size() == groupSize) {
|
||||||
|
std::sort(currentVector.begin(), currentVector.end());
|
||||||
|
// Add the first packet in vector
|
||||||
|
packet.ReconstructFromData(currentVector.at(0).second.get(), packet.HeaderSize());
|
||||||
|
// Add the rest of the packets.
|
||||||
|
int sizeOfData = 0;
|
||||||
|
for (auto& packetSegment : currentVector) {
|
||||||
|
memcpy(&sizeOfData, packetSegment.second.get(), sizeof(int));
|
||||||
|
packet.WriteData(packetSegment.second.get() + packet.HeaderSize(), sizeOfData - packet.HeaderSize());
|
||||||
|
}
|
||||||
|
if (headerInfoPacket.GetMessageType() == MessageType::Snapshot) {
|
||||||
|
m_LastReceivedSnapshotGroup = packet.Group();
|
||||||
|
}
|
||||||
|
// No need to get next it as we are returning.
|
||||||
|
m_PacketSegmentMap.erase(it);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,34 +12,110 @@ UDPServer::UDPServer(int port)
|
|||||||
|
|
||||||
UDPServer::~UDPServer()
|
UDPServer::~UDPServer()
|
||||||
{ }
|
{ }
|
||||||
|
// TODO: Fix correct groups
|
||||||
void UDPServer::Send(Packet& packet, PlayerDefinition & playerDefinition)
|
void UDPServer::Send(Packet& packet, PlayerDefinition& playerDefinition)
|
||||||
{
|
{
|
||||||
packet.UpdateSize();
|
packet.UpdateSize();
|
||||||
try {
|
try {
|
||||||
int bytesSent = m_Socket->send_to(
|
// Remove header from packet.
|
||||||
boost::asio::buffer(packet.Data(), packet.Size()),
|
packet.ReadData(packet.HeaderSize());
|
||||||
playerDefinition.Endpoint,
|
int totalBytesSent = 0;
|
||||||
0);
|
int groupIndex = 1;
|
||||||
LOG_INFO("Size of packet is %i", bytesSent);
|
int groupSize = std::ceil((float)packet.Size() / MAXPACKETSIZE);
|
||||||
|
int packetDataSent = 0;
|
||||||
|
int packetDataSize = packet.Size() - packet.HeaderSize();
|
||||||
|
|
||||||
|
while (packetDataSize > packetDataSent) {
|
||||||
|
Packet splitPacket(packet.GetMessageType(), playerDefinition.PacketID);
|
||||||
|
splitPacket.ChangeGroupIndex(groupIndex);
|
||||||
|
splitPacket.ChangeGroupSize(groupSize);
|
||||||
|
splitPacket.ChangeGroup(playerDefinition.PacketGroup);
|
||||||
|
int amountToSend = packetDataSize - packetDataSent;
|
||||||
|
if (amountToSend > MAXPACKETSIZE) {
|
||||||
|
amountToSend = MAXPACKETSIZE;
|
||||||
|
}
|
||||||
|
splitPacket.WriteData(packet.ReadData(amountToSend), amountToSend);
|
||||||
|
splitPacket.UpdateSize();
|
||||||
|
// Remove header size from bytes sent soo that we only
|
||||||
|
// count data in the packet
|
||||||
|
int bytesSent = 0;
|
||||||
|
bytesSent = m_Socket->send_to(
|
||||||
|
boost::asio::buffer(splitPacket.Data(), splitPacket.Size()),
|
||||||
|
playerDefinition.Endpoint,
|
||||||
|
0);
|
||||||
|
packetDataSent += bytesSent - splitPacket.HeaderSize();
|
||||||
|
totalBytesSent += bytesSent;
|
||||||
|
//LOG_INFO("bytesSent size %i, groupIndex: %i. Number of packets: %i", bytesSent, sequenceNumber, totalMessages);
|
||||||
|
++groupIndex;
|
||||||
|
}
|
||||||
|
playerDefinition.PacketGroup++;
|
||||||
} catch (const boost::system::system_error& e) {
|
} catch (const boost::system::system_error& e) {
|
||||||
LOG_INFO(e.what());
|
LOG_INFO(e.what());
|
||||||
// TODO: Clean up invalid endpoints out of m_ConnectedPlayers later
|
// TODO: Clean up invalid endpoints out of m_ConnectedPlayers later
|
||||||
playerDefinition.Endpoint = boost::asio::ip::udp::endpoint();
|
playerDefinition.Endpoint = boost::asio::ip::udp::endpoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UDPServer::SendToConnectedPlayers(Packet& packet, std::map<PlayerID, PlayerDefinition>& playersTosendTo)
|
||||||
|
{
|
||||||
|
packet.UpdateSize();
|
||||||
|
// Remove header from packet.
|
||||||
|
packet.ReadData(packet.HeaderSize());
|
||||||
|
int totalBytesSent = 0;
|
||||||
|
int groupIndex = 1;
|
||||||
|
int groupSize = std::ceil((float)packet.Size() / MAXPACKETSIZE);
|
||||||
|
int packetDataSent = 0;
|
||||||
|
int packetDataSize = packet.Size() - packet.HeaderSize();
|
||||||
|
|
||||||
|
while (packetDataSize > packetDataSent) {
|
||||||
|
Packet splitPacket(packet.GetMessageType());
|
||||||
|
splitPacket.ChangeGroupIndex(groupIndex);
|
||||||
|
splitPacket.ChangeGroupSize(groupSize);
|
||||||
|
int amountToSend = packetDataSize - packetDataSent;
|
||||||
|
if (amountToSend > MAXPACKETSIZE) {
|
||||||
|
amountToSend = MAXPACKETSIZE;
|
||||||
|
}
|
||||||
|
splitPacket.WriteData(packet.ReadData(amountToSend), amountToSend);
|
||||||
|
splitPacket.UpdateSize();
|
||||||
|
// Remove header size from bytes sent soo that we only
|
||||||
|
// count data in the packet
|
||||||
|
int bytesSent = 0;
|
||||||
|
for (auto& kv : playersTosendTo) {
|
||||||
|
try {
|
||||||
|
splitPacket.ChangeGroup(kv.second.PacketGroup);
|
||||||
|
bytesSent = m_Socket->send_to(
|
||||||
|
boost::asio::buffer(splitPacket.Data(), splitPacket.Size()),
|
||||||
|
kv.second.Endpoint,
|
||||||
|
0);
|
||||||
|
// LOG_INFO("bytesSent: %i", bytesSent);
|
||||||
|
} catch (const boost::system::system_error& e) {
|
||||||
|
LOG_INFO("UDPServer::SendToConnectedPlayers: Disconnected client. %s", e.what());
|
||||||
|
// TODO: Clean up invalid endpoints out of m_ConnectedPlayers later
|
||||||
|
kv.second.Endpoint = boost::asio::ip::udp::endpoint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
packetDataSent += splitPacket.Size() - splitPacket.HeaderSize();
|
||||||
|
totalBytesSent += splitPacket.Size();
|
||||||
|
|
||||||
|
//LOG_INFO("bytesSent size %i, groupIndex: %i. Number of packets: %i", bytesSent, sequenceNumber, totalMessages);
|
||||||
|
++groupIndex;
|
||||||
|
}
|
||||||
|
for (auto& kv : playersTosendTo) {
|
||||||
|
kv.second.PacketGroup++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Send back to endpoint of received packet
|
// Send back to endpoint of received packet
|
||||||
void UDPServer::Send(Packet & packet)
|
void UDPServer::Send(Packet & packet)
|
||||||
{
|
{
|
||||||
packet.UpdateSize();
|
packet.UpdateSize();
|
||||||
size_t bytesSent = m_Socket->send_to(
|
size_t bytesSent = m_Socket->send_to(
|
||||||
boost::asio::buffer(
|
boost::asio::buffer(
|
||||||
packet.Data(),
|
packet.Data(),
|
||||||
packet.Size()),
|
packet.Size()),
|
||||||
m_ReceiverEndpoint,
|
m_ReceiverEndpoint,
|
||||||
0);
|
0);
|
||||||
LOG_INFO("Size of packet is %i", bytesSent);
|
//LOG_INFO("Size of packet is %i", bytesSent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Broadcasting respond specific logic
|
// Broadcasting respond specific logic
|
||||||
@@ -52,7 +128,7 @@ void UDPServer::Send(Packet & packet, boost::asio::ip::udp::endpoint endpoint)
|
|||||||
packet.Size()),
|
packet.Size()),
|
||||||
endpoint,
|
endpoint,
|
||||||
0);
|
0);
|
||||||
LOG_INFO("Size of packet is %i", bytesSent);
|
//LOG_INFO("Size of packet is %i", bytesSent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Broadcasting
|
// Broadcasting
|
||||||
@@ -64,7 +140,7 @@ void UDPServer::Broadcast(Packet & packet, int port)
|
|||||||
boost::asio::buffer(
|
boost::asio::buffer(
|
||||||
packet.Data(),
|
packet.Data(),
|
||||||
packet.Size()),
|
packet.Size()),
|
||||||
boost::asio::ip::udp::endpoint(boost::asio::ip::address_v4().broadcast(),port),
|
boost::asio::ip::udp::endpoint(boost::asio::ip::address_v4().broadcast(), port),
|
||||||
0);
|
0);
|
||||||
m_Socket->set_option(boost::asio::socket_base::broadcast(false));
|
m_Socket->set_option(boost::asio::socket_base::broadcast(false));
|
||||||
}
|
}
|
||||||
@@ -91,7 +167,7 @@ int UDPServer::readBuffer()
|
|||||||
int addasdasd = m_Socket->available();
|
int addasdasd = m_Socket->available();
|
||||||
boost::system::error_code error;
|
boost::system::error_code error;
|
||||||
// Read size of packet
|
// Read size of packet
|
||||||
m_Socket->receive_from(boost
|
m_Socket->receive_from(boost
|
||||||
::asio::buffer((void*)m_ReadBuffer, sizeof(int)),
|
::asio::buffer((void*)m_ReadBuffer, sizeof(int)),
|
||||||
m_ReceiverEndpoint, boost::asio::ip::udp::socket::message_peek, error);
|
m_ReceiverEndpoint, boost::asio::ip::udp::socket::message_peek, error);
|
||||||
unsigned int sizeOfPacket = 0;
|
unsigned int sizeOfPacket = 0;
|
||||||
@@ -114,13 +190,13 @@ int UDPServer::readBuffer()
|
|||||||
::asio::buffer((void*)(m_ReadBuffer),
|
::asio::buffer((void*)(m_ReadBuffer),
|
||||||
sizeOfPacket),
|
sizeOfPacket),
|
||||||
m_ReceiverEndpoint, 0, error);
|
m_ReceiverEndpoint, 0, error);
|
||||||
if (error) {
|
if (error) {
|
||||||
//LOG_ERROR("receive: %s", error.message().c_str());
|
//LOG_ERROR("receive: %s", error.message().c_str());
|
||||||
}
|
}
|
||||||
if (sizeOfPacket > 1000000)
|
if (sizeOfPacket > 1000000)
|
||||||
LOG_WARNING("The packets received are bigger than 1MB");
|
LOG_WARNING("The packets received are bigger than 1MB");
|
||||||
|
|
||||||
return bytesReceived;
|
return bytesReceived;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDPServer::AcceptNewConnections(int& nextPlayerID, std::map<PlayerID, PlayerDefinition>& connectedPlayers)
|
void UDPServer::AcceptNewConnections(int& nextPlayerID, std::map<PlayerID, PlayerDefinition>& connectedPlayers)
|
||||||
|
|||||||
@@ -127,12 +127,12 @@ void AnimationSystem::UpdateAnimations(double dt)
|
|||||||
void AnimationSystem::UpdateWeights(double dt)
|
void AnimationSystem::UpdateWeights(double dt)
|
||||||
{
|
{
|
||||||
for (auto it = m_AutoBlendQueues.begin(); it != m_AutoBlendQueues.end(); ) {
|
for (auto it = m_AutoBlendQueues.begin(); it != m_AutoBlendQueues.end(); ) {
|
||||||
LOG_INFO("%s", it->first.Name().c_str());
|
/* LOG_INFO("%s", it->first.Name().c_str());
|
||||||
it->second.PrintQueue();
|
it->second.PrintQueue();*/
|
||||||
|
|
||||||
if(it->second.HasActiveBlendJob()) {
|
if(it->second.HasActiveBlendJob()) {
|
||||||
AutoBlendQueue::AutoBlendJob& blendJob = it->second.GetActiveBlendJob();
|
AutoBlendQueue::AutoBlendJob& blendJob = it->second.GetActiveBlendJob();
|
||||||
LOG_INFO("%s", blendJob.RootNode.Name().c_str());
|
//LOG_INFO("%s", blendJob.RootNode.Name().c_str());
|
||||||
std::shared_ptr<BlendTree> blendTree = it->second.GetBlendTree();
|
std::shared_ptr<BlendTree> blendTree = it->second.GetBlendTree();
|
||||||
if (blendTree != nullptr) {
|
if (blendTree != nullptr) {
|
||||||
if (blendJob.Duration != 0.0) {
|
if (blendJob.Duration != 0.0) {
|
||||||
|
|||||||
@@ -97,14 +97,14 @@ void BlurHUD::ClearBuffer()
|
|||||||
glClearStencil(0x00);
|
glClearStencil(0x00);
|
||||||
glStencilMask(~0);
|
glStencilMask(~0);
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
m_GaussianFrameBuffer_horiz.Unbind();
|
m_GaussianFrameBuffer_horiz.Unbind();
|
||||||
m_GaussianFrameBuffer_vert.Bind();
|
m_GaussianFrameBuffer_vert.Bind();
|
||||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
glClearStencil(0x00);
|
glClearStencil(0x00);
|
||||||
glStencilMask(~0);
|
glStencilMask(~0);
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
m_GaussianFrameBuffer_vert.Unbind();
|
m_GaussianFrameBuffer_vert.Unbind();
|
||||||
|
|
||||||
m_CombinedTextureBuffer.Bind();
|
m_CombinedTextureBuffer.Bind();
|
||||||
@@ -211,12 +211,16 @@ void BlurHUD::FillStencil(RenderScene& scene)
|
|||||||
RenderState state;
|
RenderState state;
|
||||||
|
|
||||||
state.BindFramebuffer(m_GaussianFrameBuffer_horiz.GetHandle());
|
state.BindFramebuffer(m_GaussianFrameBuffer_horiz.GetHandle());
|
||||||
state.Disable(GL_DEPTH_TEST);
|
state.Enable(GL_DEPTH_TEST);
|
||||||
state.Enable(GL_CULL_FACE);
|
state.Enable(GL_CULL_FACE);
|
||||||
state.Enable(GL_STENCIL_TEST);
|
state.Enable(GL_STENCIL_TEST);
|
||||||
state.StencilFunc(GL_ALWAYS, 1, 0xFF);
|
state.StencilFunc(GL_ALWAYS, 1, 0xFF);
|
||||||
state.StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
state.StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
||||||
state.StencilMask(0xFF);
|
state.StencilMask(0xFF);
|
||||||
|
|
||||||
|
state.AlphaFunc(GL_GEQUAL, 0.95f);
|
||||||
|
state.Enable(GL_ALPHA_TEST);
|
||||||
|
|
||||||
glViewport(0, 0, m_Renderer->GetViewportSize().Width/m_BlurQuality, m_Renderer->GetViewportSize().Height/m_BlurQuality);
|
glViewport(0, 0, m_Renderer->GetViewportSize().Width/m_BlurQuality, m_Renderer->GetViewportSize().Height/m_BlurQuality);
|
||||||
|
|
||||||
m_FillDepthStencilProgram->Bind();
|
m_FillDepthStencilProgram->Bind();
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ DrawBloomPass::DrawBloomPass(IRenderer* renderer, ConfigFile* config)
|
|||||||
DrawBloomPass::~DrawBloomPass() {
|
DrawBloomPass::~DrawBloomPass() {
|
||||||
CommonFunctions::DeleteTexture(&m_GaussianTexture_horiz);
|
CommonFunctions::DeleteTexture(&m_GaussianTexture_horiz);
|
||||||
CommonFunctions::DeleteTexture(&m_GaussianTexture_vert);
|
CommonFunctions::DeleteTexture(&m_GaussianTexture_vert);
|
||||||
|
CommonFunctions::DeleteTexture(&m_FinalGaussianTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawBloomPass::InitializeTextures()
|
void DrawBloomPass::InitializeTextures()
|
||||||
@@ -30,9 +31,8 @@ void DrawBloomPass::ChangeQuality(int quality)
|
|||||||
|
|
||||||
if (m_Quality == 0) {
|
if (m_Quality == 0) {
|
||||||
CommonFunctions::DeleteTexture(&m_GaussianTexture_horiz);
|
CommonFunctions::DeleteTexture(&m_GaussianTexture_horiz);
|
||||||
CommonFunctions::DeleteTexture(&m_GaussianTexture_vert);
|
CommonFunctions::DeleteTexture(&m_GaussianTexture_vert);
|
||||||
m_GaussianTexture_horiz = 0;
|
CommonFunctions::DeleteTexture(&m_FinalGaussianTexture);
|
||||||
m_GaussianTexture_vert = 0;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
InitializeTextures();
|
InitializeTextures();
|
||||||
@@ -62,22 +62,50 @@ void DrawBloomPass::InitializeShaderPrograms()
|
|||||||
m_GaussianProgram_vert->BindFragDataLocation(0, "fragmentColor");
|
m_GaussianProgram_vert->BindFragDataLocation(0, "fragmentColor");
|
||||||
m_GaussianProgram_vert->Link();
|
m_GaussianProgram_vert->Link();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_GaussianCombineProgram = ResourceManager::Load<ShaderProgram>("#GaussianCombineProgram");
|
||||||
|
if (m_GaussianCombineProgram->GetHandle() == 0) {
|
||||||
|
m_GaussianCombineProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/CombineGaussianTexture.vert.glsl")));
|
||||||
|
m_GaussianCombineProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/CombineGaussianTexture.frag.glsl")));
|
||||||
|
m_GaussianCombineProgram->Compile();
|
||||||
|
m_GaussianCombineProgram->BindFragDataLocation(0, "fragmentColor");
|
||||||
|
m_GaussianCombineProgram->Link();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawBloomPass::InitializeBuffers()
|
void DrawBloomPass::InitializeBuffers()
|
||||||
{
|
{
|
||||||
CommonFunctions::GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
CommonFunctions::GenerateMipMapTexture(
|
||||||
|
&m_GaussianTexture_horiz, GL_CLAMP_TO_BORDER, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height)
|
||||||
|
, GL_RGB, GL_FLOAT, m_BloomLod);
|
||||||
|
CommonFunctions::GenerateMipMapTexture(
|
||||||
|
&m_GaussianTexture_vert, GL_CLAMP_TO_BORDER, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height)
|
||||||
|
, GL_RGB, GL_FLOAT, m_BloomLod);
|
||||||
|
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);
|
||||||
|
|
||||||
if (m_GaussianFrameBuffer_horiz.GetHandle() == 0) {
|
if (m_GaussianCombineBuffer.GetHandle() == 0) {
|
||||||
m_GaussianFrameBuffer_horiz.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0)));
|
m_GaussianCombineBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_FinalGaussianTexture, GL_COLOR_ATTACHMENT0)));
|
||||||
}
|
}
|
||||||
m_GaussianFrameBuffer_horiz.Generate();
|
m_GaussianCombineBuffer.Generate();
|
||||||
|
|
||||||
CommonFunctions::GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
if(m_GaussianFrameBuffer_horiz == nullptr) {
|
||||||
if (m_GaussianFrameBuffer_vert.GetHandle() == 0) {
|
m_GaussianFrameBuffer_horiz = new FrameBuffer[m_BloomLod];
|
||||||
m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0)));
|
}
|
||||||
}
|
if (m_GaussianFrameBuffer_vert == nullptr) {
|
||||||
m_GaussianFrameBuffer_vert.Generate();
|
m_GaussianFrameBuffer_vert = new FrameBuffer[m_BloomLod];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < m_BloomLod; i++) {
|
||||||
|
if(m_GaussianFrameBuffer_horiz[i].GetHandle() == 0) {
|
||||||
|
m_GaussianFrameBuffer_horiz[i].AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0, i)));
|
||||||
|
}
|
||||||
|
m_GaussianFrameBuffer_horiz[i].Generate();
|
||||||
|
|
||||||
|
if (m_GaussianFrameBuffer_vert[i].GetHandle() == 0) {
|
||||||
|
m_GaussianFrameBuffer_vert[i].AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0, i)));
|
||||||
|
}
|
||||||
|
m_GaussianFrameBuffer_vert[i].Generate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -87,33 +115,75 @@ void DrawBloomPass::ClearBuffer()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GLERROR("PRE");
|
GLERROR("PRE");
|
||||||
m_GaussianFrameBuffer_horiz.Bind();
|
for (int i = 0; i < m_BloomLod; i++) {
|
||||||
|
m_GaussianFrameBuffer_horiz[i].Bind();
|
||||||
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
m_GaussianFrameBuffer_horiz[i].Unbind();
|
||||||
|
m_GaussianFrameBuffer_vert[i].Bind();
|
||||||
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
m_GaussianFrameBuffer_vert[i].Unbind();
|
||||||
|
|
||||||
|
}
|
||||||
|
m_GaussianCombineBuffer.Bind();
|
||||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
m_GaussianFrameBuffer_horiz.Unbind();
|
m_GaussianCombineBuffer.Unbind();
|
||||||
m_GaussianFrameBuffer_vert.Bind();
|
|
||||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
m_GaussianFrameBuffer_vert.Unbind();
|
|
||||||
GLERROR("END");
|
GLERROR("END");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawBloomPass::Draw(GLuint texture)
|
void DrawBloomPass::Draw(GLuint texture)
|
||||||
|
{
|
||||||
|
if (m_Quality == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < m_BloomLod; i++) {
|
||||||
|
GaussianLodPass(i, texture);
|
||||||
|
}
|
||||||
|
CombineGaussianBlur();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DrawBloomPass::OnWindowResize()
|
||||||
{
|
{
|
||||||
if (m_Quality == 0) {
|
if (m_Quality == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GLERROR("DrawBloomPass::Draw: Pre");
|
CommonFunctions::GenerateMipMapTexture(
|
||||||
|
&m_GaussianTexture_vert, GL_CLAMP_TO_BORDER, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height)
|
||||||
|
, GL_RGB, GL_FLOAT, m_BloomLod);
|
||||||
|
CommonFunctions::GenerateMipMapTexture(
|
||||||
|
&m_GaussianTexture_horiz, GL_CLAMP_TO_BORDER, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height)
|
||||||
|
, GL_RGB, GL_FLOAT, m_BloomLod);
|
||||||
|
for (int i = 0; i < m_BloomLod; i++) {
|
||||||
|
m_GaussianFrameBuffer_vert[i].Generate();
|
||||||
|
m_GaussianFrameBuffer_horiz[i].Generate();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawBloomPass::GaussianLodPass(GLuint mipMap, GLuint texture)
|
||||||
|
{
|
||||||
|
GLERROR("DrawBloomPass::Draw: Pre");
|
||||||
|
glViewport(0, 0, m_Renderer->GetViewportSize().Width/(glm::pow(2, mipMap)), m_Renderer->GetViewportSize().Height/(glm::pow(2, mipMap)));
|
||||||
DrawBloomPassState state;
|
DrawBloomPassState state;
|
||||||
|
|
||||||
GLuint shaderHandle_horiz = m_GaussianProgram_horiz->GetHandle();
|
GLuint shaderHandle_horiz = m_GaussianProgram_horiz->GetHandle();
|
||||||
GLuint shaderHandle_vert = m_GaussianProgram_vert->GetHandle();
|
GLuint shaderHandle_vert = m_GaussianProgram_vert->GetHandle();
|
||||||
|
|
||||||
|
m_GaussianProgram_vert->Bind();
|
||||||
|
glUniform1i(glGetUniformLocation(shaderHandle_vert, "Lod"), mipMap);
|
||||||
|
m_GaussianProgram_horiz->Bind();
|
||||||
|
glUniform1i(glGetUniformLocation(shaderHandle_horiz, "Lod"), mipMap);
|
||||||
|
|
||||||
|
|
||||||
//Horizontal pass, first use the given texture then save it to the horizontal framebuffer.
|
//Horizontal pass, first use the given texture then save it to the horizontal framebuffer.
|
||||||
m_GaussianFrameBuffer_horiz.Bind();
|
m_GaussianFrameBuffer_horiz[mipMap].Bind();
|
||||||
m_GaussianProgram_horiz->Bind();
|
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, texture);
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
glBindVertexArray(m_ScreenQuad->VAO);
|
glBindVertexArray(m_ScreenQuad->VAO);
|
||||||
@@ -123,55 +193,56 @@ void DrawBloomPass::Draw(GLuint texture)
|
|||||||
//Iterate some times to make it more gaussian.
|
//Iterate some times to make it more gaussian.
|
||||||
for (int i = 1; i < m_Iterations; i++) {
|
for (int i = 1; i < m_Iterations; i++) {
|
||||||
//Vertical pass
|
//Vertical pass
|
||||||
m_GaussianFrameBuffer_vert.Bind();
|
m_GaussianFrameBuffer_vert[mipMap].Bind();
|
||||||
m_GaussianProgram_vert->Bind();
|
m_GaussianProgram_vert->Bind();
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz);
|
glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz);
|
||||||
|
|
||||||
glBindVertexArray(m_ScreenQuad->VAO);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1
|
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
||||||
//horizontal pass
|
//horizontal pass
|
||||||
m_GaussianFrameBuffer_vert.Unbind();
|
m_GaussianFrameBuffer_vert[mipMap].Unbind();
|
||||||
|
|
||||||
m_GaussianFrameBuffer_horiz.Bind();
|
m_GaussianFrameBuffer_horiz[mipMap].Bind();
|
||||||
m_GaussianProgram_horiz->Bind();
|
m_GaussianProgram_horiz->Bind();
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_vert);
|
glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_vert);
|
||||||
|
|
||||||
glBindVertexArray(m_ScreenQuad->VAO);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1
|
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
||||||
m_GaussianFrameBuffer_horiz.Unbind();
|
m_GaussianFrameBuffer_horiz[mipMap].Unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
//final vertical gaussian after the iterations are done
|
//final vertical gaussian after the iterations are done
|
||||||
|
|
||||||
m_GaussianFrameBuffer_vert.Bind();
|
m_GaussianFrameBuffer_vert[mipMap].Bind();
|
||||||
m_GaussianProgram_vert->Bind();
|
m_GaussianProgram_vert->Bind();
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz);
|
glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz);
|
||||||
glBindVertexArray(m_ScreenQuad->VAO);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1
|
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
||||||
|
|
||||||
GLERROR("DrawBloomPass::Draw: END");
|
GLERROR("DrawBloomPass::Draw: END");
|
||||||
|
glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
m_GaussianFrameBuffer_vert[mipMap].Unbind();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawBloomPass::CombineGaussianBlur()
|
||||||
void DrawBloomPass::OnWindowResize()
|
|
||||||
{
|
{
|
||||||
if (m_Quality == 0) {
|
m_GaussianCombineBuffer.Bind();
|
||||||
return;
|
m_GaussianCombineProgram->Bind();
|
||||||
}
|
glUniform1i(glGetUniformLocation(m_GaussianCombineProgram->GetHandle(), "MaxMipMap"), m_BloomLod);
|
||||||
CommonFunctions::GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
|
||||||
m_GaussianFrameBuffer_vert.Generate();
|
glActiveTexture(GL_TEXTURE0);
|
||||||
CommonFunctions::GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_vert);
|
||||||
m_GaussianFrameBuffer_horiz.Generate();
|
glBindVertexArray(m_ScreenQuad->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
||||||
|
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1
|
||||||
|
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ void DrawFinalPass::InitializeTextures()
|
|||||||
|
|
||||||
void DrawFinalPass::InitializeFrameBuffers()
|
void DrawFinalPass::InitializeFrameBuffers()
|
||||||
{
|
{
|
||||||
CommonFunctions::GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
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_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);
|
||||||
//GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_FLOAT, 4);
|
//GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_FLOAT, 4);
|
||||||
//GenerateTexture(&m_StencilTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_STENCIL, GL_STENCIL_INDEX8, GL_INT);
|
//GenerateTexture(&m_StencilTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_STENCIL, GL_STENCIL_INDEX8, GL_INT);
|
||||||
|
|
||||||
@@ -311,6 +311,8 @@ void DrawFinalPass::Draw(RenderScene& scene, BlurHUD* blurHUDPass)
|
|||||||
GLERROR("TransparentObjects");
|
GLERROR("TransparentObjects");
|
||||||
//state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
//state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
stateSprite->Enable(GL_DEPTH_TEST);
|
stateSprite->Enable(GL_DEPTH_TEST);
|
||||||
|
//stateSprite->AlphaFunc(GL_GEQUAL, 0.05f);
|
||||||
|
//stateSprite->Enable(GL_ALPHA_TEST);
|
||||||
DrawSprites(scene.Jobs.SpriteJob, scene);
|
DrawSprites(scene.Jobs.SpriteJob, scene);
|
||||||
GLERROR("SpriteJobs");
|
GLERROR("SpriteJobs");
|
||||||
|
|
||||||
@@ -343,8 +345,8 @@ void DrawFinalPass::OnWindowResize()
|
|||||||
//InitializeFrameBuffers();
|
//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);
|
||||||
CommonFunctions::GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
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_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);
|
||||||
m_FinalPassFrameBuffer.Generate();
|
m_FinalPassFrameBuffer.Generate();
|
||||||
|
|
||||||
GLERROR("Error changing texture resolutions");
|
GLERROR("Error changing texture resolutions");
|
||||||
@@ -1269,23 +1271,34 @@ void DrawFinalPass::DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, Rend
|
|||||||
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
glUniform3fv(glGetUniformLocation(shaderHandle, "CameraPos"), 1, glm::value_ptr(scene.Camera->Position()));
|
glUniform3fv(glGetUniformLocation(shaderHandle, "CameraPos"), 1, glm::value_ptr(scene.Camera->Position()));
|
||||||
|
RenderState* jobState = new RenderState();
|
||||||
|
|
||||||
|
|
||||||
for(auto& job : jobs) {
|
for(auto& job : jobs) {
|
||||||
auto spriteJob = std::dynamic_pointer_cast<SpriteJob>(job);
|
auto spriteJob = std::dynamic_pointer_cast<SpriteJob>(job);
|
||||||
RenderState jobState;
|
|
||||||
|
|
||||||
if (spriteJob) {
|
if (spriteJob) {
|
||||||
if(spriteJob->Depth == 0) {
|
if(spriteJob->Depth == 0) {
|
||||||
jobState.Disable(GL_DEPTH_TEST);
|
jobState->Disable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * spriteJob->Matrix));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * spriteJob->Matrix));
|
||||||
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(spriteJob->Color));
|
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(spriteJob->Color));
|
||||||
glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(spriteJob->FillColor));
|
glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(spriteJob->FillColor));
|
||||||
glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), spriteJob->FillPercentage);
|
glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), spriteJob->FillPercentage);
|
||||||
|
glUniform1f(glGetUniformLocation(shaderHandle, "ScaleX"), spriteJob->ScaleX);
|
||||||
|
glUniform1f(glGetUniformLocation(shaderHandle, "ScaleY"), spriteJob->ScaleY);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
if (spriteJob->DiffuseTexture != nullptr) {
|
if (spriteJob->DiffuseTexture != nullptr) {
|
||||||
glBindTexture(GL_TEXTURE_2D, spriteJob->DiffuseTexture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, spriteJob->DiffuseTexture->m_Texture);
|
||||||
|
if (spriteJob->Linear) {
|
||||||
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||||
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
} else {
|
||||||
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
|
||||||
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
glBindTexture(GL_TEXTURE_2D, m_ErrorTexture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, m_ErrorTexture->m_Texture);
|
||||||
}
|
}
|
||||||
@@ -1303,6 +1316,7 @@ void DrawFinalPass::DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, Rend
|
|||||||
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
delete jobState;
|
||||||
// m_SpriteProgram->Unbind();
|
// m_SpriteProgram->Unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ DrawFinalPassState::DrawFinalPassState(GLuint frameBuffer)
|
|||||||
Enable(GL_DEPTH_TEST);
|
Enable(GL_DEPTH_TEST);
|
||||||
DepthMask(GL_TRUE);
|
DepthMask(GL_TRUE);
|
||||||
Enable(GL_CULL_FACE);
|
Enable(GL_CULL_FACE);
|
||||||
|
Enable(GL_ALPHA_TEST);
|
||||||
|
AlphaFunc(GL_GEQUAL, 0.05f);
|
||||||
// Enable(GL_STENCIL_TEST);
|
// Enable(GL_STENCIL_TEST);
|
||||||
// StencilFunc(GL_NOTEQUAL, 1, 0xFF);
|
// StencilFunc(GL_NOTEQUAL, 1, 0xFF);
|
||||||
// StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
// StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
#include "Rendering/FrameBuffer.h"
|
#include "Rendering/FrameBuffer.h"
|
||||||
|
|
||||||
|
|
||||||
BufferResource::BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment)
|
BufferResource::BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment, GLuint mipMapLod)
|
||||||
{
|
{
|
||||||
m_ResourceHandle = resourceHandle;
|
m_ResourceHandle = resourceHandle;
|
||||||
m_ResourceType = resourceType;
|
m_ResourceType = resourceType;
|
||||||
m_Attachment = attachment;
|
m_Attachment = attachment;
|
||||||
|
m_MipMapLod = mipMapLod;
|
||||||
}
|
}
|
||||||
|
|
||||||
Texture2D::~Texture2D()
|
Texture2D::~Texture2D()
|
||||||
@@ -58,7 +59,7 @@ void FrameBuffer::Generate()
|
|||||||
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:
|
case GL_TEXTURE_2D:
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle, 0);
|
glFramebufferTexture(GL_FRAMEBUFFER, (*it)->m_Attachment, *(*it)->m_ResourceHandle, (*it)->m_MipMapLod);
|
||||||
GLERROR("FrameBuffer generate: glFramebufferTexture2D");
|
GLERROR("FrameBuffer generate: glFramebufferTexture2D");
|
||||||
break;
|
break;
|
||||||
case GL_RENDERBUFFER:
|
case GL_RENDERBUFFER:
|
||||||
|
|||||||
@@ -42,6 +42,15 @@ void LightCullingPass::SetSSBOSizes()
|
|||||||
{
|
{
|
||||||
m_NumberOfTiles = (int)(m_Renderer->GetViewportSize().Width/TILE_SIZE) * (int)(m_Renderer->GetViewportSize().Height/TILE_SIZE);
|
m_NumberOfTiles = (int)(m_Renderer->GetViewportSize().Width/TILE_SIZE) * (int)(m_Renderer->GetViewportSize().Height/TILE_SIZE);
|
||||||
|
|
||||||
|
if (m_Frustums != nullptr) {
|
||||||
|
delete[] m_Frustums;
|
||||||
|
}
|
||||||
|
if (m_LightGrid != nullptr) {
|
||||||
|
delete[] m_LightGrid;
|
||||||
|
}
|
||||||
|
if (m_LightIndex != nullptr) {
|
||||||
|
delete[] m_LightIndex;
|
||||||
|
}
|
||||||
m_Frustums = new Frustum[m_NumberOfTiles];
|
m_Frustums = new Frustum[m_NumberOfTiles];
|
||||||
m_LightGrid = new LightGrid[m_NumberOfTiles];
|
m_LightGrid = new LightGrid[m_NumberOfTiles];
|
||||||
m_LightIndex = new float[m_NumberOfTiles*MAX_LIGHTS_PER_TILE];
|
m_LightIndex = new float[m_NumberOfTiles*MAX_LIGHTS_PER_TILE];
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ void PickingPass::InitializeTextures()
|
|||||||
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RG8, GL_RG, GL_UNSIGNED_BYTE);
|
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RG8, GL_RG, GL_UNSIGNED_BYTE);
|
||||||
|
|
||||||
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_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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PickingPass::InitializeFrameBuffers()
|
void PickingPass::InitializeFrameBuffers()
|
||||||
@@ -219,7 +219,7 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
m_PickingSkinnedProgram->Bind();
|
m_PickingSkinnedProgram->Bind();
|
||||||
lastShader = m_PickingSkinnedProgram->GetHandle();
|
lastShader = m_PickingSkinnedProgram->GetHandle();
|
||||||
}
|
}
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * modelJob->Matrix));
|
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * modelJob->Matrix));
|
||||||
glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
||||||
|
|
||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
|
|||||||
@@ -9,10 +9,11 @@ RenderSystem::RenderSystem(SystemParams params, const IRenderer* renderer, Rende
|
|||||||
, m_Octree(frustumCullOctree)
|
, m_Octree(frustumCullOctree)
|
||||||
{
|
{
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &RenderSystem::OnSetCamera);
|
EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &RenderSystem::OnSetCamera);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EResolutionChanged, &RenderSystem::OnResolutionChanged);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &RenderSystem::OnInputCommand);
|
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &RenderSystem::OnInputCommand);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &RenderSystem::OnPlayerSpawned);
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &RenderSystem::OnPlayerSpawned);
|
||||||
|
|
||||||
m_Camera = new Camera((float)m_Renderer->Resolution().Width / m_Renderer->Resolution().Height, glm::radians(45.f), 0.01f, 5000.f);
|
m_Camera = new Camera((float)m_Renderer->GetViewportSize().Width / m_Renderer->GetViewportSize().Height, glm::radians(45.f), 0.01f, 5000.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderSystem::~RenderSystem()
|
RenderSystem::~RenderSystem()
|
||||||
@@ -20,11 +21,18 @@ RenderSystem::~RenderSystem()
|
|||||||
delete m_Camera;
|
delete m_Camera;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RenderSystem::OnResolutionChanged(Events::ResolutionChanged& e)
|
||||||
|
{
|
||||||
|
// Update camera aspect ration on resolution change
|
||||||
|
m_Camera->SetAspectRatio((float)e.NewResolution.Width / e.NewResolution.Height);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool RenderSystem::OnSetCamera(Events::SetCamera& e)
|
bool RenderSystem::OnSetCamera(Events::SetCamera& e)
|
||||||
{
|
{
|
||||||
ComponentWrapper cTransform = e.CameraEntity["Transform"];
|
ComponentWrapper cTransform = e.CameraEntity["Transform"];
|
||||||
ComponentWrapper cCamera = e.CameraEntity["Camera"];
|
ComponentWrapper cCamera = e.CameraEntity["Camera"];
|
||||||
m_Camera->SetFOV((double)cCamera["FOV"]);
|
m_Camera->SetFOV(glm::radians((double)cCamera["FOV"]));
|
||||||
m_Camera->SetNearClip((double)cCamera["NearClip"]);
|
m_Camera->SetNearClip((double)cCamera["NearClip"]);
|
||||||
m_Camera->SetFarClip((double)cCamera["FarClip"]);
|
m_Camera->SetFarClip((double)cCamera["FarClip"]);
|
||||||
m_Camera->SetPosition(cTransform["Position"]);
|
m_Camera->SetPosition(cTransform["Position"]);
|
||||||
|
|||||||
@@ -36,16 +36,24 @@ void Renderer::Initialize()
|
|||||||
m_ImGuiRenderPass = new ImGuiRenderPass(this, m_EventBroker);
|
m_ImGuiRenderPass = new ImGuiRenderPass(this, m_EventBroker);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer::glfwWindowSizeCallback(GLFWwindow* window, int width, int height)
|
||||||
|
{
|
||||||
|
m_WindowToRenderer[window]->setWindowSize(Rectangle(width, height));
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::glfwFrameBufferCallback(GLFWwindow* window, int width, int height)
|
void Renderer::glfwFrameBufferCallback(GLFWwindow* window, int width, int height)
|
||||||
{
|
{
|
||||||
glViewport(0, 0, width, height);
|
m_WindowToRenderer[window]->updateFramebufferSize();
|
||||||
Renderer* currentRenderer = m_WindowToRenderer[window];
|
}
|
||||||
currentRenderer->m_ViewportSize = Rectangle(width, height);
|
|
||||||
currentRenderer->m_PickingPass->OnWindowResize();
|
void Renderer::SetResolution(const Rectangle& resolution)
|
||||||
currentRenderer->m_DrawFinalPass->OnWindowResize();
|
{
|
||||||
currentRenderer->m_LightCullingPass->OnWindowResize();
|
m_Resolution = resolution;
|
||||||
currentRenderer->m_DrawBloomPass->OnWindowResize();
|
|
||||||
currentRenderer->m_SSAOPass->OnWindowResize();
|
if (m_Window != nullptr) {
|
||||||
|
setWindowSize(resolution);
|
||||||
|
updateFramebufferSize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::InitializeWindow()
|
void Renderer::InitializeWindow()
|
||||||
@@ -67,6 +75,7 @@ void Renderer::InitializeWindow()
|
|||||||
LOG_ERROR("GLFW: Failed to create window");
|
LOG_ERROR("GLFW: Failed to create window");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
glfwSetWindowSizeCallback(m_Window, &glfwWindowSizeCallback);
|
||||||
glfwSetFramebufferSizeCallback(m_Window, &glfwFrameBufferCallback);
|
glfwSetFramebufferSizeCallback(m_Window, &glfwFrameBufferCallback);
|
||||||
glfwMakeContextCurrent(m_Window);
|
glfwMakeContextCurrent(m_Window);
|
||||||
|
|
||||||
@@ -111,6 +120,31 @@ void Renderer::InputUpdate(double dt)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer::setWindowSize(Rectangle size)
|
||||||
|
{
|
||||||
|
m_Resolution = size;
|
||||||
|
glfwSetWindowSize(m_Window, size.Width, size.Height);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::updateFramebufferSize()
|
||||||
|
{
|
||||||
|
Events::ResolutionChanged e;
|
||||||
|
e.OldResolution = m_ViewportSize;
|
||||||
|
|
||||||
|
int width, height;
|
||||||
|
glfwGetFramebufferSize(m_Window, &width, &height);
|
||||||
|
glViewport(0, 0, width, height);
|
||||||
|
m_ViewportSize = Rectangle(width, height);
|
||||||
|
m_PickingPass->OnWindowResize();
|
||||||
|
m_DrawFinalPass->OnWindowResize();
|
||||||
|
m_LightCullingPass->OnWindowResize();
|
||||||
|
m_DrawBloomPass->OnWindowResize();
|
||||||
|
m_SSAOPass->OnWindowResize();
|
||||||
|
|
||||||
|
e.NewResolution = m_ViewportSize;
|
||||||
|
m_EventBroker->Publish(e);
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::Update(double dt)
|
void Renderer::Update(double dt)
|
||||||
{
|
{
|
||||||
m_EventBroker->Process<Renderer>();
|
m_EventBroker->Process<Renderer>();
|
||||||
@@ -263,6 +297,7 @@ void Renderer::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filterin
|
|||||||
GLERROR("Texture initialization failed");
|
GLERROR("Texture initialization failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Renderer::InitializeRenderPasses()
|
void Renderer::InitializeRenderPasses()
|
||||||
{
|
{
|
||||||
m_PickingPass = new PickingPass(this, m_EventBroker);
|
m_PickingPass = new PickingPass(this, m_EventBroker);
|
||||||
|
|||||||
@@ -233,6 +233,11 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
|
|||||||
GLuint shaderHandle_horiz = m_GaussianProgram_horiz->GetHandle();
|
GLuint shaderHandle_horiz = m_GaussianProgram_horiz->GetHandle();
|
||||||
GLuint shaderHandle_vert = m_GaussianProgram_vert->GetHandle();
|
GLuint shaderHandle_vert = m_GaussianProgram_vert->GetHandle();
|
||||||
|
|
||||||
|
m_GaussianProgram_vert->Bind();
|
||||||
|
glUniform1i(glGetUniformLocation(shaderHandle_vert, "Lod"), 0);
|
||||||
|
m_GaussianProgram_horiz->Bind();
|
||||||
|
glUniform1i(glGetUniformLocation(shaderHandle_horiz, "Lod"), 0);
|
||||||
|
|
||||||
m_GaussianFrameBuffer_horiz.Bind();
|
m_GaussianFrameBuffer_horiz.Bind();
|
||||||
m_GaussianProgram_horiz->Bind();
|
m_GaussianProgram_horiz->Bind();
|
||||||
|
|
||||||
@@ -252,8 +257,6 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
|
|||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_Gaussian_horiz);
|
glBindTexture(GL_TEXTURE_2D, m_Gaussian_horiz);
|
||||||
|
|
||||||
glBindVertexArray(m_ScreenQuad->VAO);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
|
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
||||||
//horizontal pass
|
//horizontal pass
|
||||||
@@ -265,8 +268,6 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
|
|||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_Gaussian_vert);
|
glBindTexture(GL_TEXTURE_2D, m_Gaussian_vert);
|
||||||
|
|
||||||
glBindVertexArray(m_ScreenQuad->VAO);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
|
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
||||||
m_GaussianFrameBuffer_horiz.Unbind();
|
m_GaussianFrameBuffer_horiz.Unbind();
|
||||||
@@ -279,8 +280,7 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
|
|||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_Gaussian_horiz);
|
glBindTexture(GL_TEXTURE_2D, m_Gaussian_horiz);
|
||||||
glBindVertexArray(m_ScreenQuad->VAO);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
|
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,12 @@ void ShadowPass::InitializeShaderPrograms()
|
|||||||
m_ShadowProgram->BindFragDataLocation(0, "ShadowMap");
|
m_ShadowProgram->BindFragDataLocation(0, "ShadowMap");
|
||||||
m_ShadowProgram->Link();
|
m_ShadowProgram->Link();
|
||||||
|
|
||||||
|
m_ShadowProgramSkinned = ResourceManager::Load<ShaderProgram>("#ShadowProgramSkinned");
|
||||||
|
m_ShadowProgramSkinned->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ShadowSkinned.vert.glsl")));
|
||||||
|
m_ShadowProgramSkinned->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Shadow.frag.glsl")));
|
||||||
|
m_ShadowProgramSkinned->Compile();
|
||||||
|
m_ShadowProgramSkinned->BindFragDataLocation(0, "ShadowMap");
|
||||||
|
m_ShadowProgramSkinned->Link();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShadowPass::ClearBuffer()
|
void ShadowPass::ClearBuffer()
|
||||||
@@ -212,8 +217,7 @@ void ShadowPass::Draw(RenderScene & scene)
|
|||||||
|
|
||||||
ShadowPassState* state = new ShadowPassState(m_DepthBuffer.GetHandle());
|
ShadowPassState* state = new ShadowPassState(m_DepthBuffer.GetHandle());
|
||||||
|
|
||||||
m_ShadowProgram->Bind();
|
|
||||||
GLuint shaderHandle = m_ShadowProgram->GetHandle();
|
|
||||||
glViewport(0, 0, m_ResolutionSizeWidth, m_ResolutionSizeHeight);
|
glViewport(0, 0, m_ResolutionSizeWidth, m_ResolutionSizeHeight);
|
||||||
|
|
||||||
for (int i = 0; i < m_CurrentNrOfSplits; i++) {
|
for (int i = 0; i < m_CurrentNrOfSplits; i++) {
|
||||||
@@ -221,7 +225,11 @@ 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;
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
if (directionalLightJob) {
|
if (directionalLightJob) {
|
||||||
@@ -232,9 +240,19 @@ 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, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection[i]));
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView[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) {
|
||||||
@@ -245,6 +263,23 @@ void ShadowPass::Draw(RenderScene & scene)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(modelJob->Model->IsSkinned()) {
|
||||||
|
m_ShadowProgramSkinned->Bind();
|
||||||
|
shaderHandle = m_ShadowProgramSkinned->GetHandle();
|
||||||
|
|
||||||
|
std::vector<glm::mat4> frameBones;
|
||||||
|
if (modelJob->BlendTree != nullptr) {
|
||||||
|
frameBones = modelJob->BlendTree->GetFinalPose();
|
||||||
|
} else {
|
||||||
|
frameBones = modelJob->Skeleton->GetTPose();
|
||||||
|
}
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
m_ShadowProgram->Bind();
|
||||||
|
shaderHandle = m_ShadowProgram->GetHandle();
|
||||||
|
}
|
||||||
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||||
glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), 1.f);
|
glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), 1.f);
|
||||||
|
|
||||||
@@ -265,6 +300,23 @@ void ShadowPass::Draw(RenderScene & scene)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (modelJob->Model->IsSkinned()) {
|
||||||
|
m_ShadowProgramSkinned->Bind();
|
||||||
|
shaderHandle = m_ShadowProgramSkinned->GetHandle();
|
||||||
|
|
||||||
|
std::vector<glm::mat4> frameBones;
|
||||||
|
if (modelJob->BlendTree != nullptr) {
|
||||||
|
frameBones = modelJob->BlendTree->GetFinalPose();
|
||||||
|
} else {
|
||||||
|
frameBones = modelJob->Skeleton->GetTPose();
|
||||||
|
}
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
m_ShadowProgram->Bind();
|
||||||
|
shaderHandle = m_ShadowProgram->GetHandle();
|
||||||
|
}
|
||||||
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||||
glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), modelJob->Color.a);
|
glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), modelJob->Color.a);
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
TextureSprite::TextureSprite(std::string path)
|
TextureSprite::TextureSprite(std::string path)
|
||||||
:Texture(path)
|
:Texture(path)
|
||||||
{
|
{
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
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_MIPMAP_NEAREST);
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
GLERROR("Texture load");
|
GLERROR("Texture load");
|
||||||
}
|
}
|
||||||
@@ -25,10 +25,12 @@ void CommonFunctions::GenerateMultiSampleTexture(GLuint* texture, int numSamples
|
|||||||
|
|
||||||
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 format, GLenum type, GLint numMipMaps)
|
||||||
{
|
{
|
||||||
|
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, GL_RGBA8, dimensions.x, dimensions.y);
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, dimensions.x, dimensions.y, format, type, texture);
|
//glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, dimensions.x, dimensions.y, format, type, NULL);
|
||||||
|
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);
|
||||||
|
|||||||
@@ -36,10 +36,6 @@ ScreenCoords::PixelData ScreenCoords::ToPixelData(float x, float y, FrameBuffer*
|
|||||||
unsigned char pdata[3];
|
unsigned char pdata[3];
|
||||||
glReadPixels(x, y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pdata);
|
glReadPixels(x, y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pdata);
|
||||||
GLERROR("glReadPixels(pdata) Error");
|
GLERROR("glReadPixels(pdata) Error");
|
||||||
PickDataBuffer->Unbind();
|
|
||||||
GLERROR("Unbind Error");
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, DepthBuffer);
|
|
||||||
GLERROR("glBindFramebuffer(DepthBuffer) Error");
|
|
||||||
float depthData;
|
float depthData;
|
||||||
glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depthData);
|
glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depthData);
|
||||||
GLERROR("glReadPixels(depthData) Error");
|
GLERROR("glReadPixels(depthData) Error");
|
||||||
|
|||||||
@@ -108,10 +108,10 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
|||||||
//change what model is displaying (change all in case 2 capturepoints has been captured on the same frame)
|
//change what model is displaying (change all in case 2 capturepoints has been captured on the same frame)
|
||||||
for (int i = 0; i < m_NumberOfCapturePoints; i++) {
|
for (int i = 0; i < m_NumberOfCapturePoints; i++) {
|
||||||
auto owner = (int)m_CapturePointNumberToEntityMap[i]["Team"]["Team"];
|
auto owner = (int)m_CapturePointNumberToEntityMap[i]["Team"]["Team"];
|
||||||
if (m_CapturePointNumberToEntityMap[i].FirstChildByName("Red").ID != EntityID_Invalid) {
|
if (m_CapturePointNumberToEntityMap[i].FirstChildByName("Red").Valid()) {
|
||||||
(bool&)m_CapturePointNumberToEntityMap[i].FirstChildByName("Red")["Model"]["Visible"] = owner == redTeam ? true : false;
|
ChangeCapturePointModelsVisibility(m_CapturePointNumberToEntityMap[i].FirstChildByName("Red"), owner == redTeam);
|
||||||
(bool&)m_CapturePointNumberToEntityMap[i].FirstChildByName("Blue")["Model"]["Visible"] = owner == blueTeam ? true : false;
|
ChangeCapturePointModelsVisibility(m_CapturePointNumberToEntityMap[i].FirstChildByName("Blue"), owner == blueTeam);
|
||||||
(bool&)m_CapturePointNumberToEntityMap[i].FirstChildByName("Spectator")["Model"]["Visible"] = owner == spectatorTeam ? true : false;
|
ChangeCapturePointModelsVisibility(m_CapturePointNumberToEntityMap[i].FirstChildByName("Spectator"), owner == spectatorTeam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//save the next cap points and publish the captured event
|
//save the next cap points and publish the captured event
|
||||||
@@ -232,6 +232,14 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CapturePointSystem::ChangeCapturePointModelsVisibility(EntityWrapper &capturePointModels, bool isOwner) {
|
||||||
|
(bool&)capturePointModels["Model"]["Visible"] = isOwner;
|
||||||
|
for (auto& capModel : capturePointModels.ChildrenWithComponent("Model"))
|
||||||
|
{
|
||||||
|
(bool&)capModel["Model"]["Visible"] = isOwner;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e)
|
bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e)
|
||||||
{
|
{
|
||||||
//personEntered = e.Entity, thingEntered = e.Trigger
|
//personEntered = e.Entity, thingEntered = e.Trigger
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ SpectatorCameraSystem::SpectatorCameraSystem(SystemParams params)
|
|||||||
, m_PickedTeam(-1)
|
, m_PickedTeam(-1)
|
||||||
{
|
{
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &SpectatorCameraSystem::OnInputCommand);
|
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &SpectatorCameraSystem::OnInputCommand);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EDisconnect, &SpectatorCameraSystem::OnDisconnect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpectatorCameraSystem::Update(double dt)
|
void SpectatorCameraSystem::Update(double dt)
|
||||||
@@ -87,4 +88,17 @@ bool SpectatorCameraSystem::OnInputCommand(const Events::InputCommand& e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SpectatorCameraSystem::OnDisconnect(const Events::PlayerDisconnected& e)
|
||||||
|
{
|
||||||
|
// If local player gets disconnected, they should be set to
|
||||||
|
// the spectator camera next time a map loads that has one.
|
||||||
|
if (e.Entity == LocalPlayer.ID) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user