KallistiOS
##version##
|
Basic matrix operations. More...
Go to the source code of this file.
Macros | |
#define | mat_trans_single(x, y, z) |
Macro to transform a single vertex by the internal matrix. More... | |
#define | mat_trans_single4(x, y, z, w) |
Macro to transform a single vertex by the internal matrix. More... | |
#define | mat_trans_single3(x, y, z) |
Macro to transform a single vertex by the internal matrix. More... | |
#define | mat_trans_nodiv(x, y, z, w) |
Macro to transform a single vertex by the internal matrix with no perspective division. More... | |
#define | mat_trans_single3_nodiv(x, y, z) |
Macro to transform a single 3d vertex coordinate by the internal matrix with no perspective division. More... | |
#define | mat_trans_single3_nomod(x, y, z, x2, y2, z2) |
Macro to transform a single 3d vertex coordinate by the internal matrix with perspective division. More... | |
#define | mat_trans_single3_nodiv_nomod(x, y, z, x2, y2, z2) |
Macro to transform a single 3d vertex coordinate by the internal matrix. More... | |
#define | mat_trans_single3_nodivw(x, y, z, w) |
Macro to transform a single 3d vertex coordinate by the internal matrix. More... | |
#define | mat_trans_single3_nodiv_div(x, y, z, xd, yd, zd) |
Macro to transform a single 3d vertex coordinate by the internal matrix both with and without perspective division. More... | |
#define | mat_trans_normal3(x, y, z) |
Macro to transform a single vertex normal by the internal matrix. More... | |
#define | mat_trans_normal3_nomod(x, y, z, x2, y2, z2) |
Macro to transform a single vertex normal by the internal matrix. More... | |
Functions | |
void | mat_store (matrix_t *out) |
Copy the internal matrix to a memory one. More... | |
void | mat_load (matrix_t *out) |
Copy a memory matrix into the internal one. More... | |
void | mat_identity () |
Clear the internal matrix to identity. More... | |
void | mat_apply (matrix_t *src) |
Apply a matrix. More... | |
void | mat_transform (vector_t *invecs, vector_t *outvecs, int veccnt, int vecskip) |
Transform vectors by the internal matrix. More... | |
void | mat_transform_sq (void *input, void *output, int veccnt) |
Transform vectors by the internal matrix into the store queues. More... | |
Basic matrix operations.
This file contains various basic matrix math functionality for using the SH4's matrix transformation unit. Higher level functionality, like the 3D functionality is built off of these operations.
#define mat_trans_nodiv | ( | x, | |
y, | |||
z, | |||
w | |||
) |
Macro to transform a single vertex by the internal matrix with no perspective division.
This macro is an inline assembly operation to transform a single vertex. It works most efficiently if the x value is in fr0, y is in fr1, z is in fr2, and w is in fr3 before using the macro. This macro is similar to mat_trans_single(), but this one does not do any perspective division.
x | The X coordinate to transform. |
y | The Y coordinate to transform. |
z | The Z coordinate to transform. |
w | The W coordinate to transform. |
#define mat_trans_normal3 | ( | x, | |
y, | |||
z | |||
) |
Macro to transform a single vertex normal by the internal matrix.
This macro is an inline assembly operation to transform a 3 float vertex normal. It works most efficiently if the x value is in fr8, y is in fr9, and z is in fr10 before using the macro. This macro is similar to mat_trans_nodiv(), but this one sets the W component to 0 in order to transform a vertex normal, rather than 1 for a vertex position.
x | The X normal to transform. |
y | The Y normal to transform. |
z | The Z normal to transform. |
#define mat_trans_normal3_nomod | ( | x, | |
y, | |||
z, | |||
x2, | |||
y2, | |||
z2 | |||
) |
Macro to transform a single vertex normal by the internal matrix.
This macro is an inline assembly operation to transform a 3 float vertex normal. It works most efficiently if the x value is in fr8, y is in fr9, and z is in fr10 before using the macro. This macro is similar to mat_trans_normal3(), but this one does not modify the input operands, instead storing the transformed vector to the output operands.
x | The X normal to input transform. |
y | The Y normal to input transform. |
z | The Z normal to input transform. |
x2 | The X normal to output transform. |
y2 | The Y normal to output transform. |
z2 | The Z normal to output transform. |
#define mat_trans_single | ( | x, | |
y, | |||
z | |||
) |
Macro to transform a single vertex by the internal matrix.
This macro is an inline assembly operation to transform a single vertex. It works most efficiently if the x value is in fr0, y is in fr1, and z is in fr2 before using the macro.
x | The X coordinate to transform. |
y | The Y coordinate to transform. |
z | The Z coordinate to transform. |
#define mat_trans_single3 | ( | x, | |
y, | |||
z | |||
) |
Macro to transform a single vertex by the internal matrix.
This macro is an inline assembly operation to transform a single vertex. It works most efficiently if the x value is in fr0, y is in fr1, and z is in fr2 before using the macro. This macro is similar to mat_trans_single(), but this one leaves z/w instead of 1/w for the z component.
x | The X coordinate to transform. |
y | The Y coordinate to transform. |
z | The Z coordinate to transform. |
#define mat_trans_single3_nodiv | ( | x, | |
y, | |||
z | |||
) |
Macro to transform a single 3d vertex coordinate by the internal matrix with no perspective division.
This macro is an inline assembly operation to transform a 3 float vertex coordinate. It works most efficiently if the x value is in fr12, y is in fr13, and z is in fr14 before using the macro. This macro is similar to mat_trans_nodiv(), but this one sets the W component to 1 for use with a 3d vector.
x | The X coordinate to transform. |
y | The Y coordinate to transform. |
z | The Z coordinate to transform. |
#define mat_trans_single3_nodiv_div | ( | x, | |
y, | |||
z, | |||
xd, | |||
yd, | |||
zd | |||
) |
Macro to transform a single 3d vertex coordinate by the internal matrix both with and without perspective division.
This macro is an inline assembly operation to transform a 3 float vertex coordinate. It works most efficiently if the x value is in fr0, y is in fr1, and z is in fr2 before using the macro. This macro is similar to mat_trans_single(), but this one is used for transforming input vertex with and without perspective division.
x | The X coordinate to transform without perspective divide. |
y | The Y coordinate to transform without perspective divide. |
z | The Z coordinate to transform without perspective divide. |
xd | The X coordinate to output transform with perspective divide. |
yd | The Y coordinate to output transform with perspective divide. |
zd | The Z coordinate to output transform with perspective divide. |
#define mat_trans_single3_nodiv_nomod | ( | x, | |
y, | |||
z, | |||
x2, | |||
y2, | |||
z2 | |||
) |
Macro to transform a single 3d vertex coordinate by the internal matrix.
This macro is an inline assembly operation to transform a 3 float vertex coordinate. It works most efficiently if the x value is in fr12, y is in fr13, and z is in fr14 before using the macro. This macro is similar to mat_trans_single3_nodiv(), but this one does not modify the input operands, instead storing the transformed vector to the output operands.
x | The X coordinate to input transform. |
y | The Y coordinate to input transform. |
z | The Z coordinate to input transform. |
x2 | The X coordinate to output transform. |
y2 | The Y coordinate to output transform. |
z2 | The Z coordinate to output transform. |
#define mat_trans_single3_nodivw | ( | x, | |
y, | |||
z, | |||
w | |||
) |
Macro to transform a single 3d vertex coordinate by the internal matrix.
This macro is an inline assembly operation to transform a 3 float vertex coordinate. It works most efficiently if the x value is in fr12, y is in fr13, and z is in fr14 before using the macro. This macro is similar to mat_trans_single3_nodiv(), but this one stores the W component of transform for later perspective divide.
x | The X coordinate to transform. |
y | The Y coordinate to transform. |
z | The Z coordinate to transform. |
w | The W coordinate output of transform. |
#define mat_trans_single3_nomod | ( | x, | |
y, | |||
z, | |||
x2, | |||
y2, | |||
z2 | |||
) |
Macro to transform a single 3d vertex coordinate by the internal matrix with perspective division.
This macro is an inline assembly operation to transform a 3 float vertex coordinate. It works most efficiently if the x value is in fr12, y is in fr13, and z is in fr14 before using the macro. This macro is similar to mat_trans_single(), but this one does not modify the input operands, instead storing the transformed vector to the output operands.
x | The X coordinate to input transform. |
y | The Y coordinate to input transform. |
z | The Z coordinate to input transform. |
x2 | The X coordinate to output transform. |
y2 | The Y coordinate to output transform. |
z2 | The Z coordinate to output transform. |
#define mat_trans_single4 | ( | x, | |
y, | |||
z, | |||
w | |||
) |
Macro to transform a single vertex by the internal matrix.
This macro is an inline assembly operation to transform a single vertex. It works most efficiently if the x value is in fr0, y is in fr1, z is in fr2, and w is in fr3 before using the macro. This macro is similar to mat_trans_single(), but this one allows an input to and preserves the Z/W value.
x | The X coordinate to transform. |
y | The Y coordinate to transform. |
z | The Z coordinate to transform. |
w | The W coordinate to transform. |
void mat_apply | ( | matrix_t * | src | ) |
Apply a matrix.
This function multiplies a matrix in memory onto the internal matrix.
src | A poitner to the matrix to multiply. |
void mat_identity | ( | ) |
Clear the internal matrix to identity.
This function clears the internal matrix to a standard identity matrix.
void mat_load | ( | matrix_t * | out | ) |
Copy a memory matrix into the internal one.
This function loads the internal matrix with the values of one in memory.
out | A pointer to where to load the matrix from (must be at least 8-byte aligned, should be 32-byte aligned). |
void mat_store | ( | matrix_t * | out | ) |
Copy the internal matrix to a memory one.
This function stores the current internal matrix to one in memory.
out | A pointer to where to store the matrix (must be at least 8-byte aligned, should be 32-byte aligned). |
Transform vectors by the internal matrix.
This function transforms zero or more sets of vectors by the current internal matrix. Each vector is 3 single-precision floats long.
invecs | The list of input vectors. |
outvecs | The list of output vectors. |
veccnt | How many vectors are in the list. |
vecskip | Number of empty bytes between vectors. |
void mat_transform_sq | ( | void * | input, |
void * | output, | ||
int | veccnt | ||
) |
Transform vectors by the internal matrix into the store queues.
This function transforms one or more sets of vertices using the current internal matrix directly into the store queues. Each vertex is exactly 32-bytes long, and the non-xyz data that is with it will be copied over with the transformed coordinates. This is perfect, for instance, for transforming pvr_vertex_t vertices.
input | The list of input vertices. |
output | The output pointer. |
veccnt | The number of vertices to transform. |