NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
m_mtx.hpp
1#pragma once
2#include <types.h>
3#include <game/mLib/m_angle.hpp>
4#include <game/mLib/m_vec.hpp>
5#include <lib/nw4r/math/vec.hpp>
6#include <lib/nw4r/math/mtx.hpp>
7#include <lib/rvl/mtx/mtx.h>
8
9/// @brief A 3x4 matrix.
10/// @ingroup mlib
11class mMtx_c : public nw4r::math::MTX34 {
12public:
13 /// @brief Constructs an empty matrix.
14 mMtx_c() {}
15
16 /// @brief Constructs a matrix with the given components.
17 mMtx_c(float _00, float _01, float _02, float _03, float _10, float _11, float _12, float _13, float _20, float _21, float _22, float _23);
18
19 /// @brief Mtx cast operator.
20 operator Mtx*() { return &mtx; }
21
22 /// @brief Const Mtx cast operator.
23 operator const Mtx*() const { return &mtx; }
24
25 void XrotS(mAng angle); ///< Generates a rotation matrix for the X axis with the given angle.
26 void XrotM(mAng angle); ///< Rotates the matrix on the X axis by the given angle.
27 void YrotS(mAng angle); ///< Generates a rotation matrix for the Y axis with the given angle.
28 void YrotM(mAng angle); ///< Rotates the matrix on the Y axis by the given angle.
29 void ZrotS(mAng angle); ///< Generates a rotation matrix for the Z axis with the given angle.
30 void ZrotM(mAng angle); ///< Rotates the matrix on the Z axis by the given angle.
31
32 void ZXYrotM(mAng xRot, mAng yRot, mAng zRot); ///< Rotates the matrix on the Y, X and Z axes by the given angles.
33 void XYZrotM(mAng xRot, mAng yRot, mAng zRot); ///< Rotates the matrix on the Z, Y and X axes by the given angles.
34
35 void toRot(mAng3_c &out) const; ///< Extracts the rotation vector from the matrix.
36 void multVecZero(nw4r::math::VEC3 &out) const; ///< Extracts the translation vector from the matrix.
37 void zero(); ///< Zeroes out the matrix.
38
39 mVec3_c getTranslation() const {
40 float x = mData[0][3];
41 float y = mData[1][3];
42 float z = mData[2][3];
43 return mVec3_c(x, y, z);
44 }
45
46 mMtx_c &concat(const mMtx_c &other) { PSMTXConcat(*this, other, *this); return *this; }
47 mMtx_c &trans(const mVec3_c &v) { PSMTXTrans(*this, v.x, v.y, v.z); return *this; }
48 mMtx_c &trans(float x, float y, float z) { PSMTXTrans(*this, x, y, z); return *this; }
49
50 float transX() const { return getTranslation().x; }
51 float transY() const { return getTranslation().y; }
52 float transZ() const { return getTranslation().z; }
53
54 static mMtx_c Identity; ///< The identity matrix.
55};
A three-dimensional short angle vector.
Definition m_angle.hpp:60
mMtx_c()
Constructs an empty matrix.
Definition m_mtx.hpp:14
void ZrotS(mAng angle)
Generates a rotation matrix for the Z axis with the given angle.
Definition m_mtx.cpp:77
void XYZrotM(mAng xRot, mAng yRot, mAng zRot)
Rotates the matrix on the Z, Y and X axes by the given angles.
Definition m_mtx.cpp:109
void toRot(mAng3_c &out) const
Extracts the rotation vector from the matrix.
Definition m_mtx.cpp:123
void multVecZero(nw4r::math::VEC3 &out) const
Extracts the translation vector from the matrix.
Definition m_mtx.cpp:137
void ZrotM(mAng angle)
Rotates the matrix on the Z axis by the given angle.
Definition m_mtx.cpp:95
void XrotS(mAng angle)
Generates a rotation matrix for the X axis with the given angle.
Definition m_mtx.cpp:25
void YrotS(mAng angle)
Generates a rotation matrix for the Y axis with the given angle.
Definition m_mtx.cpp:51
void ZXYrotM(mAng xRot, mAng yRot, mAng zRot)
Rotates the matrix on the Y, X and Z axes by the given angles.
Definition m_mtx.cpp:103
static mMtx_c Identity
The identity matrix.
Definition m_mtx.hpp:54
void XrotM(mAng angle)
Rotates the matrix on the X axis by the given angle.
Definition m_mtx.cpp:43
void zero()
Zeroes out the matrix.
Definition m_mtx.cpp:143
void YrotM(mAng angle)
Rotates the matrix on the Y axis by the given angle.
Definition m_mtx.cpp:69
A three-dimensional floating point vector.
Definition m_vec.hpp:100
void PSMTXTrans(Mtx *mtx, float x, float y, float z)
Sets a translation matrix with the given components.
void PSMTXConcat(const Mtx *a, const Mtx *b, Mtx *out)
Concatenates two matrices.
float Mtx[3][4]
A 3x4 matrix.
Definition mtx.h:12
A one-dimensional short angle vector.
Definition m_angle.hpp:8
A 3x4 matrix.
Definition mtx.hpp:15
A three-dimensional floating point vector.
Definition vec.hpp:22