summaryrefslogtreecommitdiff
path: root/transform.h
diff options
context:
space:
mode:
Diffstat (limited to 'transform.h')
-rw-r--r--transform.h66
1 files changed, 23 insertions, 43 deletions
diff --git a/transform.h b/transform.h
index ed9b703..783ef31 100644
--- a/transform.h
+++ b/transform.h
@@ -1,75 +1,55 @@
#ifndef TRANSFORM_INCLUDED_H
#define TRANSFORM_INCLUDED_H
-#include "camera.h"
#include <glm/glm.hpp>
-#include <glm/gtx/transform.hpp>
+#include <utility>
-struct Transform {
-public:
- Transform(const glm::vec3 & pos = glm::vec3(), const glm::vec3 & rot = glm::vec3(),
- const glm::vec3 & scale = glm::vec3(1.0f, 1.0f, 1.0f))
- {
- this->pos = pos;
- this->rot = rot;
- this->scale = scale;
- }
+class Camera;
- inline glm::mat4
- GetModel() const
- {
- glm::mat4 posMat = glm::translate(pos);
- glm::mat4 scaleMat = glm::scale(scale);
- glm::mat4 rotX = glm::rotate(rot.x, glm::vec3(1.0, 0.0, 0.0));
- glm::mat4 rotY = glm::rotate(rot.y, glm::vec3(0.0, 1.0, 0.0));
- glm::mat4 rotZ = glm::rotate(rot.z, glm::vec3(0.0, 0.0, 1.0));
- glm::mat4 rotMat = rotX * rotY * rotZ;
+class Transform {
+public:
+ Transform(glm::vec3 pos = {}, glm::vec3 rot = {}, glm::vec3 scale = {1.0f, 1.0f, 1.0f});
- return posMat * rotMat * scaleMat;
- }
+ glm::mat4 GetModel() const;
- inline glm::mat4
- GetMVP(const Camera & camera) const
- {
- glm::mat4 VP = camera.GetViewProjection();
- glm::mat4 M = GetModel();
+ glm::mat4 GetMVP(const Camera & camera) const;
- return VP * M; // camera.GetViewProjection() * GetModel();
- }
-
- inline glm::vec3 *
+ inline glm::vec3 &
GetPos()
{
- return &pos;
+ return pos;
}
- inline glm::vec3 *
+
+ inline glm::vec3 &
GetRot()
{
- return &rot;
+ return rot;
}
- inline glm::vec3 *
+
+ inline glm::vec3 &
GetScale()
{
- return &scale;
+ return scale;
}
inline void
- SetPos(glm::vec3 & pos)
+ SetPos(glm::vec3 && pos)
{
- this->pos = pos;
+ this->pos = std::move(pos);
}
+
inline void
- SetRot(glm::vec3 & rot)
+ SetRot(glm::vec3 && rot)
{
- this->rot = rot;
+ this->rot = std::move(rot);
}
+
inline void
- SetScale(glm::vec3 & scale)
+ SetScale(glm::vec3 && scale)
{
- this->scale = scale;
+ this->scale = std::move(scale);
}
-protected:
private:
glm::vec3 pos;
glm::vec3 rot;