Ykkrosh
173c56140c
* Skinning is done in a way that works when there's more than one bone influencing a vertex. * PMDs now store vertexes in world-space instead of bind-space. (The loader converts the old-version PMDs so they still work.) * Moved SkinPoint, SkinNormal into CModelDef so it could use them when loading the old PMDs. * Made the FastNormals approach non-optional, so the inverse-transpose bone matrices could be removed. Changed the explanation of why it's a valid approach. * Quaternion: Made GetInverse assume that the quaternions have unit length (which they do when they're representing 3D rotations). * lib: Added support for DDS files that aren't a multiple of 4x4 (most useful for 1x1, 2x2, etc that are still powers of two). * Actor Viewer: Added white terrain texture to the minimal test mod, so shadows are visible. Changed default so walk/run animations don't move the unit along the ground. * Removed some redundant repetition in doc comments. * Removed some unnecessary #includes. This was SVN commit r4696.
62 lines
1.5 KiB
C++
62 lines
1.5 KiB
C++
/************************************************************
|
|
*
|
|
* File Name: Quaternion.H
|
|
*
|
|
* Description:
|
|
*
|
|
************************************************************/
|
|
|
|
#ifndef QUATERNION_H
|
|
#define QUATERNION_H
|
|
|
|
#include "Matrix3D.h"
|
|
#include "Vector3D.h"
|
|
|
|
class CQuaternion
|
|
{
|
|
public:
|
|
CVector3D m_V;
|
|
float m_W;
|
|
|
|
public:
|
|
CQuaternion();
|
|
CQuaternion(float x, float y, float z, float w);
|
|
|
|
// Quaternion addition
|
|
CQuaternion operator + (const CQuaternion &quat) const;
|
|
// Quaternion addition/assignment
|
|
CQuaternion &operator += (const CQuaternion &quat);
|
|
|
|
// Quaternion multiplication
|
|
CQuaternion operator * (const CQuaternion &quat) const;
|
|
// Quaternion multiplication/assignment
|
|
CQuaternion &operator *= (const CQuaternion &quat);
|
|
|
|
void FromEulerAngles (float x, float y, float z);
|
|
CVector3D ToEulerAngles();
|
|
|
|
// Convert the quaternion to matrix
|
|
CMatrix3D ToMatrix() const;
|
|
void ToMatrix(CMatrix3D& result) const;
|
|
|
|
// Sphere interpolation
|
|
void Slerp(const CQuaternion& from, const CQuaternion& to, float ratio);
|
|
|
|
// Create a quaternion from axis/angle representation of a rotation
|
|
void FromAxisAngle(const CVector3D& axis, float angle);
|
|
|
|
// Convert the quaternion to axis/angle representation of a rotation
|
|
void ToAxisAngle(CVector3D& axis, float& angle);
|
|
|
|
// Normalize this quaternion
|
|
void Normalize();
|
|
|
|
// Rotate a vector by this quaternion. Assumes the quaternion is normalised.
|
|
CVector3D Rotate(const CVector3D& vec) const;
|
|
|
|
// Calculate q^-1. Assumes the quaternion is normalised.
|
|
CQuaternion GetInverse() const;
|
|
};
|
|
|
|
#endif
|