1#ifndef LIBSBX_SCENES_COMPONENTS_TRANSFORM_HPP_
2#define LIBSBX_SCENES_COMPONENTS_TRANSFORM_HPP_
6#include <libsbx/math/vector3.hpp>
7#include <libsbx/math/matrix4x4.hpp>
8#include <libsbx/math/angle.hpp>
9#include <libsbx/math/quaternion.hpp>
18 : _position{position},
21 _rotation_matrix{_rotation.to_matrix()},
30 auto position()
const noexcept ->
const vector3& {
34 auto position()
noexcept ->
vector3& {
39 auto set_position(
const vector3& position)
noexcept ->
void {
44 auto move_by(
const vector3& offset)
noexcept ->
void {
49 auto rotation()
const noexcept ->
const quaternion& {
53 auto set_rotation(
const quaternion& rotation)
noexcept ->
void {
55 _rotation_matrix = _rotation.to_matrix();
61 _rotation_matrix = _rotation.to_matrix();
65 auto scale()
noexcept ->
vector3& {
70 auto scale()
const noexcept ->
const vector3& {
75 auto set_scale(
const vector3& scale)
noexcept ->
void {
80 auto forward()
const noexcept ->
vector3 {
81 return -
vector3{_rotation_matrix[2]};
84 auto right()
const noexcept ->
vector3 {
85 return vector3{_rotation_matrix[0]};
88 auto up()
const noexcept ->
vector3 {
89 return vector3{_rotation_matrix[1]};
92 auto look_at(
const vector3& target)
noexcept ->
void {
94 auto result = matrix4x4::look_at(_position, target, vector3::up);
95 _rotation =
quaternion{math::matrix4x4::inverted(result)};
96 _rotation_matrix = _rotation.to_matrix();
101 const auto translation = matrix4x4::translated(matrix4x4::identity, _position);
102 const auto scale = matrix4x4::scaled(matrix4x4::identity, _scale);
104 return translation * _rotation_matrix * scale;
107 auto is_dirty()
const noexcept ->
bool {
111 auto clear_is_dirty()
noexcept ->
void {
Definition: angle.hpp:271
Definition: matrix4x4.hpp:25
Definition: quaternion.hpp:24
Definition: vector3.hpp:22