Camera Switch event now working, Camera models Rotation still bugged
This commit is contained in:
+1
-1
Submodule assets updated: c5f674349a...008f727821
@@ -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; }
|
||||||
|
|
||||||
|
|||||||
@@ -20,16 +20,6 @@ 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; }
|
|
||||||
void SetCamera(::Camera* camera)
|
|
||||||
{
|
|
||||||
if (camera == nullptr) {
|
|
||||||
m_Camera = m_DefaultCamera;
|
|
||||||
} else {
|
|
||||||
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(RenderQueueCollection& rq) = 0;
|
||||||
@@ -40,8 +30,6 @@ 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ struct ModelJob : RenderJob
|
|||||||
//TODO: RENDERER: Not sure if the best solution for pickingColor to entity link is this
|
//TODO: RENDERER: Not sure if the best solution for pickingColor to entity link is this
|
||||||
EntityID Entity;
|
EntityID Entity;
|
||||||
|
|
||||||
glm::mat4 ModelMatrix;
|
glm::mat4 Matrix;
|
||||||
const Texture* DiffuseTexture;
|
const Texture* DiffuseTexture;
|
||||||
const Texture* NormalTexture;
|
const Texture* NormalTexture;
|
||||||
const Texture* SpecularTexture;
|
const Texture* SpecularTexture;
|
||||||
@@ -71,7 +71,7 @@ struct TransparentModelJob : RenderJob
|
|||||||
//TODO: RENDERER: Not sure if the best solution for pickingColor to entity link is this
|
//TODO: RENDERER: Not sure if the best solution for pickingColor to entity link is this
|
||||||
EntityID Entity;
|
EntityID Entity;
|
||||||
|
|
||||||
glm::mat4 ModelMatrix;
|
glm::mat4 Matrix;
|
||||||
const Texture* DiffuseTexture;
|
const Texture* DiffuseTexture;
|
||||||
const Texture* NormalTexture;
|
const Texture* NormalTexture;
|
||||||
const Texture* SpecularTexture;
|
const Texture* SpecularTexture;
|
||||||
|
|||||||
@@ -1,18 +1,54 @@
|
|||||||
#include "RenderSystem.h"
|
#include "Rendering/RenderSystem.h"
|
||||||
|
#include "Rendering/DebugCameraInputController.h"
|
||||||
|
|
||||||
RenderSystem::RenderSystem(EventBroker* eventBrokerer, RenderQueueCollection* renderQueues)
|
RenderSystem::RenderSystem(EventBroker* eventBrokerer, RenderQueueCollection* renderQueues)
|
||||||
:ImpureSystem(eventBrokerer)
|
:ImpureSystem(eventBrokerer)
|
||||||
{
|
{
|
||||||
m_RenderQueues = renderQueues;
|
m_RenderQueues = renderQueues;
|
||||||
Initialize();
|
Initialize();
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &RenderSystem::OnSetCamera);
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &RenderSystem::OnInputCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool RenderSystem::OnSetCamera(const Events::SetCamera &event)
|
||||||
|
{
|
||||||
|
m_CurrentCamera = event.Entity;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderSystem::SwitchCamera(EntityID entity)
|
||||||
|
{
|
||||||
|
m_CurrentCamera = entity;
|
||||||
|
m_SwitchCamera = false;
|
||||||
|
LOG_INFO("Switched to camera %i", m_CurrentCamera);
|
||||||
|
}
|
||||||
|
|
||||||
void RenderSystem::Initialize()
|
void RenderSystem::Initialize()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderSystem::UpdateViewMatrix(ComponentWrapper& cameraTransform)
|
||||||
|
{
|
||||||
|
glm::quat orientation = cameraTransform["Orientation"];
|
||||||
|
glm::vec3 position = cameraTransform["Position"];
|
||||||
|
|
||||||
|
m_ViewMatrix = glm::toMat4(glm::inverse(orientation)) * glm::translate(-position);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderSystem::UpdateProjectionMatrix(ComponentWrapper& cameraComponent)
|
||||||
|
{
|
||||||
|
double fov = (double&)cameraComponent["FOV"];
|
||||||
|
double aspectRatio = (double&)cameraComponent["AspectRatio"];
|
||||||
|
double nearClip = (double&)cameraComponent["NearClip"];
|
||||||
|
double farClip = (double&)cameraComponent["FarClip"];
|
||||||
|
|
||||||
|
double fovY = atan(tan(glm::radians(fov)/2.0) * aspectRatio) * 2.0;
|
||||||
|
m_ProjectionMatrix = glm::perspective(fovY, aspectRatio, nearClip, farClip);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
glm::vec3 RenderSystem::AbsolutePosition(World* world, EntityID entity)
|
glm::vec3 RenderSystem::AbsolutePosition(World* world, EntityID entity)
|
||||||
{
|
{
|
||||||
glm::vec3 position;
|
glm::vec3 position;
|
||||||
@@ -57,6 +93,7 @@ glm::vec3 RenderSystem::AbsoluteScale(World* world, EntityID entity)
|
|||||||
return scale;
|
return scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
glm::mat4 RenderSystem::ModelMatrix(World* world, EntityID entity)
|
glm::mat4 RenderSystem::ModelMatrix(World* world, EntityID entity)
|
||||||
{
|
{
|
||||||
glm::vec3 position = AbsolutePosition(world, entity);
|
glm::vec3 position = AbsolutePosition(world, entity);
|
||||||
@@ -101,10 +138,10 @@ void RenderSystem::FillModels(World* world, RenderQueue* renderQueue)
|
|||||||
job.Model = model;
|
job.Model = model;
|
||||||
job.StartIndex = texGroup.StartIndex;
|
job.StartIndex = texGroup.StartIndex;
|
||||||
job.EndIndex = texGroup.EndIndex;
|
job.EndIndex = texGroup.EndIndex;
|
||||||
job.ModelMatrix = model->m_Matrix * ModelMatrix(world, modelC.EntityID);
|
job.Matrix = m_ProjectionMatrix * m_ViewMatrix * (model->m_Matrix * ModelMatrix(world, modelC.EntityID));
|
||||||
job.Color = color;
|
job.Color = color;
|
||||||
|
|
||||||
job.Entity = modelC.EntityID;
|
job.Entity = modelC.EntityID;
|
||||||
|
|
||||||
job.Depth = 10.f; //insert real viewspace depth here
|
job.Depth = 10.f; //insert real viewspace depth here
|
||||||
|
|
||||||
renderQueue->Add(job);
|
renderQueue->Add(job);
|
||||||
@@ -117,24 +154,79 @@ void RenderSystem::FillModels(World* world, RenderQueue* renderQueue)
|
|||||||
job.Model = model;
|
job.Model = model;
|
||||||
job.StartIndex = texGroup.StartIndex;
|
job.StartIndex = texGroup.StartIndex;
|
||||||
job.EndIndex = texGroup.EndIndex;
|
job.EndIndex = texGroup.EndIndex;
|
||||||
job.ModelMatrix = model->m_Matrix * ModelMatrix(world, modelC.EntityID);
|
job.Matrix = m_ProjectionMatrix * m_ViewMatrix * (model->m_Matrix * ModelMatrix(world, modelC.EntityID));
|
||||||
job.Color = color;
|
job.Color = color;
|
||||||
|
|
||||||
//TODO: RENDERER: Not sure if the best solution for pickingColor to entity link is this
|
|
||||||
job.Entity = modelC.EntityID;
|
job.Entity = modelC.EntityID;
|
||||||
|
|
||||||
renderQueue->Add(job);
|
renderQueue->Add(job);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
void RenderSystem::Update(World* world, double dt)
|
||||||
{
|
{
|
||||||
|
m_EventBroker->Process<RenderSystem>();
|
||||||
|
static DebugCameraInputController<RenderSystem> firstPersonInputController(m_EventBroker, -1);
|
||||||
|
|
||||||
|
if (m_SwitchCamera) {
|
||||||
|
auto cameras = world->GetComponents("Camera");
|
||||||
|
|
||||||
|
if (cameras != nullptr) {
|
||||||
|
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)cameraTransform["Orientation"]);
|
||||||
|
firstPersonInputController.SetPosition((glm::vec3)cameraTransform["Position"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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::quat&)cameraTransform["Orientation"] = firstPersonInputController.Orientation();
|
||||||
|
(glm::vec3&)cameraTransform["Position"] = firstPersonInputController.Position();
|
||||||
|
|
||||||
|
|
||||||
|
UpdateProjectionMatrix(cameraComponent);
|
||||||
|
UpdateViewMatrix(cameraTransform);
|
||||||
|
} else {
|
||||||
|
m_ProjectionMatrix = glm::perspective(glm::radians(40.f), 1.77f, 0.05f, 5000.f);
|
||||||
|
m_ViewMatrix = glm::mat4();
|
||||||
|
|
||||||
|
auto cameras = world->GetComponents("Camera");
|
||||||
|
|
||||||
|
if (cameras != nullptr) {
|
||||||
|
ComponentWrapper& cameraC = *cameras->begin();
|
||||||
|
m_CurrentCamera = cameraC.EntityID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_RenderQueues->Clear();
|
m_RenderQueues->Clear();
|
||||||
FillModels(world, &m_RenderQueues->Forward);
|
FillModels(world, &m_RenderQueues->Forward);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
#include "../Core/ResourceManager.h"
|
#include "../Core/ResourceManager.h"
|
||||||
#include "ESetCamera.h"
|
#include "ESetCamera.h"
|
||||||
#include "Model.h"
|
#include "Model.h"
|
||||||
|
#include "../Core/EKeyDown.h"
|
||||||
|
#include "../Input/EInputCommand.h"
|
||||||
|
|
||||||
class RenderSystem : public ImpureSystem
|
class RenderSystem : public ImpureSystem
|
||||||
{
|
{
|
||||||
@@ -20,14 +22,29 @@ public:
|
|||||||
static glm::quat AbsoluteOrientation(World* world, EntityID entity);
|
static glm::quat AbsoluteOrientation(World* world, EntityID entity);
|
||||||
static glm::vec3 AbsoluteScale(World* world, EntityID entity);
|
static glm::vec3 AbsoluteScale(World* world, EntityID entity);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RenderQueueCollection* m_RenderQueues;
|
RenderQueueCollection* m_RenderQueues;
|
||||||
|
bool m_SwitchCamera = false;
|
||||||
|
|
||||||
|
EventRelay<RenderSystem, Events::SetCamera> m_ESetCamera;
|
||||||
|
bool OnSetCamera(const Events::SetCamera &event);
|
||||||
|
EntityID m_CurrentCamera = -1;
|
||||||
|
|
||||||
|
void SwitchCamera(EntityID entity);
|
||||||
|
|
||||||
void Initialize();
|
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);
|
glm::mat4 ModelMatrix(World* world, EntityID entity);
|
||||||
|
|
||||||
void FillModels(World* world, RenderQueue* renderQueue);
|
void FillModels(World* world, RenderQueue* renderQueue);
|
||||||
|
|
||||||
|
EventRelay<RenderSystem, Events::InputCommand> m_EInputCommand;
|
||||||
|
bool OnInputCommand(const Events::InputCommand& e);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -49,7 +49,6 @@ private:
|
|||||||
|
|
||||||
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;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<c:Camera>
|
<c:Camera>
|
||||||
<AspectRatio>1.77</AspectRatio>
|
<AspectRatio>1.77</AspectRatio>
|
||||||
<FOV>90</FOV>
|
<FOV>60.0</FOV>
|
||||||
<NearClip>0.01</NearClip>
|
<NearClip>0.01</NearClip>
|
||||||
<FarClip>5000</FarClip>
|
<FarClip>5000</FarClip>
|
||||||
</c:Camera>
|
</c:Camera>
|
||||||
@@ -13,8 +13,22 @@
|
|||||||
<Entity>
|
<Entity>
|
||||||
<Components>
|
<Components>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Scale X="1" Y="1" Z="1"/>
|
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Camera.obj</Resource>
|
||||||
|
</c:Model>
|
||||||
|
<c:Camera>
|
||||||
|
</c:Camera>
|
||||||
|
</Components>
|
||||||
|
</Entity>
|
||||||
|
<Entity>
|
||||||
|
<Components>
|
||||||
|
<c:Transform>
|
||||||
|
<Position X="10" Y="5" Z="5"/>
|
||||||
|
</c:Transform>
|
||||||
|
<c:Model>
|
||||||
|
<Resource>Models/Camera.obj</Resource>
|
||||||
|
</c:Model>
|
||||||
<c:Camera>
|
<c:Camera>
|
||||||
</c:Camera>
|
</c:Camera>
|
||||||
</Components>
|
</Components>
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
uniform mat4 M;
|
uniform mat4 Matrix;
|
||||||
uniform mat4 V;
|
|
||||||
uniform mat4 P;
|
|
||||||
uniform vec4 Color;
|
uniform vec4 Color;
|
||||||
|
|
||||||
uniform sampler2D texture0;
|
uniform sampler2D texture0;
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
uniform mat4 M;
|
uniform mat4 Matrix;
|
||||||
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;
|
||||||
@@ -25,7 +23,7 @@ out VertexData{
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = P*V*M * vec4(Position, 1.0);
|
gl_Position = Matrix * vec4(Position, 1.0);
|
||||||
|
|
||||||
Output.Position = Position;
|
Output.Position = Position;
|
||||||
Output.TextureCoordinate = TextureCoords;
|
Output.TextureCoordinate = TextureCoords;
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
uniform mat4 M;
|
uniform mat4 Matrix;
|
||||||
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;
|
||||||
@@ -22,7 +20,7 @@ out VertexData{
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = P*V*M * vec4(Position, 1.0);
|
gl_Position = Matrix * vec4(Position, 1.0);
|
||||||
|
|
||||||
Output.Position = Position;
|
Output.Position = Position;
|
||||||
}
|
}
|
||||||
@@ -42,9 +42,7 @@ void DrawScenePass::Draw(RenderQueueCollection& rq)
|
|||||||
|
|
||||||
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, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->ModelMatrix));
|
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "Matrix"), 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, "P"), 1, GL_FALSE, glm::value_ptr(m_Renderer->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
|
||||||
|
|||||||
@@ -39,13 +39,6 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,11 +72,7 @@ void PickingPass::Draw(RenderQueueCollection& rq)
|
|||||||
}
|
}
|
||||||
m_PickingColorsToEntity[glm::vec2(pickColor[0], pickColor[1])] = modelJob->Entity;
|
m_PickingColorsToEntity[glm::vec2(pickColor[0], pickColor[1])] = modelJob->Entity;
|
||||||
|
|
||||||
//Render picking stuff
|
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "Matrix"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||||
//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])));
|
glUniform2fv(glGetUniformLocation(ShaderHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
||||||
|
|
||||||
glBindVertexArray(modelJob->Model->VAO);
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
@@ -96,15 +92,15 @@ void PickingPass::Draw(RenderQueueCollection& rq)
|
|||||||
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(
|
/* Events::Picking pickEvent = Events::Picking(
|
||||||
&m_PickingBuffer,
|
&m_PickingBuffer,
|
||||||
&m_DepthBuffer,
|
&m_DepthBuffer,
|
||||||
m_Renderer->Camera()->ProjectionMatrix(),
|
m_Renderer->Camera()->ProjectionMatrix(),
|
||||||
m_Renderer->Camera()->ViewMatrix(),
|
m_Renderer->Camera()->ViewMatrix(),
|
||||||
Rectangle(fbWidth, fbHeight),
|
Rectangle(fbWidth, fbHeight),
|
||||||
&m_PickingColorsToEntity);
|
&m_PickingColorsToEntity);*/
|
||||||
|
|
||||||
m_EventBroker->Publish(pickEvent);
|
//m_EventBroker->Publish(pickEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
@@ -4,12 +4,6 @@
|
|||||||
void Renderer::Initialize()
|
void Renderer::Initialize()
|
||||||
{
|
{
|
||||||
InitializeWindow();
|
InitializeWindow();
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
TEMPCreateLights();
|
TEMPCreateLights();
|
||||||
InitializeRenderPasses();
|
InitializeRenderPasses();
|
||||||
@@ -90,10 +84,7 @@ void Renderer::InitializeShaders()
|
|||||||
|
|
||||||
void Renderer::InputUpdate(double dt)
|
void Renderer::InputUpdate(double dt)
|
||||||
{
|
{
|
||||||
static DebugCameraInputController<Renderer> firstPersonInputController(m_EventBroker, -1);
|
|
||||||
firstPersonInputController.Update(dt);
|
|
||||||
m_Camera->SetOrientation(firstPersonInputController.Orientation());
|
|
||||||
m_Camera->SetPosition(firstPersonInputController.Position());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::Update(double dt)
|
void Renderer::Update(double dt)
|
||||||
@@ -214,17 +205,17 @@ void Renderer::InitializeRenderPasses()
|
|||||||
|
|
||||||
void Renderer::CalculateFrustum()
|
void Renderer::CalculateFrustum()
|
||||||
{
|
{
|
||||||
GLERROR("CalculateFrustum Error-1");
|
// GLERROR("CalculateFrustum Error-1");
|
||||||
m_CalculateFrustumProgram->Bind();
|
// m_CalculateFrustumProgram->Bind();
|
||||||
GLERROR("CalculateFrustum Error1");
|
// GLERROR("CalculateFrustum Error1");
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, m_FrustumSSBO);
|
// glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, m_FrustumSSBO);
|
||||||
GLERROR("CalculateFrustum Error2");
|
// GLERROR("CalculateFrustum Error2");
|
||||||
glUniformMatrix4fv(glGetUniformLocation(m_CalculateFrustumProgram->GetHandle(), "P"), 1, false, glm::value_ptr(m_Camera->ProjectionMatrix()));
|
// // glUniformMatrix4fv(glGetUniformLocation(m_CalculateFrustumProgram->GetHandle(), "P"), 1, false, glm::value_ptr(m_Camera->ProjectionMatrix()));
|
||||||
GLERROR("CalculateFrustum Error3");
|
// GLERROR("CalculateFrustum Error3");
|
||||||
glUniform2f(glGetUniformLocation(m_CalculateFrustumProgram->GetHandle(), "ScreenDimensions"), m_Resolution.Width, m_Resolution.Height);
|
// // glUniform2f(glGetUniformLocation(m_CalculateFrustumProgram->GetHandle(), "ScreenDimensions"), m_Resolution.Width, m_Resolution.Height);
|
||||||
GLERROR("CalculateFrustum Error4");
|
// GLERROR("CalculateFrustum Error4");
|
||||||
glDispatchCompute(5, 3, 1);
|
// //glDispatchCompute(5, 3, 1);
|
||||||
GLERROR("CalculateFrustum Error5");
|
// GLERROR("CalculateFrustum Error5");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user