Exemplo n.º 1
0
        private void AnimateAxes(AnimationContext context)
        {
            double from;
            double to;

            PerspectiveAnimationAxis axes = this.Axes;
            double duration = this.Duration.TimeSpan.TotalSeconds;

            if ((axes & PerspectiveAnimationAxis.X) == PerspectiveAnimationAxis.X)
            {
                // animate the X-axis
                from = this.StartAngleX;
                to   = this.EndAngleX;
                this.UpdateStartEnd(ref from, ref to);
                context.RotationX(new double[] { 0, from, duration, to });
            }

            if ((axes & PerspectiveAnimationAxis.Y) == PerspectiveAnimationAxis.Y)
            {
                // animate the Y-axis
                from = this.StartAngleY;
                to   = this.EndAngleY;
                this.UpdateStartEnd(ref from, ref to);
                context.RotationY(new double[] { 0, from, duration, to });
            }

            if ((axes & PerspectiveAnimationAxis.Z) == PerspectiveAnimationAxis.Z)
            {
                // animate the Y-axis
                from = this.StartAngleZ;
                to   = this.EndAngleZ;
                this.UpdateStartEnd(ref from, ref to);
                context.RotationZ(new double[] { 0, from, duration, to });
            }
        }
        /// <summary>
        /// Applies already stored (if any) animated values.
        /// </summary>
        /// <param name="info"></param>
        protected internal override void ApplyAnimationValues(PlayAnimationInfo info)
        {
            PlaneProjection projection = info.Target.Projection as PlaneProjection;

            if (projection == null)
            {
                return;
            }

            double direction = this.Direction == PerspectiveAnimationDirection.Clockwise ? -1 : 1;
            double rotation;

            PerspectiveAnimationAxis axes = this.Axes;
            bool autoReverse = this.GetAutoReverse();

            if ((axes & PerspectiveAnimationAxis.X) == PerspectiveAnimationAxis.X)
            {
                rotation             = autoReverse ? this.StartAngleX : this.EndAngleX;
                projection.RotationX = rotation * direction;
            }
            if ((axes & PerspectiveAnimationAxis.Y) == PerspectiveAnimationAxis.Y)
            {
                rotation             = autoReverse ? this.StartAngleY : this.EndAngleY;
                projection.RotationY = rotation * direction;
            }
            if ((axes & PerspectiveAnimationAxis.Z) == PerspectiveAnimationAxis.Z)
            {
                rotation             = autoReverse ? this.StartAngleZ : this.EndAngleZ;
                projection.RotationZ = rotation * direction;
            }
        }