private static List <STKeyFrame> ParseKeyFrames(JsonReader reader, STInterpoaltionType type) { if (type == STInterpoaltionType.Constant) { return(new List <STKeyFrame>()); } List <STKeyFrame> keyFrames = new List <STKeyFrame>(); while (reader.Read()) { if (reader.TokenType == JsonToken.EndObject) { break; } if (reader.Value == null) { continue; } if (reader.Value.Equals("Frame")) { if (type == STInterpoaltionType.Bezier) { STBezierKeyFrame keyFrame = new STBezierKeyFrame(); keyFrame.Frame = (float)reader.ReadAsDecimal(); reader.Read(); //Value keyFrame.Value = (float)reader.ReadAsDecimal(); reader.Read(); //in keyFrame.SlopeIn = (float)reader.ReadAsDecimal(); reader.Read(); //out keyFrame.SlopeOut = (float)reader.ReadAsDecimal(); keyFrames.Add(keyFrame); } else { STKeyFrame keyFrame = new STKeyFrame(); keyFrame.Frame = (float)reader.ReadAsDecimal(); reader.Read(); //Value keyFrame.Value = (float)reader.ReadAsDecimal(); keyFrames.Add(keyFrame); } } } return(keyFrames); }
private InterpolationMode ConvertType(STInterpoaltionType mode) { switch (mode) { case STInterpoaltionType.Linear: return(InterpolationMode.Linear); case STInterpoaltionType.Bezier: return(InterpolationMode.Bezier); case STInterpoaltionType.Step: return(InterpolationMode.Step); case STInterpoaltionType.Constant: return(InterpolationMode.Constant); case STInterpoaltionType.Bitmap: return(InterpolationMode.Bitmap); default: return(InterpolationMode.Constant); } }
public STAnimationTrack(STInterpoaltionType interpolation) { InterpolationType = interpolation; }
private static AnimTrack ParseAnimTrack(JsonReader reader, AnimationNode group, STInterpoaltionType type) { string effect = reader.ReadAsString(); AnimTrack track = new AnimTrack(group); track.ValueIdx = group.ValueIndex; track.TrackMode = group.Mode; track.TrackEffect = ParseEffect(group.Mode, effect); track.InterpolationType = type; track.KeyFrames = new List <STKeyFrame>(); track.Unknown = 0; reader.Read(); track.KeyFrames = ParseKeyFrames(reader, type); return(track); }