SolarSim
Loading...
Searching...
No Matches
transform_component.hpp
Go to the documentation of this file.
1#pragma once
2
3#define GLM_ENABLE_EXPERIMENTAL
4
5#include "glm/ext/quaternion_transform.hpp"
6#include <glm/mat4x4.hpp>
7#include <glm/vec3.hpp>
8#include <glm/gtx/quaternion.hpp>
9
10namespace solarsim {
16 glm::vec3 position{0.0f};
17
19 glm::quat rotation{1.0f, 0.0f, 0.0f, 0.0f};
20
22 glm::vec3 scale{1.0f};
23
25 mutable glm::mat4 modelMatrix;
26
28 mutable bool dirty = true;
29
38 glm::mat4 getModelMatrix() const {
39 if (dirty) {
41 glm::translate(glm::mat4(1.0f), position) *
42 glm::toMat4(rotation) *
43 glm::scale(glm::mat4(1.0f), scale);
44 dirty = false;
45 }
46 return modelMatrix;
47 }
48 };
49}
50
Definition engine.cpp:23
Defines spatial properties and provides model matrix calculation.
Definition transform_component.hpp:14
glm::vec3 position
Definition transform_component.hpp:16
glm::mat4 getModelMatrix() const
Computes the model transformation matrix.
Definition transform_component.hpp:38
bool dirty
Definition transform_component.hpp:28
glm::mat4 modelMatrix
Definition transform_component.hpp:25
glm::quat rotation
Definition transform_component.hpp:19
glm::vec3 scale
Definition transform_component.hpp:22