al - Audio Library Functions gDP - DP GBI Macros gdSP - General GBI Macros gSP - SP GBI Macros gt - Turbo Microcode RDP gu - Graphics Utilities Math - Math Functions nuSys - NuSystem os - N64 Operating System sp - Sprite Library Functions uh - Host to Target IO 64DD - N64 Disk Drive
|
gSPMatrixSyntax#include <ultra64.h> /* gbi.h */ gSPMatrix(Gfx *gdl, Mtx *matrix, u8 param) gsSPMatrix(Mtx *matrix, u8 param) Arguments
Explanation
To declare a static unit matrix, the code would look as follows:
A matrix with the translation elements (10.5, 20.5, 30.5) would look as follows. mat.m[1][2] = (10 << 16) | (20); | 1.0 0.0 0.00.0| mat.m[1][3] = (30 << 16) | (1); ---> | 0.0 1.0 0.00.0| mat.m[3][2] = (0x8000 << 16) | (0x8000); | 0.0 0.0 1.00.0| mat.m[3][3] = (0x8000 << 16) | (0); |10.520.530.51.0|
Note
The middle 32 bits that remain in the new matrix To maintain the highest precision, the absolute values of each component of the matrices must not differ significantly. Extreme scale and translation arguments will reduce the transformation precision. Since rotation matrix and projection matrix operations require very small fractional numbers, some of these may be lost when multiplied by large integer values. Also, the least significant bit (LSB) of each matrix term is rounded off when matrices are concatenated. As a result, a 1/2 LSB error is generated in the matrix for each concatenation. To guarantee full precision, concatenate the matrices using floating-point operations in the CPU and only load that result in the RSP.
Comment
One way to optimize the process is to concatenate modeling matrices in the CPU, and concatenate viewing (V) matrices and projection matrices in the projection matrix stack. When this is done, the MxVP matrix concatenation is carried out each time the modeling matrix is loaded. There are also other simple ways of concatenating modeling matrices. For example, a matrix that concatenates a rotation matrix around one axis with a translation matrix can be obtained by simply entering the appropriate elements for the matrix components. The Mtx structure is as follows: typedef long Mtx_t[4][4]; typedef union{ Mtx_t m; long long int force_structure_alignment; } Mtx;
See Also
Revision History
|