coastline 0.0.4
Loading...
Searching...
No Matches
gu.h File Reference

The graphics utility routines for matrices and view transforms, and the trigonometry they use. More...

#include <PR/gbi.h>
#include <PR/ultratypes.h>
Include dependency graph for gu.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void guMtxF2L (float mf[4][4], Mtx *m)
 Convert a floating-point matrix to the fixed-point form of the RSP.
void guMtxL2F (float mf[4][4], Mtx *m)
 Convert a fixed-point matrix to floating point.
void guMtxIdentF (float mf[4][4])
 Set a floating-point matrix to the identity.
void guMtxIdent (Mtx *m)
 Set a fixed-point matrix to the identity.
void guMtxCatF (float mf[4][4], float nf[4][4], float res[4][4])
 Multiply two floating-point matrices.
void guMtxCatL (Mtx *m, Mtx *n, Mtx *res)
 Multiply two fixed-point matrices.
void guMtxXFMF (float mf[4][4], float x, float y, float z, float *ox, float *oy, float *oz)
 Transform a point by a floating-point matrix.
void guMtxXFML (Mtx *m, float x, float y, float z, float *ox, float *oy, float *oz)
 Transform a point by a fixed-point matrix.
void guScaleF (float mf[4][4], float x, float y, float z)
 Build a floating-point scale matrix.
void guScale (Mtx *m, float x, float y, float z)
 Build a fixed-point scale matrix.
void guTranslateF (float mf[4][4], float x, float y, float z)
 Build a floating-point translation matrix.
void guTranslate (Mtx *m, float x, float y, float z)
 Build a fixed-point translation matrix.
void guRotateF (float mf[4][4], float a, float x, float y, float z)
 Build a floating-point matrix that rotates by a degrees about an axis.
void guRotate (Mtx *m, float a, float x, float y, float z)
 Build a fixed-point matrix that rotates by a degrees about an axis.
void guNormalize (float *x, float *y, float *z)
 Scale a vector to unit length in place.
void guPerspectiveF (float mf[4][4], u16 *perspNorm, float fovy, float aspect, float near, float far, float scale)
 Build a floating-point perspective projection.
void guPerspective (Mtx *m, u16 *perspNorm, float fovy, float aspect, float near, float far, float scale)
 Build a fixed-point perspective projection.
void guLookAtF (float mf[4][4], float xEye, float yEye, float zEye, float xAt, float yAt, float zAt, float xUp, float yUp, float zUp)
 Build a floating-point viewing matrix from the eye, the point it looks at and the up vector.
void guLookAt (Mtx *m, float xEye, float yEye, float zEye, float xAt, float yAt, float zAt, float xUp, float yUp, float zUp)
 Build a fixed-point viewing matrix.
void guLookAtReflectF (float mf[4][4], LookAt *l, float xEye, float yEye, float zEye, float xAt, float yAt, float zAt, float xUp, float yUp, float zUp)
 Build a floating-point viewing matrix and the directions for reflection mapping.
void guLookAtReflect (Mtx *m, LookAt *l, float xEye, float yEye, float zEye, float xAt, float yAt, float zAt, float xUp, float yUp, float zUp)
 Build a fixed-point viewing matrix and the directions for reflection mapping.
void guLookAtHiliteF (float mf[4][4], LookAt *l, Hilite *h, float xEye, float yEye, float zEye, float xAt, float yAt, float zAt, float xUp, float yUp, float zUp, float xl1, float yl1, float zl1, float xl2, float yl2, float zl2, int twidth, int theight)
 Build a floating-point viewing matrix, the reflection directions and the positions of the highlights of two lights on a texture of the given size.
void guLookAtHilite (Mtx *m, LookAt *l, Hilite *h, float xEye, float yEye, float zEye, float xAt, float yAt, float zAt, float xUp, float yUp, float zUp, float xl1, float yl1, float zl1, float xl2, float yl2, float zl2, int twidth, int theight)
 Build a fixed-point viewing matrix with reflection directions and highlights.
float sinf (float x)
 Return the sine of an angle in radians.
float cosf (float x)
 Return the cosine of an angle in radians.
float sqrtf (float x)
 Return the square root.
s16 sins (u16 x)
 Return the sine of an angle where 0x10000 is a full turn, in s1.15 fixed point.

Detailed Description

The graphics utility routines for matrices and view transforms, and the trigonometry they use.

Function Documentation

◆ guMtxF2L()

void guMtxF2L ( float mf[4][4],
Mtx * m )

Convert a floating-point matrix to the fixed-point form of the RSP.

