2#ifndef LIBSBX_ANIMATIONS_ANIMATIONS_MODULE_HPP_
3#define LIBSBX_ANIMATIONS_ANIMATIONS_MODULE_HPP_
5#include <libsbx/core/module.hpp>
6#include <libsbx/core/engine.hpp>
8#include <libsbx/utility/logger.hpp>
10#include <libsbx/scenes/node.hpp>
11#include <libsbx/scenes/scenes_module.hpp>
13#include <libsbx/scenes/components/skinned_mesh.hpp>
15#include <libsbx/animations/animator.hpp>
16#include <libsbx/animations/animation.hpp>
17#include <libsbx/animations/mesh.hpp>
19namespace sbx::animations {
23 inline static const auto is_registered = register_module(stage::post);
31 auto update() ->
void override;
33 template<
typename... Args>
35 auto& assets_module = core::engine::get_module<assets::assets_module>();
36 auto& scenes_module = sbx::core::engine::get_module<sbx::scenes::scenes_module>();
38 auto& scene = scenes_module.active_scene();
39 auto& environment = scene.environment();
40 auto& graph = scene.graph();
50 const auto& bones =
skeleton.bones();
52 auto nodes = std::vector<scenes::node>{};
53 nodes.reserve(bones.size());
55 for (
auto i = 0u; i < bones.size(); ++i) {
56 const auto parent_id = bones[i].parent_id;
57 const auto parent = (parent_id == skeleton::bone::null) ?
node : nodes.at(parent_id);
59 const auto [position, rotation, scale] = math::decompose(bones[i].local_bind_matrix);
61 nodes.push_back(graph.create_child_node(parent,
skeleton.name_for_bone(i).str(),
scenes::transform{position, rotation, scale}));
64 skinned_mesh.set_nodes(std::move(nodes));
Definition: animations_module.hpp:21
Definition: animator.hpp:27
Definition: skeleton.hpp:21
Definition: module.hpp:92
Definition: skinned_mesh.hpp:27
Definition: hashed_string.hpp:17