Download

Animating Skeleton with local Transforms/Blueprint

Hi everyone,

I’m creating an animation blueprint to control the pose of a skeleton, but whenever a change several bones in a chain they do not accumulate the transforms. So e.g. I rotate a bone and then I rotate it’s child and the rotations occur only in regard to the bind pose… I know this is a simple task, but I can’t get it to work… i just don’t get it Dx…

The code that I currently have is this




if(BoneToModify.IsValid(BoneContainer))

        FCompactPoseBoneIndex BoneIndexRS = BoneToModify.GetCompactPoseIndex(BoneContainer);
        FTransform BoneTransformRS = MeshBases.GetComponentSpaceTransform(BoneIndexRS);
        FAnimationRuntime::ConvertCSTransformToBoneSpace(SkelComp, MeshBases, BoneTransformRS, BoneIndexRS, BCS_BoneSpace);
        FRotator RotationRS = FRotator();
        RotationRS.Yaw = 35.0f;
        const FQuat BoneQuatRS(RotationRS);
        BoneTransformRS.SetRotation(BoneQuatRS * BoneTransformRS.GetRotation());
        FAnimationRuntime::ConvertBoneSpaceTransformToCS(SkelComp, MeshBases, BoneTransformRS, BoneIndexRS, BCS_BoneSpace);
                                            
        OutBoneTransforms.Add(FBoneTransform(BoneIndexRS, BoneTransformRS));
    }

if (BoneToModifyChild.IsValid(BoneContainer)){

        FCompactPoseBoneIndex BoneIndexRS = BoneToModifyChild.GetCompactPoseIndex(BoneContainer);
        FTransform BoneTransformRS = MeshBases.GetComponentSpaceTransform(BoneIndexRS);       
        FAnimationRuntime::ConvertCSTransformToBoneSpace(SkelComp, MeshBases, BoneTransformRS, BoneIndexRS, BCS_BoneSpace);
        FRotator RotationRS = FRotator();
        RotationRS.Yaw = 35.0f;
        const FQuat BoneQuatRS(RotationRS);
        BoneTransformRS.SetRotation(BoneQuatRS * BoneTransformRS.GetRotation());
        FAnimationRuntime::ConvertBoneSpaceTransformToCS(SkelComp, MeshBases, BoneTransformRS, BoneIndexRS, BCS_BoneSpace); 

        OutBoneTransforms.Add(FBoneTransform(BoneIndexRS, BoneTransformRS));

}


I’ve tried going into accumulating the rotations and translations directly with the quaternions… but I failed miserably. So if you think that is a more suitable way I’m all ears!

Any help would be more than welcome!
Thanks