From 3e16a2f492160ee79d730bdfc79cd4a9eb5cd92d Mon Sep 17 00:00:00 2001 From: ousttrue Date: Tue, 25 May 2021 14:55:35 +0900 Subject: [PATCH] =?UTF-8?q?LoadDivided=20=E3=81=AB=20BlendShape=20import?= =?UTF-8?q?=20=E3=81=AE=E5=AE=9F=E8=A3=85=E3=81=8C=E7=84=A1=E3=81=8B?= =?UTF-8?q?=E3=81=A3=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Runtime/IO/Model/MeshImporterDivided.cs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Assets/VRM10/Runtime/IO/Model/MeshImporterDivided.cs b/Assets/VRM10/Runtime/IO/Model/MeshImporterDivided.cs index 56dcfba8b..64c646c71 100644 --- a/Assets/VRM10/Runtime/IO/Model/MeshImporterDivided.cs +++ b/Assets/VRM10/Runtime/IO/Model/MeshImporterDivided.cs @@ -45,9 +45,8 @@ namespace UniVRM10 }); } } - - // TODO: BlendShape } + dst.name = src.Name; dst.vertices = positions.ToArray(); dst.normals = normals.ToArray(); @@ -80,6 +79,25 @@ namespace UniVRM10 dst.RecalculateBounds(); dst.RecalculateTangents(); + + // + // blendshape + // + var blendShapeCount = src.Meshes[0].MorphTargets.Count; + for (int i = 0; i < blendShapeCount; ++i) + { + positions.Clear(); + normals.Clear(); + var name = src.Meshes[0].MorphTargets[i].Name; + for (int meshIndex = 0; meshIndex < src.Meshes.Count; ++meshIndex) + { + var morphTarget = src.Meshes[meshIndex].MorphTargets[i]; + positions.AddRange(morphTarget.VertexBuffer.Positions.GetSpan()); + normals.AddRange(morphTarget.VertexBuffer.Normals.GetSpan()); + } + dst.AddBlendShapeFrame(name, 100.0f, positions.ToArray(), normals.ToArray(), null); + } + return dst; } }