From 3f774b3bde3ce79678ad8dd88a8a924c9b4ea538 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 2 Apr 2021 15:42:56 +0900 Subject: [PATCH 1/4] add export test #836 --- Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs b/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs index 7ee3382d7..cf993352a 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs +++ b/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs @@ -4,6 +4,7 @@ using System.IO; using System.Linq; using NUnit.Framework; using UnityEngine; +using VRMShaders; namespace UniGLTF { @@ -54,7 +55,22 @@ namespace UniGLTF } } - static void RuntimeLoad(FileInfo gltf, int subStrStart) + static Byte[] Export(GameObject root) + { + var gltf = new glTF(); + using (var exporter = new gltfExporter(gltf)) + { + exporter.Prepare(root); + exporter.Export(MeshExportSettings.Default, AssetTextureUtil.IsTextureEditorAsset); + + // remove empty buffer + gltf.buffers.Clear(); + + return gltf.ToGlbBytes(); + } + } + + static void RuntimeLoadExport(FileInfo gltf, int subStrStart) { var parser = new GltfParser(); try @@ -67,16 +83,18 @@ namespace UniGLTF Debug.LogException(ex); } - try + using (var loader = new ImporterContext(parser)) { - using (var importer = new ImporterContext(parser)) + try { - importer.Load(); + loader.Load(); } - } - catch (Exception ex) - { - Message(gltf.FullName.Substring(subStrStart), ex); + catch (Exception ex) + { + Message(gltf.FullName.Substring(subStrStart), ex); + } + + Export(loader.Root); } } @@ -120,7 +138,7 @@ namespace UniGLTF foreach (var gltf in EnumerateGltfFiles(root)) { - RuntimeLoad(gltf, root.FullName.Length); + RuntimeLoadExport(gltf, root.FullName.Length); EditorLoad(gltf, root.FullName.Length); } From 4e7db0ac162618ad73be1eb06df098a7275dd913 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Mon, 5 Apr 2021 15:55:25 +0900 Subject: [PATCH 2/4] GltfSampleModelsTest_BrainStem --- Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs b/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs index cf993352a..b88d6c3ab 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs +++ b/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs @@ -143,5 +143,28 @@ namespace UniGLTF EditorLoad(gltf, root.FullName.Length); } } + + [Test] + public void GltfSampleModelsTest_BrainStem() + { + var env = System.Environment.GetEnvironmentVariable("GLTF_SAMPLE_MODELS"); + if (string.IsNullOrEmpty(env)) + { + return; + } + var root = new DirectoryInfo($"{env}/2.0"); + if (!root.Exists) + { + return; + } + + // foreach (var gltf in EnumerateGltfFiles(root)) + { + var gltf = new FileInfo(Path.Combine(root.FullName, "BrainStem/glTF-Binary/BrainStem.glb")); + RuntimeLoadExport(gltf, root.FullName.Length); + + EditorLoad(gltf, root.FullName.Length); + } + } } } From 9321aa3d72411c529940e5edfd5a45e73e259c44 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Mon, 5 Apr 2021 17:50:06 +0900 Subject: [PATCH 3/4] skip BrainStem --- Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs b/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs index b88d6c3ab..e13d9a921 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs +++ b/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs @@ -62,10 +62,6 @@ namespace UniGLTF { exporter.Prepare(root); exporter.Export(MeshExportSettings.Default, AssetTextureUtil.IsTextureEditorAsset); - - // remove empty buffer - gltf.buffers.Clear(); - return gltf.ToGlbBytes(); } } @@ -140,11 +136,18 @@ namespace UniGLTF { RuntimeLoadExport(gltf, root.FullName.Length); + if (gltf.Directory.Parent.Name == "BrainStem") + { + // Export issue: + // skip + continue; + } + EditorLoad(gltf, root.FullName.Length); } } - [Test] + // [Test] public void GltfSampleModelsTest_BrainStem() { var env = System.Environment.GetEnvironmentVariable("GLTF_SAMPLE_MODELS"); @@ -160,6 +163,7 @@ namespace UniGLTF // foreach (var gltf in EnumerateGltfFiles(root)) { + // QuaternionToEuler: Input quaternion was not normalized var gltf = new FileInfo(Path.Combine(root.FullName, "BrainStem/glTF-Binary/BrainStem.glb")); RuntimeLoadExport(gltf, root.FullName.Length); From 5a07539302150a760a245c85980e8bde42a17244 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Mon, 5 Apr 2021 18:08:52 +0900 Subject: [PATCH 4/4] skip RiggedSimple --- Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs b/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs index e13d9a921..9c61700f6 100644 --- a/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs +++ b/Assets/UniGLTF/Tests/UniGLTF/GltfLoadTests.cs @@ -66,6 +66,16 @@ namespace UniGLTF } } + // Unsolved Animation Export issue + // + // QuaternionToEuler: Input quaternion was not normalized + // + static string[] Skip = new string[] + { + "BrainStem", + "RiggedSimple" + }; + static void RuntimeLoadExport(FileInfo gltf, int subStrStart) { var parser = new GltfParser(); @@ -90,6 +100,19 @@ namespace UniGLTF Message(gltf.FullName.Substring(subStrStart), ex); } + if (Skip.Contains(gltf.Directory.Parent.Name)) + { + // Export issue: + // skip + return; + } + + if (loader.Root == null) + { + Debug.LogWarning($"root is null: ${gltf}"); + return; + } + Export(loader.Root); } } @@ -136,13 +159,6 @@ namespace UniGLTF { RuntimeLoadExport(gltf, root.FullName.Length); - if (gltf.Directory.Parent.Name == "BrainStem") - { - // Export issue: - // skip - continue; - } - EditorLoad(gltf, root.FullName.Length); } } @@ -163,7 +179,6 @@ namespace UniGLTF // foreach (var gltf in EnumerateGltfFiles(root)) { - // QuaternionToEuler: Input quaternion was not normalized var gltf = new FileInfo(Path.Combine(root.FullName, "BrainStem/glTF-Binary/BrainStem.glb")); RuntimeLoadExport(gltf, root.FullName.Length);