Animated GIFAnimated GIFAnimated GIFAnimated GIFAnimated GIF

Creating Simple animations of Swiss

PDB Viewer files in POV-Ray


Introduction

This document is not intended to be a comprehensive guide as to the animation functions within Swiss PDB Viewer.  If that is what you are looking for I would suggest using the ClockMod turorial.  The purpose of this page is to provide a simple step-by-step guide for setting up a simple rotation amimation (such as the one shown at the top of the page), using Swiss PDB Viewer and POV-Ray.  You will probably find that for most purposes, this is the only type of animation youi are likely to want to produce anyway - if you are interested in more complex animations then this will at least provide a starting point.


The ClockMod include file

Although there are animation functions built into the standard POV-Ray distribution, they can be quite complex to set up, and can get quite mathematical if you are trying to produce all but the simplest of motions.  For this reason it is probably easier to create your animations using an extension module (called an include file) which does all of the hard work for you.  This include file is called ClockMod and was written by Chris Colefax (who has written many useful extensions to the program).  You will need to download and install this extra file before you start producing animations.

ClockMod can be downloaded from http://www.geocities.com/SiliconValley/Lakes/1434/clockmod.html .  It comes as a .zip file.  You need to extract the contents of this file to the Include directory of your POV-Ray installation.  If you are using a standard Windows installation this will be C:\Program Files\POV-Ray for Windows\Include\.  For other systems, look for the POV-Ray directory, and there will be an Include subdirectory within it.


Creating POV-Ray files from within Swiss PDB Viewer

 

Creating a file in Swiss PDB Viewer for use in animation is exactly the same as creating a normal POV-Ray file.  You can set up the view in any way you wish, then save the scene as a POV-Ray file by using

File -> Save -> POV3 Scene

