Jump to content

Talk:Mod:Hunt Research Group/VmdScriptsMovieMol

From ChemWiki

using a plug-in from the VMD library

using the view_change_render plugin from the VMD script library

  • The shortest steps to making a movie is as follows:
Load a molecule into VMD.
Open ViewChangeRender.
Save two viewpoints and add them to the movie list.
Change the movie duration with the Set Total Time button.
Open the Extension->Visualization->Movie Maker plugin
In the Movie Settings menu (in the Movie Maker window), select User-Defined Procedure.
Click the Enable button in the ViewChangeRender window.
Click Make Movie in the Movie Maker window.
  • The default snap-shot render is rather poor
so use the default display to define your movie then upgrade the image quality
increase the display
display resize 1200 1200
this will increase the processing time on the movie considerably (put the vmd display on another window otherwise it will lock your screen)
for a movie for presentation you may want to use one of the other renderer's
in this case you can use a smaller display say 1000 by 1000
this will take some time!
another option is to play with the Tachyon rendering commands, replace some of the code in the script
render Tachyon $filename
with
render Tachyon $filename "/Applications/VMD_1.9.2.app/Contents/vmd/tachyon_MACOSXX86" -aasamples 12 %s -format TARGA -res 1500 1500 -o %s.tga
note that there must be no spaces in the directory path name!
you change the rendering with the res command I've set it to 1500 here
  • The default build from imagemagick will however make a movie that loops 4 times
you may also wish to alter the duration of the movie
if you disable the "delete images" in the movie maker window all the image files will be saved and you can combine them the way you like
see below for some more detail (and the imagemagick web-page) but you may like to use the following
convert -delay 3 -loop 1 movie_name.*.ppm movie_name.gif
if you are using large images you may want to resize the final .gif convert -delay 15 -loop 1 -units PixelsPerInch snap.*.tga -density 300 rot_movie.gif

basic using your own script

  • the process is to
  • generate a series of image files in VMD
  • convert the graphics format
  • stitch the files together in a gif animation
  • make a new directory say rotation_movie
  • load your molecule
  • copy a script into the directory which will generate the images (rotation, scaling etc)
  • in VMD scripts are first loaded and then the procedure is executed
  • for example for the script presented below
  • "source rotate_script.tcl" in the VMD console
  • "rotation_movie" in the VMD console
  • for example the following script to rotate a molecule
  • this will create 20 frames each a rotation by 18 degrees around the x axis
  • save this script as rotate_script.tcl
proc rotation_movie {} {
set frame 1
for {set i 0} {$i < 360} {incr i 18} {
set filename snap.[format "%02d" $frame].tga
render TachyonInternal $filename
incr frame
rotate x by 18
}}
  • some notes on the formatting for the file names
  • format (format_description) arguments
  • use % symbol to start format string
  • %-10s =left justify string of (minimum) 10 characters
  • %04d =don't justify, an integer of 4 characters
  • %+10.2f =right justify floating point number with 10 before decimal and 2 places after
  • use \n to produce a carrage return
  • this script will create 20 files named snap.xx.tga
  • the next step is to convert the images and combine them in a gif animation, use ImageMagick
    • the key command is "convert file.in file.out"
    • options include
  • "-delay x" delays the next image by x ticks per second, a number between 2-10 is good
  • "-loop x" loop x times (x=0 repeats and infinite number of times)
  • multiple files can be input via
  • wild cards e.g. image*.tga
  • or by listing the filenames in a file and reading the file in specified by at the at symbol "@file"
  • there are more options available on the ImageMagick website
  • thus the required command here is
  • convert -delay 5 -loop 5 snap.*.tga rot_movie.gif
  • here is my basic animation
  • as you can see you need to watch out that your rotation does not take your molecule "off-screen"

more VMD scripting options

  • you can do sequential rotations
  • "rotate y by 20": rotate 20º around y-axis
  • the following is supposed to work but it does't
  • "rotate y to 180 5": rotate in 5 steps until angle is 180º
  • rock is a continuous process
  • "rock y by 20"
  • "rock stop" to stop the rotation
  • wait
  • "wait 10": wait ten seconds before running the next command, animation continues
  • "sleep 10": wait ten seconds before running the next command, animation sleeps