public static RotationConstraint Deserialize_Rotation(ListTreeNode <JsonValue> parsed) { var value = new RotationConstraint(); 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 == "freezeAxes") { value.FreezeAxes = Deserialize_FreezeAxes(kv.Value); continue; } if (key == "weight") { value.Weight = kv.Value.GetSingle(); continue; } } return(value); }
public static void Serialize_Rotation(JsonFormatter f, RotationConstraint 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.FreezeAxes != null && value.FreezeAxes.Count() >= 3) { f.Key("freezeAxes"); Serialize_FreezeAxes(f, value.FreezeAxes); } if (value.Weight.HasValue) { f.Key("weight"); f.Value(value.Weight.GetValueOrDefault()); } f.EndMap(); }