From bb1c3d4cc1ed965ae4c3c8229ce04070451b0911 Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Fri, 4 Feb 2022 17:12:03 +0900 Subject: [PATCH 1/5] fix comments --- Assets/VRM10/Runtime/IO/Vrm10Utility.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Assets/VRM10/Runtime/IO/Vrm10Utility.cs b/Assets/VRM10/Runtime/IO/Vrm10Utility.cs index 9f86ab2d3..12e5916a8 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Utility.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Utility.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System.Threading; +using System.Threading.Tasks; using UniGLTF; using UnityEngine; using VRMShaders; @@ -27,9 +28,9 @@ namespace UniVRM10 MetaCallback metaCallback = null ) { - // 1st parse as vrm1 using (var data = new GlbLowLevelParser(path, bytes).Parse()) { + // 1. Try parsing as vrm-1.0 var vrm1Data = Vrm10Data.Parse(data); if (vrm1Data != null) { @@ -51,7 +52,7 @@ namespace UniVRM10 return default; } - // try migration... + // 2. Try migration from vrm-0.x into vrm-1.0 MigrationData migration; using (var migrated = Vrm10Data.Migrate(data, out vrm1Data, out migration)) { @@ -71,7 +72,7 @@ namespace UniVRM10 } } - // fail to migrate... + // 3. failed if (migration != null) { Debug.LogWarning(migration.Message); From 02427e630e8dd531250deb781d521a080bc37976 Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Fri, 4 Feb 2022 17:13:47 +0900 Subject: [PATCH 2/5] VRM10Utility can receive CancellationToken --- Assets/VRM10/Runtime/IO/Vrm10Utility.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Assets/VRM10/Runtime/IO/Vrm10Utility.cs b/Assets/VRM10/Runtime/IO/Vrm10Utility.cs index 12e5916a8..340d5fdf6 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Utility.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Utility.cs @@ -14,10 +14,11 @@ namespace UniVRM10 bool doNormalize, IAwaitCaller awaitCaller = null, IMaterialDescriptorGenerator materialGenerator = null, - MetaCallback metaCallback = null + MetaCallback metaCallback = null, + CancellationToken ct = default ) { - return await LoadBytesAsync(path, System.IO.File.ReadAllBytes(path), doMigrate, doNormalize, awaitCaller, materialGenerator, metaCallback); + return await LoadBytesAsync(path, System.IO.File.ReadAllBytes(path), doMigrate, doNormalize, awaitCaller, materialGenerator, metaCallback, ct); } public static async Task LoadBytesAsync(string path, byte[] bytes, @@ -25,7 +26,8 @@ namespace UniVRM10 bool doNormalize, IAwaitCaller awaitCaller = null, IMaterialDescriptorGenerator materialGenerator = null, - MetaCallback metaCallback = null + MetaCallback metaCallback = null, + CancellationToken ct = default ) { using (var data = new GlbLowLevelParser(path, bytes).Parse()) @@ -43,6 +45,10 @@ namespace UniVRM10 metaCallback(thumbnail, vrm1Data.VrmExtension.Meta, null); } var instance = await loader.LoadAsync(awaitCaller); + if (ct.IsCancellationRequested && instance != null) + { + instance.Dispose(); + } return instance; } } @@ -67,6 +73,10 @@ namespace UniVRM10 metaCallback(thumbnail, vrm1Data.VrmExtension.Meta, null); } var instance = await loader.LoadAsync(awaitCaller); + if (ct.IsCancellationRequested && instance != null) + { + instance.Dispose(); + } return instance; } } From 5d9368f9199b2247ba55cca52bb5a67bf1197860 Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Fri, 4 Feb 2022 17:22:58 +0900 Subject: [PATCH 3/5] mv Vrm10Utility to Vrm10 --- Assets/VRM10/Runtime/IO/{Vrm10Utility.cs => Vrm10.cs} | 5 ++++- .../VRM10/Runtime/IO/{Vrm10Utility.cs.meta => Vrm10.cs.meta} | 0 Assets/VRM10/Runtime/Scenes/Sample.cs | 4 ++-- Assets/VRM10/Tests/MigrationTests.cs | 2 +- Assets/VRM10/Tests/TestAsset.cs | 2 +- .../VRM10FirstPersonSample/VRM10RuntimeLoader.cs | 2 +- Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs | 2 +- 7 files changed, 10 insertions(+), 7 deletions(-) rename Assets/VRM10/Runtime/IO/{Vrm10Utility.cs => Vrm10.cs} (97%) rename Assets/VRM10/Runtime/IO/{Vrm10Utility.cs.meta => Vrm10.cs.meta} (100%) diff --git a/Assets/VRM10/Runtime/IO/Vrm10Utility.cs b/Assets/VRM10/Runtime/IO/Vrm10.cs similarity index 97% rename from Assets/VRM10/Runtime/IO/Vrm10Utility.cs rename to Assets/VRM10/Runtime/IO/Vrm10.cs index 340d5fdf6..01dba6262 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Utility.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10.cs @@ -6,7 +6,10 @@ using VRMShaders; namespace UniVRM10 { - public static class Vrm10Utility + /// + /// High-level VRM-1.0 loading API. + /// + public static class Vrm10 { public delegate void MetaCallback(Texture2D thumbnail, UniGLTF.Extensions.VRMC_vrm.Meta meta1, Migration.Vrm0Meta meta0); public static async Task LoadPathAsync(string path, diff --git a/Assets/VRM10/Runtime/IO/Vrm10Utility.cs.meta b/Assets/VRM10/Runtime/IO/Vrm10.cs.meta similarity index 100% rename from Assets/VRM10/Runtime/IO/Vrm10Utility.cs.meta rename to Assets/VRM10/Runtime/IO/Vrm10.cs.meta diff --git a/Assets/VRM10/Runtime/Scenes/Sample.cs b/Assets/VRM10/Runtime/Scenes/Sample.cs index c5c35bbab..415f2ce5f 100644 --- a/Assets/VRM10/Runtime/Scenes/Sample.cs +++ b/Assets/VRM10/Runtime/Scenes/Sample.cs @@ -22,12 +22,12 @@ namespace UniVRM10.Sample async void Run() { var src = new FileInfo(m_vrmPath); - var instance = await Vrm10Utility.LoadPathAsync(m_vrmPath, true, true); + var instance = await Vrm10.LoadPathAsync(m_vrmPath, true, true); var exportedBytes = Vrm10Exporter.Export(instance.gameObject); // Import 1.0 - var vrm10 = await Vrm10Utility.LoadBytesAsync("tmp.vrm", exportedBytes, false, true); + var vrm10 = await Vrm10.LoadBytesAsync("tmp.vrm", exportedBytes, false, true); var pos = vrm10.transform.position; pos.x += 1.5f; vrm10.transform.position = pos; diff --git a/Assets/VRM10/Tests/MigrationTests.cs b/Assets/VRM10/Tests/MigrationTests.cs index 62044094e..d60deb448 100644 --- a/Assets/VRM10/Tests/MigrationTests.cs +++ b/Assets/VRM10/Tests/MigrationTests.cs @@ -198,7 +198,7 @@ namespace UniVRM10 { try { - Vrm10Utility.LoadPathAsync(gltf.FullName, true, false).Wait(); + Vrm10.LoadPathAsync(gltf.FullName, true, false).Wait(); } catch (UnNormalizedException) { diff --git a/Assets/VRM10/Tests/TestAsset.cs b/Assets/VRM10/Tests/TestAsset.cs index 9b536d66e..2ee9fe5bf 100644 --- a/Assets/VRM10/Tests/TestAsset.cs +++ b/Assets/VRM10/Tests/TestAsset.cs @@ -16,7 +16,7 @@ namespace UniVRM10 public static Vrm10Instance LoadAlicia() { - var task = Vrm10Utility.LoadPathAsync(AliciaPath, true, true); + var task = Vrm10.LoadPathAsync(AliciaPath, true, true); task.Wait(); var instance = task.Result; diff --git a/Assets/VRM10_Samples/VRM10FirstPersonSample/VRM10RuntimeLoader.cs b/Assets/VRM10_Samples/VRM10FirstPersonSample/VRM10RuntimeLoader.cs index f10c429ae..0f507f427 100644 --- a/Assets/VRM10_Samples/VRM10FirstPersonSample/VRM10RuntimeLoader.cs +++ b/Assets/VRM10_Samples/VRM10FirstPersonSample/VRM10RuntimeLoader.cs @@ -88,7 +88,7 @@ namespace UniVRM10.FirstPersonSample async Task LoadAsync(string path) { - var instance = await Vrm10Utility.LoadPathAsync(path, true, true); + var instance = await Vrm10.LoadPathAsync(path, true, true); // VR用 FirstPerson 設定 var controller = instance.GetComponent(); diff --git a/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs b/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs index 89f606eb3..cb0a1856d 100644 --- a/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs +++ b/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs @@ -415,7 +415,7 @@ namespace UniVRM10.VRM10Viewer } Debug.LogFormat("{0}", path); - var instance = await Vrm10Utility.LoadPathAsync(path, true, m_useNormalization.isOn, + var instance = await Vrm10.LoadPathAsync(path, true, m_useNormalization.isOn, awaitCaller: new RuntimeOnlyAwaitCaller(), materialGenerator: GetVrmMaterialDescriptorGenerator(m_useUrpMaterial.isOn), metaCallback: m_texts.UpdateMeta); From 4fefbc38c3d73a6f9ee9c4524412618f8d4787d3 Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Fri, 4 Feb 2022 18:54:58 +0900 Subject: [PATCH 4/5] Change High-level VRM-1.0 loading API. --- Assets/VRM10/Runtime/IO/Vrm10.cs | 223 +++++++++++++----- Assets/VRM10/Runtime/Scenes/Sample.cs | 2 +- Assets/VRM10/Runtime/Scenes/SampleScene.unity | 5 +- .../VRM10RuntimeLoader.cs | 9 +- .../VRM10Viewer/VRM10ViewerUI.cs | 21 +- 5 files changed, 183 insertions(+), 77 deletions(-) diff --git a/Assets/VRM10/Runtime/IO/Vrm10.cs b/Assets/VRM10/Runtime/IO/Vrm10.cs index 01dba6262..270492451 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10.cs @@ -1,4 +1,5 @@ -using System.Threading; +using System; +using System.Threading; using System.Threading.Tasks; using UniGLTF; using UnityEngine; @@ -11,87 +12,189 @@ namespace UniVRM10 /// public static class Vrm10 { - public delegate void MetaCallback(Texture2D thumbnail, UniGLTF.Extensions.VRMC_vrm.Meta meta1, Migration.Vrm0Meta meta0); - public static async Task LoadPathAsync(string path, - bool doMigrate, - bool doNormalize, + /// + /// You can receive the thumbnail texture and the meta information. + /// `vrm10Meta` will be available if the model was vrm-1.0. + /// `vrm0Meta` will be available if the model was vrm-0.x. + /// + public delegate void VrmMetaInformationCallback(Texture2D thumbnail, UniGLTF.Extensions.VRMC_vrm.Meta vrm10Meta, Migration.Vrm0Meta vrm0Meta); + + /// + /// Load the VRM file from the path. + /// + /// vrm file path + /// if true, this loader can load the vrm-0.x model as vrm-1.0 model with migration. + /// if true, vrm-1.0 models are forced to load in T-pose. + /// if true, show meshes when loaded. + /// this loader use specified await strategy. + /// this loader use specified material generation strategy. + /// return callback that notify meta information before loading. + /// CancellationToken + /// vrm-1.0 instance + public static async Task LoadPathAsync( + string path, + bool canLoadVrm0X = true, + bool forceTPose = true, + bool showMeshes = true, IAwaitCaller awaitCaller = null, IMaterialDescriptorGenerator materialGenerator = null, - MetaCallback metaCallback = null, - CancellationToken ct = default - ) + VrmMetaInformationCallback vrmMetaInformationCallback = null, + CancellationToken ct = default) { - return await LoadBytesAsync(path, System.IO.File.ReadAllBytes(path), doMigrate, doNormalize, awaitCaller, materialGenerator, metaCallback, ct); + return await LoadAsync( + path, + System.IO.File.ReadAllBytes(path), + canLoadVrm0X, + forceTPose, + showMeshes, + awaitCaller, + materialGenerator, + vrmMetaInformationCallback, + ct); } - public static async Task LoadBytesAsync(string path, byte[] bytes, - bool doMigrate, - bool doNormalize, + /// + /// Load the VRM file from the binary. + /// + /// vrm file data + /// if true, this loader can load the vrm-0.x model as vrm-1.0 model with migration. + /// if true, vrm-1.0 models are forced to load in T-pose. + /// if true, show meshes when loaded. + /// this loader use specified await strategy. + /// this loader use specified material generation strategy. + /// return callback that notify meta information before loading. + /// CancellationToken + /// vrm-1.0 instance + public static async Task LoadBytesAsync( + byte[] bytes, + bool canLoadVrm0X = true, + bool forceTPose = true, + bool showMeshes = true, IAwaitCaller awaitCaller = null, IMaterialDescriptorGenerator materialGenerator = null, - MetaCallback metaCallback = null, - CancellationToken ct = default - ) + VrmMetaInformationCallback vrmMetaInformationCallback = null, + CancellationToken ct = default) { - using (var data = new GlbLowLevelParser(path, bytes).Parse()) - { - // 1. Try parsing as vrm-1.0 - var vrm1Data = Vrm10Data.Parse(data); - if (vrm1Data != null) - { - // successfully parsed vrm-1.0 - using (var loader = new Vrm10Importer(vrm1Data, materialGenerator: materialGenerator, doNormalize: doNormalize)) - { - if (metaCallback != null) - { - var thumbnail = await loader.LoadVrmThumbnailAsync(); - metaCallback(thumbnail, vrm1Data.VrmExtension.Meta, null); - } - var instance = await loader.LoadAsync(awaitCaller); - if (ct.IsCancellationRequested && instance != null) - { - instance.Dispose(); - } - return instance; - } - } + return await LoadAsync( + string.Empty, + bytes, + canLoadVrm0X, + forceTPose, + showMeshes, + awaitCaller, + materialGenerator, + vrmMetaInformationCallback, + ct); + } - if (!doMigrate) + private static async Task LoadAsync( + string name, + byte[] bytes, + bool canLoadVrm0X, + bool forceTPose, + bool showMeshes, + IAwaitCaller awaitCaller, + IMaterialDescriptorGenerator materialGenerator, + VrmMetaInformationCallback vrmMetaInformationCallback, + CancellationToken ct) + { + using (var data = new GlbLowLevelParser(name, bytes).Parse()) + { + // 1. Try loading as vrm-1.0 + var vrm10Data = Vrm10Data.Parse(data); + var vrm10Instance = await LoadVrm10DataAsync( + vrm10Data, + null, + forceTPose, + showMeshes, + awaitCaller, + materialGenerator, + vrmMetaInformationCallback, + ct); + if (vrm10Instance != null) return vrm10Instance; + + if (!canLoadVrm0X) { return default; } // 2. Try migration from vrm-0.x into vrm-1.0 - MigrationData migration; - using (var migrated = Vrm10Data.Migrate(data, out vrm1Data, out migration)) + MigrationData migrationData; + using (var migrated = Vrm10Data.Migrate(data, out vrm10Data, out migrationData)) { - if (vrm1Data != null) - { - // successfully migrated from vrm-0.x - using (var loader = new Vrm10Importer(vrm1Data, materialGenerator: materialGenerator, doNormalize: doNormalize)) - { - if (metaCallback != null) - { - var thumbnail = await loader.LoadVrmThumbnailAsync(); - metaCallback(thumbnail, vrm1Data.VrmExtension.Meta, null); - } - var instance = await loader.LoadAsync(awaitCaller); - if (ct.IsCancellationRequested && instance != null) - { - instance.Dispose(); - } - return instance; - } - } + var instance = await LoadVrm10DataAsync( + vrm10Data, + migrationData, + forceTPose, + showMeshes, + awaitCaller, + materialGenerator, + vrmMetaInformationCallback, + ct); + if (instance != null) return instance; } // 3. failed - if (migration != null) + if (migrationData != null) { - Debug.LogWarning(migration.Message); + Debug.LogWarning(migrationData.Message); } return default; } } + + private static async Task LoadVrm10DataAsync( + Vrm10Data vrm10Data, + MigrationData migrationData, + bool forceTPose, + bool showMeshes, + IAwaitCaller awaitCaller, + IMaterialDescriptorGenerator materialGenerator, + VrmMetaInformationCallback vrmMetaInformationCallback, + CancellationToken ct) + { + if (vrm10Data == null) + { + return default; + } + + using (var loader = new Vrm10Importer(vrm10Data, materialGenerator: materialGenerator, doNormalize: forceTPose)) + { + // 1. Load meta information if callback was available. + if (vrmMetaInformationCallback != null) + { + var thumbnail = await loader.LoadVrmThumbnailAsync(); + if (migrationData != null) + { + vrmMetaInformationCallback(thumbnail, default, migrationData.OriginalMetaBeforeMigration); + } + else + { + vrmMetaInformationCallback(thumbnail, vrm10Data.VrmExtension.Meta, default); + } + } + + // 2. Load + var gltfInstance = await loader.LoadAsync(awaitCaller); + if (ct.IsCancellationRequested) + { + gltfInstance.Dispose(); + return default; + } + + var vrm10Instance = gltfInstance.GetComponent(); + if (vrm10Instance == null) + { + gltfInstance.Dispose(); + return default; + } + + if (showMeshes) + { + gltfInstance.ShowMeshes(); + } + return vrm10Instance; + } + } } } diff --git a/Assets/VRM10/Runtime/Scenes/Sample.cs b/Assets/VRM10/Runtime/Scenes/Sample.cs index 415f2ce5f..6fc1b47b4 100644 --- a/Assets/VRM10/Runtime/Scenes/Sample.cs +++ b/Assets/VRM10/Runtime/Scenes/Sample.cs @@ -27,7 +27,7 @@ namespace UniVRM10.Sample var exportedBytes = Vrm10Exporter.Export(instance.gameObject); // Import 1.0 - var vrm10 = await Vrm10.LoadBytesAsync("tmp.vrm", exportedBytes, false, true); + var vrm10 = await Vrm10.LoadBytesAsync(exportedBytes, false, true); var pos = vrm10.transform.position; pos.x += 1.5f; vrm10.transform.position = pos; diff --git a/Assets/VRM10/Runtime/Scenes/SampleScene.unity b/Assets/VRM10/Runtime/Scenes/SampleScene.unity index ecb42cea9..af58e6cbd 100644 --- a/Assets/VRM10/Runtime/Scenes/SampleScene.unity +++ b/Assets/VRM10/Runtime/Scenes/SampleScene.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 705507994} - m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1} + m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -325,8 +325,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d2dd74f31dd71684da8aa80eaa66390e, type: 3} m_Name: m_EditorClassIdentifier: - m_vrmPath: ../UniVRM_1_0/Tests/Models/Alicia_vrm-0.51/AliciaSolid_vrm-0.51.vrm - m_rightHandToLeftHand: 1 + m_vrmPath: Tests/Models/Alicia_vrm-0.51/AliciaSolid_vrm-0.51.vrm --- !u!4 &1706915413 Transform: m_ObjectHideFlags: 0 diff --git a/Assets/VRM10_Samples/VRM10FirstPersonSample/VRM10RuntimeLoader.cs b/Assets/VRM10_Samples/VRM10FirstPersonSample/VRM10RuntimeLoader.cs index 0f507f427..b2c30e826 100644 --- a/Assets/VRM10_Samples/VRM10FirstPersonSample/VRM10RuntimeLoader.cs +++ b/Assets/VRM10_Samples/VRM10FirstPersonSample/VRM10RuntimeLoader.cs @@ -82,17 +82,14 @@ namespace UniVRM10.FirstPersonSample } m_target = humanPoseTransfer; SetupTarget(m_target); - - instance.ShowMeshes(); } - async Task LoadAsync(string path) + async Task LoadAsync(string path) { - var instance = await Vrm10.LoadPathAsync(path, true, true); + var instance = await Vrm10.LoadPathAsync(path); // VR用 FirstPerson 設定 - var controller = instance.GetComponent(); - await controller.Vrm.FirstPerson.SetupAsync(controller.gameObject); + await instance.Vrm.FirstPerson.SetupAsync(instance.gameObject); return instance; } diff --git a/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs b/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs index cb0a1856d..2bb86e1ba 100644 --- a/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs +++ b/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs @@ -415,16 +415,23 @@ namespace UniVRM10.VRM10Viewer } Debug.LogFormat("{0}", path); - var instance = await Vrm10.LoadPathAsync(path, true, m_useNormalization.isOn, - awaitCaller: new RuntimeOnlyAwaitCaller(), - materialGenerator: GetVrmMaterialDescriptorGenerator(m_useUrpMaterial.isOn), - metaCallback: m_texts.UpdateMeta); - if (instance == null) + var vrm10Instance = await Vrm10.LoadPathAsync(path, + canLoadVrm0X: true, + forceTPose: m_useNormalization.isOn, + showMeshes: false, + awaitCaller: new RuntimeOnlyAwaitCaller(), + materialGenerator: GetVrmMaterialDescriptorGenerator(m_useUrpMaterial.isOn), + vrmMetaInformationCallback: m_texts.UpdateMeta); + if (vrm10Instance != null) + { + SetModel(vrm10Instance.GetComponent()); + } + else { // fallback to gltf - instance = await GltfUtility.LoadAsync(path, awaitCaller: new RuntimeOnlyAwaitCaller()); + var instance = await GltfUtility.LoadAsync(path, awaitCaller: new RuntimeOnlyAwaitCaller()); + SetModel(instance); } - SetModel(instance); } void SetModel(RuntimeGltfInstance instance) From d5c0d5a4847c47f2ff77a66e03881ec85bf320aa Mon Sep 17 00:00:00 2001 From: Masataka SUMI Date: Fri, 4 Feb 2022 19:11:12 +0900 Subject: [PATCH 5/5] change name --- Assets/VRM10/Runtime/IO/Vrm10.cs | 22 +++++++++---------- .../VRM10Viewer/VRM10ViewerUI.cs | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Assets/VRM10/Runtime/IO/Vrm10.cs b/Assets/VRM10/Runtime/IO/Vrm10.cs index 270492451..3a2f3e452 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10.cs @@ -24,7 +24,7 @@ namespace UniVRM10 /// /// vrm file path /// if true, this loader can load the vrm-0.x model as vrm-1.0 model with migration. - /// if true, vrm-1.0 models are forced to load in T-pose. + /// if true, vrm-1.0 models' transforms are normalized. (e.g. rotation, scaling) /// if true, show meshes when loaded. /// this loader use specified await strategy. /// this loader use specified material generation strategy. @@ -34,7 +34,7 @@ namespace UniVRM10 public static async Task LoadPathAsync( string path, bool canLoadVrm0X = true, - bool forceTPose = true, + bool normalizeTransform = true, bool showMeshes = true, IAwaitCaller awaitCaller = null, IMaterialDescriptorGenerator materialGenerator = null, @@ -45,7 +45,7 @@ namespace UniVRM10 path, System.IO.File.ReadAllBytes(path), canLoadVrm0X, - forceTPose, + normalizeTransform, showMeshes, awaitCaller, materialGenerator, @@ -58,7 +58,7 @@ namespace UniVRM10 /// /// vrm file data /// if true, this loader can load the vrm-0.x model as vrm-1.0 model with migration. - /// if true, vrm-1.0 models are forced to load in T-pose. + /// if true, vrm-1.0 models' transforms are normalized. (e.g. rotation, scaling) /// if true, show meshes when loaded. /// this loader use specified await strategy. /// this loader use specified material generation strategy. @@ -68,7 +68,7 @@ namespace UniVRM10 public static async Task LoadBytesAsync( byte[] bytes, bool canLoadVrm0X = true, - bool forceTPose = true, + bool normalizeTransform = true, bool showMeshes = true, IAwaitCaller awaitCaller = null, IMaterialDescriptorGenerator materialGenerator = null, @@ -79,7 +79,7 @@ namespace UniVRM10 string.Empty, bytes, canLoadVrm0X, - forceTPose, + normalizeTransform, showMeshes, awaitCaller, materialGenerator, @@ -91,7 +91,7 @@ namespace UniVRM10 string name, byte[] bytes, bool canLoadVrm0X, - bool forceTPose, + bool normalizeTransform, bool showMeshes, IAwaitCaller awaitCaller, IMaterialDescriptorGenerator materialGenerator, @@ -105,7 +105,7 @@ namespace UniVRM10 var vrm10Instance = await LoadVrm10DataAsync( vrm10Data, null, - forceTPose, + normalizeTransform, showMeshes, awaitCaller, materialGenerator, @@ -125,7 +125,7 @@ namespace UniVRM10 var instance = await LoadVrm10DataAsync( vrm10Data, migrationData, - forceTPose, + normalizeTransform, showMeshes, awaitCaller, materialGenerator, @@ -146,7 +146,7 @@ namespace UniVRM10 private static async Task LoadVrm10DataAsync( Vrm10Data vrm10Data, MigrationData migrationData, - bool forceTPose, + bool normalizeTransform, bool showMeshes, IAwaitCaller awaitCaller, IMaterialDescriptorGenerator materialGenerator, @@ -158,7 +158,7 @@ namespace UniVRM10 return default; } - using (var loader = new Vrm10Importer(vrm10Data, materialGenerator: materialGenerator, doNormalize: forceTPose)) + using (var loader = new Vrm10Importer(vrm10Data, materialGenerator: materialGenerator, doNormalize: normalizeTransform)) { // 1. Load meta information if callback was available. if (vrmMetaInformationCallback != null) diff --git a/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs b/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs index 2bb86e1ba..77f191a0a 100644 --- a/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs +++ b/Assets/VRM10_Samples/VRM10Viewer/VRM10ViewerUI.cs @@ -417,7 +417,7 @@ namespace UniVRM10.VRM10Viewer Debug.LogFormat("{0}", path); var vrm10Instance = await Vrm10.LoadPathAsync(path, canLoadVrm0X: true, - forceTPose: m_useNormalization.isOn, + normalizeTransform: m_useNormalization.isOn, showMeshes: false, awaitCaller: new RuntimeOnlyAwaitCaller(), materialGenerator: GetVrmMaterialDescriptorGenerator(m_useUrpMaterial.isOn),