Share via


Matrix.CreatePerspectiveFieldOfView Method (Single, Single, Single, Single, Matrix)

Builds a perspective projection matrix based on a field of view.

Namespace: Microsoft.Xna.Framework
Assembly: Microsoft.Xna.Framework (in microsoft.xna.framework.dll)

Syntax

public static void CreatePerspectiveFieldOfView (
         float fieldOfView,
         float aspectRatio,
         float nearPlaneDistance,
         float farPlaneDistance,
         out Matrix result
)

Parameters

  • fieldOfView
    Field of view in radians.
  • aspectRatio
    Aspect ratio, defined as view space width divided by height.
  • nearPlaneDistance
    Distance to the near view plane.
  • farPlaneDistance
    Distance to the far view plane.
  • result
    [OutAttribute] The perspective projection matrix.

Exceptions

Exception type Condition
ArgumentOutOfRangeException

One of the following conditions is true:

  • fieldOfView is not between 0 and pi (180 degrees). Note that fieldOfView should be specified in radians.
  • nearPlaneDistance or farPlaneDistance is a negative value. Specify a positive value for nearPlaneDistance or farPlaneDistance.
  • nearPlaneDistance larger than farPlaneDistance. nearPlaneDistance must be smaller than farPlaneDistance.

Remarks

Projection space refers to the space after applying projection transformation from view space. After the projection transformation, visible content has x- and y-coordinates ranging from −1 to 1, and a z-coordinate ranging from 0 to 1.

See Also

Tasks

How to: Rotate and Move a Camera
How to: Make a First-Person Camera
How to: Make a Third-Person Camera

Reference

Matrix Structure
Matrix Members
Microsoft.Xna.Framework Namespace

Platforms

Xbox 360, Windows XP SP2, Windows Vista