mirror of
https://github.com/PrimeDecomp/prime.git
synced 2025-12-08 15:04:54 +00:00
Start filling out CVector3f/CTransform4f
This commit is contained in:
@@ -5,22 +5,102 @@
|
||||
|
||||
#include "Kyoto/Math/CVector3f.hpp"
|
||||
|
||||
class CInputStream;
|
||||
class CMatrix3f;
|
||||
|
||||
class CTransform4f {
|
||||
public:
|
||||
CTransform4f() {
|
||||
// TODO
|
||||
}
|
||||
CTransform4f(f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32, f32);
|
||||
CTransform4f(const CInputStream& in);
|
||||
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()); }
|
||||
|
||||
CMatrix3f BuildMatrix3f() const;
|
||||
// Get00__12CTransform4fCFv
|
||||
// Get01__12CTransform4fCFv
|
||||
// Get02__12CTransform4fCFv
|
||||
// Get03__12CTransform4fCFv
|
||||
// Get10__12CTransform4fCFv
|
||||
// Get11__12CTransform4fCFv
|
||||
// Get12__12CTransform4fCFv
|
||||
// Get13__12CTransform4fCFv
|
||||
// Get20__12CTransform4fCFv
|
||||
// Get21__12CTransform4fCFv
|
||||
// Get22__12CTransform4fCFv
|
||||
// Get23__12CTransform4fCFv
|
||||
// GetColumn__12CTransform4fCF5EDimX
|
||||
// GetColumn__12CTransform4fCF5EDimY
|
||||
// GetColumn__12CTransform4fCF5EDimZ
|
||||
// GetColumn__12CTransform4fCFi
|
||||
// GetCStyleMatrix__12CTransform4fCFv
|
||||
// GetInverse__12CTransform4fCFv
|
||||
// GetQuickInverse__12CTransform4fCFv
|
||||
// GetRotation__12CTransform4fCFv
|
||||
// GetRow__12CTransform4fCF5EDimX
|
||||
// GetRow__12CTransform4fCF5EDimY
|
||||
// GetRow__12CTransform4fCF5EDimZ
|
||||
// GetRow__12CTransform4fCFi
|
||||
// GetUp__12CTransform4fCFv
|
||||
// LookAt__12CTransform4fFRC9CVector3fRC9CVector3fRC9CVector3f
|
||||
// MakeRotationsBasedOnY__12CTransform4fFRC13CUnitVector3f
|
||||
// MultiplyIgnoreTranslation__12CTransform4fCFRC12CTransform4f
|
||||
// Orthonormalize__12CTransform4fFv
|
||||
// Rotate__12CTransform4fCFRC9CVector3f
|
||||
// RotateLocalX__12CTransform4fFRC9CRelAngle
|
||||
// RotateLocalY__12CTransform4fFRC9CRelAngle
|
||||
// RotateLocalZ__12CTransform4fFRC9CRelAngle
|
||||
// RotateX__12CTransform4fFRC9CRelAngle
|
||||
// RotateY__12CTransform4fFRC9CRelAngle
|
||||
// RotateZ__12CTransform4fFRC9CRelAngle
|
||||
// Scale__12CTransform4fFf
|
||||
// Scale__12CTransform4fFfff
|
||||
// Scale__12CTransform4fFRC9CVector3f
|
||||
// ScaleBy__12CTransform4fFf
|
||||
// SetRotation__12CTransform4fFRC12CTransform4f
|
||||
// SetRotation__12CTransform4fFRC9CMatrix3f
|
||||
// Translate__12CTransform4fFfff
|
||||
// Translate__12CTransform4fFRC9CVector3f
|
||||
// TransposeMultiply__12CTransform4fCFRC9CVector3f
|
||||
// TransposeRotate__12CTransform4fCFRC9CVector3f
|
||||
|
||||
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();
|
||||
}
|
||||
void AddTranslationZ(f32 z) { posZ += z; }
|
||||
|
||||
CTransform4f& operator*=(const CTransform4f& other);
|
||||
CTransform4f& operator*(const CTransform4f& vec);
|
||||
CTransform4f& operator*(const CVector3f& vec);
|
||||
|
||||
static CTransform4f FromColumns(const CVector3f&, const CVector3f&, const CVector3f&, const CVector3f&);
|
||||
static CTransform4f sIdentity;
|
||||
|
||||
private:
|
||||
CVector3f m0;
|
||||
f32 posX;
|
||||
CVector3f m1;
|
||||
f32 posY;
|
||||
CVector3f m2;
|
||||
f32 posZ;
|
||||
|
||||
CTransform4f() {
|
||||
// TODO
|
||||
}
|
||||
CTransform4f(const CTransform4f& other);
|
||||
};
|
||||
|
||||
extern CTransform4f skIdentity4f;
|
||||
inline bool operator==(const CTransform4f& lhs, const CTransform4f& rhs);
|
||||
|
||||
CHECK_SIZEOF(CTransform4f, 0x30)
|
||||
|
||||
|
||||
@@ -3,19 +3,109 @@
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#include "Kyoto/Math/CVector2f.hpp"
|
||||
|
||||
class CInputStream;
|
||||
class COutputStream;
|
||||
|
||||
class CVector3f {
|
||||
public:
|
||||
CVector3f() : mX(0.f), mY(0.f), mZ(0.f) {}
|
||||
explicit CVector3f(f32 x, f32 y, f32 z) : mX(x), mY(y), mZ(z) {}
|
||||
CVector3f(const CVector2f& v, f32 z) : mX(v.GetX()), mY(v.GetY()), mZ(z) {}
|
||||
|
||||
CVector3f(CInputStream& in);
|
||||
void PutTo(COutputStream& out) const;
|
||||
|
||||
f32 GetX() const { return mX; }
|
||||
f32 GetY() const { return mY; }
|
||||
f32 GetZ() const { return mZ; }
|
||||
|
||||
// private:
|
||||
void SetX(f32 x) { mX = x; }
|
||||
void SetY(f32 y) { mY = y; }
|
||||
void SetZ(f32 z) { mZ = z; }
|
||||
|
||||
// ByElementMultiply__9CVector3fFRC9CVector3fRC9CVector3f
|
||||
// Slerp__9CVector3fFRC9CVector3fRC9CVector3fRC9CRelAngle
|
||||
// Normalize__9CVector3fFv
|
||||
// Magnitude__9CVector3fCFv
|
||||
// AsNormalized__9CVector3fCFv
|
||||
// CanBeNormalized__9CVector3fCFv
|
||||
// GetAngleDiff__9CVector3fFRC9CVector3fRC9CVector3f
|
||||
// IsEqu__9CVector3fCFRC9CVector3ff
|
||||
// Lerp__9CVector3fFRC9CVector3fRC9CVector3ff
|
||||
|
||||
f32& operator[](s32 i) { return *(&mX + i); }
|
||||
f32 operator[](s32 i) const { return *(&mX + i); }
|
||||
bool IsNonZero() const { return mX != 0.f || mY != 0.f || mZ != 0.f; }
|
||||
|
||||
void DropZ() { mZ = 0.f; }
|
||||
|
||||
CVector3f& operator+=(const CVector3f& other) {
|
||||
mX += other.mX;
|
||||
mY += other.mY;
|
||||
mZ += other.mZ;
|
||||
return *this;
|
||||
}
|
||||
CVector3f& operator-=(const CVector3f& other) {
|
||||
mX -= other.mX;
|
||||
mY -= other.mY;
|
||||
mZ -= other.mZ;
|
||||
return *this;
|
||||
}
|
||||
CVector3f& operator*=(f32 v) {
|
||||
mX *= v;
|
||||
mY *= v;
|
||||
mZ *= v;
|
||||
return *this;
|
||||
}
|
||||
CVector3f& operator/=(f32 v) {
|
||||
mX /= v;
|
||||
mY /= v;
|
||||
mZ /= v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
static const CVector3f& Zero() { return sZeroVector; }
|
||||
static const CVector3f& Up() { return sUpVector; }
|
||||
static const CVector3f& Down() { return sDownVector; }
|
||||
static const CVector3f& Left() { return sLeftVector; }
|
||||
static const CVector3f& Right() { return sRightVector; }
|
||||
static const CVector3f& Forward() { return sForwardVector; }
|
||||
static const CVector3f& Back() { return sBackVector; }
|
||||
|
||||
private:
|
||||
f32 mX;
|
||||
f32 mY;
|
||||
f32 mZ;
|
||||
|
||||
static CVector3f sZeroVector;
|
||||
static CVector3f sUpVector;
|
||||
static CVector3f sDownVector;
|
||||
static CVector3f sLeftVector;
|
||||
static CVector3f sRightVector;
|
||||
static CVector3f sForwardVector;
|
||||
static CVector3f sBackVector;
|
||||
};
|
||||
|
||||
// ClassifyVector__FRC9CVector3f
|
||||
// TGetType<9CVector3f>__FRC9CVector3f
|
||||
// close_enough__FRC9CVector3fRC9CVector3ff in CloseEnough.cpp
|
||||
|
||||
inline bool operator==(const CVector3f& lhs, const CVector3f& rhs) {
|
||||
return lhs.GetX() == rhs.GetX() && lhs.GetY() == rhs.GetY() && lhs.GetZ() == rhs.GetZ();
|
||||
}
|
||||
inline bool operator!=(const CVector3f& lhs, const CVector3f& rhs) {
|
||||
return lhs.GetX() != rhs.GetX() || lhs.GetY() != rhs.GetY() || lhs.GetZ() != rhs.GetZ();
|
||||
}
|
||||
inline CVector3f operator-(const CVector3f& lhs, const CVector3f& rhs) {
|
||||
return CVector3f(lhs.GetX() - rhs.GetX(), lhs.GetY() - rhs.GetY(), lhs.GetZ() - rhs.GetZ());
|
||||
}
|
||||
inline CVector3f operator+(const CVector3f& lhs, const CVector3f& rhs) {
|
||||
return CVector3f(lhs.GetX() + rhs.GetX(), lhs.GetY() + rhs.GetY(), lhs.GetZ() + rhs.GetZ());
|
||||
}
|
||||
inline CVector3f operator*(const CVector3f& vec, f32 f) { return CVector3f(vec.GetX() * f, vec.GetY() * f, vec.GetZ() * f); }
|
||||
inline CVector3f operator/(const CVector3f& vec, f32 f) { return CVector3f(vec.GetX() / f, vec.GetY() / f, vec.GetZ() / f); }
|
||||
inline CVector3f operator-(const CVector3f& vec) { return CVector3f(-vec.GetX(), -vec.GetY(), -vec.GetZ()); }
|
||||
|
||||
#endif // __CVECTOR3F_HPP__
|
||||
|
||||
Reference in New Issue
Block a user