RenderWare V2.1

Previous Page Index Next Page

Matrices


RenderWare uses 4 x 4 homogeneous matrices to represent 3D transformations. Rotation and scaling are encoded in the top-left 3 x 3 sub-matrix, and translation in the final row:

Undisplayed Graphic

Such matrices are available to the application programmer through the opaque data type RwMatrix4d.

In addition to various high-level matrix operations (such as multiplication) the elements of a matrix can be set or retrieved either individually or as a whole. For example, the API function RwGetMatrixElements() copies the elements of a matrix into a 4 x 4 array of real numbers:

RwMatrix4d *matrix;
RwReal elements[4][4];

matrix = RwCreateMatrix();
RwGetMatrixElements(matrix, elements);

The first index of the elements array is the row number and the second is the column number. Thus, the X, Y and Z values of the translation component of matrix are elements[3][0], elements[3][1] and elements[3][2] respectively.