prep the select func

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

View File

@@ -74,4 +74,30 @@ void imguiManager::WidgetAddObject(ApplicationClass* app)
ImGui::SameLine();
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)));
}
}
}