Stereo Image Camera Creation Script

This python script creates a pair of cameras for rendering stereo images in Vue. It’s pretty easy to do without the script but this just speeds things up a bit. Christina has two tutorials about making stereo camera’s on her web site. Its a basic solution that doesn’t generate an animated camera and it won’t work with cameras that aren’t flat and level. Originally created after a request from Jim Coe.

Note: This script does not render the scene. Once you have used it you will need to render the scene from each camera yourself and do whatever magic you need to do with the output.

[codesyntax lang=”python”]

#******************************************************
# Creates a pair of cameras in a vue scene for
# rendering stereo position images
#
# - vuestereocamera.py
# - By Mark Caldwell
# - Version 0.1
# - 3rd September 2007
# - Copyright Mark Caldwell 2007
# - Tested with Vue 6.5 Infinite
#
# How to use in 3 easy steps
#
# 1. Download this file onto your computer
#
# 2. Position a camera where you want to render a
#    stereo image for and make sure it's your selected
#    camera
#
# 3. Then run script and wait for it to work
#    To run it go to Python -> Run Python Script
#    Then locate the file on your computer
#
#******************************************************

#------------------------------------------------------
# Get Input and Test Value is a positive floating point
#------------------------------------------------------

def TestValAngle (messagetxt,titletxt,default):
    hit=-2
    val=-1

    while hit<0:
        try:
            if float(val)>0:
                hit=1;
            elif hit==-2:
                val=Prompt (messagetxt,default,true,titletxt)
                hit=-1
            else:
                val=Prompt ("Error: Value must an positive number\n\n"+messagetxt,val,true,titletxt)
        except:
            hit=-1
            val=Prompt ("Error: Value must an positive number\n\n"+messagetxt,val,true,titletxt)

    return float(val)

#------------------------------------------------------
# Convert Degrees to Radians
#------------------------------------------------------

def degtorad(deg):
    rad=deg*(math.pi/180)
    return rad

#--------------------------------------------
# Start of Main Code
#--------------------------------------------

import math

separation=TestValAngle ('Eye Separation','Eye Separation','6.5')

camX=StoreCamera  ()

SwitchCamera (camX)

SelectByType(VuePython.VUEBasicObject.VOT_Camera)
cam = GetSelectedObjectByIndex(0)

pos=cam.Position()
rot=cam.GetRotationAngles()

y=(math.sin(degtorad(rot[2]))*separation)+pos[1]
x=(math.cos(degtorad(rot[2]))*separation)+pos[0]

cam.SetPosition(x,y,pos[2])

#----------------------------------------------
# End of Script
#----------------------------------------------

[/codesyntax]

impworks © Copyright Mark Caldwell 1996 - 2024