diff options
Diffstat (limited to 'src/Math')
| -rw-r--r-- | src/Math/MVP.hpp | 5 | ||||
| -rw-r--r-- | src/Math/Matrix.hpp | 9 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/Math/MVP.hpp b/src/Math/MVP.hpp index 4046a50..b7341a8 100644 --- a/src/Math/MVP.hpp +++ b/src/Math/MVP.hpp @@ -5,11 +5,12 @@ namespace Math::MVP { template<typename T = Real> -Matrix<4, 4, T> model(Vector<3> position, Rotation angles) { +Matrix<4, 4, T> model(Vector<3> position, Vector<3> size, Rotation angles) { auto transformation = Matrix<4, 4, T>::transformation(position); + auto scale = Matrix<4, 4, T>::scale(size); auto rotation = Matrix<4, 4, T>::rotation(angles); - return transformation * rotation; + return transformation * rotation * scale; } template<typename T = Real> diff --git a/src/Math/Matrix.hpp b/src/Math/Matrix.hpp index d51d171..41d3661 100644 --- a/src/Math/Matrix.hpp +++ b/src/Math/Matrix.hpp @@ -37,6 +37,15 @@ struct Matrix { }; } + static Matrix<4, 4, T> scale(Vector<3> factor) { + return { + factor.x(), 0.0, 0.0, 0.0, + 0.0, factor.y(), 0.0, 0.0, + 0.0, 0.0, factor.z(), 0.0, + 0.0, 0.0, 0.0, 1.0 + }; + } + static Matrix<4, 4, T> rotation(Rotation angles) { auto radians = angles.vector.map([](auto a) { return Math::radians(a); }); |
