2022-10-09 05:13:17 +00:00
|
|
|
#ifndef _CTRANSFORM4F
|
|
|
|
#define _CTRANSFORM4F
|
2022-07-02 05:30:04 +00:00
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
|
2022-08-09 23:03:51 +00:00
|
|
|
#include "Kyoto/Math/CVector3f.hpp"
|
2022-07-02 05:30:04 +00:00
|
|
|
|
2022-10-09 05:37:23 +00:00
|
|
|
typedef const float (*ConstMtxPtr)[4];
|
2022-09-05 04:00:04 +00:00
|
|
|
|
2022-08-13 04:32:42 +00:00
|
|
|
class CInputStream;
|
|
|
|
class CMatrix3f;
|
2022-10-03 04:49:11 +00:00
|
|
|
class CRelAngle;
|
2022-08-13 04:32:42 +00:00
|
|
|
|
2022-07-02 05:30:04 +00:00
|
|
|
class CTransform4f {
|
|
|
|
public:
|
2022-09-05 04:00:04 +00:00
|
|
|
CTransform4f(const CVector3f& m0, const CVector3f& m1, const CVector3f& m2, const CVector3f& pos)
|
|
|
|
: m0(m0), posX(pos.GetX()), m1(m1), posY(pos.GetY()), m2(m2), posZ(pos.GetZ()) {}
|
2022-10-09 05:37:23 +00:00
|
|
|
CTransform4f(float, float, float, float, float, float, float, float, float, float, float, float);
|
2022-10-07 04:23:10 +00:00
|
|
|
CTransform4f(CInputStream& in);
|
2022-08-13 04:32:42 +00:00
|
|
|
CTransform4f(const CMatrix3f& rotation, const CVector3f& translation);
|
|
|
|
CTransform4f(const CTransform4f& other);
|
|
|
|
CTransform4f& operator=(const CTransform4f& other);
|
|
|
|
|
|
|
|
CVector3f GetTranslation() const { return CVector3f(posX, posY, posZ); }
|
|
|
|
CVector3f GetRight() const { return CVector3f(m0.GetX(), m1.GetX(), m2.GetX()); }
|
|
|
|
CVector3f GetForward() const { return CVector3f(m0.GetY(), m1.GetY(), m2.GetY()); }
|
|
|
|
CVector3f GetUp() const { return CVector3f(m0.GetZ(), m1.GetZ(), m2.GetZ()); }
|
2022-09-18 06:05:46 +00:00
|
|
|
ConstMtxPtr GetCStyleMatrix() const { return reinterpret_cast< ConstMtxPtr >(this); }
|
2022-08-13 04:32:42 +00:00
|
|
|
|
|
|
|
CMatrix3f BuildMatrix3f() const;
|
2022-10-09 05:37:23 +00:00
|
|
|
float Get00() const { return m0.GetX(); }
|
|
|
|
float Get01() const { return m0.GetY(); }
|
|
|
|
float Get02() const { return m0.GetZ(); }
|
|
|
|
float Get03() const { return posX; }
|
|
|
|
float Get10() const { return m1.GetX(); }
|
|
|
|
float Get11() const { return m1.GetY(); }
|
|
|
|
float Get12() const { return m1.GetZ(); }
|
|
|
|
float Get13() const { return posY; }
|
|
|
|
float Get20() const { return m2.GetX(); }
|
|
|
|
float Get21() const { return m2.GetY(); }
|
|
|
|
float Get22() const { return m2.GetZ(); }
|
|
|
|
float Get23() const { return posZ; }
|
2022-10-08 05:12:48 +00:00
|
|
|
CVector3f GetColumn(EDimX dim) const { return CVector3f(m0[dim], m1[dim], m2[dim]); }
|
|
|
|
CVector3f GetColumn(EDimY dim) const { return CVector3f(m0[dim], m1[dim], m2[dim]); }
|
|
|
|
CVector3f GetColumn(EDimZ dim) const { return CVector3f(m0[dim], m1[dim], m2[dim]); }
|
2022-08-13 04:32:42 +00:00
|
|
|
// GetColumn__12CTransform4fCFi
|
|
|
|
// GetCStyleMatrix__12CTransform4fCFv
|
2022-09-29 05:30:20 +00:00
|
|
|
CTransform4f GetInverse() const;
|
2022-09-05 04:00:04 +00:00
|
|
|
CTransform4f GetQuickInverse() const;
|
2022-09-29 05:30:20 +00:00
|
|
|
CTransform4f GetRotation() const;
|
2022-09-05 04:00:04 +00:00
|
|
|
inline const CVector3f& GetRow(EDimX dim) const { return m0; }
|
|
|
|
inline const CVector3f& GetRow(EDimY dim) const { return m1; }
|
|
|
|
inline const CVector3f& GetRow(EDimZ dim) const { return m2; }
|
2022-10-09 20:54:18 +00:00
|
|
|
inline const CVector3f& GetRow(int i) const {
|
|
|
|
return *(reinterpret_cast< const CVector3f* >(reinterpret_cast< const float* >(&m0) + i * 4));
|
|
|
|
}
|
2022-08-13 04:32:42 +00:00
|
|
|
// GetUp__12CTransform4fCFv
|
2022-09-29 05:30:20 +00:00
|
|
|
static CTransform4f LookAt(const CVector3f& pos, const CVector3f& lookPos,
|
|
|
|
const CVector3f& up = CVector3f::Up());
|
2022-08-13 04:32:42 +00:00
|
|
|
// MakeRotationsBasedOnY__12CTransform4fFRC13CUnitVector3f
|
2022-09-05 04:00:04 +00:00
|
|
|
CTransform4f MultiplyIgnoreTranslation(const CTransform4f& other) const;
|
2022-08-13 04:32:42 +00:00
|
|
|
// Orthonormalize__12CTransform4fFv
|
2022-09-19 04:19:46 +00:00
|
|
|
CVector3f Rotate(const CVector3f& in) const;
|
2022-10-03 04:49:11 +00:00
|
|
|
void RotateLocalX(const CRelAngle& angle);
|
|
|
|
void RotateLocalY(const CRelAngle& angle);
|
|
|
|
void RotateLocalZ(const CRelAngle& angle);
|
2022-11-14 13:37:44 +00:00
|
|
|
static CTransform4f RotateX(const CRelAngle&);
|
|
|
|
static CTransform4f RotateY(const CRelAngle&);
|
2022-10-09 14:31:10 +00:00
|
|
|
static CTransform4f RotateZ(const CRelAngle&);
|
2022-10-28 21:42:35 +00:00
|
|
|
static CTransform4f Scale(float);
|
|
|
|
static CTransform4f Scale(float, float, float);
|
2022-10-03 13:15:34 +00:00
|
|
|
static CTransform4f Scale(const CVector3f&);
|
2022-08-13 04:32:42 +00:00
|
|
|
// ScaleBy__12CTransform4fFf
|
|
|
|
// SetRotation__12CTransform4fFRC12CTransform4f
|
|
|
|
// SetRotation__12CTransform4fFRC9CMatrix3f
|
|
|
|
// TransposeMultiply__12CTransform4fCFRC9CVector3f
|
2022-09-18 17:51:07 +00:00
|
|
|
CVector3f TransposeRotate(const CVector3f& in) const;
|
2022-08-13 04:32:42 +00:00
|
|
|
|
|
|
|
void SetTranslation(const CVector3f& vec) {
|
|
|
|
posX = vec.GetX();
|
|
|
|
posY = vec.GetY();
|
|
|
|
posZ = vec.GetZ();
|
|
|
|
}
|
|
|
|
void AddTranslation(const CVector3f& vec) {
|
|
|
|
posX += vec.GetX();
|
|
|
|
posY += vec.GetY();
|
|
|
|
posZ += vec.GetZ();
|
|
|
|
}
|
2022-10-09 05:37:23 +00:00
|
|
|
void AddTranslationZ(float z) { posZ += z; }
|
2022-08-13 04:32:42 +00:00
|
|
|
|
|
|
|
CTransform4f& operator*=(const CTransform4f& other);
|
2022-09-05 04:00:04 +00:00
|
|
|
CTransform4f operator*(const CTransform4f& vec) const;
|
2022-09-29 05:30:20 +00:00
|
|
|
CVector3f operator*(const CVector3f& vec) const;
|
2022-08-13 04:32:42 +00:00
|
|
|
|
2022-09-18 06:05:46 +00:00
|
|
|
static CTransform4f FromColumns(const CVector3f&, const CVector3f&, const CVector3f&,
|
|
|
|
const CVector3f&);
|
2022-10-09 05:37:23 +00:00
|
|
|
static CTransform4f Translate(float x, float y, float z);
|
2022-09-29 23:55:38 +00:00
|
|
|
static CTransform4f Translate(const CVector3f& vec);
|
|
|
|
|
2022-08-30 04:05:16 +00:00
|
|
|
static const CTransform4f& Identity() { return sIdentity; }
|
2022-08-13 04:32:42 +00:00
|
|
|
|
|
|
|
private:
|
2022-07-02 05:30:04 +00:00
|
|
|
CVector3f m0;
|
2022-10-09 05:37:23 +00:00
|
|
|
float posX;
|
2022-07-02 05:30:04 +00:00
|
|
|
CVector3f m1;
|
2022-10-09 05:37:23 +00:00
|
|
|
float posY;
|
2022-07-02 05:30:04 +00:00
|
|
|
CVector3f m2;
|
2022-10-09 05:37:23 +00:00
|
|
|
float posZ;
|
2022-08-30 04:05:16 +00:00
|
|
|
|
|
|
|
static CTransform4f sIdentity;
|
2022-07-02 05:30:04 +00:00
|
|
|
};
|
|
|
|
|
2022-08-13 04:32:42 +00:00
|
|
|
inline bool operator==(const CTransform4f& lhs, const CTransform4f& rhs);
|
2022-07-02 05:30:04 +00:00
|
|
|
|
2022-08-13 01:26:00 +00:00
|
|
|
CHECK_SIZEOF(CTransform4f, 0x30)
|
|
|
|
|
2022-10-09 05:13:17 +00:00
|
|
|
#endif // _CTRANSFORM4F
|