Camera component and RenderQueue changes
This commit is contained in:
@@ -40,7 +40,7 @@ public:
|
||||
m_TexturePressed = resourceName;
|
||||
}
|
||||
|
||||
void Draw(RenderQueueCollection& rq) override
|
||||
void Draw(RenderScene& rq) override
|
||||
{
|
||||
if (m_Texture == nullptr && !m_TextureReleased.empty()) {
|
||||
SetTexture(m_TextureReleased);
|
||||
|
||||
@@ -212,7 +212,7 @@ public:
|
||||
|
||||
virtual void Update(double dt) { }
|
||||
|
||||
void DrawLayered(RenderQueueCollection& rq)
|
||||
void DrawLayered(RenderScene& rq)
|
||||
{
|
||||
if (this->Hidden())
|
||||
return;
|
||||
@@ -232,7 +232,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
virtual void Draw(RenderQueueCollection& rq) { }
|
||||
virtual void Draw(RenderScene& rq) { }
|
||||
|
||||
protected:
|
||||
::EventBroker* m_EventBroker;
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
void EnableScissor() { m_ScissorEnabled = true; }
|
||||
void DisableScissor() { m_ScissorEnabled = false; }
|
||||
|
||||
void Draw(RenderQueueCollection& rq) override
|
||||
void Draw(RenderScene& rq) override
|
||||
{
|
||||
if (m_Texture == nullptr)
|
||||
return;
|
||||
|
||||
@@ -26,11 +26,6 @@ public:
|
||||
glm::quat Orientation() const { return m_Orientation; }
|
||||
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 ViewMatrix() const { return m_ViewMatrix; }
|
||||
|
||||
@@ -46,11 +41,10 @@ public:
|
||||
float FarClip() const { return m_FarClip; }
|
||||
void SetFarClip(float val);
|
||||
|
||||
|
||||
void UpdateViewMatrix();
|
||||
void UpdateProjectionMatrix();
|
||||
|
||||
private:
|
||||
void UpdateViewMatrix();
|
||||
void UpdateProjectionMatrix();
|
||||
|
||||
glm::vec3 m_Position;
|
||||
glm::quat m_Orientation;
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
void InitializeFrameBuffers();
|
||||
void InitializeShaderPrograms();
|
||||
|
||||
void Draw(RenderQueueCollection& rq);
|
||||
void Draw(RenderFrame& rf);
|
||||
|
||||
//Getters
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class DummyRenderer : public IRenderer
|
||||
{
|
||||
public:
|
||||
virtual void Initialize() override;
|
||||
virtual void Draw(RenderQueueCollection& rq) override;
|
||||
virtual void Draw(RenderFrame& rq) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -3,16 +3,16 @@
|
||||
|
||||
#include "../Core/EventBroker.h"
|
||||
#include "../Core/Entity.h"
|
||||
#include <string.h>
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
/** Thrown Every frame, use functions to pick*/
|
||||
struct SetCamera : Event
|
||||
{
|
||||
public:
|
||||
SetCamera() { };
|
||||
EntityID Entity;
|
||||
std::string Name;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
}
|
||||
virtual void Initialize() = 0;
|
||||
virtual void Update(double dt) = 0;
|
||||
virtual void Draw(RenderQueueCollection& rq) = 0;
|
||||
virtual void Draw(RenderFrame& rq) = 0;
|
||||
|
||||
protected:
|
||||
Rectangle m_Resolution = Rectangle(1280, 720);
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
void InitializeFrameBuffers();
|
||||
void InitializeShaderPrograms();
|
||||
|
||||
void Draw(RenderQueueCollection& rq);
|
||||
void Draw(RenderFrame& rf);
|
||||
|
||||
|
||||
//Getters
|
||||
|
||||
@@ -39,9 +39,7 @@ 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 Matrix;
|
||||
const Texture* DiffuseTexture;
|
||||
const Texture* NormalTexture;
|
||||
@@ -165,7 +163,7 @@ private:
|
||||
int m_Size = 0;
|
||||
};
|
||||
|
||||
struct RenderQueueCollection
|
||||
struct RenderScene
|
||||
{
|
||||
RenderQueue Forward;
|
||||
RenderQueue Lights;
|
||||
@@ -184,4 +182,38 @@ struct RenderQueueCollection
|
||||
}
|
||||
};
|
||||
|
||||
class RenderFrame
|
||||
{
|
||||
public:
|
||||
|
||||
void Add(RenderScene &scene)
|
||||
{
|
||||
RenderScenes.push_back(std::shared_ptr<RenderScene>(new RenderScene(scene)));
|
||||
m_Size++;
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
RenderScenes.clear();
|
||||
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
|
||||
@@ -12,10 +12,11 @@
|
||||
#include "../Input/EInputCommand.h"
|
||||
#include "Camera.h"
|
||||
|
||||
|
||||
class RenderSystem : public ImpureSystem
|
||||
{
|
||||
public:
|
||||
RenderSystem(EventBroker* eventBrokerer, RenderQueueCollection* renderQueues);
|
||||
RenderSystem(EventBroker* eventBrokerer, RenderFrame* renderFrame);
|
||||
|
||||
virtual void Update(World* world, double dt) override;
|
||||
|
||||
@@ -26,9 +27,14 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
RenderQueueCollection* m_RenderQueues;
|
||||
World* m_World = 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);
|
||||
@@ -37,13 +43,12 @@ private:
|
||||
void SwitchCamera(EntityID entity);
|
||||
|
||||
void Initialize();
|
||||
void UpdateViewMatrix(ComponentWrapper& cameraTransform);
|
||||
void UpdateProjectionMatrix(ComponentWrapper& cameraComponent);
|
||||
glm::mat4 m_ViewMatrix;
|
||||
glm::mat4 m_ProjectionMatrix;
|
||||
|
||||
glm::mat4 ModelMatrix(World* world, EntityID entity);
|
||||
void FillModels(World* world, RenderQueue* renderQueue);
|
||||
glm::mat4 ModelMatrix(EntityID entity);
|
||||
void FillModels(RenderQueue* renderQueue);
|
||||
|
||||
EventRelay<RenderSystem, Events::InputCommand> m_EInputCommand;
|
||||
bool OnInputCommand(const Events::InputCommand& e);
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
|
||||
virtual void Initialize() override;
|
||||
virtual void Update(double dt) override;
|
||||
virtual void Draw(RenderQueueCollection& rq) override;
|
||||
virtual void Draw(RenderFrame& rf) override;
|
||||
|
||||
private:
|
||||
//----------------------Variables----------------------//
|
||||
|
||||
Reference in New Issue
Block a user