Stereo ray: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (Reverted edit of 2chemp, changed back to last version by Inchoate) |
||
Line 67: | Line 67: | ||
[[Category:Script_Library|Stereo Ray]] | [[Category:Script_Library|Stereo Ray]] | ||
Revision as of 20:10, 14 November 2005
A user on the PyMol list wrote a very nice little stereo ray tracing script. Just copy this to a text file. Then, in PyMol run
run dirName/scriptName.pym
where dirName is where you put it, and scriptName is what you named the file then run one something like the example lines given:
EXAMPLE
stereo_ray output, 1000, 600
stereo_ray secondImage.png
This will create to images, one with an L and one with an R suffix. Just paste the two images next to each other (in some image editing program) and you're done.
from pymol import cmd
def stereo_ray(output='', width='', height=''):
'''
DESCRIPTION
"stereo_ray" ray-traces the current scene twice (separated by
a six-degree rotation around the y axis)
and saves a pair of images that can be combined in any image
manipulation software to form a stereoimage.
The first argument, the output file name, is mandatory.
The second and third arguments, the size of the image, are not.
If the width is given, the height will be calculated.
USAGE
stereo_ray filename [, width [, height]]
EXAMPLE
stereo_ray output, 1000, 600
stereo_ray secondImage.png
'''
if output == '':
print 'no output filename defined\n'
print 'try: \'stereo_ray filename\''
return -1
# abort if no output file name given
if width == '':
width,height = cmd.get_session()['main'][0:2]
# get dimensions from viewer if not given
elif height == '':
oldWidth,oldHeight = cmd.get_session()['main'][0:2]
height = int(width)*oldHeight/oldWidth
# calculate height from proportions of viewer if
# only width is given
cmd.ray(width, height, angle=-3)
cmd.png(output+"_r")
cmd.ray(width, height, angle=3)
cmd.png(output+"_l")
cmd.extend('stereo_ray',stereo_ray)