Patch Update - Light dans ImGui

Feat :

+ Fenêtre Light dans l'interface
+ Contrôle des lights (position, couleur)
This commit is contained in:
CatChow0 2024-04-08 14:28:27 +02:00
parent 064c34b6dc
commit 8d344dbfc7
5 changed files with 32 additions and 11 deletions

View File

@ -1448,4 +1448,19 @@ void ApplicationClass::SetLightPosition(int index, XMVECTOR position)
//set the position //set the position
m_Lights[index]->SetPosition(lightPosition.x, lightPosition.y, lightPosition.z); m_Lights[index]->SetPosition(lightPosition.x, lightPosition.y, lightPosition.z);
} }
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);
}

View File

@ -84,6 +84,8 @@ public:
void SetLightPosition(int index, XMVECTOR color); void SetLightPosition(int index, XMVECTOR color);
void SetLightColor(int index, XMVECTOR color); void SetLightColor(int index, XMVECTOR color);
void DeleteLight(int index);
std::vector<LightClass*> GetLights() const { return m_Lights; }; std::vector<LightClass*> GetLights() const { return m_Lights; };
private: private:

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|Win32">
@ -118,12 +118,12 @@
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="reflection.ps" /> <None Include="reflection.ps" />
<None Include="reflection.vs" /> <None Include="reflection.vs" />
<FxCompile Include="specmap.ps"> <None Include="specmap.ps">
<FileType>Document</FileType> <FileType>Document</FileType>
</FxCompile> </None>
<FxCompile Include="specmap.vs"> <None Include="specmap.vs">
<FileType>Document</FileType> <FileType>Document</FileType>
</FxCompile> </None>
<None Include="texture.ps" /> <None Include="texture.ps" />
<None Include="texture.vs" /> <None Include="texture.vs" />
</ItemGroup> </ItemGroup>

View File

@ -14,3 +14,7 @@ Size=492,353
Pos=892,19 Pos=892,19
Size=418,94 Size=418,94
[Window][Light]
Pos=70,378
Size=418,240

View File

@ -216,8 +216,8 @@ void imguiManager::WidgetLightWindow(ApplicationClass* app)
std::string headerName = "Light " + std::to_string(index); std::string headerName = "Light " + std::to_string(index);
if (ImGui::CollapsingHeader(headerName.c_str())) if (ImGui::CollapsingHeader(headerName.c_str()))
{ {
XMVECTOR position = light->GetPosition(); XMVECTOR position = app->GetLightPosition(index);
XMVECTOR color = light->GetColor(); XMVECTOR color = app->GetLightColor(index);
float pos[3] = { XMVectorGetX(position), XMVectorGetY(position), XMVectorGetZ(position) }; float pos[3] = { XMVectorGetX(position), XMVectorGetY(position), XMVectorGetZ(position) };
float col[3] = { XMVectorGetX(color), XMVectorGetY(color), XMVectorGetZ(color) }; 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)) 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)) 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(); ImGui::Separator();
@ -246,7 +246,7 @@ void imguiManager::WidgetLightWindow(ApplicationClass* app)
ImGui::Separator(); ImGui::Separator();
} }
index++; index++;
}) };
ImGui::End(); ImGui::End();
} }