From 4dafa2b53578c8d82eec6c3363568b5bfd7ac183 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 23 Apr 2023 21:08:41 +0100 Subject: Add getTransform to Location; wraps the standard mat4 calculations --- lib/location.cpp | 9 +++++++++ lib/location.hpp | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 lib/location.cpp (limited to 'lib') diff --git a/lib/location.cpp b/lib/location.cpp new file mode 100644 index 0000000..bff27a2 --- /dev/null +++ b/lib/location.cpp @@ -0,0 +1,9 @@ +#include "location.hpp" +#include "maths.h" +#include + +glm::mat4 +Location::getTransform() const +{ + return glm::translate(pos) * rotate_ypr(rot); +} diff --git a/lib/location.hpp b/lib/location.hpp index 1360c47..078f5d3 100644 --- a/lib/location.hpp +++ b/lib/location.hpp @@ -1,11 +1,14 @@ #pragma once -#include +#include +#include class Location { public: explicit Location(glm::vec3 pos = {}, glm::vec3 rot = {}) : pos {pos}, rot {rot} { } + glm::mat4 getTransform() const; + glm::vec3 pos; glm::vec3 rot; }; -- cgit v1.2.3