From c0a02c3c5e52da54c4513a6d9d15dd0d2a5f4024 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 14 Oct 2021 15:36:01 +0900 Subject: [PATCH 1/4] Test use latest interface. --- Assets/VRM10/Tests/MigrationTests.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Assets/VRM10/Tests/MigrationTests.cs b/Assets/VRM10/Tests/MigrationTests.cs index d3371eade..d06b496a2 100644 --- a/Assets/VRM10/Tests/MigrationTests.cs +++ b/Assets/VRM10/Tests/MigrationTests.cs @@ -198,13 +198,13 @@ namespace UniVRM10 foreach (var gltf in EnumerateGltfFiles(root)) { - var bytes = File.ReadAllBytes(gltf.FullName); try { - var migrated = MigrationVrm.Migrate(bytes); - var data = new GlbLowLevelParser(gltf.FullName, migrated).Parse(); - UniGLTF.Extensions.VRMC_vrm.GltfDeserializer.TryGet(data.GLTF.extensions, out UniGLTF.Extensions.VRMC_vrm.VRMC_vrm vrm); - Assert.NotNull(vrm); + Vrm10Data.TryParseOrMigrate(gltf.FullName, true, out Vrm10Data vrm); + using (var loader = new Vrm10Importer(vrm)) + { + loader.LoadAsync().Wait(); + } } catch (UnNormalizedException) { From e54afdbeed094dd9c188054b5639f2395e09bd63 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 14 Oct 2021 15:54:26 +0900 Subject: [PATCH 2/4] bones null check --- .../Migration/MigrationVrmSpringBone.cs | 52 +++++++++++-------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/Assets/VRM10/Runtime/Migration/MigrationVrmSpringBone.cs b/Assets/VRM10/Runtime/Migration/MigrationVrmSpringBone.cs index 0a4760fc7..6e50bcc67 100644 --- a/Assets/VRM10/Runtime/Migration/MigrationVrmSpringBone.cs +++ b/Assets/VRM10/Runtime/Migration/MigrationVrmSpringBone.cs @@ -129,10 +129,13 @@ namespace UniVRM10 // その差異に対応して、7cmの遠さに node を追加する。 foreach (var x in sa["boneGroups"].ArrayItems()) { - foreach (var y in x["bones"].ArrayItems()) + if (x.ContainsKey("bones")) { - var joints = TraverseFirstChild(gltf.nodes, gltf.nodes[y.GetInt32()]).ToArray(); - AddTail7cm(gltf, joints); + foreach (var y in x["bones"].ArrayItems()) + { + var joints = TraverseFirstChild(gltf.nodes, gltf.nodes[y.GetInt32()]).ToArray(); + AddTail7cm(gltf, joints); + } } } @@ -163,30 +166,33 @@ namespace UniVRM10 // 5 // ] // }, - foreach (var y in x["bones"].ArrayItems()) + if (x.ContainsKey("bones")) { - var comment = x.GetObjectValueOrDefault("comment", ""); - var spring = new UniGLTF.Extensions.VRMC_springBone.Spring + foreach (var y in x["bones"].ArrayItems()) { - Name = comment, - ColliderGroups = x["colliderGroups"].ArrayItems().Select(z => z.GetInt32()).ToArray(), - Joints = new List(), - }; - - foreach (var z in TraverseFirstChild(gltf.nodes, gltf.nodes[y.GetInt32()])) - { - spring.Joints.Add(new UniGLTF.Extensions.VRMC_springBone.SpringBoneJoint + var comment = x.GetObjectValueOrDefault("comment", ""); + var spring = new UniGLTF.Extensions.VRMC_springBone.Spring { - Node = gltf.nodes.IndexOf(z), - DragForce = x["dragForce"].GetSingle(), - GravityDir = MigrateVector3.Migrate(x["gravityDir"]), - GravityPower = x["gravityPower"].GetSingle(), - HitRadius = x["hitRadius"].GetSingle(), - Stiffness = x["stiffiness"].GetSingle(), - }); - } + Name = comment, + ColliderGroups = x["colliderGroups"].ArrayItems().Select(z => z.GetInt32()).ToArray(), + Joints = new List(), + }; - springBone.Springs.Add(spring); + foreach (var z in TraverseFirstChild(gltf.nodes, gltf.nodes[y.GetInt32()])) + { + spring.Joints.Add(new UniGLTF.Extensions.VRMC_springBone.SpringBoneJoint + { + Node = gltf.nodes.IndexOf(z), + DragForce = x["dragForce"].GetSingle(), + GravityDir = MigrateVector3.Migrate(x["gravityDir"]), + GravityPower = x["gravityPower"].GetSingle(), + HitRadius = x["hitRadius"].GetSingle(), + Stiffness = x["stiffiness"].GetSingle(), + }); + } + + springBone.Springs.Add(spring); + } } } From 0f2c97c10a1e1fdb4148c49b5929249ba6848616 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 14 Oct 2021 16:25:24 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=E3=83=9E=E3=82=A4=E3=82=B0=E3=83=AC?= =?UTF-8?q?=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E6=99=82=E3=81=AB=E5=8F=A4?= =?UTF-8?q?=E3=81=84=E9=A0=82=E7=82=B9Attribute=E3=81=8C=E6=AE=8B=E3=81=A3?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=81=9F(TANGENT,=20COLOR=5F0,=20TEXCOORD=5F?= =?UTF-8?q?1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/VRM10/Runtime/Migration/MeshUpdater.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Assets/VRM10/Runtime/Migration/MeshUpdater.cs b/Assets/VRM10/Runtime/Migration/MeshUpdater.cs index 01fc05ef6..d0d808554 100644 --- a/Assets/VRM10/Runtime/Migration/MeshUpdater.cs +++ b/Assets/VRM10/Runtime/Migration/MeshUpdater.cs @@ -82,6 +82,7 @@ namespace UniVRM10 var uv = AddAccessor(mesh.VertexBuffer.TexCoords); var weights = AddAccessor(mesh.VertexBuffer.Weights); var joints = AddAccessor(mesh.VertexBuffer.Joints); + var color = AddAccessor(mesh.VertexBuffer.Colors); var morphTargets = new MorphAccessor[] { }; if (mesh.MorphTargets != null) @@ -99,7 +100,10 @@ namespace UniVRM10 gltfPrim.indices = AddAccessor(subIndices); gltfPrim.attributes.POSITION = position.Value; gltfPrim.attributes.NORMAL = normal.Value; + gltfPrim.attributes.TANGENT = -1; + gltfPrim.attributes.COLOR_0 = color.GetValueOrDefault(-1); gltfPrim.attributes.TEXCOORD_0 = uv.Value; + gltfPrim.attributes.TEXCOORD_1 = -1; gltfPrim.attributes.WEIGHTS_0 = weights.GetValueOrDefault(-1); gltfPrim.attributes.JOINTS_0 = joints.GetValueOrDefault(-1); foreach (var (gltfMorph, morph) in Enumerable.Zip(gltfPrim.targets, morphTargets, (l, r) => (l, r))) From 9560187ea201f464f07718389e739ff960648fec Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 14 Oct 2021 16:49:10 +0900 Subject: [PATCH 4/4] clear Tangent --- Assets/VRM10/Runtime/Migration/MeshUpdater.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Assets/VRM10/Runtime/Migration/MeshUpdater.cs b/Assets/VRM10/Runtime/Migration/MeshUpdater.cs index d0d808554..5fdf3fe61 100644 --- a/Assets/VRM10/Runtime/Migration/MeshUpdater.cs +++ b/Assets/VRM10/Runtime/Migration/MeshUpdater.cs @@ -110,6 +110,7 @@ namespace UniVRM10 { gltfMorph.POSITION = morph.Position.GetValueOrDefault(-1); gltfMorph.NORMAL = morph.Normal.GetValueOrDefault(-1); + gltfMorph.TANGENT = -1; } } }