GameKit
0.0.1a
C++ gamedev tools
source
gl
Transform.cpp
Go to the documentation of this file.
1
/*
2
* =====================================================================================
3
*
4
* Filename: Transform.cpp
5
*
6
* Description:
7
*
8
* Created: 11/11/2018 17:39:55
9
*
10
* Author: Quentin Bazin, <quent42340@gmail.com>
11
*
12
* =====================================================================================
13
*/
14
#define GLM_FORCE_RADIANS
15
#include <glm/gtc/matrix_transform.hpp>
16
17
#include "
gk/gl/Transform.hpp
"
18
19
namespace
gk
{
20
21
const
Transform
Transform::Identity
;
22
23
Transform
&
Transform::combine
(
const
Transform
& transform) {
24
m_matrix
*= transform.
m_matrix
;
25
return
*
this
;
26
}
27
28
Transform
&
Transform::translate
(
float
x,
float
y,
float
z) {
29
m_matrix
= glm::translate(
m_matrix
, {x, y, z});
30
return
*
this
;
31
}
32
33
Transform
&
Transform::rotate
(
float
angle,
const
Vector3f
& axis) {
34
float
rotationAngle = angle *
RADIANS_PER_DEGREES
;
35
m_matrix
= glm::rotate(
m_matrix
, rotationAngle, {axis.
x
, axis.
y
, axis.
z
});
36
return
*
this
;
37
}
38
39
Transform
&
Transform::scale
(
float
scaleX,
float
scaleY,
float
scaleZ) {
40
m_matrix
= glm::scale(
m_matrix
, {scaleX, scaleY, scaleZ});
41
return
*
this
;
42
}
43
44
Transform
operator*
(
const
Transform
& left,
const
Transform
&right) {
45
return
Transform
(left).combine(right);
46
}
47
48
Transform
&
operator*=
(
Transform
&left,
const
Transform
&right) {
49
return
left.
combine
(right);
50
}
51
52
}
53
gk::Transform::translate
Transform & translate(float x, float y, float z=0)
Definition:
Transform.cpp:28
gk::Vector3::y
T y
Definition:
Vector3.hpp:66
gk
Definition:
AudioPlayer.hpp:21
gk::operator*
Vector2< T > operator*(T n, Vector2< T > &vector2)
Definition:
Vector2.hpp:65
gk::Transform::Identity
static const Transform Identity
Definition:
Transform.hpp:50
gk::Transform::combine
Transform & combine(const Transform &transform)
Definition:
Transform.cpp:23
gk::Transform::rotate
Transform & rotate(float angle)
Definition:
Transform.hpp:38
gk::Transform::scale
Transform & scale(float scaleX, float scaleY, float scaleZ=1)
Definition:
Transform.cpp:39
gk::Transform::m_matrix
glm::mat4 m_matrix
Definition:
Transform.hpp:53
gk::Transform
Definition:
Transform.hpp:28
gk::Transform::Transform
Transform()=default
gk::operator*=
Transform & operator*=(Transform &left, const Transform &right)
Definition:
Transform.cpp:48
gk::Vector3< float >
Transform.hpp
RADIANS_PER_DEGREES
#define RADIANS_PER_DEGREES
Definition:
Transform.hpp:23
gk::Vector3::x
T x
Definition:
Vector3.hpp:65
gk::Vector3::z
T z
Definition:
Vector3.hpp:67
Generated by
1.8.12