resonance 1.0.1
Loading...
Searching...
No Matches
transformops.h File Reference

Go to the source code of this file.

Namespaces

namespace  Rnd
 The rendering engine.

Functions

void InversMatrix (float *pDst, const float *pSrc)
 Invert a rigid transform.
void sceVu0MulAffineMatrix (float *pDst, const float *pA, const float *pB)
 Multiply two affine transforms across all four words of every row.
void sceVu0MulAffineMatrixXyz (float *pDst, const float *pA, const float *pB)
 Multiply two affine transforms in the first three words of every row.
void XfmConcat (const float *pA, const float *pB, float *pOut)
 Compose two transforms on VU0.
void Rnd::MakeRotMatrix (const float *pAngles, float *pMat3Rows)
 Build a rotation matrix from three Euler angles.
void Mat33BuildOrthonormal (const float *pAxisY, const float *pReference, float *pMat3Rows)
 Build an orthonormal basis around one axis and a reference direction.
void Mat33OrthonormalizeAroundY (const float *pSrc, float *pDst)
 Rebuild a basis as orthonormal around its Y row.
void Mat34DecomposeEulerScale (const float *pMat3Rows, float *pAngles, float *pScale)
 Split a basis into Euler angles and per-axis scales.
void MultiplyMat3VU0 (const float *pMatA, const float *pMatB, float *pOut)
 Multiply two rotation matrices on VU0.
void Rnd::Scale (const float *pScale, const float *pMat3Rows, float *pOut)
 Scale each row of a rotation matrix by one component of a vector.
void TransformVec3ByMat3VU0 (const float *pVec, const float *pMat3Rows, float *pOut)
 Transform a three-component vector by a rotation matrix on VU0.

Function Documentation

◆ InversMatrix()

void InversMatrix ( float * pDst,
const float * pSrc )

Invert a rigid transform.

Sony libvu0, linked as shipped. The basis rows are transposed and the translation row becomes the negated transposed basis applied to the original translation. An input whose basis is not orthonormal therefore does not invert correctly.

Parameters
pDstReceives the inverse, four rows of four floats.
pSrcThe transform to invert, four rows of four floats.
Ghidra address:
NTSC-U/C: 0x005e7b08
Ghidra address:
PAL: 0x00629cf0

◆ sceVu0MulAffineMatrix()

void sceVu0MulAffineMatrix ( float * pDst,
const float * pA,
const float * pB )

Multiply two affine transforms across all four words of every row.

A member of the Sony libvu0 object, linked as shipped, whose published name is unknown. It is sceVu0MulMatrix with the loop cut to three rows that ignore the fourth word of pB, and a fourth row that adds the translation row of pA. Callers use it where the fourth word is consumed.

Parameters
pDstReceives the product, four rows of four floats. It may alias either factor.
pAThe left factor, four rows of four floats.
pBThe right factor, four rows of four floats.
Ghidra address:
NTSC-U/C: 0x005e7a58
Ghidra address:
PAL: 0x00629c40

◆ sceVu0MulAffineMatrixXyz()

void sceVu0MulAffineMatrixXyz ( float * pDst,
const float * pA,
const float * pB )

Multiply two affine transforms in the first three words of every row.

A member of the Sony libvu0 object, linked as shipped, whose published name is unknown. It is sceVu0MulAffineMatrix under an xyz destination mask. The fourth word of every destination row therefore receives whatever the vector register already had.

Parameters
pDstReceives the product, four rows of four floats. It may alias either factor.
pAThe left factor, four rows of four floats.
pBThe right factor, four rows of four floats.
Ghidra address:
NTSC-U/C: 0x005e7ab0
Ghidra address:
PAL: 0x00629c98

◆ XfmConcat()

void XfmConcat ( const float * pA,
const float * pB,
float * pOut )

Compose two transforms on VU0.

Each row of the second transform is applied to the first, which makes the result the transform that applies pA and then pB.

Parameters
pAThe transform applied first, four rows of four floats.
pBThe transform applied second, four rows of four floats.
pOutReceives the composition and may alias either input.
Ghidra address:
NTSC-U/C: 0x0045dae8
Ghidra address:
PAL: 0x0049b190

