From 39d2307cd3bc8983cec1389e6121820d888277da Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Sun, 17 Nov 2019 08:59:11 -0500 Subject: [PATCH] Some fixes. Fix DAE exporting if textures fail to export. Fix bone detection for FBX Add model index for LM3 models. --- .../FileFormats/NLG/LM3/LM3_DICT.cs | 2 +- .../FileFormats/Assimp/Assimp.cs | 9 +++- Switch_Toolbox_Library/FileFormats/DAE/DAE.cs | 44 ++++++++++++------- 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/File_Format_Library/FileFormats/NLG/LM3/LM3_DICT.cs b/File_Format_Library/FileFormats/NLG/LM3/LM3_DICT.cs index 2948552e..aaf9bddf 100644 --- a/File_Format_Library/FileFormats/NLG/LM3/LM3_DICT.cs +++ b/File_Format_Library/FileFormats/NLG/LM3/LM3_DICT.cs @@ -327,7 +327,7 @@ namespace FirstPlugin.LuigisMansion3 text = NLG_Common.HashNames[hashID]; - currentModel.Text = text; + currentModel.Text = $"{currentModel.Text} [{text}]"; } } break; diff --git a/Switch_Toolbox_Library/FileFormats/Assimp/Assimp.cs b/Switch_Toolbox_Library/FileFormats/Assimp/Assimp.cs index 5cf19cc3..3e441417 100644 --- a/Switch_Toolbox_Library/FileFormats/Assimp/Assimp.cs +++ b/Switch_Toolbox_Library/FileFormats/Assimp/Assimp.cs @@ -455,7 +455,14 @@ namespace Toolbox.Library if (DaeHelper.IDMapToName.ContainsKey(node.Name)) Name = DaeHelper.IDMapToName[node.Name]; - bool IsBone = false; + string ParentArmatureName = node.Parent != null ? node.Parent.Name : ""; + if (ParentArmatureName != string.Empty && DaeHelper.IDMapToName.ContainsKey(ParentArmatureName)) + ParentArmatureName = DaeHelper.IDMapToName[ParentArmatureName]; + + bool IsBone = boneNames.Contains(Name) && !boneNames.Contains(ParentArmatureName) || + Name.Contains("Skl_Root") || Name.Contains("nw4f_root") || + Name.Contains("skl_root") || Name == "Root"; + if (DaeHelper.VisualSceneNodeTypes.ContainsKey(Name)) { if (DaeHelper.VisualSceneNodeTypes[Name] == "JOINT") IsBone = true; diff --git a/Switch_Toolbox_Library/FileFormats/DAE/DAE.cs b/Switch_Toolbox_Library/FileFormats/DAE/DAE.cs index cbcab3ce..d4e097e4 100644 --- a/Switch_Toolbox_Library/FileFormats/DAE/DAE.cs +++ b/Switch_Toolbox_Library/FileFormats/DAE/DAE.cs @@ -62,6 +62,8 @@ namespace Toolbox.Library if (Materials == null) Materials = new List(); + List failedTextureExport = new List(); + STProgressBar progressBar = new STProgressBar(); progressBar.Task = "Exporting Model..."; progressBar.Value = 0; @@ -98,26 +100,36 @@ namespace Toolbox.Library progressBar.Value = ((i * 100) / Textures.Count); progressBar.Refresh(); - var bitmap = Textures[i].GetBitmap(); - - string textureName = Textures[i].Text; - if (textureName.RemoveIllegaleFileNameCharacters() != textureName) + try { - string properName = textureName.RemoveIllegaleFileNameCharacters(); - for (int m = 0; m < Materials?.Count; m++) { - foreach (var tex in Materials[m].TextureMaps) { - if (tex.Name == textureName) - tex.Name = properName; + var bitmap = Textures[i].GetBitmap(); + if (bitmap != null) + { + string textureName = Textures[i].Text; + if (textureName.RemoveIllegaleFileNameCharacters() != textureName) + { + string properName = textureName.RemoveIllegaleFileNameCharacters(); + for (int m = 0; m < Materials?.Count; m++) + { + foreach (var tex in Materials[m].TextureMaps) + { + if (tex.Name == textureName) + tex.Name = properName; + } + } + + textureName = properName; } + + bitmap.Save($"{TexturePath}/{textureName}.png"); + bitmap.Dispose(); + + GC.Collect(); } - - textureName = properName; } - - bitmap.Save($"{TexturePath}/{textureName}.png"); - bitmap.Dispose(); - - GC.Collect(); + catch (Exception ex) { + failedTextureExport.Add(Textures[i].Text); + } } }