next up previous contents index
Next: Coloring Trick - Override Up: Tips and Tricks Previous: Example sites

Making a Movie

    It is possible to make movies with VMD, though the interface is not well developed. This section is not written for the casual user!

The following Tcl script uses the mpeg encoder available from ftp.cs.berkeley.edu, the image converter toppm, and successive Raster3D runs (though it is possible to do screen grabs as well) to make a movie of a spinning molecule. The script rotates the system 35 times by 10 degrees each time. For each orientation, it saves the image as a Raster3D input file, runs Raster3D on it to get an RGB raster image, then converts the RGB file to a ppm graphics file for use by the mpeg encoder. Once all the files are made, the mpeg is created. The temporary files are saved in ./images and the full process could take up a lot of disk space, depending on the size of the VMD graphics window. This script does not automatically delete the files or the directory.

The encoder input file is given after the Tcl script.

VMD script to make a movie of a rotating system  

for { set i 0 } { $i < 360 } { set i [ expr $i + 1 ] } {
  render Raster3D out.r3d
  catch { exec render < out.r3d -sgi out.rgb }
# get the right format for the number (only works up to 99)
  if { $i < 1 } { 
    set nm "00"
  } elseif { $i < 10 } {
    set nm "0$i"
  } else {
    set nm $i
  }
# convert from RGB to PPM
  catch { exec toppm out.rgb $nm.ppm }
# delete the RGB file
  catch { exec rm out.r3d out.rgb }
# and rotate by 10 degrees
  rot y by 10
}
# now make the mpeg
catch { exec mpeg_encode-1.3.sgi.bin mpeg.input }

The mpeg encoder script follows, but be careful as we guessed at most of the values.

PATTERN I
OUTPUT spin.mpg
INPUT_DIR .
INPUT
*.ppm [00-89]
END_INPUT
BASE_FILE_FORMAT PPM
INPUT_CONVERT cat *
GOP_SIZE 4
SLICES_PER_FRAME 2
PIXEL FULL
RANGE 5
PSEARCH_ALG LOGARITHMIC
BSEARCH_ALG SIMPLE
IQSCALE 1
PQSCALE 1
BQSCALE 1
REFERENCE_FRAME DECODED

You would use this by first loading a molecule, changing to the directory you wish to use to store the image files, and entering the command

	play <Tcl script filename>
  It does work. Honest.



Justin Gullingsrud
Tue Apr 6 09:22:39 CDT 1999