Minor - ImGui Use ECS - V12.4.0
This commit is contained in:
parent
8f0e583c62
commit
ddf5ea30a6
@ -53,7 +53,7 @@ DockId=0x00000006,0
|
|||||||
[Docking][Data]
|
[Docking][Data]
|
||||||
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,19 Size=1584,842 Split=Y
|
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,19 Size=1584,842 Split=Y
|
||||||
DockNode ID=0x00000003 Parent=0xCCBD8CF7 SizeRef=1584,609 Split=X
|
DockNode ID=0x00000003 Parent=0xCCBD8CF7 SizeRef=1584,609 Split=X
|
||||||
DockNode ID=0x0000000B Parent=0x00000003 SizeRef=234,842 Selected=0x321620B2
|
DockNode ID=0x0000000B Parent=0x00000003 SizeRef=234,842 Selected=0x031DC75C
|
||||||
DockNode ID=0x0000000C Parent=0x00000003 SizeRef=1348,842 Split=X
|
DockNode ID=0x0000000C Parent=0x00000003 SizeRef=1348,842 Split=X
|
||||||
DockNode ID=0x00000007 Parent=0x0000000C SizeRef=266,842 Selected=0x393905AB
|
DockNode ID=0x00000007 Parent=0x0000000C SizeRef=266,842 Selected=0x393905AB
|
||||||
DockNode ID=0x00000008 Parent=0x0000000C SizeRef=1316,842 Split=X
|
DockNode ID=0x00000008 Parent=0x0000000C SizeRef=1316,842 Split=X
|
||||||
|
@ -173,6 +173,8 @@ public:
|
|||||||
stats* get_stats() const { return stats_; };
|
stats* get_stats() const { return stats_; };
|
||||||
fps_class* get_fps() const { return fps_; };
|
fps_class* get_fps() const { return fps_; };
|
||||||
|
|
||||||
|
ecs::EntityManager* get_entity_manager() const { return entity_manager_.get(); };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool render(float, float, float, float, float);
|
bool render(float, float, float, float, float);
|
||||||
bool render_physics(float delta_time);
|
bool render_physics(float delta_time);
|
||||||
|
@ -386,47 +386,65 @@ void imguiManager::WidgetAddObject()
|
|||||||
|
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::Text("Number of cubes: %d", app_->get_cube_count());
|
ImGui::Text("Number of cubes: %d", 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void imguiManager::WidgetObjectWindow()
|
void imguiManager::WidgetObjectWindow()
|
||||||
{
|
{
|
||||||
ImGui::Begin("Objects", &showObjectWindow);
|
ImGui::Begin("Objects", &showObjectWindow);
|
||||||
|
|
||||||
|
// Obtenir toutes les entités avec un composant d'identité et de transformation
|
||||||
|
auto entities = app_->get_entity_manager()->GetEntitiesWithComponent<ecs::IdentityComponent>();
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (auto& object : app_->get_kobjects())
|
for (auto& entity : entities)
|
||||||
{
|
{
|
||||||
std::string headerName = object->GetName() + " " + std::to_string(index);
|
auto identity = entity->GetComponent<ecs::IdentityComponent>();
|
||||||
|
auto transform = entity->GetComponent<ecs::TransformComponent>();
|
||||||
|
auto render = entity->GetComponent<ecs::RenderComponent>();
|
||||||
|
auto shader = entity->GetComponent<ecs::ShaderComponent>();
|
||||||
|
auto physics = entity->GetComponent<ecs::PhysicsComponent>();
|
||||||
|
|
||||||
|
if (identity && transform)
|
||||||
|
{
|
||||||
|
std::string headerName = identity->GetName() + " " + std::to_string(identity->GetId());
|
||||||
if (ImGui::CollapsingHeader(headerName.c_str()))
|
if (ImGui::CollapsingHeader(headerName.c_str()))
|
||||||
{
|
{
|
||||||
|
// Position, Rotation, Scale
|
||||||
XMVECTOR position = object->GetPosition();
|
XMVECTOR position = transform->GetPosition();
|
||||||
XMVECTOR rotation = object->GetRotation();
|
XMVECTOR rotation = transform->GetRotation();
|
||||||
XMVECTOR scale = object->GetScale();
|
XMVECTOR scale = transform->GetScale();
|
||||||
|
|
||||||
float pos[3] = { XMVectorGetX(position), XMVectorGetY(position), XMVectorGetZ(position) };
|
float pos[3] = { XMVectorGetX(position), XMVectorGetY(position), XMVectorGetZ(position) };
|
||||||
std::string posLabel = "Position##" + std::to_string(index);
|
std::string posLabel = "Position##" + std::to_string(identity->GetId());
|
||||||
if (ImGui::DragFloat3(posLabel.c_str(), pos))
|
if (ImGui::DragFloat3(posLabel.c_str(), pos))
|
||||||
{
|
{
|
||||||
object->SetPosition(XMVectorSet(pos[0], pos[1], pos[2], 0.0f));
|
transform->SetPosition(XMVectorSet(pos[0], pos[1], pos[2], 0.0f));
|
||||||
|
transform->UpdateWorldMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
float rot[3] = { XMVectorGetX(rotation), XMVectorGetY(rotation), XMVectorGetZ(rotation) };
|
float rot[3] = { XMVectorGetX(rotation), XMVectorGetY(rotation), XMVectorGetZ(rotation) };
|
||||||
std::string rotLabel = "Rotation##" + std::to_string(index);
|
std::string rotLabel = "Rotation##" + std::to_string(identity->GetId());
|
||||||
if (ImGui::DragFloat3(rotLabel.c_str(), rot))
|
if (ImGui::DragFloat3(rotLabel.c_str(), rot))
|
||||||
{
|
{
|
||||||
object->SetRotation(XMVectorSet(rot[0], rot[1], rot[2], 0.0f));
|
transform->SetRotation(XMVectorSet(rot[0], rot[1], rot[2], 0.0f));
|
||||||
|
transform->UpdateWorldMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
float scl[3] = { XMVectorGetX(scale), XMVectorGetY(scale), XMVectorGetZ(scale) };
|
float scl[3] = { XMVectorGetX(scale), XMVectorGetY(scale), XMVectorGetZ(scale) };
|
||||||
std::string sclLabel = "Scale##" + std::to_string(index);
|
std::string sclLabel = "Scale##" + std::to_string(identity->GetId());
|
||||||
if (ImGui::DragFloat3(sclLabel.c_str(), scl))
|
if (ImGui::DragFloat3(sclLabel.c_str(), scl))
|
||||||
{
|
{
|
||||||
object->SetScale(XMVectorSet(scl[0], scl[1], scl[2], 0.0f));
|
transform->SetScale(XMVectorSet(scl[0], scl[1], scl[2], 0.0f));
|
||||||
|
transform->UpdateWorldMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
|
// Textures - Seulement si le composant de rendu existe
|
||||||
|
if (render && render->GetModel())
|
||||||
|
{
|
||||||
// Définir les types de textures_
|
// Définir les types de textures_
|
||||||
std::vector<std::string> textureCategories = {
|
std::vector<std::string> textureCategories = {
|
||||||
"Diffuse", "Normal", "Specular", "Alpha"
|
"Diffuse", "Normal", "Specular", "Alpha"
|
||||||
@ -438,7 +456,8 @@ void imguiManager::WidgetObjectWindow()
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Créer un espace pour afficher les textures_ avec défilement
|
// Créer un espace pour afficher les textures_ avec défilement
|
||||||
ImGui::BeginChild("TextureChild", ImVec2(0, 200), true, ImGuiWindowFlags_HorizontalScrollbar);
|
std::string textureChildId = "TextureChild##" + std::to_string(identity->GetId());
|
||||||
|
ImGui::BeginChild(textureChildId.c_str(), ImVec2(0, 200), true, ImGuiWindowFlags_HorizontalScrollbar);
|
||||||
|
|
||||||
// Pour chaque type de texture
|
// Pour chaque type de texture
|
||||||
for (int typeIndex = 0; typeIndex < textureCategories.size(); typeIndex++)
|
for (int typeIndex = 0; typeIndex < textureCategories.size(); typeIndex++)
|
||||||
@ -447,25 +466,27 @@ void imguiManager::WidgetObjectWindow()
|
|||||||
std::string typeName = textureCategories[typeIndex];
|
std::string typeName = textureCategories[typeIndex];
|
||||||
|
|
||||||
// Afficher le titre de la catégorie
|
// Afficher le titre de la catégorie
|
||||||
|
std::string categoryLabel = typeName + "##" + std::to_string(identity->GetId());
|
||||||
ImGui::Text("%s:", typeName.c_str());
|
ImGui::Text("%s:", typeName.c_str());
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
// Compter combien de textures_ de ce type existent
|
// Compter combien de textures_ de ce type existent
|
||||||
int textureCount = 0;
|
int textureCount = 0;
|
||||||
while (object->get_model()->GetTexture(type, textureCount) != nullptr)
|
while (render->GetModel()->GetTexture(type, textureCount) != nullptr)
|
||||||
{
|
{
|
||||||
textureCount++;
|
textureCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Afficher toutes les textures_ existantes
|
// Afficher toutes les textures_ existantes
|
||||||
|
std::string groupId = "TextureGroup_" + std::to_string(identity->GetId()) + "_" + std::to_string(typeIndex);
|
||||||
ImGui::BeginGroup();
|
ImGui::BeginGroup();
|
||||||
for (int texIndex = 0; texIndex < textureCount; texIndex++)
|
for (int texIndex = 0; texIndex < textureCount; texIndex++)
|
||||||
{
|
{
|
||||||
ID3D11ShaderResourceView* texture = object->get_model()->GetTexture(type, texIndex);
|
ID3D11ShaderResourceView* texture = render->GetModel()->GetTexture(type, texIndex);
|
||||||
if (texture)
|
if (texture)
|
||||||
{
|
{
|
||||||
// ID unique pour chaque bouton de texture
|
// ID unique pour chaque bouton de texture
|
||||||
std::string buttonId = "tex##" + std::to_string(index) + "_" +
|
std::string buttonId = "tex##" + std::to_string(identity->GetId()) + "_" +
|
||||||
std::to_string(typeIndex) + "_" +
|
std::to_string(typeIndex) + "_" +
|
||||||
std::to_string(texIndex);
|
std::to_string(texIndex);
|
||||||
|
|
||||||
@ -473,12 +494,11 @@ void imguiManager::WidgetObjectWindow()
|
|||||||
{
|
{
|
||||||
// Ouvrir une boîte de dialogue pour changer la texture
|
// Ouvrir une boîte de dialogue pour changer la texture
|
||||||
OPENFILENAME ofn;
|
OPENFILENAME ofn;
|
||||||
WCHAR szFile[260];
|
WCHAR szFile[260] = {0};
|
||||||
ZeroMemory(&ofn, sizeof(ofn));
|
ZeroMemory(&ofn, sizeof(ofn));
|
||||||
ofn.lStructSize = sizeof(ofn);
|
ofn.lStructSize = sizeof(ofn);
|
||||||
ofn.hwndOwner = NULL;
|
ofn.hwndOwner = NULL;
|
||||||
ofn.lpstrFile = szFile;
|
ofn.lpstrFile = szFile;
|
||||||
szFile[0] = '\0';
|
|
||||||
ofn.nMaxFile = sizeof(szFile);
|
ofn.nMaxFile = sizeof(szFile);
|
||||||
ofn.lpstrFilter = L"Texture\0*.png;*.jpg;*.dds\0";
|
ofn.lpstrFilter = L"Texture\0*.png;*.jpg;*.dds\0";
|
||||||
ofn.nFilterIndex = 1;
|
ofn.nFilterIndex = 1;
|
||||||
@ -488,7 +508,7 @@ void imguiManager::WidgetObjectWindow()
|
|||||||
if (GetOpenFileName(&ofn))
|
if (GetOpenFileName(&ofn))
|
||||||
{
|
{
|
||||||
// Changer la texture existante
|
// Changer la texture existante
|
||||||
object->get_model()->ChangeTexture(m_device, m_deviceContext, ofn.lpstrFile, type, texIndex);
|
render->GetModel()->ChangeTexture(m_device, m_deviceContext, ofn.lpstrFile, type, texIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,17 +526,16 @@ void imguiManager::WidgetObjectWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bouton pour ajouter une nouvelle texture
|
// Bouton pour ajouter une nouvelle texture
|
||||||
std::string addButtonLabel = "+##" + std::to_string(index) + "_" + std::to_string(typeIndex);
|
std::string addButtonLabel = "+##" + std::to_string(identity->GetId()) + "_" + std::to_string(typeIndex);
|
||||||
if (ImGui::Button(addButtonLabel.c_str(), ImVec2(48, 48)))
|
if (ImGui::Button(addButtonLabel.c_str(), ImVec2(48, 48)))
|
||||||
{
|
{
|
||||||
// Ouvrir une boîte de dialogue pour ajouter une texture
|
// Ouvrir une boîte de dialogue pour ajouter une texture
|
||||||
OPENFILENAME ofn;
|
OPENFILENAME ofn;
|
||||||
WCHAR szFile[260];
|
WCHAR szFile[260] = {0};
|
||||||
ZeroMemory(&ofn, sizeof(ofn));
|
ZeroMemory(&ofn, sizeof(ofn));
|
||||||
ofn.lStructSize = sizeof(ofn);
|
ofn.lStructSize = sizeof(ofn);
|
||||||
ofn.hwndOwner = NULL;
|
ofn.hwndOwner = NULL;
|
||||||
ofn.lpstrFile = szFile;
|
ofn.lpstrFile = szFile;
|
||||||
szFile[0] = '\0';
|
|
||||||
ofn.nMaxFile = sizeof(szFile);
|
ofn.nMaxFile = sizeof(szFile);
|
||||||
ofn.lpstrFilter = L"Texture\0*.png;*.jpg;*.dds\0";
|
ofn.lpstrFilter = L"Texture\0*.png;*.jpg;*.dds\0";
|
||||||
ofn.nFilterIndex = 1;
|
ofn.nFilterIndex = 1;
|
||||||
@ -526,7 +545,7 @@ void imguiManager::WidgetObjectWindow()
|
|||||||
if (GetOpenFileName(&ofn))
|
if (GetOpenFileName(&ofn))
|
||||||
{
|
{
|
||||||
// Ajouter une nouvelle texture
|
// Ajouter une nouvelle texture
|
||||||
object->get_model()->AddTexture(m_device, m_deviceContext, ofn.lpstrFile, type);
|
render->GetModel()->AddTexture(m_device, m_deviceContext, ofn.lpstrFile, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -535,19 +554,25 @@ void imguiManager::WidgetObjectWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
|
||||||
ImGui::Separator();
|
|
||||||
|
|
||||||
// Delete button
|
|
||||||
std::string deleteLabel = "Delete##" + std::to_string(index);
|
|
||||||
if (ImGui::Button(deleteLabel.c_str()))
|
|
||||||
{
|
|
||||||
app_->delete_kobject(index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
// Liste des options
|
// Delete button
|
||||||
|
std::string deleteLabel = "Delete##" + std::to_string(identity->GetId());
|
||||||
|
if (ImGui::Button(deleteLabel.c_str()))
|
||||||
|
{
|
||||||
|
app_->delete_entity_by_id(identity->GetId());
|
||||||
|
// Sortir du boucle après suppression pour éviter des accès invalides
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
// Shader options
|
||||||
|
if (shader)
|
||||||
|
{
|
||||||
|
// Liste des options de shader
|
||||||
const char* shaderOptions[] = {
|
const char* shaderOptions[] = {
|
||||||
"Enable Global Lighting",
|
"Enable Global Lighting",
|
||||||
"Enable Lighting",
|
"Enable Lighting",
|
||||||
@ -557,30 +582,41 @@ void imguiManager::WidgetObjectWindow()
|
|||||||
"Enable Alpha Mapping"
|
"Enable Alpha Mapping"
|
||||||
};
|
};
|
||||||
|
|
||||||
ShaderType shaderTypes[] = {
|
std::vector<ecs::ShaderType> shaderTypes = {
|
||||||
ShaderType::SUNLIGHT,
|
ecs::ShaderType::SUNLIGHT,
|
||||||
ShaderType::LIGHTING,
|
ecs::ShaderType::LIGHTING,
|
||||||
ShaderType::CEL_SHADING,
|
ecs::ShaderType::CEL_SHADING,
|
||||||
ShaderType::NORMAL_MAPPING,
|
ecs::ShaderType::NORMAL_MAPPING,
|
||||||
ShaderType::SPECULAR_MAPPING,
|
ecs::ShaderType::SPECULAR_MAPPING,
|
||||||
ShaderType::ALPHA_MAPPING
|
ecs::ShaderType::ALPHA_MAPPING
|
||||||
};
|
};
|
||||||
|
|
||||||
// Variable pour stocker l'option sélectionnée
|
// Trouver l'index actuel du shader pour cette entité spécifique
|
||||||
static int currentShader = 0; // Index de l'option actuellement sélectionnée
|
int currentShader = 0;
|
||||||
|
ecs::ShaderType activeShader = shader->GetActiveShader();
|
||||||
|
for (size_t i = 0; i < shaderTypes.size(); i++)
|
||||||
|
{
|
||||||
|
if (shaderTypes[i] == activeShader)
|
||||||
|
{
|
||||||
|
currentShader = static_cast<int>(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Création du menu déroulant
|
// Création du menu déroulant avec un ID unique pour chaque entité
|
||||||
if (ImGui::BeginCombo("Shader Options", shaderOptions[currentShader]))
|
std::string shaderComboId = "Shader Options##" + std::to_string(identity->GetId());
|
||||||
|
if (ImGui::BeginCombo(shaderComboId.c_str(), shaderOptions[currentShader]))
|
||||||
{
|
{
|
||||||
for (int i = 0; i < IM_ARRAYSIZE(shaderOptions); i++)
|
for (int i = 0; i < IM_ARRAYSIZE(shaderOptions); i++)
|
||||||
{
|
{
|
||||||
// Crée une option sélectionnable pour chaque shader
|
// Crée une option sélectionnable pour chaque shader avec ID unique
|
||||||
|
std::string shaderSelectableId = std::to_string(i) + "##shader_" + std::to_string(identity->GetId());
|
||||||
bool isSelected = (currentShader == i);
|
bool isSelected = (currentShader == i);
|
||||||
if (ImGui::Selectable(shaderOptions[i], isSelected))
|
if (ImGui::Selectable(shaderOptions[i], isSelected))
|
||||||
{
|
{
|
||||||
// Met à jour l'option sélectionnée
|
// Met à jour l'option sélectionnée uniquement pour cette entité
|
||||||
currentShader = i;
|
currentShader = i;
|
||||||
object->SetActiveShader(shaderTypes[i]);
|
shader->SetActiveShader(shaderTypes[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si l'option sélectionnée est active, nous mettons en surbrillance
|
// Si l'option sélectionnée est active, nous mettons en surbrillance
|
||||||
@ -589,88 +625,75 @@ void imguiManager::WidgetObjectWindow()
|
|||||||
}
|
}
|
||||||
ImGui::EndCombo();
|
ImGui::EndCombo();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
// physics
|
// Physics
|
||||||
std::string physicsLabel = "physics##" + std::to_string(index);
|
bool isPhysicsEnabled = (physics != nullptr);
|
||||||
|
std::string physicsLabel = "Physics##" + std::to_string(identity->GetId());
|
||||||
|
|
||||||
if (ImGui::Checkbox(physicsLabel.c_str(), &m_isPhyiscsEnabled))
|
if (ImGui::Checkbox(physicsLabel.c_str(), &isPhysicsEnabled))
|
||||||
{
|
{
|
||||||
object->SetPhysicsEnabled(m_isPhyiscsEnabled);
|
if (isPhysicsEnabled && !physics)
|
||||||
|
{
|
||||||
|
// Ajouter un composant de physique
|
||||||
|
physics = entity->AddComponent<ecs::PhysicsComponent>();
|
||||||
|
physics->Initialize();
|
||||||
|
}
|
||||||
|
else if (!isPhysicsEnabled && physics)
|
||||||
|
{
|
||||||
|
// Retirer le composant de physique
|
||||||
|
entity->RemoveComponent<ecs::PhysicsComponent>();
|
||||||
|
physics = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (physics)
|
||||||
|
{
|
||||||
// Gravity Enabled checkbox
|
// Gravity Enabled checkbox
|
||||||
std::string gravityLabel = "Gravity##" + std::to_string(index);
|
bool gravityEnabled = physics->IsGravityEnabled();
|
||||||
if (ImGui::Checkbox(gravityLabel.c_str(), &object->m_gravityEnabled))
|
std::string gravityLabel = "Gravity##" + std::to_string(identity->GetId());
|
||||||
|
if (ImGui::Checkbox(gravityLabel.c_str(), &gravityEnabled))
|
||||||
{
|
{
|
||||||
object->SetGravityEnabled(object->m_gravityEnabled);
|
physics->SetGravityEnabled(gravityEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 3 radio buttons pour le type d'objet physique avec IDs uniques
|
||||||
|
std::string typeLabel = "Type##" + std::to_string(identity->GetId());
|
||||||
|
ecs::ObjectType type = identity->GetType();
|
||||||
|
|
||||||
// 3 radio button on the same line to set the ObjectType
|
if (ImGui::RadioButton(("None##" + std::to_string(identity->GetId())).c_str(),
|
||||||
std::string typeLabel = "Type##" + std::to_string(index);
|
type == ecs::ObjectType::Unknown))
|
||||||
ObjectType type = object->GetType();
|
|
||||||
if (ImGui::RadioButton("None", type == ObjectType::Unknown))
|
|
||||||
{
|
{
|
||||||
object->SetType(ObjectType::Unknown);
|
identity->SetType(ecs::ObjectType::Unknown);
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::RadioButton("Cube", type == ObjectType::Cube))
|
if (ImGui::RadioButton(("Cube##" + std::to_string(identity->GetId())).c_str(),
|
||||||
|
type == ecs::ObjectType::Cube))
|
||||||
{
|
{
|
||||||
object->SetType(ObjectType::Cube);
|
identity->SetType(ecs::ObjectType::Cube);
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::RadioButton("Sphere", type == ObjectType::Sphere))
|
if (ImGui::RadioButton(("Sphere##" + std::to_string(identity->GetId())).c_str(),
|
||||||
|
type == ecs::ObjectType::Sphere))
|
||||||
{
|
{
|
||||||
object->SetType(ObjectType::Sphere);
|
identity->SetType(ecs::ObjectType::Sphere);
|
||||||
}
|
|
||||||
|
|
||||||
// button to launch the object
|
|
||||||
std::string launchLabel = "Launch##" + std::to_string(index);
|
|
||||||
|
|
||||||
// paraeter to set the alpha, initial stretch and spring constant
|
|
||||||
float alpha = object->GetAlpha();
|
|
||||||
float initialStretch = object->GetInitialStretch();
|
|
||||||
float springConstant = object->GetSpringConstant();
|
|
||||||
if (ImGui::DragFloat("Alpha##" , &alpha, 0.01f, 0.0f, 1.0f))
|
|
||||||
{
|
|
||||||
object->SetAlpha(alpha);
|
|
||||||
}
|
|
||||||
if (ImGui::DragFloat("Initial Stretch##", &initialStretch, 0.01f, 0.0f, 1.0f))
|
|
||||||
{
|
|
||||||
object->SetInitialStretch(initialStretch);
|
|
||||||
}
|
|
||||||
if (ImGui::DragFloat("Spring Constant##", &springConstant, 0.01f, 0.0f, 100.0f))
|
|
||||||
{
|
|
||||||
object->SetSpringConstant(springConstant);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui::Button(launchLabel.c_str()))
|
|
||||||
{
|
|
||||||
object->LaunchObject();
|
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
// button to stop the object
|
if (ImGui::RadioButton(("Terrain##" + std::to_string(identity->GetId())).c_str(),
|
||||||
std::string stopLabel = "Stop##" + std::to_string(index);
|
type == ecs::ObjectType::Terrain))
|
||||||
if (ImGui::Button(stopLabel.c_str()))
|
|
||||||
{
|
{
|
||||||
object->SetVelocity(XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f));
|
identity->SetType(ecs::ObjectType::Terrain);
|
||||||
object->SetPosition(XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
// Demo spinning
|
|
||||||
std::string demoLabel = "Demo spinning##" + std::to_string(index);
|
|
||||||
ImGui::Checkbox(demoLabel.c_str(), &object->m_demoSpinning);
|
|
||||||
}
|
}
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
@ -679,7 +702,7 @@ void imguiManager::WidgetTerrainWindow()
|
|||||||
{
|
{
|
||||||
ImGui::Begin("Terrain", &showTerrainWindow);
|
ImGui::Begin("Terrain", &showTerrainWindow);
|
||||||
|
|
||||||
ImGui::Text("Number of terrain cubes: %d", app_->get_terrain_cube_count());
|
ImGui::Text("Number of terrain cubes: %d", 1);
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
@ -1107,3 +1130,4 @@ void imguiManager::WidgetRenderStats()
|
|||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ bool scene_manager::save_scene_as() {
|
|||||||
|
|
||||||
// Mettre à jour le chemin de scène
|
// Mettre à jour le chemin de scène
|
||||||
scene_path_ = convert_w_string_to_string(filepath.wstring());
|
scene_path_ = convert_w_string_to_string(filepath.wstring());
|
||||||
object_vec_ = app_->get_kobjects();
|
//object_vec_ = app_->get_kobjects();
|
||||||
|
|
||||||
// Sauvegarder la scène avec le nouveau chemin
|
// Sauvegarder la scène avec le nouveau chemin
|
||||||
save_scene();
|
save_scene();
|
||||||
@ -67,7 +67,7 @@ bool scene_manager::save_scene_as() {
|
|||||||
bool scene_manager::load_scene() {
|
bool scene_manager::load_scene() {
|
||||||
Logger::Get().Log("Loading scene from " , __FILE__, __LINE__, Logger::LogLevel::Info);
|
Logger::Get().Log("Loading scene from " , __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||||
|
|
||||||
object_vec_ = app_->get_kobjects();
|
//object_vec_ = app_->get_kobjects();
|
||||||
object_id_ = app_->get_object_id();
|
object_id_ = app_->get_object_id();
|
||||||
w_folder_ = app_->get_w_folder();
|
w_folder_ = app_->get_w_folder();
|
||||||
direct_3d_ = app_->get_direct_3d();
|
direct_3d_ = app_->get_direct_3d();
|
||||||
@ -230,7 +230,7 @@ bool scene_manager::load_scene() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// pass the vec to the application
|
// pass the vec to the application
|
||||||
app_->set_kobjects(object_vec_);
|
//app_->set_kobjects(object_vec_);
|
||||||
|
|
||||||
Logger::Get().Log("Scene loaded successfully from ", __FILE__, __LINE__, Logger::LogLevel::Info);
|
Logger::Get().Log("Scene loaded successfully from ", __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||||
return true;
|
return true;
|
||||||
|
@ -37,9 +37,9 @@ bool stats::initialize(application_class* app)
|
|||||||
void stats::update_geometric_stats()
|
void stats::update_geometric_stats()
|
||||||
{
|
{
|
||||||
|
|
||||||
object_vec_ = app_->get_kobjects();
|
// object_vec_ = app_->get_kobjects();
|
||||||
cubes_vec_ = app_->get_cubes();
|
// cubes_vec_ = app_->get_cubes();
|
||||||
terrain_chunk_vec_ = app_->get_terrain_cubes();
|
// terrain_chunk_vec_ = app_->get_terrain_cubes();
|
||||||
|
|
||||||
|
|
||||||
*total_vertex_count_ = get_total_vertex_count();
|
*total_vertex_count_ = get_total_vertex_count();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user