ScummVM API documentation
te_matrix4x4.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef TETRAEDGE_TE_TE_MATRIX4X4_H
23#define TETRAEDGE_TE_TE_MATRIX4X4_H
24
25#include "math/matrix4.h"
26
27#include "tetraedge/te/te_vector3f32.h"
28
29namespace Tetraedge {
30
31class TeTRS;
32
38public:
40 TeMatrix4x4(const Math::Matrix<4, 4> &matrix);
41
42 void setToIdentity();
43
44 float &operator()(int row, int col) {
45 return *(_data + col * 4 + row);
46 }
47
48 const float &operator()(int row, int col) const {
49 return *(_data + col * 4 + row);
50 }
51
52 bool operator==(const TeMatrix4x4 &other) const;
53 bool operator!=(const TeMatrix4x4 &other) const {
54 return !operator==(other);
55 }
56
57 //TeMatrix4x4 &operator*=(const TeMatrix4x4 &mul);
58
59 TeVector3f32 operator*(const TeVector3f32 &mul) const;
60
61 void scale(const TeVector3f32 &vec);
62 void translate(const TeVector3f32 &vec);
63 void rotate(const TeQuaternion &rot);
64 TeVector3f32 translation() const;
65 TeVector3f32 mult3x3(const TeVector3f32 &vec) const;
66 TeVector3f32 mult4x3(const TeVector3f32 &vec) const;
67
68 Common::String toString() const;
69 Math::Matrix<4, 4> toScummVMMatrix() const;
70
71 void setValue(int row, int col, float val) {
72 operator()(row, col) = val;
73 }
74
75 TeMatrix4x4 transpose() const;
76 TeMatrix4x4 meshScale(float factor) const;
77 void meshAdd(const TeMatrix4x4 &other);
78
79 bool inverse();
80
81 static TeMatrix4x4 fromTRS(const TeTRS &trs);
82
83 const float *getData() const { return _data; }
84 float *getData() { return _data; }
85
86 void deserialize(Common::ReadStream &stream);
87 void serialize(Common::WriteStream &stream) const;
88
89private:
90 float _data[16];
91
92};
93
94TeMatrix4x4 operator*(const TeMatrix4x4 &left, const TeMatrix4x4 &right);
95
96} // end namespace Tetraedge
97
98#endif // TETRAEDGE_TE_TE_MATRIX4X4_H
Definition: stream.h:385
Definition: str.h:59
Definition: stream.h:77
Definition: te_matrix4x4.h:37
Definition: te_quaternion.h:32
Definition: te_trs.h:31
Definition: te_vector3f32.h:33