click-drag rotation

This commit is contained in:
2018-12-12 02:13:47 -05:00
parent fbdd9ac0df
commit 61d2b3a65b
6 changed files with 127 additions and 24 deletions

28
glapp/include/glmutil.h Normal file
View File

@@ -0,0 +1,28 @@
#ifndef GL_TEMPLATE_GLMUTILS_H
#define GL_TEMPLATE_GLMUTILS_H
#include <glm/mat4x4.hpp>
#include <glm/vec3.hpp>
#include <glm/gtc/matrix_transform.hpp>
namespace glmutil {
glm::mat4 rotation(float angle, glm::vec3 axis) {
auto mat = glm::identity<glm::mat4>();
return glm::rotate(mat, angle, axis);
}
glm::mat4 scale(glm::vec3 v) {
auto mat = glm::identity<glm::mat4>();
return glm::scale(mat, v);
}
glm::mat4 eulerAngles(glm::vec3 angles){
auto mat = glm::identity<glm::mat4>();
mat = glm::rotate(mat, angles.x, glm::vec3(1, 0, 0));
mat = glm::rotate(mat, angles.y, glm::vec3(0, 1, 0));
mat = glm::rotate(mat, angles.z, glm::vec3(0, 0, 1));
return mat;
}
}
#endif //GL_TEMPLATE_GLMUTILS_H