Export (0) Print
Expand All

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

Builds a perspective projection matrix based on a field of view and returns by value.

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

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

Parameters

fieldOfView
Type: Single
Field of view in the y direction, in radians.
aspectRatio
Type: Single

Aspect ratio, defined as view space width divided by height.

To match the aspect ratio of the viewport, the property AspectRatio.

nearPlaneDistance
Type: Single
Distance to the near view plane.
farPlaneDistance
Type: Single
Distance to the far view plane.

Return Value

The perspective projection matrix.

Exception typeCondition
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 is larger than farPlaneDistance. nearPlaneDistance must be smaller than farPlaneDistance.

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.

To obtain the viewable area (in world space) of a scene, create a BoundingFrustum and pass the combined view and projection matrix to the constructor.

Xbox 360, Windows 7, Windows Vista, Windows XP, Windows Phone

Community Additions

ADD
Show:
© 2014 Microsoft