Example #1
0
        public static void Serialize_Springs_ITEM(JsonFormatter f, Spring value)
        {
            f.BeginMap();


            if (value.Extensions != null)
            {
                f.Key("extensions");
                (value.Extensions as glTFExtension).Serialize(f);
            }

            if (value.Extras != null)
            {
                f.Key("extras");
                (value.Extras as glTFExtension).Serialize(f);
            }

            if (!string.IsNullOrEmpty(value.Name))
            {
                f.Key("name");
                f.Value(value.Name);
            }

            if (value.Joints != null && value.Joints.Count() >= 1)
            {
                f.Key("joints");
                __springs_ITEM_Serialize_Joints(f, value.Joints);
            }

            if (value.ColliderGroups != null && value.ColliderGroups.Count() >= 1)
            {
                f.Key("colliderGroups");
                __springs_ITEM_Serialize_ColliderGroups(f, value.ColliderGroups);
            }

            if (value.Center.HasValue)
            {
                f.Key("center");
                f.Value(value.Center.GetValueOrDefault());
            }

            f.EndMap();
        }
Example #2
0
        public static Spring Deserialize_Springs_ITEM(JsonNode parsed)
        {
            var value = new Spring();

            foreach (var kv in parsed.ObjectItems())
            {
                var key = kv.Key.GetString();

                if (key == "extensions")
                {
                    value.Extensions = new glTFExtensionImport(kv.Value);
                    continue;
                }

                if (key == "extras")
                {
                    value.Extras = new glTFExtensionImport(kv.Value);
                    continue;
                }

                if (key == "name")
                {
                    value.Name = kv.Value.GetString();
                    continue;
                }

                if (key == "joints")
                {
                    value.Joints = __springs_ITEM_Deserialize_Joints(kv.Value);
                    continue;
                }

                if (key == "colliderGroups")
                {
                    value.ColliderGroups = __springs_ITEM_Deserialize_ColliderGroups(kv.Value);
                    continue;
                }
            }
            return(value);
        }
Example #3
0
        public static Spring Deserialize_Springs_ITEM(ListTreeNode <JsonValue> parsed)
        {
            var value = new Spring();

            foreach (var kv in parsed.ObjectItems())
            {
                var key = kv.Key.GetString();

                if (key == "name")
                {
                    value.Name = kv.Value.GetString();
                    continue;
                }

                if (key == "setting")
                {
                    value.Setting = kv.Value.GetInt32();
                    continue;
                }

                if (key == "springRoot")
                {
                    value.SpringRoot = kv.Value.GetInt32();
                    continue;
                }

                if (key == "hitRadius")
                {
                    value.HitRadius = kv.Value.GetSingle();
                    continue;
                }

                if (key == "colliders")
                {
                    value.Colliders = Deserialize_Colliders(kv.Value);
                    continue;
                }
            }
            return(value);
        }
Example #4
0
        public static void Serialize_Springs_ITEM(JsonFormatter f, Spring value)
        {
            f.BeginMap();


            if (value.Extensions != null)
            {
                f.Key("extensions");
                value.Extensions.Serialize(f);
            }

            if (value.Extras != null)
            {
                f.Key("extras");
                value.Extras.Serialize(f);
            }

            if (!string.IsNullOrEmpty(value.Name))
            {
                f.Key("name");
                f.Value(value.Name);
            }

            if (value.Joints != null && value.Joints.Count() >= 0)
            {
                f.Key("joints");
                Serialize_Joints(f, value.Joints);
            }

            if (value.Colliders != null && value.Colliders.Count() >= 0)
            {
                f.Key("colliders");
                Serialize_Colliders(f, value.Colliders);
            }

            f.EndMap();
        }
Example #5
0
        public static void Serialize_Springs_ITEM(JsonFormatter f, Spring value)
        {
            f.BeginMap();


            if (!string.IsNullOrEmpty(value.Name))
            {
                f.Key("name");
                f.Value(value.Name);
            }

            if (value.Setting.HasValue)
            {
                f.Key("setting");
                f.Value(value.Setting.GetValueOrDefault());
            }

            if (value.SpringRoot.HasValue)
            {
                f.Key("springRoot");
                f.Value(value.SpringRoot.GetValueOrDefault());
            }

            if (value.HitRadius.HasValue)
            {
                f.Key("hitRadius");
                f.Value(value.HitRadius.GetValueOrDefault());
            }

            if (value.Colliders != null && value.Colliders.Count() >= 0)
            {
                f.Key("colliders");
                Serialize_Colliders(f, value.Colliders);
            }

            f.EndMap();
        }