mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +01:00
export per example
This commit is contained in:
parent
f8331bc4d8
commit
df43083101
6 changed files with 84 additions and 2 deletions
45
Penumbra/Import/Models/ModelManager.cs
Normal file
45
Penumbra/Import/Models/ModelManager.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
using Penumbra.GameData.Files;
|
||||
using SharpGLTF.Geometry;
|
||||
using SharpGLTF.Geometry.VertexTypes;
|
||||
using SharpGLTF.Materials;
|
||||
using SharpGLTF.Scenes;
|
||||
|
||||
namespace Penumbra.Import.Models;
|
||||
|
||||
public sealed class ModelManager
|
||||
{
|
||||
public ModelManager()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
// TODO: Consider moving import/export onto an async queue, check ../textures/texturemanager
|
||||
|
||||
public void ExportToGltf(/* MdlFile mdl, */string path)
|
||||
{
|
||||
var mesh = new MeshBuilder<VertexPosition>("mesh");
|
||||
|
||||
var material1 = new MaterialBuilder()
|
||||
.WithDoubleSide(true)
|
||||
.WithMetallicRoughnessShader()
|
||||
.WithChannelParam(KnownChannel.BaseColor, KnownProperty.RGBA, new Vector4(1, 0, 0, 1));
|
||||
var primitive1 = mesh.UsePrimitive(material1);
|
||||
primitive1.AddTriangle(new VertexPosition(-10, 0, 0), new VertexPosition(10, 0, 0), new VertexPosition(0, 10, 0));
|
||||
primitive1.AddTriangle(new VertexPosition(10, 0, 0), new VertexPosition(-10, 0, 0), new VertexPosition(0, -10, 0));
|
||||
|
||||
var material2 = new MaterialBuilder()
|
||||
.WithDoubleSide(true)
|
||||
.WithMetallicRoughnessShader()
|
||||
.WithChannelParam(KnownChannel.BaseColor, KnownProperty.RGBA, new Vector4(1, 0, 1, 1));
|
||||
var primitive2 = mesh.UsePrimitive(material2);
|
||||
primitive2.AddQuadrangle(new VertexPosition(-5, 0, 3), new VertexPosition(0, -5, 3), new VertexPosition(5, 0, 3), new VertexPosition(0, 5, 3));
|
||||
|
||||
var scene = new SceneBuilder();
|
||||
scene.AddRigidMesh(mesh, Matrix4x4.Identity);
|
||||
|
||||
var model = scene.ToGltf2();
|
||||
model.SaveGLTF(path);
|
||||
|
||||
// TODO: Draw the rest of the owl.
|
||||
}
|
||||
}
|
||||
|
|
@ -72,6 +72,8 @@
|
|||
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.2" />
|
||||
<PackageReference Include="SharpCompress" Version="0.33.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="SharpGLTF.Core" Version="1.0.0-alpha0030" />
|
||||
<PackageReference Include="SharpGLTF.Toolkit" Version="1.0.0-alpha0030" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ using Penumbra.Collections.Cache;
|
|||
using Penumbra.Collections.Manager;
|
||||
using Penumbra.GameData;
|
||||
using Penumbra.GameData.Data;
|
||||
using Penumbra.Import.Models;
|
||||
using Penumbra.Import.Textures;
|
||||
using Penumbra.Interop.PathResolving;
|
||||
using Penumbra.Interop.ResourceLoading;
|
||||
|
|
@ -185,7 +186,8 @@ public static class ServiceManager
|
|||
.AddSingleton<ModNormalizer>()
|
||||
.AddSingleton<ModMerger>()
|
||||
.AddSingleton<ModEditor>()
|
||||
.AddSingleton<TextureManager>();
|
||||
.AddSingleton<TextureManager>()
|
||||
.AddSingleton<ModelManager>();
|
||||
|
||||
private static IServiceCollection AddApi(this IServiceCollection services)
|
||||
=> services.AddSingleton<PenumbraApi>()
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using OtterGui.Raii;
|
|||
using OtterGui.Widgets;
|
||||
using Penumbra.GameData;
|
||||
using Penumbra.GameData.Files;
|
||||
using Penumbra.Import.Models;
|
||||
using Penumbra.String.Classes;
|
||||
|
||||
namespace Penumbra.UI.AdvancedWindow;
|
||||
|
|
@ -13,6 +14,8 @@ public partial class ModEditWindow
|
|||
{
|
||||
private const int MdlMaterialMaximum = 4;
|
||||
|
||||
private readonly ModelManager _models;
|
||||
|
||||
private readonly FileEditor<MdlTab> _modelTab;
|
||||
|
||||
private string _modelNewMaterial = string.Empty;
|
||||
|
|
@ -31,6 +34,11 @@ public partial class ModEditWindow
|
|||
);
|
||||
}
|
||||
|
||||
if (ImGui.Button("bingo bango"))
|
||||
{
|
||||
_models.ExportToGltf("C:\\Users\\ackwell\\blender\\gltf-tests\\bingo.gltf");
|
||||
}
|
||||
|
||||
var ret = false;
|
||||
|
||||
ret |= DrawModelMaterialDetails(tab, disabled);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ using Penumbra.Collections.Manager;
|
|||
using Penumbra.Communication;
|
||||
using Penumbra.GameData.Enums;
|
||||
using Penumbra.GameData.Files;
|
||||
using Penumbra.Import.Models;
|
||||
using Penumbra.Import.Textures;
|
||||
using Penumbra.Interop.ResourceTree;
|
||||
using Penumbra.Interop.Services;
|
||||
|
|
@ -563,7 +564,7 @@ public partial class ModEditWindow : Window, IDisposable
|
|||
public ModEditWindow(PerformanceTracker performance, FileDialogService fileDialog, ItemSwapTab itemSwapTab, IDataManager gameData,
|
||||
Configuration config, ModEditor editor, ResourceTreeFactory resourceTreeFactory, MetaFileManager metaFileManager,
|
||||
StainService stainService, ActiveCollections activeCollections, DalamudServices dalamud, ModMergeTab modMergeTab,
|
||||
CommunicatorService communicator, TextureManager textures, IDragDropManager dragDropManager, GameEventManager gameEvents,
|
||||
CommunicatorService communicator, TextureManager textures, ModelManager models, IDragDropManager dragDropManager, GameEventManager gameEvents,
|
||||
ChangedItemDrawer changedItemDrawer)
|
||||
: base(WindowBaseLabel)
|
||||
{
|
||||
|
|
@ -579,6 +580,7 @@ public partial class ModEditWindow : Window, IDisposable
|
|||
_communicator = communicator;
|
||||
_dragDropManager = dragDropManager;
|
||||
_textures = textures;
|
||||
_models = models;
|
||||
_fileDialog = fileDialog;
|
||||
_gameEvents = gameEvents;
|
||||
_materialTab = new FileEditor<MtrlTab>(this, gameData, config, _editor.Compactor, _fileDialog, "Materials", ".mtrl",
|
||||
|
|
|
|||
|
|
@ -26,6 +26,21 @@
|
|||
"resolved": "0.33.0",
|
||||
"contentHash": "FlHfpTAADzaSlVCBF33iKJk9UhOr3Xj+r5LXbW2GzqYr0SrhiOf6shLX2LC2fqs7g7d+YlwKbBXqWFtb+e7icw=="
|
||||
},
|
||||
"SharpGLTF.Core": {
|
||||
"type": "Direct",
|
||||
"requested": "[1.0.0-alpha0030, )",
|
||||
"resolved": "1.0.0-alpha0030",
|
||||
"contentHash": "HVL6PcrM0H/uEk96nRZfhtPeYvSFGHnni3g1aIckot2IWVp0jLMH5KWgaWfsatEz4Yds3XcdSLUWmJZivDBUPA=="
|
||||
},
|
||||
"SharpGLTF.Toolkit": {
|
||||
"type": "Direct",
|
||||
"requested": "[1.0.0-alpha0030, )",
|
||||
"resolved": "1.0.0-alpha0030",
|
||||
"contentHash": "nsoJWAFhXgEky9bVCY0zLeZVDx+S88u7VjvuebvMb6dJiNyFOGF6FrrMHiJe+x5pcVBxxlc3VoXliBF7r/EqYA==",
|
||||
"dependencies": {
|
||||
"SharpGLTF.Runtime": "1.0.0-alpha0030"
|
||||
}
|
||||
},
|
||||
"SixLabors.ImageSharp": {
|
||||
"type": "Direct",
|
||||
"requested": "[2.1.2, )",
|
||||
|
|
@ -46,6 +61,14 @@
|
|||
"resolved": "5.0.0",
|
||||
"contentHash": "VyPlqzH2wavqquTcYpkIIAQ6WdenuKoFN0BdYBbCWsclXacSOHNQn66Gt4z5NBqEYW0FAPm5rlvki9ZiCij5xQ=="
|
||||
},
|
||||
"SharpGLTF.Runtime": {
|
||||
"type": "Transitive",
|
||||
"resolved": "1.0.0-alpha0030",
|
||||
"contentHash": "Ysn+fyj9EVXj6mfG0BmzSTBGNi/QvcnTrMd54dBMOlI/TsMRvnOY3JjTn0MpeH2CgHXX4qogzlDt4m+rb3n4Og==",
|
||||
"dependencies": {
|
||||
"SharpGLTF.Core": "1.0.0-alpha0030"
|
||||
}
|
||||
},
|
||||
"System.Runtime.CompilerServices.Unsafe": {
|
||||
"type": "Transitive",
|
||||
"resolved": "5.0.0",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue