KallistiOS
2.0.0
|
Basic matrix operations. More...
#include <sys/cdefs.h>
#include <kos/vector.h>
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. | |
#define | mat_trans_single4(x, y, z, w) |
Macro to transform a single vertex by the internal matrix. | |
#define | mat_trans_single3(x, y, z) |
Macro to transform a single vertex by the internal matrix. | |
#define | mat_trans_nodiv(x, y, z, w) |
Macro to transform a single vertex by the internal matrix with no perspective division. |
Functions | |
void | mat_store (matrix_t *out) |
Copy the internal matrix to a memory one. | |
void | mat_load (matrix_t *out) |
Copy a memory matrix into the internal one. | |
void | mat_identity () |
Clear the internal matrix to identity. | |
void | mat_apply (matrix_t *src) |
Apply a matrix. | |
void | mat_transform (vector_t *invecs, vector_t *outvecs, int veccnt, int vecskip) |
Transform vectors by the internal matrix. | |
void | mat_transform_sq (void *input, void *output, int veccnt) |
Transform vectors by the internal matrix into the store queues. |
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_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_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). |
void mat_transform | ( | vector_t * | invecs, |
vector_t * | outvecs, | ||
int | veccnt, | ||
int | vecskip | ||
) |
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. |