GameKit  0.0.1a
C++ gamedev tools
Transformable.hpp
Go to the documentation of this file.
1 /*
2  * =====================================================================================
3  *
4  * Filename: Transformable.hpp
5  *
6  * Description:
7  *
8  * Created: 11/11/2018 18:06:05
9  *
10  * Author: Quentin Bazin, <quent42340@gmail.com>
11  *
12  * =====================================================================================
13  */
14 #ifndef GK_TRANSFORMABLE_HPP_
15 #define GK_TRANSFORMABLE_HPP_
16 
17 #include "gk/gl/Transform.hpp"
18 
19 namespace gk {
20 
22  public:
23  virtual ~Transformable() = default;
24 
25  void setPosition(float x, float y, float z = 0);
26  void setPosition(const Vector3f &position) { setPosition(position.x, position.y, position.z); }
27 
28  void setOrigin(float x, float y, float z = 0);
29  void setOrigin(const Vector3f &origin) { setOrigin(origin.x, origin.y, origin.z); }
30 
31  void setScale(float factorX, float factorY, float factorZ = 1);
32  void setScale(const Vector3f &factors) { setScale(factors.x, factors.y, factors.z); }
33 
34  void setRotation(float angle) { setRotation(angle, {0, 0, 1}); }
35  void setRotation(float angle, const Vector3f &axis);
36 
37  const Vector3f& getPosition() const { return m_position; }
38  const Vector3f& getOrigin() const { return m_origin; }
39  const Vector3f& getScale() const { return m_scale; }
40  float getRotation() const { return m_rotation; }
41 
42  void move(float offsetX, float offsetY, float offsetZ = 0);
43  void move(const Vector3f &offset);
44 
45  void scale(float factorX, float factorY, float factorZ = 1);
46  void scale(const Vector3f &factor);
47 
48  void rotate(float angle);
49  void rotate(float angle, const Vector3f &axis);
50 
51  const Transform& getTransform() const;
52  // const Transform& getInverseTransform() const;
53 
54  private:
55  Vector3f m_position{0, 0, 0};
56  Vector3f m_origin{0, 0, 0};
57  Vector3f m_scale{1, 1, 1};
58  float m_rotation = 0;
59 
61  // mutable Transform m_inverseTransform;
63 
64  mutable bool m_transformNeedUpdate = true;
65  // mutable bool m_inverseTransformNeedUpdate = true;
66 };
67 
68 } // namespace gk
69 
70 #endif // GK_TRANSFORMABLE_HPP_
Transform m_rotationTransform
const Vector3f & getScale() const
const Vector3f & getOrigin() const
void move(float offsetX, float offsetY, float offsetZ=0)
const Vector3f & getPosition() const
virtual ~Transformable()=default
void setRotation(float angle)
void setScale(float factorX, float factorY, float factorZ=1)
void setPosition(float x, float y, float z=0)
float getRotation() const
const Transform & getTransform() const
void rotate(float angle)
void scale(float factorX, float factorY, float factorZ=1)
void setPosition(const Vector3f &position)
void setOrigin(const Vector3f &origin)
void setScale(const Vector3f &factors)
void setOrigin(float x, float y, float z=0)