Parameters
mfThe source matrix, as f32[4][4] in row-major order.
mReceives the matrix in s15.16 fixed point, integer halves first and fractions after.
Ghidra address:
USA: 0x80260ed0
Ghidra address:
Asia: 0x80260A20
Ghidra address:
EUR: 0x80262360
Ghidra address:
JPN: 0x80261e10

◆ guMtxL2F()

void guMtxL2F ( float mf[4][4],
Mtx * m )

Convert a fixed-point matrix to floating point.

Parameters
mfReceives the matrix as f32[4][4].
mThe source matrix in s15.16 fixed point.
Ghidra address:
USA: 0x80261088
Ghidra address:
Asia: 0x80260BD8
Ghidra address:
EUR: 0x80262518
Ghidra address:
JPN: 0x80261fc8

◆ guMtxIdentF()

void guMtxIdentF ( float mf[4][4])

Set a floating-point matrix to the identity.

Parameters
mfThe f32[4][4] matrix set.
Ghidra address:
USA: 0x80260fd0
Ghidra address:
Asia: 0x80260B20
Ghidra address:
EUR: 0x80262460
Ghidra address:
JPN: 0x80261f10
Ghidra address:
BRD3D: 0x100307d0
Ghidra address:
BRGlide: 0x10029e80

◆ guMtxIdent()

void guMtxIdent ( Mtx * m)

Set a fixed-point matrix to the identity.

Parameters
mThe fixed-point matrix set.
Ghidra address:
USA: 0x80261058
Ghidra address:
Asia: 0x80260BA8
Ghidra address:
EUR: 0x802624e8
Ghidra address:
JPN: 0x80261f98

◆ guMtxCatF()

void guMtxCatF ( float mf[4][4],
float nf[4][4],
float res[4][4] )

Multiply two floating-point matrices.

The result may alias either operand.

Parameters
mfThe left operand, as f32[4][4].
nfThe right operand, as f32[4][4].
resReceives the product mf times nf.
Ghidra address:
USA: 0x80260940
Ghidra address:
Asia: 0x80260490
Ghidra address:
EUR: 0x80261e40
Ghidra address:
JPN: 0x802618b0
Ghidra address:
BRD3D: 0x100306c0
Ghidra address:
BRGlide: 0x10029d70

◆ guMtxCatL()

void guMtxCatL ( Mtx * m,
Mtx * n,
Mtx * res )

Multiply two fixed-point matrices.

Parameters
mThe left operand, in s15.16 fixed point.
nThe right operand, in s15.16 fixed point.
resReceives the product m times n.
Ghidra address:
USA: 0x80267470
Ghidra address:
Asia: 0x80266FC0
Ghidra address:
EUR: 0x80268c60
Ghidra address:
JPN: 0x80268710

◆ guMtxXFMF()

void guMtxXFMF ( float mf[4][4],
float x,
float y,
float z,
float * ox,
float * oy,
float * oz )

Transform a point by a floating-point matrix.

Parameters
mfThe transform, as f32[4][4].
xThe X coordinate of the point.
yThe Y coordinate of the point.
zThe Z coordinate of the point.
oxReceives the transformed X coordinate.
oyReceives the transformed Y coordinate.
ozReceives the transformed Z coordinate.
Ghidra address:
USA: 0x802608a0
Ghidra address:
Asia: 0x802603F0
Ghidra address:
EUR: 0x80261da0
Ghidra address:
JPN: 0x80261810

◆ guMtxXFML()

void guMtxXFML ( Mtx * m,
float x,
float y,
float z,
float * ox,
float * oy,
float * oz )

Transform a point by a fixed-point matrix.

Parameters
mThe transform, in s15.16 fixed point.
xThe X coordinate of the point.
yThe Y coordinate of the point.
zThe Z coordinate of the point.
oxReceives the transformed X coordinate.
oyReceives the transformed Y coordinate.
ozReceives the transformed Z coordinate.
Ghidra address:
USA: 0x80267410
Ghidra address:
Asia: 0x80266F60
Ghidra address:
EUR: 0x80268c00
Ghidra address:
JPN: 0x802686b0

◆ guScaleF()

void guScaleF ( float mf[4][4],
float x,
float y,
float z )

Build a floating-point scale matrix.

Parameters
mfReceives the matrix, as f32[4][4].
xThe scale along X.
yThe scale along Y.
zThe scale along Z.
Ghidra address:
USA: 0x80260800
Ghidra address:
Asia: 0x80260350
Ghidra address:
EUR: 0x80261d00
Ghidra address:
JPN: 0x80261770
Ghidra address:
BRD3D: 0x100310f0
Ghidra address:
BRGlide: 0x1002a7a0

