Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CameraSetting"/> class.
        /// </summary>
        /// <param name="camera">
        /// The camera.
        /// </param>
        public CameraSetting(ProjectionCamera camera)
        {
            this.Position          = camera.Position;
            this.LookDirection     = camera.LookDirection;
            this.UpDirection       = camera.UpDirection;
            this.NearPlaneDistance = camera.NearPlaneDistance;
            this.FarPlaneDistance  = camera.FarPlaneDistance;
            var pcamera = camera as PerspectiveCamera;

            if (pcamera != null)
            {
                this.FieldOfView = pcamera.FieldOfView;
            }
            else
            {
                this.FieldOfView = 45;
            }

            var ocamera = camera as OrthographicCamera;

            if (ocamera != null)
            {
                this.Width = ocamera.Width;
            }
            else
            {
                this.Width = 100;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Changes the direction of a camera.
        /// </summary>
        /// <param name="camera">
        /// The camera.
        /// </param>
        /// <param name="newLookDir">
        /// 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 newLookDir, Vector3D newUpDirection, double animationTime)
        {
            var    target = camera.Position + camera.LookDirection;
            double length = camera.LookDirection.Length;

            newLookDir.Normalize();
            LookAt(camera, target, newLookDir * length, newUpDirection, animationTime);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Sets the properties of the specified camera to the settings stored in this object.
        /// </summary>
        /// <param name="camera">
        /// The camera.
        /// </param>
        public void UpdateCamera(ProjectionCamera camera)
        {
            camera.Position = this.Position;
            camera.LookDirection = this.LookDirection;
            camera.UpDirection = this.UpDirection;
            camera.NearPlaneDistance = this.NearPlaneDistance;
            camera.FarPlaneDistance = this.FarPlaneDistance;
            var perspectiveCamera = camera as PerspectiveCamera;
            if (perspectiveCamera != null)
            {
                perspectiveCamera.FieldOfView = this.FieldOfView;
            }

            var orthographicCamera = camera as OrthographicCamera;
            if (orthographicCamera != null)
            {
                orthographicCamera.Width = this.Width;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CameraSetting"/> class.
        /// </summary>
        /// <param name="camera">
        /// The camera.
        /// </param>
        public CameraSetting(ProjectionCamera camera)
        {
            this.Position = camera.Position;
            this.LookDirection = camera.LookDirection;
            this.UpDirection = camera.UpDirection;
            this.NearPlaneDistance = camera.NearPlaneDistance;
            this.FarPlaneDistance = camera.FarPlaneDistance;
            var pcamera = camera as PerspectiveCamera;
            if (pcamera != null)
            {
                this.FieldOfView = pcamera.FieldOfView;
            }

            var ocamera = camera as OrthographicCamera;
            if (ocamera != null)
            {
                this.Width = ocamera.Width;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Sets the properties of the specified camera to the settings stored in this object.
        /// </summary>
        /// <param name="camera">
        /// The camera.
        /// </param>
        public void UpdateCamera(ProjectionCamera camera)
        {
            camera.Position          = this.Position;
            camera.LookDirection     = this.LookDirection;
            camera.UpDirection       = this.UpDirection;
            camera.NearPlaneDistance = this.NearPlaneDistance;
            camera.FarPlaneDistance  = this.FarPlaneDistance;
            var perspectiveCamera = camera as PerspectiveCamera;

            if (perspectiveCamera != null)
            {
                perspectiveCamera.FieldOfView = this.FieldOfView;
            }

            var orthographicCamera = camera as OrthographicCamera;

            if (orthographicCamera != null)
            {
                orthographicCamera.Width = this.Width;
            }
        }