diff --git a/File_Format_Library/FileFormats/BCRES/BCRES.cs b/File_Format_Library/FileFormats/BCRES/BCRES.cs index 222b0c29..a63b4ae8 100644 --- a/File_Format_Library/FileFormats/BCRES/BCRES.cs +++ b/File_Format_Library/FileFormats/BCRES/BCRES.cs @@ -45,6 +45,13 @@ namespace FirstPlugin public BCRES_Render RenderedBcres; public DrawableContainer DrawableContainer = new DrawableContainer(); + private List Textures = new List(); + + public List GetTextures() + { + return Textures; + } + public void Load(System.IO.Stream stream) { Text = FileName; @@ -93,7 +100,9 @@ namespace FirstPlugin RenderedBcres.Models.Add(CMDLWrapper); break; case BCRESGroupType.Textures: - Folder.AddNode(new TXOBWrapper((Texture)section, this)); + var wrapper = new TXOBWrapper((Texture)section, this); + Folder.AddNode(wrapper); + Textures.Add(wrapper); PluginRuntime.bcresTexContainers.Add(Folder); break; } @@ -171,6 +180,9 @@ namespace FirstPlugin public void Unload() { ObjectEditor.RemoveContainer(DrawableContainer); + foreach (var tex in Textures) + tex?.DisposeRenderable(); + Textures.Clear(); } public void Save(System.IO.Stream stream) diff --git a/File_Format_Library/FileFormats/BCRES/Wrappers/CMDL/CMDLWrapper.cs b/File_Format_Library/FileFormats/BCRES/Wrappers/CMDL/CMDLWrapper.cs index d5cc52a9..ce21886c 100644 --- a/File_Format_Library/FileFormats/BCRES/Wrappers/CMDL/CMDLWrapper.cs +++ b/File_Format_Library/FileFormats/BCRES/Wrappers/CMDL/CMDLWrapper.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using System.Windows.Forms; using Toolbox.Library; using BcresLibrary; +using Toolbox.Library.Forms; namespace FirstPlugin { @@ -26,6 +27,19 @@ namespace FirstPlugin SelectedImageKey = "Model"; } + public override void Export(string FileName) + { + AssimpSaver assimp = new AssimpSaver(); + ExportModelSettings settings = new ExportModelSettings(); + + var model = new STGenericModel(); + model.Materials = Materials; + model.Objects = Shapes; + + + assimp.SaveFromModel(model, FileName, BcresParent.GetTextures(), Skeleton.Renderable); + } + public CMDLWrapper(Model model, BCRES bcres) : base() { BcresParent = bcres;