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
10
namespace
solarsim
{
14
struct
TransformComponent
{
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
) {
40
modelMatrix
=
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
solarsim
Definition
engine.cpp:23
solarsim::TransformComponent
Defines spatial properties and provides model matrix calculation.
Definition
transform_component.hpp:14
solarsim::TransformComponent::position
glm::vec3 position
Definition
transform_component.hpp:16
solarsim::TransformComponent::getModelMatrix
glm::mat4 getModelMatrix() const
Computes the model transformation matrix.
Definition
transform_component.hpp:38
solarsim::TransformComponent::dirty
bool dirty
Definition
transform_component.hpp:28
solarsim::TransformComponent::modelMatrix
glm::mat4 modelMatrix
Definition
transform_component.hpp:25
solarsim::TransformComponent::rotation
glm::quat rotation
Definition
transform_component.hpp:19
solarsim::TransformComponent::scale
glm::vec3 scale
Definition
transform_component.hpp:22
include
components
transform_component.hpp
Generated by
1.15.0