diff --git a/include/Engine/Editor/EditorRenderSystem.h b/include/Engine/Editor/EditorRenderSystem.h index 5076b3a6..8b9a9195 100755 --- a/include/Engine/Editor/EditorRenderSystem.h +++ b/include/Engine/Editor/EditorRenderSystem.h @@ -7,7 +7,7 @@ class EditorRenderSystem : public ImpureSystem { public: - EditorRenderSystem(World* world, EventBroker* eventBroker, IRenderer* renderer, RenderFrame* renderFrame); + EditorRenderSystem(SystemParams params, IRenderer* renderer, RenderFrame* renderFrame); virtual void Update(double dt) override; @@ -20,5 +20,5 @@ private: EventRelay m_ESetCamera; bool OnSetCamera(Events::SetCamera& e); - void enqueueModel(RenderScene& scene, EntityWrapper entity, const glm::mat4& modelMatrix, const std::string& modelResource, bool wireframe); + void enqueueModel(RenderScene& scene, EntityWrapper entity, const glm::mat4& modelMatrix, const std::string& modelResource, ComponentWrapper cModel, bool wireframe); }; \ No newline at end of file diff --git a/src/Engine/Editor/EditorRenderSystem.cpp b/src/Engine/Editor/EditorRenderSystem.cpp index 48e3899c..05f5a393 100755 --- a/src/Engine/Editor/EditorRenderSystem.cpp +++ b/src/Engine/Editor/EditorRenderSystem.cpp @@ -1,7 +1,7 @@ #include "Editor/EditorRenderSystem.h" -EditorRenderSystem::EditorRenderSystem(World* world, EventBroker* eventBroker, IRenderer* renderer, RenderFrame* renderFrame) - : System(world, eventBroker) +EditorRenderSystem::EditorRenderSystem(SystemParams params, IRenderer* renderer, RenderFrame* renderFrame) + : System(params) , m_Renderer(renderer) , m_RenderFrame(renderFrame) { @@ -24,8 +24,9 @@ void EditorRenderSystem::Update(double dt) if (cameras != nullptr) { for (auto& cCamera : *cameras) { EntityWrapper entity(m_World, cCamera.EntityID); + entity["Model"]["Resource"] = "Models/Widgets/Camera.mesh"; glm::mat4 modelMatrix = Transform::ModelMatrix(entity); - enqueueModel(scene, entity, modelMatrix, "Models/Camera.mesh", false); + enqueueModel(scene, entity, modelMatrix, "Models/Widgets/Camera.mesh", entity["Model"], false); } } @@ -36,7 +37,8 @@ void EditorRenderSystem::Update(double dt) glm::vec3 absPosition = Transform::AbsolutePosition(entity) + (glm::vec3)cAABB["Origin"]; glm::vec3 absScale = Transform::AbsoluteScale(entity) * (glm::vec3)cAABB["Size"]; glm::mat4 modelMatrix = glm::translate(absPosition) * glm::scale(absScale); - enqueueModel(scene, entity, modelMatrix, "Models/Core/UnitCube.mesh", true); + entity["Model"]["Resource"] = "Models/Core/UnitCube.mesh"; + enqueueModel(scene, entity, modelMatrix, "Models/Core/UnitCube.mesh", entity["Model"], true); } } @@ -56,7 +58,7 @@ bool EditorRenderSystem::OnSetCamera(Events::SetCamera& e) return true; } -void EditorRenderSystem::enqueueModel(RenderScene& scene, EntityWrapper entity, const glm::mat4& modelMatrix, const std::string& modelResource, bool wireframe) +void EditorRenderSystem::enqueueModel(RenderScene& scene, EntityWrapper entity, const glm::mat4& modelMatrix, const std::string& modelResource, ComponentWrapper cModel, bool wireframe) { Model* model; try { @@ -72,27 +74,19 @@ void EditorRenderSystem::enqueueModel(RenderScene& scene, EntityWrapper entity, } for (auto matGroup : model->MaterialGroups()) { - std::shared_ptr modelJob = std::make_shared(); - modelJob->Model = model; - modelJob->TextureID = (matGroup.Texture) ? matGroup.Texture->ResourceID : 0; - modelJob->DiffuseTexture = matGroup.Texture.get(); - modelJob->NormalTexture = nullptr; - modelJob->SpecularTexture = nullptr; - modelJob->IncandescenceTexture = nullptr; - modelJob->DiffuseColor = matGroup.DiffuseColor; - modelJob->SpecularColor = matGroup.SpecularColor; - modelJob->IncandescenceColor = matGroup.IncandescenceColor; - modelJob->StartIndex = matGroup.StartIndex; - modelJob->EndIndex = matGroup.EndIndex; - modelJob->Matrix = modelMatrix; - modelJob->Entity = entity.ID; - glm::vec3 abspos = Transform::AbsolutePosition(entity); - glm::vec3 worldpos = glm::vec3(m_Camera->ViewMatrix() * glm::vec4(abspos, 1)); - modelJob->Depth = worldpos.z; - modelJob->World = m_World; + std::shared_ptr modelJob = std::shared_ptr(new ModelJob( + model, + m_Camera, + modelMatrix, + matGroup, + cModel, + m_World, + glm::vec4(1.f, 1.f, 1.f, 1.f), + 0.f, + false + )); modelJob->Wireframe = wireframe; - - scene.OpaqueObjects.push_back(modelJob); + scene.Jobs.OpaqueObjects.push_back(modelJob); } } diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index e94b3a89..1d033189 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -429,6 +429,12 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& if (modelJob) { //bind forward program //TODO: JOHAN/TOBIAS: Bind shader based on ModelJob->ShaderID; + RenderState jobState; + if (modelJob->Wireframe) { + jobState.Disable(GL_CULL_FACE); + jobState.PolygonMode(GL_FRONT_AND_BACK, GL_LINE); + } + switch (modelJob->Type) { case RawModel::MaterialType::Basic: case RawModel::MaterialType::SingleTextures: @@ -917,8 +923,6 @@ void DrawFinalPass::DrawShieldedModelRenderQueue(std::list(job); if (modelJob) { - RenderState jobState; - //bind forward program m_ForwardPlusProgram->Bind(); glUniform2f(glGetUniformLocation(forwardHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); @@ -982,10 +986,6 @@ void DrawFinalPass::DrawToDepthStencilBuffer(std::listModel->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);