sandbox
Loading...
Searching...
No Matches
skinned_mesh.hpp
1// SPDX-License-Identifier: MIT
2#ifndef LIBSBX_SCENES_COMPONENTS_SKINNED_MESH_HPP_
3#define LIBSBX_SCENES_COMPONENTS_SKINNED_MESH_HPP_
4
5#include <vector>
6#include <cinttypes>
7
9#include <libsbx/math/uuid.hpp>
10
11#include <libsbx/graphics/resource_storage.hpp>
12
13#include <libsbx/graphics/images/image2d.hpp>
14
15#include <libsbx/scenes/node.hpp>
16
17#include <libsbx/scenes/components/static_mesh.hpp>
18
19namespace sbx::scenes {
20
22 float current_time = 0.0f;
23 float speed = 1.0f;
24 bool looping = true;
25}; // struct animation_state
26
27class skinned_mesh final {
28
29public:
30
31 struct submesh {
32 std::uint32_t index;
33 math::uuid material;
34 }; // struct submesh
35
36 skinned_mesh(const math::uuid mesh_id, const std::vector<submesh>& submeshes)
37 : _mesh_id{mesh_id},
38 _submeshes{submeshes} { }
39
40 skinned_mesh(const math::uuid mesh_id, const math::uuid material)
41 : _mesh_id{mesh_id},
42 _submeshes{{0, material}} { }
43
44 auto mesh_id() const noexcept -> math::uuid {
45 return _mesh_id;
46 }
47
48 auto submeshes() const noexcept -> const std::vector<submesh>& {
49 return _submeshes;
50 }
51
52 auto submeshes() noexcept -> std::vector<submesh>& {
53 return _submeshes;
54 }
55
56 auto set_nodes(std::vector<node>&& nodes) -> void {
57 _nodes = std::move(nodes);
58 }
59
60 auto nodes() const -> const std::vector<node>& {
61 return _nodes;
62 }
63
64 auto find_node(const std::uint32_t index) const -> node {
65 return _nodes.at(index);
66 }
67
68 auto set_pose(std::vector<math::matrix4x4>&& pose) -> void {
69 _pose = std::move(pose);
70 }
71
72 auto pose() const -> const std::vector<math::matrix4x4>& {
73 return _pose;
74 }
75
76private:
77
78 math::uuid _mesh_id;
79 std::vector<submesh> _submeshes;
80
81 std::vector<node> _nodes;
82 std::vector<math::matrix4x4> _pose;
83
84}; // class skinned_mesh
85
86} // namespace sbx::scenes
87
88#endif // LIBSBX_SCENES_COMPONENTS_SKINNED_MESH_HPP_
Definition: tests.cpp:6
Definition: uuid.hpp:160
Definition: skinned_mesh.hpp:27
RGBA color representation and utilities.
Definition: skinned_mesh.hpp:21
Definition: skinned_mesh.hpp:31