diff options
| author | Mel <einebeere@gmail.com> | 2023-08-06 04:27:07 +0200 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2023-08-06 04:27:07 +0200 |
| commit | 5a1b126f1f6d55226c2b5068d0c17c428fd29ba8 (patch) | |
| tree | 3acc0240cd8dedd0764eeae6df04e134b04584c8 /src/Transform.cpp | |
| parent | e6f5f9e03f673db796f1babb308609ca2576db2f (diff) | |
| download | meowcraft-5a1b126f1f6d55226c2b5068d0c17c428fd29ba8.tar.zst meowcraft-5a1b126f1f6d55226c2b5068d0c17c428fd29ba8.zip | |
Create separate Player entity and add bad collision system
Diffstat (limited to 'src/Transform.cpp')
| -rw-r--r-- | src/Transform.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/Transform.cpp b/src/Transform.cpp new file mode 100644 index 0000000..72be8ea --- /dev/null +++ b/src/Transform.cpp @@ -0,0 +1,24 @@ +#include "Transform.hpp" +#include "Math/Common.hpp" + +namespace MC { + +Vector<3> Transform::forward() const { + return unit_vector({0, 0, 1}); +} + +Vector<3> Transform::right() const { + return unit_vector({1, 0, 0}); +} + +Vector<3> Transform::up() const { + return unit_vector({0, 1, 0}); +} + +Vector<3> Transform::unit_vector(Vector<3> axis) const { + auto rotation = Matrix<4, 4>::rotation(m_rotation); + auto result = rotation.transpose() * Vector<4>{axis.x(), axis.y(), axis.z(), 1.0f}; + return {result.x(), result.y(), result.z()}; +} + +} |
