public void AddKey(float time, ref Vector3 vp, ref Quaternion vr, ref Vector3 vs, GOECurvInterpolationType pt = GOECurvInterpolationType.Linear, GOECurvInterpolationType rt = GOECurvInterpolationType.Linear, GOECurvInterpolationType st = GOECurvInterpolationType.Linear) { GOECurvKeyFrame kf = new GOECurvKeyFrame(); kf.Time = time; kf.Position = vp; kf.Rotation = vr; kf.Scale = vs; kf.PositionInterpolationType = pt; kf.RotationInterpolationType = rt; kf.ScaleInterpolationType = st; int left, right; GOECurveFindIndexResults b = FindIndexByTime(time, out left, out right); if (b == GOECurveFindIndexResults.AfterAllKeyFrame || b == GOECurveFindIndexResults.FailedNoKeyFrame) { keyFrames.Add(kf); } else if (b == GOECurveFindIndexResults.BeforeAllKeyFrame) { KeyFrames.Insert(0, kf); } else { keyFrames.Insert(left + 1, kf); } if (EditorGameObject) { kf.EnsureEditorGO(EditorGameObject); UnityEditor.Selection.activeGameObject = kf.EditorGameObject; } }
public void InsertKey(float frame, float value) { if (!KeyFrames.Any(x => x.Frame == frame)) { KeyFrames.Add(new STKeyFrame(frame, value)); } }
private void ReadUncompressedKeyFrames(BinaryReader reader) { var keyFrameByOffsetMap = new Dictionary <int, RwKeyFrame>(); for (int i = 0; i < KeyFrames.Capacity; i++) { var keyFrame = new RwKeyFrame { Time = reader.ReadSingle(), Rotation = new Quaternion(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()), Translation = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()) }; int previousKeyFrameOffset = reader.ReadInt32(); if (keyFrame.Time != 0.0f) { keyFrame.Previous = keyFrameByOffsetMap[previousKeyFrameOffset]; } keyFrameByOffsetMap[i * UNCOMPRESSED_KEYFRAME_SIZE] = keyFrame; KeyFrames.Add(keyFrame); } }
private float GetWrapFrame(float frame) { var lastFrame = KeyFrames.Last().Frame; if (WrapMode == STLoopMode.Clamp) { if (frame > lastFrame) { return(lastFrame); } else { return(frame); } } else if (WrapMode == STLoopMode.Repeat) { while (frame > lastFrame) { frame -= lastFrame; } return(frame); } return(frame); }
private void PrepareKeyFrames() { if (_fromKeyFrame != null) { KeyFrames.Remove(_fromKeyFrame); } if (_toKeyFrame != null) { KeyFrames.Remove(_toKeyFrame); } if (!IsValueNull(From)) { _fromKeyFrame = new TKeyFrame(); _fromKeyFrame.Key = 0f; _fromKeyFrame.Value = From; KeyFrames.Add(_fromKeyFrame); } if (!IsValueNull(To)) { _toKeyFrame = new TKeyFrame(); _toKeyFrame.Key = 1f; _toKeyFrame.Value = To; KeyFrames.Add(_toKeyFrame); } }
public void AnimationAnimateBetweenWithStartTimeAndEndTime() { tlog.Debug(tag, $"AnimationAnimateBetweenWithStartTimeAndEndTime START"); View view = new View() { Opacity = 0.0f }; var keyFrames = new KeyFrames(); Assert.IsNotNull(keyFrames, "should be not null"); Assert.IsInstanceOf <KeyFrames>(keyFrames, "should be an instance of Animation class!"); keyFrames.Add(0.0f, 1.0f); var testingTarget = new Animation(600); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <Animation>(testingTarget, "should be an instance of Animation class!"); testingTarget.EndAction = Animation.EndActions.StopFinal; testingTarget.AnimateBetween(view, "Opacity", keyFrames, 0, 600); testingTarget.Dispose(); keyFrames.Dispose(); view.Dispose(); tlog.Debug(tag, $"AnimationAnimateBetweenWithStartTimeAndEndTime END (OK)"); }
protected void PrepareKeyFrames() { if (FromKeyFrame != null) { KeyFrames.Remove(FromKeyFrame); } if (ToKeyFrame != null) { KeyFrames.Remove(ToKeyFrame); } if (!IsValueNull(From)) { FromKeyFrame = new T(); FromKeyFrame.Key = 0f; FromKeyFrame.Value = From; KeyFrames.Add(FromKeyFrame); } if (!IsValueNull(To)) { ToKeyFrame = new T(); ToKeyFrame.Key = 1f; ToKeyFrame.Value = To; KeyFrames.Add(ToKeyFrame); } }
public void KeyFramesAddWithObjectAndAlphaFunc() { tlog.Debug(tag, $"KeyFramesAddWithObjectAndAlphaFunc START"); var testingTarget = new KeyFrames(); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <KeyFrames>(testingTarget, "should be an instance of KeyFrames class!"); Position pos = new Position(10.0f, 20.0f, 30.0f); AlphaFunction linear = new AlphaFunction(AlphaFunction.BuiltinFunctions.Linear); try { testingTarget.Add(0.3f, pos, linear); Assert.IsTrue("Vector3" == testingTarget.GetType().ToString()); } catch (Exception e) { tlog.Error(tag, "Caught Exception" + e.ToString()); LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString()); Assert.Fail("Caught Exception" + e.ToString()); } pos.Dispose(); linear.Dispose(); testingTarget.Dispose(); tlog.Debug(tag, $"KeyFramesAddWithObjectAndAlphaFunc END (OK)"); }
public void KeyFramesAddWithPropertyValueAndAlphaFunc() { tlog.Debug(tag, $"KeyFramesAddWithPropertyValueAndAlphaFunc START"); var testingTarget = new KeyFrames(); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <KeyFrames>(testingTarget, "should be an instance of KeyFrames class!"); PropertyValue dummy = new PropertyValue(true); AlphaFunction ease = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOut); try { testingTarget.Add(0.3f, dummy, ease); Assert.IsTrue("Boolean" == testingTarget.GetType().ToString()); } catch (Exception e) { tlog.Error(tag, "Caught Exception" + e.ToString()); LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Caught Exception" + e.ToString()); Assert.Fail("Caught Exception" + e.ToString()); } dummy.Dispose(); ease.Dispose(); testingTarget.Dispose(); tlog.Debug(tag, $"KeyFramesAddWithPropertyValueAndAlphaFunc END (OK)"); }
public void LoadKeyFrames(List <KeyFrame> keyFrames) { for (int i = 0; i < keyFrames?.Count; i++) { KeyFrames.Add(new LytKeyFrame(keyFrames[i])); } }
public override void Animate(int time) { if (KeyFrames.Count() <= 1) { return; } AnimationFrame animationFrame = AnimationFrameForTime(time) as AnimationFrame; // Store the current transform // Point tempTransform = new Point(View.X, View.Y); // Reset rotation to 0 to avoid warping //View.Transform = CGAffineTransform.MakeRotation(0); // View.Rotation = 0; View.SetX(Convert.ToSingle(animationFrame.Frame.X)); View.SetY(Convert.ToSingle(animationFrame.Frame.Y)); // AnimView.LayoutParameters = new ViewGroup.LayoutParams(Convert.ToInt32(animationFrame.Frame.Width), Convert.ToInt32(animationFrame.Frame.Height)); Console.WriteLine(string.Format("View: {0} X: {1} Y {2}", View.ToString(), View.GetX(), View.GetY())); // Return to original transform // View.X = tempTransform.X; // View.Y = tempTransform.Y; }
private static PointKeyFrame CreatePointKeyFrmas(KeyFrames <Point> Model) { PointKeyFrame frame = null; switch (Model.Type) { case KeyFramesType.Spline: frame = new SplinePointKeyFrame() { KeySpline = Model.Spline }; break; case KeyFramesType.Linear: frame = new LinearPointKeyFrame(); break; case KeyFramesType.Easing: frame = new EasingPointKeyFrame() { EasingFunction = Model.EasingFunction }; break; case KeyFramesType.Discrete: frame = new DiscretePointKeyFrame(); break; default: break; } frame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(Model.KeyTime)); frame.Value = Model.Value; return(frame); }
internal void InitPost() { if (FrameCount > 0) { KeyFrames.AddPropertyKeyFrame(new VmdPropertyFrameData(0, false)); KeyFrames.AddPropertyKeyFrame(new VmdPropertyFrameData(FrameCount, true)); } }
public override void Animate(int time) { if (KeyFrames.Count() <= 1) { return; } AnimationFrame animationFrame = AnimationFrameForTime(time) as AnimationFrame; //AnimView.Rotation=animationFrame.Angle; }
/// <summary> /// Adds a frame /// </summary> /// <param name="frame">KeyFrame to add</param> public void AddKeyFrame(KeyFrame frame) { if (frame == null) { return; } KeyFrames.Add(frame); KeyFrames.Sort(); }
public override void Animate(int time) { if (KeyFrames.Count() <= 1) { return; } var animationFrame = AnimationFrameForTime(time); View.Transform = CGAffineTransform.MakeRotation(animationFrame.Angle); }
protected virtual void AddChild(object child) { if (child is GeometryKeyFrame keyFrame) { KeyFrames.Add(keyFrame); } else { throw new ArgumentException("Animation_ChildMustBeKeyFrame", nameof(child)); } }
public override void Animate(int time) { if (KeyFrames.Count() <= 1) { return; } var animationFrame = AnimationFrameForTime(time); View.Alpha = animationFrame.Alpha; }
public override void Animate(int time) { if (KeyFrames.Count() <= 1) { return; } AnimationFrame animationFrame = AnimationFrameForTime(time) as AnimationFrame; View.BackgroundColor = animationFrame.Color; }
public void KeyFramesConstructor() { tlog.Debug(tag, $"KeyFramesConstructor START"); var testingTarget = new KeyFrames(); Assert.IsNotNull(testingTarget, "should be not null"); Assert.IsInstanceOf <KeyFrames>(testingTarget, "should be an instance of KeyFrames class!"); testingTarget.Dispose(); tlog.Debug(tag, $"KeyFramesConstructor END (OK)"); }
protected virtual void AddChild(object child) { var keyFrame = child as KeyFrame <T>; if (keyFrame == null) { throw new ArgumentException( string.Format(CultureInfo.CurrentCulture, SR.KeyFramesAnimationBase_ChildNotKeyFrame, typeof(T).Name), "child"); } KeyFrames.Add(keyFrame); }
/// <summary> /// Removes a KeyFrame /// </summary> /// <param name="frame"></param> public void RemoveKeyFrame(KeyFrame frame) { if (frame == null) { return; } if (KeyFrames.Contains(frame)) { KeyFrames.Remove(frame); } }
internal void Export() { EntityList.ForEach(e => e.OnDeath()); PmxModel.FinalizeModel(); KeyFrames.Finish(); KeyFrames.Export(); PmxModel.Export(); OnExport(EventArgs.Empty); }
/// <summary> /// Retorna o estado de rastreamento do gesto atual /// </summary> /// <param name="esqueletoUsuario"></param> /// <returns></returns> public override TrackState Track(Skeleton esqueletoUsuario) { if (esqueletoUsuario == null) { RestartTracker(); } if (ValidPosition(esqueletoUsuario)) { Estado = TrackState.EM_EXECUCAO; if (CurrentKeyFrame.Value == KeyFrames.Last.Value) { Estado = TrackState.IDENTIFICADO; } else { if (FrameCounter >= CurrentKeyFrame.Value.QuadroLimiteInferior && FrameCounter <= CurrentKeyFrame.Value.QuadroLimiteSuperior) { NextKeyFrame(); } else if (FrameCounter < CurrentKeyFrame.Value.QuadroLimiteInferior) { Tracking(); } else if (FrameCounter > CurrentKeyFrame.Value.QuadroLimiteSuperior) { RestartTracker(); } } } else if (CurrentKeyFrame.Value.QuadroLimiteSuperior < FrameCounter) { RestartTracker(); } else { Tracking(); } var index = KeyFrames.TakeWhile(n => n != CurrentKeyFrame.Value).Count(); ConsoleLog.WriteLog("(" + index + ")" + CurrentKeyFrame.Value.PoseChave.ToString() + " / " + Estado + " / " + FrameCounter, ConsoleStatesEnum.NOTICE); return(Estado); }
public Dictionary <string, SpriteJson> GetCurrentSprite() { Dictionary <string, SpriteJson> currentSprite = new Dictionary <string, SpriteJson>(); int closestKeyframeTo = -1; int closestKeyframeDistance = -1; if (KeyFrames.Count > 0) { for (int i = 0; i < KeyFrames.Count; i++) { int scrubberPos = (int)Math.Floor(_currentMs / 16); KeyFrame currentFrame = KeyFrames.ElementAt(i); bool isValid = true; if (currentFrame.TimelineX > scrubberPos) { isValid = false; } if (isValid) { if (closestKeyframeDistance == -1) { closestKeyframeDistance = Math.Abs(scrubberPos - KeyFrames.ElementAt(i).TimelineX); closestKeyframeTo = i; } else { if (Math.Abs(scrubberPos - KeyFrames.ElementAt(i).TimelineX) < closestKeyframeDistance) { closestKeyframeDistance = Math.Abs(scrubberPos - KeyFrames.ElementAt(i).TimelineX); closestKeyframeTo = i; } } } } } if (closestKeyframeTo >= 0 && KeyFrames.Count > 0) { KeyFrame originalKeyframe = KeyFrames.ElementAt(closestKeyframeTo); return(originalKeyframe.SpriteBoxes); } else { return(null); } }
protected virtual void AddChild(object child) { ColorKeyFrame keyFrame = child as ColorKeyFrame; if (keyFrame != null) { KeyFrames.Add(keyFrame); } else { throw new ArgumentException(SR.Get(SRID.Animation_ChildMustBeKeyFrame), "child"); } }
/// <summary> /// Returns a <see cref="Brush"/> which serves as a zero-value for an additive animation. /// The exact type of the brush is dependent on the first key frame in the animation. /// </summary> /// <returns>A new <see cref="Brush"/> which serves as a zero-value.</returns> protected override sealed Brush GetZeroValue() { if (KeyFrames.Count == 0) { throw new InvalidOperationException( "Creating a zero-brush requires at least one registered key frame."); } var firstFrame = KeyFrames.First(); var brushType = firstFrame.Value.GetType(); return(BrushAnimationHelper.Instance.GetZeroValue()); }
public override void Animate(int time) { if (KeyFrames.Count() <= 1) { return; } AnimationFrame aFrame = (AnimationFrame)AnimationFrameForTime(time); if (aFrame.Transform == null) { return; } CATransform3D transform = CATransform3D.Identity; transform.m34 = aFrame.Transform.M34; transform = CATransform3D.MakeRotation( aFrame.Transform.Rotate.Angle, aFrame.Transform.Rotate.X, aFrame.Transform.Rotate.Y, aFrame.Transform.Rotate.Z); // Scale transform.m11 = aFrame.Transform.Scale.Sx; transform.m22 = aFrame.Transform.Scale.Sy; transform.m33 = aFrame.Transform.Scale.Sz; // Translate transform.m41 = aFrame.Transform.Translate.Tx; transform.m42 = aFrame.Transform.Translate.Ty; transform.m43 = aFrame.Transform.Translate.Tz; // transform.Rotate ( // aFrame.Transform.Rotate.Angle, // aFrame.Transform.Rotate.X, // aFrame.Transform.Rotate.Y, // aFrame.Transform.Rotate.Z); // transform.Scale ( // aFrame.Transform.Scale.Sx, // aFrame.Transform.Scale.Sy, // aFrame.Transform.Scale.Sz); // // transform.Translate ( // aFrame.Transform.Translate.Tx, // aFrame.Transform.Translate.Ty, // aFrame.Transform.Translate.Tz); this.View.Layer.Transform = transform; }
public override void OnControlStateChanged(Button button, View.ControlStateChangedEventArgs args) { if (button.ControlState != ControlState.Pressed) { return; } var overlayImage = button.OverlayImage; if (overlayImage == null) { return; } if (null == PressAnimation) { var keyFrames = new KeyFrames(); keyFrames.Add(0.0f, 0.0f); AlphaFunction linear = new AlphaFunction(AlphaFunction.BuiltinFunctions.Linear); keyFrames.Add(0.25f, 1.0f, linear); linear.Dispose(); AlphaFunction ease = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOut); keyFrames.Add(1.0f, 0.0f, ease); ease.Dispose(); PressAnimation = new Animation(600); PressAnimation.EndAction = Animation.EndActions.StopFinal; PressAnimation.AnimateBetween(overlayImage, "Opacity", keyFrames); keyFrames.Dispose(); Vector3 vec = new Vector3(1, 1, 1); AlphaFunction easeout = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOut); PressAnimation.AnimateTo(overlayImage, "Scale", vec, 0, 600, easeout); vec.Dispose(); easeout.Dispose(); } if (PressAnimation.State == Animation.States.Playing) { PressAnimation.Stop(); overlayImage.Hide(); } overlayImage.Opacity = 0.0f; overlayImage.CornerRadius = button.CornerRadius; overlayImage.Background = button.Background; overlayImage.Size = button.Size; overlayImage.Scale = new Vector3(0.80f, 0.80f, 1); overlayImage.Show(); PressAnimation.Play(); }
internal Animatable <T> CloneWithSelectedValue(Func <T, T> selector) { if (IsAnimated) { var keyframes = from kf in KeyFrames.ToArray() select new KeyFrame <T>(kf.Frame, selector(kf.Value), kf.Easing); return(new Animatable <T>(keyframes, PropertyIndex)); } else { return(new Animatable <T>(selector(InitialValue), PropertyIndex)); } }
private static DoubleKeyFrame CreateDoubleKeyFrmas(KeyFrames<double> Model) { DoubleKeyFrame frame = null; switch (Model.Type) { case KeyFramesType.Spline: frame = new SplineDoubleKeyFrame() { KeySpline = Model.Spline }; break; case KeyFramesType.Linear: frame = new LinearDoubleKeyFrame(); break; case KeyFramesType.Easing: frame = new EasingDoubleKeyFrame() { EasingFunction = Model.EasingFunction }; break; case KeyFramesType.Discrete: frame = new DiscreteDoubleKeyFrame(); break; default: break; } frame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(Model.KeyTime)); frame.Value = Model.Value; return frame; }
private static ObjectKeyFrame CreateColorKeyFrmas(KeyFrames<Object> Model) { ObjectKeyFrame frame = null; switch (Model.Type) { case KeyFramesType.Spline: break; case KeyFramesType.Linear: break; case KeyFramesType.Easing: break; case KeyFramesType.Discrete: frame = new DiscreteObjectKeyFrame(); break; default: break; } frame.KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(Model.KeyTime)); frame.Value = Model.Value; return frame; }