Patch Update - Fix the loading and saving of the texture - V10.1.1
This commit is contained in:
parent
c442a87883
commit
5a3a4f73a8
82
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
82
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
@ -7,12 +7,12 @@
|
|||||||
<list default="true" id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment="">
|
<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$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/enginecustom/demo.ker" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/demo.ker" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/enginecustom/demo.ker" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/demo.ker" 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/applicationclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/applicationclass.h" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/modelclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/modelclass.h" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/modelclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/modelclass.h" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/object.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/object.h" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/Skybox.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/Skybox.cpp" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/applicationclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/applicationclass.cpp" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/applicationclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/applicationclass.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/modelclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/modelclass.cpp" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/modelclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/modelclass.cpp" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/object.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/object.cpp" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -32,7 +32,37 @@
|
|||||||
<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://0" root0="FORCE_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://6" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/enginecustom/include/Vulkan/Include/vulkan/vulkan_core.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/src/shader/CelShadingShader.cpp" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/enginecustom/src/src/shader/CelShadingShader.cpp" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/../../IDE_VS/VC/Tools/MSVC/14.38.33130/include/type_traits" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/../../IDE_VS/VC/Tools/MSVC/14.38.33130/include/type_traits" root0="SKIP_HIGHLIGHTING" />
|
||||||
@ -49,25 +79,25 @@
|
|||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent">{
|
<component name="PropertiesComponent"><![CDATA[{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||||
"C++ Project.enginecustom.executor": "Run",
|
"C++ Project.enginecustom.executor": "Run",
|
||||||
"C/C++ Project.enginecustom.executor": "Run",
|
"C/C++ Project.enginecustom.executor": "Run",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.git.unshallow": "true",
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||||
"git-widget-placeholder": "main",
|
"git-widget-placeholder": "main",
|
||||||
"ignore.virus.scanning.warn.message": "true",
|
"ignore.virus.scanning.warn.message": "true",
|
||||||
"node.js.detected.package.eslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.detected.package.tslint": "true",
|
"node.js.detected.package.tslint": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"node.js.selected.package.tslint": "(autodetect)",
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
"nodejs_package_manager_path": "npm",
|
"nodejs_package_manager_path": "npm",
|
||||||
"settings.editor.selected.configurable": "preferences.build.unityPlugin",
|
"settings.editor.selected.configurable": "preferences.build.unityPlugin",
|
||||||
"vue.rearranger.settings.migration": "true"
|
"vue.rearranger.settings.migration": "true"
|
||||||
}
|
}
|
||||||
}</component>
|
}]]></component>
|
||||||
<component name="RunManager" selected="C/C++ Project.enginecustom">
|
<component name="RunManager" selected="C/C++ Project.enginecustom">
|
||||||
<configuration name="KhaoticDemo" type="CppProject" factoryName="C++ Project">
|
<configuration name="KhaoticDemo" type="CppProject" factoryName="C++ Project">
|
||||||
<configuration_1 setup="1">
|
<configuration_1 setup="1">
|
||||||
@ -185,7 +215,8 @@
|
|||||||
<workItem from="1746456965664" duration="13000" />
|
<workItem from="1746456965664" duration="13000" />
|
||||||
<workItem from="1746469494034" duration="799000" />
|
<workItem from="1746469494034" duration="799000" />
|
||||||
<workItem from="1746526901276" duration="2023000" />
|
<workItem from="1746526901276" duration="2023000" />
|
||||||
<workItem from="1746536290167" duration="1831000" />
|
<workItem from="1746536290167" duration="1908000" />
|
||||||
|
<workItem from="1746538260893" duration="5726000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="Minor update - viewport window tweak">
|
<task id="LOCAL-00001" summary="Minor update - viewport window tweak">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
@ -243,11 +274,6 @@
|
|||||||
<properties exception="System.Threading.ThreadAbortException" breakIfHandledByOtherCode="false" displayValue="System.Threading.ThreadAbortException" />
|
<properties exception="System.Threading.ThreadAbortException" breakIfHandledByOtherCode="false" displayValue="System.Threading.ThreadAbortException" />
|
||||||
<option name="timeStamp" value="3" />
|
<option name="timeStamp" value="3" />
|
||||||
</breakpoint>
|
</breakpoint>
|
||||||
<line-breakpoint enabled="true" type="com.jetbrains.cidr.execution.debugger.OCBreakpointType">
|
|
||||||
<url>file://$PROJECT_DIR$/enginecustom/src/src/system/applicationclass.cpp</url>
|
|
||||||
<line>1997</line>
|
|
||||||
<option name="timeStamp" value="5" />
|
|
||||||
</line-breakpoint>
|
|
||||||
</breakpoints>
|
</breakpoints>
|
||||||
</breakpoint-manager>
|
</breakpoint-manager>
|
||||||
<watches-manager>
|
<watches-manager>
|
||||||
|
@ -1 +1 @@
|
|||||||
0 isosphere 0 10 0 0 -0 0 1 1 1 Content/Assets/Kobject/isosphere.obj ALPHA_MAPPING 1 Unknown 1 0 2 F:\Github_Repo\khaotic-engine-Reborn\enginecustom\assets\Texture\stone01.png F:\Github_Repo\khaotic-engine-Reborn\enginecustom\assets\Texture\moss01.png 1 F:\Github_Repo\khaotic-engine-Reborn\enginecustom\assets\Texture\normal01.png 1 F:\Github_Repo\khaotic-engine-Reborn\enginecustom\assets\Texture\spec02.png 1 F:\Github_Repo\khaotic-engine-Reborn\enginecustom\assets\Texture\light01.png
|
1 isosphere 0 10 0 0 -0 0 1 1 1 F:\Github_Repo\khaotic-engine-Reborn\x64\Debug\Content/Assets/Kobject/isosphere.obj SUNLIGHT 1 Unknown 1 0 2 F:\Github_Repo\khaotic-engine-Reborn\enginecustom\assets\Texture\stone01.png F:\Github_Repo\khaotic-engine-Reborn\enginecustom\assets\Texture\dirt01.png 1 assets/Texture/BricksNRM2K.png 1 assets/Texture/BricksGLOSS2K.png 1 F:\Github_Repo\khaotic-engine-Reborn\enginecustom\assets\Texture\alpha01.png
|
||||||
|
@ -66,8 +66,8 @@ Collapsed=0
|
|||||||
DockId=0x0000000C,0
|
DockId=0x0000000C,0
|
||||||
|
|
||||||
[Window][Log Window]
|
[Window][Log Window]
|
||||||
Pos=8,627
|
Pos=8,37
|
||||||
Size=1568,226
|
Size=16,19
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000006,0
|
DockId=0x00000006,0
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ public:
|
|||||||
|
|
||||||
// Save and load scene
|
// Save and load scene
|
||||||
void SaveScene();
|
void SaveScene();
|
||||||
void LoadScene();
|
bool LoadScene();
|
||||||
|
|
||||||
void SetScenePath(std::string path) { m_scenePath = path; };
|
void SetScenePath(std::string path) { m_scenePath = path; };
|
||||||
std::wstring GetScenePath();
|
std::wstring GetScenePath();
|
||||||
|
@ -225,6 +225,8 @@ public:
|
|||||||
|
|
||||||
void SetTextureContainer (TextureContainer& texturesContainer) { m_Textures = texturesContainer; }
|
void SetTextureContainer (TextureContainer& texturesContainer) { m_Textures = texturesContainer; }
|
||||||
TextureContainer GetTextureContainer() const { return m_Textures; }
|
TextureContainer GetTextureContainer() const { return m_Textures; }
|
||||||
|
|
||||||
|
bool PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* deviceContext, TextureContainer& textureContainer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool InitializeBuffers(ID3D11Device*);
|
bool InitializeBuffers(ID3D11Device*);
|
||||||
|
@ -2028,8 +2028,11 @@ void ApplicationClass::SaveScene() {
|
|||||||
Logger::Get().Log("Scene saved successfully to " + m_scenePath, __FILE__, __LINE__, Logger::LogLevel::Info);
|
Logger::Get().Log("Scene saved successfully to " + m_scenePath, __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationClass::LoadScene() {
|
|
||||||
|
|
||||||
|
bool ApplicationClass::LoadScene() {
|
||||||
|
Logger::Get().Log("Loading scene from " , __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||||
|
|
||||||
std::wstring scenePath = GetScenePath();
|
std::wstring scenePath = GetScenePath();
|
||||||
if (!scenePath.empty())
|
if (!scenePath.empty())
|
||||||
{
|
{
|
||||||
@ -2038,14 +2041,15 @@ void ApplicationClass::LoadScene() {
|
|||||||
|
|
||||||
if (m_scenePath.empty()) {
|
if (m_scenePath.empty()) {
|
||||||
Logger::Get().Log("Scene path is empty. Cannot load scene.", __FILE__, __LINE__, Logger::LogLevel::Error);
|
Logger::Get().Log("Scene path is empty. Cannot load scene.", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ifstream inFile(scenePath);
|
std::ifstream inFile(scenePath);
|
||||||
if (!inFile.is_open()) {
|
if (!inFile.is_open()) {
|
||||||
Logger::Get().Log("Failed to open file for loading scene: ", __FILE__, __LINE__, Logger::LogLevel::Error);
|
Logger::Get().Log("Failed to open file for loading scene: ", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Nettoyer les objets existants
|
// Nettoyer les objets existants
|
||||||
for (auto& obj : m_object) {
|
for (auto& obj : m_object) {
|
||||||
if (obj) {
|
if (obj) {
|
||||||
@ -2055,119 +2059,149 @@ void ApplicationClass::LoadScene() {
|
|||||||
}
|
}
|
||||||
m_object.clear();
|
m_object.clear();
|
||||||
m_ObjectId = 0;
|
m_ObjectId = 0;
|
||||||
|
|
||||||
|
// Sauvegarder le répertoire de travail actuel
|
||||||
|
std::wstring currentDirectory = m_WFolder;
|
||||||
|
|
||||||
std::string line;
|
std::string line;
|
||||||
while (std::getline(inFile, line)) {
|
while (std::getline(inFile, line)) {
|
||||||
std::istringstream iss(line);
|
std::istringstream iss(line);
|
||||||
|
|
||||||
int id;
|
int id;
|
||||||
std::string name;
|
std::string name;
|
||||||
float posX, posY, posZ, rotX, rotY, rotZ, scaleX, scaleY, scaleZ;
|
XMFLOAT3 position, rotation, scale;
|
||||||
std::string modelPath, shaderTypeStr, objectTypeStr;
|
std::string modelPath;
|
||||||
float boundingRadius, mass;
|
std::string shaderTypeStr;
|
||||||
|
float boundingRadius;
|
||||||
|
std::string objectTypeStr;
|
||||||
|
float mass;
|
||||||
bool physicsEnabled;
|
bool physicsEnabled;
|
||||||
|
|
||||||
// Lire les données de base
|
// Lire les données de base de l'objet
|
||||||
iss >> id >> name >> posX >> posY >> posZ >> rotX >> rotY >> rotZ
|
iss >> id >> name
|
||||||
>> scaleX >> scaleY >> scaleZ >> modelPath >> shaderTypeStr
|
>> position.x >> position.y >> position.z
|
||||||
>> boundingRadius >> objectTypeStr >> mass >> physicsEnabled;
|
>> rotation.x >> rotation.y >> rotation.z
|
||||||
|
>> scale.x >> scale.y >> scale.z
|
||||||
// Convertir les chemins de modèle en wstring pour Windows
|
>> modelPath >> shaderTypeStr
|
||||||
std::wstring wModelPath(modelPath.begin(), modelPath.end());
|
>> boundingRadius >> objectTypeStr
|
||||||
|
>> mass >> physicsEnabled;
|
||||||
|
|
||||||
|
if (iss.fail()) {
|
||||||
|
Logger::Get().Log("Failed to parse object data", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Créer un nouvel objet
|
// Créer un nouvel objet
|
||||||
Object* newObject = new Object();
|
Object* newObject = new Object();
|
||||||
|
|
||||||
|
// Convertir le chemin du modèle en wstring
|
||||||
|
std::wstring wModelPath(modelPath.begin(), modelPath.end());
|
||||||
|
|
||||||
|
// Vérifier si le chemin est relatif (ne commence pas par un disque comme C:)
|
||||||
|
if (modelPath.length() > 1 && modelPath[1] != ':') {
|
||||||
|
// C'est un chemin relatif, préfixer avec le répertoire de travail
|
||||||
|
if (currentDirectory.back() != L'/' && currentDirectory.back() != L'\\') {
|
||||||
|
// Ajouter un séparateur si nécessaire
|
||||||
|
wModelPath = currentDirectory + L"\\" + wModelPath;
|
||||||
|
} else {
|
||||||
|
wModelPath = currentDirectory + wModelPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Créer le conteneur de textures pour stocker les chemins
|
||||||
|
TextureContainer objectTextures;
|
||||||
|
|
||||||
// Lire les chemins de textures
|
// IMPORTANT: Vider les conteneurs de chemins de textures
|
||||||
TextureContainer textures;
|
objectTextures.diffusePaths.clear();
|
||||||
|
objectTextures.normalPaths.clear();
|
||||||
// Textures diffuses
|
objectTextures.specularPaths.clear();
|
||||||
int diffuseCount;
|
objectTextures.alphaPaths.clear();
|
||||||
iss >> diffuseCount;
|
|
||||||
std::vector<std::wstring> diffusePaths;
|
// Lire les chemins des textures diffuses
|
||||||
for (int i = 0; i < diffuseCount; i++) {
|
int diffuseTextureCount;
|
||||||
std::string path;
|
iss >> diffuseTextureCount;
|
||||||
iss >> path;
|
for (int i = 0; i < diffuseTextureCount; i++) {
|
||||||
diffusePaths.push_back(std::wstring(path.begin(), path.end()));
|
std::string texturePath;
|
||||||
|
iss >> texturePath;
|
||||||
|
std::wstring wTexturePath(texturePath.begin(), texturePath.end());
|
||||||
|
objectTextures.diffusePaths.push_back(wTexturePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Textures normales
|
// Lire les chemins des textures normales
|
||||||
int normalCount;
|
int normalTextureCount;
|
||||||
iss >> normalCount;
|
iss >> normalTextureCount;
|
||||||
std::vector<std::wstring> normalPaths;
|
for (int i = 0; i < normalTextureCount; i++) {
|
||||||
for (int i = 0; i < normalCount; i++) {
|
std::string texturePath;
|
||||||
std::string path;
|
iss >> texturePath;
|
||||||
iss >> path;
|
std::wstring wTexturePath(texturePath.begin(), texturePath.end());
|
||||||
normalPaths.push_back(std::wstring(path.begin(), path.end()));
|
objectTextures.normalPaths.push_back(wTexturePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Textures spéculaires
|
// Lire les chemins des textures spéculaires
|
||||||
int specularCount;
|
int specularTextureCount;
|
||||||
iss >> specularCount;
|
iss >> specularTextureCount;
|
||||||
std::vector<std::wstring> specularPaths;
|
for (int i = 0; i < specularTextureCount; i++) {
|
||||||
for (int i = 0; i < specularCount; i++) {
|
std::string texturePath;
|
||||||
std::string path;
|
iss >> texturePath;
|
||||||
iss >> path;
|
std::wstring wTexturePath(texturePath.begin(), texturePath.end());
|
||||||
specularPaths.push_back(std::wstring(path.begin(), path.end()));
|
objectTextures.specularPaths.push_back(wTexturePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Textures alpha
|
// Lire les chemins des textures alpha
|
||||||
int alphaCount;
|
int alphaTextureCount;
|
||||||
iss >> alphaCount;
|
iss >> alphaTextureCount;
|
||||||
std::vector<std::wstring> alphaPaths;
|
for (int i = 0; i < alphaTextureCount; i++) {
|
||||||
for (int i = 0; i < alphaCount; i++) {
|
std::string texturePath;
|
||||||
std::string path;
|
iss >> texturePath;
|
||||||
iss >> path;
|
std::wstring wTexturePath(texturePath.begin(), texturePath.end());
|
||||||
alphaPaths.push_back(std::wstring(path.begin(), path.end()));
|
objectTextures.alphaPaths.push_back(wTexturePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Combiner tous les chemins de textures
|
// preload texture
|
||||||
std::vector<std::wstring> allTextures;
|
if (!newObject->PreloadTextures(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), objectTextures))
|
||||||
allTextures.insert(allTextures.end(), diffusePaths.begin(), diffusePaths.end());
|
{
|
||||||
allTextures.insert(allTextures.end(), normalPaths.begin(), normalPaths.end());
|
// Gérer l'erreur
|
||||||
allTextures.insert(allTextures.end(), specularPaths.begin(), specularPaths.end());
|
return false;
|
||||||
allTextures.insert(allTextures.end(), alphaPaths.begin(), alphaPaths.end());
|
}
|
||||||
|
|
||||||
// Charger les textures
|
// Initialiser l'objet avec le modèle et les chemins de textures
|
||||||
newObject->LoadTexturesFromPath(allTextures, textures, m_Direct3D);
|
char modelFilename[256];
|
||||||
|
size_t convertedChars = 0;
|
||||||
// Convertir le chemin du modèle en char* pour l'initialisation
|
wcstombs_s(&convertedChars, modelFilename, sizeof(modelFilename), wModelPath.c_str(), _TRUNCATE);
|
||||||
char modelFilename[128];
|
|
||||||
wcstombs_s(nullptr, modelFilename, sizeof(modelFilename), wModelPath.c_str(), _TRUNCATE);
|
Logger::Get().Log("Loading model: " + std::string(modelFilename), __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||||
|
|
||||||
// Initialiser l'objet avec le modèle et les textures
|
// NE PAS charger les textures avant Initialize
|
||||||
if (!newObject->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, textures)) {
|
// Laisser la méthode Initialize s'en charger à partir des chemins
|
||||||
Logger::Get().Log("Failed to initialize object from scene file", __FILE__, __LINE__, Logger::LogLevel::Error);
|
if (!newObject->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, objectTextures)) {
|
||||||
|
Logger::Get().Log("Failed to initialize object: " + name, __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
delete newObject;
|
delete newObject;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Définir les propriétés de l'objet
|
// Définir les propriétés de l'objet
|
||||||
newObject->SetPosition(XMVectorSet(posX, posY, posZ, 1.0f));
|
|
||||||
newObject->SetRotation(XMVectorSet(rotX, rotY, rotZ, 1.0f));
|
|
||||||
newObject->SetScale(XMVectorSet(scaleX, scaleY, scaleZ, 1.0f));
|
|
||||||
newObject->SetName(name);
|
|
||||||
newObject->SetId(id);
|
newObject->SetId(id);
|
||||||
|
newObject->SetName(name);
|
||||||
|
newObject->SetPosition(XMLoadFloat3(&position));
|
||||||
|
newObject->SetRotation(XMLoadFloat3(&rotation));
|
||||||
|
newObject->SetScale(XMLoadFloat3(&scale));
|
||||||
newObject->SetModelPath(wModelPath);
|
newObject->SetModelPath(wModelPath);
|
||||||
newObject->SetActiveShader(newObject->StringToShaderType(shaderTypeStr));
|
newObject->SetActiveShader(newObject->StringToShaderType(shaderTypeStr));
|
||||||
|
newObject->SetBoundingRadius(boundingRadius);
|
||||||
newObject->SetType(newObject->StringToObjectType(objectTypeStr));
|
newObject->SetType(newObject->StringToObjectType(objectTypeStr));
|
||||||
newObject->SetMass(mass);
|
newObject->SetMass(mass);
|
||||||
newObject->SetPhysicsEnabled(physicsEnabled);
|
newObject->SetPhysicsEnabled(physicsEnabled);
|
||||||
|
|
||||||
// Mettre à jour les matrices de l'objet
|
// Mettre à jour l'ID global si nécessaire
|
||||||
newObject->Update();
|
|
||||||
|
|
||||||
// Ajouter l'objet à la liste
|
|
||||||
m_object.push_back(newObject);
|
|
||||||
|
|
||||||
// Mettre à jour l'ID global
|
|
||||||
if (id >= m_ObjectId) {
|
if (id >= m_ObjectId) {
|
||||||
m_ObjectId = id + 1;
|
m_ObjectId = id + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_object.push_back(newObject);
|
||||||
|
Logger::Get().Log("Loaded object: " + name, __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||||
}
|
}
|
||||||
|
|
||||||
inFile.close();
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring ApplicationClass::GetScenePath()
|
std::wstring ApplicationClass::GetScenePath()
|
||||||
|
@ -92,7 +92,6 @@ void imguiManager::SetupDockspace(ApplicationClass* app) {
|
|||||||
ImGui::MenuItem("Object Window", NULL, &showObjectWindow);
|
ImGui::MenuItem("Object Window", NULL, &showObjectWindow);
|
||||||
ImGui::MenuItem("Terrain Window", NULL, &showTerrainWindow);
|
ImGui::MenuItem("Terrain Window", NULL, &showTerrainWindow);
|
||||||
ImGui::MenuItem("Light Window", NULL, &showLightWindow);
|
ImGui::MenuItem("Light Window", NULL, &showLightWindow);
|
||||||
ImGui::MenuItem("Old Scene Window", NULL, &showOldSceneWindow);
|
|
||||||
ImGui::MenuItem("Engine Settings Window", NULL, &showEngineSettingsWindow);
|
ImGui::MenuItem("Engine Settings Window", NULL, &showEngineSettingsWindow);
|
||||||
ImGui::MenuItem("Log Window", NULL, &showLogWindow);
|
ImGui::MenuItem("Log Window", NULL, &showLogWindow);
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
|
@ -44,12 +44,6 @@ bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceCon
|
|||||||
|
|
||||||
m_Textures = textures; // Copie de la structure de textures
|
m_Textures = textures; // Copie de la structure de textures
|
||||||
|
|
||||||
// // Copie de toutes les textures de la structure
|
|
||||||
// for (auto& tex : textures.diffuse) m_Textures.diffuse.push_back(tex);
|
|
||||||
// for (auto& tex : textures.normal) m_Textures.normal.push_back(tex);
|
|
||||||
// for (auto& tex : textures.specular) m_Textures.specular.push_back(tex);
|
|
||||||
// for (auto& tex : textures.alpha) m_Textures.alpha.push_back(tex);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -581,6 +575,65 @@ void ModelClass::ReleaseModel()
|
|||||||
// return ChangeTexture(device, deviceContext, filename, TextureType::Diffuse, index);
|
// return ChangeTexture(device, deviceContext, filename, TextureType::Diffuse, index);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
bool ModelClass::PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* deviceContext, TextureContainer& textureContainer)
|
||||||
|
{
|
||||||
|
HRESULT hResult;
|
||||||
|
|
||||||
|
// Charger les textures diffuses
|
||||||
|
for (const auto& texturePath : textureContainer.diffusePaths)
|
||||||
|
{
|
||||||
|
ID3D11ShaderResourceView* texture = nullptr;
|
||||||
|
hResult = DirectX::CreateWICTextureFromFile(device, deviceContext, texturePath.c_str(), nullptr, &texture);
|
||||||
|
if (FAILED(hResult))
|
||||||
|
{
|
||||||
|
Logger::Get().Log("Échec du chargement de la texture diffuse: " + std::string(texturePath.begin(), texturePath.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
textureContainer.diffuse.push_back(texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Charger les textures normales
|
||||||
|
for (const auto& texturePath : textureContainer.normalPaths)
|
||||||
|
{
|
||||||
|
ID3D11ShaderResourceView* texture = nullptr;
|
||||||
|
hResult = DirectX::CreateWICTextureFromFile(device, deviceContext, texturePath.c_str(), nullptr, &texture);
|
||||||
|
if (FAILED(hResult))
|
||||||
|
{
|
||||||
|
Logger::Get().Log("Échec du chargement de la texture normale: " + std::string(texturePath.begin(), texturePath.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
textureContainer.normal.push_back(texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Charger les textures spéculaires
|
||||||
|
for (const auto& texturePath : textureContainer.specularPaths)
|
||||||
|
{
|
||||||
|
ID3D11ShaderResourceView* texture = nullptr;
|
||||||
|
hResult = DirectX::CreateWICTextureFromFile(device, deviceContext, texturePath.c_str(), nullptr, &texture);
|
||||||
|
if (FAILED(hResult))
|
||||||
|
{
|
||||||
|
Logger::Get().Log("Échec du chargement de la texture spéculaire: " + std::string(texturePath.begin(), texturePath.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
textureContainer.specular.push_back(texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Charger les textures alpha
|
||||||
|
for (const auto& texturePath : textureContainer.alphaPaths)
|
||||||
|
{
|
||||||
|
ID3D11ShaderResourceView* texture = nullptr;
|
||||||
|
hResult = DirectX::CreateWICTextureFromFile(device, deviceContext, texturePath.c_str(), nullptr, &texture);
|
||||||
|
if (FAILED(hResult))
|
||||||
|
{
|
||||||
|
Logger::Get().Log("Échec du chargement de la texture alpha: " + std::string(texturePath.begin(), texturePath.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
textureContainer.alpha.push_back(texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool ModelClass::ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, TextureType type, int index) {
|
bool ModelClass::ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, TextureType type, int index) {
|
||||||
Logger::Get().Log("Changing texture", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
Logger::Get().Log("Changing texture", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||||
|
|
||||||
@ -705,4 +758,5 @@ bool ModelClass::AddTexture(ID3D11ShaderResourceView* texture, TextureType type)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user