Animation in Povray


Animation in computer graphics is accomplished by creating a sequence of images where each image in the sequence is slightly shifted from the previous image. By playing back the image squence quickly, you have th illusion of continuous motion.

Keyframing

In the early days of animation all of the images were drawn by hand. This process was labor intensive. To make this process more efficient, a technique call keyframing was developed. Master animators would draw the most important "key" frames. Then the less experienced animators would do the "in-between" frames. Today, it is the computer that does the in-between frames automatically by interpolating between the key frames.

Povray is not designed to do complex animation. Animation companies today often use a combination of complex propriatory (i.e. written in house by a large team of programmers) and off-the-shelf software such as Alias/Wavefront's Maya or Discreet's 3D Studio Max. Here, we will just look at the simpler animation that you can do in Povray.

Povray: Setting up the Clock and Frame Count

The sequence of images can be generated in Povray using the clock. The clock is a variable whose value changes over a sequence of images.

To set up an animation, you need to create a .ini file that specifies the number of frames (images) and characteristics of the clock behavior. By default, the clock will start at 0 for the first frame and increase in equal increments until it is 1 for the last frame. The size of the increments is therefore determined by the number of frames. For example, the .ini file that contains:

Width=320
Height=240 
Final_Frame=4

will create 4 frames of size 320x240. The clock values associated with each of the frames will be 0 for the first frame, 1/3 for the second frame, 2/3 for the third frame, and 1 for the last frame.

Once you have created and saved your .ini file, you need to tell Povray that you want to use this .ini file. To do this, go to the Render; Edit Settings/Render menu. In the pop-up box, use the browse button in the .INI section to set the .ini name to your file.

Using the Clock in Your Povray File

So how does this clock value get used in the Povray file? Suppose we want to rotate an object e.g. a cone, around the y axis. Then we can use the following

cone { <0,0,0>, 1, <2,0,0>,  0
      pigment { Red } 
      rotate y*360*clock  
}

Each frame will have a different clock value so that the cone will be rotated by a different amount in each frame. In this example, the rotations will be at angles 0, 120, 240, and 360.

Note that in this case the first angle (0 degrees) and last angle (360 degrees) are really the same so that the first and last frame will be identical. To avoid this overlap, you can place the extra line in the .ini file:

Width=320
Height=240 
Cyclic_Animation=on
Final_Frame=4

Now, the clock will have values 0, 1/4, 1/2, 3/4 and the resulting angles will be 0, 90, 180, and 270. There are still 4 frames but they are separated by different increments.

Output Files

If your Povray file is named myCone.pov, then Povray will save the individual frames to files called myCone1.png, myCone2.png, myCone3.png, and myCone4.png. Since you are generating a lot of files, please make sure you save to png files and not .bmp files so save space.

To put all of these files into a single animated gif file, you will use ImageReady, which comes with Adobe Photoshop. This will be easy if all of your .png files are stored by themselves in a folder. Suppose, your povray files are in the folder c:\povrayStuff\. Then I suggest you save your images to a subfolder called c:\povrayStuff\images\. To do this, go into the Render; Edit Settings/Render menu. On the command line options, type (change the output file folder name to whatever you are using):

+FN  Output_File_Name=c:\povrayStuff\images\

Creating the Animation

We will go over in class how you can create the animation using ImageReady.

Examples

Walk Cycle: Click here.

Rotating Text

Click for Animation. Code: animText.pov and animate36.ini

Bouncing Ball - Physically Based Animdation

Click for Animation. Using the laws physics we can calculate the position of the ball when dropped under force of gravity. Code: ball.pov

Click for Animation. Squash and Stretch added.

Note, this isn't really done right. See the following links for better info:

Multiple Objects - Rotating Torus and Ball

Click for Animation.

Paths

Click here for examples.

Using Macros to Animate

Click here for examples.


[top]

[Home]