示例#1
0
        private static void Traverse(JsonNode node, JsonFormatter f, FilePath dir)
        {
            if (node.IsArray())
            {
                f.BeginList();
                foreach (var x in node.ArrayItems())
                {
                    TraverseItem(x, f, dir);
                }
                f.EndList();
            }
            else if (node.IsMap())
            {
                f.BeginMap();
                foreach (var kv in node.ObjectItems())
                {
                    f.Key(kv.Key.GetUtf8String());
                    TraverseItem(kv.Value, f, dir);
                }

                f.EndMap();
            }
            else
            {
                f.Value(node);
            }
        }
示例#2
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);
            }
        }
示例#3
0
        /// <summary>
        /// JsonPath を 再帰的に列挙する
        /// object[] の中身は int(array index) or string(object key)
        /// </summary>
        /// <param name="node"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public static IEnumerable <object[]> TraverseJsonPath(JsonNode node, List <object> path)
        {
            if (path == null)
            {
                path = new List <object>();
            }
            yield return(path.ToArray());

            if (node.IsArray())
            {
                int i = 0;
                foreach (var child in node.ArrayItems())
                {
                    path.Add(i);
                    foreach (var x in TraverseJsonPath(child, path))
                    {
                        yield return(x);
                    }
                    path.RemoveAt(path.Count - 1);
                    ++i;
                }
            }
            else if (node.IsMap())
            {
                foreach (var kv in node.ObjectItems())
                {
                    path.Add(kv.Key.GetString());
                    foreach (var x in TraverseJsonPath(kv.Value, path))
                    {
                        yield return(x);
                    }
                    path.RemoveAt(path.Count - 1);
                }
            }
        }
示例#4
0
 static void Traverse(this glTF self, JsonNode node, JsonFormatter f, Utf8String parentKey)
 {
     if (node.IsMap())
     {
         f.BeginMap();
         foreach (var kv in node.ObjectItems())
         {
             if (parentKey == s_extensions)
             {
                 if (!self.UsedExtension(kv.Key.GetString()))
                 {
                     continue;
                 }
             }
             f.Key(kv.Key.GetUtf8String());
             self.Traverse(kv.Value, f, kv.Key.GetUtf8String());
         }
         f.EndMap();
     }
     else if (node.IsArray())
     {
         f.BeginList();
         foreach (var x in node.ArrayItems())
         {
             self.Traverse(x, f, default(Utf8String));
         }
         f.EndList();
     }
     else
     {
         f.Value(node);
     }
 }
        public static List <VCI.glTF_VCAST_vci_animationReference> glTF_VCAST_vci_animation_Deserializevci_animationReferences(JsonNode parsed)
        {
            var value = new List <glTF_VCAST_vci_animationReference>();

            foreach (var x in parsed.ArrayItems())
            {
                value.Add(glTF_VCAST_vci_animation_Deserializevci_animationReferences_ITEM(x));
            }
            return(value);
        }
示例#6
0
        public static List <VCI.glTF_VCAST_vci_embedded_script_source> glTF_VCAST_vci_embedded_script_Deserializevci_scripts(JsonNode parsed)
        {
            var value = new List <glTF_VCAST_vci_embedded_script_source>();

            foreach (var x in parsed.ArrayItems())
            {
                value.Add(glTF_VCAST_vci_embedded_script_Deserializevci_scripts_ITEM(x));
            }
            return(value);
        }
示例#7
0
 static IEnumerable <float> DeserializeFloat2(JsonNode json)
 {
     if (json.Value.ValueType == ValueNodeType.Array)
     {
         foreach (var a in json.ArrayItems())
         {
             yield return(a.GetSingle());
         }
     }
 }
        public static List <VCI.glTF_Effekseer_effect> glTF_Effekseer_Deserializevci_effects(JsonNode parsed)
        {
            var value = new List <glTF_Effekseer_effect>();

            foreach (var x in parsed.ArrayItems())
            {
                value.Add(glTF_Effekseer_Deserializevci_effects_ITEM(x));
            }
            return(value);
        }
