/// <summary>
        /// Animate the camera's view matrix from its current value when the activity
        /// starts to the new destination matrix value.
        /// </summary>
        /// <param name="aCamera">The camera whose view matrix will be animated.</param>
        /// <param name="aMatrix">The final matrix value.</param>
        /// <param name="duration">
        /// The amount of time that the animation should take.
        /// </param>
        /// <returns>
        /// The newly scheduled activity, if the duration is greater than 0; else null.
        /// </returns>
        protected virtual PActivity AnimateCameraViewMatrixTo(PCamera aCamera, PMatrix aMatrix, int duration)
        {
            bool wasOldAnimation = false;

            // first stop any old animations.
            if (navigationActivity != null)
            {
                navigationActivity.Terminate();
                wasOldAnimation = true;
            }

            if (duration == 0)
            {
                aCamera.ViewMatrix = aMatrix;
                return(null);
            }

            PMatrix source = aCamera.ViewMatrixReference;

            if (!source.MatrixReference.Equals(aMatrix.MatrixReference))
            {
                navigationActivity = aCamera.AnimateViewToMatrix(aMatrix, duration);
                ((PTransformActivity)navigationActivity).SlowInSlowOut = !wasOldAnimation;
                return(navigationActivity);
            }

            return(null);
        }