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.scene();
46 const auto& bones =
skeleton.bones();
48 auto nodes = std::vector<scenes::node>{};
49 nodes.reserve(bones.size());
51 for (
auto i = 0u; i < bones.size(); ++i) {
52 const auto parent_id = bones[i].parent_id;
53 const auto parent = (parent_id == skeleton::bone::null) ?
node : nodes.at(parent_id);
55 const auto [position, rotation, scale] = math::decompose(bones[i].local_bind_matrix);
57 nodes.push_back(scene.create_child_node(parent,
skeleton.name_for_bone(i).str(),
scenes::transform{position, rotation, scale}));
60 skinned_mesh.set_nodes(std::move(nodes));
Definition: animations_module.hpp:21
Definition: skeleton.hpp:21
Definition: module.hpp:92
Definition: skinned_mesh.hpp:27
Definition: hashed_string.hpp:17