the line skeleton.Data.Bone.Items[timeline.BoneIndex]
contains the bone data, which is the setup pose. You want to access the timeline.frames
and timeline.curves
array values instead which contains the frame animation data. Then you will need to interpret (or evaluate) the curves
float array accordingly as each Timeline subclass Apply
does (e.g. TranslateTimeline.Apply()
). Here the frames
array stores key-frame values (time and value) and the curve values store linear curve segments between those key-frames, like e.g. [frame i] [segment_0] [segment_1]..[segment_7] [segment_8] [frame i + 1]
.
On how to read and reconstruct the Bezier curve values and tangents, you can check out and set a breakpoint at e.g. Animation.cs : line 585
which is accessing the frames
and curves
array accordingly.
The following image shows the curve
array content for a TranslateTimeline of a simple json test file with two bezier curve keys that just move a bone in x direction and have horizontal curve handles:
Note that here the actual curve values start at index 2 for a Bezier curve, where the offset is curveType - BEZIER // (4 - 2)
as accessed by this line:
x = GetBezierValue(time, i, VALUE1, curveType - BEZIER);
The Bezier curve values are stored as linear segments (9 segments) that lie between the first and second key values. It's always time, value
pairs, summing up to 18 float values per curve. So at a TranslateTimeline curve (x and y) the curve contains 2 * 18 curve segment values between the key values, which are stored at the frames
float array.
To reconstruct the tangents you would now e.g. use the first and last curve segment values in relation to the frame values that they lie next to:
accessing time values:
[frame_i] [segment_0] ... [segment_8] [frame i + 1]
accessing value, the index is +1 higher:
[frame_i + 1] [segment_0 + 1] ... [segment_8 + 1] [frame_i + 1]
Here at a bezier curve, the segment_0
array index location would be 2 so you access it as curves[2]
(time = curves[2]
, value = curves[2 + 1]
).
The segment_8
array index location would be 2 + 8 * 2 = 18 so you access it as curves[18]
(time = curves[18]
, value = curves[18 + 1]
).
Then you can calculate the time and value delta to get the first and last tangents.