Export bfres files as model containers on batch exporting.

This commit is contained in:
KillzXGaming 2020-07-29 19:54:17 -04:00
parent 2e71d8056c
commit 3d32e44e73
6 changed files with 45 additions and 16 deletions

View file

@ -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<STGenericObject> ExportableMeshes => BFRESRender.Meshes;
public IEnumerable<STGenericMaterial> ExportableMaterials
public IEnumerable<STGenericModel> ExportableModels
{
get
{
List<FMAT> materials = new List<FMAT>();
foreach (var model in BFRESRender.models)
materials.AddRange(model.materials.Values);
return materials;
}
get { return BFRESRender.models; }
}
public IEnumerable<STGenericTexture> 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

View file

@ -1356,6 +1356,8 @@ namespace Bfres.Structs
bn.UserDataDict = new ResDict();
}
public override STSkeleton GenericSkeleton => Skeleton;
public FSKL Skeleton
{
get

View file

@ -20,6 +20,8 @@ namespace Toolbox.Library
}
public virtual STSkeleton GenericSkeleton { get; set; }
private IEnumerable<STGenericMaterial> _materials;
private IEnumerable<STGenericObject> _objects;

View file

@ -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<STGenericModel> ExportableModels { get; }
IEnumerable<STGenericTexture> ExportableTextures { get; }
}
}

View file

@ -412,6 +412,7 @@
<Compile Include="Interfaces\IArchiveQuickAccess.cs" />
<Compile Include="Interfaces\IMainForm.cs" />
<Compile Include="Interfaces\IMdiContainer.cs" />
<Compile Include="Interfaces\ModelData\IExportableModelContainer.cs" />
<Compile Include="Interfaces\ModelData\IExportableModel.cs" />
<Compile Include="Interfaces\Textures\ITextureIconLoader.cs" />
<Compile Include="Interfaces\Utility\ICloneableNode.cs" />

View file

@ -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();