sandbox
Loading...
Searching...
No Matches
transform.hpp
1// SPDX-License-Identifier: MIT
2#ifndef LIBSBX_SCENES_COMPONENTS_TRANSFORM_HPP_
3#define LIBSBX_SCENES_COMPONENTS_TRANSFORM_HPP_
4
5#include <numbers>
6
7#include <libsbx/ecs/meta.hpp>
8
9#include <libsbx/math/vector3.hpp>
10#include <libsbx/math/matrix4x4.hpp>
11#include <libsbx/math/angle.hpp>
12#include <libsbx/math/quaternion.hpp>
13
14namespace sbx::scenes {
15
16class transform final {
17
18public:
19
20 transform(const math::vector3& position = math::vector3::zero, const math::quaternion& rotation = math::quaternion::identity, const math::vector3& scale = math::vector3::one);
21
22 ~transform() = default;
23
24 auto position() const noexcept -> const math::vector3&;
25
26 auto position() noexcept -> math::vector3&;
27
28 auto set_position(const math::vector3& position) noexcept -> void;
29
30 auto move_by(const math::vector3& offset) noexcept -> void;
31
32 auto rotation() const noexcept -> const math::quaternion&;
33
34 auto set_rotation(const math::quaternion& rotation) noexcept -> void;
35
36 auto set_rotation(const math::vector3& axis, const math::angle& angle) noexcept -> void;
37
38 auto scale() noexcept -> math::vector3&;
39
40 auto scale() const noexcept -> const math::vector3&;
41
42 auto set_scale(const math::vector3& scale) noexcept -> void;
43
44 auto forward() const noexcept -> math::vector3;
45
46 auto right() const noexcept -> math::vector3;
47
48 auto up() const noexcept -> math::vector3;
49
50 auto look_at(const math::vector3& target) noexcept -> void;
51
52 auto version() const noexcept -> std::uint64_t;
53
54 auto bump_version() -> void;
55
56 [[nodiscard]] auto local_transform() const -> math::matrix4x4;
57
58private:
59
60 math::vector3 _position;
61 math::quaternion _rotation;
62 math::vector3 _scale;
63
64 math::matrix4x4 _rotation_matrix;
65
66 std::uint64_t _version;
67
68}; // class transform
69
70} // namespace sbx::scenes
71
72// template<>
73// struct sbx::ecs::meta<sbx::scenes::transform> {
74// auto operator()(const utility::hashed_string& tag, sbx::scenes::transform& value) -> void {
75// if (tag == "save") {
76
77// }
78// }
79// }; // sbx::ecs::meta
80
81#endif // LIBSBX_SCENES_COMPONENTS_TRANSFORM_HPP_
Angle types and utilities.
Unified angle type stored internally in radians.
Definition: angle.hpp:591
Definition: matrix4x4.hpp:26
Definition: quaternion.hpp:25
Definition: vector3.hpp:23
Definition: transform.hpp:16