cat3d
A tiny OpenGL 3D engine library written in and for C++.
transform.hpp
1 #pragma once
2 
3 #include <glm/glm.hpp>
4 #include <glm/gtx/quaternion.hpp>
5 
6 namespace cat3d::util {
7 
12 class transform {
13 public:
14  transform();
15 
20  void reset();
21 
26  static const transform identity;
27 
33  glm::mat4 to_mat4() const;
34 
40  void set_pos(glm::vec3 p);
46  glm::vec3 get_pos() const;
53  transform& move(glm::vec3 p);
54 
60  void set_rotation(glm::vec3 angles);
66  glm::vec3 get_rotation() const;
73  transform& rotate(glm::vec3 angles);
74 
80  void set_scale(glm::vec3 s);
86  glm::vec3 get_scale() const;
93  transform& scale(glm::vec3 s);
94 
101  transform operator*(const transform& other) const;
109 
110 private:
112  glm::vec3 m_translation;
113  glm::quat m_rotation;
114  glm::vec3 m_scaling;
115 };
116 
117 }
cat3d::util::transform::get_rotation
glm::vec3 get_rotation() const
Get the transform's rotation.
cat3d::util::transform::operator*
transform operator*(const transform &other) const
Combine two transforms.
cat3d::util::transform::rotate
transform & rotate(glm::vec3 angles)
Rotate by the given euler angle displacement.
cat3d::util::transform::identity
static const transform identity
A copy of the identity matrix.
Definition: transform.hpp:26
cat3d::util::transform::set_pos
void set_pos(glm::vec3 p)
Set the transform's position.
cat3d::util::transform::get_pos
glm::vec3 get_pos() const
Get the transform's position.
cat3d::util::transform::set_scale
void set_scale(glm::vec3 s)
Set the transform's scale.
cat3d::util::transform::to_mat4
glm::mat4 to_mat4() const
Convert the transform to a GLM matrix.
cat3d::util::transform::get_scale
glm::vec3 get_scale() const
Get the transform's scale.
cat3d::util::transform::scale
transform & scale(glm::vec3 s)
Scale the transform.
cat3d::util::transform
Transformation class to manage 3D space transforms.
Definition: transform.hpp:12
cat3d::util::transform::reset
void reset()
Resets the transform back to the identity matrix.
cat3d::util::transform::move
transform & move(glm::vec3 p)
Translate the transform through space.
cat3d::util::transform::set_rotation
void set_rotation(glm::vec3 angles)
Set the transform's rotation.
cat3d::util::transform::operator*=
transform & operator*=(const transform &other)
Combine another transform with this one.