◆ guScale()

void guScale ( Mtx * m,
float x,
float y,
float z )

Build a fixed-point scale matrix.

Parameters
mReceives the matrix in s15.16 fixed point.
xThe scale along X.
yThe scale along Y.
zThe scale along Z.
Ghidra address:
USA: 0x80260854
Ghidra address:
Asia: 0x802603A4
Ghidra address:
EUR: 0x80261d54
Ghidra address:
JPN: 0x802617c4

◆ guTranslateF()

void guTranslateF ( float mf[4][4],
float x,
float y,
float z )

Build a floating-point translation matrix.

Parameters
mfReceives the matrix, as f32[4][4].
xThe translation along X.
yThe translation along Y.
zThe translation along Z.
Ghidra address:
USA: 0x80260e30
Ghidra address:
Asia: 0x80260980
Ghidra address:
EUR: 0x802622c0
Ghidra address:
JPN: 0x80261d70
Ghidra address:
BRD3D: 0x10031140
Ghidra address:
BRGlide: 0x1002a7f0

◆ guTranslate()

void guTranslate ( Mtx * m,
float x,
float y,
float z )

Build a fixed-point translation matrix.

Parameters
mReceives the matrix in s15.16 fixed point.
xThe translation along X.
yThe translation along Y.
zThe translation along Z.
Ghidra address:
USA: 0x80260e78
Ghidra address:
Asia: 0x802609C8
Ghidra address:
EUR: 0x80262308
Ghidra address:
JPN: 0x80261db8

◆ guRotateF()

void guRotateF ( float mf[4][4],
float a,
float x,
float y,
float z )

Build a floating-point matrix that rotates by a degrees about an axis.

Parameters
mfReceives the matrix, as f32[4][4].
aThe angle of the rotation in degrees.
xThe X component of the axis, normalised before use.
yThe Y component of the axis.
zThe Z component of the axis.
Ghidra address:
USA: 0x80260bc0
Ghidra address:
Asia: 0x80260710
Ghidra address:
EUR: 0x80262050
Ghidra address:
JPN: 0x80261b00
Ghidra address:
BRD3D: 0x10030ee0
Ghidra address:
BRGlide: 0x1002a590

◆ guRotate()

void guRotate ( Mtx * m,
float a,
float x,
float y,
float z )

Build a fixed-point matrix that rotates by a degrees about an axis.

Parameters
mReceives the matrix in s15.16 fixed point.
aThe angle of the rotation in degrees.
xThe X component of the axis, normalised before use.
yThe Y component of the axis.
zThe Z component of the axis.
Ghidra address:
USA: 0x80260d54
Ghidra address:
Asia: 0x802608A4
Ghidra address:
EUR: 0x802621e4
Ghidra address:
JPN: 0x80261c94

◆ guNormalize()

void guNormalize ( float * x,
float * y,
float * z )

Scale a vector to unit length in place.

Parameters
xThe X component, replaced by the normalised value.
yThe Y component, replaced by the normalised value.
zThe Z component, replaced by the normalised value.
Ghidra address:
USA: 0x802686c0
Ghidra address:
Asia: 0x80268210
Ghidra address:
EUR: 0x80269d30
Ghidra address:
JPN: 0x802697e0

◆ guPerspectiveF()

void guPerspectiveF ( float mf[4][4],
u16 * perspNorm,
float fovy,
float aspect,
float near,
float far,
float scale )

Build a floating-point perspective projection.

Parameters
mfReceives the matrix, as f32[4][4].
perspNormReceives the factor that normalises the projected W. Windows requires a pointer and writes 1. N64 permits NULL.
fovyThe vertical field of view in degrees.
aspectThe ratio of the width of the view to its height.
nearThe distance to the near clipping plane.
farThe distance to the far clipping plane.
scaleThe factor applied to every element of the N64 matrix. Windows ignores it.
Ghidra address:
USA: 0x80265180
Ghidra address:
Asia: 0x80264CD0
Ghidra address:
EUR: 0x80266910
Ghidra address:
JPN: 0x80266410
Ghidra address:
BRD3D: 0x10030930
Ghidra address:
BRGlide: 0x10029fe0

◆ guPerspective()

void guPerspective ( Mtx * m,
u16 * perspNorm,
float fovy,
float aspect,
float near,
float far,
float scale )

Build a fixed-point perspective projection.

