i done messed up
This commit is contained in:
@@ -79,6 +79,18 @@ static inline const gnMat4x4 gnRotate(gnVec3 axis, float rotation) {
|
||||
return rotate;
|
||||
}
|
||||
|
||||
static inline const gnMat4x4 gnScale(gnVec3 amount) {
|
||||
gnMat4 rotate = {
|
||||
.mat = {
|
||||
{ amount.x, 0.0f, 0.0f, 0.0f },
|
||||
{ 0.0f, amount.y, 0.0f, 0.0f },
|
||||
{ 0.0f, 0.0f, amount.z, 0.0f },
|
||||
{ 0.0f, 0.0f, 0.0f, 1.0f }
|
||||
}
|
||||
};
|
||||
return rotate;
|
||||
}
|
||||
|
||||
// used GLMs lookAtLH from /glm/ext/matrix_transform.inl as a base
|
||||
static inline const gnMat4x4 gnLookAt(gnVec3 eye, gnVec3 center, gnVec3 up) {
|
||||
const gnVec3 f = gnVec3Normalize(gnVec3Subtract(center, eye));
|
||||
@@ -94,3 +106,24 @@ static inline const gnMat4x4 gnLookAt(gnVec3 eye, gnVec3 center, gnVec3 up) {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static inline const gnMat4x4 gnMultiply(gnMat4 a, gnMat4 b) {
|
||||
gnMat4 result;
|
||||
|
||||
for (int row = 0; row < 4; ++row)
|
||||
for (int col = 0; col < 4; ++col)
|
||||
result.mat[row][col] = a.mat[row][0] * b.mat[0][col] +
|
||||
a.mat[row][1] * b.mat[1][col] +
|
||||
a.mat[row][2] * b.mat[2][col] +
|
||||
a.mat[row][3] * b.mat[3][col];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline const gnVec3 gnMat4MultiplyVec3(gnMat4 m, gnVec3 v) {
|
||||
gnVec3 result;
|
||||
result.x = m.mat[0][0] * v.x + m.mat[1][0] * v.y + m.mat[2][0] * v.z + m.mat[3][0];
|
||||
result.y = m.mat[0][1] * v.x + m.mat[1][1] * v.y + m.mat[2][1] * v.z + m.mat[3][1];
|
||||
result.z = m.mat[0][2] * v.x + m.mat[1][2] * v.y + m.mat[2][2] * v.z + m.mat[3][2];
|
||||
return result;
|
||||
}
|
||||
|
@@ -35,7 +35,8 @@ static const inline gnVec3 gnVec3Normalize(gnVec3 in) {
|
||||
}
|
||||
static const inline gnVec3 gnVec3Cross(gnVec3 a, gnVec3 b) { return (gnVec3){a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x}; }
|
||||
static const inline float gnVec3Dot(gnVec3 a, gnVec3 b) { return a.x * b.x + a.y * b.y + a.z * b.z; }
|
||||
|
||||
static const inline gnVec3 gnVec3Multiply(gnVec3 a, gnVec3 b) { return (gnVec3){ a.x * b.x, a.y * b.y, a.z * b.z }; }
|
||||
static const inline gnVec3 gnVec3MultiplyBy(gnVec3 a, float b) { return (gnVec3){ a.x * b, a.y * b, a.z * b }; }
|
||||
|
||||
typedef gnVec3 gnFVec3;
|
||||
typedef gnVec3 gnFloat3;
|
||||
|
Reference in New Issue
Block a user