Animations
Open metaverse projects need to make heavy use of animation retargeting. Any animation could be playing on any kind of model, with any kind of scale and deformation.
1.
The process begins with an AvatarAnimation packet being received from the server.
2.
a HandleNewAvatarAnimation packet is sent in response, which checks the target avatar for readiness.
3.
If the avatar is ready, build_animation() is called. This loops through every animation in the AnimationEntry.
3.
The animation's UUID is checked against the list of Default Animations. Default animations are expected to be pre-downloaded by the client, and are stored as GLTF in the Animations dir of the default assets repo.
4.
Benthic checks if a version of this animation has already been generated and cached for this skeleton. If it has, it uses that skeleton to build the retargeted animation. If not, it creates both a filtered json and a player-custom AnimationClip json.
5.
Retargeting is done within the retargeting module.
Animation Retargeting
Animations are represented in Benthic as AnimationClips. These contain the bind skeleton of the animation, along with a vector of JointAnimations, containing the joint name and animation qualities per keyframe.When moving from an animation from one skeleton to another, the only important transform is the root joint, which determines the root movement of the model. All other motions can be prepresented purely as rotations.
1.
The AnimationClip has its bind skeleton and keyframes filtered. In order to retarget from one skeleton to another, they must possess the exact same bone hierarchy. The target skeleton's list of used bones is used as the filter.
2.
The filtered AnimationClip is written to disk to build a cache of common bone layouts, to prevent regenerating unnecessarily.
2.
The retargeting function apply_joint_scale() is run on the AnimationClip. This performs the algorithm described here.