Assignment 3 - Animation

Due Date: December 5, 2003
 

General description

In the third and final assignment, you are going to add a simple animation feature to your software. Here you will employ one of the common animation techniques called key framing to animate objects in a scene. So far, we are able to construct a scene by specifying a set of transformations for our object. In key-framing, we specify parameter values for transformations at some specific times and we let the computer interpolate the in-between values during the animation.

This assignment consists of three simple parts. In the first part you are going to provide the graphical user interface that enables the user to define key frames and associated transformation parameters for each key frame. Then you will run the animation according to the key frame parameters and export each frame as a sequence of images (which may later be compiled using an external software to get a movie file). Finally you should be able to save and load the animation information in a scene file (which is povray compatible), so there would be a few additions to the Simple Scene Description Language.


Testing and input

The input filename may be specified in the command line or through the user interface:

./mrender sample-2-1.pov
./mrender

Sample files (note that thehours-anim.pov includes thehour-anim-declare.pov):
thehours-anim.pov (output images)
thehours-anim-declare.pov

For this assignment you should also design an animation scene using your own software. The animation should be interesting enough to get the full mark (and obviously your program should be able to open your own scene file). Top 3 animations will receive bonus mark and will be put in the course webpage with their creator's name!!!


Graphical User Interface (GUI)

You are going to add some new functionalities to your previous user interface to support creating and modifying key frames. Again, similar to assignment 2, I am not giving you a specific design detail and you will design the user interface yourselves.

User can specify and change duration of the animation in milliseconds.

Each object will have its own set of key frames which will occur during the animation time. User should be able to select an object (as in assignment 2) and create start-end key frames specifying the following parameters:

Start time and end time specify when the transformation will happen during the animation. Each pair of start-end key frames is associated with a basic transformation (translation, rotation or scaling) and starting and ending parameters for that transformation.
The motion clock controls the behavior of animation and it can be either constant, accelerated or decelerated.  In constant motion the transformation will be applied linearly to the object during the animation (like a car that moves with a constant speed). In an accelerated motion, transformation speed would be increasing (like a falling ball) and in a decelerated motion, transformation speed would be decreasing (like a car that brakes) based on a strength value. Actually deceleration is same as acceleration just with a negative value.

Example:

Each pair of starting-ending key frames is associated with only one of the basic transformations, but for each object we can have multiple key frames which may overlap (this gives us the capability to create more complex motions). User will be able to select and object (camera, light, shape) and then create, modify or delete its key frames.

 


Animation

You program will use the key frame information of objects to transform the objects in the scene during the animation. The program should provide some controls to enable the user to step through animation time line, and to play/pause the animation. Also, you should have some sort of mechanism to control the frame rate. For example, if the user sets the frame rate to be 25 fps, your program should actually display 25fps on a sufficiently fast machine. It is OK though to display fewer than 25fps on a slow machine.

For exporting the animation, your program takes a screenshot from each frame and stores then in image files with a sequenced filename (scene000001, scene 000002, ....) . You can generate the images in any standard file format, but probably the simplest one is Portable Pixmap file format (ppm). You can use this sample function to export frames as a ppm files.


File IO and Additions to  Simple Scene Description Language

For easy compatibility with povray, we will include clockmod macros in our scene file. To run the scene with povray, you should download and unzip clockmod in the same directory as the scene file and then include them in your scene file using this single include statement:

#include "AutoClck.mcr"

Again, you only need this to make things work with povray and inside your program, you will ignore this (as a comment)

For each key frame in an object  the key frame information will be specified using From, Using, To statements:

Transformation
  From
(starttime , <x1, y1, z1>)
  Using
(Clock_Type, Strength, 1, "")
  To
(endtime, <x2, y2, z2>)

From and To statements specify the starting and ending time and transformation values.
Clock_Type can be one of the values  ""  (for linear speed)  "A" (for accelerating) or  "D" (for deceleration).

There is an important issue about the starttime and endtime values. In povray the animation duration is always considered as 1. So, when you save your key frame information, you should convert the key frame time considering the animation duration. For example if your animation is 20 seconds (20000 ms) and a transformation occurs between second 4 and 6 (4000 ms ad 6000 ms) starttime and endtime would be 0.2 and 0.3 respectively.

// --- examples:

object { clock_hand
  rotate
    From (0.2, <0, 0, 0>)
    Using ( "", 1, 1, "")
    To (0.3, <0, 0, -720>)
}

cylinder {
  <50, -5, 0>,
  <-50, -5, 0>, 0.1
  pigment {color rgb <1, 1, 0>} // yellow

  translate
    From (0.5, <0, 0, 0>)
    Using ("A", 1, 1, "")
    To (1, <0, -10, 0>)
  scale
    From (0.5, <0, 0, 0>)
    Using ("D", 1, 1, "")
    To (1, <2, 2, 2>)
}

 

// ANIMATION duration in milliseconds

Because there is no way to save the animation duration in a povray file, we use this comment form at the start of a scene file to specify the animation duration in milliseconds. Example:  // ANIMATION 5000

Consequently, when you load a povray scene file, you should multiply starttime and endtimes to this number.

 

Exporting Animation To Image files

If you choose to use ppm file format as output image files, you can use ppmto... commands (ppmtogif, ppmtopcx, ...) to convert images to more commonly used file formats which can later be imported to an image animator program (gifanimators, movie makers, ...). Because there is a large number of generated ppm images, it is not possible to convert them manually one by one. So, you also should generate a simple script file to do this. this script file is simply a text file (with execute attirbute) that contains a sequence of ppmto... runs:

ppmtogif scene000001.ppm
ppmtogif scene000002.ppm
.
.
.
ppmtogif scene003000.ppm

 

Animation with povray

To animate your scene in povray, you should make a POVRAY.INI file in which you specify the number of frames that occur during the animation (animation duration (second) *  FPS (frame per second)) and then pass the file as a parameter to the povray:

POVRAY.INI:

Initial_Frame = 1
Final_Frame = 20

povray povray.ini +Iscene.pov  +W320 +H200


Design, Coding & Documentation

Again, the first thing to do (after reading the whole assignment) is to design the objects. This would be an easy or difficult task depending on how you have already done in previous assignments.

Again, do not delay this task, do not fudge it, do not proceed to code without most of this design finished. For each object you design, write down a brief description of its duties and members (data and functions). If unsure, discuss your design with me or the T.A.

The marks given for design on this assignment (and all assignments) are for embodied design---that is, design that has made its way into code. A supplementary document or comments explaining what you would do in code will not receive design marks.


Marking

10%  Program design and coding style
20%  File handling

10%

 Parser (opening scene files)

10%

 Saving file and exporting images
30%  GUI 10%  Defining Key frames
20%  Defining animation transformations
30%  Animation 10%  play back controls
10%  constant motion clock
10%  accelerated / decelerated motion clock
10%  Sample animated scene (s)
10%  Bonus mark for top 3 animated scenes
5%  Bonus mark for compiling the output images of your scene as an animation file (animated gif, avi, ...) using an external software

 

Last updated in Nov 10, 2003