2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-06-27 23:01:55 +00:00

Add generic XModel Export dumper without bone support yet

This commit is contained in:
Jan
2021-08-13 09:40:12 +02:00
parent 56ebbbcfa8
commit 767daca2ea
28 changed files with 1112 additions and 30 deletions

39
src/Utils/Math/Matrix.h Normal file
View File

@ -0,0 +1,39 @@
#pragma once
template <typename T>
class Matrix
{
public:
T m_data[4][4];
Matrix()
: m_data{
{T(1.0), 0, 0, 0},
{0, T(1.0), 0, 0},
{0, 0, T(1.0), 0},
{0, 0, 0, T(1.0)}
}
{
}
Matrix(T d00, T d01, T d02, T d03,
T d10, T d11, T d12, T d13,
T d20, T d21, T d22, T d23,
T d30, T d31, T d32, T d33)
: m_data{
{d00, d01, d02, d03},
{d10, d11, d12, d13},
{d20, d21, d22, d23},
{d30, d31, d32, d33}
}
{
}
static Matrix<T> Identity()
{
return Matrix();
}
};
typedef Matrix<float> Matrix32;
typedef Matrix<double> Matrix64;

View File

@ -0,0 +1,63 @@
#pragma once
#include "Utils/ClassUtils.h"
#include "Matrix.h"
template <typename T>
class Quaternion
{
public:
T m_x;
T m_y;
T m_z;
T m_w;
Quaternion()
{
m_x = T(0);
m_y = T(0);
m_z = T(0);
m_w = T(1);
}
Quaternion(T x, T y, T z, T w)
{
m_x = x;
m_y = y;
m_z = z;
m_w = w;
}
_NODISCARD Matrix<T> ToMatrix() const
{
const T xx = m_x * m_x;
const T xy = m_x * m_y;
const T xz = m_x * m_z;
const T xw = m_x * m_w;
const T yy = m_y * m_y;
const T yz = m_y * m_z;
const T yw = m_y * m_w;
const T zz = m_z * m_z;
const T zw = m_z * m_w;
const T m00 = 1 - 2 * yy - 2 * zz;
const T m01 = 2 * xy - 2 * zw;
const T m02 = 2 * xz + 2 * yw;
const T m10 = 2 * xy + 2 * zw;
const T m11 = 1 - 2 * xx - 2 * zz;
const T m12 = 2 * yz - 2 * xw;
const T m20 = 2 * xz - 2 * yw;
const T m21 = 2 * yz + 2 * xw;
const T m22 = 1 - 2 * xx - 2 * yy;
return Matrix<T>(
m00, m01, m02, 0,
m10, m11, m12, 0,
m20, m21, m22, 0,
0, 0, 0, T(1.0)
);
}
};
typedef Quaternion<float> Quaternion32;
typedef Quaternion<double> Quaternion64;

40
src/Utils/Math/Vector.h Normal file
View File

@ -0,0 +1,40 @@
#pragma once
template<typename T>
class Vector3
{
public:
union
{
struct
{
T m_x;
T m_y;
T m_z;
};
T m_data[3];
} u;
};
typedef Vector3<float> Vector3f;
typedef Vector3<double> Vector3d;
template<typename T>
class Vector4
{
public:
union
{
struct
{
T m_x;
T m_y;
T m_z;
T m_w;
};
T m_data[4];
} u;
};
typedef Vector3<float> Vector4f;
typedef Vector3<double> Vector4d;