2022-10-09 05:13:17 +00:00
|
|
|
#ifndef _CMATRIX3F
|
|
|
|
#define _CMATRIX3F
|
2022-09-18 05:55:13 +00:00
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
|
2022-12-07 05:13:59 +00:00
|
|
|
#include "Kyoto/Math/CTransform4f.hpp"
|
2022-09-18 05:55:13 +00:00
|
|
|
#include "Kyoto/Math/CVector3f.hpp"
|
|
|
|
|
2024-10-22 23:12:41 +00:00
|
|
|
class CInputStream;
|
2022-09-18 05:55:13 +00:00
|
|
|
class CMatrix3f {
|
2022-10-05 16:28:37 +00:00
|
|
|
static const CMatrix3f sIdentity;
|
2022-10-09 05:13:17 +00:00
|
|
|
|
2022-09-18 05:55:13 +00:00
|
|
|
public:
|
2024-10-22 23:12:41 +00:00
|
|
|
CMatrix3f(float _m00, float _m01, float _m02, float _m10, float _m11, float _m12, float _m20,
|
|
|
|
float _m21, float _m22)
|
|
|
|
: m00(_m00)
|
|
|
|
, m01(_m01)
|
|
|
|
, m02(_m02)
|
|
|
|
, m10(_m10)
|
|
|
|
, m11(_m11)
|
|
|
|
, m12(_m12)
|
|
|
|
, m20(_m20)
|
|
|
|
, m21(_m21)
|
|
|
|
, m22(_m22) {}
|
|
|
|
CMatrix3f(const CVector3f& _m0, const CVector3f& _m1, const CVector3f& _m2);
|
|
|
|
CMatrix3f(const CMatrix3f& left, float leftScale, const CMatrix3f& right, float rightScale);
|
|
|
|
CMatrix3f(CInputStream& in);
|
2022-10-05 16:28:37 +00:00
|
|
|
CMatrix3f(const CMatrix3f&);
|
2022-12-07 05:13:59 +00:00
|
|
|
// fake but useful for CEulerAngles?
|
2024-10-22 23:12:41 +00:00
|
|
|
CMatrix3f(const CTransform4f& xf); /*
|
|
|
|
: m0(xf.GetRow(kDX))
|
|
|
|
, m1(xf.GetRow(kDY))
|
|
|
|
, m2(xf.GetRow(kDZ)) {}*/
|
2022-12-07 05:13:59 +00:00
|
|
|
|
2024-10-22 23:12:41 +00:00
|
|
|
void RotateY(const CRelAngle& angle);
|
|
|
|
void RotateZ(const CRelAngle& angle);
|
2022-10-05 17:24:06 +00:00
|
|
|
const CMatrix3f& operator=(const CMatrix3f& other);
|
2024-10-22 23:12:41 +00:00
|
|
|
const CVector3f operator*(const CVector3f&) const;
|
|
|
|
const CMatrix3f operator*(const CMatrix3f&) const;
|
2022-09-18 05:55:13 +00:00
|
|
|
|
2022-10-05 17:24:06 +00:00
|
|
|
static const CMatrix3f& Identity() { return sIdentity; }
|
2022-10-09 05:13:17 +00:00
|
|
|
|
2022-10-17 15:02:11 +00:00
|
|
|
CMatrix3f Orthonormalized() const;
|
2024-10-22 23:12:41 +00:00
|
|
|
float Determinant() const;
|
|
|
|
void AddScaledMatrix(const CMatrix3f& mat, float scale);
|
2022-10-17 15:02:11 +00:00
|
|
|
|
2022-11-14 13:37:44 +00:00
|
|
|
// TODO: names/check
|
2024-10-22 23:12:41 +00:00
|
|
|
inline const CVector3f& GetRow(EDimX dim) const {
|
|
|
|
return *reinterpret_cast< const CVector3f* >(&m00);
|
|
|
|
}
|
|
|
|
inline const CVector3f& GetRow(EDimY dim) const {
|
|
|
|
return *reinterpret_cast< const CVector3f* >(&m10);
|
|
|
|
}
|
|
|
|
inline const CVector3f& GetRow(EDimZ dim) const {
|
|
|
|
return *reinterpret_cast< const CVector3f* >(&m20);
|
|
|
|
}
|
|
|
|
|
|
|
|
float Get00() const { return m00; }
|
|
|
|
float Get01() const { return m01; }
|
|
|
|
float Get02() const { return m02; }
|
|
|
|
float Get10() const { return m10; }
|
|
|
|
float Get11() const { return m11; }
|
|
|
|
float Get12() const { return m12; }
|
|
|
|
float Get20() const { return m20; }
|
|
|
|
float Get21() const { return m21; }
|
|
|
|
float Get22() const { return m22; }
|
|
|
|
|
|
|
|
inline CVector3f GetColumn(EDimY dim) const { return CVector3f(m01, m11, m21); }
|
|
|
|
|
|
|
|
static CMatrix3f FromTransform(const CTransform4f& xf); /* {
|
|
|
|
return CMatrix3f(xf.GetRow(kDX), xf.GetRow(kDY), xf.GetRow(kDZ));
|
|
|
|
}*/
|
2022-12-07 05:13:59 +00:00
|
|
|
|
2022-09-18 05:55:13 +00:00
|
|
|
private:
|
2022-10-09 05:37:23 +00:00
|
|
|
// TODO maybe individual floats
|
2024-10-22 23:12:41 +00:00
|
|
|
float m00;
|
|
|
|
float m01;
|
|
|
|
float m02;
|
|
|
|
float m10;
|
|
|
|
float m11;
|
|
|
|
float m12;
|
|
|
|
float m20;
|
|
|
|
float m21;
|
|
|
|
float m22;
|
|
|
|
// CVector3f m0;
|
|
|
|
// CVector3f m1;
|
|
|
|
// CVector3f m2;
|
2022-09-18 05:55:13 +00:00
|
|
|
};
|
|
|
|
CHECK_SIZEOF(CMatrix3f, 0x24);
|
|
|
|
|
2022-10-09 05:13:17 +00:00
|
|
|
#endif // _CMATRIX3F
|