Polycode can load skeletons and play back skeletal animation for SceneMesh instances. You can blend multiple animations together to create smooth animation transitions or combine animations.


Loading skeletons.

Polycode uses a custom skeleton format (.skeleton), which you can convert assets to using the Polycode import tool (see Importing Assets). Skeletons are loaded via the Skeleton class and can be assigned to a SceneMesh via the setSkeleton method. Alternatively, you can call loadSkeleton directly on the SceneMesh instance.

SceneMesh *dummy = new SceneMesh("dummy.mesh");
Skeleton *skeleton = dummy->loadSkeleton("dummy.skeleton");
dummy = SceneMesh("dummy.mesh")
skeleton = dummy:loadSkeleton("dummy.skeleton")

Loading and playing animations.

Animations in Polycode are stored in individual animation files in a custom file format (.anim), which you can import to using the Polycode import tool (see Importing Assets). Use the loadSkeleton method to load an animation file into the skeleton, providing a name for the loaded animation. Once loaded, you can play the animation using setBaseAnimationByName. This sets the base animation that is being played on loop by the skeleton. On top of this animation, you can blend other animations (see Blending animations).

skeleton->addAnimation("idle", "idle.anim");
skeleton:addAnimation("idle", "idle.anim")

Blending animations.

Blending animations requires a base animation to be loaded and playing. To blend another animation on top of the base animation, use the playAnimationByName method, providing it a weight value from 0.0 to 1.0 as the second argument. You can blend multiple animations together using different weights.

skeleton->addAnimation("run", "run.anim");
skeleton->playAnimationByName("run", 0.5, false, false);
skeleton:addAnimation("run", "run.anim")
skeleton:playAnimationByName("run", 0.5, false, false)