/* Auto Cross-Eyed Mary V1.01 Author: Chris Gray chrisgray3d@gmail.com 1.01 Finished first .ms version 2/11/2006 Changed to .mcr 29/09/2007 Added functionality to auto save UI settings with each max file with persistent global variables 21/8/2009 Description Brings 2 very useful stereo rendering elements together in a macroscript The first thing being the the XidMary Camera which can generlly be found at www.maxplugins.de The second thing is the equation for figuring out how to render correct parallel stero pairs I got this information from Paul Bourke. http://local.wasp.uwa.edu.au/~pbourke/miscellaneous/stereographics/stereorender/ Installation For those who haven't installed a macroscript before: Put the .mcr file in the usermacros directory. To find where this is look under: customize/configure system paths to see where "Additional Macros" are being stored. After you've copied the macro to the correct spot, restart max. Then goto customize/customize user interface. Select the toolbars tab. Change category to CgRay and find AutoXidMary in the list and drag it to a toolbar. If you have the free XidMary Plugin installed as well, you're ready to go. Usage Make a XidMaryCamera and use it as you would a normal Max camera. The target of the camera is the focal plane , which means that the target will be at the depth in the image at which the viewer can easily see without having to diverge or converge their eyes. For comfortable viewing, do not have any objects closer than the focal plane for any period of time or you will probably give the viewer a headache or make them feel woozy. When you are ready to set up to render, run the script. and pick the XidMary Camera. Change the spinners for X & Y res for the final resolution of your image Then hit the "Calc all and adjust render output size" button This will adjust eye seperation for the most comfortable viewing of the focal plane. as well as adjust render output size based on Paul Bourke's information on his site listed above. The eye seperation multiplier is to "force" more or less eye seperation. It's not reccomended, that you change this for the best results, but the option is there for those who want it After you've rendered the images, you need to crop the left side from the left camera image back to final image size and crop the right side from the right side camera image back to final image size If you want more explaination on how and why, check Paul's site above as he has funky diagrams that explain it well. */ macroscript AutoXidMary category: "CgRay" ( clearlistener () global AutoXidMaryDialog try (destroydialog AutoXidMaryDialog) catch () local IniFile = getDir #plugcfg + "\\AutoXidMary.ini" local XidCam Rollout AutoXidMaryDialog "Xid Mary Calculator" ( fn uiInit = ( for currentControl in AutoXidMaryDialog.controls do ( try ( case classof currentControl of ( SpinnerControl: ( currentControl.value = (execute ("perGlobUI_" + currentControl.name))) ) currentControl.enabled = (execute ("perGlobUI_" + currentControl.name +"Enabled")) currentControl.visible = (execute ("perGlobUI_" + currentControl.name +"Visible")) ) catch() ) ) fn uiSave = ( for currentControl in AutoXidMaryDialog.controls do ( try ( case classof currentControl of ( SpinnerControl: ( execute (("persistent global "+ "perGlobUI_" + currentControl.name)+ " = " + (currentControl.value as string))) ) execute (("persistent global "+ "perGlobUI_" + currentControl.name +"Enabled") + " = " + (currentControl.enabled as string)) execute (("persistent global "+ "perGlobUI_" + currentControl.name +"Visible") + " = " + (currentControl.visible as string)) ) catch() ) ) fn xidMaryFilter obj = ClassOf obj == XIdMary pickbutton pbt_campick "Pick XidMary Cam" autodisplay:true filter:xidMaryFilter spinner spn_Xres "X res" range:[1,5000,768] type:#integer enabled:false spinner spn_Yres "Y res" range:[1,5000,576] type:#integer enabled:false spinner spn_EyeSepMult "Eye Sep Multiplier" range:[.5,2,1] type:#float enabled:false button btn_calc "Calc all and adjust output render size" enabled:false label infolabel "Pick XidMary Camera" on pbt_campick picked PickXid do ( XidCam = PickXid spn_Xres.enabled = true spn_Yres.enabled = true spn_EyeSepMult.enabled = true btn_calc.enabled = true infolabel.text = "Ready to calculate" ) on btn_calc pressed do ( if XidCam == undefined then ( messagebox "No XidMary Camera Defined" ) else ( focaldist = distance XidCam XidCam.target XidCamL = XidCam.children[1] FOV = XidCamL.curfov Eyesep = (focaldist/30)*spn_EyeSepMult.value XidCam.EyeDistance = Eyesep XidCam.FocusDistance = Eyesep delta = (Eyesep*spn_Xres.value)/(2*focaldist*tan(fov/2)) renderres = spn_Xres.value+delta renderresI = renderres as integer diff = renderres - renderresI if diff > .5 then renderresI += 1 infolabel.text = "done calculating" print renderresI if renderSceneDialog.isOpen() == true then ( renderSceneDialog.close() wasclosed = true ) else ( wasclosed = false ) renderwidth = renderresI renderheight = spn_Yres.value if wasclosed == true then ( renderSceneDialog.open() ) ) ) on AutoXidMaryDialog open do uiInit() on AutoXidMaryDialog moved pos do setIniSetting IniFile "Dialog" "Position" (pos as string) on AutoXidMaryDialog close do uiSave() ) AutoXidMaryDialogPos = execute (getIniSetting IniFile "Dialog" "Position") if AutoXidMaryDialogPos == OK do AutoXidMaryDialogPos = [100,100] if AutoXidMaryDialogPos.x > sysinfo.desktopsize.x - (AutoXidMaryDialog.width) do AutoXidMaryDialogPos.x = sysinfo.desktopsize.x - (AutoXidMaryDialog.width) if AutoXidMaryDialogPos.y > sysinfo.desktopsize.y - (AutoXidMaryDialog.height + 30) do AutoXidMaryDialogPos.y = sysinfo.desktopsize.y - (AutoXidMaryDialog.height + 30) if AutoXidMaryDialogPos.x < 0 do AutoXidMaryDialogPos.x = 0 if AutoXidMaryDialogPos.y < 0 do AutoXidMaryDialogPos.y = 0 createdialog AutoXidMaryDialog pos:AutoXidMaryDialogPos width:220 )