sandbox
Loading...
Searching...
No Matches
animation.hpp
1// SPDX-License-Identifier: MIT
2#ifndef LIBSBX_ANIMATIONS_ANIMATION_HPP_
3#define LIBSBX_ANIMATIONS_ANIMATION_HPP_
4
5#include <string>
6#include <vector>
7#include <filesystem>
8
9#include <libsbx/utility/hashed_string.hpp>
10
11#include <libsbx/math/vector3.hpp>
12#include <libsbx/math/quaternion.hpp>
13#include <libsbx/math/uuid.hpp>
14
16
17namespace sbx::animations {
18
19class animation {
20
21public:
22
23 struct bone_track {
24 spline<math::vector3> position_spline;
25 spline<math::quaternion> rotation_spline;
26 spline<math::vector3> scale_spline;
27 }; // struct bone_track
28
29 animation(const std::filesystem::path& path, const std::string& name);
30
31 auto track_map() const noexcept -> const std::unordered_map<utility::hashed_string, bone_track>&;
32
33 auto duration() const noexcept -> std::float_t;
34
35private:
36
37 std::string _name;
38 std::float_t _duration = 0.0f;
39 std::float_t _ticks_per_second = 25.0f;
40
41 std::unordered_map<utility::hashed_string, bone_track> _track_map;
42
43}; // class animation
44
45struct animation_handle : public math::uuid {
46
47 constexpr animation_handle()
48 : math::uuid{math::uuid::nil()} { }
49
50 constexpr explicit animation_handle(const math::uuid& id)
51 : math::uuid{id} { }
52
53 constexpr auto is_valid() const noexcept -> bool {
54 return (*this) != math::uuid::nil();
55 }
56
57 constexpr auto operator==(const animation_handle& other) const noexcept -> bool = default;
58
59}; // struct animation_handle
60
61} // namespace sbx::animations
62
63#endif // LIBSBX_ANIMATIONS_ANIMATION_HPP_
Definition: animation.hpp:19
Time-ordered spline for interpolated animation values.
Definition: spline.hpp:65
Definition: uuid.hpp:15
Generic time-based spline container for animation sampling.
Definition: animation.hpp:23
Definition: animation.hpp:45