diff --git a/File_Format_Library/FileFormats/BFRES/BFRES.cs b/File_Format_Library/FileFormats/BFRES/BFRES.cs index b91c611c..d70c4d65 100644 --- a/File_Format_Library/FileFormats/BFRES/BFRES.cs +++ b/File_Format_Library/FileFormats/BFRES/BFRES.cs @@ -20,7 +20,7 @@ using OpenTK; namespace FirstPlugin { - public class BFRES : BFRESWrapper, IFileFormat, ITextureContainer, IExportableModel + public class BFRES : BFRESWrapper, IFileFormat, ITextureContainer, IExportableModelContainer { public FileType FileType { get; set; } = FileType.Resource; @@ -58,25 +58,13 @@ namespace FirstPlugin set { } } - public IEnumerable ExportableMeshes => BFRESRender.Meshes; - - public IEnumerable ExportableMaterials + public IEnumerable ExportableModels { - get - { - List materials = new List(); - foreach (var model in BFRESRender.models) - materials.AddRange(model.materials.Values); - return materials; - } + get { return BFRESRender.models; } } + public IEnumerable ExportableTextures => TextureList; - public STSkeleton ExportableSkeleton - { - get { return BFRESRender.models[0].Skeleton; } - } - public override string ExportFilter => Utils.GetAllFilters(new BFRES()); //Stores the skeleton and models in this diff --git a/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL.cs b/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL.cs index 4295ea87..698c5762 100644 --- a/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL.cs +++ b/File_Format_Library/FileFormats/BFRES/Bfres Structs/SubFiles/FMDL.cs @@ -1356,6 +1356,8 @@ namespace Bfres.Structs bn.UserDataDict = new ResDict(); } + public override STSkeleton GenericSkeleton => Skeleton; + public FSKL Skeleton { get diff --git a/Switch_Toolbox_Library/Generics/GenericModel.cs b/Switch_Toolbox_Library/Generics/GenericModel.cs index 50028e8d..7da50442 100644 --- a/Switch_Toolbox_Library/Generics/GenericModel.cs +++ b/Switch_Toolbox_Library/Generics/GenericModel.cs @@ -20,6 +20,8 @@ namespace Toolbox.Library } + public virtual STSkeleton GenericSkeleton { get; set; } + private IEnumerable _materials; private IEnumerable _objects; diff --git a/Switch_Toolbox_Library/Interfaces/ModelData/IExportableModelContainer.cs b/Switch_Toolbox_Library/Interfaces/ModelData/IExportableModelContainer.cs new file mode 100644 index 00000000..5a6253f0 --- /dev/null +++ b/Switch_Toolbox_Library/Interfaces/ModelData/IExportableModelContainer.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Toolbox.Library +{ + public interface IExportableModelContainer + { + IEnumerable ExportableModels { get; } + IEnumerable ExportableTextures { get; } + } +} diff --git a/Switch_Toolbox_Library/Toolbox_Library.csproj b/Switch_Toolbox_Library/Toolbox_Library.csproj index a65649ab..67abc8be 100644 --- a/Switch_Toolbox_Library/Toolbox_Library.csproj +++ b/Switch_Toolbox_Library/Toolbox_Library.csproj @@ -412,6 +412,7 @@ + diff --git a/Toolbox/MainForm.cs b/Toolbox/MainForm.cs index 7c67bfbb..c69c3a81 100644 --- a/Toolbox/MainForm.cs +++ b/Toolbox/MainForm.cs @@ -1495,6 +1495,28 @@ namespace Toolbox ExportTexture(tex, settings, $"{outputFolder}/{tex.Text}", extension); } } + else if (fileFormat is IExportableModelContainer && exportMode == ExportMode.Models) + { + string name = fileFormat.FileName.Split('.').FirstOrDefault(); + if (settings.SeperateTextureContainers) + outputFolder = Path.Combine(outputFolder, name); + + if (!Directory.Exists(outputFolder)) + Directory.CreateDirectory(outputFolder); + + DAE.ExportSettings daesettings = new DAE.ExportSettings(); + daesettings.SuppressConfirmDialog = true; + + var textures = ((IExportableModelContainer)fileFormat).ExportableTextures.ToList(); + foreach (var model in ((IExportableModelContainer)fileFormat).ExportableModels) + { + string path = $"{outputFolder}/{model.Text}"; + path = Utils.RenameDuplicateString(batchExportFileList, path, 0, 3); + + DAE.Export($"{path}.{extension}", daesettings, model, textures, model.GenericSkeleton); + batchExportFileList.Add(path); + } + } else if (fileFormat is IExportableModel && exportMode == ExportMode.Models) { string name = fileFormat.FileName.Split('.').FirstOrDefault();