Parameters
mReceives the matrix in s15.16 fixed point.
perspNormReceives the factor that normalises the projected W, unless it is NULL.
fovyThe vertical field of view in degrees.
aspectThe ratio of the width of the view to its height.
nearThe distance to the near clipping plane.
farThe distance to the far clipping plane.
scaleThe factor applied to every element of the matrix.
Ghidra address:
USA: 0x802653b0
Ghidra address:
Asia: 0x80264F00
Ghidra address:
EUR: 0x80266b40
Ghidra address:
JPN: 0x80266640

◆ guLookAtF()

void guLookAtF ( float mf[4][4],
float xEye,
float yEye,
float zEye,
float xAt,
float yAt,
float zAt,
float xUp,
float yUp,
float zUp )

Build a floating-point viewing matrix from the eye, the point it looks at and the up vector.

Parameters
mfReceives the matrix, as f32[4][4].
xEyeThe X coordinate of the eye.
yEyeThe Y coordinate of the eye.
zEyeThe Z coordinate of the eye.
xAtThe X coordinate of the point looked at.
yAtThe Y coordinate of the point looked at.
zAtThe Z coordinate of the point looked at.
xUpThe X component of the up vector.
yUpThe Y component of the up vector.
zUpThe Z component of the up vector.
Ghidra address:
USA: 0x80264e50
Ghidra address:
Asia: 0x802649A0
Ghidra address:
EUR: 0x802665e0
Ghidra address:
JPN: 0x802660e0
Ghidra address:
BRD3D: 0x100309a0
Ghidra address:
BRGlide: 0x1002a050

◆ guLookAt()

void guLookAt ( Mtx * m,
float xEye,
float yEye,
float zEye,
float xAt,
float yAt,
float zAt,
float xUp,
float yUp,
float zUp )

Build a fixed-point viewing matrix.

Parameters
mReceives the matrix in s15.16 fixed point.
xEyeThe X coordinate of the eye.
yEyeThe Y coordinate of the eye.
zEyeThe Z coordinate of the eye.
xAtThe X coordinate of the point looked at.
yAtThe Y coordinate of the point looked at.
zAtThe Z coordinate of the point looked at.
xUpThe X component of the up vector.
yUpThe Y component of the up vector.
zUpThe Z component of the up vector.
Ghidra address:
USA: 0x80265108
Ghidra address:
Asia: 0x80264C58
Ghidra address:
EUR: 0x80266898
Ghidra address:
JPN: 0x80266398

◆ guLookAtReflectF()

void guLookAtReflectF ( float mf[4][4],
LookAt * l,
float xEye,
float yEye,
float zEye,
float xAt,
float yAt,
float zAt,
float xUp,
float yUp,
float zUp )

Build a floating-point viewing matrix and the directions for reflection mapping.

Parameters
mfReceives the matrix, as f32[4][4].
lReceives the right and up vectors of the view as the two reflection directions.
xEyeThe X coordinate of the eye.
yEyeThe Y coordinate of the eye.
zEyeThe Z coordinate of the eye.
xAtThe X coordinate of the point looked at.
yAtThe Y coordinate of the point looked at.
zAtThe Z coordinate of the point looked at.
xUpThe X component of the up vector.
yUpThe Y component of the up vector.
zUpThe Z component of the up vector.
Ghidra address:
USA: 0x80261150
Ghidra address:
Asia: 0x80260CA0
Ghidra address:
EUR: 0x802625e0
Ghidra address:
JPN: 0x80262080
Ghidra address:
BRD3D: 0x10030e20
Ghidra address:
BRGlide: 0x1002a4d0

◆ guLookAtReflect()

void guLookAtReflect ( Mtx * m,
LookAt * l,
float xEye,
float yEye,
float zEye,
float xAt,
float yAt,
float zAt,
float xUp,
float yUp,
float zUp )

Build a fixed-point viewing matrix and the directions for reflection mapping.

Parameters
mReceives the matrix in s15.16 fixed point.
lReceives the right and up vectors of the view as the two reflection directions.
xEyeThe X coordinate of the eye.
yEyeThe Y coordinate of the eye.
zEyeThe Z coordinate of the eye.
xAtThe X coordinate of the point looked at.
yAtThe Y coordinate of the point looked at.
zAtThe Z coordinate of the point looked at.
xUpThe X component of the up vector.
yUpThe Y component of the up vector.
zUpThe Z component of the up vector.
Ghidra address:
USA: 0x80261590
Ghidra address:
Asia: 0x802610E0
Ghidra address:
EUR: 0x80262a20
Ghidra address:
JPN: 0x802624c0

◆ guLookAtHiliteF()

void guLookAtHiliteF ( float mf[4][4],
LookAt * l,
Hilite * h,
float xEye,
float yEye,
float zEye,
float xAt,
float yAt,
float zAt,
float xUp,
float yUp,
float zUp,
float xl1,
float yl1,
float zl1,
float xl2,
float yl2,
float zl2,
int twidth,
int theight )

