5#ifndef DCPP_MATRIX_HPP_INCLUDED
6#define DCPP_MATRIX_HPP_INCLUDED
8#include <duckcpp/core/engine/irrMath.hpp>
9#include <duckcpp/core/engine/vector3d.hpp>
10#include <duckcpp/core/engine/vector2d.hpp>
11#include <duckcpp/core/engine/plane3d.hpp>
12#include <duckcpp/core/engine/aabbox3d.hpp>
13#include <duckcpp/core/engine/rect.hpp>
14#include <duckcpp/core/engine/irrString.hpp>
26#if defined( USE_MATRIX_TEST_DEBUG )
31 MatrixTest () : ID(0), Calls(0) {}
36static MatrixTest MTest;
60 EM4CONST_INVERSE_TRANSPOSED
87#if defined ( USE_MATRIX_TEST )
99#if defined ( USE_MATRIX_TEST )
110#if defined ( USE_MATRIX_TEST )
122 inline PMatrix4<T>&
operator=(
const PMatrix4<T> &other);
125 inline PMatrix4<T>&
operator=(
const T& scalar);
131#if defined ( USE_MATRIX_TEST )
138 bool operator==(
const PMatrix4<T> &other)
const;
141 bool operator!=(
const PMatrix4<T> &other)
const;
144 PMatrix4<T>
operator+(
const PMatrix4<T>& other)
const;
147 PMatrix4<T>&
operator+=(
const PMatrix4<T>& other);
150 PMatrix4<T>
operator-(
const PMatrix4<T>& other)
const;
153 PMatrix4<T>&
operator-=(
const PMatrix4<T>& other);
157 inline PMatrix4<T>&
setbyproduct(
const PMatrix4<T>& other_a,
const PMatrix4<T>& other_b );
166 PMatrix4<T>
operator*(
const PMatrix4<T>& other)
const;
171 PMatrix4<T>&
operator*=(
const PMatrix4<T>& other);
174 PMatrix4<T>
operator*(
const T& scalar)
const;
241 PMatrix4<T>&
setScale(
const vector3d<T>& scale );
474#if defined ( USE_MATRIX_TEST )
478#if defined ( USE_MATRIX_TEST_DEBUG )
488#if defined ( USE_MATRIX_TEST )
491#if defined ( USE_MATRIX_TEST_DEBUG )
497 case EM4CONST_NOTHING:
500 case EM4CONST_IDENTITY:
501 case EM4CONST_INVERSE:
511#if defined ( USE_MATRIX_TEST )
514#if defined ( USE_MATRIX_TEST_DEBUG )
520 case EM4CONST_IDENTITY:
523 case EM4CONST_NOTHING:
528 case EM4CONST_TRANSPOSED:
529 other.getTransposed(*
this);
531 case EM4CONST_INVERSE:
532 if (!
other.getInverse(*
this))
533 std::fill_n(M, 16, 0);
535 case EM4CONST_INVERSE_TRANSPOSED:
536 if (!
other.getInverse(*
this))
537 std::fill_n(M, 16, 0);
539 *
this=getTransposed();
698#if defined ( USE_MATRIX_TEST )
700 if ( !
other.isIdentity() )
702 if ( this->isIdentity() )
704 return (*
this =
other);
709 return setbyproduct_nocheck(
temp,
other );
715 return setbyproduct_nocheck(
temp,
other );
747#if defined ( USE_MATRIX_TEST )
760#if defined ( USE_MATRIX_TEST )
777#if defined ( USE_MATRIX_TEST )
779 if ( this->isIdentity() )
781 if (
m2.isIdentity() )
826#if defined ( USE_MATRIX_TEST )
838#if defined ( USE_MATRIX_TEST )
850#if defined ( USE_MATRIX_TEST )
876 sqrtf(M[4] * M[4] + M[5] * M[5] + M[6] * M[6]),
877 sqrtf(M[8] * M[8] + M[9] * M[9] + M[10] * M[10]));
915 M[10] = (
T)(
cr*
cp );
916#if defined ( USE_MATRIX_TEST )
960 if (X < 0.0) X += 360.0;
961 if (Y < 0.0) Y += 360.0;
962 if (Z < 0.0) Z += 360.0;
982 if (scale.Y<0 && scale.Z<0)
987 else if (scale.X<0 && scale.Z<0)
992 else if (scale.X<0 && scale.Y<0)
998 return getRotationDegrees(scale);
1013 M[0] = (
T)(
cp*
cy );
1014 M[4] = (
T)(
cp*
sy );
1022 M[9] = (
T)(
sr*
cp );
1026 M[10] = (
T)(
cr*
cp );
1027#if defined ( USE_MATRIX_TEST )
1061#if defined ( USE_MATRIX_TEST )
1073 std::fill_n(M, 16, 0);
1074 M[0] = M[5] = M[10] = M[15] = (
T)1;
1075#if defined ( USE_MATRIX_TEST )
1089#if defined ( USE_MATRIX_TEST )
1116#if defined ( USE_MATRIX_TEST )
1127 T dp=M[0] * M[4 ] + M[1] * M[5 ] + M[2 ] * M[6 ] + M[3 ] * M[7 ];
1130 dp = M[0] * M[8 ] + M[1] * M[9 ] + M[2 ] * M[10] + M[3 ] * M[11];
1133 dp = M[0] * M[12] + M[1] * M[13] + M[2 ] * M[14] + M[3 ] * M[15];
1136 dp = M[4] * M[8 ] + M[5] * M[9 ] + M[6 ] * M[10] + M[7 ] * M[11];
1139 dp = M[4] * M[12] + M[5] * M[13] + M[6 ] * M[14] + M[7 ] * M[15];
1142 dp = M[8] * M[12] + M[9] * M[13] + M[10] * M[14] + M[11] * M[15];
1156#if defined ( USE_MATRIX_TEST )
1160 if(
IR(M[0])!=FLOAT32_VALUE_1)
return false;
1161 if(
IR(M[1])!=0)
return false;
1162 if(
IR(M[2])!=0)
return false;
1163 if(
IR(M[3])!=0)
return false;
1165 if(
IR(M[4])!=0)
return false;
1166 if(
IR(M[5])!=FLOAT32_VALUE_1)
return false;
1167 if(
IR(M[6])!=0)
return false;
1168 if(
IR(M[7])!=0)
return false;
1170 if(
IR(M[8])!=0)
return false;
1171 if(
IR(M[9])!=0)
return false;
1172 if(
IR(M[10])!=FLOAT32_VALUE_1)
return false;
1173 if(
IR(M[11])!=0)
return false;
1175 if(
IR(M[12])!=0)
return false;
1176 if(
IR(M[13])!=0)
return false;
1177 if(
IR(M[13])!=0)
return false;
1178 if(
IR(M[15])!=FLOAT32_VALUE_1)
return false;
1180#if defined ( USE_MATRIX_TEST )
1200 out.X =
in.X*M[0] +
in.Y*M[4] +
in.Z*M[8];
1201 out.Y =
in.X*M[1] +
in.Y*M[5] +
in.Z*M[9];
1202 out.Z =
in.X*M[2] +
in.Y*M[6] +
in.Z*M[10];
1209 out[0] =
in.X*M[0] +
in.Y*M[4] +
in.Z*M[8];
1210 out[1] =
in.X*M[1] +
in.Y*M[5] +
in.Z*M[9];
1211 out[2] =
in.X*M[2] +
in.Y*M[6] +
in.Z*M[10];
1228 vector[0] =
vect.X*M[0] +
vect.Y*M[4] +
vect.Z*M[8] + M[12];
1229 vector[1] =
vect.X*M[1] +
vect.Y*M[5] +
vect.Z*M[9] + M[13];
1230 vector[2] =
vect.X*M[2] +
vect.Y*M[6] +
vect.Z*M[10] + M[14];
1240 out.X =
in.X*M[0] +
in.Y*M[4] +
in.Z*M[8] + M[12];
1241 out.Y =
in.X*M[1] +
in.Y*M[5] +
in.Z*M[9] + M[13];
1242 out.Z =
in.X*M[2] +
in.Y*M[6] +
in.Z*M[10] + M[14];
1249 out[0] =
in.X*M[0] +
in.Y*M[4] +
in.Z*M[8] + M[12];
1250 out[1] =
in.X*M[1] +
in.Y*M[5] +
in.Z*M[9] + M[13];
1251 out[2] =
in.X*M[2] +
in.Y*M[6] +
in.Z*M[10] + M[14];
1252 out[3] =
in.X*M[3] +
in.Y*M[7] +
in.Z*M[11] + M[15];
1258 out[0] =
in[0]*M[0] +
in[1]*M[4] +
in[2]*M[8] + M[12];
1259 out[1] =
in[0]*M[1] +
in[1]*M[5] +
in[2]*M[9] + M[13];
1260 out[2] =
in[0]*M[2] +
in[1]*M[6] +
in[2]*M[10] + M[14];
1266 out[0] =
in[0]*M[0] +
in[1]*M[4] +
in[2]*M[8] +
in[3]*M[12];
1267 out[1] =
in[0]*M[1] +
in[1]*M[5] +
in[2]*M[9] +
in[3]*M[13];
1268 out[2] =
in[0]*M[2] +
in[1]*M[6] +
in[2]*M[10] +
in[3]*M[14];
1269 out[3] =
in[0]*M[3] +
in[1]*M[7] +
in[2]*M[11] +
in[3]*M[15];
1293 transformPlane(
out );
1302#if defined ( USE_MATRIX_TEST )
1316#if defined ( USE_MATRIX_TEST )
1410#if defined ( USE_MATRIX_TEST )
1411 if ( this->isIdentity() )
1420 (
m[0] *
m[6] -
m[2] *
m[4]) * (
m[9] *
m[15] -
m[11] *
m[13]) +
1421 (
m[0] *
m[7] -
m[3] *
m[4]) * (
m[9] *
m[14] -
m[10] *
m[13]) +
1422 (
m[1] *
m[6] -
m[2] *
m[5]) * (
m[8] *
m[15] -
m[11] *
m[12]) -
1423 (
m[1] *
m[7] -
m[3] *
m[5]) * (
m[8] *
m[14] -
m[10] *
m[12]) +
1424 (
m[2] *
m[7] -
m[3] *
m[6]) * (
m[8] *
m[13] -
m[9] *
m[12]);
1429 d = dcpp::nub::reciprocal (
d );
1431 out[0] =
d * (
m[5] * (
m[10] *
m[15] -
m[11] *
m[14]) +
1432 m[6] * (
m[11] *
m[13] -
m[9] *
m[15]) +
1433 m[7] * (
m[9] *
m[14] -
m[10] *
m[13]));
1434 out[1] =
d * (
m[9] * (
m[2] *
m[15] -
m[3] *
m[14]) +
1435 m[10] * (
m[3] *
m[13] -
m[1] *
m[15]) +
1436 m[11] * (
m[1] *
m[14] -
m[2] *
m[13]));
1437 out[2] =
d * (
m[13] * (
m[2] *
m[7] -
m[3] *
m[6]) +
1438 m[14] * (
m[3] *
m[5] -
m[1] *
m[7]) +
1439 m[15] * (
m[1] *
m[6] -
m[2] *
m[5]));
1440 out[3] =
d * (
m[1] * (
m[7] *
m[10] -
m[6] *
m[11]) +
1441 m[2] * (
m[5] *
m[11] -
m[7] *
m[9]) +
1442 m[3] * (
m[6] *
m[9] -
m[5] *
m[10]));
1443 out[4] =
d * (
m[6] * (
m[8] *
m[15] -
m[11] *
m[12]) +
1444 m[7] * (
m[10] *
m[12] -
m[8] *
m[14]) +
1445 m[4] * (
m[11] *
m[14] -
m[10] *
m[15]));
1446 out[5] =
d * (
m[10] * (
m[0] *
m[15] -
m[3] *
m[12]) +
1447 m[11] * (
m[2] *
m[12] -
m[0] *
m[14]) +
1448 m[8] * (
m[3] *
m[14] -
m[2] *
m[15]));
1449 out[6] =
d * (
m[14] * (
m[0] *
m[7] -
m[3] *
m[4]) +
1450 m[15] * (
m[2] *
m[4] -
m[0] *
m[6]) +
1451 m[12] * (
m[3] *
m[6] -
m[2] *
m[7]));
1452 out[7] =
d * (
m[2] * (
m[7] *
m[8] -
m[4] *
m[11]) +
1453 m[3] * (
m[4] *
m[10] -
m[6] *
m[8]) +
1454 m[0] * (
m[6] *
m[11] -
m[7] *
m[10]));
1455 out[8] =
d * (
m[7] * (
m[8] *
m[13] -
m[9] *
m[12]) +
1456 m[4] * (
m[9] *
m[15] -
m[11] *
m[13]) +
1457 m[5] * (
m[11] *
m[12] -
m[8] *
m[15]));
1458 out[9] =
d * (
m[11] * (
m[0] *
m[13] -
m[1] *
m[12]) +
1459 m[8] * (
m[1] *
m[15] -
m[3] *
m[13]) +
1460 m[9] * (
m[3] *
m[12] -
m[0] *
m[15]));
1461 out[10] =
d * (
m[15] * (
m[0] *
m[5] -
m[1] *
m[4]) +
1462 m[12] * (
m[1] *
m[7] -
m[3] *
m[5]) +
1463 m[13] * (
m[3] *
m[4] -
m[0] *
m[7]));
1464 out[11] =
d * (
m[3] * (
m[5] *
m[8] -
m[4] *
m[9]) +
1465 m[0] * (
m[7] *
m[9] -
m[5] *
m[11]) +
1466 m[1] * (
m[4] *
m[11] -
m[7] *
m[8]));
1467 out[12] =
d * (
m[4] * (
m[10] *
m[13] -
m[9] *
m[14]) +
1468 m[5] * (
m[8] *
m[14] -
m[10] *
m[12]) +
1469 m[6] * (
m[9] *
m[12] -
m[8] *
m[13]));
1470 out[13] =
d * (
m[8] * (
m[2] *
m[13] -
m[1] *
m[14]) +
1471 m[9] * (
m[0] *
m[14] -
m[2] *
m[12]) +
1472 m[10] * (
m[1] *
m[12] -
m[0] *
m[13]));
1473 out[14] =
d * (
m[12] * (
m[2] *
m[5] -
m[1] *
m[6]) +
1474 m[13] * (
m[0] *
m[6] -
m[2] *
m[4]) +
1475 m[14] * (
m[1] *
m[4] -
m[0] *
m[5]));
1476 out[15] =
d * (
m[0] * (
m[5] *
m[10] -
m[6] *
m[9]) +
1477 m[1] * (
m[6] *
m[8] -
m[4] *
m[10]) +
1478 m[2] * (
m[4] *
m[9] -
m[5] *
m[8]));
1480#if defined ( USE_MATRIX_TEST )
1507 out.M[12] = (
T)-(M[12]*M[0] + M[13]*M[1] + M[14]*M[2]);
1508 out.M[13] = (
T)-(M[12]*M[4] + M[13]*M[5] + M[14]*M[6]);
1509 out.M[14] = (
T)-(M[12]*M[8] + M[13]*M[9] + M[14]*M[10]);
1512#if defined ( USE_MATRIX_TEST )
1523#if defined ( USE_MATRIX_TEST )
1529 if (getInverse(
temp))
1544 std::copy_n(
other.M, 16, M);
1545#if defined ( USE_MATRIX_TEST )
1558#if defined ( USE_MATRIX_TEST )
1568#if defined ( USE_MATRIX_TEST )
1573 if (M[i] !=
other.M[i])
1583 return !(*
this ==
other);
1628#if defined ( USE_MATRIX_TEST )
1676#if defined ( USE_MATRIX_TEST )
1712#if defined ( USE_MATRIX_TEST )
1758#if defined ( USE_MATRIX_TEST )
1804#if defined ( USE_MATRIX_TEST )
1850#if defined ( USE_MATRIX_TEST )
1896#if defined ( USE_MATRIX_TEST )
1907 plane.Normal.normalize();
1929#if defined ( USE_MATRIX_TEST )
1943 zaxis.normalize_z();
1946 xaxis.normalize_x();
1965 M[12] = (
T)-
xaxis.dotProduct(position);
1966 M[13] = (
T)-
yaxis.dotProduct(position);
1967 M[14] = (
T)-
zaxis.dotProduct(position);
1969#if defined ( USE_MATRIX_TEST )
2006 M[12] = (
T)-
xaxis.dotProduct(position);
2007 M[13] = (
T)-
yaxis.dotProduct(position);
2008 M[14] = (
T)-
zaxis.dotProduct(position);
2010#if defined ( USE_MATRIX_TEST )
2025 mat.M[i+0] = (
T)(M[i+0] + ( b.M[i+0] - M[i+0] ) *
time);
2026 mat.M[i+1] = (
T)(M[i+1] + ( b.M[i+1] - M[i+1] ) *
time);
2027 mat.M[i+2] = (
T)(M[i+2] + ( b.M[i+2] - M[i+2] ) *
time);
2028 mat.M[i+3] = (
T)(M[i+3] + ( b.M[i+3] - M[i+3] ) *
time);
2039 getTransposed (
t );
2067#if defined ( USE_MATRIX_TEST )
2112 T ca = f.dotProduct(
t);
2116 M[0] =
vt.X * v.
X +
ca;
2117 M[5] =
vt.Y * v.
Y +
ca;
2118 M[10] =
vt.Z * v.
Z +
ca;
2177 M[0] =
static_cast<T>(
vt.X *
up.X +
ca);
2178 M[5] =
static_cast<T>(
vt.Y *
up.Y +
ca);
2179 M[10] =
static_cast<T>(
vt.Z *
up.Z +
ca);
2185 M[1] =
static_cast<T>(
vt.X -
vs.Z);
2186 M[2] =
static_cast<T>(
vt.Z +
vs.Y);
2189 M[4] =
static_cast<T>(
vt.X +
vs.Z);
2190 M[6] =
static_cast<T>(
vt.Y -
vs.X);
2193 M[8] =
static_cast<T>(
vt.Z -
vs.Y);
2194 M[9] =
static_cast<T>(
vt.Y +
vs.X);
2209#if defined ( USE_MATRIX_TEST )
2235 M[0] = (
T)(c * scale.
X);
2236 M[1] = (
T)(s * scale.
Y);
2240 M[4] = (
T)(-s * scale.
X);
2241 M[5] = (
T)(c * scale.
Y);
2254#if defined ( USE_MATRIX_TEST )
2273 M[8] = (
T)(0.5f * ( s - c) + 0.5f);
2274 M[9] = (
T)(-0.5f * ( s + c) + 0.5f);
2276#if defined ( USE_MATRIX_TEST )
2289#if defined ( USE_MATRIX_TEST )
2308#if defined ( USE_MATRIX_TEST )
2319#if defined ( USE_MATRIX_TEST )
2337 M[8] = (
T)(0.5f - 0.5f *
sx);
2338 M[9] = (
T)(0.5f - 0.5f *
sy);
2340#if defined ( USE_MATRIX_TEST )
2351 std::copy_n(data, 16, M);
2353#if defined ( USE_MATRIX_TEST )
2364#if defined ( USE_MATRIX_TEST )
2376#if defined ( USE_MATRIX_TEST )
2388#if defined ( USE_MATRIX_TEST )
4x4 matrix. Mostly used as transformation matrix for 3d calculations.
Definition matrix4.hpp:49
vector3d< T > getTranslation() const
Gets the current translation.
Definition matrix4.hpp:814
void transformVect(vector3df &vect) const
Transforms the vector by this matrix.
Definition matrix4.hpp:1224
void transformVec3(T *out, const T *in) const
An alternate transform vector method, reading from and writing to an array of 3 floats.
Definition matrix4.hpp:1256
PMatrix4< T > & setTranslation(const vector3d< T > &translation)
Set the translation of the current matrix. Will erase any previous values.
Definition matrix4.hpp:821
bool isIdentity_integer_base() const
Returns true if the matrix is the identity matrix.
Definition matrix4.hpp:1154
const T & operator[](dcpp::uint32_kt index) const
Simple operator for linearly accessing every element of the matrix.
Definition matrix4.hpp:106
PMatrix4< T > operator+(const PMatrix4< T > &other) const
Add another matrix.
Definition matrix4.hpp:546
PMatrix4< T > & setInverseRotationRadians(const vector3d< T > &rotation)
Make an inverted rotation matrix from Euler angles.
Definition matrix4.hpp:1004
void buildAxisAlignedBillboard(const dcpp::nub::vector3df &camPos, const dcpp::nub::vector3df ¢er, const dcpp::nub::vector3df &translation, const dcpp::nub::vector3df &axis, const dcpp::nub::vector3df &from)
Builds a matrix which rotates a source vector to a look vector over an arbitrary axis.
Definition matrix4.hpp:2152
PMatrix4< T > & setM(const T *data)
Sets all matrix data members at once.
Definition matrix4.hpp:2349
bool isOrthogonal() const
Returns true if the matrix is orthogonal.
Definition matrix4.hpp:1125
PMatrix4< T > & setScale(const vector3d< T > &scale)
Set Scale.
Definition matrix4.hpp:845
void getTextureTranslate(dcpp::float32_kt &x, dcpp::float32_kt &y) const
Get texture transformation translation.
Definition matrix4.hpp:2296
PMatrix4< T > & setTextureScaleCenter(dcpp::float32_kt sx, dcpp::float32_kt sy)
Set texture transformation scale, and recenter at (0.5,0.5)
Definition matrix4.hpp:2333
PMatrix4< T > & setScale(const T scale)
Set Scale.
Definition matrix4.hpp:244
const T * pointer() const
Returns pointer to internal array.
Definition matrix4.hpp:128
PMatrix4< T > & setTextureRotationCenter(dcpp::float32_kt radAngle)
Set texture transformation rotation.
Definition matrix4.hpp:2263
PMatrix4< T > & operator+=(const PMatrix4< T > &other)
Add another matrix.
Definition matrix4.hpp:572
bool operator!=(const PMatrix4< T > &other) const
Returns true if other matrix is not equal to this matrix.
Definition matrix4.hpp:1581
PMatrix4< T > & buildProjectionMatrixPerspectiveFovInfinityLH(dcpp::float32_kt fieldOfViewRadians, dcpp::float32_kt aspectRatio, dcpp::float32_kt zNear, dcpp::float32_kt epsilon=0)
Builds a left-handed perspective projection matrix based on a field of view, with far plane at infini...
Definition matrix4.hpp:1685
void transformBox(dcpp::nub::aabbox3df &box) const
Transforms a axis aligned bounding box.
Definition matrix4.hpp:1300
PMatrix4< T > & setbyproduct_nocheck(const PMatrix4< T > &other_a, const PMatrix4< T > &other_b)
Set this matrix to the product of two matrices.
Definition matrix4.hpp:723
void translateVect(vector3df &vect) const
Translate a vector by the translation part of this matrix.
Definition matrix4.hpp:1395
PMatrix4< T > & setbyproduct(const PMatrix4< T > &other_a, const PMatrix4< T > &other_b)
set this matrix to the product of two matrices
Definition matrix4.hpp:758
void getTextureScale(dcpp::float32_kt &sx, dcpp::float32_kt &sy) const
Get texture transformation scale.
Definition matrix4.hpp:2326
void setRotationCenter(const dcpp::nub::vector3df ¢er, const dcpp::nub::vector3df &translate)
Builds a combined matrix which translates to a center before rotation and translates from origin afte...
Definition matrix4.hpp:2203
dcpp::nub::vector3d< T > getScale() const
Get Scale.
Definition matrix4.hpp:863
PMatrix4< T > & operator=(const PMatrix4< T > &other)
Sets this matrix equal to the other matrix.
Definition matrix4.hpp:1540
void transformPlane(dcpp::nub::plane3df &plane) const
Transforms a plane by this matrix.
Definition matrix4.hpp:1275
PMatrix4< T > & operator-=(const PMatrix4< T > &other)
Subtract another matrix.
Definition matrix4.hpp:622
PMatrix4(const T &r0c0, const T &r0c1, const T &r0c2, const T &r0c3, const T &r1c0, const T &r1c1, const T &r1c2, const T &r1c3, const T &r2c0, const T &r2c1, const T &r2c2, const T &r2c3, const T &r3c0, const T &r3c1, const T &r3c2, const T &r3c3)
Constructor with value initialization.
Definition matrix4.hpp:68
dcpp::nub::vector3d< T > getRotationDegrees() const
Returns the rotation, as set by setRotation().
Definition matrix4.hpp:969
void setDefinitelyIdentityMatrix(bool isDefinitelyIdentityMatrix)
Sets if the matrix is definitely identity matrix.
Definition matrix4.hpp:2362
PMatrix4(eConstructor constructor=EM4CONST_IDENTITY)
Default constructor.
Definition matrix4.hpp:487
PMatrix4< T > & setInverseRotationDegrees(const vector3d< T > &rotation)
Make an inverted rotation matrix from Euler angles.
Definition matrix4.hpp:887
PMatrix4< T > & operator*=(const PMatrix4< T > &other)
Multiply by another matrix.
Definition matrix4.hpp:696
PMatrix4< T > & buildShadowMatrix(const dcpp::nub::vector3df &light, dcpp::nub::plane3df plane, dcpp::float32_kt point=1.0f)
Builds a matrix that flattens geometry into a plane.
Definition matrix4.hpp:1905
void rotateVect(vector3df &vect) const
Transform (rotate/scale) a vector by the rotation part of this matrix.
Definition matrix4.hpp:1188
PMatrix4< T > operator-(const PMatrix4< T > &other) const
Subtract another matrix.
Definition matrix4.hpp:596
void transformBoxEx(dcpp::nub::aabbox3df &box) const
Transforms a axis aligned bounding box.
Definition matrix4.hpp:1314
PMatrix4< T > & setRotationAxisRadians(const T &angle, const vector3d< T > &axis)
Make a rotation matrix from angle and axis, assuming left handed rotation.
Definition matrix4.hpp:1035
PMatrix4< T > & setRotationDegrees(const vector3d< T > &rotation)
Make a rotation matrix from Euler angles. The 4th row and column are unmodified.
Definition matrix4.hpp:881
void inverseRotateVect(vector3df &vect) const
Tranform (rotate/scale) a vector by the inverse of the rotation part this matrix.
Definition matrix4.hpp:1215
const T & operator()(const dcpp::int32_kt row, const dcpp::int32_kt col) const
Simple operator for directly accessing every element of the matrix.
Definition matrix4.hpp:94
void multiplyWith1x4Matrix(T *matrix) const
Multiplies this matrix by a 1x4 matrix.
Definition matrix4.hpp:1365
T & operator[](dcpp::uint32_kt index)
Simple operator for linearly accessing every element of the matrix.
Definition matrix4.hpp:97
PMatrix4< T > getTransposed() const
Gets transposed matrix.
Definition matrix4.hpp:2036
PMatrix4< T > & makeIdentity()
Set matrix to identity.
Definition matrix4.hpp:1071
PMatrix4< T > & setTextureTranslateTransposed(dcpp::float32_kt x, dcpp::float32_kt y)
Set texture transformation translation, using a transposed representation.
Definition matrix4.hpp:2303
PMatrix4< T > interpolate(const dcpp::nub::PMatrix4< T > &b, dcpp::float32_kt time) const
Creates a new matrix as interpolated matrix from two other ones.
Definition matrix4.hpp:2019
eConstructor
Constructor Flags.
Definition matrix4.hpp:54
bool getInverse(PMatrix4< T > &out) const
Gets the inverse matrix of this one.
Definition matrix4.hpp:1404
PMatrix4< T > & buildNDPToDPMatrix(const dcpp::nub::recti &area, dcpp::float32_kt zScale)
Builds a matrix which transforms a normalized Device Coordinate to Device Coordinates.
Definition matrix4.hpp:2075
PMatrix4< T > & setTextureTranslate(dcpp::float32_kt x, dcpp::float32_kt y)
Set texture transformation translation.
Definition matrix4.hpp:2284
PMatrix4< T > & setInverseTranslation(const vector3d< T > &translation)
Set the inverse translation of the current matrix. Will erase any previous values.
Definition matrix4.hpp:833
PMatrix4< T > & setRotationRadians(const vector3d< T > &rotation)
Make a rotation matrix from Euler angles. The 4th row and column are unmodified.
Definition matrix4.hpp:893
bool makeInverse()
Calculates inverse of matrix. Slow.
Definition matrix4.hpp:1521
PMatrix4< T > & buildProjectionMatrixPerspectiveRH(dcpp::float32_kt widthOfViewVolume, dcpp::float32_kt heightOfViewVolume, dcpp::float32_kt zNear, dcpp::float32_kt zFar, bool zClipFromZero=true)
Builds a right-handed perspective projection matrix.
Definition matrix4.hpp:1813
T & operator()(const dcpp::int32_kt row, const dcpp::int32_kt col)
Simple operator for directly accessing every element of the matrix.
Definition matrix4.hpp:85
PMatrix4< T > & buildProjectionMatrixOrthoRH(dcpp::float32_kt widthOfViewVolume, dcpp::float32_kt heightOfViewVolume, dcpp::float32_kt zNear, dcpp::float32_kt zFar, bool zClipFromZero=true)
Builds a right-handed orthogonal projection matrix.
Definition matrix4.hpp:1767
bool getDefinitelyIdentityMatrix() const
Gets if the matrix is definitely identity matrix.
Definition matrix4.hpp:2374
PMatrix4< T > & buildProjectionMatrixPerspectiveFovLH(dcpp::float32_kt fieldOfViewRadians, dcpp::float32_kt aspectRatio, dcpp::float32_kt zNear, dcpp::float32_kt zFar, bool zClipFromZero=true)
Builds a left-handed perspective projection matrix based on a field of view.
Definition matrix4.hpp:1637
void transformVec4(T *out, const T *in) const
An alternate transform vector method, reading from and writing to an array of 4 floats.
Definition matrix4.hpp:1264
bool getInversePrimitive(PMatrix4< T > &out) const
Inverts a primitive matrix which only contains a translation and a rotation.
Definition matrix4.hpp:1490
PMatrix4< T > & buildTextureTransform(dcpp::float32_kt rotateRad, const dcpp::nub::vector2df &rotatecenter, const dcpp::nub::vector2df &translate, const dcpp::nub::vector2df &scale)
Set to a texture transformation matrix with the given parameters.
Definition matrix4.hpp:2227
PMatrix4< T > operator*(const PMatrix4< T > &other) const
Multiply by another matrix.
Definition matrix4.hpp:775
bool equals(const dcpp::nub::PMatrix4< T > &other, const T tolerance=(T) ROUNDING_ERROR_Float64) const
Compare two matrices using the equal method.
Definition matrix4.hpp:2386
PMatrix4< T > & buildCameraLookAtMatrixRH(const vector3df &position, const vector3df &target, const vector3df &upVector)
Builds a right-handed look-at matrix.
Definition matrix4.hpp:1978
PMatrix4< T > & setTextureScale(dcpp::float32_kt sx, dcpp::float32_kt sy)
Set texture transformation scale.
Definition matrix4.hpp:2315
PMatrix4< T > & buildProjectionMatrixPerspectiveFovRH(dcpp::float32_kt fieldOfViewRadians, dcpp::float32_kt aspectRatio, dcpp::float32_kt zNear, dcpp::float32_kt zFar, bool zClipFromZero=true)
Builds a right-handed perspective projection matrix based on a field of view.
Definition matrix4.hpp:1589
PMatrix4< T > & buildProjectionMatrixOrthoLH(dcpp::float32_kt widthOfViewVolume, dcpp::float32_kt heightOfViewVolume, dcpp::float32_kt zNear, dcpp::float32_kt zFar, bool zClipFromZero=true)
Builds a left-handed orthogonal projection matrix.
Definition matrix4.hpp:1721
PMatrix4< T > & buildRotateFromTo(const dcpp::nub::vector3df &from, const dcpp::nub::vector3df &to)
Builds a matrix that rotates from one vector to another.
Definition matrix4.hpp:2096
PMatrix4< T > & buildProjectionMatrixPerspectiveLH(dcpp::float32_kt widthOfViewVolume, dcpp::float32_kt heightOfViewVolume, dcpp::float32_kt zNear, dcpp::float32_kt zFar, bool zClipFromZero=true)
Builds a left-handed perspective projection matrix.
Definition matrix4.hpp:1859
bool isIdentity() const
Returns true if the matrix is the identity matrix.
Definition matrix4.hpp:1087
void inverseTranslateVect(vector3df &vect) const
Translate a vector by the inverse of the translation part of this matrix.
Definition matrix4.hpp:1387
bool operator==(const PMatrix4< T > &other) const
Returns true if other matrix is equal to this matrix.
Definition matrix4.hpp:1566
PMatrix4< T > & buildCameraLookAtMatrixLH(const vector3df &position, const vector3df &target, const vector3df &upVector)
Builds a left-handed look-at matrix.
Definition matrix4.hpp:1937
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.hpp:22
aabbox3d()
Default Constructor.
Definition aabbox3d.hpp:26
void repair()
Repairs the box.
Definition aabbox3d.hpp:180
vector3d< T > MaxEdge
The far edge.
Definition aabbox3d.hpp:418
vector3d< T > MinEdge
The near edge.
Definition aabbox3d.hpp:415
Template plane class with some intersection testing methods.
Definition plane3d.hpp:34
Rectangle template.
Definition rect.hpp:27
2d vector template class with lots of operators and methods.
Definition vector2d.hpp:22
T X
X coordinate of vector.
Definition vector2d.hpp:392
T Y
Y coordinate of vector.
Definition vector2d.hpp:395
3d vector template class with lots of operators and methods.
Definition vector3d.hpp:32
T X
X coordinate of the vector.
Definition vector3d.hpp:459
T Y
Y coordinate of the vector.
Definition vector3d.hpp:462
T Z
Z coordinate of the vector.
Definition vector3d.hpp:465
vector3d< T > & normalize()
Normalizes the vector.
Definition vector3d.hpp:187
dcpp::uint32_kt IR(dcpp::float32_kt x)
Definition irrMath.hpp:387
DUCKCPP_API const matrix4 IdentityMatrix
global const identity matrix
vector3d< T > operator*(const S scalar, const vector3d< T > &vector)
Function multiplying a scalar and a vector component-wise.
Definition vector3d.hpp:497
const dcpp::float32_kt DEGTORAD
32bit Constant for converting from degrees to radians
Definition irrMath.hpp:72
bool equals(const T a, const T b, const T tolerance=roundingError< T >())
returns if a equals b, taking possible rounding errors into account
Definition irrMath.hpp:243
const T clamp(const T &value, const T &low, const T &high)
clamps a value between low and high
Definition irrMath.hpp:164
const dcpp::float64_kt RADTODEG64
64bit constant for converting from radians to degrees
Definition irrMath.hpp:81
bool iszero(const dcpp::float64_kt a, const dcpp::float64_kt tolerance=ROUNDING_ERROR_Float64)
returns if a equals zero, taking rounding errors into account
Definition irrMath.hpp:304
As of Duckcpp 1.6, position2d is a synonym for vector2d.
Definition shared_device.hpp:34
double float64_kt
64 bit floating point variable.
Definition irrTypes.hpp:112
unsigned int uint32_kt
32 bit unsigned variable.
Definition irrTypes.hpp:64
float float32_kt
32 bit floating point variable.
Definition irrTypes.hpp:108
signed int int32_kt
32 bit signed variable.
Definition irrTypes.hpp:72