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="">
|
||||
<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/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/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/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/object.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/object.cpp" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<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="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/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" />
|
||||
@ -49,25 +79,25 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"C++ Project.enginecustom.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.build.unityPlugin",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"C++ Project.enginecustom.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.build.unityPlugin",
|
||||
"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">
|
||||
@ -185,7 +215,8 @@
|
||||
<workItem from="1746456965664" duration="13000" />
|
||||
<workItem from="1746469494034" duration="799000" />
|
||||
<workItem from="1746526901276" duration="2023000" />
|
||||
<workItem from="1746536290167" duration="1831000" />
|
||||
<workItem from="1746536290167" duration="1908000" />
|
||||
<workItem from="1746538260893" duration="5726000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Minor update - viewport window tweak">
|
||||
<option name="closed" value="true" />
|
||||
@ -243,11 +274,6 @@
|
||||
<properties exception="System.Threading.ThreadAbortException" breakIfHandledByOtherCode="false" displayValue="System.Threading.ThreadAbortException" />
|
||||
<option name="timeStamp" value="3" />
|
||||
</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>
|
||||
</breakpoint-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
|
||||
|
||||
[Window][Log Window]
|
||||
Pos=8,627
|
||||
Size=1568,226
|
||||
Pos=8,37
|
||||
Size=16,19
|
||||
Collapsed=0
|
||||
DockId=0x00000006,0
|
||||
|
||||
|
@ -151,7 +151,7 @@ public:
|
||||
|
||||
// Save and load scene
|
||||
void SaveScene();
|
||||
void LoadScene();
|
||||
bool LoadScene();
|
||||
|
||||
void SetScenePath(std::string path) { m_scenePath = path; };
|
||||
std::wstring GetScenePath();
|
||||
|
@ -225,6 +225,8 @@ public:
|
||||
|
||||
void SetTextureContainer (TextureContainer& texturesContainer) { m_Textures = texturesContainer; }
|
||||
TextureContainer GetTextureContainer() const { return m_Textures; }
|
||||
|
||||
bool PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* deviceContext, TextureContainer& textureContainer);
|
||||
|
||||
private:
|
||||
bool InitializeBuffers(ID3D11Device*);
|
||||
|
@ -2028,8 +2028,11 @@ void ApplicationClass::SaveScene() {
|
||||
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();
|
||||
if (!scenePath.empty())
|
||||
{
|
||||
@ -2038,14 +2041,15 @@ void ApplicationClass::LoadScene() {
|
||||
|
||||
if (m_scenePath.empty()) {
|
||||
Logger::Get().Log("Scene path is empty. Cannot load scene.", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::ifstream inFile(scenePath);
|
||||
if (!inFile.is_open()) {
|
||||
Logger::Get().Log("Failed to open file for loading scene: ", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
}
|
||||
|
||||
|
||||
std::ifstream inFile(scenePath);
|
||||
if (!inFile.is_open()) {
|
||||
Logger::Get().Log("Failed to open file for loading scene: ", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Nettoyer les objets existants
|
||||
for (auto& obj : m_object) {
|
||||
if (obj) {
|
||||
@ -2055,119 +2059,149 @@ void ApplicationClass::LoadScene() {
|
||||
}
|
||||
m_object.clear();
|
||||
m_ObjectId = 0;
|
||||
|
||||
|
||||
// Sauvegarder le répertoire de travail actuel
|
||||
std::wstring currentDirectory = m_WFolder;
|
||||
|
||||
std::string line;
|
||||
while (std::getline(inFile, line)) {
|
||||
std::istringstream iss(line);
|
||||
|
||||
int id;
|
||||
std::string name;
|
||||
float posX, posY, posZ, rotX, rotY, rotZ, scaleX, scaleY, scaleZ;
|
||||
std::string modelPath, shaderTypeStr, objectTypeStr;
|
||||
float boundingRadius, mass;
|
||||
XMFLOAT3 position, rotation, scale;
|
||||
std::string modelPath;
|
||||
std::string shaderTypeStr;
|
||||
float boundingRadius;
|
||||
std::string objectTypeStr;
|
||||
float mass;
|
||||
bool physicsEnabled;
|
||||
|
||||
// Lire les données de base
|
||||
iss >> id >> name >> posX >> posY >> posZ >> rotX >> rotY >> rotZ
|
||||
>> scaleX >> scaleY >> scaleZ >> modelPath >> shaderTypeStr
|
||||
>> boundingRadius >> objectTypeStr >> mass >> physicsEnabled;
|
||||
|
||||
// Convertir les chemins de modèle en wstring pour Windows
|
||||
std::wstring wModelPath(modelPath.begin(), modelPath.end());
|
||||
|
||||
|
||||
// Lire les données de base de l'objet
|
||||
iss >> id >> name
|
||||
>> position.x >> position.y >> position.z
|
||||
>> rotation.x >> rotation.y >> rotation.z
|
||||
>> scale.x >> scale.y >> scale.z
|
||||
>> modelPath >> shaderTypeStr
|
||||
>> 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
|
||||
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
|
||||
TextureContainer textures;
|
||||
|
||||
// Textures diffuses
|
||||
int diffuseCount;
|
||||
iss >> diffuseCount;
|
||||
std::vector<std::wstring> diffusePaths;
|
||||
for (int i = 0; i < diffuseCount; i++) {
|
||||
std::string path;
|
||||
iss >> path;
|
||||
diffusePaths.push_back(std::wstring(path.begin(), path.end()));
|
||||
// IMPORTANT: Vider les conteneurs de chemins de textures
|
||||
objectTextures.diffusePaths.clear();
|
||||
objectTextures.normalPaths.clear();
|
||||
objectTextures.specularPaths.clear();
|
||||
objectTextures.alphaPaths.clear();
|
||||
|
||||
// Lire les chemins des textures diffuses
|
||||
int diffuseTextureCount;
|
||||
iss >> diffuseTextureCount;
|
||||
for (int i = 0; i < diffuseTextureCount; i++) {
|
||||
std::string texturePath;
|
||||
iss >> texturePath;
|
||||
std::wstring wTexturePath(texturePath.begin(), texturePath.end());
|
||||
objectTextures.diffusePaths.push_back(wTexturePath);
|
||||
}
|
||||
|
||||
// Textures normales
|
||||
int normalCount;
|
||||
iss >> normalCount;
|
||||
std::vector<std::wstring> normalPaths;
|
||||
for (int i = 0; i < normalCount; i++) {
|
||||
std::string path;
|
||||
iss >> path;
|
||||
normalPaths.push_back(std::wstring(path.begin(), path.end()));
|
||||
|
||||
// Lire les chemins des textures normales
|
||||
int normalTextureCount;
|
||||
iss >> normalTextureCount;
|
||||
for (int i = 0; i < normalTextureCount; i++) {
|
||||
std::string texturePath;
|
||||
iss >> texturePath;
|
||||
std::wstring wTexturePath(texturePath.begin(), texturePath.end());
|
||||
objectTextures.normalPaths.push_back(wTexturePath);
|
||||
}
|
||||
|
||||
// Textures spéculaires
|
||||
int specularCount;
|
||||
iss >> specularCount;
|
||||
std::vector<std::wstring> specularPaths;
|
||||
for (int i = 0; i < specularCount; i++) {
|
||||
std::string path;
|
||||
iss >> path;
|
||||
specularPaths.push_back(std::wstring(path.begin(), path.end()));
|
||||
|
||||
// Lire les chemins des textures spéculaires
|
||||
int specularTextureCount;
|
||||
iss >> specularTextureCount;
|
||||
for (int i = 0; i < specularTextureCount; i++) {
|
||||
std::string texturePath;
|
||||
iss >> texturePath;
|
||||
std::wstring wTexturePath(texturePath.begin(), texturePath.end());
|
||||
objectTextures.specularPaths.push_back(wTexturePath);
|
||||
}
|
||||
|
||||
// Textures alpha
|
||||
int alphaCount;
|
||||
iss >> alphaCount;
|
||||
std::vector<std::wstring> alphaPaths;
|
||||
for (int i = 0; i < alphaCount; i++) {
|
||||
std::string path;
|
||||
iss >> path;
|
||||
alphaPaths.push_back(std::wstring(path.begin(), path.end()));
|
||||
|
||||
// Lire les chemins des textures alpha
|
||||
int alphaTextureCount;
|
||||
iss >> alphaTextureCount;
|
||||
for (int i = 0; i < alphaTextureCount; i++) {
|
||||
std::string texturePath;
|
||||
iss >> texturePath;
|
||||
std::wstring wTexturePath(texturePath.begin(), texturePath.end());
|
||||
objectTextures.alphaPaths.push_back(wTexturePath);
|
||||
}
|
||||
|
||||
// Combiner tous les chemins de textures
|
||||
std::vector<std::wstring> allTextures;
|
||||
allTextures.insert(allTextures.end(), diffusePaths.begin(), diffusePaths.end());
|
||||
allTextures.insert(allTextures.end(), normalPaths.begin(), normalPaths.end());
|
||||
allTextures.insert(allTextures.end(), specularPaths.begin(), specularPaths.end());
|
||||
allTextures.insert(allTextures.end(), alphaPaths.begin(), alphaPaths.end());
|
||||
|
||||
// Charger les textures
|
||||
newObject->LoadTexturesFromPath(allTextures, textures, m_Direct3D);
|
||||
|
||||
// Convertir le chemin du modèle en char* pour l'initialisation
|
||||
char modelFilename[128];
|
||||
wcstombs_s(nullptr, modelFilename, sizeof(modelFilename), wModelPath.c_str(), _TRUNCATE);
|
||||
|
||||
// Initialiser l'objet avec le modèle et les textures
|
||||
if (!newObject->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, textures)) {
|
||||
Logger::Get().Log("Failed to initialize object from scene file", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
|
||||
// preload texture
|
||||
if (!newObject->PreloadTextures(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), objectTextures))
|
||||
{
|
||||
// Gérer l'erreur
|
||||
return false;
|
||||
}
|
||||
|
||||
// Initialiser l'objet avec le modèle et les chemins de textures
|
||||
char modelFilename[256];
|
||||
size_t convertedChars = 0;
|
||||
wcstombs_s(&convertedChars, modelFilename, sizeof(modelFilename), wModelPath.c_str(), _TRUNCATE);
|
||||
|
||||
Logger::Get().Log("Loading model: " + std::string(modelFilename), __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
|
||||
// NE PAS charger les textures avant Initialize
|
||||
// Laisser la méthode Initialize s'en charger à partir des chemins
|
||||
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;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// 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->SetName(name);
|
||||
newObject->SetPosition(XMLoadFloat3(&position));
|
||||
newObject->SetRotation(XMLoadFloat3(&rotation));
|
||||
newObject->SetScale(XMLoadFloat3(&scale));
|
||||
newObject->SetModelPath(wModelPath);
|
||||
newObject->SetActiveShader(newObject->StringToShaderType(shaderTypeStr));
|
||||
newObject->SetBoundingRadius(boundingRadius);
|
||||
newObject->SetType(newObject->StringToObjectType(objectTypeStr));
|
||||
newObject->SetMass(mass);
|
||||
newObject->SetPhysicsEnabled(physicsEnabled);
|
||||
|
||||
// Mettre à jour les matrices de l'objet
|
||||
newObject->Update();
|
||||
|
||||
// Ajouter l'objet à la liste
|
||||
m_object.push_back(newObject);
|
||||
|
||||
// Mettre à jour l'ID global
|
||||
|
||||
// Mettre à jour l'ID global si nécessaire
|
||||
if (id >= m_ObjectId) {
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::wstring ApplicationClass::GetScenePath()
|
||||
|
@ -92,7 +92,6 @@ void imguiManager::SetupDockspace(ApplicationClass* app) {
|
||||
ImGui::MenuItem("Object Window", NULL, &showObjectWindow);
|
||||
ImGui::MenuItem("Terrain Window", NULL, &showTerrainWindow);
|
||||
ImGui::MenuItem("Light Window", NULL, &showLightWindow);
|
||||
ImGui::MenuItem("Old Scene Window", NULL, &showOldSceneWindow);
|
||||
ImGui::MenuItem("Engine Settings Window", NULL, &showEngineSettingsWindow);
|
||||
ImGui::MenuItem("Log Window", NULL, &showLogWindow);
|
||||
ImGui::EndMenu();
|
||||
|
@ -44,12 +44,6 @@ bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceCon
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -581,6 +575,65 @@ void ModelClass::ReleaseModel()
|
||||
// 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) {
|
||||
Logger::Get().Log("Changing texture", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
|
||||
@ -705,4 +758,5 @@ bool ModelClass::AddTexture(ID3D11ShaderResourceView* texture, TextureType type)
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user