RetroArch
Functions
gu.c File Reference
#include <gu.h>
#include <math.h>
Include dependency graph for gu.c:

Functions

void __ps_guMtxRotAxisRadInternal (register Mtx mt, const register guVector *axis, register f32 sT, register f32 cT)
 
void guFrustum (Mtx44 mt, f32 t, f32 b, f32 l, f32 r, f32 n, f32 f)
 Sets a 4x4 perspective projection matrix from viewing volume dimensions. More...
 
void guPerspective (Mtx44 mt, f32 fovy, f32 aspect, f32 n, f32 f)
 Sets a 4x4 perspective projection matrix from field of view and aspect ratio parameters. More...
 
void guOrtho (Mtx44 mt, f32 t, f32 b, f32 l, f32 r, f32 n, f32 f)
 Sets a 4x4 matrix for orthographic projection. More...
 
void guLightPerspective (Mtx mt, f32 fovY, f32 aspect, f32 scaleS, f32 scaleT, f32 transS, f32 transT)
 Sets a 3x4 perspective projection matrix from field of view and aspect ratio parameters, two scale values, and two translation values. More...
 
void guLightOrtho (Mtx mt, f32 t, f32 b, f32 l, f32 r, f32 scaleS, f32 scaleT, f32 transS, f32 transT)
 Sets a 3x4 matrix for orthographic projection. More...
 
void guLightFrustum (Mtx mt, f32 t, f32 b, f32 l, f32 r, f32 n, f32 scaleS, f32 scaleT, f32 transS, f32 transT)
 Sets a 3x4 perspective projection matrix from viewing volume dimensions, two scale values, and two translation values. More...
 
void guLookAt (Mtx mt, guVector *camPos, guVector *camUp, guVector *target)
 Sets a world-space to camera-space transformation matrix. More...
 
void c_guMtxIdentity (Mtx mt)
 
void c_guMtxRotRad (Mtx mt, const char axis, f32 rad)
 
void c_guMtxRotTrig (Mtx mt, const char axis, f32 sinA, f32 cosA)
 
void c_guMtxRotAxisRad (Mtx mt, guVector *axis, f32 rad)
 
void c_guMtxCopy (Mtx src, Mtx dst)
 
void c_guMtxConcat (Mtx a, Mtx b, Mtx ab)
 
void c_guMtxScale (Mtx mt, f32 xS, f32 yS, f32 zS)
 
void c_guMtxScaleApply (Mtx src, Mtx dst, f32 xS, f32 yS, f32 zS)
 
void c_guMtxApplyScale (Mtx src, Mtx dst, f32 xS, f32 yS, f32 zS)
 
void c_guMtxTrans (Mtx mt, f32 xT, f32 yT, f32 zT)
 
void c_guMtxTransApply (Mtx src, Mtx dst, f32 xT, f32 yT, f32 zT)
 
void c_guMtxApplyTrans (Mtx src, Mtx dst, f32 xT, f32 yT, f32 zT)
 
u32 c_guMtxInverse (Mtx src, Mtx inv)
 
void c_guMtxTranspose (Mtx src, Mtx xPose)
 
u32 c_guMtxInvXpose (Mtx src, Mtx xPose)
 
void c_guMtxReflect (Mtx m, guVector *p, guVector *n)
 
void c_guVecAdd (guVector *a, guVector *b, guVector *ab)
 
void c_guVecSub (guVector *a, guVector *b, guVector *ab)
 
void c_guVecScale (guVector *src, guVector *dst, f32 scale)
 
void c_guVecNormalize (guVector *v)
 
void c_guVecCross (guVector *a, guVector *b, guVector *axb)
 
void c_guVecMultiply (Mtx mt, guVector *src, guVector *dst)
 
void c_guVecMultiplySR (Mtx mt, guVector *src, guVector *dst)
 
f32 c_guVecDotProduct (guVector *a, guVector *b)
 
void c_guQuatAdd (guQuaternion *a, guQuaternion *b, guQuaternion *ab)
 
void c_guQuatSub (guQuaternion *a, guQuaternion *b, guQuaternion *ab)
 
void c_guQuatMultiply (guQuaternion *a, guQuaternion *b, guQuaternion *ab)
 
void c_guQuatNormalize (guQuaternion *a, guQuaternion *d)
 
void c_guQuatInverse (guQuaternion *a, guQuaternion *d)
 
void c_guQuatMtx (guQuaternion *a, Mtx m)
 
void c_guMtxQuat (Mtx m, guQuaternion *a)
 
void guVecHalfAngle (guVector *a, guVector *b, guVector *half)
 Computes a vector that lies halfway between a and b. More...
 

