Skip to content

Instantly share code, notes, and snippets.

@alanhaugen
Created August 30, 2020 17:34
Show Gist options
  • Save alanhaugen/1872f5950c4912f78cf6be0323614f0e to your computer and use it in GitHub Desktop.
Save alanhaugen/1872f5950c4912f78cf6be0323614f0e to your computer and use it in GitHub Desktop.
#include "mat.h"
Mat::Mat()
: matrix(glm::mat4())
{
rotation = glm::quat();
position = glm::vec3();
scale = glm::vec3(1.0f);
}
Mat::Mat(glm::mat4 matrix_)
: matrix(matrix_)
{
rotation = glm::quat();
position = glm::vec3();
scale = glm::vec3(1.0f);
}
void Mat::Translate(glm::vec3 pos)
{
matrix = glm::translate(matrix, pos) * matrix;
}
/*void Mat::Translate(glm::vec4 pos)
{
//matrix[3] += pos; // Not correct???
}*/
void Mat::Scale(glm::vec3 scale)
{
matrix = glm::scale(matrix, scale) * matrix;
}
void Mat::Rotate(glm::vec4 rotation)
{
glm::quat quat(rotation.w, rotation.x, rotation.y, rotation.z);
matrix = glm::mat4_cast(quat) * matrix;
}
void Mat::Rotate(glm::quat quat)
{
matrix = glm::mat4_cast(quat) * matrix;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment