F-Curves, Keyframes, and the Power of Python

Having been working on the animation and putting data into it, I thought it made sense to write a post explaining how exactly the animation process works. In the last post on animation, I talked about the character mesh, UV unwrapping and rigging – and now I’m going to talk about the complete tangled mess fun-filled world of F-Curves and Keyframes.

Animations consist of things changing over time. In this case, we need the skeleton of our man to move – and to accurately represent how it moves, we use F-Curves. Each bone has several properties (describing location, scaling, and rotation in all axes), and when the animation is broken down like this we can represent the movement as a function of frame number on the x axis, and value on the y axis.

In each of these curves, we can insert keyframes. These are defined points on the line, and ensure that the F-Curve passes through them. Blender is clever enough to know how to smoothly interpolate between the keyframes by treating them as control points for a Bezier curve.

You can see an example of 100 frames worth of F-Curve for a simple animation that transitions from a normal pose to an “I’m-freezing-to-death” pose below:

Looks OK! Wait... what's that thick line in the middle?
Looks OK! Wait… what’s that thick line in the middle?
F-Curve2
A complete mess, apparently

As you can see, F-Curves are both numerous (>700 for just the pose!) and complicated – these are generated by posing the model in a 3D view. Our aim is to have the animation react to the real telemetry data from the balloon.

There were two possible approaches to this:

  1. Export each pose, interpolate between them to find intermediate poses, and select the appropriate in-between pose according to the data.
  2. Avoid the trouble of interpolating properly by baking the F-Curves (generating a keyframe at every frame) and exporting each one, then selecting the appropriate one according to the telemetry data.

I decided to go with the second approach – Blender is very good at performing the interpolation between the control points and it seemed unwise to introduce unnecessary complexity to the program. However, this does mean that a lot more data must be extracted and stored from the pre-baked animation.

The Blender Python API is incredibly extensive – absolutely every single part of the program can be scripted if desired. Thankfully, this makes it possible to automate keyframe insertion! The tool is still in the works, but you can check out the current progress at the GitHub repo here!

Dylan

Advertisements