raylib-cpp
C++ object-oriented wrapper library for raylib.
Matrix.hpp
1 #ifndef RAYLIB_CPP_MATRIX_HPP_
2 #define RAYLIB_CPP_MATRIX_HPP_
3 
4 #ifdef __cplusplus
5 extern "C"{
6 #endif
7 #include "raylib.h"
8 #ifndef RAYLIB_CPP_NO_MATH
9 #include "raymath.h"
10 #endif
11 #ifdef __cplusplus
12 }
13 #endif
14 
15 #include "./raylib-cpp-utils.hpp"
16 #ifndef RAYLIB_CPP_NO_MATH
17 #include <cmath>
18 #endif
19 
20 namespace raylib {
21  class Matrix : public ::Matrix {
22  public:
23  Matrix(::Matrix mat) {
24  set(mat);
25  };
26 
27  Matrix(float M0 = 0, float M1 = 0, float M2 = 0, float M3 = 0, float M4 = 0, float M5 = 0, float M6 = 0, float M7 = 0, float M8 = 0, float M9 = 0, float M10 = 0, float M11 = 0, float M12 = 0, float M13 = 0, float M14 = 0, float M15 = 0) {
28  m0 = M0;
29  m1 = M1;
30  m2 = M2;
31  m3 = M3;
32  m4 = M4;
33  m5 = M5;
34  m6 = M6;
35  m7 = M7;
36  m8 = M8;
37  m9 = M9;
38  m10 = M10;
39  m11 = M11;
40  m12 = M12;
41  m13 = M13;
42  m14 = M14;
43  m15 = M15;
44  };
45 
46  GETTERSETTER(float,M0,m0)
47  GETTERSETTER(float,M1,m1)
48  GETTERSETTER(float,M2,m2)
49  GETTERSETTER(float,M3,m3)
50  GETTERSETTER(float,M4,m4)
51  GETTERSETTER(float,M5,m5)
52  GETTERSETTER(float,M6,m6)
53  GETTERSETTER(float,M7,m7)
54  GETTERSETTER(float,M8,m8)
55  GETTERSETTER(float,M9,m9)
56  GETTERSETTER(float,M10,m10)
57  GETTERSETTER(float,M11,m11)
58  GETTERSETTER(float,M12,m12)
59  GETTERSETTER(float,M13,m13)
60  GETTERSETTER(float,M14,m14)
61  GETTERSETTER(float,M15,m15)
62 
63  Matrix& operator=(const ::Matrix& matrix) {
64  set(matrix);
65  return *this;
66  }
67 
68  Matrix& operator=(const Matrix& matrix) {
69  set(matrix);
70  return *this;
71  }
72 
73  bool operator==(const Matrix& other) {
74  return m0 == other.m0
75  && m1 == other.m1
76  && m2 == other.m2
77  && m3 == other.m3
78  && m4 == other.m4
79  && m5 == other.m5
80  && m6 == other.m6
81  && m7 == other.m7
82  && m8 == other.m8
83  && m9 == other.m9
84  && m10 == other.m10
85  && m11 == other.m11
86  && m12 == other.m12
87  && m13 == other.m13
88  && m14 == other.m14
89  && m15 == other.m15;
90  }
91 
92  inline Matrix& SetProjection() {
93  ::SetMatrixProjection(*this);
94  return *this;
95  }
96 
97  inline Matrix& SetModelview() {
98  ::SetMatrixModelview(*this);
99  return *this;
100  }
101 
102  static Matrix GetModelview() {
103  return ::GetMatrixModelview();
104  }
105 
107  return ::GetMatrixProjection();
108  }
109 
110 #ifndef RAYLIB_CPP_NO_MATH
111  float Trace() {
112  return ::MatrixTrace(*this);
113  }
115  return ::MatrixTranspose(*this);
116  }
118  return ::MatrixInvert(*this);
119  }
121  return ::MatrixNormalize(*this);
122  }
123  static Matrix Identity() {
124  return ::MatrixIdentity();
125  }
126  Matrix Add(::Matrix right) {
127  return ::MatrixAdd(*this, right);
128  }
129  Matrix operator+(const Matrix& matrix) {
130  return ::MatrixAdd(*this, matrix);
131  }
132  Matrix Subtract(::Matrix right) {
133  return ::MatrixSubtract(*this, right);
134  }
135  Matrix operator-(const Matrix& matrix) {
136  return ::MatrixSubtract(*this, matrix);
137  }
138  static Matrix Translate(float x, float y, float z) {
139  return ::MatrixTranslate(x, y, z);
140  }
141  static Matrix Rotate(Vector3 axis, float angle) {
142  return ::MatrixRotate(axis, angle);
143  }
144  static Matrix RotateXYZ(Vector3 angle) {
145  return ::MatrixRotateXYZ(angle);
146  }
147  static Matrix RotateX(float angle) {
148  return ::MatrixRotateX(angle);
149  }
150  static Matrix RotateY(float angle) {
151  return ::MatrixRotateY(angle);
152  }
153  static Matrix RotateZ(float angle) {
154  return ::MatrixRotateZ(angle);
155  }
156  static Matrix Scale(float x, float y, float z) {
157  return ::MatrixScale(x, y, z);
158  }
160  return ::MatrixMultiply(*this, right);
161  }
162  Matrix operator*(const Matrix& matrix) {
163  return ::MatrixMultiply(*this, matrix);
164  }
165 
166  static Matrix Frustum(double left, double right, double bottom, double top, double near, double far) {
167  return ::MatrixFrustum(left, right, bottom, top, near, far);
168  }
169 
170  static Matrix Perspective(double fovy, double aspect, double near, double far) {
171  return ::MatrixPerspective(fovy, aspect, near, far);
172  }
173 
174  static Matrix Ortho(double left, double right, double bottom, double top, double near, double far) {
175  return ::MatrixOrtho(left, right, bottom, top, near, far);
176  }
177 
178  static Matrix LookAt(Vector3 eye, Vector3 target, Vector3 up) {
179  return ::MatrixLookAt(eye, target, up);
180  }
181 
182  inline float16 ToFloatV() {
183  return ::MatrixToFloatV(*this);
184  }
185  operator float16() {
186  return ToFloatV();
187  }
188 #endif
189  protected:
190 
191 
192  inline void set(::Matrix mat) {
193  m0 = mat.m0;
194  m1 = mat.m1;
195  m2 = mat.m2;
196  m3 = mat.m3;
197  m4 = mat.m4;
198  m5 = mat.m5;
199  m6 = mat.m6;
200  m7 = mat.m7;
201  m8 = mat.m8;
202  m9 = mat.m9;
203  m10 = mat.m10;
204  m11 = mat.m11;
205  m12 = mat.m12;
206  m13 = mat.m13;
207  m14 = mat.m14;
208  m15 = mat.m15;
209  }
210  };
211 }
212 
213 
214 #endif
raylib
Provides all the classes associated with raylib-cpp.
Definition: AudioDevice.hpp:14
raylib::Matrix::Invert
Matrix Invert()
Definition: Matrix.hpp:117
raylib::Matrix
Definition: Matrix.hpp:21
raylib::Matrix::operator*
Matrix operator*(const Matrix &matrix)
Definition: Matrix.hpp:162
raylib::Matrix::Frustum
static Matrix Frustum(double left, double right, double bottom, double top, double near, double far)
Definition: Matrix.hpp:166
raylib::Matrix::Add
Matrix Add(::Matrix right)
Definition: Matrix.hpp:126
raylib::Matrix::RotateXYZ
static Matrix RotateXYZ(Vector3 angle)
Definition: Matrix.hpp:144
raylib::Matrix::Scale
static Matrix Scale(float x, float y, float z)
Definition: Matrix.hpp:156
raylib::Matrix::Translate
static Matrix Translate(float x, float y, float z)
Definition: Matrix.hpp:138
raylib::Matrix::Rotate
static Matrix Rotate(Vector3 axis, float angle)
Definition: Matrix.hpp:141
raylib::Matrix::RotateZ
static Matrix RotateZ(float angle)
Definition: Matrix.hpp:153
raylib::Vector3
Definition: Vector3.hpp:21
raylib::Matrix::SetProjection
Matrix & SetProjection()
Definition: Matrix.hpp:92
raylib::Matrix::SetModelview
Matrix & SetModelview()
Definition: Matrix.hpp:97
raylib::Matrix::operator-
Matrix operator-(const Matrix &matrix)
Definition: Matrix.hpp:135
raylib::Matrix::Identity
static Matrix Identity()
Definition: Matrix.hpp:123
raylib::Matrix::operator=
Matrix & operator=(const Matrix &matrix)
Definition: Matrix.hpp:68
raylib::Matrix::Normalize
Matrix Normalize()
Definition: Matrix.hpp:120
raylib::Matrix::Matrix
Matrix(::Matrix mat)
Definition: Matrix.hpp:23
raylib::Matrix::RotateX
static Matrix RotateX(float angle)
Definition: Matrix.hpp:147
raylib::Matrix::Perspective
static Matrix Perspective(double fovy, double aspect, double near, double far)
Definition: Matrix.hpp:170
raylib::Matrix::ToFloatV
float16 ToFloatV()
Definition: Matrix.hpp:182
raylib::Matrix::set
void set(::Matrix mat)
Definition: Matrix.hpp:192
raylib::Matrix::Subtract
Matrix Subtract(::Matrix right)
Definition: Matrix.hpp:132
raylib::Matrix::GetModelview
static Matrix GetModelview()
Definition: Matrix.hpp:102
raylib::Matrix::Matrix
Matrix(float M0=0, float M1=0, float M2=0, float M3=0, float M4=0, float M5=0, float M6=0, float M7=0, float M8=0, float M9=0, float M10=0, float M11=0, float M12=0, float M13=0, float M14=0, float M15=0)
Definition: Matrix.hpp:27
raylib::Matrix::Trace
float Trace()
Definition: Matrix.hpp:111
raylib::Matrix::LookAt
static Matrix LookAt(Vector3 eye, Vector3 target, Vector3 up)
Definition: Matrix.hpp:178
raylib::Matrix::RotateY
static Matrix RotateY(float angle)
Definition: Matrix.hpp:150
raylib::Matrix::Multiply
Matrix Multiply(Matrix right)
Definition: Matrix.hpp:159
raylib::Matrix::operator==
bool operator==(const Matrix &other)
Definition: Matrix.hpp:73
raylib::Matrix::GetProjection
static Matrix GetProjection()
Definition: Matrix.hpp:106
raylib::Matrix::operator+
Matrix operator+(const Matrix &matrix)
Definition: Matrix.hpp:129
raylib::Matrix::Ortho
static Matrix Ortho(double left, double right, double bottom, double top, double near, double far)
Definition: Matrix.hpp:174
raylib::Matrix::Transpose
Matrix Transpose()
Definition: Matrix.hpp:114