Partager via


Transforms.Projection Property (Microsoft.DirectX.Direct3D)

How Do I...?

  • Set Up a Projection Matrix

Retrieves or sets the projection transformation Matrix.

Definition

Visual Basic Public Property Projection As Matrix
C# public Matrix Projection { get; set; }
C++ public:
property Matrix Projection {
        Matrix get();
        void set(Matrix value);
}
JScript public function get Projection() : Matrix
public function set Projection(Matrix);

Property Value

Microsoft.DirectX.Matrix

This property is read/write. 

Remarks

The default projection transformation Matrix is the identity Matrix.

How Do I...?

Set Up a Projection Matrix

This example demonstrates how to set up the projection transformation matrix, which transforms 3-D camera or view space coordinates into 2-D screen coordinates.

See the following C# code example, the Projection transformation matrix is set to be equal to the left-handed (LH) PerspectiveFovLH matrix. Input arguments to PerspectiveFovLH are as follows.

  1. Field of view in radians: pi/4.
  2. Aspect ratio, or view-space height divided by width: 1, for a square window.
  3. Near clipping plane distance: 1 unit.
  4. Far clipping plane distance: 100 units.
              [C#]
              

using Microsoft.DirectX;

Direct3D.Device device = null;  // Create rendering device.

// For the projection matrix, you set up a perspective transform (which
//   transforms geometry from 3-D view space to 2-D viewport space, with
//   a perspective divide making objects smaller in the distance). To build
//   a perspective transform, you need the field of view (1/4 pi is common),
//   the aspect ratio, and the near and far clipping planes (which define 
//   the distances at which geometry should no longer be rendered).

device.Transform.Projection = Matrix.PerspectiveFovLH(
                              (float)Math.PI / 4, 1.0f, 1.0f, 100.0f );

See Also