SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
MtxUtil.cpp
1#include "Game/Util/MtxUtil.hpp"
2
3namespace MR {
4 void setMtxTrans(MtxPtr mtx, f32 x, f32 y, f32 z) {
5 mtx[0][3] = x;
6 mtx[1][3] = y;
7 mtx[2][3] = z;
8 }
9
10 void addTransMtx(MtxPtr mtx, const TVec3f &rVec) {
11 mtx[0][3] += rVec.x;
12 mtx[1][3] += rVec.y;
13 mtx[2][3] += rVec.z;
14 }
15
16 void addTransMtxLocal(MtxPtr mtx, const TVec3f &rVec) {
17 addTransMtxLocalX(mtx, rVec.x);
18 addTransMtxLocalY(mtx, rVec.y);
19 addTransMtxLocalZ(mtx, rVec.z);
20 }
21
22 void addTransMtxLocalX(MtxPtr mtx, f32 x_coord) {
23 mtx[0][3] = mtx[0][3] + (mtx[0][0] * x_coord);
24 mtx[1][3] = mtx[1][3] + (mtx[1][0] * x_coord);
25 mtx[2][3] = mtx[2][3] + (mtx[2][0] * x_coord);
26 }
27
28 void addTransMtxLocalY(MtxPtr mtx, f32 y_coord) {
29 mtx[0][3] = mtx[0][3] + (mtx[0][1] * y_coord);
30 mtx[1][3] = mtx[1][3] + (mtx[1][1] * y_coord);
31 mtx[2][3] = mtx[2][3] + (mtx[2][1] * y_coord);
32 }
33
34 void addTransMtxLocalZ(MtxPtr mtx, f32 z_coord) {
35 mtx[0][3] = mtx[0][3] + (mtx[0][2] * z_coord);
36 mtx[1][3] = mtx[1][3] + (mtx[1][2] * z_coord);
37 mtx[2][3] = mtx[2][3] + (mtx[2][2] * z_coord);
38 }
39
40 void extractMtxXDir(MtxPtr mtx, TVec3f *pOut) {
41 pOut->x = mtx[0][0];
42 pOut->y = mtx[1][0];
43 pOut->z = mtx[2][0];
44 }
45
46 void extractMtxYDir(MtxPtr mtx, TVec3f *pOut) {
47 pOut->x = mtx[0][1];
48 pOut->y = mtx[1][1];
49 pOut->z = mtx[2][1];
50 }
51
52 void extractMtxZDir(MtxPtr mtx, TVec3f *pOut) {
53 pOut->x = mtx[0][2];
54 pOut->y = mtx[1][2];
55 pOut->z = mtx[2][2];
56 }
57
58 void extractMtxXYZDir(MtxPtr mtx, TVec3f *pOutX, TVec3f *pOutY, TVec3f *pOutZ) {
59 MR::extractMtxXDir(mtx, pOutX);
60 MR::extractMtxYDir(mtx, pOutY);
61 MR::extractMtxZDir(mtx, pOutZ);
62 }
63
64 void extractMtxTrans(MtxPtr mtx, TVec3f *pOut) {
65 pOut->x = mtx[0][3];
66 pOut->y = mtx[1][3];
67 pOut->z = mtx[2][3];
68 }
69
70 /*
71 bool isSameMtx(MtxPtr lhs, MtxPtr rhs) {
72 for (int i = 0; i < 4; i++) {
73 for (int j = 0; j < 3; j++) {
74 if (lhs[i][j] != rhs[i][j]) {
75 return false;
76 }
77 }
78 }
79
80 return true;
81 }
82 */
83};