1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
#ifndef __ASURA_MATRIX_H__
#define __ASURA_MATRIX_H__
namespace AsuraEngine
{
namespace Math
{
///
/// ҪתõOpenGLglm::mat4
/// https://blog.csdn.net/candycat1992/article/details/8830894
///
class Matrix44
{
public:
static const Matrix44 Identity;
///
/// Creates a new identity matrix.
///
Matrix44();
///
/// Copy constructor.
///
Matrix44(const Matrix44& m);
///
/// Destructor.
///
~Matrix44();
void operator = (const Matrix44& m);
void SetOrtho(float _left, float _right, float _bottom, float _top, float _near, float _far);
///
/// Multiplies this Matrix44 with another Matrix44, changing neither.
/// @param m The Matrix44 to multiply with this Matrix44.
/// @return The combined matrix.
///
Matrix44 operator * (const Matrix44 & m) const;
///
/// Multiplies a Matrix44 into this Matrix44.
/// @param m The Matrix44 to combine into this Matrix44.
///
void operator *= (const Matrix44 & m);
///
/// Gets a pointer to the 16 array elements.
/// @return The array elements.
///
const float* GetElements() const;
///
/// ReSets this Matrix44 to the identity matrix.
///
void SetIdentity();
///
/// ReSets this Matrix44 to a translation.
/// @param x Translation along x-axis.
/// @param y Translation along y-axis.
///
void SetTranslation(float x, float y);
///
/// ReSets this Matrix44 to a rotation.
/// @param r The angle in radians.
///
void SetRotation(float r);
///
/// ReSets this Matrix44 to a scale transformation.
/// @param sx Scale factor along the x-axis.
/// @param sy Scale factor along the y-axis.
///
void SetScale(float sx, float sy);
///
/// ReSets this Matrix44 to a shear transformation.
/// @param kx Shear along x-axis.
/// @param ky Shear along y-axis.
///
void SetShear(float kx, float ky);
///
/// Creates a transformation with a certain position, orientation, scale
/// and offSet. Perfect for Drawables -- what a coincidence!
///
/// @param x The translation along the x-axis.
/// @param y The translation along the y-axis.
/// @param angle The rotation (rad) around the center with offSet (ox,oy).
/// @param sx Scale along x-axis.
/// @param sy Scale along y-axis.
/// @param ox The offSet for rotation along the x-axis.
/// @param oy The offSet for rotation along the y-axis.
/// @param kx Shear along x-axis
/// @param ky Shear along y-axis
///
void SetTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy);
///
/// Multiplies this Matrix44 with a translation.
/// @param x Translation along x-axis.
/// @param y Translation along y-axis.
///
void Translate(float x, float y);
///
/// Multiplies this Matrix44 with a rotation.
/// @param r Angle in radians.
///
void Rotate(float r);
///
/// Multiplies this Matrix44 with a scale transformation.
/// @param sx Scale factor along the x-axis.
/// @param sy Scale factor along the y-axis.
///
void Scale(float sx, float sy);
///
/// Multiplies this Matrix44 with a shear transformation.
/// @param kx Shear along the x-axis.
/// @param ky Shear along the y-axis.
///
void Shear(float kx, float ky);
/////
///// Transforms an array of vertices by this Matrix44. The sources and
///// destination arrays may be the same.
/////
///// @param dst Storage for the transformed vertices.
///// @param src The source vertices.
///// @param size The number of vertices.
/////
//void transform(Graphics::Vertex* dst, const Graphics::Vertex * src, int size) const;
private:
///
/// | e0 e4 e8 e12 |
/// | e1 e5 e9 e13 |
/// | e2 e6 e10 e14 |
/// | e3 e7 e11 e15 |
///
float e[16];
};
}
}
namespace AEMath = AsuraEngine::Math;
#endif
|