Пример #1
0
        private void CalculateTransform(IChannel channel, out Transform transform)
        {
            int frameIndex = _channelFrames[channel.BoneIndex];

            //frame which is greater than or equal to the current time
            Keyframe b = channel.BoneTransform(frameIndex);
            if (b.Time == ElapsedTime)
            {
                transform = b.Transform;
                return;
            }

            //Previous frame
            Keyframe a = channel.BoneTransform(frameIndex - 1);

            //Interpolation factor between frames
            var t = (float) ((ElapsedTime.TotalSeconds - a.Time.TotalSeconds) / (b.Time.TotalSeconds - a.Time.TotalSeconds));

            //Convert linear interpolation into some other easing function
            var t2 = PlaybackParameters.Interpolator(t);

            //Linearly interpolate frames
            transform = a.Transform.Interpolate(b.Transform, t2);
        }