mirror of
https://github.com/ScrelliCopter/NeHe-SDL_GPU.git
synced 2025-06-19 21:49:17 +10:00
c: Add matrix scale
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
extern inline void Mtx_Identity(float m[16]);
|
extern inline void Mtx_Identity(float m[16]);
|
||||||
extern inline void Mtx_Translation(float m[16], float x, float y, float z);
|
extern inline void Mtx_Translation(float m[16], float x, float y, float z);
|
||||||
|
extern inline void Mtx_Scaled(float m[16], float x, float y, float z);
|
||||||
|
|
||||||
static void MakeRotation(float m[9], float c, float s, float x, float y, float z)
|
static void MakeRotation(float m[9], float c, float s, float x, float y, float z)
|
||||||
{
|
{
|
||||||
@@ -109,6 +110,19 @@ void Mtx_Translate(float m[16], float x, float y, float z)
|
|||||||
m[15] += x * m[3] + y * m[7] + z * m[11];
|
m[15] += x * m[3] + y * m[7] + z * m[11];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Mtx_Scale(float m[16], float x, float y, float z)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
m = { [x 0 0 0]
|
||||||
|
[0 y 0 0]
|
||||||
|
[0 0 z 0]
|
||||||
|
[0 0 0 1] } * m
|
||||||
|
*/
|
||||||
|
m[0] *= x; m[1] *= x; m[2] *= x; m[3] *= x;
|
||||||
|
m[4] *= y; m[5] *= y; m[6] *= y; m[7] *= y;
|
||||||
|
m[8] *= z; m[9] *= z; m[10] *= z; m[11] *= z;
|
||||||
|
}
|
||||||
|
|
||||||
void Mtx_Rotate(float m[16], float angle, float x, float y, float z)
|
void Mtx_Rotate(float m[16], float angle, float x, float y, float z)
|
||||||
{
|
{
|
||||||
// Set up temporaries
|
// Set up temporaries
|
||||||
|
|||||||
@@ -25,12 +25,24 @@ inline void Mtx_Translation(float m[16], float x, float y, float z)
|
|||||||
}, sizeof(float) * 16);
|
}, sizeof(float) * 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void Mtx_Scaled(float m[16], float x, float y, float z)
|
||||||
|
{
|
||||||
|
SDL_memcpy(m, (float[])
|
||||||
|
{
|
||||||
|
x, 0, 0, 0,
|
||||||
|
0, y, 0, 0,
|
||||||
|
0, 0, z, 0,
|
||||||
|
0, 0, 0, 1
|
||||||
|
}, sizeof(float) * 16);
|
||||||
|
}
|
||||||
|
|
||||||
void Mtx_Rotation(float m[16], float angle, float x, float y, float z);
|
void Mtx_Rotation(float m[16], float angle, float x, float y, float z);
|
||||||
void Mtx_Perspective(float m[16], float fovy, float aspect, float near, float far);
|
void Mtx_Perspective(float m[16], float fovy, float aspect, float near, float far);
|
||||||
|
|
||||||
void Mtx_Multiply(float m[16], const float l[16], const float r[16]);
|
void Mtx_Multiply(float m[16], const float l[16], const float r[16]);
|
||||||
|
|
||||||
void Mtx_Translate(float m[16], float x, float y, float z);
|
void Mtx_Translate(float m[16], float x, float y, float z);
|
||||||
|
void Mtx_Scale(float m[16], float x, float y, float z);
|
||||||
void Mtx_Rotate(float m[16], float angle, float x, float y, float z);
|
void Mtx_Rotate(float m[16], float angle, float x, float y, float z);
|
||||||
|
|
||||||
#endif//MATRIX_H
|
#endif//MATRIX_H
|
||||||
|
|||||||
Reference in New Issue
Block a user