PovRay

From PyMOLWiki
Revision as of 15:55, 6 November 2007 by Inchoate (talk | contribs)
Jump to navigation Jump to search

Nice PovRay settings

I typically use the make_pov.py script and "run" it from pymol once to load the function, and then I do make_pov('povray.inp') to create the povray.inp file. Then I edit that file to insert some lines like:

fog {
  distance 10
  fog_type 2
  fog_alt 10.
  fog_offset -160.
  up <0.,1.,.4>
colour rgbt<1.0, 1.0, 1.0, 0.1>
turbulence 0.8
}

In this case I'm not really doing depth-cueing but adding fog at the lower background edge (there were two planes defining the background and a surface below the molecule) rising up towards the front upper edge of the scene.

"fog_type 2" means a "rising fog" along the "up" vector. fog_type 1 is a constant fog. To get pure depth cueing, you would want "up" to be along the <0., 0., 1.> vector (I think!). You'll need to play around with the distance and fog_offset parameters. You wouldn't necessarily want the "turbulence" parameter in there either. Check out "Atmospheric Effects" in the povray documentation for many more details: http://www.povray.org/documentation/view/201/

make_pov.py v1

# make_pov.py
# Do "run make_pov.py" from within pymol and then execute the script
# with "make_pov('povray.inp')" to create the povray.inp file.
#
# written by Robert Campbell 2003
#
from pymol import cmd

def make_pov(file):
	(header,data) = cmd.get_povray()
	povfile=open(file,'w')
	povfile.write(header)
	povfile.write(data)
	povfile.close()

make_pov.py v2

This version was recently posted with a few more options to the user along with a little more flexibility in rendering the POV scene.

The temporary povray file is written to the working directory. This will write your scene in two parts, a .pov file containing all meta data, such as the lights, camera and #defaults, and an include file (.inc) which contains the structure. In this way you have maximum control over your scene without having to edit a huge povray file. You may even want to consider splitting your scene up in separate parts (taken from the same perspective), which you combine in a global .pov file using #include statements. This will give even more control with regards to modifications to the scene.

Once you run run make_pov.py, run make_pov to execute the script.

NB. the .pov file contains a commented statement with regards to a povray script, which allows transforming scenes and objects from model space to camera space and vice versa. If you want, you can get a copy of that script.

# make_pov.py                                                                                       
# Do "run make_pov.py" from within pymol and then execute the script                                
# with "make_pov('povray.inp')" to create the povray.inp file.                                      
#                                                                                                   

from pymol import cmd

def make_pov(file, meta=True):
        f1, f2 = file, file[:-4] + '.inc'

        (header,data) = cmd.get_povray()
        povfile = open(f1,'w')
        if meta: povfile.write(header)
        povview = cmd.get_view()

        povfile.write("""\n
// Uncomment the following lines if you have the pymolmacro.inc include file and want to use it.
/*
#include \"pymolmacro.inc\"
PYMOL_VIEW( %10.5f, %10.5f, %10.5f,
            %10.5f, %10.5f, %10.5f,
            %10.5f, %10.5f, %10.5f,
            %10.5f, %10.5f, %10.5f,
            %10.5f, %10.5f, %10.5f,
            %10.5f, %10.5f, %10.5f )
*/

""" % povview)
        povfile.write('#include "%s"\n\n' % f2)
        povfile.close()
        povfile = open(f2,'w')
        povfile.write(data)
        povfile.close()

cmd.extend('make_pov',make_pov)