From dbec248d8a30ad06698e240a74cc752c63b02f7a Mon Sep 17 00:00:00 2001 From: "a.pilote" Date: Sat, 16 Jul 2022 21:49:17 -0400 Subject: [PATCH] Fixed math problem and display submeshes in editor panel --- Editor/src/ComponentsPanel/MeshPanel.h | 27 ++++++++++++++++--- .../ModelResourceInspector.cpp | 23 ++++++++++++++++ .../ComponentsPanel/ModelResourceInspector.h | 16 +++++++++++ Editor/src/ComponentsPanel/TransformPanel.h | 4 +-- Nuake/Maths.cpp | 13 --------- Nuake/src/Core/FileSystem.cpp | 2 -- Nuake/src/Core/Maths.cpp | 12 +++++++++ Nuake/src/Core/Maths.h | 1 + 8 files changed, 78 insertions(+), 20 deletions(-) create mode 100644 Editor/src/ComponentsPanel/ModelResourceInspector.cpp create mode 100644 Editor/src/ComponentsPanel/ModelResourceInspector.h delete mode 100644 Nuake/Maths.cpp create mode 100644 Nuake/src/Core/Maths.cpp diff --git a/Editor/src/ComponentsPanel/MeshPanel.h b/Editor/src/ComponentsPanel/MeshPanel.h index b2093539..06f06c5c 100644 --- a/Editor/src/ComponentsPanel/MeshPanel.h +++ b/Editor/src/ComponentsPanel/MeshPanel.h @@ -1,5 +1,8 @@ #pragma once +#include #include "ComponentPanel.h" +#include "ModelResourceInspector.h" + #include #include @@ -7,9 +10,14 @@ #include class MeshPanel : ComponentPanel { - +private: + Scope _modelInspector; + bool _expanded = false; public: - MeshPanel() {} + MeshPanel() + { + CreateScope(); + } void Draw(Nuake::Entity entity) override { @@ -23,7 +31,20 @@ public: ImGui::TableNextColumn(); std::string label = std::to_string(component.ModelResource->ID); - ImGui::Button(label.c_str(), ImVec2(ImGui::GetContentRegionAvail().x, 0)); + if (ImGui::Button(label.c_str(), ImVec2(ImGui::GetContentRegionAvail().x, 0))) + { + if (!_expanded) + { + _modelInspector = CreateScope(component.ModelResource); + } + + _expanded = !_expanded; + } + + if (_expanded) + { + _modelInspector->Draw(); + } if (ImGui::BeginDragDropTarget()) { diff --git a/Editor/src/ComponentsPanel/ModelResourceInspector.cpp b/Editor/src/ComponentsPanel/ModelResourceInspector.cpp new file mode 100644 index 00000000..aab18ef0 --- /dev/null +++ b/Editor/src/ComponentsPanel/ModelResourceInspector.cpp @@ -0,0 +1,23 @@ +#include "ModelResourceInspector.h" +#include + +ModelResourceInspector::ModelResourceInspector(Ref model) +{ + _model = model; +} + +void ModelResourceInspector::Draw() +{ + ImGui::BeginChild("modelInspector",ImVec2(0,0), true); + { + for (uint32_t i = 0; i < std::size(_model->GetMeshes()); i++) + { + std::string headerLabel = "Mesh " + std::to_string(i); + if (ImGui::CollapsingHeader(headerLabel.c_str())) + { + + } + } + } + ImGui::EndChild(); +} \ No newline at end of file diff --git a/Editor/src/ComponentsPanel/ModelResourceInspector.h b/Editor/src/ComponentsPanel/ModelResourceInspector.h new file mode 100644 index 00000000..2d4de191 --- /dev/null +++ b/Editor/src/ComponentsPanel/ModelResourceInspector.h @@ -0,0 +1,16 @@ +#pragma once +#include +#include + +class ModelResourceInspector +{ +private: + Ref _model; + +public: + ModelResourceInspector(Ref model); + ModelResourceInspector() = default; + ~ModelResourceInspector() = default; + + void Draw(); +}; \ No newline at end of file diff --git a/Editor/src/ComponentsPanel/TransformPanel.h b/Editor/src/ComponentsPanel/TransformPanel.h index d6c797e5..885a2ec6 100644 --- a/Editor/src/ComponentsPanel/TransformPanel.h +++ b/Editor/src/ComponentsPanel/TransformPanel.h @@ -2,7 +2,7 @@ #include "ComponentPanel.h" #include #include - +#include class TransformPanel : ComponentPanel { public: @@ -44,7 +44,7 @@ public: if (eulerLocal != eulerAngles) { Quat rotation = QuatFromEuler(eulerAngles.x, eulerAngles.y, eulerAngles.z); - //component.SetLocalRotation(rotation); + component.SetLocalRotation(rotation); } ImGui::TableNextColumn(); diff --git a/Nuake/Maths.cpp b/Nuake/Maths.cpp deleted file mode 100644 index 64b593f3..00000000 --- a/Nuake/Maths.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "src/Core/Maths.h" - -namespace Nuake -{ - Quat QuatFromEuler(float x, float y, float z) - { - // Taken from: https://gamedev.stackexchange.com/questions/13436/glm-euler-angles-to-quaternion - Quat QuatAroundX = Quat(x, Vector3(1.0, 0.0, 0.0)); - Quat QuatAroundY = Quat(y, Vector3(0.0, 1.0, 0.0)); - Quat QuatAroundZ = Quat(z, Vector3(0.0, 0.0, 1.0)); - return QuatAroundX * QuatAroundY * QuatAroundZ; - } -} \ No newline at end of file diff --git a/Nuake/src/Core/FileSystem.cpp b/Nuake/src/Core/FileSystem.cpp index 5bdd90c3..f099bd3e 100644 --- a/Nuake/src/Core/FileSystem.cpp +++ b/Nuake/src/Core/FileSystem.cpp @@ -202,7 +202,5 @@ namespace Nuake } } } - } - } diff --git a/Nuake/src/Core/Maths.cpp b/Nuake/src/Core/Maths.cpp new file mode 100644 index 00000000..13afd27b --- /dev/null +++ b/Nuake/src/Core/Maths.cpp @@ -0,0 +1,12 @@ +#include "src/Core/Maths.h" + +using namespace Nuake; + +Quat Nuake::QuatFromEuler(float x, float y, float z) +{ + // Taken from: https://gamedev.stackexchange.com/questions/13436/glm-euler-angles-to-quaternion + Quat QuatAroundX = Quat(x, Vector3(1.0, 0.0, 0.0)); + Quat QuatAroundY = Quat(y, Vector3(0.0, 1.0, 0.0)); + Quat QuatAroundZ = Quat(z, Vector3(0.0, 0.0, 1.0)); + return QuatAroundX * QuatAroundY * QuatAroundZ; +} diff --git a/Nuake/src/Core/Maths.h b/Nuake/src/Core/Maths.h index 58d8ddd4..140ae529 100644 --- a/Nuake/src/Core/Maths.h +++ b/Nuake/src/Core/Maths.h @@ -6,6 +6,7 @@ #include #include #include + namespace Nuake { // Type definitions