Animation involves rendering a sequence of frames that are then assembled into a format suitable for animated display. The generation of each frame from one or more scene files can be performed using POV-Ray. Assembly needs to be performed using a separate tool. Various tools are available to assemble individual frames generated by POV-Ray as BMP or PNG files into an animated format (e.g. animated GIF, MOV or MPEG).
Various approaches can be used with POV-Ray to generate frames for animation. This documentation only covers the technique used by the POV-Person library.
POV-Person helps to shortcut the normal processes of animation by using a small number of manually defined key-poses and interpolating between them. POV-Person also incorporates macros to provide position mirroring to further reduce the number of poses that need to be manually defined. As a consequence, the standard 30 frame animation loop of a person walking has been constructed using four manually defined poses.
POV-Person includes various pre-defined sequences and these sequences can be chained together and smoothed using POV-Person macros to enable more complex sequences to be developed. Furthermore, interpolated frames can be written to disk enabling them to be used as key-poses for other animations.
The ppwalking.inc file uses the POV-Ray clock variable to control the animation sequence. If you use it in a normal static scene file, the clock variable will default to 0 which will generate the first position from the walking sequence.
To animate a scene you can add the +KFF command line option followed by a value for the number of frames to generate.
For example +KFF6 will generate 6 frames and will cycle the clock variable from 0 to 1 as it does so. This means that when the first frame is generated the clock variable will have a value of 0, for the second frame it will have a value of 0.2, and for the third through sixth frames the clock variable will have the values 0.4, 0.6, 0.8 and 1. The figure on the right shows how to set the command line option when using the Windows version of POV-Ray. |
![]() |
The ppwalking.inc file uses a set of 8 files that define the key poses. These files are ppwalking0.inc through ppwalking7.inc. The first 4 files contain joint rotation settings. The last 4 files use the first 4 files and then mirror those joint rotation settings.
If you open ppwalking.inc in a text editor you will notice that it starts with a little bit of SDL that allows you to render a scene from the include file (The 8 include files storing the key poses contain something similar). Ignore this for now and look for the following lines of SDL:
The ppWalkTimings array effectively stores the timing of the 8 key poses. Notice that these don't have to be at regular intervals, so the interval between the first key pose (as stored in ppwalking0.inc) and the second key pose (as stored in ppwalking1.inc) will be 0.2 clock cycles, whereas the interval between the second and third key poses is only 0.1 clock cycles. Notice also that there are 9 timings specified. Because our walking loop will repeat once per full clock cycle, the last time boundary (1 clock cycle) will map to the first time boundary (0 clock cycles).
The next section of SDL works out which pose files to use for this image frame based upon the value of the clock. In fact we use our own version of the clock setting called ppClock that needs to be defined in the main scene file. In this case if you look at the file pp00animationexample01.pov you'll see that the ppClock variable is defined as being clock*ppFrameCount/(ppFrameCount+1) where ppFrameCount is the number of frames that will be rendered.
In ppwalking.inc, we use a #while loop to step through the timings recorded in the ppWalkTimings array using ppClock variable to work out which pose files we need to use to generate the current frame. The first pose file is included. The ppStashJointRotations macro is used to store the joint rotation settings away into a safe place. The second pose file is then included and the ppInterpolatePose macro is called to interpolate between the saved set of joint positions and the current set of joint positions, overwriting the current joint positions as it goes. The parameter to the ppInterpolatePose macro tells it how far between the first and second pose file to interpolate.
For example, if the ppClock variable happens to contain the value 0.32, then we use pose frames ppwalking2.inc and ppwalking3.inc (remember to start counting from 0 not 1). The interpolation parameter tells the ppInterpolatePose macro to use joint rotations that are (0.32-0.3)/(0.4-0.3) = 0.2 or 20% of the way between those specified in ppwalking2.inc and those specified in ppwalking3.inc.
If you look at ppwalking2.inc (ignoring the little bit at the top for now) you will see a standard pose file with a series of joint rotations being specified using the ppRotateJoint macro. For example:
If you look at ppwalking3.inc you'll see
The pose defined in ppwalking2.inc brings the right foot in contact with the floor in preparation for the left foot to be lifted. Therefore we need to find the position of the right foot from ppwalking2.inc and use it to fix the position of the right foot in ppwalking3.inc. This information is therefore written out to the message stream using the #debug instruction. The following information should be similar to that output by ppwalking2.inc
With this it is possible to generate animations by defining a complete sequence of key positions and a file to control interpolation. However, even for the more artistic amongst you it can be difficult to visualize the combination of joint rotations and transitions required to generate smooth animations. POV-Person therefore includes a number of small utilities to help design and tailor your animations.
If you look at ppwalking04.inc you will see that it mirrors the first key pose in the sequence with the statement:
The ability to 'overlay' different poses is very useful for lining up sequences of positions so that smooth transitions can be designed. The colouration of poses helps to avoid confusion about which body parts belong to the current pose. The transparency setting enables you to see the pose that you are working on, but considerably slows down the render. It is therefore recommended to set ppAnimationGhosts to '0' unless you find that another pose obscures detail that you need to see.
There are various sites that discuss the more artistic aspects of animation including:
http://www.jdhancock.com/walking.asp
http://www.rubberbug.com/walking.htm
http://www.siggraph.org/education/materials/HyperGraph/animation/character_animation/walking/walking_excercise.htm