/* ------------------------------------------------------------------------ ------------------------------------------------------------------------ Corona Proxy Tools v1.0 Created By NicolasC (nicocaplat@gmail.com) Based on the VRay Proxy Tools made by David Mackenzie (dave@daveandgoliath.com) ------------------------------------------------------------------------ ------------------------------------------------------------------------ Changelog: V1.0: code cleaning to match my little habits, removed undo I found useless, main features are functional / little problem remaining with the progress, nothing crucial, will need investigation ------------------------------------------------------------------------ To-Do: - handling of Keep In Memory option ? - handling of Animation ? enable/disable, mode ? ------------------------------------------------------------------------ ! USE AT YOUR OWN RISK ! ------------------------------------------------------------------------ */ macroScript CProxiesTool Category:"Corona Renderer" toolTip:"Manages CProxies display modes" buttontext:"CProxiesTool" ( try (destroyDialog ::CoronaProxiesTools) catch() rollout CoronaProxiesTools "CoronaProxiesTools v1.0" ( --- VARIABLES -- local col_prox = #() -- ##### CONTROLS ##### -- group "Settings" ( checkbox chkAllProxies "All Proxies" across:2 checked:True checkbox chkSelected "Selected Proxies" button btnRefresh "Refresh" height:30 width:220 ) group "Hide/Show" ( button btnShow "Show Proxies" across:2 width:110 height:30 button btnHide "Hide Proxies" width:110 height:30 ) group "Display Mode" ( button btnBound "Solid BBox" across:2 width:110 height:30 button btnWire "Wire BBox" width:110 height:30 button btnPCloud "Point Cloud" across:2 width:110 height:30 button btnFMesh "Full Mesh" width:110 height:30 ) progressbar progBar width:232 pos:[4,240] height:19 label lblState "State: " align:#left -- ##### FUNCTIONS ##### -- --Collects scene proxies fn CollectProxies all:True = ( lblState.text = "State: Collecting Proxies" if all == True then ( tot = objects.count inc = 0 for o in objects do ( if (classOf o) == CProxy then ( append col_prox o inc += 1 progBar.value = (100.0*inc/tot) ) ) lblState.text = "State: Proxies Collected" ) else ( sel= (selection as array) inc = 0 for s in sel do ( if (classof s) == CProxy then ( append col_prox s progBar.value = (100.0*inc/sel.count) ) ) lblState.text = "State: Proxies Collected" ) ) --Hide or shows proxies fn HideShowProxies hiden:True = ( tot = col_prox.count if hiden == True then ( lblState.text = "State: Hiding Proxies" inc = 0 for cc in col_prox do ( if cc != undefined then hide cc inc += 1 progBar.value = (100.0*inc/tot) ) lblState.text = "State: Done" ) else ( ( lblState.text = "State: Show Proxies" inc = 0 for c in col_prox do ( unhide c inc += 1 progBar.value = (100.0*inc/tot) ) ) lblState.text = "State: Done" ) ) --Sets the display mode for the proxies. Use getClassInstances to speed up as the max wrapper is not needed. fn ViewportDisplay mode:2 = ( if chkSelected.state == True then ( tot = col_prox.count lblState.text = "State: Setting Display Mode" inc = 0 for cc in col_prox do ( if cc != undefined then cc.previzType = mode inc += 1 progBar.value = (100.0*inc/tot) ) lblState.text = "State: Done" ) else ( ( lblState.text = "State: Setting Display Mode" temp_prox = (getClassInstances CProxy) inc = 0 for tt in temp_prox do ( if tt != undefined then tt.previzType = mode inc += 1 progBar.value = (100.0*inc/temp_prox.count) ) ) lblState.text = "State: Done" ) ) -- ##### EVENTS ##### -- on CoronaProxiesTools open do CollectProxies() on chkAllProxies changed state do ( if state == True then ( chkSelected.state = False col_prox = #() CollectProxies() ) else ( chkSelected.state = True col_prox = #() CollectProxies all:False ) ) on chkSelected changed state do ( if state == True then ( chkAllProxies.state = False col_prox = #() CollectProxies all:False ) else ( chkAllProxies.state = True col_prox = #() CollectProxies() ) ) on btnShow pressed do HideShowProxies hiden:False on btnHide pressed do HideShowProxies hiden:True on btnBound pressed do ViewportDisplay mode:0 on btnWire pressed do ViewportDisplay mode:1 on btnPCloud pressed do ViewportDisplay mode:2 on btnFMesh pressed do ViewportDisplay mode:3 on btnRefresh pressed do ( if chkAllProxies == True then ( CollectProxies() ) else ( CollectProxies all:False ) ) )-- end of rollout if CProxy != undefined then ( createDialog CoronaProxiesTools 240 290 ) else ( messagebox "This tool requires Corona to be installed. The CProxy class name is undefined." ) )--end of script