mirror of
https://github.com/recp/cglm.git
synced 2026-02-17 03:39:05 +00:00
quat: create view wmatrix with quaternion helper
This commit is contained in:
@@ -39,6 +39,8 @@
|
||||
|
||||
#include "common.h"
|
||||
#include "vec4.h"
|
||||
#include "mat4.h"
|
||||
#include "mat3.h"
|
||||
|
||||
#ifdef CGLM_SSE_FP
|
||||
# include "simd/sse2/quat.h"
|
||||
@@ -578,4 +580,29 @@ glm_quat_slerp(versor from, versor to, float t, versor dest) {
|
||||
glm_vec4_scale(q1, 1.0f / sinTheta, dest);
|
||||
}
|
||||
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_mat4_mulv(mat4 m, vec4 v, vec4 dest);
|
||||
|
||||
/*!
|
||||
* @brief creates view matrix using quaternion as camera orientation
|
||||
*
|
||||
* @param[in] eye eye
|
||||
* @param[in] ori orientation in world space as quaternion
|
||||
* @param[out] dest view matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_quat_look(vec3 eye, versor ori, mat4 dest) {
|
||||
vec4 t;
|
||||
|
||||
/* orientation */
|
||||
glm_quat_mat4t(ori, dest);
|
||||
|
||||
/* translate */
|
||||
glm_vec4(eye, 1.0f, t);
|
||||
glm_mat4_mulv(dest, t, t);
|
||||
glm_vec_flipsign_to(t, dest[3]);
|
||||
}
|
||||
|
||||
#endif /* cglm_quat_h */
|
||||
|
||||
Reference in New Issue
Block a user