impworks Logo - a grinning imp in flight

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.

  1. #******************************************************
  2. # Creates a pair of cameras in a vue scene for
  3. # rendering stereo position images
  4. #
  5. # - vuestereocamera.py
  6. # - By Mark Caldwell
  7. # - Version 0.1
  8. # - 3rd September 2007
  9. # - Copyright Mark Caldwell 2007
  10. # - Tested with Vue 6.5 Infinite
  11. #
  12. # How to use in 3 easy steps
  13. #
  14. # 1. Download this file onto your computer
  15. #
  16. # 2. Position a camera where you want to render a
  17. # stereo image for and make sure it's your selected
  18. # camera
  19. #
  20. # 3. Then run script and wait for it to work
  21. # To run it go to Python -> Run Python Script
  22. # Then locate the file on your computer
  23. #
  24. #******************************************************
  25.  
  26. #------------------------------------------------------
  27. # Get Input and Test Value is a positive floating point
  28. #------------------------------------------------------
  29.  
  30. def TestValAngle (messagetxt,titletxt,default):
  31. hit=-2
  32. val=-1
  33.  
  34. while hit<0:
  35. try:
  36. if float(val)>0:
  37. hit=1;
  38. elif hit==-2:
  39. val=Prompt (messagetxt,default,true,titletxt)
  40. hit=-1
  41. else:
  42. val=Prompt ("Error: Value must an positive number\n\n"+messagetxt,val,true,titletxt)
  43. except:
  44. hit=-1
  45. val=Prompt ("Error: Value must an positive number\n\n"+messagetxt,val,true,titletxt)
  46.  
  47. return float(val)
  48.  
  49. #------------------------------------------------------
  50. # Convert Degrees to Radians
  51. #------------------------------------------------------
  52.  
  53. def degtorad(deg):
  54. rad=deg*(math.pi/180)
  55. return rad
  56.  
  57. #--------------------------------------------
  58. # Start of Main Code
  59. #--------------------------------------------
  60.  
  61. import math
  62.  
  63. separation=TestValAngle ('Eye Separation','Eye Separation','6.5')
  64.  
  65. camX=StoreCamera ()
  66.  
  67. SwitchCamera (camX)
  68.  
  69. SelectByType(VuePython.VUEBasicObject.VOT_Camera)
  70. cam = GetSelectedObjectByIndex(0)
  71.  
  72. pos=cam.Position()
  73. rot=cam.GetRotationAngles()
  74.  
  75. y=(math.sin(degtorad(rot[2]))*separation)+pos[1]
  76. x=(math.cos(degtorad(rot[2]))*separation)+pos[0]
  77.  
  78. cam.SetPosition(x,y,pos[2])
  79.  
  80. #----------------------------------------------
  81. # End of Script
  82. #----------------------------------------------

impworks © Copyright Mark Caldwell 1996 - 2017