Copy the direction of the source Camera - CSharp System.Windows.Media.Media3D

CSharp examples for System.Windows.Media.Media3D:PerspectiveCamera

Description

Copy the direction of the source Camera

Demo Code

//   http://helixtoolkit.codeplex.com, license: MIT
using System.Windows.Media.Media3D;
using System.Windows.Media.Animation;
using System.Windows.Controls;
using System.Windows;
using System.Text;
using System.Globalization;
using System;//from   ww  w  .  j a v  a 2s. co m

public class Main{
        /// <summary>
        /// Copy the direction of the source <see cref="Camera"/>. Used for the CoordinateSystem view.
        /// </summary>
        /// <param name="source">
        /// The source camera.
        /// </param>
        /// <param name="dest">
        /// The destination camera.
        /// </param>
        /// <param name="distance">
        /// New length of the LookDirection vector.
        /// </param>
        public static void CopyDirectionOnly(this ProjectionCamera source, ProjectionCamera dest, double distance)
        {
            if (source == null || dest == null)
            {
                return;
            }

            Vector3D dir = source.LookDirection;
            dir.Normalize();
            dir *= distance;

            dest.LookDirection = dir;
            dest.Position = new Point3D(-dest.LookDirection.X, -dest.LookDirection.Y, -dest.LookDirection.Z);
            dest.UpDirection = source.UpDirection;
        }
}

Related Tutorials