Beispiel #1
0
        public static AimConstraint Deserialize_Aim(ListTreeNode <JsonValue> parsed)
        {
            var value = new AimConstraint();

            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 == "source")
                {
                    value.Source = kv.Value.GetInt32();
                    continue;
                }

                if (key == "sourceSpace")
                {
                    value.SourceSpace = (ObjectSpace)Enum.Parse(typeof(ObjectSpace), kv.Value.GetString(), true);
                    continue;
                }

                if (key == "destinationSpace")
                {
                    value.DestinationSpace = (ObjectSpace)Enum.Parse(typeof(ObjectSpace), kv.Value.GetString(), true);
                    continue;
                }

                if (key == "aimVector")
                {
                    value.AimVector = Deserialize_AimVector(kv.Value);
                    continue;
                }

                if (key == "upVector")
                {
                    value.UpVector = Deserialize_UpVector(kv.Value);
                    continue;
                }

                if (key == "freezeAxes")
                {
                    value.FreezeAxes = Deserialize_FreezeAxes(kv.Value);
                    continue;
                }

                if (key == "weight")
                {
                    value.Weight = kv.Value.GetSingle();
                    continue;
                }
            }
            return(value);
        }
Beispiel #2
0
        public static void Serialize_Aim(JsonFormatter f, AimConstraint 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.Source.HasValue)
            {
                f.Key("source");
                f.Value(value.Source.GetValueOrDefault());
            }

            if (true)
            {
                f.Key("sourceSpace");
                f.Value(value.SourceSpace.ToString());
            }

            if (true)
            {
                f.Key("destinationSpace");
                f.Value(value.DestinationSpace.ToString());
            }

            if (value.AimVector != null && value.AimVector.Count() >= 3)
            {
                f.Key("aimVector");
                Serialize_AimVector(f, value.AimVector);
            }

            if (value.UpVector != null && value.UpVector.Count() >= 3)
            {
                f.Key("upVector");
                Serialize_UpVector(f, value.UpVector);
            }

            if (value.FreezeAxes != null && value.FreezeAxes.Count() >= 2)
            {
                f.Key("freezeAxes");
                Serialize_FreezeAxes(f, value.FreezeAxes);
            }

            if (value.Weight.HasValue)
            {
                f.Key("weight");
                f.Value(value.Weight.GetValueOrDefault());
            }

            f.EndMap();
        }