Minor - ECS use for import object - V12.1.0
This commit is contained in:
parent
039b034175
commit
3adfddf44f
100
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
100
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
@ -4,16 +4,7 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment="">
|
||||
<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/imgui.ini" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/imgui.ini" 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/imguiManager.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/imguiManager.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/stats.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/stats.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/application_class.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/application_class.cpp" 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" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/stats.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/stats.cpp" afterDir="false" />
|
||||
</list>
|
||||
<list default="true" id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment="" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
@ -26,52 +17,20 @@
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="HighlightingSettingsPerFile">
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="cidr-memory-view://10" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um/d3d11.h" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um/dinput.h" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.44.35207/include/memory" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/include/Inc/VertexTypes.h" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/include/Vulkan/Include/vulkan/vulkan_core.h" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/component.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/identity_component.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/physics_component.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/render_component.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/shader_component.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/transform_component.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/entity.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/entity_manager.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/systems/render_system.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/../../IDE_VS/VC/Tools/MSVC/14.38.33130/include/type_traits" root0="SKIP_HIGHLIGHTING" />
|
||||
</component>
|
||||
<component name="KubernetesApiPersistence">{}</component>
|
||||
@ -93,26 +52,26 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"C++ Project.enginecustom.executor": "Run",
|
||||
"C/C++ Project.KhaoticDemo.executor": "Run",
|
||||
"C/C++ Project.enginecustom.executor": "Run",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"RunOnceActivity.git.unshallow": "true",
|
||||
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"git-widget-placeholder": "main",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"settings.editor.selected.configurable": "preferences.environmentSetup",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"C++ Project.enginecustom.executor": "Run",
|
||||
"C/C++ Project.KhaoticDemo.executor": "Run",
|
||||
"C/C++ Project.enginecustom.executor": "Run",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"RunOnceActivity.git.unshallow": "true",
|
||||
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"git-widget-placeholder": "main",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"settings.editor.selected.configurable": "preferences.environmentSetup",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
}
|
||||
}]]></component>
|
||||
}</component>
|
||||
<component name="RunManager" selected="C/C++ Project.enginecustom">
|
||||
<configuration name="KhaoticDemo" type="CppProject" factoryName="C++ Project">
|
||||
<configuration_1 setup="1">
|
||||
@ -263,6 +222,7 @@
|
||||
<workItem from="1750420267631" duration="148000" />
|
||||
<workItem from="1750592598277" duration="332000" />
|
||||
<workItem from="1750699146323" duration="10385000" />
|
||||
<workItem from="1750763086646" duration="4874000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Minor update - viewport window tweak">
|
||||
<option name="closed" value="true" />
|
||||
|
@ -121,6 +121,7 @@
|
||||
<ClInclude Include="src\inc\system\display_plane_class.h" />
|
||||
<ClInclude Include="src\inc\system\ecs\component.h" />
|
||||
<ClInclude Include="src\inc\system\ecs\components\identity_component.h" />
|
||||
<ClInclude Include="src\inc\system\ecs\components\model_path_component.h" />
|
||||
<ClInclude Include="src\inc\system\ecs\components\physics_component.h" />
|
||||
<ClInclude Include="src\inc\system\ecs\components\render_component.h" />
|
||||
<ClInclude Include="src\inc\system\ecs\components\shader_component.h" />
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "ecs/components/physics_component.h"
|
||||
#include "ecs/components/shader_component.h"
|
||||
#include "ecs/systems/render_system.h"
|
||||
#include "ecs/components/model_path_component.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <WICTextureLoader.h>
|
||||
|
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include "../component.h"
|
||||
#include <string>
|
||||
|
||||
namespace ecs {
|
||||
|
||||
class ModelPathComponent : public Component {
|
||||
public:
|
||||
ModelPathComponent() = default;
|
||||
explicit ModelPathComponent(const std::wstring& path) : m_path(path) {}
|
||||
~ModelPathComponent() = default;
|
||||
|
||||
void Initialize() override {}
|
||||
void Update(float deltaTime) override {}
|
||||
|
||||
// Getters et setters
|
||||
const std::wstring& GetPath() const { return m_path; }
|
||||
void SetPath(const std::wstring& path) { m_path = path; }
|
||||
|
||||
private:
|
||||
std::wstring m_path;
|
||||
};
|
||||
|
||||
} // namespace ecs
|
@ -1368,9 +1368,8 @@ void application_class::add_kobject(std::wstring& filepath)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(objects_mutex_);
|
||||
Logger::Get().Log("Adding object", __FILE__, __LINE__);
|
||||
|
||||
|
||||
char modelFilename[128];
|
||||
vector<string> Filename;
|
||||
TextureContainer KobjectsTextures;
|
||||
filesystem::path p(filepath);
|
||||
string filename = p.stem().string();
|
||||
@ -1386,27 +1385,69 @@ void application_class::add_kobject(std::wstring& filepath)
|
||||
L"assets/Texture/BricksNRM2K.png",
|
||||
L"assets/Texture/BricksGLOSS2K.png"
|
||||
};
|
||||
|
||||
// Configurer les chemins des textures dans le conteneur
|
||||
KobjectsTextures.diffusePaths.push_back(kobjTexture[0]);
|
||||
if (kobjTexture.size() > 1) KobjectsTextures.normalPaths.push_back(kobjTexture[1]);
|
||||
if (kobjTexture.size() > 2) KobjectsTextures.specularPaths.push_back(kobjTexture[2]);
|
||||
|
||||
object* newObject = new object(*this);
|
||||
newObject->LoadTexturesFromPath(kobjTexture,KobjectsTextures, direct_3d_); // Load textures_ from the path
|
||||
newObject->Initialize(direct_3d_->get_device(), direct_3d_->get_device_context(), modelFilename, KobjectsTextures);
|
||||
newObject->SetMass(1.0f);
|
||||
newObject->SetTranslateMatrix(XMMatrixTranslation(0.0f, 50.0f, 0.0f));
|
||||
newObject->SetName(filename);
|
||||
newObject->SetId(object_id_);
|
||||
newObject->SetModelPath(filepath); // Store the path as std::wstring
|
||||
// Vérifier si le modèle existe déjà dans le cache
|
||||
std::string modelKey = std::string(modelFilename);
|
||||
std::shared_ptr<model_class> sharedModel;
|
||||
|
||||
auto it = g_model_cache.find(modelKey);
|
||||
if (it != g_model_cache.end()) {
|
||||
// Utiliser le modèle existant du cache
|
||||
Logger::Get().Log("Using cached model for " + modelKey, __FILE__, __LINE__);
|
||||
sharedModel = it->second;
|
||||
}
|
||||
else {
|
||||
// Créer un nouveau modèle
|
||||
sharedModel = std::make_shared<model_class>();
|
||||
|
||||
// Précharger les textures
|
||||
sharedModel->PreloadTextures(direct_3d_->get_device(), direct_3d_->get_device_context(), KobjectsTextures);
|
||||
|
||||
// Initialiser le modèle
|
||||
if (!sharedModel->Initialize(direct_3d_->get_device(), direct_3d_->get_device_context(), modelFilename, KobjectsTextures)) {
|
||||
Logger::Get().Log("Failed to initialize model for object: " + modelKey, __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return;
|
||||
}
|
||||
|
||||
// Ajouter le modèle au cache
|
||||
g_model_cache[modelKey] = sharedModel;
|
||||
Logger::Get().Log("Added model to cache: " + modelKey, __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
// Créer une nouvelle entité
|
||||
auto entity = entity_manager_->CreateEntity();
|
||||
|
||||
// Ajouter un composant d'identité
|
||||
auto identity = entity->AddComponent<ecs::IdentityComponent>(object_id_++);
|
||||
identity->SetName(filename);
|
||||
identity->SetType(ecs::ObjectType::Unknown);
|
||||
|
||||
// Ajouter un composant de transformation
|
||||
auto transform = entity->AddComponent<ecs::TransformComponent>();
|
||||
transform->SetPosition(XMVectorSet(0.0f, 50.0f, 0.0f, 0.0f));
|
||||
transform->SetScale(XMVectorSet(1.0f, 1.0f, 1.0f, 0.0f));
|
||||
transform->UpdateWorldMatrix();
|
||||
|
||||
// Ajouter un composant de rendu avec le modèle partagé
|
||||
auto render = entity->AddComponent<ecs::RenderComponent>();
|
||||
render->InitializeWithModel(sharedModel);
|
||||
|
||||
// Ajouter un composant de shader
|
||||
auto shader = entity->AddComponent<ecs::ShaderComponent>();
|
||||
shader->SetActiveShader(ecs::ShaderType::LIGHTING);
|
||||
|
||||
// Stocker le chemin du modèle
|
||||
auto modelPath = entity->AddComponent<ecs::ModelPathComponent>();
|
||||
modelPath->SetPath(filepath);
|
||||
|
||||
object_id_++;
|
||||
|
||||
object_.push_back(newObject);
|
||||
Logger::Get().Log("ECS entity created with ID: " + std::to_string(identity->GetId()), __FILE__, __LINE__);
|
||||
|
||||
update_stats_after_modification();
|
||||
|
||||
// Vérifiez que l'objet a bien reçu les textures_
|
||||
if (newObject->get_model()->GetTexture(TextureType::Diffuse,0) == nullptr)
|
||||
{
|
||||
Logger::Get().Log("object texture is null after initialization", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
}
|
||||
}
|
||||
|
||||
void application_class::add_cube()
|
||||
|
Loading…
x
Reference in New Issue
Block a user