diff options
Diffstat (limited to 'source/modules/asura-utils/math/matrix44.h')
-rw-r--r-- | source/modules/asura-utils/math/matrix44.h | 152 |
1 files changed, 144 insertions, 8 deletions
diff --git a/source/modules/asura-utils/math/matrix44.h b/source/modules/asura-utils/math/matrix44.h index 4ab3c0b..c0cea92 100644 --- a/source/modules/asura-utils/math/matrix44.h +++ b/source/modules/asura-utils/math/matrix44.h @@ -1,24 +1,160 @@ -#ifndef __ASURA_ENGINE_MATRIX44_H__ -#define __ASURA_ENGINE_MATRIX44_H__ +#ifndef __ASURA_MATRIX_H__ +#define __ASURA_MATRIX_H__ namespace AsuraEngine { namespace Math { + /// + /// ҪתõOpenGLglm::mat4 + /// https://blog.csdn.net/candycat1992/article/details/8830894 /// - /// 4x4 - /// + 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
\ No newline at end of file +#endif
\ No newline at end of file |