improved model loading and added model component
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "open_engine/renderer/renderer3d.hpp"
|
||||
#include "open_engine/scene/components.hpp"
|
||||
#include <Jolt/Physics/Body/MotionType.h>
|
||||
#include <cstdint>
|
||||
#include <editor_component.hpp>
|
||||
#include <entt/entity/fwd.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
@@ -295,4 +296,33 @@ namespace OpenEngine {
|
||||
"%.2f",
|
||||
ImGuiSliderFlags_AlwaysClamp);
|
||||
}
|
||||
|
||||
void ModelOnImGuiRender(entt::registry& registry, entt::entity entity)
|
||||
{
|
||||
auto& model_comp = registry.get<ModelComponent>(entity);
|
||||
|
||||
bool opened = ImGui::TreeNodeEx(
|
||||
(void*)(intptr_t)entity,
|
||||
ImGuiTreeNodeFlags_None,
|
||||
"Meshes",
|
||||
nullptr
|
||||
);
|
||||
|
||||
if (opened) {
|
||||
unsigned int i = 0;
|
||||
for (auto& mesh : model_comp.model->GetMeshes())
|
||||
ImGui::Text("Mesh: %i", i++);
|
||||
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, {1, 1, 1, 1});
|
||||
if (ImGui::BeginChild("Material list")) {
|
||||
for (auto& mesh : model_comp.model->GetMeshes())
|
||||
ImGui::Text("Material: %s", mesh.material.name.c_str());
|
||||
ImGui::EndChild();
|
||||
}
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace OpenEngine {
|
||||
RegisterDrawer<SphereShapeComponent>("Sphere Shape", &SphereShapeOnImGuiRender);
|
||||
RegisterDrawer<BoxShapeComponent>("Box Shape", &BoxShapeOnImGuiRender);
|
||||
RegisterDrawer<PlaneShapeComponent>("Plane Shape", &PlaneShapeOnImGuiRender);
|
||||
RegisterDrawer<ModelComponent>("Model", &ModelOnImGuiRender);
|
||||
|
||||
scene = context;
|
||||
selected_context = {};
|
||||
@@ -81,6 +82,11 @@ namespace OpenEngine {
|
||||
selected_context.AddComponent<PlaneShapeComponent>();
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
if (!selected_context.HasComponent<ModelComponent>())
|
||||
if (ImGui::MenuItem("Model")) {
|
||||
selected_context.AddComponent<ModelComponent>();
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
|
||||
void EntityPopup(Ref<Scene>& scene)
|
||||
|
||||
Reference in New Issue
Block a user