Пример #1
0
        static IEnumerable <UniGLTF.Extensions.VRMC_vrm.MorphTargetBind> ToMorphTargetBinds(JsonNode json,
                                                                                            MigrationVrm.MeshIndexToNodeIndexFunc meshToNode)
        {
            foreach (var x in json.ArrayItems())
            {
                var meshIndex        = x["mesh"].GetInt32();
                var morphTargetIndex = x["index"].GetInt32();
                var weight           = x["weight"].GetSingle();

                var bind = new UniGLTF.Extensions.VRMC_vrm.MorphTargetBind();

                // https://github.com/vrm-c/vrm-specification/pull/106
                // https://github.com/vrm-c/vrm-specification/pull/153
                var nodeIndex = meshToNode(meshIndex);
                if (nodeIndex == -1)
                {
                    // invalid data. skip
                    Debug.LogWarning($"[MigrationVrmExpression] node.mesh == {meshIndex} not found");
                    continue;
                }
                bind.Node  = nodeIndex;
                bind.Index = morphTargetIndex;
                // https://github.com/vrm-c/vrm-specification/issues/209
                bind.Weight = weight * 0.01f;

                yield return(bind);
            }
        }
Пример #2
0
        static IEnumerable <UniGLTF.Extensions.VRMC_vrm.MorphTargetBind> ToMorphTargetBinds(UniGLTF.glTF gltf, JsonNode json)
        {
            foreach (var x in json.ArrayItems())
            {
                var meshIndex        = x["mesh"].GetInt32();
                var morphTargetIndex = x["index"].GetInt32();
                var weight           = x["weight"].GetSingle();

                var bind = new UniGLTF.Extensions.VRMC_vrm.MorphTargetBind();

                // https://github.com/vrm-c/vrm-specification/pull/106
                // https://github.com/vrm-c/vrm-specification/pull/153
                bind.Node  = gltf.nodes.IndexOf(gltf.nodes.First(y => y.mesh == meshIndex));
                bind.Index = morphTargetIndex;
                // https://github.com/vrm-c/vrm-specification/issues/209
                bind.Weight = weight * 0.01f;

                yield return(bind);
            }
        }