Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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!

Product Version: UE 4.11
more ▼

asked May 12 '16 at 10:28 PM in C++ Programming

avatar image

21 2 3 4

avatar image blsd May 12 '16 at 11:02 PM

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.

avatar image Zarkopafilis May 14 '16 at 12:06 PM

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

avatar image blsd May 15 '16 at 12:27 AM

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.

avatar image Zarkopafilis May 15 '16 at 04:54 AM

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

avatar image blsd May 15 '16 at 08:47 AM

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?

avatar image blsd May 15 '16 at 10:24 AM

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 alt text alt text. 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

kosci1.png (783.7 kB)
kosci2.png (808.9 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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++).
    1. Other way is to convert the relative bone location to world location

Any suggestions are welcome!

Thank you.

more ▼

answered Dec 20 '18 at 07:05 AM

avatar image

11 1 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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

more ▼

answered Dec 20 '18 at 05:51 PM

avatar image

6 1 1

avatar image Vinayaka_P Dec 21 '18 at 04:42 AM

Thank you for the answer.

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

avatar image MPalacios Dec 21 '18 at 08:52 AM

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;
avatar image Vinayaka_P Dec 24 '18 at 04:31 AM

Wow, it's so simple... Thank you very much.

avatar image Vinayaka_P Mar 04 '19 at 08:04 AM

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?alt text

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question