コード例 #1
0
        //-----------------------------------------------------------------------
        public Animation(SkeletalAnimationItem item)
        {
            Timeline             = new AnimationTimeline();
            Timeline.DataContext = this;
            Item = item;

            InterpolatedSkeleton = RecursivelyConvert(Item.RootBone);

            PropertyChanged += (e, args) =>
            {
                item.RaisePropertyChangedEvent(args.PropertyName);
            };

            Timeline.PropertyChanged += (e, args) =>
            {
                if (args.PropertyName == "IndicatorTime")
                {
                    Prev = null;
                    Next = null;

                    if (Keyframes.Count > 0)
                    {
                        if (Timeline.IndicatorTime <= Keyframes.FirstOrDefault().Time)
                        {
                            Prev = Keyframes.FirstOrDefault();
                        }
                        else if (Timeline.IndicatorTime >= Keyframes.LastOrDefault().Time)
                        {
                            Prev = Keyframes.LastOrDefault();
                        }
                        else
                        {
                            foreach (var keyframe in Keyframes)
                            {
                                Prev = Next;
                                Next = keyframe;

                                if (keyframe.Time >= Timeline.IndicatorTime)
                                {
                                    break;
                                }
                            }
                        }
                    }

                    foreach (var bone in InterpolatedSkeleton.Descendants)
                    {
                        bone.InvalidateTransforms();
                    }

                    RaisePropertyChangedEvent("IndicatorTime");
                }
            };
        }