Making animations from VTK
We start with a simple program which generates the frames. I wrote a
program which uses some vtkSphereSources to show pretty
illumination patterns on a shiny sphere. One of the frames is shown
above.
Here is the program ballanim.tcl in HTML or as the straight TCL. There are lots of comments explaining
what's going on. Hopefully, it will be clear how to adapt this
program to vary the parameters that matter for your application.
Running this program generates a number of image files in PPM format.
These will be used as the basis of the animations.
On the PC, its very very easy to make two kinds of animations, and
below I show how to make MPEGs and animated GIFS. Obviously, if
you've generated frames on the UNIX side of the world, you have to
transfer them over to a PC. Put all the frames into one directory.
Making an MPEG animation
- I used the VideoMach
program from Gromada, available
for download here.
Installing the program was painless.
- Go to the File menu, select Open
- Browse to the directory with your frames. Select the first frame,
and then Shift-Click the last frame, then click Open. This gets all
the frames into VideoMach.
- You can use the up and down arrows to preview the movie, or
use the Moyager
program (also from Gromada), but
I never got this to work.
- Go to the File menu, select Define Output
- This Dialog box has tabs the File and for Video and Audio
parameters. For the File information, click on the ... button
next to the filename text entry widget. If you give it a filename
ending with .mpg, then it will assume you want to make an
MPEG.
- Click on the Video tab and click the "Format Options" button.
I tried the 2xCDROM and 4xCDROM preset options.
- Click OK
- Go to the File menu, select Start Processing. This will
generate and save the animation, and then try to open the resulting
file with MediaPlayer or whatever else you use to look at .mpg files.
The 2xCDROM setting produced ball1.mpg (1.8 megs), and the 4xCDROM
setting produced ball2.mpg (2.0 megs).
Making an animated GIF
MPEGS are a good format for scientific animations, because their color
palette is not limited to 8-bits, as GIFs are. Animated GIFs are fun
to put on web pages, or for very simple animations which only require
a few frames.
- I used Animation Shop 2
available from JascSoftware. It
comes as part of the full Paint Shop Pro 6
installation, or you can download it here.
Installing the program was painless.
- Go to the File Menu, select Animation Wizard. This will step you
through the various parameter settings.
- You may want to select a different frame size. The program is
intelligent about downsampling the frames to smaller size, so the
quality looks pretty good.
- There is one step with a checkbox for "Scale Frames to Fit". You
NEED to select this if you've changed the frame size in the first
step, and still want the whole image in each frame.
- You can select a time interval between frames, but most of the
time I've found that the web browser displaying the animated GIF
can't keep up with anything very fast.
- At the step where you "Add Image", browse to the directory with
your frames. Select the first frame, and then Shift-Click the last
frame, then click Open.
- Go to the File Menu, select Save As; choose Animated GIF.
Here is the result I produced, shrinking the frame size down to 64 by 64,
and choosing a 1/100 second delay between frames:
Other URLS: