From 95b032d12ee1f2a02fd88ba535f5ee19c706112f Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Wed, 20 Oct 2021 16:31:42 +0900 Subject: [PATCH] =?UTF-8?q?gltfExporter=20=E3=81=AE=20GltfExportSettings?= =?UTF-8?q?=20=E3=81=8C=E3=80=81=E3=82=B3=E3=83=B3=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=83=A9=E3=82=AF=E3=82=BF=E3=81=A8=20Export=20=E9=96=A2?= =?UTF-8?q?=E6=95=B0=E3=81=AE=E5=BC=95=E6=95=B0=E3=81=A7=E4=BA=8C=E9=87=8D?= =?UTF-8?q?=E3=81=AB=E4=B8=8E=E3=81=88=E3=82=89=E3=82=8C=E3=81=A6=E3=81=84?= =?UTF-8?q?=E3=81=9F=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UniGLTF/ExportDialog/GltfExportWindow.cs | 2 +- Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs | 10 +++++----- .../Tests/UniGLTF/EditorTextureSerializerTests.cs | 13 +++++-------- Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs | 2 +- Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs | 14 +++++++------- Assets/VRM/Editor/Format/VRMEditorExporter.cs | 4 ++-- Assets/VRM/Runtime/IO/VRMExporter.cs | 6 +++--- 7 files changed, 24 insertions(+), 27 deletions(-) diff --git a/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/GltfExportWindow.cs b/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/GltfExportWindow.cs index 056118790..b99a31ab9 100644 --- a/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/GltfExportWindow.cs +++ b/Assets/UniGLTF/Editor/UniGLTF/ExportDialog/GltfExportWindow.cs @@ -104,7 +104,7 @@ namespace UniGLTF using (var exporter = new gltfExporter(gltf, Settings)) { exporter.Prepare(State.ExportRoot); - exporter.Export(Settings, new EditorTextureSerializer()); + exporter.Export(new EditorTextureSerializer()); } if (isGlb) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs index 916f25cd8..40f073a76 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/gltfExporter.cs @@ -222,7 +222,7 @@ namespace UniGLTF // do nothing } - public virtual void Export(GltfExportSettings meshExportSettings, ITextureSerializer textureSerializer) + public virtual void Export(ITextureSerializer textureSerializer) { var bytesBuffer = new ArrayByteBuffer(new byte[50 * 1024 * 1024]); var bufferIndex = glTF.AddBuffer(bytesBuffer); @@ -232,7 +232,7 @@ namespace UniGLTF .ToList(); var uniqueUnityMeshes = new MeshExportList(); - uniqueUnityMeshes.GetInfo(Nodes, meshExportSettings); + uniqueUnityMeshes.GetInfo(Nodes, m_settings); #region Materials and Textures Materials = uniqueUnityMeshes.GetUniqueMaterials().ToList(); @@ -252,9 +252,9 @@ namespace UniGLTF continue; } - var (gltfMesh, blendShapeIndexMap) = meshExportSettings.DivideVertexBuffer - ? MeshExporter_DividedVertexBuffer.Export(glTF, bufferIndex, unityMesh, Materials, m_settings.InverseAxis.Create(), meshExportSettings) - : MeshExporter_SharedVertexBuffer.Export(glTF, bufferIndex, unityMesh, Materials, m_settings.InverseAxis.Create(), meshExportSettings) + var (gltfMesh, blendShapeIndexMap) = m_settings.DivideVertexBuffer + ? MeshExporter_DividedVertexBuffer.Export(glTF, bufferIndex, unityMesh, Materials, m_settings.InverseAxis.Create(), m_settings) + : MeshExporter_SharedVertexBuffer.Export(glTF, bufferIndex, unityMesh, Materials, m_settings.InverseAxis.Create(), m_settings) ; glTF.meshes.Add(gltfMesh); Meshes.Add(unityMesh.Mesh); diff --git a/Assets/UniGLTF/Tests/UniGLTF/EditorTextureSerializerTests.cs b/Assets/UniGLTF/Tests/UniGLTF/EditorTextureSerializerTests.cs index 1b239377a..d625b3c28 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/EditorTextureSerializerTests.cs +++ b/Assets/UniGLTF/Tests/UniGLTF/EditorTextureSerializerTests.cs @@ -125,17 +125,14 @@ namespace UniGLTF var gltf = new glTF(); using (var exporter = new gltfExporter(gltf, new GltfExportSettings { - InverseAxis = Axes.X + InverseAxis = Axes.X, + ExportOnlyBlendShapePosition = false, + UseSparseAccessorForMorphTarget = false, + DivideVertexBuffer = false, })) { exporter.Prepare(root); - var settings = new GltfExportSettings - { - ExportOnlyBlendShapePosition = false, - UseSparseAccessorForMorphTarget = false, - DivideVertexBuffer = false, - }; - exporter.Export(settings, new EditorTextureSerializer()); + exporter.Export(new EditorTextureSerializer()); } Assert.AreEqual(1, gltf.images.Count); var exportedImage = gltf.images[0]; diff --git a/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs b/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs index 554df42e3..c9432c047 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs +++ b/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs @@ -61,7 +61,7 @@ namespace UniGLTF using (var exporter = new gltfExporter(gltf, new GltfExportSettings())) { exporter.Prepare(root); - exporter.Export(new GltfExportSettings(), new EditorTextureSerializer()); + exporter.Export(new EditorTextureSerializer()); return gltf.ToGlbBytes(); } } diff --git a/Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs b/Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs index c155aefda..985a5e8c6 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs +++ b/Assets/UniGLTF/Tests/UniGLTF/UniGLTFTests.cs @@ -106,7 +106,7 @@ namespace UniGLTF using (var exporter = new gltfExporter(gltf, new GltfExportSettings())) { exporter.Prepare(go); - exporter.Export(new GltfExportSettings(), new EditorTextureSerializer()); + exporter.Export(new EditorTextureSerializer()); // remove empty buffer gltf.buffers.Clear(); @@ -297,7 +297,7 @@ namespace UniGLTF using (var exporter = new gltfExporter(gltf, new GltfExportSettings())) { exporter.Prepare(CreateSimpleScene()); - exporter.Export(new GltfExportSettings(), new EditorTextureSerializer()); + exporter.Export(new EditorTextureSerializer()); } var expected = gltf.ToJson().ParseAsJson(); @@ -533,7 +533,7 @@ namespace UniGLTF using (var exporter = new gltfExporter(gltf, new GltfExportSettings())) { exporter.Prepare(go); - exporter.Export(new UniGLTF.GltfExportSettings(), new EditorTextureSerializer()); + exporter.Export(new EditorTextureSerializer()); json = gltf.ToJson(); } @@ -574,7 +574,7 @@ namespace UniGLTF { var storage = new SimpleStorage(new ArraySegment(new byte[1024 * 1024])); var data = new JsonWithStorageParser(json, storage).Parse(); - + //Debug.LogFormat("{0}", context.Json); using (var context = new ImporterContext(data)) using (var loaded = context.Load()) @@ -615,7 +615,7 @@ namespace UniGLTF using (var exporter = new gltfExporter(gltf, new GltfExportSettings())) { exporter.Prepare(go); - exporter.Export(new UniGLTF.GltfExportSettings(), new EditorTextureSerializer()); + exporter.Export(new EditorTextureSerializer()); json = gltf.ToJson(); } @@ -628,7 +628,7 @@ namespace UniGLTF { var storage = new SimpleStorage(new ArraySegment(new byte[1024 * 1024])); var data = new JsonWithStorageParser(json, storage).Parse(); - + using (var context = new ImporterContext(data)) using (var loaded = context.Load()) { @@ -679,7 +679,7 @@ namespace UniGLTF using (var exporter = new gltfExporter(gltf, new GltfExportSettings())) { exporter.Prepare(root); - exporter.Export(new UniGLTF.GltfExportSettings(), new EditorTextureSerializer()); + exporter.Export(new EditorTextureSerializer()); json = gltf.ToJson(); } diff --git a/Assets/VRM/Editor/Format/VRMEditorExporter.cs b/Assets/VRM/Editor/Format/VRMEditorExporter.cs index a853981bd..e7a4d3ae1 100644 --- a/Assets/VRM/Editor/Format/VRMEditorExporter.cs +++ b/Assets/VRM/Editor/Format/VRMEditorExporter.cs @@ -223,10 +223,10 @@ namespace VRM // 出力 var sw = System.Diagnostics.Stopwatch.StartNew(); var gltf = new UniGLTF.glTF(); - using (var exporter = new VRMExporter(gltf)) + using (var exporter = new VRMExporter(gltf, settings.MeshExportSettings)) { exporter.Prepare(target); - exporter.Export(settings.MeshExportSettings, new EditorTextureSerializer()); + exporter.Export(new EditorTextureSerializer()); } var bytes = gltf.ToGlbBytes(); Debug.LogFormat("Export elapsed {0}", sw.Elapsed); diff --git a/Assets/VRM/Runtime/IO/VRMExporter.cs b/Assets/VRM/Runtime/IO/VRMExporter.cs index 30dd44166..2f7b4b6c9 100644 --- a/Assets/VRM/Runtime/IO/VRMExporter.cs +++ b/Assets/VRM/Runtime/IO/VRMExporter.cs @@ -18,17 +18,17 @@ namespace VRM public static glTF Export(GltfExportSettings configuration, GameObject go, ITextureSerializer textureSerializer) { var gltf = new glTF(); - using (var exporter = new VRMExporter(gltf)) + using (var exporter = new VRMExporter(gltf, configuration)) { exporter.Prepare(go); - exporter.Export(configuration, textureSerializer); + exporter.Export(textureSerializer); } return gltf; } public readonly VRM.glTF_VRM_extensions VRM = new glTF_VRM_extensions(); - public VRMExporter(glTF gltf) : base(gltf, new GltfExportSettings()) + public VRMExporter(glTF gltf, GltfExportSettings exportSettings) : base(gltf, exportSettings) { gltf.extensionsUsed.Add(glTF_VRM_extensions.ExtensionName); }