Browse Source

Scene+System: Enable model loading

master
Riyyi 4 months ago
parent
commit
c06b06ed62
  1. 3
      src/inferno/application.cpp
  2. 5
      src/inferno/scene/scene.cpp
  3. 11
      src/inferno/system/rendersystem.cpp

3
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<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();

5
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<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();

11
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<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

Loading…
Cancel
Save