Matrix Structure |
Language: |
Describes and manipulates a matrix.
Visual Basic Public Structure Matrix C# public struct Matrix C++ public value class Matrix sealed JScript In JScript, you can use structures, but you cannot define your own.
This structure represents a 4x4 matrix of Single values. The fields of this structure are named with the row number first, then the column number.
In Microsoft Direct3D, the M34 element of a projection matrix cannot be a negative number. If an application needs to use a negative value in this location, it should scale the entire projection matrix by -1 instead.
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.
- Field of view in radians: pi/4.
- Aspect ratio, or view-space height divided by width: 1, for a square window.
- Near clipping plane distance: 1 unit.
- 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 );
Namespace Microsoft.DirectX Assembly Microsoft.DirectX (microsoft.directx.dll) Strong Name Microsoft.DirectX, Version=1.0.900.0, Culture=neutral, PublicKeyToken=d3231b57b74a1492
Send comments about this topic to Microsoft. © Microsoft Corporation. All rights reserved.
Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center