mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
Bit of cleanup
This commit is contained in:
parent
71fc901798
commit
18fd36d2d7
4 changed files with 28 additions and 14 deletions
|
|
@ -54,8 +54,8 @@ public sealed class ModelManager : SingleTaskQueue, IDisposable
|
|||
return task;
|
||||
}
|
||||
|
||||
public Task ExportToGltf(MdlFile mdl, string path)
|
||||
=> Enqueue(new ExportToGltfAction(mdl, path));
|
||||
public Task ExportToGltf(MdlFile mdl, string outputPath)
|
||||
=> Enqueue(new ExportToGltfAction(mdl, outputPath));
|
||||
|
||||
public void SkeletonTest()
|
||||
{
|
||||
|
|
@ -122,12 +122,12 @@ public sealed class ModelManager : SingleTaskQueue, IDisposable
|
|||
private class ExportToGltfAction : IAction
|
||||
{
|
||||
private readonly MdlFile _mdl;
|
||||
private readonly string _path;
|
||||
private readonly string _outputPath;
|
||||
|
||||
public ExportToGltfAction(MdlFile mdl, string path)
|
||||
public ExportToGltfAction(MdlFile mdl, string outputPath)
|
||||
{
|
||||
_mdl = mdl;
|
||||
_path = path;
|
||||
_outputPath = outputPath;
|
||||
}
|
||||
|
||||
public void Execute(CancellationToken token)
|
||||
|
|
@ -148,7 +148,7 @@ public sealed class ModelManager : SingleTaskQueue, IDisposable
|
|||
}
|
||||
|
||||
var model = scene.ToGltf2();
|
||||
model.SaveGLTF(_path);
|
||||
model.SaveGLTF(_outputPath);
|
||||
}
|
||||
|
||||
public bool Equals(IAction? other)
|
||||
|
|
|
|||
|
|
@ -10,13 +10,18 @@ public partial class ModEditWindow
|
|||
{
|
||||
private class MdlTab : IWritable
|
||||
{
|
||||
private ModEditWindow _edit;
|
||||
|
||||
public readonly MdlFile Mdl;
|
||||
public readonly List<Utf8GamePath> GamePaths;
|
||||
|
||||
private readonly List<string>[] _attributes;
|
||||
|
||||
public MdlTab(byte[] bytes, string path, Mod? mod)
|
||||
public bool PendingIo { get; private set; } = false;
|
||||
|
||||
public MdlTab(ModEditWindow edit, byte[] bytes, string path, Mod? mod)
|
||||
{
|
||||
_edit = edit;
|
||||
|
||||
Mdl = new MdlFile(bytes);
|
||||
GamePaths = mod == null ? new() : FindGamePaths(path, mod);
|
||||
_attributes = CreateAttributes(Mdl);
|
||||
|
|
@ -31,6 +36,9 @@ public partial class ModEditWindow
|
|||
=> Mdl.Write();
|
||||
|
||||
// TODO: this _needs_ to be done asynchronously, kart mods hang for a good second or so
|
||||
/// <summary> Find the list of game paths that may correspond to this model. </summary>
|
||||
/// <param name="path"> Resolved path to a .mdl. </param>
|
||||
/// <param name="mod"> Mod within which the .mdl is resolved. </param>
|
||||
private List<Utf8GamePath> FindGamePaths(string path, Mod mod)
|
||||
{
|
||||
// todo: might be worth ordering based on prio + selection for disambiguating between multiple matches? not sure. same for the multi group case
|
||||
|
|
@ -42,6 +50,15 @@ public partial class ModEditWindow
|
|||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary> Export model to an interchange format. </summary>
|
||||
/// <param name="outputPath"> Disk path to save the resulting file to. </param>
|
||||
public void Export(string outputPath)
|
||||
{
|
||||
PendingIo = true;
|
||||
_edit._models.ExportToGltf(Mdl, outputPath)
|
||||
.ContinueWith(_ => PendingIo = false);
|
||||
}
|
||||
|
||||
/// <summary> Remove the material given by the index. </summary>
|
||||
/// <remarks> Meshes using the removed material are redirected to material 0, and those after the index are corrected. </remarks>
|
||||
public void RemoveMaterial(int materialIndex)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ public partial class ModEditWindow
|
|||
private readonly FileEditor<MdlTab> _modelTab;
|
||||
|
||||
private readonly ModelManager _models;
|
||||
private bool _pendingIo = false;
|
||||
|
||||
private string _modelNewMaterial = string.Empty;
|
||||
private readonly List<TagButtons> _subMeshAttributeTagWidgets = [];
|
||||
|
|
@ -35,11 +34,9 @@ public partial class ModEditWindow
|
|||
);
|
||||
}
|
||||
|
||||
if (ImGuiUtil.DrawDisabledButton("bingo bango", Vector2.Zero, "description", _pendingIo))
|
||||
if (ImGuiUtil.DrawDisabledButton("bingo bango", Vector2.Zero, "description", tab.PendingIo))
|
||||
{
|
||||
_pendingIo = true;
|
||||
var task = _models.ExportToGltf(file, "C:\\Users\\ackwell\\blender\\gltf-tests\\bingo.gltf");
|
||||
task.ContinueWith(_ => _pendingIo = false);
|
||||
tab.Export("C:\\Users\\ackwell\\blender\\gltf-tests\\bingo.gltf");
|
||||
}
|
||||
if (ImGui.Button("zoingo boingo"))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -587,7 +587,7 @@ public partial class ModEditWindow : Window, IDisposable
|
|||
() => PopulateIsOnPlayer(_editor.Files.Mtrl, ResourceType.Mtrl), DrawMaterialPanel, () => _mod?.ModPath.FullName ?? string.Empty,
|
||||
(bytes, path, writable) => new MtrlTab(this, new MtrlFile(bytes), path, writable));
|
||||
_modelTab = new FileEditor<MdlTab>(this, gameData, config, _editor.Compactor, _fileDialog, "Models", ".mdl",
|
||||
() => PopulateIsOnPlayer(_editor.Files.Mdl, ResourceType.Mdl), DrawModelPanel, () => _mod?.ModPath.FullName ?? string.Empty, (bytes, path, _) => new MdlTab(bytes, path, _mod));
|
||||
() => PopulateIsOnPlayer(_editor.Files.Mdl, ResourceType.Mdl), DrawModelPanel, () => _mod?.ModPath.FullName ?? string.Empty, (bytes, path, _) => new MdlTab(this, bytes, path, _mod));
|
||||
_shaderPackageTab = new FileEditor<ShpkTab>(this, gameData, config, _editor.Compactor, _fileDialog, "Shaders", ".shpk",
|
||||
() => PopulateIsOnPlayer(_editor.Files.Shpk, ResourceType.Shpk), DrawShaderPackagePanel, () => _mod?.ModPath.FullName ?? string.Empty,
|
||||
(bytes, _, _) => new ShpkTab(_fileDialog, bytes));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue