Added Transform.h that holds all the AbsoluteTransformation functions. Camera now working better with scenes. Changed Modeljob Matrix to only hold the model matrix instad of all matrix info

This commit is contained in:
viktorljung
2016-01-14 11:12:02 +01:00
parent 0f17f9a888
commit e7f02f14a0
16 changed files with 135 additions and 133 deletions
+62
View File
@@ -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
+1 -1
View File
@@ -9,7 +9,7 @@
#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/RenderSystem.h" #include "../Core/Transform.h"
#include "../Core/EFileDropped.h" #include "../Core/EFileDropped.h"
#include "../Core/EntityFilePreprocessor.h" #include "../Core/EntityFilePreprocessor.h"
#include "../Core/EntityFileParser.h" #include "../Core/EntityFileParser.h"
+1 -1
View File
@@ -17,7 +17,7 @@ public:
void InitializeFrameBuffers(); void InitializeFrameBuffers();
void InitializeShaderPrograms(); void InitializeShaderPrograms();
void Draw(RenderFrame& rf); void Draw(RenderScene& scene);
//Getters //Getters
+1 -1
View File
@@ -19,7 +19,7 @@ public:
void InitializeFrameBuffers(); void InitializeFrameBuffers();
void InitializeShaderPrograms(); void InitializeShaderPrograms();
void Draw(RenderFrame& rf); void Draw(RenderScene& scene);
//Getters //Getters
+1 -1
View File
@@ -52,7 +52,7 @@ struct RenderScene
::Camera* Camera; ::Camera* Camera;
std::list<std::shared_ptr<RenderJob>> ForwardJobs; std::list<std::shared_ptr<RenderJob>> ForwardJobs;
std::list<std::shared_ptr<RenderJob>> LightJobs; std::list<std::shared_ptr<RenderJob>> LightJobs;
Rectangle ViewPort; Rectangle Viewport;
void Clear() void Clear()
{ {
+1 -8
View File
@@ -13,6 +13,7 @@
#include "Camera.h" #include "Camera.h"
#include "ModelJob.h" #include "ModelJob.h"
#include "Renderer.h" #include "Renderer.h"
#include "../Core/Transform.h"
class RenderSystem : public ImpureSystem class RenderSystem : public ImpureSystem
{ {
@@ -21,12 +22,6 @@ public:
virtual void Update(World* world, double dt) override; virtual void Update(World* world, double dt) override;
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: private:
World* m_World = nullptr; World* m_World = nullptr;
const IRenderer* m_Renderer = nullptr; const IRenderer* m_Renderer = nullptr;
@@ -44,13 +39,11 @@ private:
void switchCamera(EntityID entity); void switchCamera(EntityID entity);
void initialize();
void updateCamera(World* world, double dt); void updateCamera(World* world, double dt);
void updateProjectionMatrix(ComponentWrapper& cameraComponent); void updateProjectionMatrix(ComponentWrapper& cameraComponent);
glm::mat4 m_ViewMatrix; glm::mat4 m_ViewMatrix;
glm::mat4 m_ProjectionMatrix; glm::mat4 m_ProjectionMatrix;
glm::mat4 ModelMatrix(EntityID entity, World* world);
void fillModels(std::list<std::shared_ptr<RenderJob>>& jobs, World* world); void fillModels(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
EventRelay<RenderSystem, Events::InputCommand> m_EInputCommand; EventRelay<RenderSystem, Events::InputCommand> m_EInputCommand;
+1 -1
View File
@@ -26,7 +26,7 @@ public:
virtual void Initialize() override; virtual void Initialize() override;
virtual void Update(double dt) override; virtual void Update(double dt) override;
virtual void Draw(RenderFrame& rf) override; virtual void Draw(RenderFrame& frame) override;
virtual PickData Pick(glm::vec2 screenCoord) override; virtual PickData Pick(glm::vec2 screenCoord) override;
-1
View File
@@ -1,6 +1,5 @@
#version 430 #version 430
uniform mat4 Matrix;
uniform vec4 Color; uniform vec4 Color;
uniform sampler2D texture0; uniform sampler2D texture0;
+4 -2
View File
@@ -1,6 +1,8 @@
#version 430 #version 430
uniform mat4 Matrix; uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
layout(location = 0) in vec3 Position; layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal; layout(location = 1) in vec3 Normal;
@@ -23,7 +25,7 @@ out VertexData{
void main() void main()
{ {
gl_Position = Matrix * 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;
-3
View File
@@ -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{
+4 -2
View File
@@ -1,6 +1,8 @@
#version 430 #version 430
uniform mat4 Matrix; uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
layout(location = 0) in vec3 Position; layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal; layout(location = 1) in vec3 Normal;
@@ -20,7 +22,7 @@ out VertexData{
void main() void main()
{ {
gl_Position = Matrix * vec4(Position, 1.0); gl_Position = P * V* M * vec4(Position, 1.0);
Output.Position = Position; Output.Position = Position;
} }
+7 -7
View File
@@ -159,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(RenderSystem::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) {
@@ -178,7 +178,7 @@ bool EditorSystem::OnMouseMove(const Events::MouseMove& e)
// parentOrientation = RenderSystem::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 = RenderSystem::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));
@@ -321,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 = RenderSystem::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(RenderSystem::AbsoluteOrientation(m_World, m_Selection)); widgetTransform["Orientation"] = glm::eulerAngles(Transform::AbsoluteOrientation(m_World, m_Selection));
} }
} }
} }
@@ -359,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(RenderSystem::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) {
@@ -370,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(RenderSystem::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";
@@ -379,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(RenderSystem::AbsoluteOrientation(m_World, m_Selection)); widgetTransform["Orientation"] = glm::eulerAngles(Transform::AbsoluteOrientation(m_World, m_Selection));
} }
} }
} }
+7 -6
View File
@@ -23,22 +23,23 @@ void DrawScenePass::InitializeShaderPrograms()
m_BasicForwardProgram->Link(); m_BasicForwardProgram->Link();
} }
void DrawScenePass::Draw(RenderFrame& rf) void DrawScenePass::Draw(RenderScene& scene)
{ {
//glBindFramebuffer(GL_FRAMEBUFFER, 0); //glBindFramebuffer(GL_FRAMEBUFFER, 0);
GLERROR("Renderer::Draw PickingPass"); GLERROR("Renderer::Draw PickingPass");
DrawScenePassState state; DrawScenePassState state;
for (auto scene : rf.RenderScenes) {
for (auto &job : scene->ForwardJobs) { 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) {
GLuint ShaderHandle = m_BasicForwardProgram->GetHandle(); GLuint ShaderHandle = m_BasicForwardProgram->GetHandle();
m_BasicForwardProgram->Bind(); m_BasicForwardProgram->Bind();
//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, "Matrix"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); 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()));
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
@@ -54,9 +55,9 @@ void DrawScenePass::Draw(RenderFrame& rf)
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;
}
} }
} }
GLERROR("DrawScene Error"); GLERROR("DrawScene Error");
} }
+8 -7
View File
@@ -43,7 +43,7 @@ void PickingPass::InitializeShaderPrograms()
m_PickingProgram->Link(); m_PickingProgram->Link();
} }
void PickingPass::Draw(RenderFrame& rf) void PickingPass::Draw(RenderScene& scene)
{ {
m_PickingColorsToEntity.clear(); m_PickingColorsToEntity.clear();
PickingPassState* state = new PickingPassState(m_PickingBuffer.GetHandle()); PickingPassState* state = new PickingPassState(m_PickingBuffer.GetHandle());
@@ -57,11 +57,9 @@ void PickingPass::Draw(RenderFrame& rf)
std::map<EntityID, glm::vec2> entityColors; std::map<EntityID, glm::vec2> entityColors;
for(auto scene : rf.RenderScenes) m_Camera = scene.Camera;
{
m_Camera = scene->Camera;
for (auto &job : scene->ForwardJobs) { 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) {
@@ -81,7 +79,10 @@ void PickingPass::Draw(RenderFrame& rf)
} }
m_PickingColorsToEntity[glm::vec2(pickColor[0], pickColor[1])] = modelJob->Entity; m_PickingColorsToEntity[glm::vec2(pickColor[0], pickColor[1])] = modelJob->Entity;
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "Matrix"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
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]))); glUniform2fv(glGetUniformLocation(ShaderHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
glBindVertexArray(modelJob->Model->VAO); glBindVertexArray(modelJob->Model->VAO);
@@ -89,7 +90,7 @@ void PickingPass::Draw(RenderFrame& rf)
glDrawElementsBaseVertex(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, nullptr, modelJob->StartIndex); 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");
+9 -67
View File
@@ -5,7 +5,6 @@ RenderSystem::RenderSystem(EventBroker* eventBrokerer, const IRenderer* renderer
{ {
m_Renderer = renderer; m_Renderer = renderer;
m_RenderFrame = renderFrame; m_RenderFrame = renderFrame;
initialize();
EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &RenderSystem::OnSetCamera); EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &RenderSystem::OnSetCamera);
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &RenderSystem::OnInputCommand); EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &RenderSystem::OnInputCommand);
@@ -52,11 +51,6 @@ void RenderSystem::switchCamera(EntityID entity)
} }
} }
void RenderSystem::initialize()
{
}
void RenderSystem::updateProjectionMatrix(ComponentWrapper& cameraComponent) void RenderSystem::updateProjectionMatrix(ComponentWrapper& cameraComponent)
{ {
double fov = cameraComponent["FOV"]; double fov = cameraComponent["FOV"];
@@ -74,56 +68,6 @@ void RenderSystem::updateProjectionMatrix(ComponentWrapper& cameraComponent)
m_Camera->UpdateProjectionMatrix(); m_Camera->UpdateProjectionMatrix();
} }
glm::vec3 RenderSystem::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;
}
glm::quat RenderSystem::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 RenderSystem::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;
}
glm::mat4 RenderSystem::ModelMatrix(EntityID entity, World* world)
{
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;
}
void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& jobs, World* world) void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& jobs, World* world)
{ {
auto models = world->GetComponents("Model"); auto models = world->GetComponents("Model");
@@ -146,11 +90,10 @@ void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& jobs, World
model = ResourceManager::Load<::Model>("Models/Core/Error.obj"); model = ResourceManager::Load<::Model>("Models/Core/Error.obj");
} }
glm::mat4 modelMatrix = ModelMatrix(modelComponent.EntityID, world); glm::mat4 modelMatrix = Transform::ModelMatrix(modelComponent.EntityID, world);
glm::mat4 matrix = m_Camera->ProjectionMatrix() * m_Camera->ViewMatrix() * (model->m_Matrix * modelMatrix);
for (auto texGroup : model->TextureGroups) { for (auto texGroup : model->TextureGroups) {
std::shared_ptr<ModelJob> modelJob = std::shared_ptr<ModelJob>(new ModelJob(model, m_Camera, matrix, texGroup, modelComponent)); std::shared_ptr<ModelJob> modelJob = std::shared_ptr<ModelJob>(new ModelJob(model, m_Camera, modelMatrix, texGroup, modelComponent));
jobs.push_back(modelJob); jobs.push_back(modelJob);
} }
} }
@@ -175,12 +118,11 @@ void RenderSystem::Update(World* world, double dt)
//Only supports opaque geometry atm //Only supports opaque geometry atm
m_RenderFrame->Clear(); m_RenderFrame->Clear();
RenderScene* rs = new RenderScene(); RenderScene rs;
rs->Camera = m_Camera; rs.Camera = m_Camera;
rs->ViewPort = Rectangle(1280, 720); rs.Viewport = Rectangle(1280, 720);
fillModels(rs->ForwardJobs, world); fillModels(rs.ForwardJobs, world);
m_RenderFrame->Add(*rs); m_RenderFrame->Add(rs);
delete rs;
} }
void RenderSystem::updateCamera(World* world, double dt) void RenderSystem::updateCamera(World* world, double dt)
@@ -218,8 +160,8 @@ void RenderSystem::updateCamera(World* world, double dt)
(glm::vec3&)cameraTransform["Orientation"] = glm::eulerAngles(firstPersonInputController.Orientation()); (glm::vec3&)cameraTransform["Orientation"] = glm::eulerAngles(firstPersonInputController.Orientation());
(glm::vec3&)cameraTransform["Position"] = firstPersonInputController.Position(); (glm::vec3&)cameraTransform["Position"] = firstPersonInputController.Position();
glm::vec3 position = AbsolutePosition(world, m_CurrentCamera); glm::vec3 position = Transform::AbsolutePosition(world, m_CurrentCamera);
glm::quat orientation = AbsoluteOrientation(world, m_CurrentCamera); glm::quat orientation = Transform::AbsoluteOrientation(world, m_CurrentCamera);
m_Camera->SetPosition(position); m_Camera->SetPosition(position);
m_Camera->SetOrientation(orientation); m_Camera->SetOrientation(orientation);
+7 -4
View File
@@ -89,15 +89,18 @@ void Renderer::Update(double dt)
m_ImGuiRenderPass->Update(dt); m_ImGuiRenderPass->Update(dt);
} }
void Renderer::Draw(RenderFrame& rf) void Renderer::Draw(RenderFrame& frame)
{ {
m_Camera = (*rf.begin())->Camera; // Fix this with some better solution for (auto scene : frame.RenderScenes){
m_PickingPass->Draw(rf); m_Camera = scene->Camera; // remove renderer camera when Editor uses the render scene cameras.
m_PickingPass->Draw(*scene);
glClearColor(255.f / 255, 163.f / 255, 176.f / 255, 1.f); glClearColor(255.f / 255, 163.f / 255, 176.f / 255, 1.f);
m_DrawScenePass->Draw(rf); m_DrawScenePass->Draw(*scene);
GLERROR("Renderer::Draw m_DrawScenePass->Draw"); GLERROR("Renderer::Draw m_DrawScenePass->Draw");
}
m_ImGuiRenderPass->Draw(); m_ImGuiRenderPass->Draw();
glfwSwapBuffers(m_Window); glfwSwapBuffers(m_Window);
} }