We have this working now.
At first we recursively traversed the hierarchy of bones, and added the translations from the timelines (these should really be renamed to keys or keyframes, it makes debugging hard ๐ ).
However this does not work, the reason being is that the parent bone of an translation animation YisDown
is true, so if the parent bone moves -200 in the x, the translation in the timeline will be +200 and the bone will have a -180 rotation in the setup pose. You can do some extra maths to get the correct position but we opted for the method below. As a question (to nate I guess) What determines if Y is down on a bone?
This code plays an animation on the final frame and gets the world position of the bone. which works ๐
spAnimationStateData* stateData = spAnimationStateData_create( SkeletonData );
spAnimationState* newAnimState = spAnimationState_create( stateData );
spAnimationState_setAnimationByName( newAnimState, 0, animName, false );
skeleton->time = anim->duration;
spAnimationState_update( newAnimState, skeleton->time * 1 );
spAnimationState_apply( newAnimState, skeleton );
spSkeleton_updateWorldTransform( skeleton );
Vector2 pos = Vector2(GetBone(boneid).Translate.x, GetBone(boneid).Translate.y);