summaryrefslogtreecommitdiff
path: root/source/LoG/math/matrix44.h
blob: 3639df9e7da72d25b1833742f36d696a2fc7bbe1 (plain)
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
#ifndef __LOG_MAT44_H__
#define __LOG_MAT44_H__


//
// 4x4矩阵,不需要转置,直接运用在Opengl中,由于opengl的glUniformMatrix按列填入矩阵,进行
// 的是和列向量的右乘,为了不需要转置,直接使用按列定义的矩阵。保证矩阵的内存排列和输入opengl
// 的统一
//
class Matrix44
{
public:

	static const Matrix44 Identity;

	Matrix44();

	Matrix44(const Matrix44& m);

	~Matrix44();

	void operator = (const Matrix44& m);

	void SetOrtho(float _left, float _right, float _bottom, float _top, float _near, float _far);

	Matrix44 operator * (const Matrix44 & m) const;

	void operator *= (const Matrix44 & m);

	const float* GetElements() const;

	void SetIdentity();

	void SetTranslation(float x, float y);

	void SetRotation(float r);

	void SetScale(float sx, float sy);

	void SetShear(float kx, float ky);

	void SetTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy);

	void Translate(float x, float y);

	//
	// 饶xyz轴旋转
	//
	void Rotate(float r, float x, float y, float z);

	void Scale(float sx, float sy);

	void Transform(float x, float y, float angle, float sx, float sy, float ox, float oy);

	// 
	// 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);

	void Ortho(float left, float right, float bottom, float top, float near, float far);

	//// 
	//// 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;

	//
	// 
	//
	void Frustum(float l, float r, float t, float b, float near, float far);

	void Perspective(float fov, float aspect, float near, float far);

private:

	// 
	// | e0 e4 e8  e12 |
	// | e1 e5 e9  e13 |
	// | e2 e6 e10 e14 |
	// | e3 e7 e11 e15 |
	//
	float e[16];

};


#endif