示例#9
0
        public static List <VCI.glTF_VCAST_vci_SpringBone> glTF_VCAST_vci_spring_bone_Deserializevci_springBones(JsonNode parsed)
        {
            var value = new List <glTF_VCAST_vci_SpringBone>();

            foreach (var x in parsed.ArrayItems())
            {
                value.Add(glTF_VCAST_vci_spring_bone_Deserializevci_springBones_ITEM(x));
            }
            return(value);
        }
示例#10
0
        public static List <VRM.glTF_VRM_SecondaryAnimationColliderGroup> Deserialize_vrm_secondaryAnimation_colliderGroups(JsonNode parsed)
        {
            var value = new List <glTF_VRM_SecondaryAnimationColliderGroup>();

            foreach (var x in parsed.ArrayItems())
            {
                value.Add(Deserialize_vrm_secondaryAnimation_colliderGroups_LIST(x));
            }
            return(value);
        }
示例#11
0
        public static List <VRM.glTF_VRM_MaterialValueBind> Deserialize_vrm_blendShapeMaster_blendShapeGroups__materialValues(JsonNode parsed)
        {
            var value = new List <glTF_VRM_MaterialValueBind>();

            foreach (var x in parsed.ArrayItems())
            {
                value.Add(Deserialize_vrm_blendShapeMaster_blendShapeGroups__materialValues_LIST(x));
            }
            return(value);
        }
示例#12
0
        public static List <VRM.glTF_VRM_MeshAnnotation> Deserialize_vrm_firstPerson_meshAnnotations(JsonNode parsed)
        {
            var value = new List <glTF_VRM_MeshAnnotation>();

            foreach (var x in parsed.ArrayItems())
            {
                value.Add(Deserialize_vrm_firstPerson_meshAnnotations_LIST(x));
            }
            return(value);
        }
示例#13
0
        public static List <VCI.glTF_VCAST_vci_joint> glTF_VCAST_vci_joints_Deserializevci_joints(JsonNode parsed)
        {
            var value = new List <glTF_VCAST_vci_joint>();

            foreach (var x in parsed.ArrayItems())
            {
                value.Add(glTF_VCAST_vci_joints_Deserializevci_joints_ITEM(x));
            }
            return(value);
        }
示例#14
0
        public static List <ColliderGroup> Deserialize_ColliderGroups(JsonNode parsed)
        {
            var value = new List <ColliderGroup>();

            foreach (var x in parsed.ArrayItems())
            {
                value.Add(Deserialize_ColliderGroups_ITEM(x));
            }
            return(value);
        }
示例#15
0
        public static List <VRM.glTF_VRM_Material> Deserialize_vrm_materialProperties(JsonNode parsed)
        {
            var value = new List <glTF_VRM_Material>();

            foreach (var x in parsed.ArrayItems())
            {
                value.Add(Deserialize_vrm_materialProperties_LIST(x));
            }
            return(value);
        }
示例#16
0
        public static List <Spring> Deserialize_Springs(JsonNode parsed)
        {
            var value = new List <Spring>();

            foreach (var x in parsed.ArrayItems())
            {
                value.Add(Deserialize_Springs_ITEM(x));
            }
            return(value);
        }
示例#17
0
        public static List <SpringBoneJoint> __springs_ITEM_Deserialize_Joints(JsonNode parsed)
        {
            var value = new List <SpringBoneJoint>();

            foreach (var x in parsed.ArrayItems())
            {
                value.Add(__springs_ITEM_Deserialize_Joints_ITEM(x));
            }
            return(value);
        }
示例#18
0
        public static List <System.String> glTF_VCAST_vci_attachable_Deserializevci_attachableHumanBodyBones(JsonNode parsed)
        {
            var value = new List <String>();

            foreach (var x in parsed.ArrayItems())
            {
                value.Add(x.GetString());
            }
            return(value);
        }
