Commit current work

This commit is contained in:
SirLynix
2022-05-13 17:48:35 +02:00
committed by Jérôme Leclercq
parent a7ab2fbaf4
commit b8ea79c40e
12 changed files with 619 additions and 641 deletions

View File

@@ -132,7 +132,7 @@ namespace Nz
static Matrix4 Transform(const Vector3<T>& translation, const Quaternion<T>& rotation);
static Matrix4 Transform(const Vector3<T>& translation, const Quaternion<T>& rotation, const Vector3<T>& scale);
static Matrix4 TransformInverse(const Vector3<T>& translation, const Quaternion<T>& rotation);
static Matrix4 TransformInverse(const Vector3<T>& translation, const Quaternion<T>& rotation, const Vector3<T>&scale);
static Matrix4 TransformInverse(const Vector3<T>& translation, const Quaternion<T>& rotation, const Vector3<T>& scale);
static Matrix4 Zero();
T m11, m12, m13, m14,

View File

@@ -1031,6 +1031,16 @@ namespace Nz
return MakeTransform(-(invRot * translation), invRot);
}
template<typename T>
Matrix4<T>& Matrix4<T>::MakeTransformInverse(const Vector3<T>& translation, const Quaternion<T>& rotation, const Vector3<T>& scale)
{
// A view matrix must apply an inverse transformation of the 'world' matrix
Quaternion<T> invRot = rotation.GetConjugate(); // Inverse of the rotation
Vector3<T> invScale = T(1.0) / scale;
return MakeTransform(-(invScale * (invRot * translation)), invRot, invScale);
}
/*!
* \brief Makes the matrix an inverse transform matrix (aka view matrix)
* \return A reference to this matrix
@@ -1696,6 +1706,15 @@ namespace Nz
return mat;
}
template<typename T>
Matrix4<T> Matrix4<T>::TransformInverse(const Vector3<T>& translation, const Quaternion<T>& rotation, const Vector3<T>& scale)
{
Matrix4 mat;
mat.MakeTransformInverse(translation, rotation, scale);
return mat;
}
/*!
* \brief Shorthand for the 'view' matrix
* \return A Matrix4 which is the 'view matrix'

View File

@@ -13,6 +13,8 @@
#include <Nazara/Core/ResourceLoader.hpp>
#include <Nazara/Core/ResourceManager.hpp>
#include <Nazara/Core/ResourceParameters.hpp>
#include <Nazara/Math/Quaternion.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Utility/Config.hpp>
#include <Nazara/Utility/Enums.hpp>
#include <Nazara/Utils/MovablePtr.hpp>
@@ -32,6 +34,13 @@ namespace Nz
// Reference skeleton
const Skeleton* skeleton = nullptr;
// Transform joints by these transformations
Vector3f jointOffset = Vector3f::Zero();
Quaternionf jointRotation = Quaternionf::Identity();
Vector3f jointScale = Vector3f::Unit();
bool IsValid() const;
};

View File

@@ -38,8 +38,12 @@ namespace Nz
// Buffer usage flags used to build the vertex buffers
BufferUsageFlags vertexBufferFlags = BufferUsage::DirectMapping | BufferUsage::Read | BufferUsage::Write;
// A matrix which will transform every vertex position
Matrix4f matrix = Matrix4f::Identity();
// Transform vertices and joints by these transformations
Vector3f vertexOffset = Vector3f::Zero();
Quaternionf vertexRotation = Quaternionf::Identity();
Vector3f vertexScale = Vector3f::Unit();
// Offset to apply on the texture coordinates (not scaled)
Vector2f texCoordOffset = {0.f, 0.f};