From ed325934ee56fbc5f17cf182e1dec7fe15fb55b7 Mon Sep 17 00:00:00 2001 From: CatChow0 Date: Mon, 25 Mar 2024 17:59:47 +0100 Subject: [PATCH] prep the select func --- enginecustom/applicationclass.cpp | 7 ++++++- enginecustom/applicationclass.h | 3 +++ enginecustom/imgui.ini | 2 +- enginecustom/imguiManager.cpp | 28 +++++++++++++++++++++++++++- enginecustom/imguiManager.h | 1 + 5 files changed, 38 insertions(+), 3 deletions(-) diff --git a/enginecustom/applicationclass.cpp b/enginecustom/applicationclass.cpp index c5ce75d..2376221 100644 --- a/enginecustom/applicationclass.cpp +++ b/enginecustom/applicationclass.cpp @@ -234,4 +234,9 @@ void ApplicationClass::AddCube() newCube->SetTranslateMatrix(XMMatrixTranslation(0.0f, 0.0f, 0.0f)); m_cubes.push_back(newCube); -} \ No newline at end of file +} + +void ApplicationClass::SelectedObject(int mouseX, int mouseY) +{ + // TODO: Implement this function +} diff --git a/enginecustom/applicationclass.h b/enginecustom/applicationclass.h index 679784d..8c6d1e2 100644 --- a/enginecustom/applicationclass.h +++ b/enginecustom/applicationclass.h @@ -45,6 +45,8 @@ public: void AddCube(); int GetCubeCount() const { return m_cubes.size(); }; + void SelectedObject(int mouseX, int mouseY); + private: bool Render(float); @@ -57,6 +59,7 @@ private: LightClass* m_Light; float speed = 0.1f; std::vector m_cubes; + Object* m_SelectedObject; }; #endif diff --git a/enginecustom/imgui.ini b/enginecustom/imgui.ini index 62501f1..b35ac97 100644 --- a/enginecustom/imgui.ini +++ b/enginecustom/imgui.ini @@ -3,6 +3,6 @@ Pos=60,60 Size=400,400 [Window][Khaotic Engine] -Pos=522,44 +Pos=43,18 Size=694,367 diff --git a/enginecustom/imguiManager.cpp b/enginecustom/imguiManager.cpp index 3142e48..6cf7320 100644 --- a/enginecustom/imguiManager.cpp +++ b/enginecustom/imguiManager.cpp @@ -74,4 +74,30 @@ void imguiManager::WidgetAddObject(ApplicationClass* app) ImGui::SameLine(); ImGui::Text("Number of cubes: %d", app->GetCubeCount()); } -} \ No newline at end of file +} + +void imguiManager::WidgetSelectedObject(ApplicationClass* app) +{ + Object* selectedObject = app->SelectedObject(); + if (selectedObject) + { + if (ImGui::CollapsingHeader("Selected Object")) + { + XMFLOAT3 position, rotation, scale; + // Get the current position, rotation, and scale of the object + XMStoreFloat3(&position, selectedObject->GetTranslateMatrix().r[3]); + XMStoreFloat3(&rotation, selectedObject->GetRotateMatrix().r[3]); + XMStoreFloat3(&scale, selectedObject->GetScaleMatrix().r[3]); + + // Create ImGui controls to modify these values + ImGui::InputFloat3("Position", &position.x); + ImGui::InputFloat3("Rotation", &rotation.x); + ImGui::InputFloat3("Scale", &scale.x); + + // Update the object's matrices with the new values + selectedObject->SetTranslateMatrix(XMMatrixTranslationFromVector(XMLoadFloat3(&position))); + selectedObject->SetRotateMatrix(XMMatrixRotationRollPitchYawFromVector(XMLoadFloat3(&rotation))); + selectedObject->SetScaleMatrix(XMMatrixScalingFromVector(XMLoadFloat3(&scale))); + } + } +} diff --git a/enginecustom/imguiManager.h b/enginecustom/imguiManager.h index 9cb406f..63b5410 100644 --- a/enginecustom/imguiManager.h +++ b/enginecustom/imguiManager.h @@ -25,6 +25,7 @@ public: void WidgetButton(); void WidgetFPS(); void WidgetAddObject(ApplicationClass* app); + void WidgetSelectedObject(ApplicationClass* app); private: ImGuiIO* io;