Implement bone matrix computation
This commit is contained in:
1 parent
e81061ad22
commit
998d5e88e1
6 files changed
+132
No files matched your search
@@ -74,3 +74,60 @@ mat4_t mat4_perspective(float aspect, float fov, float near, float far)
|
||||
{ 0, 0, -far * near / (far - near), 0 },
|
||||
};
|
||||
}
|
||||
|
||||
mat4_t mat4_translate_vec3(vec3_t v)
|
||||
{
|
||||
return (mat4_t) {
|
||||
{ 1, 0, 0, 0 },
|
||||
{ 0, 1, 0, 0 },
|
||||
{ 0, 0, 1, 0 },
|
||||
{ v.x, v.y, v.z, 1 },
|
||||
};
|
||||
}
|
||||
|
||||
mat4_t mat4_scale_vec3(vec3_t v)
|
||||
{
|
||||
return (mat4_t) {
|
||||
{ v.x, 0, 0, 0 },
|
||||
{ 0, v.y, 0, 0 },
|
||||
{ 0, 0, v.z, 0 },
|
||||
{ 0, 0, 0, 1 },
|
||||
};
|
||||
}
|
||||
|
||||
mat4_t mat4_rotate_quaternion(vec4_t q)
|
||||
{
|
||||
const float xx = q.x * q.x;
|
||||
const float xy = q.x * q.y;
|
||||
const float xz = q.x * q.z;
|
||||
const float xw = q.x * q.w;
|
||||
|
||||
const float yy = q.y * q.y;
|
||||
const float yz = q.y * q.z;
|
||||
const float yw = q.y * q.w;
|
||||
|
||||
const float zz = q.z * q.z;
|
||||
const float zw = q.z * q.w;
|
||||
|
||||
return (mat4_t) {
|
||||
{
|
||||
1 - 2 * (yy + zz),
|
||||
2 * (xy + zw),
|
||||
2 * (xz - yw),
|
||||
0,
|
||||
},
|
||||
{
|
||||
2 * (xy - zw),
|
||||
1 - 2 * (xx + zz),
|
||||
2 * (yz + xw),
|
||||
0,
|
||||
},
|
||||
{
|
||||
2 * (xz + yw),
|
||||
2 * (yz - xw),
|
||||
1 - 2 * (xx + yy),
|
||||
0,
|
||||
},
|
||||
{ 0, 0, 0, 1 },
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user