Minor - Improves scene editor and adds audio support - V13.1.0
Improves the scene editor by adding an inspector window to view and modify entity components. Adds audio component support with basic playback controls integrated into the inspector. Adds default audio files.
This commit is contained in:
20
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
20
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
@@ -5,13 +5,18 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/audio_component.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj.filters" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj.filters" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/application_class.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/application_class.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/ComponentFactory.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/ComponentFactory.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/Main.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/Main.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/component.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/component.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/audio_component.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/audio_component.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/identity_component.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/identity_component.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/model_path_component.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/model_path_component.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/physics_component.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/physics_component.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/render_component.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/render_component.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/shader_component.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/shader_component.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/transform_component.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/transform_component.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/entity_manager.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/ecs/entity_manager.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/imguiManager.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/imguiManager.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/imguiManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/imguiManager.cpp" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -250,6 +255,9 @@
|
||||
<workItem from="1757182479393" duration="1386000" />
|
||||
<workItem from="1757427950015" duration="2864000" />
|
||||
<workItem from="1757431548883" duration="986000" />
|
||||
<workItem from="1757449929378" duration="1107000" />
|
||||
<workItem from="1757456559331" duration="2094000" />
|
||||
<workItem from="1757458683204" duration="3628000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Minor update - viewport window tweak">
|
||||
<option name="closed" value="true" />
|
||||
|
BIN
enginecustom/assets/sounds/default.mp3
Normal file
BIN
enginecustom/assets/sounds/default.mp3
Normal file
Binary file not shown.
BIN
enginecustom/assets/sounds/default.opus
Normal file
BIN
enginecustom/assets/sounds/default.opus
Normal file
Binary file not shown.
@@ -2,6 +2,7 @@
|
||||
#include <memory>
|
||||
#include <typeindex>
|
||||
#include <typeinfo>
|
||||
#include <imgui.h>
|
||||
|
||||
/**
|
||||
* namespace for the Entity-Component-System (ECS)
|
||||
@@ -46,6 +47,12 @@ public:
|
||||
*/
|
||||
virtual bool Deserialize(const std::string& data) { return false;}
|
||||
|
||||
/**
|
||||
* Virtual function to render ImGui controls for the component.
|
||||
* This can be overridden by derived components to provide custom UI.
|
||||
*/
|
||||
virtual void OnImGuiRender() { /* Default implementation does nothing */ }
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
@@ -1,8 +1,9 @@
|
||||
// AudioComponent.h
|
||||
#pragma once
|
||||
#include "ecs/component.h"
|
||||
#include "../component.h"
|
||||
#include <Fmod/core/inc/fmod.hpp>
|
||||
#include <string>
|
||||
#include <filesystem>
|
||||
|
||||
namespace ecs {
|
||||
class AudioComponent : public Component {
|
||||
@@ -10,11 +11,59 @@ public:
|
||||
AudioComponent() : m_system(nullptr), m_sound(nullptr), m_channel(nullptr) {}
|
||||
~AudioComponent() override {
|
||||
if (m_sound) m_sound->release();
|
||||
// Ne pas lib<69>rer m_system ici car il peut <20>tre partag<61>
|
||||
}
|
||||
|
||||
bool Load(FMOD::System* system, const std::string& path) {
|
||||
m_system = system;
|
||||
return m_system->createSound(path.c_str(), FMOD_DEFAULT, nullptr, &m_sound) == FMOD_OK;
|
||||
void Initialize() override
|
||||
{
|
||||
// create FMOD system if not already created
|
||||
if (!m_system)
|
||||
{
|
||||
FMOD_RESULT result = FMOD::System_Create(&m_system);
|
||||
if (result != FMOD_OK) {
|
||||
m_lastError = "<EFBFBD>chec de la cr<63>ation du syst<73>me FMOD: " + std::to_string(result);
|
||||
return;
|
||||
}
|
||||
|
||||
result = m_system->init(512, FMOD_INIT_NORMAL, nullptr);
|
||||
if (result != FMOD_OK) {
|
||||
m_lastError = "<EFBFBD>chec de l'initialisation du syst<73>me FMOD: " + std::to_string(result);
|
||||
m_system->release();
|
||||
m_system = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Load(const std::string& path) {
|
||||
if (!m_system) {
|
||||
Initialize();
|
||||
if (!m_system) return false; // L'erreur est d<>j<EFBFBD> d<>finie dans Initialize()
|
||||
}
|
||||
|
||||
m_soundPath = path;
|
||||
|
||||
// V<>rifier si le fichier existe
|
||||
if (!std::filesystem::exists(path)) {
|
||||
m_lastError = "Fichier non trouv<75>: " + path;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Lib<69>rer le son pr<70>c<EFBFBD>dent s'il existe
|
||||
if (m_sound) {
|
||||
m_sound->release();
|
||||
m_sound = nullptr;
|
||||
}
|
||||
|
||||
// Essayer de charger avec le chemin absolu
|
||||
std::filesystem::path absolutePath = std::filesystem::absolute(path);
|
||||
FMOD_RESULT result = m_system->createSound(absolutePath.string().c_str(), FMOD_DEFAULT, nullptr, &m_sound);
|
||||
if (result != FMOD_OK) {
|
||||
m_lastError = "<EFBFBD>chec du chargement du son: " + std::to_string(result) +
|
||||
" (chemin: " + absolutePath.string() + ")";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Play() {
|
||||
@@ -27,9 +76,44 @@ public:
|
||||
m_channel->stop();
|
||||
}
|
||||
|
||||
void OnImGuiRender() override {
|
||||
// Afficher le r<>pertoire de travail actuel
|
||||
std::string currentDir = std::filesystem::current_path().string();
|
||||
ImGui::Text("R<EFBFBD>pertoire actuel: %s", currentDir.c_str());
|
||||
|
||||
if (m_sound) {
|
||||
ImGui::Text("Son charg<72>: %s", m_soundPath.c_str());
|
||||
if (ImGui::Button("Jouer")) {
|
||||
Play();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Arr<EFBFBD>ter")) {
|
||||
Stop();
|
||||
}
|
||||
} else {
|
||||
ImGui::Text("Aucun son charg<72>");
|
||||
|
||||
// Montrer l'erreur s'il y en a une
|
||||
if (!m_lastError.empty()) {
|
||||
ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), "Erreur: %s", m_lastError.c_str());
|
||||
}
|
||||
|
||||
static char path[256] = "F:/Github_Repo/khaotic-engine-Reborn/x64/Release/assets/sounds/default.mp3";
|
||||
ImGui::InputText("Chemin du fichier", path, sizeof(path));
|
||||
|
||||
if (ImGui::Button("Charger le son")) {
|
||||
if (!Load(path)) {
|
||||
// L'erreur est d<>j<EFBFBD> d<>finie dans Load()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
FMOD::System* m_system;
|
||||
FMOD::Sound* m_sound;
|
||||
FMOD::Channel* m_channel;
|
||||
std::string m_soundPath;
|
||||
std::string m_lastError;
|
||||
};
|
||||
}
|
||||
|
@@ -134,6 +134,20 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnImGuiRender() override {
|
||||
ImGui::Text("ID: %d", m_id);
|
||||
char nameBuffer[256];
|
||||
strncpy_s(nameBuffer, m_name.c_str(), sizeof(nameBuffer));
|
||||
if (ImGui::InputText("#Name", nameBuffer, sizeof(nameBuffer))) {
|
||||
m_name = std::string(nameBuffer);
|
||||
}
|
||||
|
||||
const char* objectTypes[] = { "Unknown", "Cube", "Sphere", "Terrain" };
|
||||
int currentTypeIndex = static_cast<int>(m_type);
|
||||
if (ImGui::Combo("Object Type", ¤tTypeIndex, objectTypes, IM_ARRAYSIZE(objectTypes))) {
|
||||
m_type = static_cast<ObjectType>(currentTypeIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
int m_id; // ID unique de l'objet
|
||||
|
@@ -55,6 +55,16 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnImGuiRender() override {
|
||||
char path[260];
|
||||
std::string currentPath = convert_w_string_to_string(m_path);
|
||||
strcpy_s(path, currentPath.c_str());
|
||||
|
||||
if (ImGui::InputText("Model Path", path, sizeof(path))) {
|
||||
SetPath(std::wstring(path, path + strlen(path)));
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::wstring m_path;
|
||||
};
|
||||
|
@@ -233,6 +233,45 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnImGuiRender() override {
|
||||
float mass = GetMass();
|
||||
if (ImGui::DragFloat("Mass", &mass, 0.1f, 0.1f, 100.0f)) {
|
||||
SetMass(mass);
|
||||
}
|
||||
|
||||
float radius = GetBoundingRadius();
|
||||
if (ImGui::DragFloat("Bounding Radius", &radius, 0.1f, 0.1f, 100.0f)) {
|
||||
SetBoundingRadius(radius);
|
||||
}
|
||||
|
||||
bool physicsEnabled = IsPhysicsEnabled();
|
||||
if (ImGui::Checkbox("Physics Enabled", &physicsEnabled)) {
|
||||
SetPhysicsEnabled(physicsEnabled);
|
||||
}
|
||||
|
||||
bool gravityEnabled = IsGravityEnabled();
|
||||
if (ImGui::Checkbox("Gravity Enabled", &gravityEnabled)) {
|
||||
SetGravityEnabled(gravityEnabled);
|
||||
}
|
||||
|
||||
bool isGrounded = IsGrounded();
|
||||
if (ImGui::Checkbox("Is Grounded", &isGrounded)) {
|
||||
SetGrounded(isGrounded);
|
||||
}
|
||||
|
||||
XMFLOAT3 velocity;
|
||||
XMStoreFloat3(&velocity, GetVelocity());
|
||||
if (ImGui::DragFloat3("Velocity", &velocity.x, 0.1f)) {
|
||||
SetVelocity(XMLoadFloat3(&velocity));
|
||||
}
|
||||
|
||||
XMFLOAT3 acceleration;
|
||||
XMStoreFloat3(&acceleration, GetAcceleration());
|
||||
if (ImGui::DragFloat3("Acceleration", &acceleration.x, 0.1f)) {
|
||||
SetAcceleration(XMLoadFloat3(&acceleration));
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
XMVECTOR m_Velocity;
|
||||
XMVECTOR m_Acceleration;
|
||||
|
@@ -208,6 +208,16 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnImGuiRender() override {
|
||||
ImGui::Checkbox("Visible", &m_isVisible);
|
||||
ImGui::Text("Model File Path: %s", m_modelFilePath.c_str());
|
||||
if (m_model) {
|
||||
ImGui::Text("Index Count: %d", m_model->GetIndexCount());
|
||||
} else {
|
||||
ImGui::Text("No model loaded.");
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<model_class> m_model;
|
||||
std::string m_modelFilePath;
|
||||
|
@@ -110,6 +110,27 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnImGuiRender() override {
|
||||
ShaderType currentShader = GetActiveShader();
|
||||
int shaderIndex = static_cast<int>(currentShader);
|
||||
const char* shaderNames[] = {
|
||||
"CEL_SHADING",
|
||||
"LIGHTING",
|
||||
"NORMAL_MAPPING",
|
||||
"SPECULAR_MAPPING",
|
||||
"REFLECTION",
|
||||
"REFRACTION",
|
||||
"TEXTURE",
|
||||
"SKYBOX",
|
||||
"SUNLIGHT",
|
||||
"ALPHA_MAPPING"
|
||||
};
|
||||
|
||||
if (ImGui::Combo("Active Shader", &shaderIndex, shaderNames, IM_ARRAYSIZE(shaderNames))) {
|
||||
SetActiveShader(static_cast<ShaderType>(shaderIndex));
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
ShaderType m_activeShader;
|
||||
};
|
||||
|
@@ -197,6 +197,26 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnImGuiRender() override {
|
||||
XMFLOAT3 position, rotation, scale;
|
||||
XMStoreFloat3(&position, GetPosition());
|
||||
XMStoreFloat3(&rotation, GetRotation());
|
||||
XMStoreFloat3(&scale, GetScale());
|
||||
|
||||
if (ImGui::DragFloat3("Position", &position.x, 0.1f)) {
|
||||
SetPosition(XMLoadFloat3(&position));
|
||||
}
|
||||
|
||||
if (ImGui::DragFloat3("Rotation", &rotation.x, 0.01f)) {
|
||||
SetRotation(XMLoadFloat3(&rotation));
|
||||
}
|
||||
|
||||
if (ImGui::DragFloat3("Scale", &scale.x, 0.1f, 0.01f, 100.0f)) {
|
||||
SetScale(XMLoadFloat3(&scale));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
XMMATRIX m_ScaleMatrix;
|
||||
XMMATRIX m_RotateMatrix;
|
||||
|
@@ -128,6 +128,22 @@ public:
|
||||
m_NextEntityID = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get entity by ID (const version).
|
||||
* @param id The ID of the entity to retrieve.
|
||||
* @return A shared pointer to the entity, or nullptr if it does not exist.
|
||||
*/
|
||||
std::shared_ptr<Entity> GetEntityByID(EntityID entityID)
|
||||
{
|
||||
if (entityID < m_Entities.size())
|
||||
{
|
||||
return m_Entities[entityID];
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
EntityID m_NextEntityID;
|
||||
std::unordered_map<EntityID, std::shared_ptr<Entity>> m_Entities;
|
||||
|
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "render_texture_class.h"
|
||||
#include "scene_manager.h"
|
||||
#include "ecs/entity_manager.h"
|
||||
|
||||
class application_class;
|
||||
class stats;
|
||||
@@ -87,7 +88,7 @@ public:
|
||||
void WidgetAddObject();
|
||||
|
||||
/**
|
||||
* create a window to display the object list and their properties.
|
||||
* create a window to display the object list and allow to add objects to the scene.
|
||||
*/
|
||||
void WidgetObjectWindow();
|
||||
/**
|
||||
@@ -124,6 +125,12 @@ public:
|
||||
*/
|
||||
bool ImGuiWidgetRenderer();
|
||||
|
||||
/**
|
||||
* Create a window to display the inspector.
|
||||
* This window shows the components of the selected entity and allows to edit them.
|
||||
*/
|
||||
void WidgetInspectorWindow();
|
||||
|
||||
/**
|
||||
* set the Old scene window size.
|
||||
* @param size
|
||||
@@ -160,6 +167,7 @@ private:
|
||||
std::shared_ptr<application_class> app_;
|
||||
scene_manager* scene_manager_;
|
||||
stats* stats_;
|
||||
ecs::EntityManager* entity_manager_;
|
||||
|
||||
bool showObjectWindow;
|
||||
bool showTerrainWindow;
|
||||
@@ -168,6 +176,7 @@ private:
|
||||
bool showEngineSettingsWindow;
|
||||
bool showLogWindow;
|
||||
bool showStatsWindow;
|
||||
bool show_inspector_window_;
|
||||
|
||||
int m_SideCount = 0;
|
||||
|
||||
@@ -201,6 +210,8 @@ private:
|
||||
// cpu information
|
||||
std::string cpu_name_;
|
||||
std::string version_driver_;
|
||||
|
||||
ecs::EntityID m_selected_entity_id = 0; // ID of the currently selected entity
|
||||
};
|
||||
|
||||
#endif
|
@@ -25,8 +25,9 @@ imguiManager::imguiManager()
|
||||
showEngineSettingsWindow = false;
|
||||
showLogWindow = false;
|
||||
showStatsWindow = false;
|
||||
show_inspector_window_ = false;
|
||||
|
||||
// Initialiser l'historique des frametimes <20> z<>ro
|
||||
// Initialiser l'historique des frametimes <20> z<>ro
|
||||
for (int i = 0; i < FRAME_HISTORY_COUNT; i++)
|
||||
{
|
||||
m_frameTimeHistory[i] = 0.0f;
|
||||
@@ -39,7 +40,8 @@ imguiManager::imguiManager()
|
||||
{&showLightWindow, [&](){WidgetLightWindow();}},
|
||||
{&showLogWindow, [&](){WidgetLogWindow();}},
|
||||
{&showOldSceneWindow, [&](){WidgetRenderWindow(ImVec2(800, 600));}},
|
||||
{&showStatsWindow, [&](){WidgetRenderStats();}}
|
||||
{&showStatsWindow, [&](){WidgetRenderStats();}},
|
||||
{&show_inspector_window_, [&](){WidgetInspectorWindow();}}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -64,14 +66,14 @@ bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceConte
|
||||
ImGui_ImplWin32_Init(hwnd);
|
||||
ImGui_ImplDX11_Init(m_device, m_deviceContext);
|
||||
|
||||
// Appliquer un th<74>me sombre de base
|
||||
// Appliquer un th<74>me sombre de base
|
||||
ImGui::StyleColorsDark();
|
||||
|
||||
// D<>finir les couleurs pour une interface de type <20>diteur sobre
|
||||
// D<>finir les couleurs pour une interface de type <20>diteur sobre
|
||||
ImGuiStyle& style = ImGui::GetStyle();
|
||||
|
||||
// Palette de couleurs sobres inspir<69>e des <20>diteurs modernes
|
||||
ImVec4 background_dark = ImVec4(0.10f, 0.10f, 0.10f, 1.00f); // Fond fonc<6E>
|
||||
// Palette de couleurs sobres inspir<69>e des <20>diteurs modernes
|
||||
ImVec4 background_dark = ImVec4(0.10f, 0.10f, 0.10f, 1.00f); // Fond fonc<6E>
|
||||
ImVec4 background = ImVec4(0.15f, 0.15f, 0.15f, 1.00f); // Fond principal
|
||||
ImVec4 background_light = ImVec4(0.20f, 0.20f, 0.20f, 1.00f); // Fond clair
|
||||
ImVec4 accent = ImVec4(0.14f, 0.44f, 0.80f, 0.50f); // Accent bleu
|
||||
@@ -79,8 +81,8 @@ bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceConte
|
||||
ImVec4 text = ImVec4(1.0f, 1.0f, 1.0f, 1.00f); // Texte plus blanc
|
||||
ImVec4 text_dim = ImVec4(0.70f, 0.70f, 0.70f, 1.00f);
|
||||
|
||||
// Ajustements de style g<>n<EFBFBD>raux
|
||||
style.WindowPadding = ImVec2(4.0f, 4.0f); // Moins de padding dans les fen<65>tres
|
||||
// Ajustements de style g<>n<EFBFBD>raux
|
||||
style.WindowPadding = ImVec2(4.0f, 4.0f); // Moins de padding dans les fen<65>tres
|
||||
style.FramePadding = ImVec2(4.0f, 3.0f); // Moins de padding dans les cadres
|
||||
style.ItemSpacing = ImVec2(4.0f, 3.0f); // Moins d'espace entre les widgets
|
||||
style.ItemInnerSpacing = ImVec2(3.0f, 3.0f); // Moins d'espace interne
|
||||
@@ -119,7 +121,7 @@ bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceConte
|
||||
style.Colors[ImGuiCol_TitleBgActive] = accent;
|
||||
style.Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.12f, 0.12f, 0.12f, 0.90f);
|
||||
|
||||
// <20>l<EFBFBD>ments de menu
|
||||
// <20>l<EFBFBD>ments de menu
|
||||
style.Colors[ImGuiCol_MenuBarBg] = background_dark;
|
||||
style.Colors[ImGuiCol_ScrollbarBg] = background_dark;
|
||||
style.Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.40f, 0.40f, 0.40f, 1.00f);
|
||||
@@ -134,7 +136,7 @@ bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceConte
|
||||
style.Colors[ImGuiCol_ButtonHovered] = ImVec4(0.30f, 0.30f, 0.30f, 1.00f);
|
||||
style.Colors[ImGuiCol_ButtonActive] = accent;
|
||||
|
||||
// En-t<>tes et onglets
|
||||
// En-t<>tes et onglets
|
||||
style.Colors[ImGuiCol_Header] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
|
||||
style.Colors[ImGuiCol_HeaderHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f);
|
||||
style.Colors[ImGuiCol_HeaderActive] = accent;
|
||||
@@ -149,21 +151,21 @@ bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceConte
|
||||
style.Colors[ImGuiCol_TabUnfocused] = background_dark;
|
||||
style.Colors[ImGuiCol_TabUnfocusedActive] = background;
|
||||
|
||||
// Autres <20>l<EFBFBD>ments
|
||||
// Autres <20>l<EFBFBD>ments
|
||||
style.Colors[ImGuiCol_DockingPreview] = accent;
|
||||
style.Colors[ImGuiCol_DockingEmptyBg] = background_light;
|
||||
|
||||
// Charger une police avec une meilleure nettet<65>
|
||||
// Charger une police avec une meilleure nettet<65>
|
||||
ImFontConfig fontConfig;
|
||||
fontConfig.OversampleH = 2; // Sur<75>chantillonnage horizontal
|
||||
fontConfig.OversampleV = 2; // Sur<75>chantillonnage vertical
|
||||
fontConfig.OversampleH = 2; // Sur<75>chantillonnage horizontal
|
||||
fontConfig.OversampleV = 2; // Sur<75>chantillonnage vertical
|
||||
fontConfig.PixelSnapH = true; // Alignement sur la grille de pixels
|
||||
fontConfig.RasterizerMultiply = 1.2f; // L<>g<EFBFBD>re augmentation de l'<27>paisseur
|
||||
fontConfig.RasterizerMultiply = 1.2f; // L<>g<EFBFBD>re augmentation de l'<27>paisseur
|
||||
io->Fonts->AddFontDefault(&fontConfig);
|
||||
|
||||
io->Fonts->Build();
|
||||
|
||||
// OU charger une police personnalis<69>e (d<>commenter si vous avez la police)
|
||||
// OU charger une police personnalis<69>e (d<>commenter si vous avez la police)
|
||||
// io->Fonts->AddFontFromFileTTF("assets/fonts/roboto.ttf", 16.0f, &fontConfig);
|
||||
|
||||
|
||||
@@ -183,6 +185,8 @@ bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceConte
|
||||
total_triangle_count_ = stats_->get_triangle_count_ptr();
|
||||
total_vertex_count_ = stats_->get_vertex_count_ptr();
|
||||
|
||||
entity_manager_ = app_->get_entity_manager();
|
||||
|
||||
Logger::Get().Log("imgui initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
|
||||
return true;
|
||||
@@ -218,15 +222,15 @@ void imguiManager::NewFrame()
|
||||
}
|
||||
|
||||
void imguiManager::SetupDockspace() {
|
||||
// Configuration du style pour supprimer l'espace autour des fen<65>tres dock<63>es
|
||||
// Configuration du style pour supprimer l'espace autour des fen<65>tres dock<63>es
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
|
||||
// Configuration du style pour les n<>uds de dock
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_DockingSeparatorSize, 1.0f); // R<>duit l'<27>paisseur des s<>parateurs
|
||||
// Configuration du style pour les n<>uds de dock
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_DockingSeparatorSize, 1.0f); // R<>duit l'<27>paisseur des s<>parateurs
|
||||
|
||||
// Configuration de la fen<65>tre principale
|
||||
// Configuration de la fen<65>tre principale
|
||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;
|
||||
ImGuiViewport* viewport = ImGui::GetMainViewport();
|
||||
ImGui::SetNextWindowPos(viewport->Pos);
|
||||
@@ -239,8 +243,8 @@ void imguiManager::SetupDockspace() {
|
||||
|
||||
ImGui::Begin("DockSpace", nullptr, window_flags);
|
||||
|
||||
// Pop des styles apr<70>s avoir cr<63><72> la fen<65>tre principale
|
||||
ImGui::PopStyleVar(4); // 4 car nous avons pouss<73> 4 variables de style
|
||||
// Pop des styles apr<70>s avoir cr<63><72> la fen<65>tre principale
|
||||
ImGui::PopStyleVar(4); // 4 car nous avons pouss<73> 4 variables de style
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
// Configuration du DockSpace
|
||||
@@ -363,15 +367,15 @@ void imguiManager::WidgetAddObject()
|
||||
|
||||
if (!CopyFile(filepath.c_str(), targetPath.c_str(), FALSE))
|
||||
{
|
||||
// En cas d'erreur, vous pouvez g<>rer ici l'erreur (par exemple afficher un message)
|
||||
// En cas d'erreur, vous pouvez g<>rer ici l'erreur (par exemple afficher un message)
|
||||
MessageBox(NULL, L"Erreur lors de la copie du fichier.", L"Erreur", MB_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
// On r<>cup<75>re le chemin relatif par rapport <20> exeDir
|
||||
// On r<>cup<75>re le chemin relatif par rapport <20> exeDir
|
||||
std::wstring relativePath = targetPath.substr(exeDir.size());
|
||||
|
||||
// Suppression du premier caract<63>re s'il s'agit d'un antislash
|
||||
// Suppression du premier caract<63>re s'il s'agit d'un antislash
|
||||
if (!relativePath.empty() && (relativePath[0] == L'\\' || relativePath[0] == L'/'))
|
||||
{
|
||||
relativePath.erase(0, 1);
|
||||
@@ -386,7 +390,7 @@ void imguiManager::WidgetAddObject()
|
||||
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("Number of cubes: %d", app_->get_entity_manager()->GetEntityCount());
|
||||
ImGui::Text("Number of cubes: %d", entity_manager_->GetEntityCount());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,305 +398,228 @@ void imguiManager::WidgetObjectWindow()
|
||||
{
|
||||
ImGui::Begin("Objects", &showObjectWindow);
|
||||
|
||||
// Obtenir toutes les entit<69>s avec un composant d'identit<69> et de transformation
|
||||
auto entities = app_->get_entity_manager()->GetEntitiesWithComponent<ecs::IdentityComponent>();
|
||||
if (ImGui::Button("Add Cube")) { app_->add_cube(); }
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Import Object"))
|
||||
{
|
||||
// Open file dialog
|
||||
OPENFILENAME ofn;
|
||||
WCHAR szFile[260];
|
||||
ZeroMemory(&ofn, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = NULL;
|
||||
ofn.lpstrFile = szFile;
|
||||
ofn.lpstrFile[0] = '\0';
|
||||
ofn.nMaxFile = sizeof(szFile);
|
||||
ofn.lpstrFilter = L"OBJ\0*.obj\0KOBJ\0*.kobj\0TXT\0*.txt";
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.lpstrFileTitle = NULL;
|
||||
ofn.nMaxFileTitle = 0;
|
||||
ofn.lpstrInitialDir = NULL;
|
||||
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
|
||||
|
||||
if (GetOpenFileName(&ofn))
|
||||
{
|
||||
std::wstring filepath = ofn.lpstrFile;
|
||||
|
||||
WCHAR exePath[MAX_PATH];
|
||||
GetModuleFileName(NULL,exePath,MAX_PATH);
|
||||
std::wstring exeDir = exePath;
|
||||
size_t pos = exeDir.find_last_of(L"\\/");
|
||||
if(pos != std::wstring::npos)
|
||||
{
|
||||
exeDir = exeDir.substr(0, pos);
|
||||
}
|
||||
|
||||
std::wstring targetDir = exeDir + L"\\Content\\Assets\\Kobject";
|
||||
|
||||
|
||||
DWORD ftyp = GetFileAttributesW(targetDir.c_str());
|
||||
if( ftyp == INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
std::wstring contentDir = exeDir + L"\\Content";
|
||||
if (GetFileAttributes(contentDir.c_str()) == INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
CreateDirectory(contentDir.c_str(), NULL);
|
||||
}
|
||||
std::wstring assetsDir = contentDir + L"\\Assets";
|
||||
if (GetFileAttributes(assetsDir.c_str()) == INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
CreateDirectory(assetsDir.c_str(), NULL);
|
||||
}
|
||||
std::wstring kobjectDir = assetsDir + L"\\Kobject";
|
||||
if (GetFileAttributes(kobjectDir.c_str()) == INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
CreateDirectory(kobjectDir.c_str(), NULL);
|
||||
}
|
||||
}
|
||||
|
||||
size_t posFile = filepath.find_last_of(L"\\/");
|
||||
std::wstring filename = (posFile != std::wstring::npos) ? filepath.substr(posFile + 1) : filepath;
|
||||
|
||||
std::wstring targetPath = targetDir + L"\\" + filename;
|
||||
|
||||
if (!CopyFile(filepath.c_str(), targetPath.c_str(), FALSE))
|
||||
{
|
||||
// En cas d'erreur, vous pouvez g<>rer ici l'erreur (par exemple afficher un message)
|
||||
MessageBox(NULL, L"Erreur lors de la copie du fichier.", L"Erreur", MB_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
// On r<>cup<75>re le chemin relatif par rapport <20> exeDir
|
||||
std::wstring relativePath = targetPath.substr(exeDir.size());
|
||||
|
||||
// Suppression du premier caract<63>re s'il s'agit d'un antislash
|
||||
if (!relativePath.empty() && (relativePath[0] == L'\\' || relativePath[0] == L'/'))
|
||||
{
|
||||
relativePath.erase(0, 1);
|
||||
}
|
||||
|
||||
// Remplacer les antislashs par des slashs
|
||||
std::replace(relativePath.begin(), relativePath.end(), L'\\', L'/');
|
||||
app_->add_kobject(relativePath);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("Number of objects: %d", entity_manager_->GetEntityCount());
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
auto entities = entity_manager_->GetAllEntities();
|
||||
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing,ImVec2(4,2));
|
||||
|
||||
int index = 0;
|
||||
for (auto& entity : entities)
|
||||
{
|
||||
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)
|
||||
{
|
||||
std::string name = identity->GetName();
|
||||
if (name.empty()) name = "Entity #" + std::to_string(identity->GetId());
|
||||
|
||||
if (identity && transform)
|
||||
bool isSelected = (entity->GetID() == m_selected_entity_id);
|
||||
if (ImGui::Selectable(name.c_str(), isSelected))
|
||||
{
|
||||
std::string headerName = identity->GetName() + " " + std::to_string(identity->GetId());
|
||||
if (ImGui::CollapsingHeader(headerName.c_str()))
|
||||
{
|
||||
// Position, Rotation, Scale
|
||||
XMVECTOR position = transform->GetPosition();
|
||||
XMVECTOR rotation = transform->GetRotation();
|
||||
XMVECTOR scale = transform->GetScale();
|
||||
|
||||
float pos[3] = { XMVectorGetX(position), XMVectorGetY(position), XMVectorGetZ(position) };
|
||||
std::string posLabel = "Position##" + std::to_string(identity->GetId());
|
||||
if (ImGui::DragFloat3(posLabel.c_str(), pos))
|
||||
{
|
||||
transform->SetPosition(XMVectorSet(pos[0], pos[1], pos[2], 0.0f));
|
||||
transform->UpdateWorldMatrix();
|
||||
m_selected_entity_id = entity->GetID();
|
||||
show_inspector_window_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float rot[3] = { XMVectorGetX(rotation), XMVectorGetY(rotation), XMVectorGetZ(rotation) };
|
||||
std::string rotLabel = "Rotation##" + std::to_string(identity->GetId());
|
||||
if (ImGui::DragFloat3(rotLabel.c_str(), rot))
|
||||
{
|
||||
transform->SetRotation(XMVectorSet(rot[0], rot[1], rot[2], 0.0f));
|
||||
transform->UpdateWorldMatrix();
|
||||
ImGui::PopStyleVar();
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
float scl[3] = { XMVectorGetX(scale), XMVectorGetY(scale), XMVectorGetZ(scale) };
|
||||
std::string sclLabel = "Scale##" + std::to_string(identity->GetId());
|
||||
if (ImGui::DragFloat3(sclLabel.c_str(), scl))
|
||||
void imguiManager::WidgetInspectorWindow()
|
||||
{
|
||||
transform->SetScale(XMVectorSet(scl[0], scl[1], scl[2], 0.0f));
|
||||
transform->UpdateWorldMatrix();
|
||||
ImGui::Begin("Inspector", &show_inspector_window_);
|
||||
|
||||
auto entity = entity_manager_->GetEntityByID(m_selected_entity_id);
|
||||
if (entity)
|
||||
{
|
||||
auto identity = entity->GetComponent<ecs::IdentityComponent>();
|
||||
if (identity)
|
||||
{
|
||||
char name[256];
|
||||
strcpy_s(name, identity->GetName().c_str());
|
||||
if (ImGui::InputText("Name", name, sizeof(name)))
|
||||
{
|
||||
identity->SetName(std::string(name));
|
||||
}
|
||||
ImGui::Text("ID: %d", identity->GetId());
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
// Textures - Seulement si le composant de rendu existe
|
||||
if (render && render->GetModel())
|
||||
// Lister et afficher les composants
|
||||
auto components = entity->GetAllComponents();
|
||||
for (auto& pair : components)
|
||||
{
|
||||
// D<>finir les types de textures_
|
||||
std::vector<std::string> textureCategories = {
|
||||
"Diffuse", "Normal", "Specular", "Alpha"
|
||||
};
|
||||
|
||||
std::vector<TextureType> textureTypes = {
|
||||
TextureType::Diffuse, TextureType::Normal,
|
||||
TextureType::Specular, TextureType::Alpha
|
||||
};
|
||||
|
||||
// Cr<43>er un espace pour afficher les textures_ avec d<>filement
|
||||
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
|
||||
for (int typeIndex = 0; typeIndex < textureCategories.size(); typeIndex++)
|
||||
auto& comp = pair.second;
|
||||
// Utiliser le nom du type comme en-tete
|
||||
std::string compName = typeid(*comp).name();
|
||||
if (ImGui::CollapsingHeader(compName.c_str()))
|
||||
{
|
||||
TextureType type = textureTypes[typeIndex];
|
||||
std::string typeName = textureCategories[typeIndex];
|
||||
comp->OnImGuiRender();
|
||||
}
|
||||
}
|
||||
|
||||
// Afficher le titre de la cat<61>gorie
|
||||
std::string categoryLabel = typeName + "##" + std::to_string(identity->GetId());
|
||||
ImGui::Text("%s:", typeName.c_str());
|
||||
if (ImGui::Button("Delete Entity"))
|
||||
{
|
||||
entity_manager_->DestroyEntity(m_selected_entity_id);
|
||||
m_selected_entity_id = -1;
|
||||
show_inspector_window_ = false;
|
||||
}
|
||||
ImGui::SameLine();
|
||||
|
||||
// Compter combien de textures_ de ce type existent
|
||||
int textureCount = 0;
|
||||
while (render->GetModel()->GetTexture(type, textureCount) != nullptr)
|
||||
if (ImGui::Button("Add Component"))
|
||||
{
|
||||
textureCount++;
|
||||
ImGui::OpenPopup("AddComponentPopup");
|
||||
}
|
||||
|
||||
// Afficher toutes les textures_ existantes
|
||||
std::string groupId = "TextureGroup_" + std::to_string(identity->GetId()) + "_" + std::to_string(typeIndex);
|
||||
ImGui::BeginGroup();
|
||||
for (int texIndex = 0; texIndex < textureCount; texIndex++)
|
||||
if (ImGui::BeginPopup("AddComponentPopup"))
|
||||
{
|
||||
ID3D11ShaderResourceView* texture = render->GetModel()->GetTexture(type, texIndex);
|
||||
if (texture)
|
||||
{
|
||||
// ID unique pour chaque bouton de texture
|
||||
std::string buttonId = "tex##" + std::to_string(identity->GetId()) + "_" +
|
||||
std::to_string(typeIndex) + "_" +
|
||||
std::to_string(texIndex);
|
||||
|
||||
if (ImGui::ImageButton(buttonId.c_str(), (ImTextureID)texture, ImVec2(48, 48)))
|
||||
{
|
||||
// Ouvrir une bo<62>te de dialogue pour changer la texture
|
||||
OPENFILENAME ofn;
|
||||
WCHAR szFile[260] = {0};
|
||||
ZeroMemory(&ofn, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = NULL;
|
||||
ofn.lpstrFile = szFile;
|
||||
ofn.nMaxFile = sizeof(szFile);
|
||||
ofn.lpstrFilter = L"Texture\0*.png;*.jpg;*.dds\0";
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.lpstrInitialDir = NULL;
|
||||
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
|
||||
|
||||
if (GetOpenFileName(&ofn))
|
||||
{
|
||||
// Changer la texture existante
|
||||
render->GetModel()->ChangeTexture(m_device, m_deviceContext, ofn.lpstrFile, type, texIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// Afficher l'indice de texture et pr<70>visualisation au survol
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::Text("%s %d", typeName.c_str(), texIndex);
|
||||
ImGui::Image((ImTextureID)texture, ImVec2(192, 192));
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
}
|
||||
}
|
||||
|
||||
// Bouton pour ajouter une nouvelle texture
|
||||
std::string addButtonLabel = "+##" + std::to_string(identity->GetId()) + "_" + std::to_string(typeIndex);
|
||||
if (ImGui::Button(addButtonLabel.c_str(), ImVec2(48, 48)))
|
||||
{
|
||||
// Ouvrir une bo<62>te de dialogue pour ajouter une texture
|
||||
OPENFILENAME ofn;
|
||||
WCHAR szFile[260] = {0};
|
||||
ZeroMemory(&ofn, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = NULL;
|
||||
ofn.lpstrFile = szFile;
|
||||
ofn.nMaxFile = sizeof(szFile);
|
||||
ofn.lpstrFilter = L"Texture\0*.png;*.jpg;*.dds\0";
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.lpstrInitialDir = NULL;
|
||||
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
|
||||
|
||||
if (GetOpenFileName(&ofn))
|
||||
{
|
||||
// Ajouter une nouvelle texture
|
||||
render->GetModel()->AddTexture(m_device, m_deviceContext, ofn.lpstrFile, type);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndGroup();
|
||||
ImGui::Separator();
|
||||
}
|
||||
|
||||
ImGui::EndChild();
|
||||
}
|
||||
|
||||
ImGui::Text("Select Component to Add:");
|
||||
ImGui::Separator();
|
||||
|
||||
// Delete button
|
||||
std::string deleteLabel = "Delete##" + std::to_string(identity->GetId());
|
||||
if (ImGui::Button(deleteLabel.c_str()))
|
||||
if (ImGui::MenuItem("Transform Component"))
|
||||
{
|
||||
app_->delete_entity_by_id(identity->GetId());
|
||||
// Sortir du boucle apr<70>s suppression pour <20>viter des acc<63>s invalides
|
||||
break;
|
||||
if (!entity->HasComponent<ecs::TransformComponent>())
|
||||
{
|
||||
entity->AddComponent<ecs::TransformComponent>();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
// Shader options
|
||||
if (shader)
|
||||
{
|
||||
// Liste des options de shader
|
||||
const char* shaderOptions[] = {
|
||||
"Enable Global Lighting",
|
||||
"Enable Lighting",
|
||||
"Enable Cel Shading",
|
||||
"Enable Normal Mapping",
|
||||
"Enable Specular Mapping",
|
||||
"Enable Alpha Mapping"
|
||||
};
|
||||
|
||||
std::vector<ecs::ShaderType> shaderTypes = {
|
||||
ecs::ShaderType::SUNLIGHT,
|
||||
ecs::ShaderType::LIGHTING,
|
||||
ecs::ShaderType::CEL_SHADING,
|
||||
ecs::ShaderType::NORMAL_MAPPING,
|
||||
ecs::ShaderType::SPECULAR_MAPPING,
|
||||
ecs::ShaderType::ALPHA_MAPPING
|
||||
};
|
||||
|
||||
// Trouver l'index actuel du shader pour cette entit<69> sp<73>cifique
|
||||
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;
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
|
||||
// Cr<43>ation du menu d<>roulant avec un ID unique pour chaque entit<69>
|
||||
std::string shaderComboId = "Shader Options##" + std::to_string(identity->GetId());
|
||||
if (ImGui::BeginCombo(shaderComboId.c_str(), shaderOptions[currentShader]))
|
||||
if (ImGui::MenuItem("Model Path Component"))
|
||||
{
|
||||
for (int i = 0; i < IM_ARRAYSIZE(shaderOptions); i++)
|
||||
if (!entity->HasComponent<ecs::ModelPathComponent>())
|
||||
{
|
||||
// Cr<43>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);
|
||||
if (ImGui::Selectable(shaderOptions[i], isSelected))
|
||||
entity->AddComponent<ecs::ModelPathComponent>();
|
||||
}
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
if (ImGui::MenuItem("Audio Component"))
|
||||
{
|
||||
// Met <20> jour l'option s<>lectionn<6E>e uniquement pour cette entit<69>
|
||||
currentShader = i;
|
||||
shader->SetActiveShader(shaderTypes[i]);
|
||||
}
|
||||
|
||||
// Si l'option s<>lectionn<6E>e est active, nous mettons en surbrillance
|
||||
if (isSelected)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
// Physics
|
||||
bool isPhysicsEnabled = (physics != nullptr);
|
||||
std::string physicsLabel = "Physics##" + std::to_string(identity->GetId());
|
||||
|
||||
if (ImGui::Checkbox(physicsLabel.c_str(), &isPhysicsEnabled))
|
||||
if (!entity->HasComponent<ecs::AudioComponent>())
|
||||
{
|
||||
if (isPhysicsEnabled && !physics)
|
||||
{
|
||||
// Ajouter un composant de physique
|
||||
physics = entity->AddComponent<ecs::PhysicsComponent>();
|
||||
physics->Initialize();
|
||||
entity->AddComponent<ecs::AudioComponent>();
|
||||
}
|
||||
else if (!isPhysicsEnabled && physics)
|
||||
{
|
||||
// Retirer le composant de physique
|
||||
entity->RemoveComponent<ecs::PhysicsComponent>();
|
||||
physics = nullptr;
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
}
|
||||
|
||||
if (physics)
|
||||
if (ImGui::MenuItem("Physics Component"))
|
||||
{
|
||||
// Gravity Enabled checkbox
|
||||
bool gravityEnabled = physics->IsGravityEnabled();
|
||||
std::string gravityLabel = "Gravity##" + std::to_string(identity->GetId());
|
||||
if (ImGui::Checkbox(gravityLabel.c_str(), &gravityEnabled))
|
||||
if (!entity->HasComponent<ecs::PhysicsComponent>())
|
||||
{
|
||||
physics->SetGravityEnabled(gravityEnabled);
|
||||
entity->AddComponent<ecs::PhysicsComponent>();
|
||||
}
|
||||
|
||||
// 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();
|
||||
|
||||
if (ImGui::RadioButton(("None##" + std::to_string(identity->GetId())).c_str(),
|
||||
type == ecs::ObjectType::Unknown))
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
if (ImGui::MenuItem("Render Component"))
|
||||
{
|
||||
identity->SetType(ecs::ObjectType::Unknown);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::RadioButton(("Cube##" + std::to_string(identity->GetId())).c_str(),
|
||||
type == ecs::ObjectType::Cube))
|
||||
if (!entity->HasComponent<ecs::RenderComponent>())
|
||||
{
|
||||
identity->SetType(ecs::ObjectType::Cube);
|
||||
entity->AddComponent<ecs::RenderComponent>();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::RadioButton(("Sphere##" + std::to_string(identity->GetId())).c_str(),
|
||||
type == ecs::ObjectType::Sphere))
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
if (ImGui::MenuItem("Shader Component"))
|
||||
{
|
||||
identity->SetType(ecs::ObjectType::Sphere);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::RadioButton(("Terrain##" + std::to_string(identity->GetId())).c_str(),
|
||||
type == ecs::ObjectType::Terrain))
|
||||
if (!entity->HasComponent<ecs::ShaderComponent>())
|
||||
{
|
||||
identity->SetType(ecs::ObjectType::Terrain);
|
||||
entity->AddComponent<ecs::ShaderComponent>();
|
||||
}
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::EndPopup();
|
||||
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
}
|
||||
index++;
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui::Text("No entity selected.");
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
@@ -907,7 +834,7 @@ void imguiManager::WidgetLogWindow()
|
||||
// Place the menu on the same line as the filter
|
||||
ImGui::SameLine();
|
||||
|
||||
// Menu d<>roulant pour les niveaux de log
|
||||
// Menu d<>roulant pour les niveaux de log
|
||||
if (ImGui::BeginMenu("Log Levels"))
|
||||
{
|
||||
for (size_t i = 0; i < Logger::LogLevelCount; ++i)
|
||||
@@ -925,7 +852,7 @@ void imguiManager::WidgetLogWindow()
|
||||
std::vector<Logger::LogEntry> logfiltered;
|
||||
int logCount = logBuffer.size();
|
||||
|
||||
// Affichage des logs filtr<74>s
|
||||
// Affichage des logs filtr<74>s
|
||||
ImGui::BeginChild("Log");
|
||||
|
||||
for (const auto& log : logBuffer)
|
||||
@@ -976,7 +903,7 @@ void imguiManager::WidgetRenderWindow(ImVec2 availableSize)
|
||||
ImVec2 oldWindowSize = windowSize;
|
||||
windowSize = ImGui::GetContentRegionAvail();
|
||||
|
||||
// Si la taille de la fen<65>tre a chang<6E>, ajustez la taille de la fen<65>tre de l'application
|
||||
// Si la taille de la fen<65>tre a chang<6E>, ajustez la taille de la fen<65>tre de l'application
|
||||
if (oldWindowSize.x != windowSize.x || oldWindowSize.y != windowSize.y)
|
||||
{
|
||||
app_->set_window_size(windowSize);
|
||||
@@ -999,7 +926,7 @@ void imguiManager::WidgetRenderWindow(ImVec2 availableSize)
|
||||
if (texture)
|
||||
{
|
||||
|
||||
// Affichez la scenne projet<65> sur texture dans une fen<65>tre ImGui
|
||||
// Affichez la scenne projet<65> sur texture dans une fen<65>tre ImGui
|
||||
// alpha blend is not enable to render the texture
|
||||
|
||||
app_->get_direct_3d()->turn_z_buffer_off();
|
||||
@@ -1042,7 +969,7 @@ void imguiManager::WidgetRenderStats()
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
// Trouver les valeurs min/max pour l'<27>chelle du graphique
|
||||
// Trouver les valeurs min/max pour l'<27>chelle du graphique
|
||||
float frameTimeMin = FLT_MAX;
|
||||
float frameTimeMax = 0.0f;
|
||||
for (int i = 0; i < FRAME_HISTORY_COUNT; i++) {
|
||||
@@ -1055,14 +982,14 @@ void imguiManager::WidgetRenderStats()
|
||||
if (frameTimeMax == 0.0f) frameTimeMax = 0.033f; // ~30 FPS
|
||||
if (frameTimeMin == FLT_MAX) frameTimeMin = 0.0f;
|
||||
|
||||
// Ajouter 10% de marge pour la lisibilit<69>
|
||||
// Ajouter 10% de marge pour la lisibilit<69>
|
||||
float margin = (frameTimeMax - frameTimeMin) * 0.1f;
|
||||
frameTimeMin = max(0.0f, frameTimeMin - margin);
|
||||
frameTimeMax += margin;
|
||||
|
||||
// Afficher le graphique
|
||||
ImGui::Text("Frame Time: %.3f ms", current_frame_time_ * 1000.0f);
|
||||
ImGui::PlotLines("FrameTimeGraph", // Au lieu de cha<68>ne vide ""
|
||||
ImGui::PlotLines("FrameTimeGraph", // Au lieu de cha<68>ne vide ""
|
||||
m_frameTimeHistory,
|
||||
FRAME_HISTORY_COUNT,
|
||||
m_frameTimeHistoryIndex,
|
||||
|
BIN
x64/Release/assets/sounds/default.mp3
Normal file
BIN
x64/Release/assets/sounds/default.mp3
Normal file
Binary file not shown.
Reference in New Issue
Block a user