Skeleton
and Pose
based 3D Animation System for RayLib
- Layer based animation system.(Similar to Unity's Layered animation system).
- Overriden/Interpolated and Additive blending implemented at both
Pose
level andSkeleton
level. - Choice of blending using local pose or global pose.
- Convert global pose to local pose or vice versa.
Pose
is defined as array ofTransform
. So,ModelAnimation.framePoses[frame]
andModel.bindPose
are both considered asPose
and hence completely compatible with Pose functions.BoneMask
implementation to assist in split body animation.- Mask bones using bone name and regular expression.
Basic usage example is present in examples/skeleton/skeleton_animation_blending.c
This system in built with layer based animation blending(similar to Unity's Layered Animation) in mind. And its general usage consists of:
- First getting
Skeleton
from model.
Skeleton skeleton = LoadSkeletonFromModel(model);
-
Then assign a base pose to begin with. Base pose can be a single pose or a pose which is interpolated between two poses.
a. Use single pose.
void UpdateSkeletonModelAnimation(Skeleton skeleton, ModelAnimation anim, int frame);
or use the following way(above one is preffered).
skeleton.pose = CopyPose(model.bindPose, model.boneCount);
b. Use interpolated/blended pose.
void UpdateSkeletonModelAnimationPoseLerp(Skeleton skeleton, ModelAnimation animA, int frameA, ModelAnimation animB, int frameB, float blendFactor);
-
Then add any number of layers as needed.
a. Add Override/Interpolation layer
void UpdateSkeletonModelAnimationPoseOverrideLayer(Skeleton skeleton, ModelAnimation anim, int frame, float factor, /* weight of layer */ int flags, /* not implemented */ float *boneMask); /* affect per bone */
b. Add Additive layer
void UpdateSkeletonModelAnimationPoseAdditiveLayer(Skeleton skeleton, ModelAnimation anim, int frame, Pose referencePose/* reference pose */ float factor, /* weight of layer */ int flags, /* not implemented */ float *boneMask); /* affect per bone */
Don't know what reference pose is and why is it needed?
The transforms which when applied to reference pose makes it target pose. Additive layer calculates those transforms and applies toSkeleton
's pose.
More Docs, Examples and Features Comming Soon ...
Happy Animating :)