diff --git a/enginecustom/applicationclass.cpp b/enginecustom/applicationclass.cpp index e763530..7746c44 100644 --- a/enginecustom/applicationclass.cpp +++ b/enginecustom/applicationclass.cpp @@ -1448,4 +1448,19 @@ void ApplicationClass::SetLightPosition(int index, XMVECTOR position) //set the position m_Lights[index]->SetPosition(lightPosition.x, lightPosition.y, lightPosition.z); -} \ No newline at end of file +} + +void ApplicationClass::DeleteLight(int index) +{ + if (index < 0 || index >= m_Lights.size()) + { + // Index out of bounds + return; + } + + // Delete the light object + delete m_Lights[index]; + + // Remove the light from the vector + m_Lights.erase(m_Lights.begin() + index); +} diff --git a/enginecustom/applicationclass.h b/enginecustom/applicationclass.h index 9ecf3eb..87abf46 100644 --- a/enginecustom/applicationclass.h +++ b/enginecustom/applicationclass.h @@ -84,6 +84,8 @@ public: void SetLightPosition(int index, XMVECTOR color); void SetLightColor(int index, XMVECTOR color); + void DeleteLight(int index); + std::vector GetLights() const { return m_Lights; }; private: diff --git a/enginecustom/enginecustom.vcxproj b/enginecustom/enginecustom.vcxproj index 1c7211c..2237b7f 100644 --- a/enginecustom/enginecustom.vcxproj +++ b/enginecustom/enginecustom.vcxproj @@ -1,4 +1,4 @@ - + @@ -118,12 +118,12 @@ - + Document - - + + Document - + diff --git a/enginecustom/imgui.ini b/enginecustom/imgui.ini index 21e4b2c..2b717da 100644 --- a/enginecustom/imgui.ini +++ b/enginecustom/imgui.ini @@ -14,3 +14,7 @@ Size=492,353 Pos=892,19 Size=418,94 +[Window][Light] +Pos=70,378 +Size=418,240 + diff --git a/enginecustom/imguiManager.cpp b/enginecustom/imguiManager.cpp index 9b57fa5..8fba111 100644 --- a/enginecustom/imguiManager.cpp +++ b/enginecustom/imguiManager.cpp @@ -216,8 +216,8 @@ void imguiManager::WidgetLightWindow(ApplicationClass* app) std::string headerName = "Light " + std::to_string(index); if (ImGui::CollapsingHeader(headerName.c_str())) { - XMVECTOR position = light->GetPosition(); - XMVECTOR color = light->GetColor(); + XMVECTOR position = app->GetLightPosition(index); + XMVECTOR color = app->GetLightColor(index); float pos[3] = { XMVectorGetX(position), XMVectorGetY(position), XMVectorGetZ(position) }; float col[3] = { XMVectorGetX(color), XMVectorGetY(color), XMVectorGetZ(color) }; @@ -226,12 +226,12 @@ void imguiManager::WidgetLightWindow(ApplicationClass* app) if (ImGui::DragFloat3(posLabel.c_str(), pos)) { - light->SetPosition(XMVectorSet(pos[0], pos[1], pos[2], 0.0f)); + app->SetLightPosition(index, XMVectorSet(pos[0], pos[1], pos[2], 0.0f)); } if (ImGui::ColorEdit3(colLabel.c_str(), col)) { - light->SetColor(XMVectorSet(col[0], col[1], col[2], 0.0f)); + app->SetLightColor(index, XMVectorSet(col[0], col[1], col[2], 0.0f)); } ImGui::Separator(); @@ -246,7 +246,7 @@ void imguiManager::WidgetLightWindow(ApplicationClass* app) ImGui::Separator(); } index++; - }) + }; ImGui::End(); } \ No newline at end of file