Scene+System: Enable model loading
This commit is contained in:
@@ -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<glm::mat4, glm::mat4> 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();
|
||||
|
||||
|
||||
@@ -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<TextAreaComponent>(entity);
|
||||
components.at("text").getTo(text);
|
||||
}
|
||||
if (components.exists("model")) {
|
||||
auto& text = addComponent<ModelComponent>(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();
|
||||
|
||||
@@ -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<TransformComponent, ModelComponent>();
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user