Changes the direction of a camera. - CSharp System.Windows.Media.Media3D

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

Description

Changes the direction of a 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  w w  w . j  ava 2s.  c o m*/

public class Main{
        /// <summary>
        /// Changes the direction of a camera.
        /// </summary>
        /// <param name="camera">
        /// The camera.
        /// </param>
        /// <param name="newLookDirection">
        /// The new look direction.
        /// </param>
        /// <param name="newUpDirection">
        /// The new up direction.
        /// </param>
        /// <param name="animationTime">
        /// The animation time.
        /// </param>
        public static void ChangeDirection(this ProjectionCamera camera, Vector3D newLookDirection, Vector3D newUpDirection, double animationTime)
        {
            var target = camera.Position + camera.LookDirection;
            var length = camera.LookDirection.Length;
            newLookDirection.Normalize();
            LookAt(camera, target, newLookDirection * length, newUpDirection, animationTime);
        }
}

Related Tutorials