TDME2
1.9.121
src
tdme
engine
Transformations.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <vector>
4
5
#include <
tdme/tdme.h
>
6
#include <
tdme/engine/fwd-tdme.h
>
7
#include <
tdme/engine/model/RotationOrder.h
>
8
#include <
tdme/engine/Rotation.h
>
9
#include <
tdme/math/fwd-tdme.h
>
10
#include <
tdme/math/Matrix4x4.h
>
11
#include <
tdme/math/Quaternion.h
>
12
#include <
tdme/math/Vector3.h
>
13
14
using
std::vector;
15
16
using
tdme::engine::model::RotationOrder
;
17
using
tdme::engine::Rotation
;
18
using
tdme::math::Matrix4x4
;
19
using
tdme::math::Quaternion
;
20
using
tdme::math::Vector3
;
21
22
/**
23
* Transformations which contain scale, rotations and translation
24
* @author Andreas Drewke
25
* @version $Id$
26
*/
27
class
tdme::engine::Transformations
{
28
private
:
29
Vector3
translation
;
30
Vector3
scale
;
31
Vector3
pivot
;
32
Quaternion
rotationsQuaternion
;
33
vector<Rotation>
rotations
;
34
Matrix4x4
transformationsMatrix
;
35
36
public
:
37
/**
38
* Public constructor
39
*/
40
Transformations
();
41
42
/**
43
* Destructor
44
*/
45
virtual
~Transformations
();
46
47
/**
48
* @return object translation
49
*/
50
inline
const
Vector3
&
getTranslation
()
const
{
51
return
translation
;
52
}
53
54
/**
55
* Set translation
56
* @param translation translation
57
*/
58
inline
void
setTranslation
(
const
Vector3
&
translation
) {
59
this->translation.
set
(
translation
);
60
}
61
62
/**
63
* @return object scale
64
*/
65
inline
const
Vector3
&
getScale
()
const
{
66
return
scale
;
67
}
68
69
/**
70
* Set scale
71
* @param scale scale
72
*/
73
inline
void
setScale
(
const
Vector3
&
scale
) {
74
this->scale.
set
(
scale
);
75
}
76
77
/**
78
* @return pivot or center of rotations
79
*/
80
inline
const
Vector3
&
getPivot
()
const
{
81
return
pivot
;
82
}
83
84
/**
85
* Set pivot
86
* @param pivot pivot
87
*/
88
inline
void
setPivot
(
const
Vector3
&
pivot
) {
89
this->pivot.
set
(
pivot
);
90
}
91
92
/**
93
* @return rotation count
94
*/
95
inline
const
int
getRotationCount
()
const
{
96
return
rotations
.size();
97
}
98
99
/**
100
* Get rotation at given index
101
* @param idx rotation index
102
* @return rotation
103
*/
104
inline
Rotation
&
getRotation
(
const
int
idx) {
105
return
rotations
[idx];
106
}
107
108
/**
109
* Add rotation
110
* @param axis axis
111
* @param angle angle
112
*/
113
inline
void
addRotation
(
const
Vector3
& axis,
const
float
angle) {
114
rotations
.push_back(
Rotation
(axis, angle));
115
}
116
117
/**
118
* Remove rotation
119
* @param idx index
120
*/
121
inline
void
removeRotation
(
const
int
idx) {
122
rotations
.erase(
rotations
.begin() + idx);
123
}
124
125
/**
126
* @param idx rotation index
127
* @return rotation axis for rotation with given index
128
*/
129
inline
const
Vector3
&
getRotationAxis
(
const
int
idx)
const
{
130
return
rotations
[idx].getAxis();
131
}
132
133
/**
134
* Set rotation axis
135
* @param idx rotation index
136
* @param axis rotation axis
137
*/
138
inline
void
setRotationAxis
(
const
int
idx,
const
Vector3
& axis) {
139
return
rotations
[idx].setAxis(axis);
140
}
141
142
/**
143
* @param idx rotation index
144
* @return rotation angle for rotation with given index
145
*/
146
inline
const
float
getRotationAngle
(
const
int
idx)
const
{
147
return
rotations
[idx].getAngle();
148
}
149
150
/**
151
* @param idx rotation index
152
* @param angle rotation angle
153
* @return rotation angle for rotation with given index
154
*/
155
inline
void
setRotationAngle
(
const
int
idx,
const
float
angle) {
156
rotations
[idx].setAngle(angle);
157
}
158
159
/**
160
* @return rotations quaternion
161
*/
162
inline
const
Quaternion
&
getRotationsQuaternion
()
const
{
163
return
rotationsQuaternion
;
164
}
165
166
/**
167
* @return this transformations matrix
168
*/
169
inline
const
Matrix4x4
&
getTransformationsMatrix
()
const
{
170
return
transformationsMatrix
;
171
}
172
173
/**
174
* Set up this transformations from given transformations
175
* @param transformations transformations
176
*/
177
virtual
void
fromTransformations
(
const
Transformations
& transformations);
178
179
/**
180
* Set up this transformations from given matrix and rotation order
181
* @param matrix matrix
182
* @param rotationOrder rotation order
183
*/
184
virtual
void
fromMatrix
(
const
Matrix4x4
& matrix,
RotationOrder
* rotationOrder);
185
186
/**
187
* Computes transformation matrix
188
* @param parentTransformations parent transformations
189
*/
190
virtual
void
update
();
191
192
/**
193
* Apply parent transformations
194
* @param parentTransformations parent transformations
195
*/
196
virtual
void
applyParentTransformations
(
const
Transformations
& parentTransformations);
197
198
/**
199
* Invert this transformations
200
*/
201
virtual
void
invert
();
202
203
};
Matrix4x4.h
Quaternion.h
RotationOrder.h
Rotation.h
Vector3.h
tdme::engine::Rotation
Rotation representation.
Definition:
Rotation.h:18
tdme::engine::Transformations
Transformations which contain scale, rotations and translation.
Definition:
Transformations.h:27
tdme::engine::Transformations::fromMatrix
virtual void fromMatrix(const Matrix4x4 &matrix, RotationOrder *rotationOrder)
Set up this transformations from given matrix and rotation order.
Definition:
Transformations.cpp:38
tdme::engine::Transformations::getTransformationsMatrix
const Matrix4x4 & getTransformationsMatrix() const
Definition:
Transformations.h:169
tdme::engine::Transformations::translation
Vector3 translation
Definition:
Transformations.h:29
tdme::engine::Transformations::getRotation
Rotation & getRotation(const int idx)
Get rotation at given index.
Definition:
Transformations.h:104
tdme::engine::Transformations::setRotationAngle
void setRotationAngle(const int idx, const float angle)
Definition:
Transformations.h:155
tdme::engine::Transformations::setRotationAxis
void setRotationAxis(const int idx, const Vector3 &axis)
Set rotation axis.
Definition:
Transformations.h:138
tdme::engine::Transformations::Transformations
Transformations()
Public constructor.
Definition:
Transformations.cpp:22
tdme::engine::Transformations::setTranslation
void setTranslation(const Vector3 &translation)
Set translation.
Definition:
Transformations.h:58
tdme::engine::Transformations::removeRotation
void removeRotation(const int idx)
Remove rotation.
Definition:
Transformations.h:121
tdme::engine::Transformations::scale
Vector3 scale
Definition:
Transformations.h:30
tdme::engine::Transformations::getRotationsQuaternion
const Quaternion & getRotationsQuaternion() const
Definition:
Transformations.h:162
tdme::engine::Transformations::invert
virtual void invert()
Invert this transformations.
Definition:
Transformations.cpp:89
tdme::engine::Transformations::applyParentTransformations
virtual void applyParentTransformations(const Transformations &parentTransformations)
Apply parent transformations.
Definition:
Transformations.cpp:85
tdme::engine::Transformations::rotationsQuaternion
Quaternion rotationsQuaternion
Definition:
Transformations.h:32
tdme::engine::Transformations::getScale
const Vector3 & getScale() const
Definition:
Transformations.h:65
tdme::engine::Transformations::setScale
void setScale(const Vector3 &scale)
Set scale.
Definition:
Transformations.h:73
tdme::engine::Transformations::getRotationAxis
const Vector3 & getRotationAxis(const int idx) const
Definition:
Transformations.h:129
tdme::engine::Transformations::rotations
vector< Rotation > rotations
Definition:
Transformations.h:33
tdme::engine::Transformations::getRotationCount
const int getRotationCount() const
Definition:
Transformations.h:95
tdme::engine::Transformations::fromTransformations
virtual void fromTransformations(const Transformations &transformations)
Set up this transformations from given transformations.
Definition:
Transformations.cpp:32
tdme::engine::Transformations::getPivot
const Vector3 & getPivot() const
Definition:
Transformations.h:80
tdme::engine::Transformations::pivot
Vector3 pivot
Definition:
Transformations.h:31
tdme::engine::Transformations::update
virtual void update()
Computes transformation matrix.
Definition:
Transformations.cpp:49
tdme::engine::Transformations::transformationsMatrix
Matrix4x4 transformationsMatrix
Definition:
Transformations.h:34
tdme::engine::Transformations::getTranslation
const Vector3 & getTranslation() const
Definition:
Transformations.h:50
tdme::engine::Transformations::setPivot
void setPivot(const Vector3 &pivot)
Set pivot.
Definition:
Transformations.h:88
tdme::engine::Transformations::addRotation
void addRotation(const Vector3 &axis, const float angle)
Add rotation.
Definition:
Transformations.h:113
tdme::engine::Transformations::getRotationAngle
const float getRotationAngle(const int idx) const
Definition:
Transformations.h:146
tdme::engine::Transformations::~Transformations
virtual ~Transformations()
Destructor.
Definition:
Transformations.cpp:29
tdme::engine::model::RotationOrder
Represents rotation orders of a model.
Definition:
RotationOrder.h:23
tdme::math::Matrix4x4
4x4 3D Matrix class
Definition:
Matrix4x4.h:24
tdme::math::Quaternion
Quaternion class.
Definition:
Quaternion.h:22
tdme::math::Vector3
3D vector 3 class
Definition:
Vector3.h:22
tdme::math::Vector3::set
Vector3 & set(float x, float y, float z)
Set up vector.
Definition:
Vector3.h:73
fwd-tdme.h
fwd-tdme.h
tdme.h
Generated by
1.9.3