CS 428 - Fall 2011
Project 3: Modeling and Animation

Due electronically: Wednesday, November 16th, 12 noon
(The image and MPEG movie are due the following Monday, November 21)


Check this page frequently for updates and clarifications
(Significant changes or clarifications are marked with [Update])


Description

The automatic generation of objects and their motions is required in applications such as games or simulations. This generation starts with a model of a particular phenomena (in this case: rocks, trees, or wandering motion). Ideally, this model takes into account knowledge such as the object's formation, growth, or biomechanics, to produce a greater degree of realism. More typically, such information simply inspires an approach to procedural generation.

Objective

From this assignment, you will understand how structures such as trees and rocks can be generated using procedural methods. You will also implement a behavior-based approach for animating some crawling bugs (where only the leg motions are keyframed).

Program

You will be provided with skeleton code for this program, which supplies the necessary user interface and main program structure. The basic data structures for the rock, tree and bug are provided for you, which you must complete in particular places. You will also need to create the "scene" which contains any number of rocks, trees or bugs. You will mostly be filling in the missing parts in functions (which are marked with "// ..."). In some cases, you will find code that is a placeholder for what you need to write (so that you at least see something where the tree and rock are) -- just remove it once you start on that part. In addition, you will probably have to add code elsewhere, and not just where the comment markers are. So don't feel confined by where these comments are placed; they're a guide.

The skeleton code for this project can be found (on the iLab machines) in the directory
      ~decarlo/428/proj3/
Also included is a Makefile.

This assignment is a bit vague so that you can make a lot of the design decisions yourself. There are several approaches to the problems here. Use your best judgement to try and get the most useful result. Ask for help or clarification when you need it.

Handing in

Hand in the following:

  1. all of your java files (no class files please)
  2. your makefile
  3. a description file descrip.txt
  4. a still frame in PPM format and an MPEG movie (see the section below)
    Hand in the image and movie separately from the rest of your program. There is a separate hand-in for it.
    Pick any still frame from your animation (save one of the PPM files from /tmp; the first one in there is just fine)
The description file should be a very brief description of what you changed and added. Put your name at the top of this file. It should briefly describe all modifications to the skeleton code you performed, as well as describe the additional code you wrote for the assignment. If you implemented any additional/optional features or anything else special, you must state what you did in this file (to get credit).

You will need to create a tar archive to hand in, that contains your java files, Makefile, and description:

   tar cf proj3.tar Makefile *.java descrip.txt
Here are the instructions on how to hand in this file.

This assignment is a bit vague so that you can make a lot of the design decisions yourself. There are several approaches to the problems here. Use your best judgement to try and get the most useful result. Ask for help or clarification when you need it.

Program use

To simply run the program with default options:     java Main

There are a number of command line options available (italicized words indicate you need to specify a particular value):

For example, to run the program in "nice" mode with the seed value of 37:
    java Main -nice -seed 37

Once the program is running, you can transform the scene, turn on/off animation, or reset the scene.

Making MPEG Movies

It's easy to make MPEG movies of your animations. You should not only do this when your program is completed, but also during its development to record any interesting or amusing "out-takes".

An example movie/image pair are in ~decarlo/428/proj3.mpg and ~decarlo/428/proj3.ppm

The "-dump" command-line switch described above is used to save a numbered series of images. You can use "ppmtompeg" to build an MPEG animation file from these images (type "man ppmtompeg" to see brief documentation). Instead of reading about the details of the encoder, you can use the pre-made encoding file, which tells the encoder where the files are, and how they are to be constructed. All you will need to do is edit the top of the file.

The sample encoding file is on cereal in:    ~decarlo/428/encode.txt

Copy this file into your directory. The first few lines of this file specify the input and output files as:

  OUTPUT          anim.mpg

  INPUT_DIR       /tmp/decarlo

  INPUT
  image*.ppm [0000-0299]
  END_INPUT
The filename given on the OUTPUT line states the file that is created when you run "ppmtompeg". Set INPUT_DIR to "/tmp/your-userid", or whichever dump directory you specified when running your project. Finally, determine the number of images that were dumped by your project (by typing "ls -lt" in the dump directory), and set this in the square brackets. If you don't want to include all the images, that's ok. Be sure to use 4 digit numbers (with leading zeros) so that the filenames are reconstructed properly.

Remember that "/tmp" is on the local machine, so that when you log in somewhere else, the images you left won't be there. Plus, if a machine reboots, your images in "/tmp" on that machine will probably be lost. It's also not a bad idea to clear everything out of that directory each time you make a movie, so you don't confuse which files you just created.

In the above example, the encoder will use the files "/tmp/decarlo/image0000.ppm" through "/tmp/decarlo/image0299.ppm" to produce an mpeg file called "anim.mpg". It uses 300 files: at 30 frames per second, this animation will last for 10 seconds.

If you want to include only a sub-range of the images (say you only wanted to use [0060-0209]), use the image viewing program "eog" to figure out which ones. If you load many images at once using "eog *.ppm", then you can advance to the next/previous one using the left/right mouse buttons (the scroll wheel works too). A useful trick to see every 10th image is to run "eog *0.ppm".

Once you're done, you can play your MPEG animations using "xine anim.mpg".

In summary:

  1. If dumping for the first time on a particular machine:
       mkdir /tmp/your-userid
  2. java Main -dump    (let the animation run for the duration you want.)
  3. ls -lt /tmp/your-userid    (to determine the largest indexed file)
  4. Update the encode.txt file
  5. ppmtompeg encode.txt    (this might take a while)
  6. xine anim.mpg
  7. mv anim.mpg new-name.mpg    (if you want to keep it)
For best results: Do a nice job with this, as these movies will be put on the course web page!

Data structures

The rocks are represented using the Rock class. It contains information about the location and size of the rock, and it stores a two-dimensional array of height values.

The trees are represented using the Tree class, which contains information about the location of the tree, as well as a recursive data structure from the class TreePart which stores the branches and leaves of the tree as a hierarchical model.

Instances of Rock and Tree also implement the Obstacle interface, so they can be treated uniformly as scene objects when drawn, and when doing bug computations (obstacles should be avoided by bugs).

The bugs are represented using the Bug class, which is an extension of the Critter class. (This way, if you want to add another type of critter, it won't be too hard.) The keyframes for the bug are stored in the Bug class, although the Critter.keyframe() method is used to compute the current bug parameters given the time. The state (position, velocity, acceleration) is stored in Critter, which is also where you should compute accelerations, and do the numerical integration for the bug simulation.

The scene is represented using the Scene class, and stores the obstacles and critters in the scene, and has methods which you will need to complete which create and simulate the scene.

Requirements

The following is a description of what you must do for this project.

Extensions

The following is a list of optional extensions. The first two are required for graduate students.

Hints

The following are some suggestions...


428 Home