Pārlūkot izejas kodu

adding Matrix MatrixCompose( translate, rotation, scale ) to raymath.h (#5324)

pull/5325/head
EDBC_REPO pirms 1 dienas
committed by GitHub
vecāks
revīzija
81004135a4
Šim parakstam datu bāzē netika atrasta zināma atslēga GPG atslēgas ID: B5690EEEBB952194
1 mainītis faili ar 32 papildinājumiem un 0 dzēšanām
  1. +32
    -0
      src/raymath.h

+ 32
- 0
src/raymath.h Parādīt failu

@ -2552,6 +2552,38 @@ RMAPI int QuaternionEquals(Quaternion p, Quaternion q)
return result;
}
// Compose a transformation matrix from rotational, translational and scaling components
RMAPI Matrix MatrixCompose( Vector3 translation, Quaternion rotation, Vector3 scale )
{
//Initialize Vectors
Vector3 right = { 1, 0, 0 };
Vector3 up = { 0, 1, 0 };
Vector3 forward = { 0, 0, 1 };
//Scale Vectors
right = Vector3Scale( right , scale.x );
up = Vector3Scale( up , scale.y );
forward = Vector3Scale( forward , scale.z );
//Rotate Vectors
right = Vector3RotateByQuaternion( right , rotation );
up = Vector3RotateByQuaternion( up , rotation );
forward = Vector3RotateByQuaternion( forward, rotation );
// Set matrix output
Matrix result = {
right.x, up.x, forward.x, position.x,
right.y, up.y, forward.y, position.y,
right.z, up.z, forward.z, position.z,
0, 0, 0, 1
};
// Return matrix output
return result;
}
// Decompose a transformation matrix into its rotational, translational and scaling components and remove shear
RMAPI void MatrixDecompose(Matrix mat, Vector3 *translation, Quaternion *rotation, Vector3 *scale)
{

Notiek ielāde…
Atcelt
Saglabāt