Skylicht Engine
Loading...
Searching...
No Matches
Skylicht::CSkeleton Class Reference

Manages a hierarchy of animated entities, handling keyframe updates and animation blending. More...

#include <Animation/Skeleton/CSkeleton.h>

Public Types

enum  EAnimationType { KeyFrame = 0 , Blending }
 Operating modes for the skeleton. More...
enum  EAnimationLayerType { DefaultBlending , Replace , Addtive }
 Blending algorithms for layers. More...

Public Member Functions

 CSkeleton (int id)
void initSkeleton (core::array< CEntity * > &entities)
 Initializes the skeleton hierarchy from a list of world entities.
void releaseAllEntities ()
 Releases all bone entities.
void update ()
 Updates the animation state.
void updateActivateEntities ()
 Filters and caches bones that are currently contributing to the animation.
int simulateTransform (float timeSecond, core::matrix4 origin, core::matrix4 *transforms, int numTransform)
 Simulates the skeleton at a specific time and returns world matrices.
void getBoneIdMap (std::map< std::string, int > &bones)
 Builds a map from bone names to bone IDs.
void applyTransform ()
 Applies calculated local PRS to the relative matrices of bones.
void syncAnimationByTimeScale ()
 Synchronizes time across multiple blended layers based on the highest weight.
void setAnimation (CAnimationClip *clip, bool loop, bool pause=false)
 Sets an animation clip to play on this skeleton.
void setAnimation (CAnimationClip *clip, bool loop, float from, float duration, bool pause=false)
 Sets an animation clip with a specific range.
void setJointWeights (float weight)
 Sets the blending weight for ALL joints in the skeleton.
void setJointWeights (const char *name, float weight, bool includeChild=true)
 Sets the blending weight for a specific joint and its children.
void getJoints (const char *name, std::vector< CAnimationTransformData * > &joints)
 Gets a list of joint data pointers starting from a named joint.
void setJointWeights (std::vector< CAnimationTransformData * > &joints, float weight)
 Sets blending weights for a provided list of joints.
CAnimationTransformDatagetJoint (const char *name)
 Gets the joint data for a specific bone name.
std::vector< CAnimationTransformData * > & getJoints ()
 Gets the list of all joint data in the skeleton.
CAnimationClipgetCurrentAnimation ()
 Gets the currently assigned animation clip.
int getID ()
 Gets the skeleton ID.
bool isEnable ()
 Checks if the skeleton is enabled.
void setEnable (bool b)
 Sets whether the skeleton is enabled.
CAnimationTimelinegetTimeline ()
 Gets the animation timeline for this skeleton.
void setAnimationType (EAnimationType type)
 Sets the operating mode of the skeleton.
EAnimationType getAnimationType ()
 Gets the current operating mode.
void setLayerType (EAnimationLayerType type)
 Sets the blending algorithm (Replace, Addtive, etc.) for this skeleton layer.
EAnimationLayerType getLayerType ()
 Gets the layer blending type.
void notifyUpdateActivateEntities ()
 Manually notifies the skeleton to refresh its active joint list.
void setTarget (CSkeleton *skeleton)
 Sets the target skeleton that this skeleton will blend into.
CSkeleton * getTarget ()
 Gets the target skeleton.
std::vector< CSkeleton * > & getBlending ()
 Gets the list of layers (sub-skeletons) blending into this skeleton.
void addBlending (CSkeleton *skeleton)
 Adds a layer to blend into this skeleton.
void removeBlending (CSkeleton *skeleton)
 Removes a blended layer.
void drawDebug (const core::matrix4 &transform, const SColor &c)
 Draws the skeleton hierarchy for debugging.
void drawDebugDefaultSkeleton (const core::matrix4 &transform, const SColor &c)
 Draws the default pose of the skeleton.

Protected Member Functions

void setAnimationData ()
 Internal helper to set up keyframe data for each joint from the current clip.
void updateTrackKeyFrame ()
 Evaluates current keyframes and interpolates PRS data for all active joints.
void updateBlending ()
 Orchestrates the blending of all attached layers.
void doBlending (CSkeleton *skeleton, bool first)
 Performs standard linear blending from a source layer.
void doAddtive (CSkeleton *skeleton, bool first)
 Performs additive blending from a source layer.
void doReplace (CSkeleton *skeleton, bool first)
 Performs override (replace) blending from a source layer.

