How to create keyframes
by R. Niehoff
So what's a keyframe?
A keyfame describes a state of motion or animation. Between the different states the motion and animation of the character is interpolated by translating and rotating the entire character or rotating a part of the body. To create a chain of keyframes (also called "keyframe") you have to define at least 2 motion states and the time interval between the two states. Normally a keyframe in Tuxracer consists of 10 - 20 states.
An Example
The following keyframe is quite simple
*[time] 0 [pos] 1.5 0 0 [yaw] 180 [sh] 60 60
There are two states, and the time interval from the first to the second state is 2.6 seconds. The position differs from x = -2 to x = 1.5. So the character moves to the right for 3.5 units. The [yaw] defines the viewing direction of the character. With [yaw] 0 the character looks to the viewer, and with [yaw] 180 it shows his rear part. With the keyframe above the character turns smoothly. And the [sh] defines the stance of the arms. The first value is always the left, the second the right arm (or leg, or ankle). The arms are rotated at the schoulder joints (sh).
In this way it goes on, and apparently the last frame doesn't need a time value.
List with the possible motions:
[yaw] rotation of the entire body (y-axis) [pitch] rotation of the entire body (up, down) [neck] rotation at the neck joint (forward, backward) [head] rotation of the head (left, right) [sh] rotation of the arms at the shoulder joints (forward, backward) [hip] rotation of the legs at the hip joints (forward, backward) [knee] rotation of the lower legs at the knee joints (forward, backward) [ankle] rotation of the feed at the ankle joints (forward, backward)
Probably you miss some options, for example the arm rotation up and down. At the moment those motions are not implemented, but it's no problem to add them in the code.
Keyframes in Bunny Hill
Bunny Hill uses two keyframes: a start keyframe when Tux is moving to the startpoint and the end keyframe after Tux has passed the finishing line. Both must be adapted to the racing phase. That means that the final position in the start keyframe must be (0 0 0) to stop the motion at the startpoint. On the other hand, the end keyframe must begin with the position (0 0 0) to start the motion at the last racing position. Same with the orientation: during the race Tux is sliding on his belly, looking in -z direction. This orientation is described by the following values:
For the two situations I've written different keyframes, it's really easy! You can choose between 4 start frames (tux_walk, tux_walk2, tux_jump, tux_fast) and 2 finish frames (tux_joice, tux_sad). To enter one of these frames open main.cpp and change the entries in InitConfig ().
You can test your own keyframes or the modified Bunny Hill keyframes on the course but you may want to see more details. Therefore change the progmode in InitConfig () from RACE to KEYFRAME. Adjust the position with the cursor keys and pagedown/pageup. Press ENTER if you want to repeat the keyframe. The keyframe you want to test must be entered in InitConfig () as "testframe".