示例#19
0
        public static List <VRM.glTF_VRM_HumanoidBone> Deserialize_vrm_humanoid_humanBones(JsonNode parsed)
        {
            var value = new List <glTF_VRM_HumanoidBone>();

            foreach (var x in parsed.ArrayItems())
            {
                value.Add(Deserialize_vrm_humanoid_humanBones_LIST(x));
            }
            return(value);
        }
        public static List <VCI.glTF_VCI_Material> glTF_VCAST_vci_material_unity_Deserializevci_materials(JsonNode parsed)
        {
            var value = new List <glTF_VCI_Material>();

            foreach (var x in parsed.ArrayItems())
            {
                value.Add(glTF_VCAST_vci_material_unity_Deserializevci_materials_ITEM(x));
            }
            return(value);
        }
示例#21
0
        public static int[] __springs_ITEM_Deserialize_ColliderGroups(JsonNode parsed)
        {
            var value = new int[parsed.GetArrayCount()];
            int i     = 0;

            foreach (var x in parsed.ArrayItems())
            {
                value[i++] = x.GetInt32();
            }
            return(value);
        }
示例#22
0
        public static float[] __springs_ITEM__joints_ITEM_Deserialize_GravityDir(JsonNode parsed)
        {
            var value = new float[parsed.GetArrayCount()];
            int i     = 0;

            foreach (var x in parsed.ArrayItems())
            {
                value[i++] = x.GetSingle();
            }
            return(value);
        }
示例#23
0
        public static float[] __colliderGroups_ITEM__colliders_ITEM__shape__capsule_Deserialize_Tail(JsonNode parsed)
        {
            var value = new float[parsed.GetArrayCount()];
            int i     = 0;

            foreach (var x in parsed.ArrayItems())
            {
                value[i++] = x.GetSingle();
            }
            return(value);
        }
        public static Single[] glTF_VCAST_vci_material_unity_Deserializevci_materials__vectorProperties_ITEM(JsonNode parsed)
        {
            var value = new Single[parsed.GetArrayCount()];
            int i     = 0;

            foreach (var x in parsed.ArrayItems())
            {
                value[i++] = x.GetSingle();
            }
            return(value);
        }
示例#25
0
        public static Single[] glTF_VCAST_vci_lightmap_Deserializevci_lightmap_offset(JsonNode parsed)
        {
            var value = new Single[parsed.GetArrayCount()];
            int i     = 0;

            foreach (var x in parsed.ArrayItems())
            {
                value[i++] = x.GetSingle();
            }
            return(value);
        }
示例#26
0
        public static bool[] Deserialize_FreezeAxes(JsonNode parsed)
        {
            var value = new bool[parsed.GetArrayCount()];
            int i     = 0;

            foreach (var x in parsed.ArrayItems())
            {
                value[i++] = x.GetBoolean();
            }
            return(value);
        }
        public static Single[] glTF_VCAST_vci_reflectionProbe_Deserializevci_reflectionProbe_boxSize(JsonNode parsed)
        {
            var value = new Single[parsed.GetArrayCount()];
            int i     = 0;

            foreach (var x in parsed.ArrayItems())
            {
                value[i++] = x.GetSingle();
            }
            return(value);
        }
        public static glTFCubemapFaceTextureSet[] glTF_VCAST_vci_reflectionProbe_Deserializevci_reflectionProbe_cubemap_mipmapTextures(JsonNode parsed)
        {
            var value = new glTFCubemapFaceTextureSet[parsed.GetArrayCount()];
            int i     = 0;

            foreach (var x in parsed.ArrayItems())
            {
                value[i++] = glTF_VCAST_vci_reflectionProbe_Deserializevci_reflectionProbe_cubemap_mipmapTextures_ITEM(x);
            }
            return(value);
        }
示例#29
0
        public static float[] Deserialize_OutlineColorFactor(JsonNode parsed)
        {
            var value = new float[parsed.GetArrayCount()];
            int i     = 0;

            foreach (var x in parsed.ArrayItems())
            {
                value[i++] = x.GetSingle();
            }
            return(value);
        }
示例#30
0
        public static Single[] glTF_VCAST_vci_joints_Deserializevci_joints__connectedAnchor(JsonNode parsed)
        {
            var value = new Single[parsed.GetArrayCount()];
            int i     = 0;

            foreach (var x in parsed.ArrayItems())
            {
                value[i++] = x.GetSingle();
            }
            return(value);
        }