-- -- camManager.ms - Michael B. Comet -- http://www.comet-cartoons.com/ -- -- -- This script lets you set cameras and time ranges, so that you -- can have 1 "cameraMain" camera to view in the viewport and -- for rendering and previews, cameraMain will automatically pop -- from shot to shot for each shotcamera that is chosen. -- It automatically stores the data with the scene file, and will -- refresh the UI when the scene is reset or reloaded. -- -- -- -- Version 1.02 - March 3, 2001 - Fixed up targetCam checking so it uses the -- classOf function to make sure it is a targetCamera, instead of trying to -- do target object checks etc...much more elegant this way. -- -- Version 1.03 - March 15, 2001 - Fixed up the is_camera() script to check -- to make sure dummyCam and cameraMain can't be picked...I had commented -- that out by accident before release. -- -- Version 1.04 - July 30, 2001 - Fixed up camManager to be ok when started first -- time or stuck in a mcr file. -- -- Version 1.05 - Sept 28, 2001 - Added a new "RESET" button under prefs and fixed -- up global proc declaration bugs, and general wackiness with persistents... -- -- ------------------ Global Variables -- global titlever = "1.05"; global cM_running; -- is the ui up? global camManRF; -- Rollout Floater global prefsRoll; -- rollouts global shotsRoll; -- Function declarations! global remove_camManager_var; global init_camManager_var; global update_cameraMain_script; global create_camManager_cameras; global create_shot_ui; global deinit_camManager_var; -- -- ------------------ Customization Variables, set these before running! -- -- -- ------------------- Helper Functions ------------------- -- -- Given an object name, return the handle ie: find_object "Box01" fn find_object name = ( local o = objects as array; local i; for i in 1 to o.count do ( if o[i].name == name do return o[i]; ) return undefined; ) -- Given an object, test to see if it is a camera or not -- Checks also to make sure it's not the camera.Target object as well. fn is_camera obj = ( local c=#(); local i=0; local isTarget=false; -- format "DEBUG: is_camera obj name=%\n" obj.name; if (obj == undefined) then return false; -- local cam = viewport.getCamera(); -- and get cam info try ( -- don't ask me why, but sometimes this fails?... c = cameras as array; -- use max global camera array i = findItem c obj; -- search array to see if its there. isTarget = (classOf obj == Targetcamera); ) catch ( return false; ) -- not a camera? if (i <= 0 or i == undefined) then ( return false; ) -- Make sure it's not the actual Target dummy! if (isTarget == false or isTarget == undefined) then ( return false; ) -- Make sure it's not cameraMain or dummyCam if (obj.name == "cameraMain" or obj.name == "dummyCam") then ( return false; ) -- format "DEBUG: is_camera CHOSE obj name=%\n" obj.name; return true; ) -- Given a camera name, return the handle ie: find_object "Box01" fn find_camera name = ( local o = cameras as array; local i; for i in 1 to o.count do ( -- format "DEBUG: % ?= %\n" o[i].name name; if o[i].name == name do return o[i]; ) return undefined; ) -- -- -------------------------- Data Access Functions ------------ -- -- Given an index, return the start time of the range fn get_start n = ( local ns = n as string; local s = execute( "cM_start"+ns+";" ); return s; ) -- Given an index, return the end time of the range fn get_end n = ( local ns = n as string; local e = execute( "cM_end"+ns+";" ); -- local e = execute( "shotsRoll.end"+ns+".value;" ); return e; ) -- Returns the string name of the camera chosen for the shot fn get_camera n = ( local ns = n as string; local c = execute( "cM_cam"+ns+";" ); -- local c = execute( "shotsRoll.cam"+ns+".text;" ); return c; ) -- -- ---------------------- Callback Functions ---------------- -- -- -- The following 3 functions are used to cleanup any left over global -- variables. They basically go through and will call a cleanup funciton. -- These are called every time the system is reset, new'd or opening a -- new file. This way, the variables are gone in case a new file is -- loaded, and the UI is not using leftover data. -- If the UI has been closed, this will be called just once, so that -- if it is reopened things are still cleaned up. fn cM_post_reset = ( -- format "System has been reset!\n"; deinit_camManager_var(); -- delete persistents remove_camManager_var(); -- cleanup values -- remove callbacks if we've been called once now, and the -- dialog has been dismissed. if (cM_running != 1) then ( callbacks.removeScripts id:#cM_postResetCB; callbacks.removeScripts id:#cM_postNewCB; callbacks.removeScripts id:#cM_preOpenCB; ) else ( -- reinit so the shot # stuff doesn't break. init_camManager_var(); -- initialize needed variables execute( "removeRollout shotsRoll camManRF;" ); execute( "rollout shotsRoll \"Shots\" ( )" ); execute( "addRollout shotsRoll camManRF;" ); ) ) fn cM_post_new = ( -- format "System has done a New!!\n"; deinit_camManager_var(); -- delete persistents remove_camManager_var(); -- cleanup -- remove callbacks if we've been called once now, and the -- dialog has been dismissed. if (cM_running != 1) then ( callbacks.removeScripts id:#cM_postResetCB; callbacks.removeScripts id:#cM_postNewCB; callbacks.removeScripts id:#cM_preOpenCB; ) else ( -- reinit so the shot # stuff doesn't break. init_camManager_var(); -- initialize needed variables execute( "removeRollout shotsRoll camManRF;" ); execute( "rollout shotsRoll \"Shots\" ( )" ); execute( "addRollout shotsRoll camManRF;" ); ) ) fn cM_pre_open = ( -- format "About to open a file!\n"; remove_camManager_var(); -- cleanup -- remove callbacks if we've been called once now, and the -- dialog has been dismissed. if (cM_running != 1) then ( callbacks.removeScripts id:#cM_postResetCB; callbacks.removeScripts id:#cM_postNewCB; callbacks.removeScripts id:#cM_preOpenCB; ) ) -- Called when a file is opened to update the UI -- with new data, assuming opened file had camManager data already -- in it. This is only called when camManager is running! fn cM_post_open = ( -- format "File has been opened!\n"; varExists = execute( "camManagerVer != undefined"); if (varExists) then ( init_camManager_var(); -- initialize needed variables create_camManager_cameras(); -- create dummyCam and cameraMain update_cameraMain_script(); create_shot_ui(); -- and build the new UI. ) ) -- -- ---------------------- Work Functions ---------------- -- -- Given a start and end time, set the current range, and sliderTime fn set_range s e = ( if (s == e) do -- sanity check, must be at least 1 difference e = s + 1; -- if it's less than, MAX doesn't care and just internally -- swaps the s and e for us. animationRange = (interval s e); sliderTime = s; ) -- Given the control #, handle what needs to go on when the range but is pressed fn range_pressed n = ( local ns = n as string; local s = get_start n; local e = get_end n; set_range s e ; ) -- fn jump_start_pressed n = ( local ns = n as string; local s = get_start n; local e = animationRange.end; if (s == e) then e = s + 1; animationRange = (interval s e); ) -- fn jump_end_pressed n = ( local ns = n as string; local s = animationRange.start; local e = get_end n; if (s == e) then s = e - 1; animationRange = (interval s e); ) /* *not needed after all, i used persistent variables instead. -- Adds an integer attr to object with attribute name aname. fn add_int_attr aname obj = ( local str = ( aname+"Attr = attributes "+aname+"AttrDEF "+ "( "+ "parameters main rollout:"+aname+"Roll "+ " ( "+ " "+aname+" type:#integer default:0 ui:"+aname+"Spin; "+ " )"+ " "+ "rollout "+aname+"Roll \""+aname+"\" "+ " ( "+ " spinner "+aname+"Spin \""+aname+"\" type:#integer range:[-9999,9999,0]"+ " )"+ "); "+ " "+ "custAttributes.add $"+(obj.name)+" "+aname+"Attr;" ); print str; execute str; ) */ -- -- ----------------- Interface Stuff --------------------- -- -- update_cameraMain_script() - -- This will set the cameraMain script for cameraMain -- By setting each controller to be the proper script text. -- fn update_cameraMain_script = ( local notInit = false; try ( cM = execute("$cameraMain"); ) catch ( cM = undefined; ) try ( cMT = execute("$cameraMain.Target"); ) catch ( cMT = undefined; ) -- First make sure we HAVE a camera main and target! if (cM == undefined or cMT == undefined) then ( return false; ) varExists = execute( "cM_startShot != undefined"); if (not varExists) then ( notInit = true; ) varExists = execute( "cM_endShot != undefined"); if (not varExists) then ( notInit = true; ) -- If notInit == true, then it means we don't have our needed -- shot variables! if (notInit == true) then ( return false; ) -- Now get the values of these new persistent globals. local s = execute( "cM_startShot;" ); local e = execute( "cM_endShot;" ); -- At this point we can start making our string of our script local str = "-- camManager cameraMain script *DO NOT MODIFY*\n"; local rastr = str; local tstr = str; local nrstr = str; local frstr = str; local ncstr = str; local fcstr = str; local fovstr = str; for i in s to e do ( local cs = get_start i; local ce = get_end i; local cname = get_camera i; local en = (cs != undefined and ce != undefined and cname != undefined and cname != "Pick Camera"); -- if this camera is enabled, ie: we have a camera, setup the script for it. if (en == true) then ( str += "if ($"+cname+" != undefined and currentTime >= "+(cs as string)+" and currentTime <= "+(ce as string)+" ) then\n"; rastr += "if ($"+cname+" != undefined and currentTime >= "+(cs as string)+" and currentTime <= "+(ce as string)+" ) then\n"; tstr += "if ($"+cname+" != undefined and currentTime >= "+(cs as string)+" and currentTime <= "+(ce as string)+" ) then\n"; nrstr += "if ($"+cname+" != undefined and currentTime >= "+(cs as string)+" and currentTime <= "+(ce as string)+" ) then\n"; frstr += "if ($"+cname+" != undefined and currentTime >= "+(cs as string)+" and currentTime <= "+(ce as string)+" ) then\n"; ncstr += "if ($"+cname+" != undefined and currentTime >= "+(cs as string)+" and currentTime <= "+(ce as string)+" ) then\n"; fcstr += "if ($"+cname+" != undefined and currentTime >= "+(cs as string)+" and currentTime <= "+(ce as string)+" ) then\n"; fovstr += "if ($"+cname+" != undefined and currentTime >= "+(cs as string)+" and currentTime <= "+(ce as string)+" ) then\n"; str += "(\n"; rastr += "(\n"; tstr += "(\n"; nrstr += "(\n"; frstr += "(\n"; ncstr += "(\n"; fcstr += "(\n"; fovstr += "(\n"; str += " animate off (\n"; rastr += " animate off (\n"; tstr += " animate off (\n"; nrstr += " animate off (\n"; frstr += " animate off (\n"; ncstr += " animate off (\n"; fcstr += " animate off (\n"; fovstr += " animate off (\n"; str += " $cameraMain.clipManually = $"+cname+".clipManually;\n"; str += " $cameraMain.position = $"+cname+".position\n"; rastr += " $"+cname+".transform.controller.Roll_Angle*pi/180;\n"; tstr += " $cameraMain.Target.position = $"+cname+".Target.position\n"; nrstr += " $"+cname+".nearrange;\n"; frstr += " $"+cname+".farrange;\n"; ncstr += " $"+cname+".nearclip;\n"; fcstr += " $"+cname+".farclip;\n"; fovstr += " ($"+cname+".fov)*pi/180;\n"; str += " ) --end of animate off\n"; rastr += " ) --end of animate off\n"; tstr += " ) --end of animate off\n"; nrstr += " ) --end of animate off\n"; frstr += " ) --end of animate off\n"; ncstr += " ) --end of animate off\n"; fcstr += " ) --end of animate off\n"; fovstr += " ) --end of animate off\n"; str += ") else\n"; rastr += ") else\n"; tstr += ") else\n"; nrstr += ") else\n"; frstr += ") else\n"; ncstr += ") else\n"; fcstr += ") else\n"; fovstr += ") else\n"; ) ) -- end of i in s to e -- now do the default case local cname = "dummyCam"; str += "if ( $"+cname+" != undefined ) then\n"; rastr += "if ( $"+cname+" != undefined ) then\n"; tstr += "if ( $"+cname+" != undefined ) then\n"; nrstr += "if ( $"+cname+" != undefined ) then\n"; frstr += "if ( $"+cname+" != undefined ) then\n"; ncstr += "if ( $"+cname+" != undefined ) then\n"; fcstr += "if ( $"+cname+" != undefined ) then\n"; fovstr += "if ( $"+cname+" != undefined ) then\n"; str += "(\n"; rastr += "(\n"; tstr += "(\n"; nrstr += "(\n"; frstr += "(\n"; ncstr += "(\n"; fcstr += "(\n"; fovstr += "(\n"; str += " animate off (\n"; rastr += " animate off (\n"; tstr += " animate off (\n"; nrstr += " animate off (\n"; frstr += " animate off (\n"; ncstr += " animate off (\n"; fcstr += " animate off (\n"; fovstr += " animate off (\n"; str += " $cameraMain.clipManually = $"+cname+".clipManually;\n"; str += " $cameraMain.position = $"+cname+".position\n"; rastr += " $"+cname+".transform.controller.Roll_Angle*pi/180;\n"; tstr += " $cameraMain.Target.position = $"+cname+".Target.position\n"; nrstr += " $"+cname+".nearrange;\n"; frstr += " $"+cname+".farrange;\n"; ncstr += " $"+cname+".nearclip\n"; fcstr += " $"+cname+".farclip\n"; fovstr += " ($"+cname+".fov)*pi/180;\n"; str += " ) --end of animate off\n"; rastr += " ) --end of animate off\n"; tstr += " ) --end of animate off\n"; nrstr += " ) --end of animate off\n"; frstr += " ) --end of animate off\n"; ncstr += " ) --end of animate off\n"; fcstr += " ) --end of animate off\n"; fovstr += " ) --end of animate off\n"; str += ") else\n"; rastr += ") else\n"; tstr += ") else\n"; nrstr += ") else\n"; frstr += ") else\n"; ncstr += ") else\n"; fcstr += ") else\n"; fovstr += ") else\n"; str += "(\n"; rastr += "(\n"; tstr += "(\n"; nrstr += "(\n"; frstr += "(\n"; ncstr += "(\n"; fcstr += "(\n"; fovstr += "(\n"; str += " animate off (\n"; rastr += " animate off (\n"; tstr += " animate off (\n"; nrstr += " animate off (\n"; frstr += " animate off (\n"; ncstr += " animate off (\n"; fcstr += " animate off (\n"; fovstr += " animate off (\n"; str += " [0,0,0];"; rastr += " 0.0;"; tstr += " [0,100,0];\n"; nrstr += " 0.0;\n"; frstr += " 1000;\n"; ncstr += " 1.0;\n"; fcstr += " 1000;\n"; fovstr += " 35*pi/180;\n"; str += " ) --end of animate off\n"; rastr += " ) --end of animate off\n"; tstr += " ) --end of animate off\n"; nrstr += " ) --end of animate off\n"; frstr += " ) --end of animate off\n"; ncstr += " ) --end of animate off\n"; fcstr += " ) --end of animate off\n"; fovstr += " ) --end of animate off\n"; str += ")\n"; rastr += ")\n"; tstr += ")\n"; nrstr += ")\n"; frstr += ")\n"; ncstr += ")\n"; fcstr += ")\n"; fovstr += ")\n"; -- format "DEBUG: cameraMain script=\n"; -- format "%\n" str; -- Finally update the script! cM.position.controller.script = str; cMT.position.controller.script = tstr; cM.transform.controller.Roll_Angle.controller.script = rastr; cM.nearrange.controller.script = nrstr; cM.farrange.controller.script = frstr; cM.nearclip.controller.script = ncstr; cM.farclip.controller.script = fcstr; cM.fov.controller.script = fovstr; return true; ) -- This will make the required cameraMain and dummyCamera if needed. fn create_camManager_cameras = ( if ( execute("$dummyCam == undefined") ) then ( local c1 = freeCamera(); c1.rotation = (quat 0.707107 0 0 0.707107); c1.position = [0,0,0]; c1.type = #target; c1.targetDistance = 100; t1 = c1.name+".Target"; local t = execute("$"+t1); -- get handle to real cameraTarget. t.name = "dummyCam.Target"; c1.name = "dummyCam"; hide c1; hide t; ) if ( execute("$cameraMain == undefined") ) then ( messageBox "cameraMain not found!\nTarget camera, cameraMain will be created." title:"cameraMain not found"; local c1 = freeCamera(); c1.rotation = (quat 0.707107 0 0 0.707107); c1.position = [0,0,0]; c1.type = #target; c1.targetDistance = 100; t1 = c1.name+".Target"; local t = execute("$"+t1); -- get handle to real cameraTarget. t.name = "cameraMain.Target"; c1.name = "cameraMain"; c1.showCone = true; c1.position.controller = position_script(); -- finally set up cameraMain to be scripted... c1.position.controller.script = "[0, 0, 0]"; t.position.controller = position_script(); t.position.controller.script = "[0,100,0]"; c1.transform.controller.Roll_Angle.controller = float_script(); c1.fov.controller = float_script(); c1.nearclip.controller = float_script(); c1.farclip.controller = float_script(); c1.nearrange.controller = float_script(); c1.farrange.controller = float_script(); freeze c1; freeze t; ) ) -- This will go through and set all camManager variables to undefined. fn remove_camManager_var = ( varExists = execute( "camManagerVer != undefined"); if (varExists) then ( execute( "camManagerVer = undefined;"); -- hmm lets do this ) -- keep this so we can use it later... local s = execute( "cM_startShot;" ); local e = execute( "cM_endShot;" ); local i = 0; camManagerVer = undefined; cM_startShot = undefined; cM_endShot = undefined; if (s != undefined and e != undefined) then ( for i in s to e do ( execute( "cM_start"+(i as string)+" = undefined;"); execute( "cM_end"+(i as string)+" = undefined;"); execute( "cM_cam"+(i as string)+" = undefined;"); ) ) if (cM_running != 0 and camManRF != undefined) then -- are we still up? ( execute( "removeRollout shotsRoll camManRF;" ); execute( "rollout shotsRoll \"Shots\" ( )" ); execute( "addRollout shotsRoll camManRF;" ); ) return true; ) -- This will init the camera Manager variables fn init_camManager_var = ( -- Now make sure persistent global variables are setup to store each shots -- start and end times, as well as camera string name. -- Basically, if the variable exists, don't try to recreate it or change its value -- but if it doesn't exist, create the new persistent variable. varExists = execute( "camManagerVer != undefined"); if (not varExists) then ( str = ( "persistent global camManagerVer=\""+titlever+"\";\n"); execute str; format "camManager initialized version: %\n" titlever; ) varExists = execute( "cM_startShot != undefined"); if (not varExists) then ( str = ( "persistent global cM_startShot=1;\n"); execute str; ) varExists = execute( "cM_endShot != undefined"); if (not varExists) then ( str = ( "persistent global cM_endShot=10;\n"); execute str; ) -- Now get the values of these new persistent globals. -- we need to do this thru an execute, since if the script was started -- for the first time, they will have been "undefined" when it was parsed -- and run. local s = execute( "cM_startShot;" ); local e = execute( "cM_endShot;" ); if (prefsRoll != undefined) then ( -- Update spinners to correct values now. prefsRoll.startShotSpin.value = s; prefsRoll.endShotSpin.value = e; ) for i in s to e do ( varExists = execute( "cM_start"+(i as string)+" != undefined"); if (not varExists) then ( str = "persistent global cM_start"+(i as string)+"="+( (((i-1)*10)+1) as string )+";\n"; -- format "DEBUG: %" str; execute str; ) varExists = execute( "cM_end"+(i as string)+" != undefined"); if (not varExists) then ( str = "persistent global cM_end"+(i as string)+"="+( (i*10) as string )+";\n"; -- format "DEBUG: %" str; execute str; ) varExists = execute( "cM_cam"+(i as string)+" != undefined"); if (not varExists) then ( str = "persistent global cM_cam"+(i as string)+"=\"Pick Camera\";\n"; -- format "DEBUG: %" str; execute str; ) ) ) -- This will deinit the camera Manager variables and make it "erased" fn deinit_camManager_var = ( -- Now make sure persistent global variables are setup to store each shots -- start and end times, as well as camera string name. -- Basically, if the variable exists, don't try to recreate it or change its value -- but if it doesn't exist, create the new persistent variable. varExists = execute( "camManagerVer != undefined"); if (varExists) then ( str = ( "persistents.remove #camManagerVer;\n"); execute str; ) else return; varExists = execute( "cM_startShot != undefined"); if (varExists) then ( str = ( "persistents.remove #cM_startShot;\n"); execute str; ) varExists = execute( "cM_endShot != undefined"); if (varExists) then ( str = ( "persistents.remove #cM_endShot;\n"); execute str; ) -- Now get the values of these new persistent globals. -- we need to do this thru an execute, since if the script was started -- for the first time, they will have been "undefined" when it was parsed -- and run. local s = execute( "cM_startShot;" ); local e = execute( "cM_endShot;" ); execute( "camManagerVer = undefined;"); execute( "cM_startShot = undefined;"); execute( "cM_endShot = undefined;"); if (s == undefined) then return; if (prefsRoll != undefined) then ( -- Update spinners to correct values now. prefsRoll.startShotSpin.value = 1; prefsRoll.endShotSpin.value = 10; ) for i in s to e do ( varExists = execute( "cM_start"+(i as string)+" != undefined"); if (varExists) then ( str = "persistents.remove #cM_start"+(i as string)+";\n"; -- format "DEBUG: %" str; execute str; ) varExists = execute( "cM_end"+(i as string)+" != undefined"); if (varExists) then ( str = "persistents.remove #cM_end"+(i as string)+";\n"; -- format "DEBUG: %" str; execute str; ) varExists = execute( "cM_cam"+(i as string)+" != undefined"); if (varExists) then ( str = "persistents.remove #cM_cam"+(i as string)+";\n"; -- format "DEBUG: %" str; execute str; ) execute( "cM_start"+(i as string)+" = undefined;"); execute( "cM_end"+(i as string)+" = undefined;"); execute( "cM_cam"+(i as string)+" = undefined;"); ) -- now put def values back in remove_camManager_var(); ) -- This will create the Shots Rollout, remove and recreate it if needed fn create_shot_ui = ( -- remove old rollout if it exists execute( "removeRollout shotsRoll camManRF;" ); -- get variable values locally via and execute in case this is first -- time script is run local s = execute( "cM_startShot;" ); local e = execute( "cM_endShot;" ); str=""; str += "rollout shotsRoll \"Shots\"\n";; str += "(\n"; str += "\n"; for i in s to e do ( local cname = execute( "cM_cam"+(i as string) ); -- get name from variable local en = (cname != undefined and cname != "Pick Camera"); str += "spinner start"+(i as string)+" \"\" range:[-9999,9999,cM_start"+(i as string)+"] enabled:"+(en as string)+" scale:1 type:#integer fieldwidth:40 tooltip:\"Start frame\" offset:[0,2] across:7;\n"; str += "button jstart"+(i as string)+" \"S\" width:15 enabled:"+(en as string)+" tooltip:\"Set timeSlider start to Start of Shot\" offset:[-8,0];\n"; str += "button range"+(i as string)+" \""+(i as string)+"\" width:32 enabled:"+(en as string)+" tooltip:\"Set timeSlider range to Shot Range\" offset:[-24,0];\n"; str += "button jend"+(i as string)+" \"E\" width:15 enabled:"+(en as string)+" tooltip:\"Set timeSlider end to End of Shot\" offset:[-40,0];\n"; str += "spinner end"+(i as string)+" \"\" range:[-9999,9999,cM_end"+(i as string)+"] enabled:"+(en as string)+" scale:1 type:#integer fieldwidth:40 tooltip:\"End frame\" offset:[-42,2];\n"; str += "pickbutton cam"+(i as string)+" \"Pick Camera\" width:115 filter:is_camera tooltip:\"Pick Camera for Shot\" offset:[-20,0];\n"; str += "button killcam"+(i as string)+" \"X\" width:15 enabled:"+(en as string)+" tooltip:\"Remove Camera for Shot\" offset:[25,0];\n"; str += "\n"; ) for i in s to e do ( str += "on start"+(i as string)+" changed val do\n"; str += "(\n"; str += " cM_start"+(i as string)+" = val;\n"; str += " update_cameraMain_script();\n"; str += " setSaveRequired true;\n"; str += ")\n"; ) for i in s to e do ( str += "on end"+(i as string)+" changed val do\n"; str += "(\n"; str += " cM_end"+(i as string)+" = val;\n"; str += " update_cameraMain_script();\n"; str += " setSaveRequired true;\n"; str += ")\n"; ) for i in s to e do ( str += "on cam"+(i as string)+" picked node do\n"; str += "(\n"; str += " cam"+(i as string)+".text = node.name;\n"; str += " start"+(i as string)+".enabled = jstart"+(i as string)+".enabled = range"+(i as string)+".enabled = jend"+(i as string)+".enabled = end"+(i as string)+".enabled = killcam"+(i as string)+".enabled = true;\n"; str += " cM_cam"+(i as string)+" = node.name;\n"; str += " update_cameraMain_script();\n"; str += " setSaveRequired true;\n"; str += ")\n"; ) for i in s to e do ( str += "on jstart"+(i as string)+" pressed do\n"; str += "(\n"; str += " jump_start_pressed "+(i as string)+";\n"; str += ")\n"; ) for i in s to e do ( str += "on jend"+(i as string)+" pressed do\n"; str += "(\n"; str += " jump_end_pressed "+(i as string)+";\n"; str += ")\n"; ) for i in s to e do ( str += "on range"+(i as string)+" pressed do\n"; str += "(\n"; str += " range_pressed "+(i as string)+";\n"; str += ")\n"; ) for i in s to e do ( str += "on killcam"+(i as string)+" pressed do\n"; str += "(\n"; str += " cam"+(i as string)+".text = \"Pick Camera\";\n"; str += " start"+(i as string)+".enabled = jstart"+(i as string)+".enabled = range"+(i as string)+".enabled = jend"+(i as string)+".enabled = end"+(i as string)+".enabled = killcam"+(i as string)+".enabled = false;\n"; str += " cM_cam"+(i as string)+" = undefined;\n"; str += " update_cameraMain_script();\n"; str += " setSaveRequired true;\n"; str += ")\n"; ) str += ")\n\n"; execute str; -- now make the shotsRoll str = "addRollout shotsRoll camManRF;"; execute str; -- do this via execute too in case 1st time. -- adjust cname of buttons here so they don't resize. for i in s to e do ( local cname = execute( "cM_cam"+(i as string) ); -- get name from variable str = "shotsRoll.cam"+(i as string)+".text = \""+(cname)+"\";\n"; execute str; ) ) rollout shotsRoll "Shots" ( ) rollout prefsRoll "Setup" ( group "Number of Shots" ( spinner startShotSpin "Starting Shot #:" range:[1,998,1] scale:1 type:#integer fieldwidth:48 offset:[0,2] enabled:true across:2; spinner endShotSpin "Ending Shot #:" range:[2,999,10] scale:1 type:#integer fieldwidth:48 offset:[0,2] enabled:true; button makeSlidersBut "Create/Update Shot Rollout" width:270 enabled:true tooltip:"Creates or regenerates all the UI sliders and buttons for shots"; button clearManagerBut "RESET: Delete ALL Shots" width:270 enabled:true tooltip:"Totally wipes out all current camManager data, and resets everything."; ) -- This occurs once the floater window is created on prefsRoll open do ( cM_running = 1; callbacks.addScript #systemPostReset "cM_post_reset()" id:#cM_postResetCB; callbacks.addScript #systemPostNew "cM_post_reset()" id:#cM_postNewCB; callbacks.addScript #filePreOpen "cM_pre_open()" id:#cM_preOpenCB; callbacks.addScript #filePostOpen "cM_post_open()" id:#cM_postOpenCB; init_camManager_var(); -- initialize needed variables create_camManager_cameras(); -- create dummyCam and cameraMain update_cameraMain_script(); create_shot_ui(); -- and build the new UI. ) -- This occurs when the floater window is closed on prefsRoll close do ( callbacks.removeScripts id:#cM_postOpenCB; cM_running = 0; ) on startShotSpin changed val do ( local int s = execute( "cM_startShot = "+(val as string)+";" ); local int e = execute( "cM_endShot;" ); if (s >= e) then ( execute( "cM_endShot = cM_startShot + 1;" ); endShotSpin.value = s + 1; ) ) on endShotSpin changed val do ( local s = execute( "cM_startShot;" ); local e = execute( "cM_endShot = "+(val as string)+";" ); if (e <= s) then ( execute( "cM_startShot = cM_endShot - 1;" ); startShotSpin.value = e - 1; ) ) on makeSlidersBut pressed do ( init_camManager_var(); -- initialize needed variables, # of shots may be changed create_shot_ui(); -- and build the new UI. update_cameraMain_script(); -- and update cameraMain! setSaveRequired true; ) on clearManagerBut pressed do ( cM_post_reset(); -- just do this, it will do the right thing. ) ) rollout aboutRoll "About camManager" ( label abtlbl1 ""; label abtlbl2 "by"; label abtlbl3 "Michael B. Comet"; label abtlbl4 "http://www.comet-cartoons.com/"; label abtlbl5 "comet@comet-cartoons.com"; label abtlbl6 ""; label abtlbl7 "Copyright ©2001 Michael B. Comet"; label abtlbl8 "All Rights Reserved"; label abtlbl9 ""; label abtlb20 "Do *NOT* modify or delete the"; label abtlb21 "cameraMain or dummyCam objects!"; on aboutroll open do ( abtlbl1.text = titlever; ) ) if (cM_running != 1) then ( -- Do any preRollout preprocessing here -- create the rollout window and add the rollout execute("camManRF = newRolloutFloater (\"Comet camManager \" + titlever) 345 532;"); execute("addRollout aboutRoll camManRF rolledUp:true"); execute("addRollout prefsRoll camManRF rolledUp:true"); execute("addRollout shotsRoll camManRF"); ) -- Do any postRollout preprocessing here --end of camManager.ms