-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmodel-loading.cpp
55 lines (45 loc) · 1.54 KB
/
model-loading.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "model-loading.h"
#include <imgui.h>
#include "systems/render-system.h"
#include "systems/camera-system.h"
#include "components/graphics/pipeline.h"
#include "components/physics/transform.h"
#include "factories/entities/model-factory.h"
namespace basicExample {
ModelLoading::ModelLoading(Context& context) : m_ctx(context) {
// Init
m_systems = {
std::make_shared<RenderSystem>(context),
std::make_shared<CameraSystem>(context)
};
ModelFactory modelFactory(context);
// Pipeline
scomp::ShaderPipeline shaders = {};
shaders.vs = m_ctx.rcommand->createVertexShader("res/shaders/basics/model-loading/model-loading.vert");
shaders.fs = m_ctx.rcommand->createFragmentShader("res/shaders/basics/model-loading/model-loading.frag");
scomp::ConstantBufferIndex cbIndices[] = {
scomp::PER_MESH,
scomp::PER_FRAME
};
comp::Pipeline pipeline = m_ctx.rcommand->createPipeline(shaders, cbIndices, std::size(cbIndices));
// Transform
comp::Transform transform = {};
// Assign pipeline to model entites
auto entities = modelFactory.createEntitiesFromGltf("res/models/damaged-helmet/DamagedHelmet.gltf");
for (auto entity : entities) {
m_ctx.registry.assign<comp::Pipeline>(entity, pipeline);
m_ctx.registry.assign<comp::Transform>(entity, transform);
}
}
ModelLoading::~ModelLoading() {}
void ModelLoading::update() {
for (auto& system : m_systems) {
system->update();
}
}
void ModelLoading::imGuiUpdate() {
ImGui::Begin("Exemple properties");
ImGui::Text("Model loading");
ImGui::End();
}
}