6#include <glm/mat4x4.hpp>
68 void addBlendShape(
const std::string& name,
const std::vector<BlendShapeData>& blendshape_data);
74 void setWeight(
const std::string& name,
const float weight);
86 inline uint32_t getCount() {
return _count; }
87 inline uint32_t getTotalAffectedVerticesCount() {
return _vertices_count; }
91 uint32_t _vertices_count = 0;
92 std::vector<float> _blendshape_raw_data;
94 std::vector<std::string> _names;
95 std::vector<float> _weights;
101 template <IsSkinnedVertex VertexType>
106 const auto& bones = v.bones;
107 const auto& weights = v.weights;
109 return (bones.x == id_bone && weights.x > 0.f)
110 || (bones.y == id_bone && weights.y > 0.f)
111 || (bones.z == id_bone && weights.z > 0.f)
112 || (bones.w == id_bone && weights.w > 0.f);
130 bones_matrices.push_back(glm::mat4(1.0));
134 .inverse_bind_matrix = inverse_bind_matrix,
135 .raw_bounding_box = bone_bbox,
136 .bounding_box = bone_bbox
149 std::vector<Bone> bones;
150 std::vector<glm::mat4> bones_matrices;
Axis-aligned bounding box.
Definition aabb.h:13
const std::vector< float > & getAllWeights() const
Definition skin.h:79
std::vector< uint8_t > getPackedData()
size_t getIdFromName(const std::string &name)
BlendShapeManager(size_t count, size_t vertices)
void setWeight(const std::string &name, const float weight)
void addBlendShape(const std::string &name, const std::vector< BlendShapeData > &blendshape_data)
Helpers and classes related to skinned meshes.
Definition skin.h:13
AABB generateBoneBoundingBox(const scene::Mesh< VertexType > &mesh, const int32_t id_bone)
Compute bone bounding box by taking all influenced vertices in the mesh.
Definition skin.h:102
constexpr AABB generateBoundingBoxFromPredicate(const MeshType &mesh, F &&predicate) noexcept
Generate a bounding box containing vertices matching a predicate.
Definition aabb.h:275
uint32_t index_t
Definition vertex.h:13
Wrapper to a node reference to use pointers to node even if the actual node moves in memory.
Definition node_ptr.h:19
Skinned mesh skeleton.
Definition skin.h:120
void update()
Update armature.
void addBone(NodePtr node, const AABB &bone_bbox, const glm::mat4 &inverse_bind_matrix)
Add a bone to the armature.
Definition skin.h:128
index_t index
Definition skin.h:39
glm::vec3 position
Definition skin.h:42
Skinned mesh bone.
Definition skin.h:18
AABB raw_bounding_box
Definition skin.h:26
scene::NodePtr node
Definition skin.h:20
glm::mat4 inverse_bind_matrix
Definition skin.h:23
AABB bounding_box
Definition skin.h:29