Function Documentation

◆ __ps_guMtxRotAxisRadInternal()

void __ps_guMtxRotAxisRadInternal ( register Mtx  mt,
const register guVector axis,
register f32  sT,
register f32  cT 
)

◆ c_guMtxApplyScale()

void c_guMtxApplyScale ( Mtx  src,
Mtx  dst,
f32  xS,
f32  yS,
f32  zS 
)

◆ c_guMtxApplyTrans()

void c_guMtxApplyTrans ( Mtx  src,
Mtx  dst,
f32  xT,
f32  yT,
f32  zT 
)

◆ c_guMtxConcat()

void c_guMtxConcat ( Mtx  a,
Mtx  b,
Mtx  ab 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_guMtxCopy()

void c_guMtxCopy ( Mtx  src,
Mtx  dst 
)
Here is the caller graph for this function:

◆ c_guMtxIdentity()

void c_guMtxIdentity ( Mtx  mt)

◆ c_guMtxInverse()

u32 c_guMtxInverse ( Mtx  src,
Mtx  inv 
)
Here is the call graph for this function:

◆ c_guMtxInvXpose()

u32 c_guMtxInvXpose ( Mtx  src,
Mtx  xPose 
)
Here is the call graph for this function:

◆ c_guMtxQuat()

void c_guMtxQuat ( Mtx  m,
guQuaternion a 
)

◆ c_guMtxReflect()

void c_guMtxReflect ( Mtx  m,
guVector p,
guVector n 
)
Here is the call graph for this function:

◆ c_guMtxRotAxisRad()

void c_guMtxRotAxisRad ( Mtx  mt,
guVector axis,
f32  rad 
)
Here is the call graph for this function:

◆ c_guMtxRotRad()

void c_guMtxRotRad ( Mtx  mt,
const char  axis,
f32  rad 
)
Here is the call graph for this function:

◆ c_guMtxRotTrig()

void c_guMtxRotTrig ( Mtx  mt,
const char  axis,
f32  sinA,
f32  cosA 
)
Here is the caller graph for this function:

◆ c_guMtxScale()

void c_guMtxScale ( Mtx  mt,
f32  xS,
f32  yS,
f32  zS 
)

◆ c_guMtxScaleApply()

void c_guMtxScaleApply ( Mtx  src,
Mtx  dst,
f32  xS,
f32  yS,
f32  zS 
)

◆ c_guMtxTrans()

void c_guMtxTrans ( Mtx  mt,
f32  xT,
f32  yT,
f32  zT 
)

◆ c_guMtxTransApply()

void c_guMtxTransApply ( Mtx  src,
Mtx  dst,
f32  xT,
f32  yT,
f32  zT 
)

◆ c_guMtxTranspose()

void c_guMtxTranspose ( Mtx  src,
Mtx  xPose 
)
Here is the call graph for this function:

◆ c_guQuatAdd()

void c_guQuatAdd ( guQuaternion a,
guQuaternion b,
guQuaternion ab 
)

◆ c_guQuatInverse()

void c_guQuatInverse ( guQuaternion a,
guQuaternion d 
)

◆ c_guQuatMtx()

void c_guQuatMtx ( guQuaternion a,
Mtx  m 
)
Here is the call graph for this function:

◆ c_guQuatMultiply()

void c_guQuatMultiply ( guQuaternion a,
guQuaternion b,
guQuaternion ab 
)

◆ c_guQuatNormalize()

void c_guQuatNormalize ( guQuaternion a,
guQuaternion d 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_guQuatSub()

void c_guQuatSub ( guQuaternion a,
guQuaternion b,
guQuaternion ab 
)

◆ c_guVecAdd()

void c_guVecAdd ( guVector a,
guVector b,
guVector ab 
)

◆ c_guVecCross()

void c_guVecCross ( guVector a,
guVector b,
guVector axb 
)

◆ c_guVecDotProduct()

f32 c_guVecDotProduct ( guVector a,
guVector b 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ c_guVecMultiply()

void c_guVecMultiply ( Mtx  mt,
guVector src,
guVector dst 
)

◆ c_guVecMultiplySR()

void c_guVecMultiplySR ( Mtx  mt,
guVector src,
guVector dst 
)

◆ c_guVecNormalize()

void c_guVecNormalize ( guVector v)
Here is the caller graph for this function:

◆ c_guVecScale()

void c_guVecScale ( guVector src,
guVector dst,
f32  scale 
)

◆ c_guVecSub()

void c_guVecSub ( guVector a,
guVector b,
guVector ab 
)

◆ guFrustum()

void guFrustum ( Mtx44  mt,
f32  t,
f32  b,
f32  l,
f32  r,
f32  n,
f32  f 
)

Sets a 4x4 perspective projection matrix from viewing volume dimensions.

This matrix is used by the GX API to transform points to screen space.

For normal perspective projection, the axis of projection is the -z axis, so t = positive, b = -t, r = positive, l = -r. n and f must both be given as positive distances.

Note
m negates a point's 'z' values, so pre-transformed points should have negative 'z' values in eye space in order to be visible after projection.
Parameters
[out]mtNew projection matrix.
[in]tTop edge of view volume at the near clipping plane.
[in]bBottom edge of view volume at the near clipping plane.
[in]lLeft edge of view volume at the near clipping plane.
[in]rRight edge of view volume at the near clipping plane.
[in]nPositive distance to the near clipping plane.
[in]fPositive distance to the far clipping plane.
Returns
none

◆ guLightFrustum()

void guLightFrustum ( Mtx  mt,
f32  t,
f32  b,
f32  l,
f32  r,
f32  n,
f32  scaleS,
f32  scaleT,
f32  transS,
f32  transT 
)

Sets a 3x4 perspective projection matrix from viewing volume dimensions, two scale values, and two translation values.

This matrix is used to project points into texture space and yield texture coordinates.

For normal perspective projection, the axis of projection is the -z axis, so t = positive, b = -t, r = positive, l = -r. n must be given as a positive distance.

Standard projection yields values ranging from -1.0 to 1.0 in both dimensions of the front clipping plane. Since texture coordinates usually should be within the range of 0.0 to 1.0, we have added a scale and translation value for both S and T. The most common usage of these values is to set all of them to 0.5 so that points in the range of -1.0 to 1.0 are first scaled by 0.5 to be in the range of -0.5 to 0.5, and are then translated by 0.5 to be in the range of 0.0 to 1.0. Other values can be used for translation and scale to yield different effects.

Parameters
[out]mtNew projection matrix.
[in]tTop edge of view volume at the near clipping plane.
[in]bBottom edge of view volume at the near clipping plane.
[in]lLeft edge of view volume at the near clipping plane.
[in]rRight edge of view volume at the near clipping plane.
[in]nPositive distance to the near clipping plane.
[in]scaleSScale in the S direction for projected coordinates (usually 0.5).
[in]scaleTScale in the T direction for projected coordinates (usually 0.5).
[in]transSTranslate in the S direction for projected coordinates (usually 0.5).
[in]transTTranslate in the T direction for projected coordinates (usually 0.5).
Returns
none

◆ guLightOrtho()

void guLightOrtho ( Mtx  mt,
f32  t,
f32  b,
f32  l,
f32  r,
f32  scaleS,
f32  scaleT,
f32  transS,
f32  transT 
)

Sets a 3x4 matrix for orthographic projection.

Use this matrix to project points into texture space and yield texture coordinates.

For normal parallel projections, the axis of projection is the -z axis, so t = positive, b = -t, r = positive, l = -r.

Standard projection yields values ranging from -1.0 to 1.0 in both dimensions of the front clipping plane. Since texture coordinates should usually be within the range of 0.0 to 1.0, we have added a scale and translation value for both S and T. The most common way to use these values is to set all of them to 0.5 so that points in the range of -1.0 to 1.0 are first scaled by 0.5 (to be in the range of -0.5 to 0.5). Then they are translated by 0.5 to be in the range of 0.0 to 1.0. Other values can be used for translation and scale to yield different effects.

Parameters
[out]mtNew parallel projection matrix.
[in]tTop edge of view volume.
[in]bBottom edge of view volume.
[in]lLeft edge of view volume.
[in]rRight edge of view volume.
[in]scaleSScale in the S direction for projected coordinates (usually 0.5).
[in]scaleTScale in the T direction for projected coordinates (usually 0.5).
[in]transSTranslate in the S direction for projected coordinates (usually 0.5).
[in]transTTranslate in the T direction for projected coordinates (usually 0.5).
Returns
none

◆ guLightPerspective()

void guLightPerspective ( Mtx  mt,
f32  fovY,
f32  aspect,
f32  scaleS,
f32  scaleT,
f32  transS,
f32  transT 
)

Sets a 3x4 perspective projection matrix from field of view and aspect ratio parameters, two scale values, and two translation values.

This matrix is used to project points into texture space and yield texture coordinates.

This function generates a projection matrix, equivalent to that created by guLightFrustum(), with the axis of projection centered around Z. This function is included to provide an alternative method of specifying texture projection volume dimensions.

The field of view (fovy) is the total field of view in degrees in the YZ plane. aspect is the ratio (width / height) of the view window in screen space.

Standard projection yields values ranging from -1.0 to 1.0 in both dimensions of the front clipping plane. Since texture coordinates should usually be within the range of 0.0 to 1.0, we have added a scale and translation value for both S and T. The most common way to use these values is to set all of them to 0.5 (so that points in the range of -1.0 to 1.0 are first scaled by 0.5) to be in the range of -0.5 to 0.5. Then they are translated by 0.5 to be in the range of 0.0 to 1.0. Other values can be used for translation and scale to yield different effects.

Parameters
[out]mtNew projection matrix.
[in]fovyTotal field of view in the YZ plane measured in degrees.
[in]aspectView window aspect ratio (width / height)
[in]scaleSScale in the S direction for projected coordinates (usually 0.5).
[in]scaleTScale in the T direction for projected coordinates (usually 0.5).
[in]transSTranslate in the S direction for projected coordinates (usually 0.5).
[in]transTTranslate in the T direction for projected coordinates (usually 0.5).
Returns
none

◆ guLookAt()

void guLookAt ( Mtx  mt,
guVector camPos,
guVector camUp,
guVector target 
)

Sets a world-space to camera-space transformation matrix.

Create the matrix m by specifying a camera position (camPos), a camera "up" direction (camUp), and a target position (target).

The camera's reference viewing direction is the -z axis. The camera's reference 'up' direction is the +y axis.

This function is especially convenient for creating a tethered camera, aiming at an object, panning, or specifying an arbitrary view.

Parameters
[out]mtNew viewing matrix.
[in]camPosVector giving 3D camera position in world space.
[in]camUpVector containing camera "up" vector; does not have to be a unit vector.
[in]targetVector giving 3D target position in world space.
Returns
none

◆ guOrtho()

void guOrtho ( Mtx44  mt,
f32  t,
f32  b,
f32  l,
f32  r,
f32  n,
f32  f 
)

Sets a 4x4 matrix for orthographic projection.

This matrix is used by the GX API to transform points from eye space to screen space.

For normal parallel projections, the axis of projection is the -z axis, so t = positive, b = -t, r = positive, l = -r. n and f must both be given as positive distances.

Note
m negates a point's 'z' values, so pre-transformed points should have negative 'z' values in eye space in order to be visible after projection.
Parameters
[out]mtNew parallel projection matrix.
[in]tTop edge of view volume.
[in]bBottom edge of view volume.
[in]lLeft edge of view volume.
[in]rRight edge of view volume.
[in]nPositive distance to the near clipping plane.
[in]fPositive distance to the far clipping plane.
Returns
none
Here is the caller graph for this function:

◆ guPerspective()

void guPerspective ( Mtx44  mt,
f32  fovy,
f32  aspect,
f32  n,
f32  f 
)

Sets a 4x4 perspective projection matrix from field of view and aspect ratio parameters.

This matrix is used by the GX API to transform points to screen space.

This function generates a projection matrix equivalent to that created by guFrustum() with the axis of projection centered around Z. It is included to provide an alternative method of specifying view volume dimensions.

The field of view (fovy) is the total field of view in degrees in the Y-Z plane. aspect is the ratio (width/height) of the view window in screen space. n and f must both be given as positive distances.

Note
m negates a point's 'z' values, so pre-transformed points should have negative 'z' values in eye space in order to be visible after projection.
Parameters
[out]mtNew perspective projection matrix.
[in]fovyTotal field of view in the Y-Z plane measured in degrees.
[in]aspectView window aspect ratio (width/height)
[in]nPositive distance to near clipping plane.
[in]fPositive distance to far clipping plane.
Returns
none

◆ guVecHalfAngle()

void guVecHalfAngle ( guVector a,
guVector b,
guVector half 
)

Computes a vector that lies halfway between a and b.

The halfway vector is useful in specular reflection calculations. It is interpreted as pointing from the reflecting surface to the general viewing direction.

a and b do not have to be unit vectors. Both of these vectors are assumed to be pointing towards the surface from the light or viewer, respectively. Local copies of these vectors are negated, normalized and added head to tail.

half is computed as a unit vector that points from the surface to halfway between the light and the viewing direction.

Parameters
[in]aPointer to incident vector. Must point from the light source to the surface.
[in]bPointer to viewing vector. Must point from the viewer to the surface.
[out]halfPointer to resultant half-angle unit vector; points from the surface to halfway between the light and the viewing direction.
Returns
none