public override void Evaluate(double CurrentTime) { base.Evaluate(CurrentTime); FCommand = TLAutomataCommand.NoChange; if (FCurrentState != null) { TLStateKeyFrame lastState = FCurrentState; TLStateKeyFrame tmpState = (FKeyFrames.Find(delegate(TLBaseKeyFrame s) { return(s.Time > CurrentTime); }) as TLStateKeyFrame); if (tmpState.Time > lastState.Time) //lastState is over, so execute action of lastState { SetCurrentStateAndCommand(lastState.Events[0], lastState, lastState.Time); } //else { //go through all events of FCurrentState and see if their inputs are ON double on = 0; foreach (TLEvent e in FCurrentState.Events) { if (e.EventPin != null) { e.EventPin.GetValue(0, out on); if (on > 0.5) { SetCurrentStateAndCommand(e, lastState, CurrentTime); break; } } } } OutputAsString = FCurrentState.Name; } }
public TLEditorValue(List <TLBaseKeyFrame> Keys) : base(Keys) { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); ValueBox.Minimum = double.MinValue; ValueBox.Maximum = double.MaxValue; //check if all keyframes have the same time/value double time = FKeyFrames[0].Time; double val = (FKeyFrames[0] as TLValueKeyFrame).Value; TLBaseKeyFrame kf = FKeyFrames.Find(delegate(TLBaseKeyFrame k) { return(k.Time != time); }); if (kf == null) { TimeBox.Value = time; } kf = FKeyFrames.Find(delegate(TLBaseKeyFrame k) { return((k as TLValueKeyFrame).Value != val); }); if (kf == null) { ValueBox.Value = val; } FStartValue = val; Height = TimeBox.Height + ValueBox.Height + 1; this.ActiveControl = ValueBox; ValueBox.ShowValueBox(); }
public TLEditorString(List <TLBaseKeyFrame> Keys) : base(Keys) { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); //check if all keyframes have the same time/value double time = FKeyFrames[0].Time; string text = (FKeyFrames[0] as TLStringKeyFrame).Value; TLBaseKeyFrame kf = FKeyFrames.Find(delegate(TLBaseKeyFrame k) { return(k.Time != time); }); if (kf == null) { TimeBox.Value = time; } kf = FKeyFrames.Find(delegate(TLBaseKeyFrame k) { return((k as TLStringKeyFrame).Value != text); }); if (kf == null) { ValueBox.Text = text; } FStartValue = ValueBox.Text; Height = TimeBox.Height + ValueBox.Height + 1; //make the valuebox have the focus ValueBox.SelectAll(); this.ActiveControl = ValueBox; }
public override void DestroyPins() { FHost.DeletePin(FKeyTime); FHost.DeletePin(FKeyColor); FKeyTime = null; FKeyColor = null; FKeyFrames.Clear(); }
private void SetCurrentStateAndCommand(TLEvent Event, TLStateKeyFrame LastState, double CurrentTime) { switch (Event.Action.Command) { case TLActionCommand.next: { FCurrentState = (FKeyFrames.Find(delegate(TLBaseKeyFrame s) { return(s.Time > LastState.Time); }) as TLStateKeyFrame); FCommand = TLAutomataCommand.Jump; break; } case TLActionCommand.previous: { FCurrentState = (FKeyFrames.FindLast(delegate(TLBaseKeyFrame s) { return(s.Time < LastState.Time); }) as TLStateKeyFrame); FCommand = TLAutomataCommand.Jump; break; } case TLActionCommand.loop: { FCurrentState = LastState; FCommand = TLAutomataCommand.Jump; break; } case TLActionCommand.play: { FCurrentState = (FKeyFrames.Find(delegate(TLBaseKeyFrame s) { return(s.Time > CurrentTime); }) as TLStateKeyFrame); FCommand = TLAutomataCommand.Play; break; } case TLActionCommand.pause: { FCurrentState = LastState; FPauseTime = CurrentTime; FCommand = TLAutomataCommand.Pause; break; } case TLActionCommand.jump: { FCurrentState = (TLStateKeyFrame)FKeyFrames.Find(delegate(TLBaseKeyFrame k) { return((k as TLStateKeyFrame).Name == Event.GotoState); }); if (FCurrentState == null) { FCurrentState = LastState; FCommand = TLAutomataCommand.Pause; } else { FCommand = TLAutomataCommand.Jump; } break; } } }
private TLBaseKeyFrame AddKeyFrame(double Time, float FlagY, string Value) { //called via configpinchanged and gui-doubleclick float sliceheight = FPin.Height / FPin.SliceCount; float slicetop = FPin.Top + FSliceIndex * sliceheight; TLStringKeyFrame k = new TLStringKeyFrame(FPin.Transformer, Time, FlagY, Value, slicetop, sliceheight); FKeyFrames.Add(k); return(k); }
private TLBaseKeyFrame AddKeyFrame(double Time, double Value, TLInterpolationType InType, TLInterpolationType OutType) { //called via configpinchanged and gui-doubleclick float sliceheight = FPin.Height / FPin.SliceCount; float slicetop = FPin.Top + FSliceIndex * sliceheight; TLValueKeyFrame k = new TLValueKeyFrame(FPin.Transformer, Time, Value, FMinValue, FMaxValue, InType, OutType, slicetop, sliceheight); FKeyFrames.Add(k); return(k); }
private TLBaseKeyFrame AddKeyFrame(string Name, double EndTime, string Events) { //called via configpinchanged and gui-doubleclick float sliceheight = FPin.Height; // / FPin.SliceCount; float slicetop = FPin.Top + FSliceIndex * sliceheight; FKeyFrames.Add(new TLStateKeyFrame(FPin.Transformer, EndTime, Name, Events, slicetop, sliceheight)); return(FKeyFrames[FKeyFrames.Count - 1]); }
private TLBaseKeyFrame AddKeyFrame(double Start, double End, int Track, int Channel, int Note, int Velocity) { //called via configpinchanged and gui-doubleclick float sliceheight = FPin.Height / FPin.SliceCount; float slicetop = FPin.Top + FSliceIndex * sliceheight; TLMidiKeyFrame k = new TLMidiKeyFrame(FPin.Transformer, Track, Channel, Note, Velocity, Start, End, FMinNote, FMaxNote, slicetop, sliceheight); FKeyFrames.Add(k); return(k); }
public override void DestroyPins() { FHost.DeletePin(FStateTime); FHost.DeletePin(FStateName); FHost.DeletePin(FStateEvents); FStateTime = null; FStateName = null; FStateEvents = null; FKeyFrames.Clear(); }
private TLBaseKeyFrame AddKeyFrame(double Time, RGBAColor Color) { //called via configpinchanged and gui-doubleclick float sliceheight = FPin.Height / FPin.SliceCount; float slicetop = FPin.Top + FSliceIndex * sliceheight; TLColorKeyFrame k = new TLColorKeyFrame(FPin.Transformer, Time, Color, slicetop, sliceheight); FKeyFrames.Add(k); return(k); }
public TLEditorColor(List <TLBaseKeyFrame> Keys) : base(Keys) { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); //check if all keyframes have the same time/value //if they have the same value, show that value, if not leave it blank double time = FKeyFrames[0].Time; TLBaseKeyFrame kf = FKeyFrames.Find(delegate(TLBaseKeyFrame k) { return(k.Time != time); }); if (kf == null) { TimeBox.Value = time; } RGBAColor rgba = (FKeyFrames[0] as TLColorKeyFrame).RGBAColor; VColor.RGBtoHSV(rgba.R, rgba.G, rgba.B, out FOldH, out FOldS, out FOldV); FOldA = rgba.A; /* * FOldH = (FKeyFrames[0] as TLColorKeyFrame).Color.GetHue(); * FOldS = (FKeyFrames[0] as TLColorKeyFrame).Color.GetSaturation(); * FOldL = (FKeyFrames[0] as TLColorKeyFrame).Color.GetBrightness(); * FOldA = (FKeyFrames[0] as TLColorKeyFrame).Color.A; */ kf = FKeyFrames.Find(delegate(TLBaseKeyFrame k) { return((k as TLColorKeyFrame).Hue != FOldH); }); if (kf == null) { HueBox.Value = FOldH; } kf = FKeyFrames.Find(delegate(TLBaseKeyFrame k) { return((k as TLColorKeyFrame).Saturation != FOldS); }); if (kf == null) { SatBox.Value = FOldS; } kf = FKeyFrames.Find(delegate(TLBaseKeyFrame k) { return((k as TLColorKeyFrame).Value != FOldV); }); if (kf == null) { LumBox.Value = FOldV; } kf = FKeyFrames.Find(delegate(TLBaseKeyFrame k) { return((k as TLColorKeyFrame).Alpha != FOldA); }); if (kf == null) { AlphaBox.Value = FOldA; } Height = TimeBox.Height + HueBox.Height + SatBox.Height + LumBox.Height + AlphaBox.Height + 4; this.ActiveControl = LumBox; }
public override void DestroyPins() { FHost.DeletePin(FKeyTime); FHost.DeletePin(FKeyFlagY); FHost.DeletePin(FKeyValue); FKeyTime = null; FKeyValue = null; FKeyFlagY = null; FKeyFrames.Clear(); }
public TLEditorState(List <TLBaseKeyFrame> Keys) : base(Keys) { // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); //check if all keyframes have the same time/value double time = FKeyFrames[0].Time; string name = (FKeyFrames[0] as TLStateKeyFrame).Name; string onEndAction = (FKeyFrames[0] as TLStateKeyFrame).Events[0].Action.ToString(); TLBaseKeyFrame kf = FKeyFrames.Find(delegate(TLBaseKeyFrame k) { return(k.Time != time); }); if (kf == null) { TimeBox.Value = time; } kf = FKeyFrames.Find(delegate(TLBaseKeyFrame k) { return((k as TLStateKeyFrame).Name != name); }); if (kf == null) { NameBox.Text = name; } FStartName = NameBox.Text; string events = ""; for (int i = 1; i < (FKeyFrames[0] as TLStateKeyFrame).Events.Count; i++) { events += (FKeyFrames[0] as TLStateKeyFrame).Events[i].ToString(); } events = events.Replace(";", "\r\n"); events = events.Trim(); EventsBox.Text = events; kf = FKeyFrames.Find(delegate(TLBaseKeyFrame k) { return((k as TLStateKeyFrame).Events[0].Action.ToString() != onEndAction); }); if (kf == null) { EndActionBox.Text = onEndAction; } FStartEvents = (FKeyFrames[0] as TLStateKeyFrame).EventsAsString; Height = TimeBox.Height + NameBox.Height + label3.Height + EventsBox.Height + EndActionBox.Height + 4; //make the valuebox have the focus EndActionBox.SelectAll(); this.ActiveControl = EndActionBox; }
public override void SaveKeyFrames() { FKeyTime.SliceCount = FKeyFrames.Count; FKeyColor.SliceCount = FKeyFrames.Count; FKeyFrames.Sort(delegate(TLBaseKeyFrame k0, TLBaseKeyFrame k1) { return(k0.Time.CompareTo(k1.Time)); }); for (int i = 0; i < FKeyFrames.Count; i++) { FKeyTime.SetValue(i, FKeyFrames[i].Time); TLColorKeyFrame kfc = (FKeyFrames[i] as TLColorKeyFrame); FKeyColor.SetColor(i, kfc.RGBAColor); } }
public override void SaveKeyFrames() { FKeyTime.SliceCount = FKeyFrames.Count; FKeyFlagY.SliceCount = FKeyFrames.Count; FKeyValue.SliceCount = FKeyFrames.Count; FKeyFrames.Sort(delegate(TLBaseKeyFrame k0, TLBaseKeyFrame k1) { return(k0.Time.CompareTo(k1.Time)); }); for (int i = 0; i < FKeyFrames.Count; i++) { FKeyTime.SetValue(i, FKeyFrames[i].Time); FKeyFlagY.SetValue(i, (FKeyFrames[i] as TLStringKeyFrame).PositionY); FKeyValue.SetString(i, (FKeyFrames[i] as TLStringKeyFrame).Value); } }
public override void SaveKeyFrames() { FStateTime.SliceCount = FKeyFrames.Count; FStateName.SliceCount = FKeyFrames.Count; FStateEvents.SliceCount = FKeyFrames.Count; FKeyFrames.Sort(delegate(TLBaseKeyFrame k0, TLBaseKeyFrame k1) { return(k0.Time.CompareTo(k1.Time)); }); for (int i = 0; i < FKeyFrames.Count; i++) { FStateTime.SetValue(i, FKeyFrames[i].Time); FStateName.SetString(i, (FKeyFrames[i] as TLStateKeyFrame).Name); FStateEvents.SetString(i, (FKeyFrames[i] as TLStateKeyFrame).EventsAsString); } }
public override void Evaluate(double CurrentTime) { base.Evaluate(CurrentTime); TLBaseKeyFrame kf = FKeyFrames.FindLast(delegate(TLBaseKeyFrame k) { return(k.Time <= CurrentTime); }); if (kf == null) { FOutput = ""; } else { FOutput = (kf as TLStringKeyFrame).Value; } OutputAsString = FOutput; }
public override void SaveKeyFrames() { FKeyTime.SliceCount = FKeyFrames.Count; FKeyValue.SliceCount = FKeyFrames.Count; FKeyInType.SliceCount = FKeyFrames.Count; FKeyOutType.SliceCount = FKeyFrames.Count; FKeyFrames.Sort(delegate(TLBaseKeyFrame k0, TLBaseKeyFrame k1) { return(k0.Time.CompareTo(k1.Time)); }); for (int i = 0; i < FKeyFrames.Count; i++) { FKeyTime.SetValue(i, FKeyFrames[i].Time); FKeyValue.SetValue(i, (FKeyFrames[i] as TLValueKeyFrame).Value); FKeyInType.SetValue(i, (int)(FKeyFrames[i] as TLValueKeyFrame).InType); FKeyOutType.SetValue(i, (int)(FKeyFrames[i] as TLValueKeyFrame).OutType); } }
public override void Evaluate(double CurrentTime) { base.Evaluate(CurrentTime); double t; TLBaseKeyFrame kf = FKeyFrames.FindLast(delegate(TLBaseKeyFrame k) { return(k.Time <= CurrentTime); }); TLBaseKeyFrame kf1 = FKeyFrames.Find(delegate(TLBaseKeyFrame k) { return(k.Time >= CurrentTime); }); if (kf == null && kf1 == null) { FOutput = 0; } else if (kf == null) { FOutput = (kf1 as TLValueKeyFrame).Value; } else if (kf1 == null) { FOutput = (kf as TLValueKeyFrame).Value; } else { if ((kf as TLValueKeyFrame).OutType == TLInterpolationType.Step) { FOutput = (kf as TLValueKeyFrame).Value; } else if ((kf as TLValueKeyFrame).OutType == TLInterpolationType.Linear) { // LINEAR INTERPOLATION t = VMath.Map(CurrentTime, kf.Time, kf1.Time, 0, 1, TMapMode.Float); FOutput = VMath.Lerp((kf as TLValueKeyFrame).Value, (kf1 as TLValueKeyFrame).Value, t); } else if ((kf as TLValueKeyFrame).OutType == TLInterpolationType.Cubic) { // CUBIC INTERPOLATION t = VMath.Map(CurrentTime, kf.Time, kf1.Time, 0, 1, TMapMode.Float); FOutput = VMath.SolveCubic(t, (kf as TLValueKeyFrame).Value, (kf as TLValueKeyFrame).Value, (kf1 as TLValueKeyFrame).Value, (kf1 as TLValueKeyFrame).Value); } //spline here } OutputAsString = FOutput.ToString("f4", TimelinerPlugin.GNumberFormat); }
public override void Configurate(IPluginConfig Input, bool FirstFrame) { //if Input = last ConfigInput created! if (Input == FKeyColor && FirstFrame) { FKeyFrames.Clear(); RGBAColor c; double time; for (int i = 0; i < FKeyColor.SliceCount; i++) { FKeyTime.GetValue(i, out time); FKeyColor.GetColor(i, out c); AddKeyFrame(time, c); } FKeyFrames.Sort(delegate(TLBaseKeyFrame k0, TLBaseKeyFrame k1) { return(k0.Time.CompareTo(k1.Time)); }); } base.Configurate(Input, FirstFrame); }
public override void Configurate(IPluginConfig Input, bool FirstFrame) { //if Input = last ConfigInput created! if (Input == FKeyOutType && FirstFrame) { FKeyFrames.Clear(); //System.Windows.Forms.MessageBox.Show("FKeyOutType: " + FKeyOutType.SliceCount.ToString()); double time, val, intype, outtype; for (int i = 0; i < FKeyOutType.SliceCount; i++) { FKeyTime.GetValue(i, out time); FKeyValue.GetValue(i, out val); FKeyInType.GetValue(i, out intype); FKeyOutType.GetValue(i, out outtype); AddKeyFrame(time, val, (TLInterpolationType)intype, (TLInterpolationType)outtype); } FKeyFrames.Sort(delegate(TLBaseKeyFrame k0, TLBaseKeyFrame k1) { return(k0.Time.CompareTo(k1.Time)); }); } base.Configurate(Input, FirstFrame); }
public override void Configurate(IPluginConfig Input, bool FirstFrame) { //if Input = last ConfigInput created! if (Input == FKeyValue && FirstFrame) { FKeyFrames.Clear(); double time, flag; string val; for (int i = 0; i < FKeyValue.SliceCount; i++) { FKeyTime.GetValue(i, out time); FKeyFlagY.GetValue(i, out flag); FKeyValue.GetString(i, out val); AddKeyFrame(time, (float)flag, val); } FKeyFrames.Sort(delegate(TLBaseKeyFrame k0, TLBaseKeyFrame k1) { return(k0.Time.CompareTo(k1.Time)); }); } base.Configurate(Input, FirstFrame); }
public override void DestroyPins() { FKeyFrames.Clear(); }
public override void Evaluate(double CurrentTime) { base.Evaluate(CurrentTime); if (FKeyFrames.Count == 0) { FOutput = VColor.Black; } else { TLColorKeyFrame from = (TLColorKeyFrame)FKeyFrames.FindLast(delegate(TLBaseKeyFrame k) { return(k.Time <= CurrentTime); }); TLColorKeyFrame to = (TLColorKeyFrame)FKeyFrames.Find(delegate(TLBaseKeyFrame k) { return(k.Time > CurrentTime); }); if (from == null) { from = to; } if (to == null) { to = from; } /* * * int a1, r1, g1, b1, a2, r2, g2, b2; * a1 = from.Color.A; * a2 = to.Color.A; * r1 = from.Color.R; * r2 = to.Color.R; * g1 = from.Color.G; * g2 = to.Color.G; * b1 = from.Color.B; * b2 = to.Color.B; * * double tSpan, f, tCurrent; * tSpan = to.Time - from.Time; * tCurrent = CurrentTime - from.Time; * * if (tSpan == 0) * f = 0; * else * f = tCurrent / tSpan; * * ; * * int a, r, g, b; * * a = (int) Math.Round(a2 * f + a1 * (1-f)); * r = (int) Math.Round(r2 * f + r1 * (1-f)); * g = (int) Math.Round(g2 * f + g1 * (1-f)); * b = (int) Math.Round(b2 * f + b1 * (1-f)); */ double tSpan, f, tCurrent; tSpan = to.Time - from.Time; tCurrent = CurrentTime - from.Time; if (tSpan == 0) { f = 0; } else { f = tCurrent / tSpan; } FOutput = VColor.LerpRGBA(from.RGBAColor, to.RGBAColor, f); } double h, s, v, a; VColor.RGBtoHSV(FOutput.R, FOutput.G, FOutput.B, out h, out s, out v); a = FOutput.A; OutputAsString = "H: " + h.ToString("f2") + " S: " + s.ToString("f2") + " V: " + v.ToString("f2") + " A: " + a.ToString("f2"); }
public void ForceStateFromCurrentTime(double CurrentTime) { FCurrentState = (FKeyFrames.Find(delegate(TLBaseKeyFrame s) { return(s.Time > CurrentTime); }) as TLStateKeyFrame); }
public override void Configurate(IPluginConfig Input, bool FirstFrame) { //if Input = last ConfigInput created! if (Input == FStateEvents && FirstFrame) { FKeyFrames.Clear(); string name, events; double time; for (int i = 0; i < FStateEvents.SliceCount; i++) { FStateTime.GetValue(i, out time); FStateName.GetString(i, out name); FStateEvents.GetString(i, out events); AddKeyFrame(name, time, events); } FKeyFrames.Sort(delegate(TLBaseKeyFrame k0, TLBaseKeyFrame k1) { return(k0.Time.CompareTo(k1.Time)); }); } //make sure every state's events have according input-pins //remove all inputs that don't have an according event //go through all events and find a corresponding pin List <IValueFastIn> tmpList = new List <IValueFastIn>(); IValueFastIn tmpEventPin; foreach (TLStateKeyFrame skf in FKeyFrames) { foreach (TLEvent e in skf.Events) { if (e.Name != "OnEnd") { IValueFastIn ep = FEventPins.Find(delegate(IValueFastIn p) { return(p.Name == e.Name); }); if (ep == null) { FHost.CreateValueFastInput(e.Name, 1, null, TSliceMode.Single, TPinVisibility.True, out tmpEventPin); tmpEventPin.SetSubType(0, 1, 1, 0, false, false, false); e.EventPin = tmpEventPin; tmpList.Add(tmpEventPin); FEventPins.Add(tmpEventPin); } else { e.EventPin = ep; if (!tmpList.Contains(ep)) { tmpList.Add(ep); } } } } } for (int i = 0; i < FEventPins.Count; i++) { if (!tmpList.Contains(FEventPins[i])) { FHost.DeletePin(FEventPins[i]); } } FEventPins.Clear(); FEventPins.AddRange(tmpList); }