From 5a1b126f1f6d55226c2b5068d0c17c428fd29ba8 Mon Sep 17 00:00:00 2001 From: Mel Date: Sun, 6 Aug 2023 04:27:07 +0200 Subject: Create separate Player entity and add bad collision system --- src/Transform.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/Transform.cpp (limited to 'src/Transform.cpp') 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()}; +} + +} -- cgit 1.4.1