Merging Skeletal Animations onto Different Body Parts

Thanks to the blender, any user can split the skeleton into body parts and animate them separately. Doing it is simple: filter the bones and define groups.

Let’s have a blender containing two skeletal animation clip controllers: body and head.

At the initialization step, we want both to be played but on different bones:

  • Filter-out the body bones of the head animation (RED::ISkeletalAnimationController::SetBoneFilter)

  • Filter-out the head bones of the body animation

  • Set different groups for head and body (RED::ISkeletalAnimationController::SetGroup)

  • Set both blend weights to 1 (RED::ISkeletalAnimationController::SetBlendWeight)

// RED::Object* headController and bodyController are skeletal animation clip controllers controlling the same skeleton.
RED::ISkeletalAnimationController* iheadController = headController->As< RED::ISkeletalAnimationController >();
RED::ISkeletalAnimationController* ibodyController = bodyController->As< RED::ISkeletalAnimationController >();

// Add the animations to the blender.
RED::ISkeletalAnimationBlender* iblender = blender->As< RED::ISkeletalAnimationBlender >();
RC_TEST( iblender->AddController( headController ) );
RC_TEST( iblender->AddController( bodyController ) );

// Filter the head and body bones (head bone index is 3).
RC_TEST( iheadController->SetBoneFilter( 0, true, true ) );
RC_TEST( iheadController->SetBoneFilter( 3, false, true ) );
RC_TEST( ibodyController->SetBoneFilter( 3, true, true ) );

// Make them belong to a different group (useful for later BlendTo).
iheadController->SetGroup( 0 );
ibodyController->SetGroup( 1 );

// Both animations are played. We can do this because they animate different bones.
iheadController->SetBlendWeight( 1.0 );
ibodyController->SetBlendWeight( 1.0 );

After calling the RED::ISkeletalAnimationController::Update method, we see that both animations are played, each on its dedicated body part.