Matrices

A Direct3D matrix is a 4×4 homogenous matrix, as defined by a D3DMATRIX structure. You use Direct3D matrices to define world, view, and projection transformations. Although Direct3D matrices are not standard objects — they are not represented by a COM interface — you can create and set them just as you would any other Direct3D object.

The D3D_OVERLOADS implementation of the D3DMATRIX structure (D3DMATRIX (D3D_OVERLOADS)) implements a parentheses ("()") operator. This operator offers convenient access to values in the matrix for C++ programmers. Instead of having to refer to the structure members by name, C++ programmers can refer to them by row and column number, and simply index these numbers as needed. These indices are zero-based, so for example the element in the third row, second column would be M(2, 1). To use the D3D_OVERLOADS operators, you must define D3D_OVERLOADS before including D3dtypes.h.

You can create a Direct3D matrix by calling the IDirect3DDevice::CreateMatrix method, and you can set the contents of the matrix by calling the IDirect3DDevice::SetMatrix method.

Matrices appear to you only as handles. These handles (defined by the D3DMATRIXHANDLE type) are used in execute buffers and in the D3DOP_MATRIXLOAD and D3DOP_MATRIXMULTIPLY opcodes.