Extract bone locations from an animations frame

Hey guys,

Does anyone know of a way on how to, having an animation sequence, extract locations/transformations of each bone in a given frame? I don’t need to modify the bone locations, I only need to get out the data to use it later on.

Thanks in advance!

I have tried using the UAnimSequence->GetBoneTransform(), but I don’t know what the track is in this context. The documentation doesn’t explain that.

There sould be a way in engine but you could just parse the fbx file manually and gather info from that

This would be definitely something I would like to avoid - the engine has already done this, so it would be illogical to parse the file once again myself.

I believe that the track index actually maps to a bone index somehow. Probably through the use of a skeleton asset.

The skeleton asset stores the hierarchy and the starting transform of each bone, the animation sequence asset is a series of offset keyframes (over time). Also, animation tick is different than the normal blueprint/c++ tick so you can’t listen in-game once and save to a file either

So if I understand correctly - the first frame of the animation sequence holds bone transforms relative to the reference pose in the skeleton asset. Am I correct?

This is what I have currently done to compare the meshes http://codepaste.net/j2ngq1

I don’t know exactly why, but this doesn’t really work. Here are two screenshots showing how it looks like

. The blue lines are of bones from the ragdoll, the red ones are the animation bones. Doesn’t seem right to me. Is there a bug in my function or are the positions in the animation different? You can clearly see some features there, e.g. hands

But you didn’t mention in which space you want the bone location (WorldSpace, or relative to parent)

If it is relative to parent bone, here is the answer:

FTransform OutAtom;
FVector BoneLocation;
AnimSequence->GetBoneTransform(OutAtom, TrackIndex, InTime, bUseRawData);
BoneLocation = OutAtom.GetLocation();

(Please calculate InTime for required frame of AnimSequence by doing some math)
Here’s documentation
Now…
I’m also looking for an answer to this question, but I want location of bone in worldspace.
What I’ve observed so far:

  1. In persona editor i can see both local as well as world location of a bone/track in an animation sequence. But i couldn’t find that functionality in scripting (c++).
    2. Other way is to convert the relative bone location to world location

Any suggestions are welcome!

Thank you.

You should take a look at UAnimInstance::SnapshotPose(FPoseSnapshot& Snapshot), the struct is will contain the data you need.

Thank you for the answer.

FPoseSnapshot contained local transform, but do you how to convert that into world location?

Think about it logically.
Your relative location is the vector you must move, starting from the root bone, to get to your specific bone’s location. So to convert, all you need to do is add the root bone’s location, which should be equal to the MeshComponent’s location.

The function GetComponentLocation returns the location in world space. So add your bone’s relative location and you’re there.

FVector RelativeLocation;

FVector WorldLocation = GetMesh()->GetComponentLocation() + RelativeLocation;

Wow, it’s so simple…
Thank you very much.

Ooops, the local transform (in the FPoseSnapshot) is not accurate, is containing some offset (see the picture below).There’s no error in process of converting from LocalTransform to WorldTransofrm. Donno why?