Protected Attributes

CEntityPrefab m_entities
 Collection of entities (bones) in this skeleton.
std::vector< CAnimationTransformData * > m_entitiesData
 List of internal animation data for each bone.
core::array< CAnimationTransformData * > m_entitiesActivated
 List of bones that are currently active (weight > 0).
CAnimationTransformDatam_root
 Pointer to the root bone data.
int m_id
 Unique ID of the skeleton.
bool m_enable
 Whether this skeleton is enabled.
bool m_needUpdateActivateEntities
 Flag to trigger update of activated entities.
CAnimationTimeline m_timeline
 Playback state for this skeleton.
EAnimationType m_animationType
 Current operating mode.
CAnimationClipm_clip
 Currently assigned animation clip.
EAnimationLayerType m_layerType
 Blending type for this skeleton (when used as a layer).
CSkeleton * m_target
 For blending: the skeleton that this layer blends into.
std::vector< CSkeleton * > m_blending
 List of sub-skeletons (layers) that blend into this skeleton.

Detailed Description

Manages a hierarchy of animated entities, handling keyframe updates and animation blending.

Example of setting up blending

CSkeleton* baseSkeleton = animController->createSkeleton();
CSkeleton* walkLayer = new CSkeleton(1);
walkLayer->initSkeleton(renderMesh->getEntities());
walkLayer->setAnimation(walkClip, true);
walkLayer->setTarget(baseSkeleton);
Manages a hierarchy of animated entities, handling keyframe updates and animation blending.
Definition CSkeleton.h:50
void setTarget(CSkeleton *skeleton)
Sets the target skeleton that this skeleton will blend into.
void setAnimation(CAnimationClip *clip, bool loop, bool pause=false)
Sets an animation clip to play on this skeleton.
void initSkeleton(core::array< CEntity * > &entities)
Initializes the skeleton hierarchy from a list of world entities.
@ Blending
Standard mode: plays a single animation clip.
Definition CSkeleton.h:58
void setAnimationType(EAnimationType type)
Sets the operating mode of the skeleton.
Definition CSkeleton.h:276

Member Enumeration Documentation

◆ EAnimationLayerType

Blending algorithms for layers.

Enumerator
Replace 

Normal linear blending.

Addtive 

Overrides previous layers.

◆ EAnimationType

Operating modes for the skeleton.

Enumerator
Blending 

Standard mode: plays a single animation clip.

Member Function Documentation

◆ addBlending()

void Skylicht::CSkeleton::addBlending ( CSkeleton * skeleton)

Adds a layer to blend into this skeleton.

Parameters
skeletonPointer to layer skeleton.

◆ drawDebug()

void Skylicht::CSkeleton::drawDebug ( const core::matrix4 & transform,
const SColor & c )

Draws the skeleton hierarchy for debugging.

Parameters
transformRoot transform matrix.
cColor of the skeleton lines.

◆ drawDebugDefaultSkeleton()

void Skylicht::CSkeleton::drawDebugDefaultSkeleton ( const core::matrix4 & transform,
const SColor & c )

Draws the default pose of the skeleton.

Parameters
transformRoot transform matrix.
cColor of the skeleton lines.

◆ getAnimationType()

EAnimationType Skylicht::CSkeleton::getAnimationType ( )
inline

Gets the current operating mode.

Returns
EAnimationType.

◆ getBlending()

std::vector< CSkeleton * > & Skylicht::CSkeleton::getBlending ( )
inline

Gets the list of layers (sub-skeletons) blending into this skeleton.

Returns
Vector of skeleton pointers.

◆ getBoneIdMap()

void Skylicht::CSkeleton::getBoneIdMap ( std::map< std::string, int > & bones)

Builds a map from bone names to bone IDs.

Parameters
bones[out] Map to populate.

◆ getCurrentAnimation()

CAnimationClip * Skylicht::CSkeleton::getCurrentAnimation ( )
inline

Gets the currently assigned animation clip.

Returns
Pointer to CAnimationClip.

◆ getID()

int Skylicht::CSkeleton::getID ( )
inline

Gets the skeleton ID.

Returns
ID.

◆ getJoint()

CAnimationTransformData * Skylicht::CSkeleton::getJoint ( const char * name)

Gets the joint data for a specific bone name.

Parameters
nameBone name.
Returns
Pointer to CAnimationTransformData, or NULL if not found.

