SkinnedMesh
A mesh that has a Skeleton with bones
that can then be used to animate the vertices of the geometry..
This class extends Mesh to support skeletal
animation using a skeleton composed of bones. It allows for realistic
deformation of meshes based on bone movements.
- Skeletal animation support with bone hierarchies
- Bind matrix management for bone transformations
- Bounding volume computation for animated meshes
- Skin weight normalization for smooth deformations
- 4 Bones per Vertex
Methods
SkinnedMesh()
Default constructor - creates an empty skinned mesh
SkinnedMesh(BufferGeometry* geometry, Material* material)
Constructor with geometry and optional material
| geometry | Pointer to geometry with skin data | |
| material | Pointer to material to use | nullptr |
void bind(Skeleton* skeleton, Mtx* bindMatrix)
Binds a skeleton to this skinned mesh
| skeleton | The skeleton to bind | |
| bindMatrix | The bind matrix | nullptr |
void pose()
Sets the skinned mesh to rest pose (resets the pose)
void normalizeSkinWeights()
Normalizes the skin weights to ensure they sum to 1.0
void computeBoundingBox()
Computes the bounding box of the skinned mesh and updates the boundingBox property
void computeBoundingSphere()
Computes the bounding sphere of the skinned mesh and updates the boundingSphere property
void getVertexPosition(u32 index, Vector3& target)
Gets the transformed vertex position for the given index
| index | Vertex index to get position for | 0 |
| target | Vector to store the position | Vector3() |
void applyBoneTransform(u32 index, Vector3& target)
Applies the bone transform associated with the given index to the provided position vector
| index | Vertex index to transform | 0 |
| target | Vector to store transformed position | Vector3() |
virtual void render()
Renders this skinned mesh with bone transformations applied
virtual SkinnedMesh* clone(bool recursive) const
Creates a copy of this skinned mesh
| recursive | Whether to clone children | true |
virtual void copy(const Object3D& object, bool recursive) override
Copies properties from another object
| object | Source object to copy from | |
| recursive | Whether to copy children | true |
Properties
| isSkinnedMesh | bool | Read |
| bindMode | BindMode | Either AttachedBindMode or DetachedBindMode |
| bindMatrix | Mtx | The base matrix that is used for the bound bone transforms |
| bindMatrixInv | Mtx | The base matrix that is used for resetting the bound bone transforms |
| skeleton | Skeleton * | Skeleton representing the bone hierarchy of the skinned mesh |
| boundingBox | Box3 * | The bounding box of the SkinnedMesh |
| boundingSphere | void * | The bounding sphere of the SkinnedMesh |