diff --git a/src/inferno/application.cpp b/src/inferno/application.cpp index 09b2615..f358d93 100644 --- a/src/inferno/application.cpp +++ b/src/inferno/application.cpp @@ -80,6 +80,7 @@ Application::~Application() RendererFont::destroy(); Renderer2D::destroy(); + Renderer3D::destroy(); RendererCubemap::destroy(); RenderCommand::destroy(); AssetManager::destroy(); @@ -168,6 +169,7 @@ int Application::run() std::pair projectionView = m_scene->cameraProjectionView(); RendererCubemap::the().beginScene(projectionView.first, projectionView.second); // camera, lights, environment + Renderer3D::the().beginScene(projectionView.first, projectionView.second); // camera, lights, environment Renderer2D::the().beginScene(projectionView.first, projectionView.second); // camera, lights, environment RendererFont::the().beginScene(projectionView.first, projectionView.second); // camera, lights, environment @@ -175,6 +177,7 @@ int Application::run() // RendererCharacter::the().drawCharacter(character, f->texture()); RendererCubemap::the().endScene(); + Renderer3D::the().endScene(); Renderer2D::the().endScene(); RendererFont::the().endScene(); diff --git a/src/inferno/scene/scene.cpp b/src/inferno/scene/scene.cpp index 96f20b9..2fe096a 100644 --- a/src/inferno/scene/scene.cpp +++ b/src/inferno/scene/scene.cpp @@ -19,6 +19,7 @@ #include "inferno/component/cubemap-component.h" #include "inferno/component/id-component.h" #include "inferno/component/luascriptcomponent.h" +#include "inferno/component/model-component.h" #include "inferno/component/nativescriptcomponent.h" #include "inferno/component/spritecomponent.h" #include "inferno/component/tagcomponent.h" @@ -166,6 +167,10 @@ uint32_t Scene::loadEntity(ruc::Json components, uint32_t parentEntity) auto& text = addComponent(entity); components.at("text").getTo(text); } + if (components.exists("model")) { + auto& text = addComponent(entity); + components.at("model").getTo(text); + } if (components.exists("children")) { VERIFY(components.at("children").type() == ruc::Json::Type::Array); const auto& children = components.at("children").asArray(); diff --git a/src/inferno/system/rendersystem.cpp b/src/inferno/system/rendersystem.cpp index 4cdc995..53986dc 100644 --- a/src/inferno/system/rendersystem.cpp +++ b/src/inferno/system/rendersystem.cpp @@ -5,9 +5,11 @@ */ #include "glm/ext/matrix_transform.hpp" // glm::translate, glm::rotate, glm::scale, glm::radians +#include "inferno/component/model-component.h" #include "ruc/format/log.h" #include "inferno/component/cubemap-component.h" +#include "inferno/component/model-component.h" #include "inferno/component/spritecomponent.h" #include "inferno/component/transformcomponent.h" #include "inferno/render/renderer.h" @@ -37,6 +39,15 @@ void RenderSystem::render() for (auto [entity, transform, cubemap] : cubemapView.each()) { RendererCubemap::the().drawCubemap(transform, cubemap.color, cubemap.texture); } + + auto modelView = m_registry->view(); + + for (auto [entity, transform, model] : modelView.each()) { + Renderer3D::the().drawModel(model.model->vertices(), + model.model->elements(), + transform, + model.model->texture() ? model.model->texture() : model.texture); + } } } // namespace Inferno