Nxna2
 All Classes Namespaces Functions Enumerations Enumerator Pages
Matrix.h
1 #ifndef MATH_MATRIX_H
2 #define MATH_MATRIX_H
3 
4 #include "Vector3.h"
5 
6 namespace Nxna
7 {
8  struct Matrix
9  {
10  Matrix();
11  Matrix(float m11, float m12, float m13, float m14,
12  float m21, float m22, float m23, float m24,
13  float m31, float m32, float m33, float m34,
14  float m41, float m42, float m43, float m44);
15 
16  union
17  {
18  struct
19  {
20  float M11, M12, M13, M14,
21  M21, M22, M23, M24,
22  M31, M32, M33, M34,
23  M41, M42, M43, M44;
24  };
25  float C[16];
26  };
27 
28  Matrix operator*(const Matrix& matrix)
29  {
30  Matrix result;
31  Multiply(*this, matrix, result);
32  return result;
33  }
34 
35  static const Matrix Identity;
36 
37  static void GetIdentity(Matrix& m)
38  {
39  m.M12 = m.M13 = m.M14 =
40  m.M21 = m.M23 = m.M24 =
41  m.M31 = m.M32 = m.M34 =
42  m.M41 = m.M42 = m.M43 = 0;
43 
44  m.M11 = m.M22 = m.M33 = m.M44 = 1.0f;
45  }
46 
47  static Matrix CreateLookAt(const Vector3& cameraPosition, const Vector3& cameraTarget, const Vector3& cameraUpVector);
48  static Matrix CreateOrthographicOffCenter(float left, float right, float bottom, float top, float zNearPlane, float zFarPlane);
49  static Matrix CreatePerspectiveFieldOfView(float fieldOfView, float aspectRatio, float nearPlaneDistance, float farPlaneDistance);
50  static Matrix CreatePerspective(float width, float height, float nearPlaneDistance, float farPlaneDistance);
51  static Matrix CreateTranslation(float x, float y, float z) { Matrix m; CreateTranslation(x, y, z, m); return m; }
52  static void CreateTranslation(float x, float y, float z, Matrix& result);
53  static Matrix CreateTranslation(const Vector3& position) { Matrix m; CreateTranslation(position.X, position.Y, position.Z, m); return m; }
54  static Matrix CreateScale(float scale) { Matrix m; CreateScale(scale, scale, scale, m); return m; }
55  static void CreateScale(float x, float y, float z, Matrix& result);
56  static Matrix CreateRotationX(float rotation) { Matrix m; CreateRotationX(rotation, m); return m; }
57  static void CreateRotationX(float rotation, Matrix& result);
58  static Matrix CreateRotationY(float rotation) { Matrix m; CreateRotationY(rotation, m); return m; }
59  static void CreateRotationY(float rotation, Matrix& result);
60  static Matrix CreateRotationZ(float rotation) { Matrix m; CreateRotationZ(rotation, m); return m; }
61  static void CreateRotationZ(float rotation, Matrix& result);
62  static Matrix CreateFromAxisAngle(const Vector3& axis, float angle) { Matrix m; CreateFromAxisAngle(axis, angle, m); return m; }
63  static void CreateFromAxisAngle(const Vector3& axis, float angle, Matrix& result);
64  static Matrix CreateConstrainedBillboard(const Vector3& objectPosition, const Vector3& cameraPosition, const Vector3& rotationAxis, const Vector3* cameraForwardVector, const Vector3* objectForwardVector) { Matrix m; CreateConstrainedBillboard(objectPosition, cameraPosition, rotationAxis, cameraForwardVector, objectForwardVector, m); return m; }
65  static void CreateConstrainedBillboard(const Vector3& objectPosition, const Vector3& cameraPosition, const Vector3& rotationAxis, const Vector3* cameraForwardVector, const Vector3* objectForwardVector, Matrix& result);
66  static Matrix CreateWorld(const Vector3& position, const Vector3& forward, const Vector3& up);
67  static void Invert(const Matrix& matrix, Matrix& result);
68 
69  static void Multiply(const Matrix& matrix1, const Matrix& matrix2, Matrix& result);
70  };
71 }
72 
73 #endif // MATH_MATRIX_H
Definition: Vector3.h:11
Definition: Matrix.h:8