Build a floating-point viewing matrix, the reflection directions and the positions of the highlights of two lights on a texture of the given size.

Parameters
mfReceives the matrix, as f32[4][4].
lReceives the right and up vectors of the view as the two reflection directions.
hReceives the texture coordinates of the two highlights, in units of 1/4 texel.
xEyeThe X coordinate of the eye.
yEyeThe Y coordinate of the eye.
zEyeThe Z coordinate of the eye.
xAtThe X coordinate of the point looked at.
yAtThe Y coordinate of the point looked at.
zAtThe Z coordinate of the point looked at.
xUpThe X component of the up vector.
yUpThe Y component of the up vector.
zUpThe Z component of the up vector.
xl1The X component of the direction of the first light.
yl1The Y component of the direction of the first light.
zl1The Z component of the direction of the first light.
xl2The X component of the direction of the second light.
yl2The Y component of the direction of the second light.
zl2The Z component of the direction of the second light.
twidthThe width of the highlight texture in texels.
theightThe height of the highlight texture in texels.
Ghidra address:
USA: 0x80266be0
Ghidra address:
Asia: 0x80266730
Ghidra address:
EUR: 0x802683d0
Ghidra address:
JPN: 0x80267e80
Ghidra address:
BRD3D: 0x10030b50
Ghidra address:
BRGlide: 0x1002a200

◆ guLookAtHilite()

void guLookAtHilite ( Mtx * m,
LookAt * l,
Hilite * h,
float xEye,
float yEye,
float zEye,
float xAt,
float yAt,
float zAt,
float xUp,
float yUp,
float zUp,
float xl1,
float yl1,
float zl1,
float xl2,
float yl2,
float zl2,
int twidth,
int theight )

Build a fixed-point viewing matrix with reflection directions and highlights.

Parameters
mReceives the matrix in s15.16 fixed point.
lReceives the right and up vectors of the view as the two reflection directions.
hReceives the texture coordinates of the two highlights, in units of 1/4 texel.
xEyeThe X coordinate of the eye.
yEyeThe Y coordinate of the eye.
zEyeThe Z coordinate of the eye.
xAtThe X coordinate of the point looked at.
yAtThe Y coordinate of the point looked at.
zAtThe Z coordinate of the point looked at.
xUpThe X component of the up vector.
yUpThe Y component of the up vector.
zUpThe Z component of the up vector.
xl1The X component of the direction of the first light.
yl1The Y component of the direction of the first light.
zl1The Z component of the direction of the first light.
xl2The X component of the direction of the second light.
yl2The Y component of the direction of the second light.
zl2The Z component of the direction of the second light.
twidthThe width of the highlight texture in texels.
theightThe height of the highlight texture in texels.
Ghidra address:
USA: 0x8026734c
Ghidra address:
Asia: 0x80266E9C
Ghidra address:
EUR: 0x80268b3c
Ghidra address:
JPN: 0x802685ec

◆ sinf()

float sinf ( float x)

Return the sine of an angle in radians.

Parameters
xThe angle in radians.
Returns
The sine of the angle, from -1 to 1.
Ghidra address:
USA: 0x80261610
Ghidra address:
Asia: 0x80261160
Ghidra address:
EUR: 0x80262aa0
Ghidra address:
JPN: 0x80262540

◆ cosf()

float cosf ( float x)

Return the cosine of an angle in radians.

Parameters
xThe angle in radians.
Returns
The cosine of the angle, from -1 to 1.
Ghidra address:
USA: 0x802617d0
Ghidra address:
Asia: 0x80261320
Ghidra address:
EUR: 0x80262c60
Ghidra address:
JPN: 0x80262700

◆ sqrtf()

float sqrtf ( float x)

Return the square root.

Parameters
xThe value, at least 0.
Returns
The square root of the value.
Ghidra address:
USA: 0x80261140
Ghidra address:
Asia: 0x80260C90
Ghidra address:
EUR: 0x802625d0
Ghidra address:
JPN: 0x80267c60

◆ sins()

s16 sins ( u16 x)

Return the sine of an angle where 0x10000 is a full turn, in s1.15 fixed point.

Parameters
xThe angle, where 0x10000 is a full turn and the low 4 bits are ignored.
Returns
The sine of the angle from -0x7fff to 0x7fff, where 0x7fff is 1.
Ghidra address:
USA: 0x80264420
Ghidra address:
Asia: 0x80263F70
Ghidra address:
EUR: 0x80265ba0
Ghidra address:
JPN: 0x80265640