prep the select func

This commit is contained in:
CatChow0 2024-03-25 17:59:47 +01:00
parent 7ef3237d88
commit ed325934ee
5 changed files with 38 additions and 3 deletions

View File

@ -234,4 +234,9 @@ void ApplicationClass::AddCube()
newCube->SetTranslateMatrix(XMMatrixTranslation(0.0f, 0.0f, 0.0f)); newCube->SetTranslateMatrix(XMMatrixTranslation(0.0f, 0.0f, 0.0f));
m_cubes.push_back(newCube); m_cubes.push_back(newCube);
} }
void ApplicationClass::SelectedObject(int mouseX, int mouseY)
{
// TODO: Implement this function
}

View File

@ -45,6 +45,8 @@ public:
void AddCube(); void AddCube();
int GetCubeCount() const { return m_cubes.size(); }; int GetCubeCount() const { return m_cubes.size(); };
void SelectedObject(int mouseX, int mouseY);
private: private:
bool Render(float); bool Render(float);
@ -57,6 +59,7 @@ private:
LightClass* m_Light; LightClass* m_Light;
float speed = 0.1f; float speed = 0.1f;
std::vector<Object*> m_cubes; std::vector<Object*> m_cubes;
Object* m_SelectedObject;
}; };
#endif #endif

View File

@ -3,6 +3,6 @@ Pos=60,60
Size=400,400 Size=400,400
[Window][Khaotic Engine] [Window][Khaotic Engine]
Pos=522,44 Pos=43,18
Size=694,367 Size=694,367

View File

@ -74,4 +74,30 @@ void imguiManager::WidgetAddObject(ApplicationClass* app)
ImGui::SameLine(); ImGui::SameLine();
ImGui::Text("Number of cubes: %d", app->GetCubeCount()); ImGui::Text("Number of cubes: %d", app->GetCubeCount());
} }
} }
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)));
}
}
}

View File

@ -25,6 +25,7 @@ public:
void WidgetButton(); void WidgetButton();
void WidgetFPS(); void WidgetFPS();
void WidgetAddObject(ApplicationClass* app); void WidgetAddObject(ApplicationClass* app);
void WidgetSelectedObject(ApplicationClass* app);
private: private:
ImGuiIO* io; ImGuiIO* io;