◆ getJoints() [1/2]

std::vector< CAnimationTransformData * > & Skylicht::CSkeleton::getJoints ( )
inline

Gets the list of all joint data in the skeleton.

Returns
Vector of joint data pointers.

◆ getJoints() [2/2]

void Skylicht::CSkeleton::getJoints ( const char * name,
std::vector< CAnimationTransformData * > & joints )

Gets a list of joint data pointers starting from a named joint.

Parameters
nameThe name of the joint.
joints[out] Vector to store pointers.

◆ getLayerType()

EAnimationLayerType Skylicht::CSkeleton::getLayerType ( )
inline

Gets the layer blending type.

Returns
EAnimationLayerType.

◆ getTarget()

CSkeleton * Skylicht::CSkeleton::getTarget ( )
inline

Gets the target skeleton.

Returns
Pointer to target skeleton.

◆ getTimeline()

CAnimationTimeline & Skylicht::CSkeleton::getTimeline ( )
inline

Gets the animation timeline for this skeleton.

Returns
Reference to CAnimationTimeline.

◆ initSkeleton()

void Skylicht::CSkeleton::initSkeleton ( core::array< CEntity * > & entities)

Initializes the skeleton hierarchy from a list of world entities.

Parameters
entitiesList of entities representing the model's bones.

◆ isEnable()

bool Skylicht::CSkeleton::isEnable ( )
inline

Checks if the skeleton is enabled.

Returns
True if enabled.

◆ removeBlending()

void Skylicht::CSkeleton::removeBlending ( CSkeleton * skeleton)

Removes a blended layer.

Parameters
skeletonPointer to layer skeleton.

◆ setAnimation() [1/2]

void Skylicht::CSkeleton::setAnimation ( CAnimationClip * clip,
bool loop,
bool pause = false )

Sets an animation clip to play on this skeleton.

Parameters
clipPointer to the clip.
loopWhether to loop.
pauseWhether to start paused.

◆ setAnimation() [2/2]

void Skylicht::CSkeleton::setAnimation ( CAnimationClip * clip,
bool loop,
float from,
float duration,
bool pause = false )

Sets an animation clip with a specific range.

Parameters
clipPointer to the clip.
loopWhether to loop.
fromStart time in seconds.
durationPlayback duration in seconds.
pauseWhether to start paused.

◆ setAnimationType()

void Skylicht::CSkeleton::setAnimationType ( EAnimationType type)
inline

Sets the operating mode of the skeleton.

Parameters
typeOperating mode.

◆ setEnable()

void Skylicht::CSkeleton::setEnable ( bool b)
inline

Sets whether the skeleton is enabled.

Parameters
bEnable state.

◆ setJointWeights() [1/3]

void Skylicht::CSkeleton::setJointWeights ( const char * name,
float weight,
bool includeChild = true )

Sets the blending weight for a specific joint and its children.

Parameters
nameThe name of the joint.
weightBlending weight.
includeChildWhether to apply to children recursively.

◆ setJointWeights() [2/3]

void Skylicht::CSkeleton::setJointWeights ( float weight)

Sets the blending weight for ALL joints in the skeleton.

Parameters
weightBlending weight (0 to 1).

◆ setJointWeights() [3/3]

void Skylicht::CSkeleton::setJointWeights ( std::vector< CAnimationTransformData * > & joints,
float weight )

Sets blending weights for a provided list of joints.

Parameters
jointsVector of joint data pointers.
weightBlending weight.

◆ setLayerType()

void Skylicht::CSkeleton::setLayerType ( EAnimationLayerType type)
inline

Sets the blending algorithm (Replace, Addtive, etc.) for this skeleton layer.

Parameters
typeLayer blending type.

◆ setTarget()

void Skylicht::CSkeleton::setTarget ( CSkeleton * skeleton)

Sets the target skeleton that this skeleton will blend into.

Parameters
skeletonPointer to target skeleton.

◆ simulateTransform()

int Skylicht::CSkeleton::simulateTransform ( float timeSecond,
core::matrix4 origin,
core::matrix4 * transforms,
int numTransform )

Simulates the skeleton at a specific time and returns world matrices.

Parameters
timeSecondTime in seconds.
originRoot transform.
transforms[out] Array to store resulting bone matrices.
numTransformMax size of transforms array.
Returns
Number of matrices calculated.

The documentation for this class was generated from the following file: