1#ifndef OE_SCENE_TRANSFORM_H
2#define OE_SCENE_TRANSFORM_H
4#include <glm/mat4x4.hpp>
7#include <glm/gtx/quaternion.hpp>
10#include "../util/angle.h"
20 {v.x} -> std::convertible_to<float>;
21 {v.y} -> std::convertible_to<float>;
22 {v.z} -> std::convertible_to<float>;
31 {v.x} -> std::convertible_to<float>;
32 {v.y} -> std::convertible_to<float>;
33 {v.z} -> std::convertible_to<float>;
34 {v.w} -> std::convertible_to<float>;
57 template<>
struct IsPosition<glm::vec3> : std::true_type {};
58 template<>
struct IsRotation<glm::quat> : std::true_type {};
59 template<>
struct IsScale<glm::vec3> : std::true_type {};
77 const glm::vec3& translation = glm::vec3(0.f),
78 const glm::quat& rotation = glm::quat(1.f, 0.f, 0.f, 0.f),
79 const glm::vec3& scale = glm::vec3(1.f),
80 const glm::vec3& skew = glm::vec3(0.f),
81 const glm::vec4& perspective = glm::vec4(glm::vec3(0.f), 1.f)
83 _translation(translation),
87 _perspective(perspective)
194 void setPosition(
const float x,
const float y,
const float z)
noexcept
219 _rotation = glm::quat(glm::vec3(x.getRadians(), y.getRadians(), z.getRadians()));
231 _rotation = rotation;
267 void setScale(
const float x,
const float y,
const float z)
noexcept
283 _translation += translation;
325 _rotation = quaternion * _rotation;
353 relativeRotate(glm::quat(glm::vec3(x.getRadians(), y.getRadians(), z.getRadians())));
387 _perspective = perspective;
400 _translation = glm::mix(_translation, target._translation, ratio);
401 _rotation = glm::slerp(_rotation, target._rotation, ratio);
402 _scale = glm::mix(_scale, target._scale, ratio);
403 _skew = glm::mix(_skew, target._skew, ratio);
404 _perspective = glm::mix(_perspective, target._perspective, ratio);
416 _translation = transform._translation;
417 _rotation = transform._rotation;
418 _scale = transform._scale;
419 _skew = transform._skew;
420 _perspective = transform._perspective;
430 template<TranslationType T>
433 _translation.x = translation.x;
434 _translation.y = translation.y;
435 _translation.z = translation.z;
445 template<RotationType R>
448 _rotation.x = rotation.x;
449 _rotation.y = rotation.y;
450 _rotation.z = rotation.z;
451 _rotation.w = rotation.w;
461 template<ScaleType S>
478 template<TranslationType T>
481 result.x = _translation.x;
482 result.y = _translation.y;
483 result.z = _translation.z;
493 template<RotationType R>
496 result.x = _rotation.x;
497 result.y = _rotation.y;
498 result.z = _rotation.z;
499 result.w = _rotation.w;
509 template<ScaleType S>
540 _is_dirty = is_dirty;
544 glm::vec3 _translation;
548 glm::vec4 _perspective;
550 mutable bool _is_dirty =
true;
Definition transform.h:51
Definition transform.h:54
Definition transform.h:48
Represent a generic vector of 3 floats.
Definition transform.h:18
Represent a generic vector of 4 floats.
Definition transform.h:29
Scene related management (Render-agnostic Geometry, Manger, etc...)
Definition debug.h:19
Wrapper and helper to abstract conversions between degree and radian angles.
Definition angle.h:19
Definition transform.h:38
Definition transform.h:44
Definition transform.h:41