public TrackingShot Load() { string shotstr = SettingsStore.Get <string>(Entity, "shot", null); if (shotstr == null) { return(new TrackingShot()); } var parser = new RDParser(shotstr); parser.Expect("Position"); parser.Expect(":"); var position_timeline = Timeline.Deserialize(parser); parser.Expect(","); parser.Expect("LookAt"); parser.Expect(":"); var lookat_timeline = Timeline.Deserialize(parser); parser.Expect(","); parser.Expect("UpVec"); parser.Expect(":"); var upvec_timeline = Timeline.Deserialize(parser); parser.End(); return(new TrackingShot(position_timeline, lookat_timeline, upvec_timeline)); }
public static Timeline Deserialize(RDParser parser) { Timeline timeline = new Timeline(); while (true) { long frame = 0; TrackingInfo info = new TrackingInfo(); if (!parser.Accept("[")) { break; } if (!parser.GetLong(ref frame)) { parser.Fail("frame expected"); } parser.Expect(":"); if (parser.Accept("Locked")) { info.Mode = TrackMode.Locked; } else if (parser.Accept("Unlocked")) { info.Mode = TrackMode.Unlocked; } else { parser.Fail("unknown track mode"); } parser.Expect(":"); if (info.Mode == TrackMode.Locked) { if (!parser.GetLong(ref info.EntityId)) { parser.Fail("entity id expected"); } } parser.Expect(":"); parser.Expect("<"); if (!parser.GetDouble(ref info.Value3D.X)) { parser.Fail("vector x expected"); } parser.Expect(","); if (!parser.GetDouble(ref info.Value3D.Y)) { parser.Fail("vector y expected"); } parser.Expect(","); if (!parser.GetDouble(ref info.Value3D.Z)) { parser.Fail("vector z expected"); } parser.Expect(">"); parser.Expect(":"); if (parser.Accept("Constant")) { info.Transition = TransitionMode.Constant; } else if (parser.Accept("Linear")) { info.Transition = TransitionMode.Linear; } else if (parser.Accept("Cosine")) { info.Transition = TransitionMode.Cosine; } else if (parser.Accept("Spline")) { info.Transition = TransitionMode.Spline; } else { parser.Fail("unknown transition mode"); } parser.Expect("]"); timeline.keyframes.Add((int)frame, info); } return(timeline); }