From b0d6087272a335bf73b5ae2ed93ea73b61101986 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 7 Nov 2024 18:37:12 +0900 Subject: [PATCH] RotateParticleSpringboneRuntime --- .../ClothSample/ClothViewer/ClothViewerUI.cs | 31 ++-------- .../RotateParticle/RotateParticle.asmdef | 5 +- .../RotateParticleSpringboneRuntime.cs | 60 +++++++++++++++++++ .../RotateParticleSpringboneRuntime.cs.meta | 11 ++++ 4 files changed, 81 insertions(+), 26 deletions(-) create mode 100644 Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/RotateParticleSpringboneRuntime.cs create mode 100644 Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/RotateParticleSpringboneRuntime.cs.meta diff --git a/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewerUI.cs b/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewerUI.cs index 7bf02069a..dc4fddaa8 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewerUI.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothViewer/ClothViewerUI.cs @@ -549,18 +549,6 @@ namespace UniVRM10.Cloth.Viewer } } - static IMaterialDescriptorGenerator GetMaterialDescriptorGenerator(bool useUrp) - { - if (useUrp) - { - return new UrpGltfMaterialDescriptorGenerator(); - } - else - { - return new BuiltInGltfMaterialDescriptorGenerator(); - } - } - async void LoadModel(string path) { // cleanup @@ -578,7 +566,12 @@ namespace UniVRM10.Cloth.Viewer showMeshes: false, awaitCaller: m_useAsync.enabled ? (IAwaitCaller)new RuntimeOnlyAwaitCaller() : (IAwaitCaller)new ImmediateCaller(), materialGenerator: GetVrmMaterialDescriptorGenerator(true), - vrmMetaInformationCallback: m_texts.UpdateMeta); + vrmMetaInformationCallback: m_texts.UpdateMeta, + springboneRuntime: new RotateParticle.RotateParticleSpringboneRuntime((instance) => + { + var autoSetup = instance.transform.gameObject.AddComponent(); + autoSetup.Reset(); + })); if (cancellationToken.IsCancellationRequested) { UnityObjectDestroyer.DestroyRuntimeOrEditor(vrm10Instance.gameObject); @@ -591,18 +584,6 @@ namespace UniVRM10.Cloth.Viewer return; } - // - // RotateParticle.HumanoidAutoSetup - // - - // clear - vrm10Instance.SpringBone = new Vrm10InstanceSpringBone(); - - var autoSetup = vrm10Instance.transform.gameObject.AddComponent(); - autoSetup.Reset(); - var system = vrm10Instance.GetComponent(); - system.Initialize(); - var instance = vrm10Instance.GetComponent(); instance.ShowMeshes(); instance.EnableUpdateWhenOffscreen(); diff --git a/Assets/VRM10_Samples/ClothSample/RotateParticle/RotateParticle.asmdef b/Assets/VRM10_Samples/ClothSample/RotateParticle/RotateParticle.asmdef index 023d57489..2e4dac009 100644 --- a/Assets/VRM10_Samples/ClothSample/RotateParticle/RotateParticle.asmdef +++ b/Assets/VRM10_Samples/ClothSample/RotateParticle/RotateParticle.asmdef @@ -2,7 +2,10 @@ "name": "RotateParticle", "rootNamespace": "", "references": [ - "GUID:0138a2c7639266f45b948ea162125de5" + "GUID:0138a2c7639266f45b948ea162125de5", + "GUID:3e5d614bc16b50d41bd94c8d7444ca46", + "GUID:e47c917724578cc43b5506c17a27e9a0", + "GUID:8d76e605759c3f64a957d63ef96ada7c" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/RotateParticleSpringboneRuntime.cs b/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/RotateParticleSpringboneRuntime.cs new file mode 100644 index 000000000..24f31a300 --- /dev/null +++ b/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/RotateParticleSpringboneRuntime.cs @@ -0,0 +1,60 @@ +using System; +using System.Threading.Tasks; +using UniGLTF; +using UniGLTF.SpringBoneJobs.Blittables; +using UnityEngine; +using UniVRM10; + +namespace RotateParticle +{ + /// + /// SpcriptedImporter 経由の import 向け。 + /// NativeArray の確保や DontDestroyOnLoad を回避。 + /// + public class RotateParticleSpringboneRuntime : IVrm10SpringBoneRuntime + { + Action _setup; + + public RotateParticleSpringboneRuntime(Action setup) + { + _setup = setup; + } + + public void Dispose() + { + } + + public Task InitializeAsync(Vrm10Instance instance, IAwaitCaller awaitCaller) + { + if (_setup != null) + { + _setup(instance); + } + var system = instance.GetComponent(); + system.Initialize(); + + return Task.CompletedTask; + } + + public void Process() + { + } + + public bool ReconstructSpringBone() + { + return false; + } + + public void RestoreInitialTransform() + { + } + + public void SetJointLevel(Transform joint, BlittableJointMutable jointSettings) + { + } + + public void SetModelLevel(Transform modelRoot, BlittableModelLevel modelSettings) + { + } + } +} \ No newline at end of file diff --git a/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/RotateParticleSpringboneRuntime.cs.meta b/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/RotateParticleSpringboneRuntime.cs.meta new file mode 100644 index 000000000..7db3453e5 --- /dev/null +++ b/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/RotateParticleSpringboneRuntime.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: edc50c3e3f828de469f8ae6af569c174 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: