Monad Engine da02fba2
> Undercity Codex_
Loading...
Searching...
No Matches
SkinnedMeshComponent.h
Go to the documentation of this file.
1/**
2 * @file SkinnedMeshComponent.h
3 * @ingroup mnd_components
4 * @brief Renderable component for GPU-skinned meshes driven by a Skeleton.
5 *
6 * Mirrors MeshComponent but uploads a per-frame bone palette as the
7 * `uBones` mat4[] uniform on its Material before submitting the draw.
8 *
9 * The palette source is plugged in externally — typically by an
10 * AnimationComponent on an ancestor GameObject. Until a source is wired,
11 * the component renders the bind pose (identity palette).
12 */
13
14#pragma once
15
16#include <memory>
17#include <vector>
18
19#include <glm/mat4x4.hpp>
20
21#include "Types.h"
22#include "scene/Component.h"
23
24namespace mnd
25{
26
27class Material;
28class Mesh;
29class Skeleton;
30class AnimationComponent;
31
33{
35
36public:
38 SkinnedMeshComponent(const std::shared_ptr<Material> &material,
39 const std::shared_ptr<Mesh> &mesh,
40 const std::shared_ptr<Skeleton> &skeleton);
41
42 void Update(f32 deltaTime) override;
43
44 void SetMaterial(const std::shared_ptr<Material> &material);
45 void SetMesh(const std::shared_ptr<Mesh> &mesh);
46 void SetSkeleton(const std::shared_ptr<Skeleton> &skeleton);
47
48 /// Plug an AnimationComponent (typically on the model root) as the live palette source.
50
51private:
52 std::shared_ptr<Material> m_material;
53 std::shared_ptr<Mesh> m_mesh;
54 std::shared_ptr<Skeleton> m_skeleton;
55 AnimationComponent *m_paletteSource = nullptr;
56 std::vector<glm::mat4> m_identityPalette; ///< Bind-pose fallback when no source wired.
57};
58
59} // namespace mnd
std::shared_ptr< Material > material
std::shared_ptr< Mesh > mesh
Engine-wide primitive type aliases and GLM math imports.
Drives transform animation on a hierarchy of GameObjects.
void SetMaterial(const std::shared_ptr< Material > &material)
void SetPaletteSource(AnimationComponent *anim)
Plug an AnimationComponent (typically on the model root) as the live palette source.
void SetMesh(const std::shared_ptr< Mesh > &mesh)
void Update(f32 deltaTime) override
void SetSkeleton(const std::shared_ptr< Skeleton > &skeleton)
#define COMPONENT(ComponentClass)
Definition Component.h:105
float f32
32-bit IEEE float — the standard GL scalar type.
Definition Types.h:40