From c272fd263e37b05aaac06ad4be0f8cbb77e6009b Mon Sep 17 00:00:00 2001 From: Joey de Vries Date: Sun, 7 Feb 2021 20:37:11 +0100 Subject: [PATCH] Add assimp glm helpers. --- includes/learnopengl/assimp_glm_helpers.h | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 includes/learnopengl/assimp_glm_helpers.h diff --git a/includes/learnopengl/assimp_glm_helpers.h b/includes/learnopengl/assimp_glm_helpers.h new file mode 100644 index 0000000..960c1d9 --- /dev/null +++ b/includes/learnopengl/assimp_glm_helpers.h @@ -0,0 +1,34 @@ +#pragma once + +#include +#include +#include +#include +#include + + +class AssimpGLMHelpers +{ +public: + + static inline glm::mat4 ConvertMatrixToGLMFormat(const aiMatrix4x4& from) + { + glm::mat4 to; + //the a,b,c,d in assimp is the row ; the 1,2,3,4 is the column + to[0][0] = from.a1; to[1][0] = from.a2; to[2][0] = from.a3; to[3][0] = from.a4; + to[0][1] = from.b1; to[1][1] = from.b2; to[2][1] = from.b3; to[3][1] = from.b4; + to[0][2] = from.c1; to[1][2] = from.c2; to[2][2] = from.c3; to[3][2] = from.c4; + to[0][3] = from.d1; to[1][3] = from.d2; to[2][3] = from.d3; to[3][3] = from.d4; + return to; + } + + static inline glm::vec3 GetGLMVec(const aiVector3D& vec) + { + return glm::vec3(vec.x, vec.y, vec.z); + } + + static inline glm::quat GetGLMQuat(const aiQuaternion& pOrientation) + { + return glm::quat(pOrientation.w, pOrientation.x, pOrientation.y, pOrientation.z); + } +}; \ No newline at end of file