There are a couple of extra considerations worth making when producing scenes for animation;

 
  • Try to use only one light to illuminate your scene.  This will mean that you have to make less alterations to the POV-Ray code, and you will also find that POV-Ray will work more quickly if it only has to calculate information from one light source.  You can check your current setup by looking in Preferences -> 3D Lights.
  • Make sure that there is sufficient room around your molecule to allow it to rotate without falling off the side of the screen.  It is very frustrating to spend 30 min+ waiting for an animation to finish, only to find that part of it is not visible.  When in doubt always zoom out a little bit more!

  • Setting up the animation in POV-Ray

    To allow POV-Ray to product an animation you will need to make changes to two files.  The first is the master configuration file for POV-Ray, called POVRAY.ini.  The second is the .pov file which is created by Swiss PDB Viewer.


     

    POVRAY.ini

    You will need to add a few extra lines to the end of the POVRAY.ini file in order to initiate an animation.  You can edit this file by starting POV-Ray, and then selecting;

    Tools -> Edit Master POVRAY.ini

    You then need to add these extra lines to the end of the file;

    Initial_Frame = 1
    Final_Frame   = 15
    Cyclic_Animation = on

    You do not need to change anthing else in that file!!

    The only value you may wish to change is the Final_Frame value.  This is the total number of frames which are going to be produced.  For a simple, small rotation (such as the one at the top of the page) 15 frames is sufficient.  For a smoother, more detailed rotation (such as the one in the .avi file at the end), then you might want to increase this number to 30 or so.

    You should note that, having altered this file, POV-Ray will try to produce a 15 frame animation from all of the subsequent files you load into it.  Thus, when you have finshed making your animation, you need to go back to this file and place a ";" in front of each of these 3 lines to stop it from animating.


     
     
     

    .POV Files

    Whilst it is possible to rotate individual objects within a POV-Ray file this can be quite complicated with scenes as complex as those generated by SPDBV.  Therefore I would suggest that it is probably easier to leave the objects where they are and then simply rotate the camera and lights around them.

    You will need to add a few extra lines of code after the POV-Ray entry for every object you wish to move during the animation.  In most cases this code will be the same for all objects, but there is nothing to stop your lights and camera rotating at different rates, or even in different directions.

    The first thing you will need to change is in the header at the very top of your POV-Ray file.  This one had me confused for a while!  The ClockMod file will not work with older versions of POV-Ray, and it identifies Swiss PDB Viewer files as being too old, despite the fact that they use the latest version of the POV-Ray scene language. To correct this you need to change the line which says;

    #version 3  // this scene uses POV-Ray 3.x syntax

    so that it reads

    #version 3.1  // this scene uses POV-Ray 3.x syntax

     
     
     

    Next, you can move down to the Camera section of the file, the one that starts with;

    //************ CAMERA *********

    You need to add the following line immediately below this line;

    #include"AutoClck.mcr"

    This tells the program that you are working with the ClockMod add-in.

    You should then have a camera statement which looks something like this;


    camera{location<0, 0, -141.9 >  // get closer to <0,0,0> to zoom in on the model

    // rotate < 0, 2.000, 0>    //  uncomment to get  left Eye stereo view

    // rotate < 0, -2.000, 0>   //  uncomment to get right Eye stereo view

    direction<0, 0, 2.836>

    up<0, 1, 0>

    right<640/480, 0, 0>  // **NOTE:** do not forget to adjust this etc. etc.

    look_at<0, 0, 0>}


    You should alter this statement so that it reads as follows;


    camera{location<0, 0, -141.9 >  // get closer to <0,0,0> to zoom in on the model

    // rotate < 0, 2.000, 0>    //  uncomment to get  left Eye stereo view

    // rotate < 0, -2.000, 0>   //  uncomment to get right Eye stereo view

    direction<0, 0, 2.836>

    up<0, 1, 0>

    right<640/480, 0, 0>  // **NOTE:** do not forget to adjust this etc. etc.

    look_at<0, 0, 0>

    rotate

                  From (0, <0, 0, 0>)

                  Using ( "", 1, 1, "")

                  To (1, <0, 360, 0> )

    }


    You have inserted the rotate, From, Using, and To statements just before the final bracket of the camera statement.

    The Using statement simply tells the program to move at a constant rate.

    The From and To statements define the extent of the rotation in the <> brackets.  The 3 values are rotations on the x, y and z axes.  In this case we are performing a 360 degree rotation about the y-axis.

    Finally, you need to perform a similar modification to all of your lights, so that they too will rotate around the molecule.  Thus the following light statement;


    #declare Intensity = 2

    background{color rgb <1.000, 1.000, 1.000>}

    object{light_source{<0.000, 0.000, -200.000>color rgb Intensity*0.800}}


    Would become;


    #declare Intensity = 2

    background{color rgb <1.000, 1.000, 1.000>}

    object{light_source{<0.000, 0.000, -200.000>color rgb Intensity*0.800}

    rotate

                  From (0, <0, 0, 0>)

                  Using ( "", 1, 1, "")

                  To (1, <0, 360, 0> )

    }


    . . . and that's about it.  Press the render button, and the program will chug into life (probably for quite a while!) and will produce however many frames of animation you specified in your POVRAY.ini file.


    Turning individual frames into movie files

    The process described above will not produce an actual animation* but will output a series of individual frames, which, when viewed sequentially will generate an animation.  The last step you need to undertake is to convert these individual frames into a common movie format, such as .avi .mpeg or animated .gif.

    (*In the Mac version of POV-Ray you can apparently output directly as QuickTime format movies but I have never tried this myself)

    There are commercial animation packages such as Adobe Premiere which will perform this kind of operation.  Whilst this is a very competent package, it is aimed more at people using their computers for video editing and is really overkill for this kind of operation.  Its extended functionality is also reflected in its price!

    Before selecting a package you should consider what animation format you would like to use.


    Animated .gif

    This format is the accepted standard for inserting small animations into web pages.  The image at the top of this page is an animated .gif.

    Advantages

  • Very compact files
  • Viewable within web browser
  • Cross platform
  • Accepted standard
  • Disadvantages

  • Limited to 256 colours
  • Only smooth for small images
  • Not supported by most graphics packages
  • Cannot easily be incorporated into presentations

  • AVIs and MPEGs

    AVIs and MPEGs are one the two most common movie formats available.  They are designed to create high quality animations of any size.  They are not usually designed to incorporated directly into web pages, but are more suited to local display, and use in presentations.

    Advantages

  • High quality possible (can use varying amounts of compression)
  • Support high colour depth
  • Cross platform
  • Can add sound track!
  • Disadvantages

  • Files can become very large
  • Playback may not be smooth on older computers
  • Cannot integrate directly into web pages
  • Some compatability problems with different viewers (esp AVIs)

  • Software

    To create these animation files from individual frames requires a specific piece of software.  I claim to be no kind of authority on the whole range of packages available as my experience has mainly been with PCs running Windows.  However, similar packages will exist for all platforms.

    A good place to look for utilities to create animations is the POV-Ray animations utilities page.  This lists a whole heap of programs for various platforms.  This page can be found at; http://www.povray.org/links/3D_Animation_Utilities/ .

    The packages I have personally used and have found to be very good and easy to use are;

     

    GIF Construction Set Professional

    If you are running Windows then this is the package you have to use to create animated .gifs.  It is extremely simple to use, with a Wizard system which walks you through creating your file.  It also has a good compression utitility which can significantly reduce the size of the final file.

     

     Platypus animator

    Again, Windows only (sorry, but it's what I use!), Platypus animator is another extremely easy to use program which will create .avi files from individual frames. It will allow you to add a sound track to your animation, and supports variable compression levels.  You can also use this program to extract individual frames from an existing .avi animation.  Although this program is shareware, it will draw a small platypus in the corner of all animations it creates until it is registered (but hey it only costs £13!).

    You can see an example of an animation created using Swiss PDB Viewer, POV-Ray and Platypus animator by clicking  here (950kb).




    These pages written by Simon Andrews 15/05/00.  Please report any problems to molbio.support@bbsrc.ac.uk