matrix.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef MATRIX_H
  2. #define MATRIX_H
  3. #include <array>
  4. #include <vector3.h>
  5. struct TransformParameters{
  6. TransformParameters() :scaling(Vector3(1,1,1)) {};
  7. Vector3 translation;
  8. Vector3 rotation;
  9. Vector3 scaling;
  10. };
  11. class Matrix4{
  12. public:
  13. float& operator()(size_t y, size_t x){
  14. return mMatrix[y*4 + x];
  15. }
  16. Matrix4 operator* (Matrix4 &rhs);
  17. Vector3 matMultVec(Vector3 &vec);
  18. void printMat();
  19. //Probably should be their own classes or constructors in the future
  20. Matrix4 static makeTestMat();
  21. Matrix4 static makeFullRotMat(float alpha, float beta, float gamma);
  22. Matrix4 static makeScaleMat(float scaleX, float scaleY, float scaleZ);
  23. Matrix4 static makeTranslateMat(float dx, float dy, float dz);
  24. //Builds a matrix that rotates, scales and translates all in one
  25. Matrix4 static transformMatrix(TransformParameters transform);
  26. //Camera transformation matrix (the world from the camera's eyes)
  27. Matrix4 static lookAt(Vector3& position, Vector3& target, Vector3& temp);
  28. //2D to 3D projection matrix
  29. Matrix4 static makeProjectionMatrix(float fov, float AR, float near, float far);
  30. Matrix4(){};
  31. private:
  32. std::array<float, 16> mMatrix{};
  33. };
  34. #endif