◆ Mat33BuildOrthonormal()

void Mat33BuildOrthonormal ( const float * pAxisY,
const float * pReference,
float * pMat3Rows )

Build an orthonormal basis around one axis and a reference direction.

The Y row is the supplied axis normalised. The X row is that axis crossed with the reference direction and normalised. The Z row is X crossed with Y, and needs no normalising. A reference direction parallel to the axis yields a zero cross product and then a division by zero.

Each row is written as a whole quadword, and the two cross products propagate the fourth word of the supplied axis into the other two rows. All three rows therefore end with pAxisY[3]. The 1.0 that the inlined vector construction writes into the scratch quadword is overwritten before anything reads it.

Parameters
pAxisYThe direction the Y row takes, four floats.
pReferenceThe reference direction, three floats.
pMat3RowsReceives the basis, three rows of four floats.
Ghidra address:
NTSC-U/C: 0x004f0538
Ghidra address:
PAL: 0x0052f128

◆ Mat33OrthonormalizeAroundY()

void Mat33OrthonormalizeAroundY ( const float * pSrc,
float * pDst )

Rebuild a basis as orthonormal around its Y row.

The Y row is normalised. The X row becomes that Y row crossed with the source Z row, normalised, and the Z row becomes X crossed with Y. Each row is written as a whole quadword, and the cross products propagate the fourth word of the source Y row into the other two rows. pDst may be pSrc. The source Z row is read before the destination Z row is written. Rnd::Transformable::GetDrawXfm() rebuilds its camera-facing basis in place with it, and the routines at 0x00254b30 and 0x00254c20 also call it.

Parameters
pSrcThe basis to rebuild, three rows of four floats.
pDstReceives the orthonormal basis, three rows of four floats.
Ghidra address:
NTSC-U/C: 0x002556c8
Ghidra address:
PAL: 0x0026adc0

◆ Mat34DecomposeEulerScale()

void Mat34DecomposeEulerScale ( const float * pMat3Rows,
float * pAngles,
float * pScale )

Split a basis into Euler angles and per-axis scales.

Each scale is the length of the matching row. The Z scale is negated when the three rows are left handed. Negating it is the only way the remaining rotation can stay a pure rotation. The angles are then extracted from the rows divided by their scales, and the extraction inverts Rnd::MakeRotMatrix() from three angles. A basis at the gimbal lock limit yields a Y angle of zero and folds the whole remaining rotation into the Z angle.

Parameters
pMat3RowsThe basis, three rows of four floats.
pAnglesReceives the three angles in radians, ordered X, Y, and Z.
pScaleReceives the three scales.
Ghidra address:
NTSC-U/C: 0x004ee750
Ghidra address:
PAL: 0x0052d2f8

◆ MultiplyMat3VU0()

void MultiplyMat3VU0 ( const float * pMatA,
const float * pMatB,
float * pOut )

Multiply two rotation matrices on VU0.

Every row of pMatA is pushed through pMatB. A destination that is the right factor is routed through three scratch quadwords. A destination that is the left factor needs no special handling and gets none, because each row of pMatA is consumed before that row is written. Each row is stored as a whole quadword, and the fourth word of the result comes from the fourth word of the matching row of pMatA.

Parameters
pMatAThe left factor, three rows of four floats.
pMatBThe right factor, three rows of four floats.
pOutReceives the product, and may alias either factor.
Ghidra address:
NTSC-U/C: 0x00453ec8
Ghidra address:
PAL: 0x004913e8

◆ TransformVec3ByMat3VU0()

void TransformVec3ByMat3VU0 ( const float * pVec,
const float * pMat3Rows,
float * pOut )

Transform a three-component vector by a rotation matrix on VU0.

The vector is treated as a row vector, and each component selects a row of the matrix. The store moves a whole quadword while the accumulate stage writes only three components. The fourth word of the destination therefore receives the fourth word of the source.

Parameters
pVecThe vector to transform, four floats.
pMat3RowsThe rotation, three rows of four floats.
pOutReceives the transformed vector, and may alias pVec.
Ghidra address:
NTSC-U/C: 0x00453ea0
Ghidra address:
PAL: 0x004913c0