mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-09 20:08:57 +03:00
Fixed math problem and display submeshes in editor panel
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
#pragma once
|
||||
#include <src/Core/Core.h>
|
||||
#include "ComponentPanel.h"
|
||||
#include "ModelResourceInspector.h"
|
||||
|
||||
#include <src/Scene/Entities/ImGuiHelper.h>
|
||||
#include <src/Scene/Components/MeshComponent.h>
|
||||
|
||||
@@ -7,9 +10,14 @@
|
||||
#include <src/Core/String.h>
|
||||
|
||||
class MeshPanel : ComponentPanel {
|
||||
|
||||
private:
|
||||
Scope<ModelResourceInspector> _modelInspector;
|
||||
bool _expanded = false;
|
||||
public:
|
||||
MeshPanel() {}
|
||||
MeshPanel()
|
||||
{
|
||||
CreateScope<ModelResourceInspector>();
|
||||
}
|
||||
|
||||
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<ModelResourceInspector>(component.ModelResource);
|
||||
}
|
||||
|
||||
_expanded = !_expanded;
|
||||
}
|
||||
|
||||
if (_expanded)
|
||||
{
|
||||
_modelInspector->Draw();
|
||||
}
|
||||
|
||||
if (ImGui::BeginDragDropTarget())
|
||||
{
|
||||
|
||||
23
Editor/src/ComponentsPanel/ModelResourceInspector.cpp
Normal file
23
Editor/src/ComponentsPanel/ModelResourceInspector.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "ModelResourceInspector.h"
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
ModelResourceInspector::ModelResourceInspector(Ref<Nuake::Model> 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();
|
||||
}
|
||||
16
Editor/src/ComponentsPanel/ModelResourceInspector.h
Normal file
16
Editor/src/ComponentsPanel/ModelResourceInspector.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include <src/Core/Core.h>
|
||||
#include <src/Resource/Model.h>
|
||||
|
||||
class ModelResourceInspector
|
||||
{
|
||||
private:
|
||||
Ref<Nuake::Model> _model;
|
||||
|
||||
public:
|
||||
ModelResourceInspector(Ref<Nuake::Model> model);
|
||||
ModelResourceInspector() = default;
|
||||
~ModelResourceInspector() = default;
|
||||
|
||||
void Draw();
|
||||
};
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "ComponentPanel.h"
|
||||
#include <src/Scene/Entities/ImGuiHelper.h>
|
||||
#include <src/Scene/Components/TransformComponent.h>
|
||||
|
||||
#include <src/Core/Maths.h>
|
||||
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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -202,7 +202,5 @@ namespace Nuake
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
12
Nuake/src/Core/Maths.cpp
Normal file
12
Nuake/src/Core/Maths.cpp
Normal file
@@ -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;
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <src/Vendors/glm/ext/vector_float2.hpp>
|
||||
#include <src/Vendors/glm/ext/matrix_float4x4.hpp>
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
|
||||
namespace Nuake
|
||||
{
|
||||
// Type definitions
|
||||
|
||||
Reference in New Issue
Block a user