Merge remote-tracking branch 'origin/master' into Forward+
# Conflicts: # include/Engine/Rendering/PickingPass.h # include/Engine/Rendering/Renderer.h # resources/Schema/Entities/Test.xml # src/Engine/Rendering/DrawScenePass.cpp # src/Engine/Rendering/PickingPass.cpp # src/Engine/Rendering/RenderQueueFactory.cpp # src/Engine/Rendering/Renderer.cpp
This commit is contained in:
+1
-1
Submodule assets updated: c8e631f449...6cbf2365d4
@@ -14,6 +14,7 @@ struct ComponentInfo
|
|||||||
|
|
||||||
struct Field_t
|
struct Field_t
|
||||||
{
|
{
|
||||||
|
std::string Name;
|
||||||
std::string Type;
|
std::string Type;
|
||||||
unsigned int Offset;
|
unsigned int Offset;
|
||||||
unsigned int Stride;
|
unsigned int Stride;
|
||||||
@@ -21,7 +22,7 @@ struct ComponentInfo
|
|||||||
|
|
||||||
std::string Name;
|
std::string Name;
|
||||||
std::unordered_map<std::string, Field_t> Fields;
|
std::unordered_map<std::string, Field_t> Fields;
|
||||||
std::vector<const Field_t*> FieldsInOrder;
|
std::vector<std::string> FieldsInOrder;
|
||||||
Meta_t Meta;
|
Meta_t Meta;
|
||||||
std::shared_ptr<char> Defaults = nullptr;
|
std::shared_ptr<char> Defaults = nullptr;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
#ifndef Transform_h__
|
||||||
|
#define Transform_h__
|
||||||
|
|
||||||
|
#include "../GLM.h"
|
||||||
|
#include "World.h"
|
||||||
|
|
||||||
|
static class Transform
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static glm::vec3 AbsolutePosition(World* world, EntityID entity)
|
||||||
|
{
|
||||||
|
glm::vec3 position;
|
||||||
|
|
||||||
|
while (entity != EntityID_Invalid) {
|
||||||
|
ComponentWrapper transform = world->GetComponent(entity, "Transform");
|
||||||
|
EntityID parent = world->GetParent(entity);
|
||||||
|
position += AbsoluteOrientation(world, parent) * (glm::vec3)transform["Position"];
|
||||||
|
entity = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
return position;
|
||||||
|
};
|
||||||
|
|
||||||
|
static glm::quat AbsoluteOrientation(World* world, EntityID entity)
|
||||||
|
{
|
||||||
|
glm::quat orientation;
|
||||||
|
|
||||||
|
while (entity != EntityID_Invalid) {
|
||||||
|
ComponentWrapper transform = world->GetComponent(entity, "Transform");
|
||||||
|
orientation = glm::quat((glm::vec3)transform["Orientation"]) * orientation;
|
||||||
|
entity = world->GetParent(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
return orientation;
|
||||||
|
};
|
||||||
|
|
||||||
|
static glm::vec3 AbsoluteScale(World* world, EntityID entity)
|
||||||
|
{
|
||||||
|
glm::vec3 scale(1.f);
|
||||||
|
|
||||||
|
while (entity != EntityID_Invalid) {
|
||||||
|
ComponentWrapper transform = world->GetComponent(entity, "Transform");
|
||||||
|
scale *= (glm::vec3)transform["Scale"];
|
||||||
|
entity = world->GetParent(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
return scale;
|
||||||
|
};
|
||||||
|
|
||||||
|
static glm::mat4 ModelMatrix(EntityID entity, World* world)
|
||||||
|
{
|
||||||
|
glm::vec3 position = Transform::AbsolutePosition(world, entity);
|
||||||
|
glm::quat orientation = Transform::AbsoluteOrientation(world, entity);
|
||||||
|
glm::vec3 scale = Transform::AbsoluteScale(world, entity);
|
||||||
|
|
||||||
|
glm::mat4 modelMatrix = glm::translate(glm::mat4(), position) * glm::toMat4(orientation) * glm::scale(scale);
|
||||||
|
return modelMatrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -9,9 +9,8 @@
|
|||||||
#include "../Core/ConfigFile.h"
|
#include "../Core/ConfigFile.h"
|
||||||
#include "../Input/EInputCommand.h"
|
#include "../Input/EInputCommand.h"
|
||||||
#include "../Rendering/IRenderer.h"
|
#include "../Rendering/IRenderer.h"
|
||||||
#include "../Rendering/EPicking.h"
|
#include "../Core/Transform.h"
|
||||||
#include "../Core/EFileDropped.h"
|
#include "../Core/EFileDropped.h"
|
||||||
#include "../Rendering/RenderQueueFactory.h"
|
|
||||||
#include "../Core/EntityFilePreprocessor.h"
|
#include "../Core/EntityFilePreprocessor.h"
|
||||||
#include "../Core/EntityFileParser.h"
|
#include "../Core/EntityFileParser.h"
|
||||||
#include "../Core/EntityFileWriter.h"
|
#include "../Core/EntityFileWriter.h"
|
||||||
@@ -26,6 +25,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
IRenderer* m_Renderer;
|
IRenderer* m_Renderer;
|
||||||
World* m_World = nullptr;
|
World* m_World = nullptr;
|
||||||
|
Camera* m_Camera = nullptr;
|
||||||
|
|
||||||
bool m_Enabled;
|
bool m_Enabled;
|
||||||
bool m_Visible;
|
bool m_Visible;
|
||||||
@@ -57,6 +57,7 @@ private:
|
|||||||
EntityID m_WidgetOrigin = EntityID_Invalid;
|
EntityID m_WidgetOrigin = EntityID_Invalid;
|
||||||
glm::vec3 m_WidgetCurrentAxis;
|
glm::vec3 m_WidgetCurrentAxis;
|
||||||
float m_WidgetPickingDepth = 0.f;
|
float m_WidgetPickingDepth = 0.f;
|
||||||
|
glm::vec3 m_WidgetPickingPosition = glm::vec3(0);
|
||||||
|
|
||||||
EntityID m_Selection = EntityID_Invalid;
|
EntityID m_Selection = EntityID_Invalid;
|
||||||
EntityID m_LastSelection = EntityID_Invalid;
|
EntityID m_LastSelection = EntityID_Invalid;
|
||||||
@@ -75,11 +76,10 @@ private:
|
|||||||
bool OnMousePress(const Events::MousePress& e);
|
bool OnMousePress(const Events::MousePress& e);
|
||||||
EventRelay<EditorSystem, Events::MouseMove> m_EMouseMove;
|
EventRelay<EditorSystem, Events::MouseMove> m_EMouseMove;
|
||||||
bool OnMouseMove(const Events::MouseMove& e);
|
bool OnMouseMove(const Events::MouseMove& e);
|
||||||
EventRelay<EditorSystem, Events::Picking> m_EPicking;
|
|
||||||
bool OnPicking(const Events::Picking& e);
|
|
||||||
EventRelay<EditorSystem, Events::FileDropped> m_EFileDropped;
|
EventRelay<EditorSystem, Events::FileDropped> m_EFileDropped;
|
||||||
bool OnFileDropped(const Events::FileDropped& e);
|
bool OnFileDropped(const Events::FileDropped& e);
|
||||||
|
|
||||||
|
void Picking();
|
||||||
void createWidget();
|
void createWidget();
|
||||||
void updateWidget();
|
void updateWidget();
|
||||||
void setWidgetMode(WidgetMode newMode);
|
void setWidgetMode(WidgetMode newMode);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public:
|
|||||||
m_TexturePressed = resourceName;
|
m_TexturePressed = resourceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw(RenderQueueCollection& rq) override
|
void Draw(RenderScene& rq) override
|
||||||
{
|
{
|
||||||
if (m_Texture == nullptr && !m_TextureReleased.empty()) {
|
if (m_Texture == nullptr && !m_TextureReleased.empty()) {
|
||||||
SetTexture(m_TextureReleased);
|
SetTexture(m_TextureReleased);
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ public:
|
|||||||
|
|
||||||
virtual void Update(double dt) { }
|
virtual void Update(double dt) { }
|
||||||
|
|
||||||
void DrawLayered(RenderQueueCollection& rq)
|
void DrawLayered(RenderScene& rq)
|
||||||
{
|
{
|
||||||
if (this->Hidden())
|
if (this->Hidden())
|
||||||
return;
|
return;
|
||||||
@@ -232,7 +232,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Draw(RenderQueueCollection& rq) { }
|
virtual void Draw(RenderScene& rq) { }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
::EventBroker* m_EventBroker;
|
::EventBroker* m_EventBroker;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public:
|
|||||||
void EnableScissor() { m_ScissorEnabled = true; }
|
void EnableScissor() { m_ScissorEnabled = true; }
|
||||||
void DisableScissor() { m_ScissorEnabled = false; }
|
void DisableScissor() { m_ScissorEnabled = false; }
|
||||||
|
|
||||||
void Draw(RenderQueueCollection& rq) override
|
void Draw(RenderScene& rq) override
|
||||||
{
|
{
|
||||||
if (m_Texture == nullptr)
|
if (m_Texture == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ public:
|
|||||||
~Client();
|
~Client();
|
||||||
void Start(World* world, EventBroker* eventBroker) override;
|
void Start(World* world, EventBroker* eventBroker) override;
|
||||||
void Update() override;
|
void Update() override;
|
||||||
void Close();
|
|
||||||
private:
|
private:
|
||||||
// Assio UDP logic
|
// Assio UDP logic
|
||||||
boost::asio::ip::udp::endpoint m_ReceiverEndpoint;
|
boost::asio::ip::udp::endpoint m_ReceiverEndpoint;
|
||||||
@@ -32,7 +31,7 @@ private:
|
|||||||
|
|
||||||
// Sending message to server logic
|
// Sending message to server logic
|
||||||
int bytesRead = -1;
|
int bytesRead = -1;
|
||||||
char readBuf[1024] = { 0 };
|
char readBuf[INPUTSIZE] = { 0 };
|
||||||
int snapshotInterval = 33;
|
int snapshotInterval = 33;
|
||||||
std::clock_t previousSnapshotMessage = std::clock();
|
std::clock_t previousSnapshotMessage = std::clock();
|
||||||
|
|
||||||
@@ -49,7 +48,6 @@ private:
|
|||||||
// Network logic
|
// Network logic
|
||||||
PlayerDefinition m_PlayerDefinitions[MAXCONNECTIONS];
|
PlayerDefinition m_PlayerDefinitions[MAXCONNECTIONS];
|
||||||
SnapshotDefinitions m_NextSnapshot;
|
SnapshotDefinitions m_NextSnapshot;
|
||||||
bool m_ThreadIsRunning = true;
|
|
||||||
double m_DurationOfPingTime;
|
double m_DurationOfPingTime;
|
||||||
std::clock_t m_StartPingTime;
|
std::clock_t m_StartPingTime;
|
||||||
// Use to check if we should send disconnect message
|
// Use to check if we should send disconnect message
|
||||||
@@ -59,7 +57,7 @@ private:
|
|||||||
// Private member functions
|
// Private member functions
|
||||||
void readFromServer();
|
void readFromServer();
|
||||||
void sendSnapshotToServer();
|
void sendSnapshotToServer();
|
||||||
int receive(char* data, size_t length);
|
int receive(char* data, size_t length);
|
||||||
void send(Packet& packet);
|
void send(Packet& packet);
|
||||||
void connect();
|
void connect();
|
||||||
void disconnect();
|
void disconnect();
|
||||||
@@ -67,6 +65,7 @@ private:
|
|||||||
void moveMessageHead(char*& data, size_t& length, size_t stepSize);
|
void moveMessageHead(char*& data, size_t& length, size_t stepSize);
|
||||||
void parseMessageType(Packet& packet);
|
void parseMessageType(Packet& packet);
|
||||||
void parseEventMessage(Packet& packet);
|
void parseEventMessage(Packet& packet);
|
||||||
|
void updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID, const std::string& componentType);
|
||||||
void parseConnect(Packet& packet);
|
void parseConnect(Packet& packet);
|
||||||
void parsePing();
|
void parsePing();
|
||||||
void parseServerPing();
|
void parseServerPing();
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "Network/Packet.h"
|
#include "Network/Packet.h"
|
||||||
|
|
||||||
#define MAXCONNECTIONS 8
|
#define MAXCONNECTIONS 8
|
||||||
#define INPUTSIZE 128
|
#define INPUTSIZE 4097
|
||||||
|
|
||||||
class Network
|
class Network
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,15 +14,17 @@ public:
|
|||||||
Packet(MessageType type, unsigned int& packetID);
|
Packet(MessageType type, unsigned int& packetID);
|
||||||
// Used to create packet from already existing data buffer.
|
// Used to create packet from already existing data buffer.
|
||||||
Packet(char* data, const int sizeOfPacket);
|
Packet(char* data, const int sizeOfPacket);
|
||||||
|
|
||||||
~Packet();
|
~Packet();
|
||||||
|
void Init(MessageType type, unsigned int& packetID);
|
||||||
|
|
||||||
// Add primitive types like int, float, char...
|
// Add primitive types like int, float, char...
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void WritePrimitive(T val)
|
void WritePrimitive(T val)
|
||||||
{
|
{
|
||||||
// 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)) {
|
||||||
LOG_WARNING("Packet AddPrimitive(): You are trying to add more than we have allocated for!");
|
LOG_WARNING("Packet AddPrimitive(): You are trying to add more than we have allocated for! New size is %i bytes\n", m_MaxPacketSize*2);
|
||||||
|
resizeData();
|
||||||
}
|
}
|
||||||
memcpy(m_Data + m_Offset, &val, sizeof(T));
|
memcpy(m_Data + m_Offset, &val, sizeof(T));
|
||||||
m_Offset += sizeof(T);
|
m_Offset += sizeof(T);
|
||||||
@@ -41,7 +43,7 @@ public:
|
|||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
// Add a string to the message
|
// Add a string to the message
|
||||||
void WriteString(std::string str);
|
void WriteString(const std::string& str);
|
||||||
// Add data to the message
|
// Add data to the message
|
||||||
void WriteData(char* data, int sizeOfData);
|
void WriteData(char* data, int sizeOfData);
|
||||||
// Pops the first element as if it was a string.
|
// Pops the first element as if it was a string.
|
||||||
@@ -50,12 +52,15 @@ public:
|
|||||||
|
|
||||||
int Size() { return m_Offset; };
|
int Size() { return m_Offset; };
|
||||||
char* Data() { return m_Data; };
|
char* Data() { return m_Data; };
|
||||||
|
unsigned int DataReadSize() { return m_ReturnDataOffset; }
|
||||||
|
unsigned int MaxSize() { return m_MaxPacketSize; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char* m_Data;
|
char* m_Data;
|
||||||
unsigned int m_ReturnDataOffset = 0;
|
unsigned int m_ReturnDataOffset = 0;
|
||||||
int m_Offset = 0;
|
int m_Offset = 0;
|
||||||
unsigned int m_MaxPacketSize = 128;
|
unsigned int m_MaxPacketSize = 512;
|
||||||
|
void resizeData();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -20,8 +20,6 @@ public:
|
|||||||
~Server();
|
~Server();
|
||||||
void Start(World* m_world, EventBroker *eventBroker) override;
|
void Start(World* m_world, EventBroker *eventBroker) override;
|
||||||
void Update() override;
|
void Update() override;
|
||||||
void Close();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// UDP logic
|
// UDP logic
|
||||||
boost::asio::ip::udp::endpoint m_ReceiverEndpoint;
|
boost::asio::ip::udp::endpoint m_ReceiverEndpoint;
|
||||||
@@ -30,7 +28,7 @@ private:
|
|||||||
PlayerDefinition m_PlayerDefinitions[MAXCONNECTIONS];
|
PlayerDefinition m_PlayerDefinitions[MAXCONNECTIONS];
|
||||||
|
|
||||||
// Sending messages to client logic
|
// Sending messages to client logic
|
||||||
char readBuffer[1024] = { 0 };
|
char readBuffer[INPUTSIZE] = { 0 };
|
||||||
int bytesRead = 0;
|
int bytesRead = 0;
|
||||||
// time for previouse message
|
// time for previouse message
|
||||||
std::clock_t previousePingMessage = std::clock();
|
std::clock_t previousePingMessage = std::clock();
|
||||||
@@ -56,9 +54,6 @@ private:
|
|||||||
unsigned int m_PreviousPacketID;
|
unsigned int m_PreviousPacketID;
|
||||||
unsigned int m_SendPacketID;
|
unsigned int m_SendPacketID;
|
||||||
|
|
||||||
// Close logic
|
|
||||||
bool m_ThreadIsRunning = true;
|
|
||||||
|
|
||||||
// Private member functions
|
// Private member functions
|
||||||
int receive(char* data, size_t length);
|
int receive(char* data, size_t length);
|
||||||
void readFromClients();
|
void readFromClients();
|
||||||
|
|||||||
@@ -26,13 +26,12 @@ public:
|
|||||||
glm::quat Orientation() const { return m_Orientation; }
|
glm::quat Orientation() const { return m_Orientation; }
|
||||||
void SetOrientation(glm::quat val);
|
void SetOrientation(glm::quat val);
|
||||||
|
|
||||||
/*float Pitch() const { return m_Pitch; }
|
|
||||||
void Pitch(float val);
|
|
||||||
float Yaw() const { return m_Yaw; }
|
|
||||||
void Yaw(float val);*/
|
|
||||||
|
|
||||||
glm::mat4 ProjectionMatrix() const { return m_ProjectionMatrix; }
|
glm::mat4 ProjectionMatrix() const { return m_ProjectionMatrix; }
|
||||||
|
void SetProjectionMatrix(glm::mat4 val);
|
||||||
|
|
||||||
glm::mat4 ViewMatrix() const { return m_ViewMatrix; }
|
glm::mat4 ViewMatrix() const { return m_ViewMatrix; }
|
||||||
|
void SetViewMatrix(glm::mat4 val);
|
||||||
|
|
||||||
|
|
||||||
float AspectRatio() const { return m_AspectRatio; }
|
float AspectRatio() const { return m_AspectRatio; }
|
||||||
void SetAspectRatio(float val);
|
void SetAspectRatio(float val);
|
||||||
@@ -46,11 +45,10 @@ public:
|
|||||||
float FarClip() const { return m_FarClip; }
|
float FarClip() const { return m_FarClip; }
|
||||||
void SetFarClip(float val);
|
void SetFarClip(float val);
|
||||||
|
|
||||||
|
void UpdateViewMatrix();
|
||||||
|
void UpdateProjectionMatrix();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void UpdateViewMatrix();
|
|
||||||
void UpdateProjectionMatrix();
|
|
||||||
|
|
||||||
glm::vec3 m_Position;
|
glm::vec3 m_Position;
|
||||||
glm::quat m_Orientation;
|
glm::quat m_Orientation;
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ public:
|
|||||||
: FirstPersonInputController(eventBroker, playerID)
|
: FirstPersonInputController(eventBroker, playerID)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
void SetPosition(const glm::vec3 position) { m_Position = position; }
|
||||||
|
void SetOrientation(const glm::quat orientation) { m_Orientation = orientation; }
|
||||||
|
|
||||||
const glm::vec3 Position() const { return m_Position; }
|
const glm::vec3 Position() const { return m_Position; }
|
||||||
void SetBaseSpeed(float speed) { m_BaseSpeed = speed; }
|
void SetBaseSpeed(float speed) { m_BaseSpeed = speed; }
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public:
|
|||||||
void InitializeFrameBuffers();
|
void InitializeFrameBuffers();
|
||||||
void InitializeShaderPrograms();
|
void InitializeShaderPrograms();
|
||||||
|
|
||||||
void Draw(RenderQueueCollection& rq);
|
void Draw(RenderScene& scene);
|
||||||
|
|
||||||
//Getters
|
//Getters
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public:
|
|||||||
void InitializeFrameBuffers();
|
void InitializeFrameBuffers();
|
||||||
void InitializeShaderPrograms();
|
void InitializeShaderPrograms();
|
||||||
|
|
||||||
void Draw(RenderQueueCollection& rq);
|
void Draw(RenderScene& scene);
|
||||||
|
|
||||||
//Getters
|
//Getters
|
||||||
|
|
||||||
@@ -25,12 +25,18 @@ public:
|
|||||||
private:
|
private:
|
||||||
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
||||||
|
|
||||||
|
static bool DepthSort(const std::shared_ptr<RenderJob> &i, const std::shared_ptr<RenderJob> &j)
|
||||||
|
{
|
||||||
|
return (i->Depth < j->Depth);
|
||||||
|
};
|
||||||
|
|
||||||
Texture* m_WhiteTexture;
|
Texture* m_WhiteTexture;
|
||||||
|
|
||||||
const IRenderer* m_Renderer;
|
const IRenderer* m_Renderer;
|
||||||
|
|
||||||
ShaderProgram* m_BasicForwardProgram;
|
ShaderProgram* m_BasicForwardProgram;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -9,7 +9,7 @@ class DummyRenderer : public IRenderer
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void Initialize() override;
|
virtual void Initialize() override;
|
||||||
virtual void Draw(RenderQueueCollection& rq) override;
|
virtual void Draw(RenderFrame& rq) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
#ifndef Events_Picking_h__
|
|
||||||
#define Events_Picking_h__
|
|
||||||
|
|
||||||
#include "../OpenGL.h"
|
|
||||||
#include "../GLM.h"
|
|
||||||
|
|
||||||
#include "../Core/EventBroker.h"
|
|
||||||
#include "Util/ScreenCoords.h"
|
|
||||||
#include "FrameBuffer.h"
|
|
||||||
#include "../Core/Entity.h"
|
|
||||||
#include "Util/UnorderedMapVec2.h"
|
|
||||||
|
|
||||||
namespace Events
|
|
||||||
{
|
|
||||||
|
|
||||||
/** Thrown Every frame, use functions to pick*/
|
|
||||||
struct Picking : Event
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Picking(FrameBuffer* pickingBuffer, GLuint* depthBuffer, glm::mat4 projectionMatrix, glm::mat4 viewMatrix, Rectangle resolution, const std::unordered_map<glm::vec2, EntityID>* pickingColorsToEntity)
|
|
||||||
: PickingBuffer(pickingBuffer)
|
|
||||||
, DepthBuffer(depthBuffer)
|
|
||||||
, ProjectionMatrix(projectionMatrix)
|
|
||||||
, ViewMatrix(viewMatrix)
|
|
||||||
, Resolution(resolution)
|
|
||||||
, PickingColorsToEntity(pickingColorsToEntity)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct PickData
|
|
||||||
{
|
|
||||||
//Picked Entity
|
|
||||||
EntityID Entity;
|
|
||||||
//World position of the "pick"
|
|
||||||
glm::vec3 Position;
|
|
||||||
// Depth
|
|
||||||
float Depth;
|
|
||||||
};
|
|
||||||
|
|
||||||
PickData Pick(glm::vec2 screenCoord) const
|
|
||||||
{
|
|
||||||
PickData pickData;
|
|
||||||
|
|
||||||
// Invert screen y coordinate
|
|
||||||
screenCoord.y = Resolution.Height - screenCoord.y;
|
|
||||||
ScreenCoords::PixelData data = ScreenCoords::ToPixelData(screenCoord, PickingBuffer, *DepthBuffer);
|
|
||||||
pickData.Depth = data.Depth;
|
|
||||||
|
|
||||||
auto it = PickingColorsToEntity->find(glm::vec2(data.Color[0], data.Color[1]));
|
|
||||||
if (it != PickingColorsToEntity->end()) {
|
|
||||||
pickData.Entity = it->second;
|
|
||||||
} else {
|
|
||||||
pickData.Entity = EntityID_Invalid;
|
|
||||||
}
|
|
||||||
pickData.Position = ScreenCoords::ToWorldPos(screenCoord.x, screenCoord.y, data.Depth, Resolution, ProjectionMatrix, ViewMatrix);
|
|
||||||
|
|
||||||
return pickData;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
FrameBuffer* PickingBuffer;
|
|
||||||
GLuint* DepthBuffer;
|
|
||||||
const glm::mat4 ProjectionMatrix;
|
|
||||||
const glm::mat4 ViewMatrix;
|
|
||||||
const Rectangle Resolution;
|
|
||||||
const std::unordered_map<glm::vec2, EntityID>* PickingColorsToEntity;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
#ifndef Events_SetCamera_h__
|
||||||
|
#define Events_SetCamera_h__
|
||||||
|
|
||||||
|
#include "../Core/EventBroker.h"
|
||||||
|
#include "../Core/Entity.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
struct SetCamera : Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SetCamera() { };
|
||||||
|
std::string Name;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -10,9 +10,17 @@
|
|||||||
#include "RenderQueue.h"
|
#include "RenderQueue.h"
|
||||||
#include "Model.h"
|
#include "Model.h"
|
||||||
#include "../Core/World.h" //So temp
|
#include "../Core/World.h" //So temp
|
||||||
#include "RenderQueueFactory.h" //So temp
|
|
||||||
|
|
||||||
|
|
||||||
|
struct PickData
|
||||||
|
{
|
||||||
|
EntityID Entity;
|
||||||
|
glm::vec3 Position; //World position
|
||||||
|
float Depth;
|
||||||
|
::Camera* Camera;
|
||||||
|
const ::World* World;
|
||||||
|
};
|
||||||
|
|
||||||
class IRenderer
|
class IRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -23,19 +31,19 @@ public:
|
|||||||
void SetFullscreen(bool fullscreen) { m_Fullscreen = fullscreen; }
|
void SetFullscreen(bool fullscreen) { m_Fullscreen = fullscreen; }
|
||||||
bool VSYNC() const { return m_VSYNC; }
|
bool VSYNC() const { return m_VSYNC; }
|
||||||
void SetVSYNC(bool vsync) { m_VSYNC = vsync; }
|
void SetVSYNC(bool vsync) { m_VSYNC = vsync; }
|
||||||
::Camera* Camera() const { return m_Camera; }
|
::Camera* Camera() const { return m_Camera; }
|
||||||
void SetCamera(::Camera* camera)
|
void SetCamera(::Camera* camera)
|
||||||
{
|
{
|
||||||
if (camera == nullptr) {
|
if (camera == nullptr) {
|
||||||
m_Camera = m_DefaultCamera;
|
m_Camera = m_DefaultCamera;
|
||||||
} else {
|
} else {
|
||||||
m_Camera = camera;
|
m_Camera = camera;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Initialize() = 0;
|
virtual void Initialize() = 0;
|
||||||
virtual void Update(double dt) = 0;
|
virtual void Update(double dt) = 0;
|
||||||
virtual void Draw(RenderQueueCollection& rq) = 0;
|
virtual void Draw(RenderFrame& rq) = 0;
|
||||||
|
virtual PickData Pick(glm::vec2 screenCord) = 0;
|
||||||
|
|
||||||
World* m_World; //Temp world, untill viktor merge.
|
World* m_World; //Temp world, untill viktor merge.
|
||||||
|
|
||||||
@@ -45,9 +53,9 @@ protected:
|
|||||||
bool m_VSYNC = false;
|
bool m_VSYNC = false;
|
||||||
int m_GLVersion[2];
|
int m_GLVersion[2];
|
||||||
std::string m_GLVendor;
|
std::string m_GLVendor;
|
||||||
::Camera* m_DefaultCamera;
|
|
||||||
::Camera* m_Camera = nullptr;
|
|
||||||
GLFWwindow* m_Window = nullptr;
|
GLFWwindow* m_Window = nullptr;
|
||||||
|
::Camera* m_DefaultCamera;
|
||||||
|
::Camera* m_Camera = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // Renderer_h__
|
#endif // Renderer_h__
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "IRenderer.h"
|
#include "IRenderer.h"
|
||||||
#include "LightCullingPassState.h"
|
#include "LightCullingPassState.h"
|
||||||
#include "ShaderProgram.h"
|
#include "ShaderProgram.h"
|
||||||
|
#include "RenderQueue.h"
|
||||||
|
|
||||||
|
|
||||||
class LightCullingPass
|
class LightCullingPass
|
||||||
@@ -15,9 +16,9 @@ public:
|
|||||||
LightCullingPass(IRenderer* renderer);
|
LightCullingPass(IRenderer* renderer);
|
||||||
~LightCullingPass();
|
~LightCullingPass();
|
||||||
|
|
||||||
void GenerateNewFrustum();
|
void GenerateNewFrustum(RenderScene& scene);
|
||||||
void CullLights();
|
void CullLights(RenderScene& scene);
|
||||||
void FillLightList(RenderQueueCollection& rq);
|
void FillLightList(RenderScene& scene);
|
||||||
|
|
||||||
GLuint FrustumSSBO() const { return m_FrustumSSBO; }
|
GLuint FrustumSSBO() const { return m_FrustumSSBO; }
|
||||||
GLuint LightSSBO() const { return m_LightSSBO; }
|
GLuint LightSSBO() const { return m_LightSSBO; }
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
#ifndef ModelJob_h__
|
||||||
|
#define ModelJob_h__
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include "../Common.h"
|
||||||
|
#include "../GLM.h"
|
||||||
|
#include "../Core/ComponentWrapper.h"
|
||||||
|
#include "Texture.h"
|
||||||
|
#include "Model.h"
|
||||||
|
#include "RenderJob.h"
|
||||||
|
#include "../Core/ResourceManager.h"
|
||||||
|
#include "Camera.h"
|
||||||
|
#include "../Core/World.h"
|
||||||
|
|
||||||
|
struct ModelJob : RenderJob
|
||||||
|
{
|
||||||
|
ModelJob(Model* model, Camera* camera, glm::mat4 matrix, ::Model::MaterialGroup texGroup, ComponentWrapper modelComponent, World* world)
|
||||||
|
: RenderJob()
|
||||||
|
{
|
||||||
|
Model = model;
|
||||||
|
TextureID = (texGroup.Texture) ? texGroup.Texture->ResourceID : 0;
|
||||||
|
DiffuseTexture = texGroup.Texture.get();
|
||||||
|
NormalTexture = texGroup.NormalMap.get();
|
||||||
|
SpecularTexture = texGroup.SpecularMap.get();
|
||||||
|
StartIndex = texGroup.StartIndex;
|
||||||
|
EndIndex = texGroup.EndIndex;
|
||||||
|
Matrix = matrix;
|
||||||
|
Color = modelComponent["Color"];
|
||||||
|
Entity = modelComponent.EntityID;
|
||||||
|
World = world;
|
||||||
|
};
|
||||||
|
|
||||||
|
unsigned int TextureID;
|
||||||
|
unsigned int ShaderID;
|
||||||
|
|
||||||
|
EntityID Entity;
|
||||||
|
glm::mat4 Matrix;
|
||||||
|
const Texture* DiffuseTexture;
|
||||||
|
const Texture* NormalTexture;
|
||||||
|
const Texture* SpecularTexture;
|
||||||
|
float Shininess = 0.f;
|
||||||
|
glm::vec4 Color;
|
||||||
|
const ::Model* Model = nullptr;
|
||||||
|
unsigned int StartIndex = 0;
|
||||||
|
unsigned int EndIndex = 0;
|
||||||
|
World* World;
|
||||||
|
|
||||||
|
void CalculateHash() override
|
||||||
|
{
|
||||||
|
Hash = TextureID;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -7,9 +7,9 @@
|
|||||||
#include "PickingPassState.h"
|
#include "PickingPassState.h"
|
||||||
#include "FrameBuffer.h"
|
#include "FrameBuffer.h"
|
||||||
#include "ShaderProgram.h"
|
#include "ShaderProgram.h"
|
||||||
#include "Util/UnorderedMapVec2.h"
|
#include "Util/UnorderedMapiVec2.h"
|
||||||
#include "../Core/EventBroker.h"
|
#include "../Core/EventBroker.h"
|
||||||
#include "EPicking.h"
|
#include "../Core/World.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -22,15 +22,19 @@ public:
|
|||||||
void InitializeFrameBuffers();
|
void InitializeFrameBuffers();
|
||||||
void InitializeShaderPrograms();
|
void InitializeShaderPrograms();
|
||||||
|
|
||||||
void Draw(RenderQueueCollection& rq);
|
void Draw(RenderScene& scene);
|
||||||
|
void ClearPicking();
|
||||||
|
|
||||||
//Getters
|
//Getters
|
||||||
const ShaderProgram& PickingProgram() const { return *m_PickingProgram; }
|
const ShaderProgram& PickingProgram() const { return *m_PickingProgram; }
|
||||||
const std::unordered_map<glm::vec2, EntityID>& PickingColorsToEntity() const { return m_PickingColorsToEntity; }
|
//const std::unordered_map<glm::ivec2, EntityID>& PickingColorsToEntity() const { return m_PickingColorsToEntity; }
|
||||||
GLuint PickingTexture() const { return m_PickingTexture; }
|
GLuint PickingTexture() const { return m_PickingTexture; }
|
||||||
GLuint DepthBuffer() const { return m_DepthBuffer; }
|
GLuint DepthBuffer() const { return m_DepthBuffer; }
|
||||||
const FrameBuffer& PickingBuffer() const { return m_PickingBuffer; }
|
const FrameBuffer& PickingBuffer() const { return m_PickingBuffer; }
|
||||||
|
|
||||||
|
|
||||||
|
PickData Pick(glm::vec2 screenCoord);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
||||||
|
|
||||||
@@ -39,13 +43,24 @@ private:
|
|||||||
const IRenderer* m_Renderer;
|
const IRenderer* m_Renderer;
|
||||||
|
|
||||||
ShaderProgram* m_PickingProgram;
|
ShaderProgram* m_PickingProgram;
|
||||||
|
Camera* m_Camera;
|
||||||
|
|
||||||
std::unordered_map<glm::vec2, EntityID> m_PickingColorsToEntity;
|
struct PickingInfo
|
||||||
|
{
|
||||||
|
EntityID Entity;
|
||||||
|
const ::World* World;
|
||||||
|
::Camera* Camera;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::unordered_map<glm::ivec2, PickingInfo> m_PickingColorsToEntity;
|
||||||
|
|
||||||
GLuint m_PickingTexture;
|
GLuint m_PickingTexture;
|
||||||
GLuint m_DepthBuffer;
|
GLuint m_DepthBuffer;
|
||||||
|
|
||||||
FrameBuffer m_PickingBuffer;
|
FrameBuffer m_PickingBuffer;
|
||||||
|
|
||||||
|
int m_ColorCounter[2];
|
||||||
|
std::map<std::tuple<EntityID, const World*, Camera*>, glm::ivec2> m_EntityColors;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#ifndef PointLightJob_h__
|
||||||
|
#define PointLightJob_h__
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include "../Common.h"
|
||||||
|
#include "../GLM.h"
|
||||||
|
#include "../Core/ComponentWrapper.h"
|
||||||
|
#include "RenderJob.h"
|
||||||
|
|
||||||
|
struct PointLightJob : RenderJob
|
||||||
|
{
|
||||||
|
PointLightJob(ComponentWrapper transformComponent, ComponentWrapper pointLightComponent)
|
||||||
|
: RenderJob()
|
||||||
|
{
|
||||||
|
Position = glm::vec4((glm::vec3)transformComponent["Position"], 1.0f);
|
||||||
|
Color = (glm::vec4)pointLightComponent["Color"];
|
||||||
|
Radius = (double)pointLightComponent["Radius"];
|
||||||
|
Intensity = (double)pointLightComponent["Intensity"];
|
||||||
|
Falloff = (double)pointLightComponent["Falloff"];
|
||||||
|
};
|
||||||
|
|
||||||
|
glm::vec4 Position;
|
||||||
|
glm::vec4 Color;
|
||||||
|
float Radius;
|
||||||
|
float Intensity;
|
||||||
|
float Falloff;
|
||||||
|
float padding = 123;
|
||||||
|
|
||||||
|
void CalculateHash() override
|
||||||
|
{
|
||||||
|
Hash = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -46,6 +46,7 @@ public:
|
|||||||
struct MaterialGroup
|
struct MaterialGroup
|
||||||
{
|
{
|
||||||
float Shininess;
|
float Shininess;
|
||||||
|
float Transparency;
|
||||||
std::shared_ptr<::Texture> Texture;
|
std::shared_ptr<::Texture> Texture;
|
||||||
std::shared_ptr<::Texture> NormalMap;
|
std::shared_ptr<::Texture> NormalMap;
|
||||||
std::shared_ptr<::Texture> SpecularMap;
|
std::shared_ptr<::Texture> SpecularMap;
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#ifndef RenderJob_h__
|
||||||
|
#define RenderJob_h__
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include "../Common.h"
|
||||||
|
#include "../GLM.h"
|
||||||
|
#include "../Core/ComponentWrapper.h"
|
||||||
|
#include "RenderQueue.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct RenderJob
|
||||||
|
{
|
||||||
|
friend class RenderQueue;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
float Depth;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
uint64_t Hash;
|
||||||
|
|
||||||
|
virtual void CalculateHash() = 0;
|
||||||
|
|
||||||
|
bool operator<(const RenderJob& rhs)
|
||||||
|
{
|
||||||
|
return this->Hash < rhs.Hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -8,61 +8,13 @@
|
|||||||
#include "../GLM.h"
|
#include "../GLM.h"
|
||||||
#include "../Core/Util/Rectangle.h"
|
#include "../Core/Util/Rectangle.h"
|
||||||
#include "../Core/Entity.h"
|
#include "../Core/Entity.h"
|
||||||
|
#include "Camera.h"
|
||||||
|
#include "RenderJob.h"
|
||||||
|
#include "ModelJob.h"
|
||||||
|
#include "PointLightJob.h"
|
||||||
|
|
||||||
class Model;
|
|
||||||
class Skeleton;
|
|
||||||
class Texture;
|
|
||||||
class RenderQueue;
|
|
||||||
|
|
||||||
//TODO: Render: Remove obsolete RenderJobs and fix standard values on variables.
|
|
||||||
|
|
||||||
struct RenderJob
|
|
||||||
{
|
|
||||||
friend class RenderQueue;
|
|
||||||
|
|
||||||
float Depth;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
uint64_t Hash;
|
|
||||||
|
|
||||||
virtual void CalculateHash() = 0;
|
|
||||||
|
|
||||||
bool operator<(const RenderJob& rhs)
|
|
||||||
{
|
|
||||||
return this->Hash < rhs.Hash;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ModelJob : RenderJob
|
|
||||||
{
|
|
||||||
unsigned int ShaderID = 0;
|
|
||||||
unsigned int TextureID = 0;
|
|
||||||
|
|
||||||
//TODO: RENDERER: Not sure if the best solution for pickingColor to entity link is this
|
|
||||||
EntityID Entity;
|
|
||||||
|
|
||||||
glm::mat4 ModelMatrix;
|
|
||||||
const Texture* DiffuseTexture;
|
|
||||||
const Texture* NormalTexture;
|
|
||||||
const Texture* SpecularTexture;
|
|
||||||
float Shininess = 0.f;
|
|
||||||
glm::vec4 Color;
|
|
||||||
const Model* Model = nullptr;
|
|
||||||
unsigned int StartIndex = 0;
|
|
||||||
unsigned int EndIndex = 0;
|
|
||||||
|
|
||||||
// Animation
|
|
||||||
Skeleton* Skeleton = nullptr;
|
|
||||||
bool NoRootMotion = true;
|
|
||||||
std::string AnimationName;
|
|
||||||
double AnimationTime = 0;
|
|
||||||
|
|
||||||
void CalculateHash() override
|
|
||||||
{
|
|
||||||
Hash = TextureID;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
/*
|
||||||
struct SpriteJob : RenderJob
|
struct SpriteJob : RenderJob
|
||||||
{
|
{
|
||||||
unsigned int ShaderID = 0;
|
unsigned int ShaderID = 0;
|
||||||
@@ -94,62 +46,53 @@ struct PointLightJob : RenderJob
|
|||||||
Hash = 0;
|
Hash = 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
class RenderQueue
|
struct RenderScene
|
||||||
{
|
{
|
||||||
public:
|
::Camera* Camera;
|
||||||
template <typename T>
|
std::list<std::shared_ptr<RenderJob>> ForwardJobs;
|
||||||
void Add(T &job)
|
std::list<std::shared_ptr<RenderJob>> PointLightJobs;
|
||||||
{
|
Rectangle Viewport;
|
||||||
job.CalculateHash();
|
|
||||||
Jobs.push_back(std::shared_ptr<T>(new T(job)));
|
|
||||||
m_Size++;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Sort()
|
|
||||||
{
|
|
||||||
Jobs.sort();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Clear()
|
void Clear()
|
||||||
{
|
{
|
||||||
Jobs.clear();
|
ForwardJobs.clear();
|
||||||
m_Size = 0;
|
PointLightJobs.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Size() const { return m_Size; }
|
|
||||||
std::list<std::shared_ptr<RenderJob>>::const_iterator begin()
|
|
||||||
{
|
|
||||||
return Jobs.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::list<std::shared_ptr<RenderJob>>::const_iterator end()
|
|
||||||
{
|
|
||||||
return Jobs.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::list<std::shared_ptr<RenderJob>> Jobs;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int m_Size = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RenderQueueCollection
|
struct RenderFrame
|
||||||
{
|
{
|
||||||
RenderQueue Forward;
|
public:
|
||||||
RenderQueue Lights;
|
|
||||||
|
|
||||||
void Clear()
|
void Add(RenderScene &scene)
|
||||||
{
|
{
|
||||||
Forward.Clear();
|
RenderScenes.push_back(std::shared_ptr<RenderScene>(new RenderScene(scene)));
|
||||||
Lights.Clear();
|
m_Size++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sort()
|
void Clear()
|
||||||
{
|
{
|
||||||
Forward.Sort();
|
RenderScenes.clear();
|
||||||
Lights.Sort();
|
m_Size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Size() const { return m_Size; }
|
||||||
|
std::list<std::shared_ptr<RenderScene>>::const_iterator begin()
|
||||||
|
{
|
||||||
|
return RenderScenes.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::list<std::shared_ptr<RenderScene>>::const_iterator end()
|
||||||
|
{
|
||||||
|
return RenderScenes.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::list<std::shared_ptr<RenderScene>> RenderScenes;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_Size = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
#ifndef RenderQueueFactory_h__
|
|
||||||
#define RenderQueueFactory_h__
|
|
||||||
|
|
||||||
#include "../Core/World.h"
|
|
||||||
#include "RenderQueue.h"
|
|
||||||
#include "../Core/ResourceManager.h"
|
|
||||||
#include "Model.h"
|
|
||||||
#include "../GLM.h"
|
|
||||||
|
|
||||||
class RenderQueueFactory
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
RenderQueueFactory();
|
|
||||||
void Update(World* world);
|
|
||||||
|
|
||||||
RenderQueueCollection RenderQueues() const { return m_RenderQueues; }
|
|
||||||
|
|
||||||
static glm::vec3 AbsolutePosition(World* world, EntityID entity);
|
|
||||||
static glm::quat AbsoluteOrientation(World* world, EntityID entity);
|
|
||||||
static glm::vec3 AbsoluteScale(World* world, EntityID entity);
|
|
||||||
|
|
||||||
private:
|
|
||||||
RenderQueueCollection m_RenderQueues;
|
|
||||||
|
|
||||||
void FillModels(World* world, RenderQueue* renderQueue);
|
|
||||||
void FillLights(World* world, RenderQueue* renderQueue);
|
|
||||||
|
|
||||||
glm::mat4 ModelMatrix(World* world, EntityID entity);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
#ifndef RenderSystem_h__
|
||||||
|
#define RenderSystem_h__
|
||||||
|
|
||||||
|
#include "../Core/System.h"
|
||||||
|
#include "RenderQueue.h"
|
||||||
|
#include "../GLM.h"
|
||||||
|
#include "../OpenGL.h"
|
||||||
|
#include "../Core/ResourceManager.h"
|
||||||
|
#include "ESetCamera.h"
|
||||||
|
#include "Model.h"
|
||||||
|
#include "../Core/EKeyDown.h"
|
||||||
|
#include "../Input/EInputCommand.h"
|
||||||
|
#include "Camera.h"
|
||||||
|
#include "ModelJob.h"
|
||||||
|
#include "Renderer.h"
|
||||||
|
#include "PointLightJob.h"
|
||||||
|
#include "../Core/Transform.h"
|
||||||
|
|
||||||
|
class RenderSystem : public ImpureSystem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RenderSystem(EventBroker* eventBrokerer, const IRenderer* renderer, RenderFrame* renderFrame);
|
||||||
|
|
||||||
|
virtual void Update(World* world, double dt) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
World* m_World = nullptr;
|
||||||
|
const IRenderer* m_Renderer = nullptr;
|
||||||
|
|
||||||
|
RenderFrame* m_RenderFrame;
|
||||||
|
bool m_SwitchCamera = false;
|
||||||
|
Camera* m_Camera = nullptr;
|
||||||
|
Camera* m_DefaultCamera = nullptr;
|
||||||
|
|
||||||
|
std::list<ComponentWrapper> m_CameraComponents;
|
||||||
|
|
||||||
|
EventRelay<RenderSystem, Events::SetCamera> m_ESetCamera;
|
||||||
|
bool OnSetCamera(const Events::SetCamera &event);
|
||||||
|
EntityID m_CurrentCamera = EntityID_Invalid;
|
||||||
|
|
||||||
|
void switchCamera(EntityID entity);
|
||||||
|
|
||||||
|
void updateCamera(World* world, double dt);
|
||||||
|
void updateProjectionMatrix(ComponentWrapper& cameraComponent);
|
||||||
|
glm::mat4 m_ViewMatrix;
|
||||||
|
glm::mat4 m_ProjectionMatrix;
|
||||||
|
|
||||||
|
void fillModels(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||||
|
void fillLight(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||||
|
|
||||||
|
EventRelay<RenderSystem, Events::InputCommand> m_EInputCommand;
|
||||||
|
bool OnInputCommand(const Events::InputCommand& e);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -12,34 +12,34 @@
|
|||||||
#include "../Core/World.h"
|
#include "../Core/World.h"
|
||||||
#include "PickingPass.h"
|
#include "PickingPass.h"
|
||||||
#include "DrawScenePass.h"
|
#include "DrawScenePass.h"
|
||||||
#include "DebugCameraInputController.h"
|
|
||||||
#include "LightCullingPass.h"
|
#include "LightCullingPass.h"
|
||||||
#include "DrawFinalPass.h"
|
#include "DrawFinalPass.h"
|
||||||
|
|
||||||
#include "../Core/EventBroker.h"
|
#include "../Core/EventBroker.h"
|
||||||
#include "EPicking.h"
|
|
||||||
#include "ImGuiRenderPass.h"
|
#include "ImGuiRenderPass.h"
|
||||||
|
#include "Camera.h"
|
||||||
|
#include "../Core/Transform.h"
|
||||||
|
|
||||||
class Renderer : public IRenderer
|
class Renderer : public IRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Renderer(EventBroker* eventBroker)
|
Renderer(EventBroker* eventBroker, World* world)
|
||||||
: m_EventBroker(eventBroker)
|
: m_EventBroker(eventBroker)
|
||||||
|
, m_World(world)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
virtual void Initialize() override;
|
virtual void Initialize() override;
|
||||||
virtual void Update(double dt) override;
|
virtual void Update(double dt) override;
|
||||||
virtual void Draw(RenderQueueCollection& rq) override;
|
virtual void Draw(RenderFrame& frame) override;
|
||||||
|
|
||||||
|
virtual PickData Pick(glm::vec2 screenCoord) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//----------------------Variables----------------------//
|
//----------------------Variables----------------------//
|
||||||
EventBroker* m_EventBroker;
|
EventBroker* m_EventBroker;
|
||||||
|
World* m_World;
|
||||||
std::shared_ptr<DebugCameraInputController<Renderer>> m_DebugCameraInputController;
|
|
||||||
|
|
||||||
Texture* m_ErrorTexture;
|
Texture* m_ErrorTexture;
|
||||||
Texture* m_WhiteTexture;
|
Texture* m_WhiteTexture;
|
||||||
float m_CameraMoveSpeed;
|
|
||||||
|
|
||||||
Model* m_ScreenQuad;
|
Model* m_ScreenQuad;
|
||||||
Model* m_UnitQuad;
|
Model* m_UnitQuad;
|
||||||
@@ -62,8 +62,7 @@ private:
|
|||||||
void DrawScreenQuad(GLuint textureToDraw);
|
void DrawScreenQuad(GLuint textureToDraw);
|
||||||
|
|
||||||
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 FillDepth(RenderQueueCollection& rq);
|
void FillDepth(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;
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#pragma once
|
||||||
|
#ifndef UnorderedMapiVec2_h__
|
||||||
|
#define UnorderedMapiVec2_h__
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
#include <boost/functional/hash.hpp>
|
||||||
|
#include <glm/vec2.hpp>
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct std::hash<glm::ivec2>
|
||||||
|
{
|
||||||
|
inline std::size_t operator()(const glm::ivec2 &v) const
|
||||||
|
{
|
||||||
|
return boost::hash<float>()(v.x) ^ boost::hash<float>()(v.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator()(const glm::ivec2& a, const glm::ivec2& b)const
|
||||||
|
{
|
||||||
|
return a.x == b.x && a.y == b.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
+2
-2
@@ -8,7 +8,6 @@
|
|||||||
#include "Core/InputManager.h"
|
#include "Core/InputManager.h"
|
||||||
#include "GUI/Frame.h"
|
#include "GUI/Frame.h"
|
||||||
#include "Core/World.h"
|
#include "Core/World.h"
|
||||||
#include "Rendering/RenderQueueFactory.h"
|
|
||||||
#include "Input/InputProxy.h"
|
#include "Input/InputProxy.h"
|
||||||
#include "Input/KeyboardInputHandler.h"
|
#include "Input/KeyboardInputHandler.h"
|
||||||
#include "Input/MouseInputHandler.h"
|
#include "Input/MouseInputHandler.h"
|
||||||
@@ -19,6 +18,7 @@
|
|||||||
#include "PlayerSystem.h"
|
#include "PlayerSystem.h"
|
||||||
#include "Editor/EditorSystem.h"
|
#include "Editor/EditorSystem.h"
|
||||||
#include "Core/EntityFile.h"
|
#include "Core/EntityFile.h"
|
||||||
|
#include "Rendering/RenderSystem.h"
|
||||||
#include "Core/EntityFileParser.h"
|
#include "Core/EntityFileParser.h"
|
||||||
|
|
||||||
// Network
|
// Network
|
||||||
@@ -47,7 +47,7 @@ private:
|
|||||||
GUI::Frame* m_FrameStack;
|
GUI::Frame* m_FrameStack;
|
||||||
World* m_World;
|
World* m_World;
|
||||||
SystemPipeline* m_SystemPipeline;
|
SystemPipeline* m_SystemPipeline;
|
||||||
RenderQueueFactory* m_RenderQueueFactory;
|
RenderFrame* m_RenderFrame;
|
||||||
// Network variables
|
// Network variables
|
||||||
boost::thread m_NetworkThread;
|
boost::thread m_NetworkThread;
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
<xs:include schemaLocation="Components/Test.xsd"/>
|
<xs:include schemaLocation="Components/Test.xsd"/>
|
||||||
<xs:include schemaLocation="Components/RaptorCopter.xsd"/>
|
<xs:include schemaLocation="Components/RaptorCopter.xsd"/>
|
||||||
<xs:include schemaLocation="Components/Player.xsd"/>
|
<xs:include schemaLocation="Components/Player.xsd"/>
|
||||||
|
<xs:include schemaLocation="Components/Camera.xsd"/>
|
||||||
<xs:include schemaLocation="Components/AABB.xsd"/>
|
<xs:include schemaLocation="Components/AABB.xsd"/>
|
||||||
<xs:include schemaLocation="Components/PointLight.xsd"/>
|
<xs:include schemaLocation="Components/PointLight.xsd"/>
|
||||||
<xs:include schemaLocation="Components/Trigger.xsd"/>
|
<xs:include schemaLocation="Components/Trigger.xsd"/>
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<c:Camera>
|
||||||
|
<Name>cam</Name>
|
||||||
|
<FOV>60.0</FOV>
|
||||||
|
<NearClip>0.01</NearClip>
|
||||||
|
<FarClip>5000</FarClip>
|
||||||
|
</c:Camera>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
|
||||||
|
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
|
||||||
|
|
||||||
|
<xs:element name="Camera">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:documentation>It's a camera thingy!</xs:documentation>
|
||||||
|
</xs:annotation>
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:all>
|
||||||
|
<xs:element name="Name" type="t:string" minOccurs="0"/>
|
||||||
|
<xs:element name="FOV" type="t:double" minOccurs="0"/>
|
||||||
|
<xs:element name="NearClip" type="t:double" minOccurs="0"/>
|
||||||
|
<xs:element name="FarClip" type="t:double" minOccurs="0"/>
|
||||||
|
</xs:all>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:schema>
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Entity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd" xmlns:c="components">
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0" Z="0"/>
|
||||||
|
<Orientation X="0" Y="0" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
</Components>
|
||||||
|
<Children>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="1" Z="10"/>
|
||||||
|
</c:Transform>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Camera.obj</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Camera>
|
||||||
|
<Name>MainCamera</Name>
|
||||||
|
</c:Camera>
|
||||||
|
</Components>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="5" Y="1" Z="5"/>
|
||||||
|
</c:Transform>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Camera.obj</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Camera>
|
||||||
|
<Name>ActionCamera</Name>
|
||||||
|
</c:Camera>
|
||||||
|
</Components>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="-1" Z="0"/>
|
||||||
|
<Scale X="100" Y="1" Z="100"/>
|
||||||
|
</c:Transform>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Core/UnitPlane.obj</Resource>
|
||||||
|
</c:Model>
|
||||||
|
</Components>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="0" Y="0" Z="0"/>
|
||||||
|
</c:Transform>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>An error</Resource>
|
||||||
|
</c:Model>
|
||||||
|
</Components>
|
||||||
|
</Entity>
|
||||||
|
</Children>
|
||||||
|
</Entity>
|
||||||
@@ -9,114 +9,19 @@
|
|||||||
<Resource>Models/DummyScene.obj</Resource>
|
<Resource>Models/DummyScene.obj</Resource>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
</Components>
|
</Components>
|
||||||
|
</Entity>
|
||||||
<Children>
|
<Children>
|
||||||
<!--<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="-1.5"/>
|
|
||||||
<Scale X="1" Y="1" Z="1"/>
|
|
||||||
</c:Transform>
|
|
||||||
<c:Model>
|
|
||||||
<Resource>Models/ScaleWidget.obj</Resource>
|
|
||||||
</c:Model>
|
|
||||||
</Components>
|
|
||||||
</Entity>-->
|
|
||||||
<!--<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="1.5"/>
|
|
||||||
<Scale X="2" Y="2" Z="2"/>
|
|
||||||
</c:Transform>
|
|
||||||
<c:Model>
|
|
||||||
<Resource>Models/RotationWidget.obj</Resource>
|
|
||||||
</c:Model>
|
|
||||||
<c:Trigger>
|
|
||||||
</c:Trigger>
|
|
||||||
</Components>
|
|
||||||
</Entity>-->
|
|
||||||
<!--<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:Player>
|
|
||||||
<Velocity X="0" Y="0" Z="0"/>
|
|
||||||
</c:Player>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="2.5"/>
|
|
||||||
</c:Transform>
|
|
||||||
<c:Model>
|
|
||||||
<Resource>Models/Core/UnitCube.obj</Resource>
|
|
||||||
</c:Model>
|
|
||||||
<c:AABB>
|
|
||||||
</c:AABB>
|
|
||||||
</Components>
|
|
||||||
</Entity>-->
|
|
||||||
<Entity>
|
<Entity>
|
||||||
<Components>
|
<Components>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="0" Y="-0"/>
|
<Position X="0" Y="-0"/>
|
||||||
<Scale X="1" Y="1" Z="1"/>
|
<Scale X="1" Y="1" Z="1"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
<!--<c:Move>
|
<c:Camera>
|
||||||
<Speed>1</Speed>
|
</c:Camera>
|
||||||
<Direction X="-1"/>
|
<c:Model>
|
||||||
<Rotation Y="3.14"/>
|
<Resource>Models/Camera.obj</Resource>
|
||||||
</c:Move>-->
|
</c:Model>
|
||||||
</Components>
|
</Components>
|
||||||
<Children>
|
|
||||||
<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="0" Y="0"/>
|
|
||||||
<Orientation X="0.0" Y="0" Z="1.0"/>
|
|
||||||
</c:Transform>
|
|
||||||
<c:Model>
|
|
||||||
<Resource>Models/Core/UnitRaptor.obj</Resource>
|
|
||||||
<Color R="1" G="0.4" B="0.8"/>
|
|
||||||
</c:Model>
|
|
||||||
</Components>
|
|
||||||
<Children>
|
|
||||||
<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="-0.01" Y="0.55"/>
|
|
||||||
<Orientation X="0" Y="0" Z="-1"/>
|
|
||||||
</c:Transform>
|
|
||||||
<c:RaptorCopter>
|
|
||||||
<Speed>20</Speed>
|
|
||||||
<Axis Y="1"/>
|
|
||||||
</c:RaptorCopter>
|
|
||||||
</Components>
|
|
||||||
<Children>
|
|
||||||
<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="0" Y="0"/>
|
|
||||||
<Scale X="1.7" Y="0.03" Z="0.1"/>
|
|
||||||
<Orientation X="0" Y="0" Z="0"/>
|
|
||||||
</c:Transform>
|
|
||||||
<c:Model>
|
|
||||||
<Resource>Models/Core/UnitCube.obj</Resource>
|
|
||||||
<Color R="1" G="0.4" B="0.8"/>
|
|
||||||
</c:Model>
|
|
||||||
</Components>
|
|
||||||
</Entity>
|
|
||||||
<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="0" Y="0"/>
|
|
||||||
<Scale X="1.7" Y="0.03" Z="0.1"/>
|
|
||||||
<Orientation X="0" Y="1.57" Z="0"/>
|
|
||||||
</c:Transform>
|
|
||||||
<c:Model>
|
|
||||||
<Resource>Models/Core/UnitCube.obj</Resource>
|
|
||||||
<Color R="1" G="0.4" B="0.8"/>
|
|
||||||
</c:Model>
|
|
||||||
</Components>
|
|
||||||
</Entity>
|
|
||||||
</Children>
|
|
||||||
</Entity>
|
|
||||||
</Children>
|
|
||||||
</Entity>
|
|
||||||
</Children>
|
|
||||||
</Entity>
|
</Entity>
|
||||||
</Children>
|
</Children>
|
||||||
</Entity>
|
|
||||||
@@ -1,8 +1,5 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
uniform mat4 M;
|
|
||||||
uniform mat4 V;
|
|
||||||
uniform mat4 P;
|
|
||||||
uniform vec4 Color;
|
uniform vec4 Color;
|
||||||
|
|
||||||
uniform sampler2D texture0;
|
uniform sampler2D texture0;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ out VertexData{
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = P*V*M * vec4(Position, 1.0);
|
gl_Position = P * V * M * vec4(Position, 1.0);
|
||||||
|
|
||||||
Output.Position = Position;
|
Output.Position = Position;
|
||||||
Output.TextureCoordinate = TextureCoords;
|
Output.TextureCoordinate = TextureCoords;
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
uniform mat4 M;
|
|
||||||
uniform mat4 V;
|
|
||||||
uniform mat4 P;
|
|
||||||
uniform vec2 PickingColor;
|
uniform vec2 PickingColor;
|
||||||
|
|
||||||
in VertexData{
|
in VertexData{
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ out VertexData{
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = P*V*M * vec4(Position, 1.0);
|
gl_Position = P * V* M * vec4(Position, 1.0);
|
||||||
|
|
||||||
Output.Position = Position;
|
Output.Position = Position;
|
||||||
}
|
}
|
||||||
+178
-178
@@ -8,196 +8,196 @@
|
|||||||
namespace Collision
|
namespace Collision
|
||||||
{
|
{
|
||||||
|
|
||||||
//note: this one hasnt been delta adjusted like RayVsAABB has
|
//note: this one hasnt been delta adjusted like RayVsAABB has
|
||||||
bool RayAABBIntr(const Ray& ray, const AABB& box)
|
bool RayAABBIntr(const Ray& ray, const AABB& box)
|
||||||
{
|
{
|
||||||
glm::vec3 w = 75.0f * ray.Direction();
|
glm::vec3 w = 75.0f * ray.Direction();
|
||||||
glm::vec3 v = glm::abs(w);
|
glm::vec3 v = glm::abs(w);
|
||||||
glm::vec3 c = ray.Origin() - box.Center() + w;
|
glm::vec3 c = ray.Origin() - box.Center() + w;
|
||||||
glm::vec3 half = box.HalfSize();
|
glm::vec3 half = box.HalfSize();
|
||||||
|
|
||||||
if (abs(c.x) > v.x + half.x) {
|
if (abs(c.x) > v.x + half.x) {
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
if (abs(c.y) > v.y + half.y) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (abs(c.z) > v.z + half.z) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (abs(c.y*w.z - c.z*w.y) > half.y*v.z + half.z*v.y) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (abs(c.x*w.z - c.z*w.x) > half.x*v.z + half.z*v.x) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return !(abs(c.x*w.y - c.y*w.x) > half.x*v.y + half.y*v.x);
|
|
||||||
}
|
}
|
||||||
|
if (abs(c.y) > v.y + half.y) {
|
||||||
bool RayVsAABB(const Ray& ray, const AABB& box)
|
return false;
|
||||||
{
|
|
||||||
float dummy;
|
|
||||||
return RayVsAABB(ray, box, dummy);
|
|
||||||
}
|
}
|
||||||
|
if (abs(c.z) > v.z + half.z) {
|
||||||
bool RayVsAABB(const Ray& ray, const AABB& box, float& outDistance)
|
|
||||||
{
|
|
||||||
glm::vec3 invdir = 1.0f / ray.Direction();
|
|
||||||
glm::vec3 origin = ray.Origin();
|
|
||||||
|
|
||||||
float t1 = (box.MinCorner().x - origin.x)*invdir.x;
|
|
||||||
float t2 = (box.MaxCorner().x - origin.x)*invdir.x;
|
|
||||||
float t3 = (box.MinCorner().y - origin.y)*invdir.y;
|
|
||||||
float t4 = (box.MaxCorner().y - origin.y)*invdir.y;
|
|
||||||
float t5 = (box.MinCorner().z - origin.z)*invdir.z;
|
|
||||||
float t6 = (box.MaxCorner().z - origin.z)*invdir.z;
|
|
||||||
|
|
||||||
float tmin = std::max(std::max(std::min(t1, t2), std::min(t3, t4)), std::min(t5, t6));
|
|
||||||
float tmax = std::min(std::min(std::max(t1, t2), std::max(t3, t4)), std::max(t5, t6));
|
|
||||||
|
|
||||||
//if (tmax < 0 || tmin > tmax)
|
|
||||||
//if tmin,tmax are almost the same (i.e. hitting exactly in the corner) then tmin might be slightly
|
|
||||||
//greater than tmax becuase of floating-precision problems. fixed by adding a small delta to tmax
|
|
||||||
if (tmax < 0 || tmin>(tmax + 0.0001f))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
outDistance = (tmin > 0) ? tmin : tmax;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AABBVsAABB(const AABB& a, const AABB& b)
|
|
||||||
{
|
|
||||||
const glm::vec3& aCenter = a.Center();
|
|
||||||
const glm::vec3& bCenter = b.Center();
|
|
||||||
const glm::vec3& aHSize = a.HalfSize();
|
|
||||||
const glm::vec3& bHSize = b.HalfSize();
|
|
||||||
//Test will probably exit because of the X and Z axes more often, so test them first.
|
|
||||||
if (abs(aCenter[0] - bCenter[0]) > (aHSize[0] + bHSize[0])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (abs(aCenter[2] - bCenter[2]) > (aHSize[2] + bHSize[2])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return (abs(aCenter[1] - bCenter[1]) <= (aHSize[1] + bHSize[1]));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AABBVsAABB(const AABB& a, const AABB& b, glm::vec3& minimumTranslation)
|
|
||||||
{
|
|
||||||
minimumTranslation = glm::vec3(0, 0, 0);
|
|
||||||
const glm::vec3& aMax = a.MaxCorner();
|
|
||||||
const glm::vec3& bMax = b.MaxCorner();
|
|
||||||
const glm::vec3& aMin = a.MinCorner();
|
|
||||||
const glm::vec3& bMin = b.MinCorner();
|
|
||||||
const glm::vec3& bSize = b.Size();
|
|
||||||
const glm::vec3& aSize = a.Size();
|
|
||||||
float minOffset = INFINITY;
|
|
||||||
float off;
|
|
||||||
auto axisesIntersecting = glm::tvec3<bool, glm::highp>(false, false, false);
|
|
||||||
for (int i = 0; i < 3; ++i) {
|
|
||||||
off = bMax[i] - aMin[i];
|
|
||||||
if (off > 0 && off < bSize[i] + aSize[i]) {
|
|
||||||
if (off < minOffset) {
|
|
||||||
minimumTranslation = glm::vec3();
|
|
||||||
minimumTranslation[i] = minOffset = off;
|
|
||||||
}
|
|
||||||
axisesIntersecting[i] = true;
|
|
||||||
}
|
|
||||||
off = aMax[i] - bMin[i];
|
|
||||||
if (off > 0 && off < bSize[i] + aSize[i]) {
|
|
||||||
if (off < minOffset) {
|
|
||||||
minOffset = off;
|
|
||||||
minimumTranslation = glm::vec3();
|
|
||||||
minimumTranslation[i] = -off;
|
|
||||||
}
|
|
||||||
axisesIntersecting[i] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return glm::all(axisesIntersecting);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RayVsModel(const Ray& ray,
|
|
||||||
const std::vector<RawModel::Vertex>& modelVertices,
|
|
||||||
const std::vector<unsigned int>& modelIndices)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < modelIndices.size(); ++i) {
|
|
||||||
glm::vec3 v0 = modelVertices[modelIndices[i]].Position;
|
|
||||||
glm::vec3 e1 = modelVertices[modelIndices[++i]].Position - v0; //v1 - v0
|
|
||||||
glm::vec3 e2 = modelVertices[modelIndices[++i]].Position - v0; //v2 - v0
|
|
||||||
glm::vec3 m = ray.Origin() - v0;
|
|
||||||
glm::vec3 MxE1 = glm::cross(m, e1);
|
|
||||||
glm::vec3 DxE2 = glm::cross(ray.Direction(), e2);
|
|
||||||
float DetInv = glm::dot(e1, DxE2);
|
|
||||||
if (std::abs(DetInv) < FLT_EPSILON) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
DetInv = 1.0f / DetInv;
|
|
||||||
float u = glm::dot(m, DxE2) * DetInv;
|
|
||||||
float v = glm::dot(ray.Direction(), MxE1) * DetInv;
|
|
||||||
//u,v can be very close to 0 but still negative sometimes. added a deltafactor to compensate for that problem
|
|
||||||
if ((u + 0.001f) < 0 || (v + 0.001f) < 0 || 1 < u + v) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
//Here, u and v are positive, u+v <= 1, and if distance is positive - triangle is hit.
|
|
||||||
if (0 <= glm::dot(e2, MxE1) * DetInv) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RayVsModel(const Ray& ray,
|
if (abs(c.y*w.z - c.z*w.y) > half.y*v.z + half.z*v.y) {
|
||||||
const std::vector<RawModel::Vertex>& modelVertices,
|
return false;
|
||||||
const std::vector<unsigned int>& modelIndices,
|
}
|
||||||
float& outDistance,
|
if (abs(c.x*w.z - c.z*w.x) > half.x*v.z + half.z*v.x) {
|
||||||
float& outUCoord,
|
return false;
|
||||||
float& outVCoord)
|
}
|
||||||
{
|
return !(abs(c.x*w.y - c.y*w.x) > half.x*v.y + half.y*v.x);
|
||||||
outDistance = INFINITY;
|
}
|
||||||
bool hit = false;
|
|
||||||
for (int i = 0; i < modelIndices.size(); ++i) {
|
|
||||||
glm::vec3 v0 = modelVertices[modelIndices[i]].Position;
|
|
||||||
glm::vec3 e1 = modelVertices[modelIndices[++i]].Position - v0; //v1 - v0
|
|
||||||
glm::vec3 e2 = modelVertices[modelIndices[++i]].Position - v0; //v2 - v0
|
|
||||||
glm::vec3 m = ray.Origin() - v0;
|
|
||||||
glm::vec3 MxE1 = glm::cross(m, e1);
|
|
||||||
glm::vec3 DxE2 = glm::cross(ray.Direction(), e2);//pVec
|
|
||||||
float DetInv = glm::dot(e1, DxE2);
|
|
||||||
if (std::abs(DetInv) < FLT_EPSILON) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
DetInv = 1.0f / DetInv;
|
|
||||||
float dist = glm::dot(e2, MxE1) * DetInv;
|
|
||||||
if (dist >= outDistance) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
float u = glm::dot(m, DxE2) * DetInv;
|
|
||||||
float v = glm::dot(ray.Direction(), MxE1) * DetInv;
|
|
||||||
|
|
||||||
//u,v can be very close to 0 but still negative sometimes. added a deltafactor to compensate for that problem
|
bool RayVsAABB(const Ray& ray, const AABB& box)
|
||||||
//If u and v are positive, u+v <= 1, dist is positive, and less than closest.
|
{
|
||||||
if (0 <= (u + 0.001f) && 0 <= (v + 0.001f) && u + v <= 1 && 0 <= dist) {
|
float dummy;
|
||||||
outDistance = dist;
|
return RayVsAABB(ray, box, dummy);
|
||||||
outUCoord = u;
|
}
|
||||||
outVCoord = v;
|
|
||||||
hit = true;
|
bool RayVsAABB(const Ray& ray, const AABB& box, float& outDistance)
|
||||||
|
{
|
||||||
|
glm::vec3 invdir = 1.0f / ray.Direction();
|
||||||
|
glm::vec3 origin = ray.Origin();
|
||||||
|
|
||||||
|
float t1 = (box.MinCorner().x - origin.x)*invdir.x;
|
||||||
|
float t2 = (box.MaxCorner().x - origin.x)*invdir.x;
|
||||||
|
float t3 = (box.MinCorner().y - origin.y)*invdir.y;
|
||||||
|
float t4 = (box.MaxCorner().y - origin.y)*invdir.y;
|
||||||
|
float t5 = (box.MinCorner().z - origin.z)*invdir.z;
|
||||||
|
float t6 = (box.MaxCorner().z - origin.z)*invdir.z;
|
||||||
|
|
||||||
|
float tmin = std::max(std::max(std::min(t1, t2), std::min(t3, t4)), std::min(t5, t6));
|
||||||
|
float tmax = std::min(std::min(std::max(t1, t2), std::max(t3, t4)), std::max(t5, t6));
|
||||||
|
|
||||||
|
//if (tmax < 0 || tmin > tmax)
|
||||||
|
//if tmin,tmax are almost the same (i.e. hitting exactly in the corner) then tmin might be slightly
|
||||||
|
//greater than tmax becuase of floating-precision problems. fixed by adding a small delta to tmax
|
||||||
|
if (tmax < 0 || tmin>(tmax + 0.0001f))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
outDistance = (tmin > 0) ? tmin : tmax;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AABBVsAABB(const AABB& a, const AABB& b)
|
||||||
|
{
|
||||||
|
const glm::vec3& aCenter = a.Center();
|
||||||
|
const glm::vec3& bCenter = b.Center();
|
||||||
|
const glm::vec3& aHSize = a.HalfSize();
|
||||||
|
const glm::vec3& bHSize = b.HalfSize();
|
||||||
|
//Test will probably exit because of the X and Z axes more often, so test them first.
|
||||||
|
if (abs(aCenter[0] - bCenter[0]) > (aHSize[0] + bHSize[0])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (abs(aCenter[2] - bCenter[2]) > (aHSize[2] + bHSize[2])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return (abs(aCenter[1] - bCenter[1]) <= (aHSize[1] + bHSize[1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AABBVsAABB(const AABB& a, const AABB& b, glm::vec3& minimumTranslation)
|
||||||
|
{
|
||||||
|
minimumTranslation = glm::vec3(0, 0, 0);
|
||||||
|
const glm::vec3& aMax = a.MaxCorner();
|
||||||
|
const glm::vec3& bMax = b.MaxCorner();
|
||||||
|
const glm::vec3& aMin = a.MinCorner();
|
||||||
|
const glm::vec3& bMin = b.MinCorner();
|
||||||
|
const glm::vec3& bSize = b.Size();
|
||||||
|
const glm::vec3& aSize = a.Size();
|
||||||
|
float minOffset = INFINITY;
|
||||||
|
float off;
|
||||||
|
auto axisesIntersecting = glm::tvec3<bool, glm::highp>(false, false, false);
|
||||||
|
for (int i = 0; i < 3; ++i) {
|
||||||
|
off = bMax[i] - aMin[i];
|
||||||
|
if (off > 0 && off < bSize[i] + aSize[i]) {
|
||||||
|
if (off < minOffset) {
|
||||||
|
minimumTranslation = glm::vec3();
|
||||||
|
minimumTranslation[i] = minOffset = off;
|
||||||
}
|
}
|
||||||
|
axisesIntersecting[i] = true;
|
||||||
|
}
|
||||||
|
off = aMax[i] - bMin[i];
|
||||||
|
if (off > 0 && off < bSize[i] + aSize[i]) {
|
||||||
|
if (off < minOffset) {
|
||||||
|
minOffset = off;
|
||||||
|
minimumTranslation = glm::vec3();
|
||||||
|
minimumTranslation[i] = -off;
|
||||||
|
}
|
||||||
|
axisesIntersecting[i] = true;
|
||||||
}
|
}
|
||||||
return hit;
|
|
||||||
}
|
}
|
||||||
|
return glm::all(axisesIntersecting);
|
||||||
|
}
|
||||||
|
|
||||||
bool RayVsModel(const Ray& ray,
|
bool RayVsModel(const Ray& ray,
|
||||||
const std::vector<RawModel::Vertex>& modelVertices,
|
const std::vector<RawModel::Vertex>& modelVertices,
|
||||||
const std::vector<unsigned int>& modelIndices,
|
const std::vector<unsigned int>& modelIndices)
|
||||||
glm::vec3& outHitPosition)
|
{
|
||||||
{
|
for (int i = 0; i < modelIndices.size(); ++i) {
|
||||||
float u;
|
glm::vec3 v0 = modelVertices[modelIndices[i]].Position;
|
||||||
float v;
|
glm::vec3 e1 = modelVertices[modelIndices[++i]].Position - v0; //v1 - v0
|
||||||
float dist;
|
glm::vec3 e2 = modelVertices[modelIndices[++i]].Position - v0; //v2 - v0
|
||||||
bool hit = RayVsModel(ray, modelVertices, modelIndices, dist, u, v);
|
glm::vec3 m = ray.Origin() - v0;
|
||||||
outHitPosition = ray.Origin() + dist * ray.Direction();
|
glm::vec3 MxE1 = glm::cross(m, e1);
|
||||||
return hit;
|
glm::vec3 DxE2 = glm::cross(ray.Direction(), e2);
|
||||||
|
float DetInv = glm::dot(e1, DxE2);
|
||||||
|
if (std::abs(DetInv) < FLT_EPSILON) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
DetInv = 1.0f / DetInv;
|
||||||
|
float u = glm::dot(m, DxE2) * DetInv;
|
||||||
|
float v = glm::dot(ray.Direction(), MxE1) * DetInv;
|
||||||
|
//u,v can be very close to 0 but still negative sometimes. added a deltafactor to compensate for that problem
|
||||||
|
if ((u + 0.001f) < 0 || (v + 0.001f) < 0 || 1 < u + v) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//Here, u and v are positive, u+v <= 1, and if distance is positive - triangle is hit.
|
||||||
|
if (0 <= glm::dot(e2, MxE1) * DetInv) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RayVsModel(const Ray& ray,
|
||||||
|
const std::vector<RawModel::Vertex>& modelVertices,
|
||||||
|
const std::vector<unsigned int>& modelIndices,
|
||||||
|
float& outDistance,
|
||||||
|
float& outUCoord,
|
||||||
|
float& outVCoord)
|
||||||
|
{
|
||||||
|
outDistance = INFINITY;
|
||||||
|
bool hit = false;
|
||||||
|
for (int i = 0; i < modelIndices.size(); ++i) {
|
||||||
|
glm::vec3 v0 = modelVertices[modelIndices[i]].Position;
|
||||||
|
glm::vec3 e1 = modelVertices[modelIndices[++i]].Position - v0; //v1 - v0
|
||||||
|
glm::vec3 e2 = modelVertices[modelIndices[++i]].Position - v0; //v2 - v0
|
||||||
|
glm::vec3 m = ray.Origin() - v0;
|
||||||
|
glm::vec3 MxE1 = glm::cross(m, e1);
|
||||||
|
glm::vec3 DxE2 = glm::cross(ray.Direction(), e2);//pVec
|
||||||
|
float DetInv = glm::dot(e1, DxE2);
|
||||||
|
if (std::abs(DetInv) < FLT_EPSILON) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
DetInv = 1.0f / DetInv;
|
||||||
|
float dist = glm::dot(e2, MxE1) * DetInv;
|
||||||
|
if (dist >= outDistance) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
float u = glm::dot(m, DxE2) * DetInv;
|
||||||
|
float v = glm::dot(ray.Direction(), MxE1) * DetInv;
|
||||||
|
|
||||||
|
//u,v can be very close to 0 but still negative sometimes. added a deltafactor to compensate for that problem
|
||||||
|
//If u and v are positive, u+v <= 1, dist is positive, and less than closest.
|
||||||
|
if (0 <= (u + 0.001f) && 0 <= (v + 0.001f) && u + v <= 1 && 0 <= dist) {
|
||||||
|
outDistance = dist;
|
||||||
|
outUCoord = u;
|
||||||
|
outVCoord = v;
|
||||||
|
hit = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hit;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RayVsModel(const Ray& ray,
|
||||||
|
const std::vector<RawModel::Vertex>& modelVertices,
|
||||||
|
const std::vector<unsigned int>& modelIndices,
|
||||||
|
glm::vec3& outHitPosition)
|
||||||
|
{
|
||||||
|
float u;
|
||||||
|
float v;
|
||||||
|
float dist;
|
||||||
|
bool hit = RayVsModel(ray, modelVertices, modelIndices, dist, u, v);
|
||||||
|
outHitPosition = ray.Origin() + dist * ray.Direction();
|
||||||
|
return hit;
|
||||||
|
}
|
||||||
|
|
||||||
bool IsSameBoxProbably(const AABB& first, const AABB& second, const float epsilon)
|
bool IsSameBoxProbably(const AABB& first, const AABB& second, const float epsilon)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -144,10 +144,11 @@ void EntityFilePreprocessor::parseComponentInfo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto& field = compInfo.Fields[name];
|
auto& field = compInfo.Fields[name];
|
||||||
|
field.Name = name;
|
||||||
field.Type = type;
|
field.Type = type;
|
||||||
field.Offset = fieldOffset;
|
field.Offset = fieldOffset;
|
||||||
field.Stride = stride;
|
field.Stride = stride;
|
||||||
compInfo.FieldsInOrder.push_back(&field);
|
compInfo.FieldsInOrder.push_back(name);
|
||||||
|
|
||||||
fieldOffset += stride;
|
fieldOffset += stride;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ EditorSystem::EditorSystem(EventBroker* eventBroker, IRenderer* renderer)
|
|||||||
EVENT_SUBSCRIBE_MEMBER(m_EMousePress, &EditorSystem::OnMousePress);
|
EVENT_SUBSCRIBE_MEMBER(m_EMousePress, &EditorSystem::OnMousePress);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EMouseRelease, &EditorSystem::OnMouseRelease);
|
EVENT_SUBSCRIBE_MEMBER(m_EMouseRelease, &EditorSystem::OnMouseRelease);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EMouseMove, &EditorSystem::OnMouseMove);
|
EVENT_SUBSCRIBE_MEMBER(m_EMouseMove, &EditorSystem::OnMouseMove);
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EPicking, &EditorSystem::OnPicking);
|
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EFileDropped, &EditorSystem::OnFileDropped);
|
EVENT_SUBSCRIBE_MEMBER(m_EFileDropped, &EditorSystem::OnFileDropped);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,7 +33,7 @@ void EditorSystem::Update(World* world, double dt)
|
|||||||
if (!m_Visible) {
|
if (!m_Visible) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Picking();
|
||||||
updateWidget();
|
updateWidget();
|
||||||
|
|
||||||
drawUI(world, dt);
|
drawUI(world, dt);
|
||||||
@@ -128,7 +127,7 @@ bool EditorSystem::OnMouseMove(const Events::MouseMove& e)
|
|||||||
|
|
||||||
auto widgetTransform = m_World->GetComponent(m_Widget, "Transform");
|
auto widgetTransform = m_World->GetComponent(m_Widget, "Transform");
|
||||||
glm::vec3 widgetOrientation = widgetTransform["Orientation"];
|
glm::vec3 widgetOrientation = widgetTransform["Orientation"];
|
||||||
glm::quat totalOrientation = m_Renderer->Camera()->Orientation() * glm::inverse(glm::quat(widgetOrientation));
|
glm::quat totalOrientation = m_Camera->Orientation() * glm::inverse(glm::quat(widgetOrientation));
|
||||||
|
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
@@ -140,14 +139,14 @@ bool EditorSystem::OnMouseMove(const Events::MouseMove& e)
|
|||||||
delta2,
|
delta2,
|
||||||
m_WidgetPickingDepth,
|
m_WidgetPickingDepth,
|
||||||
res,
|
res,
|
||||||
m_Renderer->Camera()->ProjectionMatrix(),
|
m_Camera->ProjectionMatrix(),
|
||||||
glm::toMat4(glm::inverse(totalOrientation))
|
glm::toMat4(glm::inverse(totalOrientation))
|
||||||
);
|
);
|
||||||
glm::vec3 origin = ScreenCoords::ToWorldPos(
|
glm::vec3 origin = ScreenCoords::ToWorldPos(
|
||||||
glm::vec2(res.Width / 2.f, res.Height / 2.f),
|
glm::vec2(res.Width / 2.f, res.Height / 2.f),
|
||||||
m_WidgetPickingDepth,
|
m_WidgetPickingDepth,
|
||||||
res,
|
res,
|
||||||
m_Renderer->Camera()->ProjectionMatrix(),
|
m_Camera->ProjectionMatrix(),
|
||||||
glm::toMat4(glm::inverse(totalOrientation))
|
glm::toMat4(glm::inverse(totalOrientation))
|
||||||
);
|
);
|
||||||
deltaWorld = deltaWorld - origin;
|
deltaWorld = deltaWorld - origin;
|
||||||
@@ -160,7 +159,7 @@ bool EditorSystem::OnMouseMove(const Events::MouseMove& e)
|
|||||||
EntityID parent = m_World->GetParent(m_Selection);
|
EntityID parent = m_World->GetParent(m_Selection);
|
||||||
glm::quat inverseParentOrientation;
|
glm::quat inverseParentOrientation;
|
||||||
//if (parent != 0) {
|
//if (parent != 0) {
|
||||||
inverseParentOrientation = glm::inverse(RenderQueueFactory::AbsoluteOrientation(m_World, parent));
|
inverseParentOrientation = glm::inverse(Transform::AbsoluteOrientation(m_World, parent));
|
||||||
//}
|
//}
|
||||||
(glm::vec3&)m_World->GetComponent(m_Selection, "Transform")["Position"] += inverseParentOrientation * movement;
|
(glm::vec3&)m_World->GetComponent(m_Selection, "Transform")["Position"] += inverseParentOrientation * movement;
|
||||||
} else if (m_WidgetSpace == WidgetSpace::Local) {
|
} else if (m_WidgetSpace == WidgetSpace::Local) {
|
||||||
@@ -176,10 +175,10 @@ bool EditorSystem::OnMouseMove(const Events::MouseMove& e)
|
|||||||
EntityID parent = m_World->GetParent(m_Selection);
|
EntityID parent = m_World->GetParent(m_Selection);
|
||||||
glm::quat parentOrientation;
|
glm::quat parentOrientation;
|
||||||
//if (parent != 0) {
|
//if (parent != 0) {
|
||||||
// parentOrientation = RenderQueueFactory::AbsoluteOrientation(m_World, parent);
|
// parentOrientation = RenderSystem::AbsoluteOrientation(m_World, parent);
|
||||||
//}
|
//}
|
||||||
glm::vec3& selectionOrientation = m_World->GetComponent(m_Selection, "Transform")["Orientation"];
|
glm::vec3& selectionOrientation = m_World->GetComponent(m_Selection, "Transform")["Orientation"];
|
||||||
glm::quat currentOrientation = RenderQueueFactory::AbsoluteOrientation(m_World, m_Selection);
|
glm::quat currentOrientation = Transform::AbsoluteOrientation(m_World, m_Selection);
|
||||||
//glm::quat currentOrientation = parentOrientation * glm::quat(selectionOrientation);
|
//glm::quat currentOrientation = parentOrientation * glm::quat(selectionOrientation);
|
||||||
glm::quat deltaOrientation(finalMovement);
|
glm::quat deltaOrientation(finalMovement);
|
||||||
selectionOrientation = glm::eulerAngles(glm::inverse(parentOrientation) * (deltaOrientation * currentOrientation));
|
selectionOrientation = glm::eulerAngles(glm::inverse(parentOrientation) * (deltaOrientation * currentOrientation));
|
||||||
@@ -235,10 +234,10 @@ bool EditorSystem::OnMouseRelease(const Events::MouseRelease& e)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditorSystem::OnPicking(const Events::Picking& e)
|
void EditorSystem::Picking()
|
||||||
{
|
{
|
||||||
for (auto& pos : m_PickingQueue) {
|
for (auto& pos : m_PickingQueue) {
|
||||||
auto result = e.Pick(pos);
|
auto result = m_Renderer->Pick(pos);
|
||||||
EntityID entity = result.Entity;
|
EntityID entity = result.Entity;
|
||||||
if (glm::length2(m_WidgetCurrentAxis) > 0.f) {
|
if (glm::length2(m_WidgetCurrentAxis) > 0.f) {
|
||||||
// ???
|
// ???
|
||||||
@@ -246,6 +245,7 @@ bool EditorSystem::OnPicking(const Events::Picking& e)
|
|||||||
LOG_INFO("Selected %i", entity);
|
LOG_INFO("Selected %i", entity);
|
||||||
if (entity != EntityID_Invalid) {
|
if (entity != EntityID_Invalid) {
|
||||||
EntityID parent = m_World->GetParent(entity);
|
EntityID parent = m_World->GetParent(entity);
|
||||||
|
m_Camera = result.Camera;
|
||||||
if (parent == m_Widget) {
|
if (parent == m_Widget) {
|
||||||
m_WidgetCurrentAxis = glm::vec3(
|
m_WidgetCurrentAxis = glm::vec3(
|
||||||
(entity == m_WidgetX) || (entity == m_WidgetOrigin) || (entity == m_WidgetPlaneY || entity == m_WidgetPlaneZ),
|
(entity == m_WidgetX) || (entity == m_WidgetOrigin) || (entity == m_WidgetPlaneY || entity == m_WidgetPlaneZ),
|
||||||
@@ -253,7 +253,6 @@ bool EditorSystem::OnPicking(const Events::Picking& e)
|
|||||||
(entity == m_WidgetZ) || (entity == m_WidgetOrigin) || (entity == m_WidgetPlaneX || entity == m_WidgetPlaneY)
|
(entity == m_WidgetZ) || (entity == m_WidgetOrigin) || (entity == m_WidgetPlaneX || entity == m_WidgetPlaneY)
|
||||||
);
|
);
|
||||||
m_WidgetPickingDepth = result.Depth;
|
m_WidgetPickingDepth = result.Depth;
|
||||||
|
|
||||||
//auto widgetTransform = m_World->GetComponent(m_Widget, "Transform");
|
//auto widgetTransform = m_World->GetComponent(m_Widget, "Transform");
|
||||||
//auto selectionTransform = m_World->GetComponent(m_Selection, "Transform");
|
//auto selectionTransform = m_World->GetComponent(m_Selection, "Transform");
|
||||||
//widgetTransform["Position"] = (glm::vec3)selectionTransform["Position"];
|
//widgetTransform["Position"] = (glm::vec3)selectionTransform["Position"];
|
||||||
@@ -269,7 +268,6 @@ bool EditorSystem::OnPicking(const Events::Picking& e)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_PickingQueue.clear();
|
m_PickingQueue.clear();
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool EditorSystem::OnFileDropped(const Events::FileDropped& e)
|
bool EditorSystem::OnFileDropped(const Events::FileDropped& e)
|
||||||
@@ -323,10 +321,10 @@ void EditorSystem::updateWidget()
|
|||||||
|
|
||||||
if (m_Selection != EntityID_Invalid) {
|
if (m_Selection != EntityID_Invalid) {
|
||||||
auto widgetTransform = m_World->GetComponent(m_Widget, "Transform");
|
auto widgetTransform = m_World->GetComponent(m_Widget, "Transform");
|
||||||
glm::vec3 selectionPosition = RenderQueueFactory::AbsolutePosition(m_World, m_Selection);
|
glm::vec3 selectionPosition = Transform::AbsolutePosition(m_World, m_Selection);
|
||||||
widgetTransform["Position"] = selectionPosition;
|
widgetTransform["Position"] = selectionPosition;
|
||||||
if (m_WidgetSpace == WidgetSpace::Local) {
|
if (m_WidgetSpace == WidgetSpace::Local) {
|
||||||
widgetTransform["Orientation"] = glm::eulerAngles(RenderQueueFactory::AbsoluteOrientation(m_World, m_Selection));
|
widgetTransform["Orientation"] = glm::eulerAngles(Transform::AbsoluteOrientation(m_World, m_Selection));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -361,7 +359,7 @@ void EditorSystem::setWidgetMode(WidgetMode newMode)
|
|||||||
if (m_Selection != EntityID_Invalid) {
|
if (m_Selection != EntityID_Invalid) {
|
||||||
if (m_WidgetSpace == WidgetSpace::Local) {
|
if (m_WidgetSpace == WidgetSpace::Local) {
|
||||||
auto selectionTransform = m_World->GetComponent(m_Selection, "Transform");
|
auto selectionTransform = m_World->GetComponent(m_Selection, "Transform");
|
||||||
widgetTransform["Orientation"] = glm::eulerAngles(RenderQueueFactory::AbsoluteOrientation(m_World, m_Selection));
|
widgetTransform["Orientation"] = glm::eulerAngles(Transform::AbsoluteOrientation(m_World, m_Selection));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (newMode == WidgetMode::Scale) {
|
} else if (newMode == WidgetMode::Scale) {
|
||||||
@@ -372,7 +370,7 @@ void EditorSystem::setWidgetMode(WidgetMode newMode)
|
|||||||
m_World->GetComponent(m_WidgetOrigin, "Model")["Resource"] = "Models/ScaleWidgetOrigin.obj";
|
m_World->GetComponent(m_WidgetOrigin, "Model")["Resource"] = "Models/ScaleWidgetOrigin.obj";
|
||||||
if (m_Selection != EntityID_Invalid) {
|
if (m_Selection != EntityID_Invalid) {
|
||||||
auto selectionTransform = m_World->GetComponent(m_Selection, "Transform");
|
auto selectionTransform = m_World->GetComponent(m_Selection, "Transform");
|
||||||
widgetTransform["Orientation"] = glm::eulerAngles(RenderQueueFactory::AbsoluteOrientation(m_World, m_Selection));
|
widgetTransform["Orientation"] = glm::eulerAngles(Transform::AbsoluteOrientation(m_World, m_Selection));
|
||||||
}
|
}
|
||||||
} else if (newMode == WidgetMode::Rotate) {
|
} else if (newMode == WidgetMode::Rotate) {
|
||||||
m_World->GetComponent(m_WidgetX, "Model")["Resource"] = "Models/RotationWidgetX.obj";
|
m_World->GetComponent(m_WidgetX, "Model")["Resource"] = "Models/RotationWidgetX.obj";
|
||||||
@@ -381,7 +379,7 @@ void EditorSystem::setWidgetMode(WidgetMode newMode)
|
|||||||
if (m_Selection != EntityID_Invalid) {
|
if (m_Selection != EntityID_Invalid) {
|
||||||
auto selectionTransform = m_World->GetComponent(m_Selection, "Transform");
|
auto selectionTransform = m_World->GetComponent(m_Selection, "Transform");
|
||||||
if (m_WidgetSpace == WidgetSpace::Local) {
|
if (m_WidgetSpace == WidgetSpace::Local) {
|
||||||
widgetTransform["Orientation"] = glm::eulerAngles(RenderQueueFactory::AbsoluteOrientation(m_World, m_Selection));
|
widgetTransform["Orientation"] = glm::eulerAngles(Transform::AbsoluteOrientation(m_World, m_Selection));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ void InputProxy::Process()
|
|||||||
e.Command = command;
|
e.Command = command;
|
||||||
e.Value = currentValue;
|
e.Value = currentValue;
|
||||||
m_EventBroker->Publish(e);
|
m_EventBroker->Publish(e);
|
||||||
LOG_DEBUG("Input: Published command %s=%f for player %i", e.Command.c_str(), e.Value, e.PlayerID);
|
//LOG_DEBUG("Input: Published command %s=%f for player %i", e.Command.c_str(), e.Value, e.PlayerID);
|
||||||
m_LastCommandValues[command] = currentValue;
|
m_LastCommandValues[command] = currentValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,7 @@ void InputProxy::Process()
|
|||||||
}
|
}
|
||||||
//e.Value = std::max(-1.f, std::min(e.Value, 1.f));
|
//e.Value = std::max(-1.f, std::min(e.Value, 1.f));
|
||||||
m_EventBroker->Publish(e);
|
m_EventBroker->Publish(e);
|
||||||
LOG_DEBUG("Input: Published command %s=%f for player %i", e.Command.c_str(), e.Value, e.PlayerID);
|
//LOG_DEBUG("Input: Published command %s=%f for player %i", e.Command.c_str(), e.Value, e.PlayerID);
|
||||||
}
|
}
|
||||||
m_CommandQueue.clear();
|
m_CommandQueue.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ Client::Client(ConfigFile* config) : m_Socket(m_IOService)
|
|||||||
|
|
||||||
Client::~Client()
|
Client::~Client()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::Start(World* world, EventBroker* eventBroker)
|
void Client::Start(World* world, EventBroker* eventBroker)
|
||||||
@@ -27,14 +26,8 @@ void Client::Start(World* world, EventBroker* eventBroker)
|
|||||||
m_World = world;
|
m_World = world;
|
||||||
|
|
||||||
// Subscribe to events
|
// Subscribe to events
|
||||||
m_EInputCommand = decltype(m_EInputCommand)(std::bind(&Client::OnInputCommand, this, std::placeholders::_1));
|
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Client::OnInputCommand);
|
||||||
m_EventBroker->Subscribe(m_EInputCommand);
|
|
||||||
|
|
||||||
|
|
||||||
//while (m_PlayerName.size() > 7) {
|
|
||||||
// LOG_INFO("Please enter your name (No longer than 7 characters):");
|
|
||||||
// std::cin >> m_PlayerName;
|
|
||||||
//}
|
|
||||||
m_Socket.connect(m_ReceiverEndpoint);
|
m_Socket.connect(m_ReceiverEndpoint);
|
||||||
LOG_INFO("I am client. BIP BOP");
|
LOG_INFO("I am client. BIP BOP");
|
||||||
}
|
}
|
||||||
@@ -44,18 +37,9 @@ void Client::Update()
|
|||||||
readFromServer();
|
readFromServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::Close()
|
|
||||||
{
|
|
||||||
if (m_WasStarted) {
|
|
||||||
disconnect();
|
|
||||||
m_ThreadIsRunning = false;
|
|
||||||
m_EventBroker->Unsubscribe(m_EInputCommand);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Client::readFromServer()
|
void Client::readFromServer()
|
||||||
{
|
{
|
||||||
if (m_Socket.available()) {
|
while (m_Socket.available()) {
|
||||||
bytesRead = receive(readBuf, INPUTSIZE);
|
bytesRead = receive(readBuf, INPUTSIZE);
|
||||||
if (bytesRead > 0) {
|
if (bytesRead > 0) {
|
||||||
Packet packet(readBuf, bytesRead);
|
Packet packet(readBuf, bytesRead);
|
||||||
@@ -65,7 +49,7 @@ void Client::readFromServer()
|
|||||||
std::clock_t currentTime = std::clock();
|
std::clock_t currentTime = std::clock();
|
||||||
if (snapshotInterval < (1000 * (currentTime - previousSnapshotMessage) / (double)CLOCKS_PER_SEC)) {
|
if (snapshotInterval < (1000 * (currentTime - previousSnapshotMessage) / (double)CLOCKS_PER_SEC)) {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
sendSnapshotToServer();
|
//sendSnapshotToServer();
|
||||||
}
|
}
|
||||||
previousSnapshotMessage = currentTime;
|
previousSnapshotMessage = currentTime;
|
||||||
}
|
}
|
||||||
@@ -73,13 +57,12 @@ void Client::readFromServer()
|
|||||||
|
|
||||||
void Client::sendSnapshotToServer()
|
void Client::sendSnapshotToServer()
|
||||||
{
|
{
|
||||||
// Reset previouse key state in snapshot.
|
// Reset previous key state in snapshot.
|
||||||
m_NextSnapshot.InputForward = "";
|
m_NextSnapshot.InputForward = "";
|
||||||
m_NextSnapshot.InputRight = "";
|
m_NextSnapshot.InputRight = "";
|
||||||
|
|
||||||
auto player = m_World->GetComponent(m_PlayerDefinitions[m_PlayerID].EntityID, "Player");
|
auto player = m_World->GetComponent(m_PlayerDefinitions[m_PlayerID].EntityID, "Player");
|
||||||
|
|
||||||
|
|
||||||
// See if any movement keys are down
|
// See if any movement keys are down
|
||||||
// We dont care if it's overwritten by later
|
// We dont care if it's overwritten by later
|
||||||
// if statement. Watcha gonna do, right!
|
// if statement. Watcha gonna do, right!
|
||||||
@@ -125,6 +108,8 @@ void Client::parseMessageType(Packet& packet)
|
|||||||
// 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
|
||||||
|
if (m_PacketID <= m_PreviousPacketID)
|
||||||
|
return;
|
||||||
//IdentifyPacketLoss();
|
//IdentifyPacketLoss();
|
||||||
|
|
||||||
switch (static_cast<MessageType>(messageType)) {
|
switch (static_cast<MessageType>(messageType)) {
|
||||||
@@ -184,33 +169,51 @@ void Client::parseEventMessage(Packet& packet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Client::updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID, const std::string& componentType)
|
||||||
|
{
|
||||||
|
for (auto field : componentInfo.FieldsInOrder) {
|
||||||
|
ComponentInfo::Field_t fieldInfo = componentInfo.Fields.at(field);
|
||||||
|
if (fieldInfo.Type == "string") {
|
||||||
|
std::string& value = packet.ReadString();
|
||||||
|
m_World->GetComponent(entityID, componentType)[fieldInfo.Name] = value;
|
||||||
|
} else {
|
||||||
|
memcpy(m_World->GetComponent(entityID, componentType).Data + fieldInfo.Offset, packet.ReadData(fieldInfo.Stride), fieldInfo.Stride);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Field parse
|
||||||
void Client::parseSnapshot(Packet& packet)
|
void Client::parseSnapshot(Packet& packet)
|
||||||
{
|
{
|
||||||
std::string tempName;
|
std::string componentType = packet.ReadString();
|
||||||
for (size_t i = 0; i < MAXCONNECTIONS; i++) {
|
while (packet.DataReadSize() < packet.Size()) {
|
||||||
// We're checking for empty name for now. This might not be the best way,
|
EntityID entityID = packet.ReadPrimitive<EntityID>();
|
||||||
// but it is to avoid sending redundant data.
|
ComponentInfo componentInfo = m_World->GetComponents(componentType)->ComponentInfo();
|
||||||
tempName = packet.ReadString();
|
if (m_World->ValidEntity(entityID)) {
|
||||||
|
if (m_World->HasComponent(entityID, componentType)) {
|
||||||
|
// If the entity and the component exists update it
|
||||||
// Apply the position data read to the player entity
|
updateFields(packet, componentInfo, entityID, componentType);
|
||||||
// New player connected on the server side
|
// if entity exists but not the component
|
||||||
if (m_PlayerDefinitions[i].Name == "" && tempName != "") {
|
} else {
|
||||||
m_PlayerDefinitions[i].Name = tempName;
|
// Create component
|
||||||
m_PlayerDefinitions[i].EntityID = createPlayer();
|
m_World->AttachComponent(entityID, componentType);
|
||||||
} else if (m_PlayerDefinitions[i].Name != "" && tempName == "") {
|
// Copy data to newly created component
|
||||||
// Someone disconnected
|
updateFields(packet, componentInfo, entityID, componentType);
|
||||||
// TODO: Insert code here
|
}
|
||||||
break;
|
// If the entity dosent exist nor the component
|
||||||
} else if (m_PlayerDefinitions[i].Name == "" && tempName == "") {
|
} else {
|
||||||
// Not a connected player
|
//Create Entity
|
||||||
break;
|
// If entity dosen't exist
|
||||||
}
|
EntityID newEntityID = m_World->CreateEntity();
|
||||||
if (m_PlayerDefinitions[i].EntityID != -1) {
|
// Check if EntityIDs are out of sync
|
||||||
|
if (newEntityID != entityID) {
|
||||||
// Move player to server position
|
LOG_INFO("Client::parseSnapshot(Packet& packet): Newly created EntityID is not the \
|
||||||
int dataSize = m_World->GetComponent(m_PlayerDefinitions[i].EntityID, "Transform").Info.Meta.Stride;
|
same as the one sent by server (EntityIDs are out of sync)");
|
||||||
memcpy(m_World->GetComponent(m_PlayerDefinitions[i].EntityID, "Transform").Data, packet.ReadData(dataSize), dataSize);
|
}
|
||||||
|
// Create component
|
||||||
|
m_World->AttachComponent(newEntityID, componentType);
|
||||||
|
// Copy data to newly created component
|
||||||
|
updateFields(packet, componentInfo, newEntityID, componentType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -225,7 +228,7 @@ int Client::receive(char* data, size_t length)
|
|||||||
0, error);
|
0, error);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
//LOG_ERROR("receive: %s", error.message().c_str());
|
LOG_ERROR("receive: %s", error.message().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
return bytesReceived;
|
return bytesReceived;
|
||||||
|
|||||||
@@ -3,13 +3,7 @@
|
|||||||
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];
|
||||||
// Create message header
|
Init(type, packetID);
|
||||||
// Add message type
|
|
||||||
int messageType = static_cast<int>(type);
|
|
||||||
Packet::WritePrimitive<int>(messageType);
|
|
||||||
packetID = packetID % 1000; // Packet id modulos
|
|
||||||
Packet::WritePrimitive<int>(packetID);
|
|
||||||
packetID++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create message
|
// Create message
|
||||||
@@ -28,12 +22,26 @@ Packet::~Packet()
|
|||||||
delete[] m_Data;
|
delete[] m_Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Packet::WriteString(std::string str)
|
void Packet::Init(MessageType type, unsigned int & packetID)
|
||||||
|
{
|
||||||
|
m_ReturnDataOffset = 0;
|
||||||
|
m_Offset = 0;
|
||||||
|
// Create message header
|
||||||
|
// Add message type
|
||||||
|
int messageType = static_cast<int>(type);
|
||||||
|
Packet::WritePrimitive<int>(messageType);
|
||||||
|
packetID = packetID % 1000; // Packet id modulos
|
||||||
|
Packet::WritePrimitive<int>(packetID);
|
||||||
|
packetID++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Packet::WriteString(const std::string& str)
|
||||||
{
|
{
|
||||||
// Message, add one extra byte for null terminator
|
// Message, add one extra byte for null terminator
|
||||||
int sizeOfString = str.size() + 1;
|
int sizeOfString = str.size() + 1;
|
||||||
if (m_Offset + sizeOfString > m_MaxPacketSize) {
|
if (m_Offset + sizeOfString > m_MaxPacketSize) {
|
||||||
LOG_WARNING("Package::WriteString(): Data size in packet exceeded maximum package size.\n");
|
LOG_WARNING("Package::WriteString(): Data size in packet exceeded maximum package size. New size is %i bytes\n", m_MaxPacketSize*2);
|
||||||
|
resizeData();
|
||||||
}
|
}
|
||||||
memcpy(m_Data + m_Offset, str.data(), sizeOfString * sizeof(char));
|
memcpy(m_Data + m_Offset, str.data(), sizeOfString * sizeof(char));
|
||||||
m_Offset += sizeOfString * sizeof(char);
|
m_Offset += sizeOfString * sizeof(char);
|
||||||
@@ -42,7 +50,8 @@ void Packet::WriteString(std::string str)
|
|||||||
void Packet::WriteData(char * data, int sizeOfData)
|
void Packet::WriteData(char * data, int sizeOfData)
|
||||||
{
|
{
|
||||||
if (m_Offset + sizeOfData > m_MaxPacketSize) {
|
if (m_Offset + sizeOfData > m_MaxPacketSize) {
|
||||||
LOG_WARNING("Packet::WriteData(): Data size in packet exceeded maximum packet size.\n");
|
LOG_WARNING("Packet::WriteData(): Data size in packet exceeded maximum packet size. New size is %i bytes\n", m_MaxPacketSize*2);
|
||||||
|
resizeData();
|
||||||
}
|
}
|
||||||
memcpy(m_Data + m_Offset, data, sizeOfData);
|
memcpy(m_Data + m_Offset, data, sizeOfData);
|
||||||
m_Offset += sizeOfData;
|
m_Offset += sizeOfData;
|
||||||
@@ -70,3 +79,23 @@ char * Packet::ReadData(int SizeOfData)
|
|||||||
m_ReturnDataOffset += SizeOfData;
|
m_ReturnDataOffset += SizeOfData;
|
||||||
return (m_Data + oldReturnDataOffset);
|
return (m_Data + oldReturnDataOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Packet::resizeData()
|
||||||
|
{
|
||||||
|
|
||||||
|
// Allocate memory to store our data in
|
||||||
|
char* holdData = new char[m_MaxPacketSize];
|
||||||
|
// Copy our data to the newly allocated memory
|
||||||
|
memcpy(holdData, m_Data, m_Offset);
|
||||||
|
// Increase max packet size
|
||||||
|
m_MaxPacketSize = m_MaxPacketSize * 2;
|
||||||
|
// Delete our data
|
||||||
|
delete m_Data;
|
||||||
|
// Allocate twice the memory we had before
|
||||||
|
m_Data = new char[m_MaxPacketSize];
|
||||||
|
// Copy our data to new location
|
||||||
|
memcpy(m_Data, holdData, m_Offset);
|
||||||
|
// Delete the memory allocated to hold our data
|
||||||
|
// while we resized the old data container.
|
||||||
|
delete holdData;
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ Server::Server() : m_Socket(m_IOService, boost::asio::ip::udp::endpoint(boost::a
|
|||||||
{ }
|
{ }
|
||||||
|
|
||||||
Server::~Server()
|
Server::~Server()
|
||||||
{ }
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Server::Start(World* world, EventBroker* eventBroker)
|
void Server::Start(World* world, EventBroker* eventBroker)
|
||||||
@@ -22,18 +24,9 @@ void Server::Update()
|
|||||||
readFromClients();
|
readFromClients();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::Close()
|
|
||||||
{
|
|
||||||
m_ThreadIsRunning = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Server::readFromClients()
|
void Server::readFromClients()
|
||||||
{
|
{
|
||||||
// m_ThreadIsRunning might be unnecessary but the
|
while (m_Socket.available()) {
|
||||||
// program crashed if it executed m_Socket.available()
|
|
||||||
// when closing the program.
|
|
||||||
|
|
||||||
if (m_Socket.available()) {
|
|
||||||
try {
|
try {
|
||||||
bytesRead = receive(readBuffer, INPUTSIZE);
|
bytesRead = receive(readBuffer, INPUTSIZE);
|
||||||
Packet packet(readBuffer, bytesRead);
|
Packet packet(readBuffer, bytesRead);
|
||||||
@@ -41,7 +34,6 @@ void Server::readFromClients()
|
|||||||
} catch (const std::exception& err) {
|
} catch (const std::exception& err) {
|
||||||
//LOG_ERROR("%i: Read from client crashed %s", m_PacketID, err.what());
|
//LOG_ERROR("%i: Read from client crashed %s", m_PacketID, err.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
std::clock_t currentTime = std::clock();
|
std::clock_t currentTime = std::clock();
|
||||||
// Send snapshot
|
// Send snapshot
|
||||||
@@ -58,7 +50,7 @@ void Server::readFromClients()
|
|||||||
|
|
||||||
// Time out logic
|
// Time out logic
|
||||||
if (checkTimeOutInterval < (1000 * (currentTime - timOutTimer) / (double)CLOCKS_PER_SEC)) {
|
if (checkTimeOutInterval < (1000 * (currentTime - timOutTimer) / (double)CLOCKS_PER_SEC)) {
|
||||||
checkForTimeOuts();
|
//checkForTimeOuts();
|
||||||
timOutTimer = currentTime;
|
timOutTimer = currentTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,7 +100,7 @@ int Server::receive(char * data, size_t length)
|
|||||||
|
|
||||||
void Server::send(Packet& packet, int playerID)
|
void Server::send(Packet& packet, int playerID)
|
||||||
{
|
{
|
||||||
m_Socket.send_to(
|
int bytesSent = m_Socket.send_to(
|
||||||
boost::asio::buffer(packet.Data(), packet.Size()),
|
boost::asio::buffer(packet.Data(), packet.Size()),
|
||||||
m_PlayerDefinitions[playerID].Endpoint,
|
m_PlayerDefinitions[playerID].Endpoint,
|
||||||
0);
|
0);
|
||||||
@@ -150,22 +142,32 @@ void Server::broadcast(Packet& packet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Send snapshot fields
|
||||||
void Server::sendSnapshot()
|
void Server::sendSnapshot()
|
||||||
{
|
{
|
||||||
Packet packet(MessageType::Snapshot, m_SendPacketID);
|
// Should time this
|
||||||
for (size_t i = 0; i < MAXCONNECTIONS; i++) {
|
std::unordered_map<std::string, ComponentPool*> worldComponentPools = m_World->GetComponentPools();
|
||||||
|
for (auto& it : worldComponentPools) {
|
||||||
|
Packet packet(MessageType::Snapshot, m_SendPacketID);
|
||||||
|
std::string componentType = it.first;
|
||||||
|
ComponentPool* componentPool = it.second;
|
||||||
|
ComponentInfo componentInfo = componentPool->ComponentInfo();
|
||||||
|
packet.WriteString(componentInfo.Name);
|
||||||
|
|
||||||
// Send an empty name if there is no player connected on this position.
|
for (auto& componentWrapper : *componentPool) {
|
||||||
packet.WriteString(m_PlayerDefinitions[i].Name);
|
packet.WritePrimitive(componentWrapper.EntityID);
|
||||||
|
for (auto& componentField : componentWrapper.Info.FieldsInOrder) {
|
||||||
if (m_PlayerDefinitions[i].EntityID == -1) {
|
ComponentInfo::Field_t fieldInfo = componentInfo.Fields.at(componentField);
|
||||||
continue;
|
if (fieldInfo.Type == "string") {
|
||||||
|
std::string& value = componentWrapper[componentField];
|
||||||
|
packet.WriteString(value);
|
||||||
|
} else {
|
||||||
|
packet.WriteData(componentWrapper.Data + fieldInfo.Offset, fieldInfo.Stride);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Pack transfrom component into data packet
|
broadcast(packet);
|
||||||
auto transform = m_World->GetComponent(m_PlayerDefinitions[i].EntityID, "Transform");
|
|
||||||
packet.WriteData(transform.Data, transform.Info.Meta.Stride);
|
|
||||||
}
|
}
|
||||||
broadcast(packet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::sendPing()
|
void Server::sendPing()
|
||||||
@@ -174,10 +176,9 @@ void Server::sendPing()
|
|||||||
for (size_t i = 0; i < MAXCONNECTIONS; i++) {
|
for (size_t i = 0; i < MAXCONNECTIONS; i++) {
|
||||||
if (m_PlayerDefinitions[i].Endpoint.address() != boost::asio::ip::address()) {
|
if (m_PlayerDefinitions[i].Endpoint.address() != boost::asio::ip::address()) {
|
||||||
int ping = 1000 * (m_StopTimes[i] - m_StartPingTime) / static_cast<double>(CLOCKS_PER_SEC);
|
int ping = 1000 * (m_StopTimes[i] - m_StartPingTime) / static_cast<double>(CLOCKS_PER_SEC);
|
||||||
LOG_INFO("%i: Player %i's ping: %i", m_PacketID, i, ping);
|
LOG_INFO("Last packetID received %i: Player %i's ping: %i", m_PacketID, i, ping);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create ping message
|
// Create ping message
|
||||||
Packet packet(MessageType::ServerPing, m_SendPacketID);
|
Packet packet(MessageType::ServerPing, m_SendPacketID);
|
||||||
packet.WriteString("Ping from server");
|
packet.WriteString("Ping from server");
|
||||||
@@ -271,7 +272,7 @@ void Server::parseConnect(Packet& packet)
|
|||||||
|
|
||||||
m_StopTimes[i] = std::clock();
|
m_StopTimes[i] = std::clock();
|
||||||
|
|
||||||
LOG_INFO("Player \"%s\" connected on IP: %s", m_PlayerDefinitions[i].Name, m_PlayerDefinitions[i].Endpoint.address().to_string());
|
LOG_INFO("Player \"%s\" connected on IP: %s", m_PlayerDefinitions[i].Name.c_str(), m_PlayerDefinitions[i].Endpoint.address().to_string().c_str());
|
||||||
|
|
||||||
Packet packet(MessageType::Connect, m_SendPacketID);
|
Packet packet(MessageType::Connect, m_SendPacketID);
|
||||||
packet.WritePrimitive<int>(i); // Player ID
|
packet.WritePrimitive<int>(i); // Player ID
|
||||||
|
|||||||
@@ -50,6 +50,18 @@ void Camera::SetOrientation(glm::quat val)
|
|||||||
UpdateViewMatrix();
|
UpdateViewMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Camera::SetProjectionMatrix(glm::mat4 val)
|
||||||
|
{
|
||||||
|
m_ProjectionMatrix = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Camera::SetViewMatrix(glm::mat4 val)
|
||||||
|
{
|
||||||
|
m_ViewMatrix = val;
|
||||||
|
}
|
||||||
|
|
||||||
//void Camera::Pitch(float val)
|
//void Camera::Pitch(float val)
|
||||||
//{
|
//{
|
||||||
// m_Pitch = val;
|
// m_Pitch = val;
|
||||||
@@ -64,15 +76,6 @@ void Camera::SetOrientation(glm::quat val)
|
|||||||
|
|
||||||
void Camera::UpdateProjectionMatrix()
|
void Camera::UpdateProjectionMatrix()
|
||||||
{
|
{
|
||||||
// m_ProjectionMatrix = glm::ortho(
|
|
||||||
// -16.f,
|
|
||||||
// 16.f,
|
|
||||||
// -9.f,
|
|
||||||
// 9.f,
|
|
||||||
// m_NearClip,
|
|
||||||
// m_FarClip
|
|
||||||
// );
|
|
||||||
|
|
||||||
m_ProjectionMatrix = glm::perspective(m_FOV, m_AspectRatio, m_NearClip, m_FarClip);
|
m_ProjectionMatrix = glm::perspective(m_FOV, m_AspectRatio, m_NearClip, m_FarClip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ void DrawFinalPass::InitializeShaderPrograms()
|
|||||||
m_ForwardPlusProgram->Link();
|
m_ForwardPlusProgram->Link();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawFinalPass::Draw(RenderQueueCollection& rq)
|
void DrawFinalPass::Draw(RenderScene& scene)
|
||||||
{
|
{
|
||||||
GLERROR("DrawFinalPass::Draw: Pre");
|
GLERROR("DrawFinalPass::Draw: Pre");
|
||||||
|
|
||||||
@@ -38,11 +38,11 @@ void DrawFinalPass::Draw(RenderQueueCollection& rq)
|
|||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_Renderer->Camera()->ProjectionMatrix()));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_Renderer->Camera()->ProjectionMatrix()));
|
||||||
|
|
||||||
//TODO: Render: Add code for more jobs than modeljobs.
|
//TODO: Render: Add code for more jobs than modeljobs.
|
||||||
for (auto &job : rq.Forward) {
|
for (auto &job : scene.ForwardJobs) {
|
||||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
if(modelJob) {
|
if(modelJob) {
|
||||||
//TODO: Kolla upp "header/include/common" shader saken så man slipper skicka in asmycket uniforms
|
//TODO: Kolla upp "header/include/common" shader saken så man slipper skicka in asmycket uniforms
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->ModelMatrix));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||||
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(modelJob->Color));
|
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(modelJob->Color));
|
||||||
|
|
||||||
if(modelJob->DiffuseTexture != nullptr) {
|
if(modelJob->DiffuseTexture != nullptr) {
|
||||||
|
|||||||
@@ -22,25 +22,23 @@ void DrawScenePass::InitializeShaderPrograms()
|
|||||||
m_BasicForwardProgram->Link();
|
m_BasicForwardProgram->Link();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawScenePass::Draw(RenderQueueCollection& rq)
|
void DrawScenePass::Draw(RenderScene& scene)
|
||||||
{
|
{
|
||||||
//glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
//glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
GLERROR("DrawScenePass::Draw: Pre");
|
GLERROR("DrawScenePass::Draw: Pre");
|
||||||
|
|
||||||
DrawScenePassState state;
|
DrawScenePassState state = DrawScenePassState();
|
||||||
m_BasicForwardProgram->Bind();
|
m_BasicForwardProgram->Bind();
|
||||||
|
|
||||||
|
for (auto &job : scene.ForwardJobs) {
|
||||||
//TODO: Render: Add code for more jobs than modeljobs.
|
|
||||||
for (auto &job : rq.Forward) {
|
|
||||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
if (modelJob) {
|
if (modelJob) {
|
||||||
GLuint ShaderHandle = m_BasicForwardProgram->GetHandle();
|
GLuint ShaderHandle = m_BasicForwardProgram->GetHandle();
|
||||||
|
|
||||||
//TODO: Kolla upp "header/include/common" shader saken så man slipper skicka in asmycket uniforms
|
//TODO: Kolla upp "header/include/common" shader saken så man slipper skicka in asmycket uniforms
|
||||||
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->ModelMatrix));
|
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||||
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_Renderer->Camera()->ViewMatrix()));
|
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_Renderer->Camera()->ProjectionMatrix()));
|
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
glUniform4fv(glGetUniformLocation(ShaderHandle, "Color"), 1, glm::value_ptr(modelJob->Color));
|
glUniform4fv(glGetUniformLocation(ShaderHandle, "Color"), 1, glm::value_ptr(modelJob->Color));
|
||||||
|
|
||||||
//TODO: Renderer: bättre textur felhantering samt fler texturer stöd
|
//TODO: Renderer: bättre textur felhantering samt fler texturer stöd
|
||||||
@@ -56,12 +54,7 @@ void DrawScenePass::Draw(RenderQueueCollection& rq)
|
|||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, 0, modelJob->StartIndex);
|
glDrawElementsBaseVertex(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, 0, modelJob->StartIndex);
|
||||||
|
|
||||||
continue;
|
//continue;
|
||||||
}
|
|
||||||
auto spriteJob = std::dynamic_pointer_cast<SpriteJob>(job);
|
|
||||||
if(spriteJob)
|
|
||||||
{
|
|
||||||
//Hello im a sprite, please draw me.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,10 @@ DrawScenePassState::DrawScenePassState()
|
|||||||
GLERROR("---");
|
GLERROR("---");
|
||||||
Enable(GL_DEPTH_TEST);
|
Enable(GL_DEPTH_TEST);
|
||||||
Enable(GL_CULL_FACE);
|
Enable(GL_CULL_FACE);
|
||||||
ClearColor(glm::vec4(255.f / 255, 163.f / 255, 176.f / 255, 0.f));
|
Enable(GL_BLEND);
|
||||||
Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
// ClearColor(glm::vec4(255.f / 255, 163.f / 255, 176.f / 255, 0.f));
|
||||||
|
// Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawScenePassState::~DrawScenePassState()
|
DrawScenePassState::~DrawScenePassState()
|
||||||
|
|||||||
@@ -39,17 +39,10 @@ void DummyRenderer::Initialize()
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create default camera
|
|
||||||
m_DefaultCamera = new ::Camera((float)m_Resolution.Width / m_Resolution.Height, glm::radians(45.f), 0.01f, 5000.f);
|
|
||||||
m_DefaultCamera->SetPosition(glm::vec3(0, 0, 0));
|
|
||||||
if (m_Camera == nullptr) {
|
|
||||||
m_Camera = m_DefaultCamera;
|
|
||||||
}
|
|
||||||
|
|
||||||
glfwSwapInterval(m_VSYNC);
|
glfwSwapInterval(m_VSYNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DummyRenderer::Draw(RenderQueueCollection& rq)
|
void DummyRenderer::Draw(RenderFrame& rq)
|
||||||
{
|
{
|
||||||
glClearColor(255.f / 255, 163.f / 255, 176.f / 255, 0.f);
|
glClearColor(255.f / 255, 163.f / 255, 176.f / 255, 0.f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ LightCullingPass::LightCullingPass(IRenderer* renderer)
|
|||||||
m_Renderer = renderer;
|
m_Renderer = renderer;
|
||||||
InitializeSSBOs();
|
InitializeSSBOs();
|
||||||
InitializeShaderPrograms();
|
InitializeShaderPrograms();
|
||||||
GenerateNewFrustum();
|
//GenerateNewFrustum(TODO);
|
||||||
}
|
}
|
||||||
|
|
||||||
LightCullingPass::~LightCullingPass()
|
LightCullingPass::~LightCullingPass()
|
||||||
@@ -13,21 +13,24 @@ LightCullingPass::~LightCullingPass()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightCullingPass::GenerateNewFrustum()
|
void LightCullingPass::GenerateNewFrustum(RenderScene& scene)
|
||||||
{
|
{
|
||||||
|
if (scene.PointLightJobs.size() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
GLERROR("CalculateFrustum Error: Pre");
|
GLERROR("CalculateFrustum Error: Pre");
|
||||||
|
|
||||||
m_CalculateFrustumProgram->Bind();
|
m_CalculateFrustumProgram->Bind();
|
||||||
|
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, m_FrustumSSBO);
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, m_FrustumSSBO);
|
||||||
glUniformMatrix4fv(glGetUniformLocation(m_CalculateFrustumProgram->GetHandle(), "P"), 1, false, glm::value_ptr(m_Renderer->Camera()->ProjectionMatrix()));
|
glUniformMatrix4fv(glGetUniformLocation(m_CalculateFrustumProgram->GetHandle(), "P"), 1, false, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
glUniform2f(glGetUniformLocation(m_CalculateFrustumProgram->GetHandle(), "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height);
|
glUniform2f(glGetUniformLocation(m_CalculateFrustumProgram->GetHandle(), "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height);
|
||||||
glDispatchCompute(5, 3, 1); //TODO: Renderer: This needs change so resolution will be right.
|
glDispatchCompute(5, 3, 1); //TODO: Renderer: This needs change so resolution will be right.
|
||||||
|
|
||||||
GLERROR("CalculateFrustum Error: End");
|
GLERROR("CalculateFrustum Error: End");
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightCullingPass::CullLights()
|
void LightCullingPass::CullLights(RenderScene& scene)
|
||||||
{
|
{
|
||||||
GLERROR("CullLights Error: Pre");
|
GLERROR("CullLights Error: Pre");
|
||||||
m_LightOffset = 0;
|
m_LightOffset = 0;
|
||||||
@@ -45,7 +48,7 @@ void LightCullingPass::CullLights()
|
|||||||
glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
|
glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);
|
||||||
|
|
||||||
m_LightCullProgram->Bind();
|
m_LightCullProgram->Bind();
|
||||||
glUniformMatrix4fv(glGetUniformLocation(m_LightCullProgram->GetHandle(), "V"), 1, false, glm::value_ptr(m_Renderer->Camera()->ViewMatrix()));
|
glUniformMatrix4fv(glGetUniformLocation(m_LightCullProgram->GetHandle(), "V"), 1, false, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, m_FrustumSSBO);
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, m_FrustumSSBO);
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightSSBO);
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightSSBO);
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightGridSSBO);
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightGridSSBO);
|
||||||
@@ -56,10 +59,11 @@ void LightCullingPass::CullLights()
|
|||||||
GLERROR("CullLights Error: End");
|
GLERROR("CullLights Error: End");
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightCullingPass::FillLightList(RenderQueueCollection& rq)
|
void LightCullingPass::FillLightList(RenderScene& scene)
|
||||||
{
|
{
|
||||||
m_PointLights.clear();
|
m_PointLights.clear();
|
||||||
for(auto &job : rq.Lights) {
|
|
||||||
|
for(auto &job : scene.PointLightJobs) {
|
||||||
auto pointLightjob = std::dynamic_pointer_cast<PointLightJob>(job);
|
auto pointLightjob = std::dynamic_pointer_cast<PointLightJob>(job);
|
||||||
if (pointLightjob) {
|
if (pointLightjob) {
|
||||||
PointLight p;
|
PointLight p;
|
||||||
|
|||||||
@@ -43,70 +43,109 @@ void PickingPass::InitializeShaderPrograms()
|
|||||||
m_PickingProgram->Link();
|
m_PickingProgram->Link();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PickingPass::Draw(RenderQueueCollection& rq)
|
void PickingPass::Draw(RenderScene& scene)
|
||||||
{
|
{
|
||||||
m_PickingColorsToEntity.clear();
|
|
||||||
PickingPassState* state = new PickingPassState(m_PickingBuffer.GetHandle());
|
PickingPassState* state = new PickingPassState(m_PickingBuffer.GetHandle());
|
||||||
|
|
||||||
int r = 0;
|
|
||||||
int g = 0;
|
|
||||||
//TODO: Render: Add code for more jobs than modeljobs.
|
//TODO: Render: Add code for more jobs than modeljobs.
|
||||||
|
|
||||||
GLuint ShaderHandle = m_PickingProgram->GetHandle();
|
GLuint ShaderHandle = m_PickingProgram->GetHandle();
|
||||||
m_PickingProgram->Bind();
|
m_PickingProgram->Bind();
|
||||||
|
|
||||||
std::map<EntityID, glm::vec2> entityColors;
|
|
||||||
|
|
||||||
for (auto &job : rq.Forward) {
|
|
||||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
|
||||||
|
|
||||||
if (modelJob) {
|
m_Camera = scene.Camera;
|
||||||
int pickColor[2] = { r, g };
|
|
||||||
auto color = entityColors.find(modelJob->Entity);
|
for (auto &job : scene.ForwardJobs) {
|
||||||
if (color != entityColors.end()) {
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
pickColor[0] = color->second[0];
|
|
||||||
pickColor[1] = color->second[1];
|
if (modelJob) {
|
||||||
} else {
|
int pickColor[2] = { m_ColorCounter[0], m_ColorCounter[1] };
|
||||||
entityColors[modelJob->Entity] = glm::vec2(pickColor[0], pickColor[1]);
|
|
||||||
if (r + 1 > 255) {
|
PickingInfo pickInfo;
|
||||||
r = 0;
|
pickInfo.Entity = modelJob->Entity;
|
||||||
g += 1;
|
pickInfo.World = modelJob->World;
|
||||||
|
pickInfo.Camera = scene.Camera;
|
||||||
|
|
||||||
|
auto color = m_EntityColors.find(std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera));
|
||||||
|
if (color != m_EntityColors.end()) {
|
||||||
|
pickColor[0] = color->second[0];
|
||||||
|
pickColor[1] = color->second[1];
|
||||||
} else {
|
} else {
|
||||||
r += 1;
|
m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]);
|
||||||
|
if (m_ColorCounter[0] > 255) {
|
||||||
|
m_ColorCounter[0] = 0;
|
||||||
|
m_ColorCounter[1]++;;
|
||||||
|
} else {
|
||||||
|
m_ColorCounter[0]++;;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_PickingColorsToEntity[glm::ivec2(pickColor[0], pickColor[1])] = pickInfo;
|
||||||
|
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2fv(glGetUniformLocation(ShaderHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
||||||
|
|
||||||
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
|
glDrawElementsBaseVertex(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, nullptr, modelJob->StartIndex);
|
||||||
}
|
}
|
||||||
m_PickingColorsToEntity[glm::vec2(pickColor[0], pickColor[1])] = modelJob->Entity;
|
|
||||||
|
|
||||||
//Render picking stuff
|
|
||||||
//TODO: Kolla upp "header/include/common" shader saken så man slipper skicka in asmycket uniforms
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->ModelMatrix));
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_Renderer->Camera()->ViewMatrix()));
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_Renderer->Camera()->ProjectionMatrix()));
|
|
||||||
glUniform2fv(glGetUniformLocation(ShaderHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
|
||||||
|
|
||||||
glBindVertexArray(modelJob->Model->VAO);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, nullptr, modelJob->StartIndex);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
m_PickingBuffer.Unbind();
|
m_PickingBuffer.Unbind();
|
||||||
GLERROR("PickingPass Error");
|
GLERROR("PickingPass Error");
|
||||||
|
|
||||||
//Publish pick event every frame with the pick data that can be picked by the event
|
|
||||||
|
delete state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void PickingPass::ClearPicking()
|
||||||
|
{
|
||||||
|
m_PickingColorsToEntity.clear();
|
||||||
|
m_EntityColors.clear();
|
||||||
|
m_ColorCounter[0] = 0;
|
||||||
|
m_ColorCounter[1] = 0;
|
||||||
|
|
||||||
|
m_PickingBuffer.Bind();
|
||||||
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
m_PickingBuffer.Unbind();
|
||||||
|
}
|
||||||
|
|
||||||
|
PickData PickingPass::Pick(glm::vec2 screenCoord)
|
||||||
|
{
|
||||||
int fbWidth;
|
int fbWidth;
|
||||||
int fbHeight;
|
int fbHeight;
|
||||||
glfwGetFramebufferSize(m_Renderer->Window(), &fbWidth, &fbHeight);
|
glfwGetFramebufferSize(m_Renderer->Window(), &fbWidth, &fbHeight);
|
||||||
Events::Picking pickEvent = Events::Picking(
|
|
||||||
&m_PickingBuffer,
|
|
||||||
&m_DepthBuffer,
|
|
||||||
m_Renderer->Camera()->ProjectionMatrix(),
|
|
||||||
m_Renderer->Camera()->ViewMatrix(),
|
|
||||||
Rectangle(fbWidth, fbHeight),
|
|
||||||
&m_PickingColorsToEntity);
|
|
||||||
|
|
||||||
m_EventBroker->Publish(pickEvent);
|
Rectangle resolution = Rectangle(fbWidth, fbHeight);
|
||||||
|
PickData pickData;
|
||||||
|
// Invert screen y coordinate
|
||||||
|
screenCoord.y = resolution.Height - screenCoord.y;
|
||||||
|
ScreenCoords::PixelData data = ScreenCoords::ToPixelData(screenCoord, &m_PickingBuffer, m_DepthBuffer);
|
||||||
|
pickData.Depth = data.Depth;
|
||||||
|
|
||||||
delete state;
|
PickingInfo pickInfo;
|
||||||
|
|
||||||
|
auto it = m_PickingColorsToEntity.find(glm::ivec2(data.Color[0], data.Color[1]));
|
||||||
|
if (it != m_PickingColorsToEntity.end()) {
|
||||||
|
pickInfo = it->second;
|
||||||
|
} else {
|
||||||
|
pickData.Entity = EntityID_Invalid;
|
||||||
|
}
|
||||||
|
pickData.Position = ScreenCoords::ToWorldPos(screenCoord.x, screenCoord.y, data.Depth, resolution, pickInfo.Camera->ProjectionMatrix(), pickInfo.Camera->ViewMatrix());
|
||||||
|
|
||||||
|
|
||||||
|
pickData.Entity = pickInfo.Entity;
|
||||||
|
pickData.Camera = pickInfo.Camera;
|
||||||
|
pickData.World = pickInfo.World;
|
||||||
|
return pickData;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PickingPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
|
void PickingPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ PickingPassState::PickingPassState(GLuint frameBuffer)
|
|||||||
Enable(GL_CULL_FACE);
|
Enable(GL_CULL_FACE);
|
||||||
|
|
||||||
glm::vec4 clearColor = glm::vec4(0.f);
|
glm::vec4 clearColor = glm::vec4(0.f);
|
||||||
ClearColor(clearColor);
|
//ClearColor(clearColor);
|
||||||
Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
//Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
PickingPassState::~PickingPassState()
|
PickingPassState::~PickingPassState()
|
||||||
|
|||||||
@@ -81,6 +81,9 @@ RawModel::RawModel(std::string fileName)
|
|||||||
float opacity;
|
float opacity;
|
||||||
material->Get(AI_MATKEY_OPACITY, opacity);
|
material->Get(AI_MATKEY_OPACITY, opacity);
|
||||||
desc.DiffuseVertexColor = glm::vec4(diffuse.r, diffuse.g, diffuse.b, opacity);
|
desc.DiffuseVertexColor = glm::vec4(diffuse.r, diffuse.g, diffuse.b, opacity);
|
||||||
|
|
||||||
|
desc.DiffuseVertexColor = glm::vec4(diffuse.r, diffuse.g, diffuse.b, opacity);
|
||||||
|
|
||||||
// Material specular color
|
// Material specular color
|
||||||
aiColor3D specular;
|
aiColor3D specular;
|
||||||
material->Get(AI_MATKEY_COLOR_SPECULAR, specular);
|
material->Get(AI_MATKEY_COLOR_SPECULAR, specular);
|
||||||
@@ -134,6 +137,7 @@ RawModel::RawModel(std::string fileName)
|
|||||||
matGroup.EndIndex = m_Indices.size() - 1;
|
matGroup.EndIndex = m_Indices.size() - 1;
|
||||||
// Material shininess
|
// Material shininess
|
||||||
material->Get(AI_MATKEY_SHININESS, matGroup.Shininess);
|
material->Get(AI_MATKEY_SHININESS, matGroup.Shininess);
|
||||||
|
material->Get(AI_MATKEY_OPACITY, matGroup.Transparency);
|
||||||
//LOG_DEBUG("Shininess: %f", matGroup.Shininess);
|
//LOG_DEBUG("Shininess: %f", matGroup.Shininess);
|
||||||
// Diffuse texture
|
// Diffuse texture
|
||||||
//LOG_DEBUG("%i diffuse textures found", material->GetTextureCount(aiTextureType_DIFFUSE));
|
//LOG_DEBUG("%i diffuse textures found", material->GetTextureCount(aiTextureType_DIFFUSE));
|
||||||
|
|||||||
@@ -1,150 +0,0 @@
|
|||||||
#include "Rendering/RenderQueueFactory.h"
|
|
||||||
|
|
||||||
|
|
||||||
RenderQueueFactory::RenderQueueFactory()
|
|
||||||
{
|
|
||||||
m_RenderQueues = RenderQueueCollection();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderQueueFactory::Update(World* world)
|
|
||||||
{
|
|
||||||
m_RenderQueues.Clear();
|
|
||||||
FillModels(world, &m_RenderQueues.Forward);
|
|
||||||
FillLights(world, &m_RenderQueues.Lights);
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::mat4 RenderQueueFactory::ModelMatrix(World* world, EntityID entity)
|
|
||||||
{
|
|
||||||
glm::vec3 position = AbsolutePosition(world, entity);
|
|
||||||
glm::quat orientation = AbsoluteOrientation(world, entity);
|
|
||||||
glm::vec3 scale = AbsoluteScale(world, entity);
|
|
||||||
|
|
||||||
glm::mat4 modelMatrix = glm::translate(glm::mat4(), position) * glm::toMat4(orientation) * glm::scale(scale);
|
|
||||||
return modelMatrix;
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec3 RenderQueueFactory::AbsolutePosition(World* world, EntityID entity)
|
|
||||||
{
|
|
||||||
glm::vec3 position;
|
|
||||||
|
|
||||||
while (entity != EntityID_Invalid) {
|
|
||||||
ComponentWrapper transform = world->GetComponent(entity, "Transform");
|
|
||||||
EntityID parent = world->GetParent(entity);
|
|
||||||
//if (parent != EntityID_Invalid) {
|
|
||||||
position += AbsoluteOrientation(world, parent) * (glm::vec3)transform["Position"];
|
|
||||||
//} else {
|
|
||||||
// position += (glm::vec3)transform["Position"];
|
|
||||||
//}
|
|
||||||
entity = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::quat RenderQueueFactory::AbsoluteOrientation(World* world, EntityID entity)
|
|
||||||
{
|
|
||||||
glm::quat orientation;
|
|
||||||
|
|
||||||
while (entity != EntityID_Invalid) {
|
|
||||||
ComponentWrapper transform = world->GetComponent(entity, "Transform");
|
|
||||||
orientation = glm::quat((glm::vec3)transform["Orientation"]) * orientation;
|
|
||||||
entity = world->GetParent(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
return orientation;
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec3 RenderQueueFactory::AbsoluteScale(World* world, EntityID entity)
|
|
||||||
{
|
|
||||||
glm::vec3 scale(1.f);
|
|
||||||
|
|
||||||
while (entity != EntityID_Invalid) {
|
|
||||||
ComponentWrapper transform = world->GetComponent(entity, "Transform");
|
|
||||||
scale *= (glm::vec3)transform["Scale"];
|
|
||||||
entity = world->GetParent(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
return scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderQueueFactory::FillModels(World* world, RenderQueue* renderQueue)
|
|
||||||
{
|
|
||||||
auto models = world->GetComponents("Model");
|
|
||||||
if (models == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto& modelC : *models) {
|
|
||||||
bool visible = modelC["Visible"];
|
|
||||||
if (!visible) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
std::string resource = modelC["Resource"];
|
|
||||||
if (resource.empty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
glm::vec4 color = modelC["Color"];
|
|
||||||
Model* model = ResourceManager::Load<Model>(resource);
|
|
||||||
if (model == nullptr) {
|
|
||||||
model = ResourceManager::Load<Model>("Models/Core/Error.obj");
|
|
||||||
}
|
|
||||||
|
|
||||||
auto transformC = world->GetComponent(modelC.EntityID, "Transform");
|
|
||||||
if(&transformC == nullptr)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto texGroup : model->TextureGroups) {
|
|
||||||
ModelJob job;
|
|
||||||
job.TextureID = (texGroup.Texture) ? texGroup.Texture->ResourceID : 0;
|
|
||||||
job.DiffuseTexture = texGroup.Texture.get();
|
|
||||||
job.NormalTexture = texGroup.NormalMap.get();
|
|
||||||
job.SpecularTexture = texGroup.SpecularMap.get();
|
|
||||||
job.Model = model;
|
|
||||||
job.StartIndex = texGroup.StartIndex;
|
|
||||||
job.EndIndex = texGroup.EndIndex;
|
|
||||||
job.ModelMatrix = model->m_Matrix * ModelMatrix(world, modelC.EntityID);
|
|
||||||
job.Color = color;
|
|
||||||
|
|
||||||
//TODO: RENDERER: Not sure if the best solution for pickingColor to entity link is this
|
|
||||||
job.Entity = modelC.EntityID;
|
|
||||||
|
|
||||||
renderQueue->Add(job);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderQueueFactory::FillLights(World* world, RenderQueue* renderQueue)
|
|
||||||
{
|
|
||||||
auto pointLights = world->GetComponents("PointLight");
|
|
||||||
if(pointLights == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(auto& pointlightC : *pointLights) {
|
|
||||||
bool visible = pointlightC["Visible"];
|
|
||||||
if(!visible) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
auto transformC = world->GetComponent(pointlightC.EntityID, "Transform");
|
|
||||||
if(&transformC == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec4 color = pointlightC["Color"];
|
|
||||||
float radius = (double)pointlightC["Radius"];
|
|
||||||
float intensity = (double)pointlightC["Intensity"];
|
|
||||||
float falloff = (double)pointlightC["Falloff"];
|
|
||||||
|
|
||||||
PointLightJob job;
|
|
||||||
job.Position = glm::vec4(AbsolutePosition(world, transformC.EntityID), 1.f);
|
|
||||||
job.Color = color;
|
|
||||||
job.Radius = radius;
|
|
||||||
job.Intensity = intensity;
|
|
||||||
job.Falloff = falloff;
|
|
||||||
|
|
||||||
renderQueue->Add(job);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -0,0 +1,218 @@
|
|||||||
|
#include "Rendering/RenderSystem.h"
|
||||||
|
#include "Rendering/DebugCameraInputController.h"
|
||||||
|
|
||||||
|
RenderSystem::RenderSystem(EventBroker* eventBrokerer, const IRenderer* renderer, RenderFrame* renderFrame) :ImpureSystem(eventBrokerer)
|
||||||
|
{
|
||||||
|
m_Renderer = renderer;
|
||||||
|
m_RenderFrame = renderFrame;
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &RenderSystem::OnSetCamera);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &RenderSystem::OnInputCommand);
|
||||||
|
|
||||||
|
m_DefaultCamera = new Camera((float)m_Renderer->Resolution().Width / m_Renderer->Resolution().Height, glm::radians(45.f), 0.01f, 5000.f);
|
||||||
|
m_DefaultCamera->SetPosition(glm::vec3(0, 0, 10));
|
||||||
|
if (m_Camera == nullptr) {
|
||||||
|
m_Camera = m_DefaultCamera;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RenderSystem::OnSetCamera(const Events::SetCamera &event)
|
||||||
|
{
|
||||||
|
auto cameras = m_World->GetComponents("Camera");
|
||||||
|
|
||||||
|
if (cameras != nullptr) {
|
||||||
|
for (auto it = cameras->begin(); it != cameras->end(); it++) {
|
||||||
|
if ((std::string)(*it)["Name"] == event.Name) {
|
||||||
|
switchCamera((*it).EntityID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderSystem::switchCamera(EntityID entity)
|
||||||
|
{
|
||||||
|
if(m_World->HasComponent(entity, "Camera")) {
|
||||||
|
|
||||||
|
if (m_CurrentCamera != EntityID_Invalid) {
|
||||||
|
if (m_World->HasComponent(m_CurrentCamera, "Model")) {
|
||||||
|
m_World->GetComponent(m_CurrentCamera, "Model")["Visible"] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_World->HasComponent(entity, "Model")) {
|
||||||
|
m_World->GetComponent(entity, "Model")["Visible"] = false;
|
||||||
|
}
|
||||||
|
m_CurrentCamera = entity;
|
||||||
|
m_SwitchCamera = false;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
LOG_ERROR("Entity %i does not have a CameraComponent", entity);
|
||||||
|
m_SwitchCamera = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderSystem::updateProjectionMatrix(ComponentWrapper& cameraComponent)
|
||||||
|
{
|
||||||
|
double fov = cameraComponent["FOV"];
|
||||||
|
double aspectRatio = m_Renderer->Resolution().Width / m_Renderer->Resolution().Height;
|
||||||
|
double nearClip = cameraComponent["NearClip"];
|
||||||
|
double farClip = cameraComponent["FarClip"];
|
||||||
|
|
||||||
|
double fovY = atan(tan(glm::radians(fov)/2.0) * aspectRatio) * 2.0;
|
||||||
|
m_ProjectionMatrix = glm::perspective(fovY, aspectRatio, nearClip, farClip);
|
||||||
|
|
||||||
|
m_Camera->SetFOV(fovY);
|
||||||
|
m_Camera->SetAspectRatio(aspectRatio);
|
||||||
|
m_Camera->SetNearClip(nearClip);
|
||||||
|
m_Camera->SetFarClip(farClip);
|
||||||
|
m_Camera->UpdateProjectionMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& jobs, World* world)
|
||||||
|
{
|
||||||
|
auto models = world->GetComponents("Model");
|
||||||
|
if (models == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& modelComponent : *models) {
|
||||||
|
bool visible = modelComponent["Visible"];
|
||||||
|
if (!visible) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
std::string resource = modelComponent["Resource"];
|
||||||
|
if (resource.empty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Model* model = ResourceManager::Load<::Model>(resource);
|
||||||
|
if (model == nullptr) {
|
||||||
|
model = ResourceManager::Load<::Model>("Models/Core/Error.obj");
|
||||||
|
}
|
||||||
|
|
||||||
|
glm::mat4 modelMatrix = Transform::ModelMatrix(modelComponent.EntityID, world);
|
||||||
|
|
||||||
|
for (auto texGroup : model->TextureGroups) {
|
||||||
|
std::shared_ptr<ModelJob> modelJob = std::shared_ptr<ModelJob>(new ModelJob(model, m_Camera, modelMatrix, texGroup, modelComponent, world));
|
||||||
|
jobs.push_back(modelJob);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RenderSystem::fillLight(std::list<std::shared_ptr<RenderJob>>& jobs, World* world)
|
||||||
|
{
|
||||||
|
auto pointLights = world->GetComponents("PointLight");
|
||||||
|
if (pointLights == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& pointlightC : *pointLights) {
|
||||||
|
bool visible = pointlightC["Visible"];
|
||||||
|
if (!visible) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
auto transformC = world->GetComponent(pointlightC.EntityID, "Transform");
|
||||||
|
if (&transformC == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<PointLightJob> pointLightJob = std::shared_ptr<PointLightJob>(new PointLightJob(transformC, pointlightC));
|
||||||
|
jobs.push_back(pointLightJob);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RenderSystem::OnInputCommand(const Events::InputCommand& e)
|
||||||
|
{
|
||||||
|
if (e.Command == "SwitchCamera" && e.Value > 0) {
|
||||||
|
m_SwitchCamera = true;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderSystem::Update(World* world, double dt)
|
||||||
|
{
|
||||||
|
m_World = world;
|
||||||
|
m_EventBroker->Process<RenderSystem>();
|
||||||
|
|
||||||
|
updateCamera(world, dt);
|
||||||
|
|
||||||
|
//Only supports opaque geometry atm
|
||||||
|
m_RenderFrame->Clear();
|
||||||
|
|
||||||
|
RenderScene scene;
|
||||||
|
scene.Camera = m_Camera;
|
||||||
|
scene.Viewport = Rectangle(1280, 720);
|
||||||
|
fillModels(scene.ForwardJobs, world);
|
||||||
|
fillLight(scene.PointLightJobs, world);
|
||||||
|
m_RenderFrame->Add(scene);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderSystem::updateCamera(World* world, double dt)
|
||||||
|
{
|
||||||
|
|
||||||
|
static DebugCameraInputController<RenderSystem> firstPersonInputController(m_EventBroker, -1);
|
||||||
|
|
||||||
|
if (m_SwitchCamera) {
|
||||||
|
auto cameras = world->GetComponents("Camera");
|
||||||
|
for (auto it = cameras->begin(); it != cameras->end(); it++) {
|
||||||
|
if ((*it).EntityID == m_CurrentCamera) {
|
||||||
|
it++;
|
||||||
|
if (it != cameras->end()) {
|
||||||
|
switchCamera((*it).EntityID);
|
||||||
|
} else {
|
||||||
|
switchCamera((*cameras->begin()).EntityID);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ComponentWrapper& cameraComponent = world->GetComponent(m_CurrentCamera, "Camera");
|
||||||
|
ComponentWrapper& cameraTransform = world->GetComponent(m_CurrentCamera, "Transform");
|
||||||
|
|
||||||
|
firstPersonInputController.SetOrientation(glm::quat((glm::vec3)cameraTransform["Orientation"]));
|
||||||
|
firstPersonInputController.SetPosition(cameraTransform["Position"]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_World->ValidEntity(m_CurrentCamera)) {
|
||||||
|
if (world->HasComponent(m_CurrentCamera, "Camera") && world->HasComponent(m_CurrentCamera, "Transform")) {
|
||||||
|
ComponentWrapper& cameraComponent = world->GetComponent(m_CurrentCamera, "Camera");
|
||||||
|
ComponentWrapper& cameraTransform = world->GetComponent(m_CurrentCamera, "Transform");
|
||||||
|
|
||||||
|
firstPersonInputController.Update(dt);
|
||||||
|
(glm::vec3&)cameraTransform["Orientation"] = glm::eulerAngles(firstPersonInputController.Orientation());
|
||||||
|
(glm::vec3&)cameraTransform["Position"] = firstPersonInputController.Position();
|
||||||
|
|
||||||
|
glm::vec3 position = Transform::AbsolutePosition(world, m_CurrentCamera);
|
||||||
|
glm::quat orientation = Transform::AbsoluteOrientation(world, m_CurrentCamera);
|
||||||
|
|
||||||
|
m_Camera->SetPosition(position);
|
||||||
|
m_Camera->SetOrientation(orientation);
|
||||||
|
|
||||||
|
updateProjectionMatrix(cameraComponent);
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m_Camera = m_DefaultCamera;
|
||||||
|
|
||||||
|
auto cameras = world->GetComponents("Camera");
|
||||||
|
if (cameras != nullptr) {
|
||||||
|
if (cameras->begin() != cameras->end()) {
|
||||||
|
ComponentWrapper& cameraC = *cameras->begin();
|
||||||
|
switchCamera(cameraC.EntityID);
|
||||||
|
|
||||||
|
ComponentWrapper& cameraComponent = world->GetComponent(m_CurrentCamera, "Camera");
|
||||||
|
ComponentWrapper& cameraTransform = world->GetComponent(m_CurrentCamera, "Transform");
|
||||||
|
|
||||||
|
firstPersonInputController.SetOrientation(glm::quat((glm::vec3)cameraTransform["Orientation"]));
|
||||||
|
firstPersonInputController.SetPosition(cameraTransform["Position"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Camera->UpdateViewMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
@@ -3,13 +3,7 @@
|
|||||||
void Renderer::Initialize()
|
void Renderer::Initialize()
|
||||||
{
|
{
|
||||||
InitializeWindow();
|
InitializeWindow();
|
||||||
// Create default camera
|
|
||||||
m_DefaultCamera = new ::Camera((float)m_Resolution.Width / m_Resolution.Height, glm::radians(90.0f), 0.01f, 5000.f);
|
|
||||||
m_DefaultCamera->SetPosition(glm::vec3(0, 1, 10));
|
|
||||||
if (m_Camera == nullptr) {
|
|
||||||
m_Camera = m_DefaultCamera;
|
|
||||||
}
|
|
||||||
m_DebugCameraInputController = std::make_shared<DebugCameraInputController<Renderer>>(m_EventBroker, -1);
|
|
||||||
InitializeRenderPasses();
|
InitializeRenderPasses();
|
||||||
|
|
||||||
glfwSwapInterval(m_VSYNC);
|
glfwSwapInterval(m_VSYNC);
|
||||||
@@ -21,6 +15,15 @@ void Renderer::Initialize()
|
|||||||
m_UnitSphere = ResourceManager::Load<Model>("Models/Core/UnitSphere.obj");
|
m_UnitSphere = ResourceManager::Load<Model>("Models/Core/UnitSphere.obj");
|
||||||
|
|
||||||
m_ImGuiRenderPass = new ImGuiRenderPass(this, m_EventBroker);
|
m_ImGuiRenderPass = new ImGuiRenderPass(this, m_EventBroker);
|
||||||
|
|
||||||
|
|
||||||
|
// Create default camera
|
||||||
|
m_DefaultCamera = new ::Camera((float)m_Resolution.Width / m_Resolution.Height, glm::radians(45.f), 0.01f, 5000.f);
|
||||||
|
m_DefaultCamera->SetPosition(glm::vec3(0, 0, 10));
|
||||||
|
if (m_Camera == nullptr) {
|
||||||
|
m_Camera = m_DefaultCamera;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::InitializeWindow()
|
void Renderer::InitializeWindow()
|
||||||
@@ -76,9 +79,7 @@ void Renderer::InitializeShaders()
|
|||||||
|
|
||||||
void Renderer::InputUpdate(double dt)
|
void Renderer::InputUpdate(double dt)
|
||||||
{
|
{
|
||||||
m_DebugCameraInputController->Update(dt);
|
|
||||||
m_Camera->SetOrientation(m_DebugCameraInputController->Orientation());
|
|
||||||
m_Camera->SetPosition(m_DebugCameraInputController->Position());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::Update(double dt)
|
void Renderer::Update(double dt)
|
||||||
@@ -88,22 +89,37 @@ void Renderer::Update(double dt)
|
|||||||
m_ImGuiRenderPass->Update(dt);
|
m_ImGuiRenderPass->Update(dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::Draw(RenderQueueCollection& rq)
|
void Renderer::Draw(RenderFrame& frame)
|
||||||
{
|
{
|
||||||
FillDepth(rq);
|
glClearColor(255.f / 255, 163.f / 255, 176.f / 255, 0.f);
|
||||||
m_PickingPass->Draw(rq);
|
|
||||||
//DrawScreenQuad(m_PickingPass->PickingTexture());
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
m_LightCullingPass->FillLightList(rq);
|
|
||||||
m_LightCullingPass->CullLights();
|
|
||||||
|
m_PickingPass->ClearPicking();
|
||||||
|
for (auto scene : frame.RenderScenes){
|
||||||
|
|
||||||
|
m_Camera = scene->Camera; // remove renderer camera when Editor uses the render scene cameras.
|
||||||
|
FillDepth(*scene);
|
||||||
|
m_PickingPass->Draw(*scene);
|
||||||
|
m_LightCullingPass->GenerateNewFrustum(*scene);
|
||||||
|
m_LightCullingPass->FillLightList(*scene);
|
||||||
|
m_LightCullingPass->CullLights(*scene);
|
||||||
|
m_DrawFinalPass->Draw(*scene);
|
||||||
|
//m_DrawScenePass->Draw(rq);
|
||||||
|
|
||||||
|
GLERROR("Renderer::Draw m_DrawScenePass->Draw");
|
||||||
|
}
|
||||||
|
|
||||||
//m_DrawScenePass->Draw(rq);
|
|
||||||
m_DrawFinalPass->Draw(rq);
|
|
||||||
glClearColor(255.f / 255, 163.f / 255, 176.f / 255, 1.f);
|
|
||||||
GLERROR("Renderer::Draw m_DrawScenePass->Draw");
|
|
||||||
m_ImGuiRenderPass->Draw();
|
m_ImGuiRenderPass->Draw();
|
||||||
glfwSwapBuffers(m_Window);
|
glfwSwapBuffers(m_Window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PickData Renderer::Pick(glm::vec2 screenCoord)
|
||||||
|
{
|
||||||
|
return m_PickingPass->Pick(screenCoord);
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::DrawScreenQuad(GLuint textureToDraw)
|
void Renderer::DrawScreenQuad(GLuint textureToDraw)
|
||||||
{
|
{
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
@@ -152,13 +168,18 @@ void Renderer::InitializeRenderPasses()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Temp func
|
//Temp func
|
||||||
void Renderer::FillDepth(RenderQueueCollection& rq)
|
void Renderer::FillDepth(RenderScene& scene)
|
||||||
{
|
{
|
||||||
for(auto job : rq.Forward) {
|
for (auto job : scene.ForwardJobs) {
|
||||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
glm::vec3 abspos = RenderQueueFactory::AbsolutePosition(m_World, modelJob->Entity);
|
if(! modelJob) {
|
||||||
glm::vec3 worldpos = glm::vec3(m_Camera->ViewMatrix() * glm::vec4(abspos, 1));
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
glm::vec3 abspos = Transform::AbsolutePosition(modelJob->World, modelJob->Entity);
|
||||||
|
glm::vec3 worldpos = glm::vec3(scene.Camera->ViewMatrix() * glm::vec4(abspos, 1));
|
||||||
modelJob->Depth = worldpos.z;
|
modelJob->Depth = worldpos.z;
|
||||||
}
|
}
|
||||||
rq.Forward.Jobs.sort(Renderer::DepthSort);
|
scene.ForwardJobs.sort(Renderer::DepthSort);
|
||||||
}
|
}
|
||||||
+11
-13
@@ -18,10 +18,9 @@ Game::Game(int argc, char* argv[])
|
|||||||
// Create the core event broker
|
// Create the core event broker
|
||||||
m_EventBroker = new EventBroker();
|
m_EventBroker = new EventBroker();
|
||||||
|
|
||||||
m_RenderQueueFactory = new RenderQueueFactory();
|
|
||||||
|
|
||||||
// Create the renderer
|
// Create the renderer
|
||||||
m_Renderer = new Renderer(m_EventBroker);
|
m_Renderer = new Renderer(m_EventBroker, m_World);
|
||||||
m_Renderer->SetFullscreen(m_Config->Get<bool>("Video.Fullscreen", false));
|
m_Renderer->SetFullscreen(m_Config->Get<bool>("Video.Fullscreen", false));
|
||||||
m_Renderer->SetVSYNC(m_Config->Get<bool>("Video.VSYNC", false));
|
m_Renderer->SetVSYNC(m_Config->Get<bool>("Video.VSYNC", false));
|
||||||
m_Renderer->SetResolution(Rectangle::Rectangle(
|
m_Renderer->SetResolution(Rectangle::Rectangle(
|
||||||
@@ -31,7 +30,7 @@ Game::Game(int argc, char* argv[])
|
|||||||
m_Config->Get<int>("Video.Height", 720)
|
m_Config->Get<int>("Video.Height", 720)
|
||||||
));
|
));
|
||||||
m_Renderer->Initialize();
|
m_Renderer->Initialize();
|
||||||
m_Renderer->Camera()->SetFOV(glm::radians(m_Config->Get<float>("Video.FOV", 90.f)));
|
//m_Renderer->Camera()->SetFOV(glm::radians(m_Config->Get<float>("Video.FOV", 90.f)));
|
||||||
|
|
||||||
// Create input manager
|
// Create input manager
|
||||||
m_InputManager = new InputManager(m_Renderer->Window(), m_EventBroker);
|
m_InputManager = new InputManager(m_Renderer->Window(), m_EventBroker);
|
||||||
@@ -58,9 +57,12 @@ Game::Game(int argc, char* argv[])
|
|||||||
//SO MUCH TEMP PLEASE REMOVE ME OMFG VIKTOR HELP
|
//SO MUCH TEMP PLEASE REMOVE ME OMFG VIKTOR HELP
|
||||||
m_Renderer->m_World = m_World;
|
m_Renderer->m_World = m_World;
|
||||||
|
|
||||||
|
m_RenderFrame = new RenderFrame();
|
||||||
|
|
||||||
// Create system pipeline
|
// Create system pipeline
|
||||||
m_SystemPipeline = new SystemPipeline(m_EventBroker);
|
m_SystemPipeline = new SystemPipeline(m_EventBroker);
|
||||||
|
|
||||||
|
|
||||||
//All systems with orderlevel 0 will be updated first.
|
//All systems with orderlevel 0 will be updated first.
|
||||||
unsigned int updateOrderLevel = 0;
|
unsigned int updateOrderLevel = 0;
|
||||||
m_SystemPipeline->AddSystem<RaptorCopterSystem>(updateOrderLevel);
|
m_SystemPipeline->AddSystem<RaptorCopterSystem>(updateOrderLevel);
|
||||||
@@ -73,6 +75,9 @@ Game::Game(int argc, char* argv[])
|
|||||||
m_SystemPipeline->AddSystem<CollisionSystem>(updateOrderLevel);
|
m_SystemPipeline->AddSystem<CollisionSystem>(updateOrderLevel);
|
||||||
m_SystemPipeline->AddSystem<TriggerSystem>(updateOrderLevel);
|
m_SystemPipeline->AddSystem<TriggerSystem>(updateOrderLevel);
|
||||||
|
|
||||||
|
++updateOrderLevel;
|
||||||
|
m_SystemPipeline->AddSystem<RenderSystem>(updateOrderLevel, m_Renderer, m_RenderFrame);
|
||||||
|
|
||||||
// Invoke network
|
// Invoke network
|
||||||
if (m_Config->Get<bool>("Networking.StartNetwork", false)) {
|
if (m_Config->Get<bool>("Networking.StartNetwork", false)) {
|
||||||
//boost::thread workerThread(&Game::networkFunction, this);
|
//boost::thread workerThread(&Game::networkFunction, this);
|
||||||
@@ -88,8 +93,8 @@ Game::~Game()
|
|||||||
delete m_FrameStack;
|
delete m_FrameStack;
|
||||||
delete m_InputProxy;
|
delete m_InputProxy;
|
||||||
delete m_InputManager;
|
delete m_InputManager;
|
||||||
|
delete m_RenderFrame;
|
||||||
delete m_Renderer;
|
delete m_Renderer;
|
||||||
delete m_RenderQueueFactory;
|
|
||||||
delete m_EventBroker;
|
delete m_EventBroker;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,15 +120,13 @@ void Game::Tick()
|
|||||||
if (m_IsClientOrServer) {
|
if (m_IsClientOrServer) {
|
||||||
m_ClientOrServer->Update();
|
m_ClientOrServer->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate through systems and update world!
|
// Iterate through systems and update world!
|
||||||
m_SystemPipeline->Update(m_World, dt);
|
m_SystemPipeline->Update(m_World, dt);
|
||||||
m_Renderer->Update(dt);
|
m_Renderer->Update(dt);
|
||||||
m_EventBroker->Process<Client>();
|
m_EventBroker->Process<Client>();
|
||||||
|
|
||||||
m_RenderQueueFactory->Update(m_World);
|
|
||||||
GLERROR("Game::Tick m_RenderQueueFactory->Update");
|
GLERROR("Game::Tick m_RenderQueueFactory->Update");
|
||||||
m_Renderer->Draw(m_RenderQueueFactory->RenderQueues());
|
m_Renderer->Draw(*m_RenderFrame);
|
||||||
GLERROR("Game::Tick m_Renderer->Draw");
|
GLERROR("Game::Tick m_Renderer->Draw");
|
||||||
m_EventBroker->Swap();
|
m_EventBroker->Swap();
|
||||||
m_EventBroker->Clear();
|
m_EventBroker->Clear();
|
||||||
@@ -146,10 +149,5 @@ void Game::networkFunction()
|
|||||||
m_ClientOrServer = new Server();
|
m_ClientOrServer = new Server();
|
||||||
}
|
}
|
||||||
m_ClientOrServer->Start(m_World, m_EventBroker);
|
m_ClientOrServer->Start(m_World, m_EventBroker);
|
||||||
// I don't think we are reaching this part of the code right now.
|
|
||||||
// ~Game() is not called if the game is exited by closing console windows
|
|
||||||
// When server or client is done set it to false.
|
|
||||||
//m_IsClientOrServer = false;
|
|
||||||
// Destroy it
|
|
||||||
//delete m_ClientOrServer;
|
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,6 @@
|
|||||||
#include "Core/ResourceManager.h"
|
#include "Core/ResourceManager.h"
|
||||||
#include "Core/ConfigFile.h"
|
#include "Core/ConfigFile.h"
|
||||||
#include "Rendering/Renderer.h"
|
#include "Rendering/Renderer.h"
|
||||||
#include "Core/EntityXMLFile.h"
|
|
||||||
#include "Engine\Rendering\Texture.h"
|
#include "Engine\Rendering\Texture.h"
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(resourceManagerTests)
|
BOOST_AUTO_TEST_SUITE(resourceManagerTests)
|
||||||
|
|||||||
Reference in New Issue
Block a user