Ill check over the weekend, and try to test when I can, But ill def give it a go in Monday!
Cheers
Cheers
IMPORTANT Chaos License Server update January 28th 2025.
If you have not yet updated your License Server to version 6.1 or above and are unable to access your license please follow these simple instructions HERE.-- Rollouts global rlt_MPManager -- Functions global loadRolloutPosition global saveRolloutPosition global loadLayerListBox global MPMsetupMattePass global resetMatteObjects global isOnMatteLayer global MPMSetupMatteXrefs global resetMatteXrefObjects global MPMLoadFunctionsFile global writeFunctionFile -- Variables global selectedLayerNameArray = #() global MPManagerINIFile = (getDir #scripts + "\\MPManager.ini") global AlphaContribution = -1.0 global Shadows = false global AffectAlpha = false global Brightness = 1.0 global ReflectionAmt = 1.0 global RefractionAmt = 1.0 global GIAmt = 1.0 global noGI = true global MPMFunctionsFilename = "MPManager_Functions.ms" ---- persistent global MPMFunctionsFile = "" persistent global overrideWrappers = false persistent global overrideXRefs = true persistent global g_layerNameArr = "" persistent global g_optionsArr = #() --fileIn "Q:/Colin/MPManager/MPManager_Functions.ms" if (rlt_MPManager != undefined) then destroyDialog rlt_MPManager /************************************************************************************************************/ /* loadRolloutPosition -- loads the ini file and sets the position of the rollout*/ fn loadRolloutPosition theRlt theINIFile = ( if (doesFileExist theINIFile) and (hasINISetting theINIFile theRlt.name "pos_x") and (hasINISetting theINIFile theRlt.name "pos_y") then ( local thePos = point2 0 0 thePos.x = (getINISetting theINIFile theRlt.name "pos_x") as float thePos.y = (getINISetting theINIFile theRlt.name "pos_y") as float setDialogPos theRlt thePos ) else ( -- ini file doesn't exist, create it saveRolloutPosition theRlt theINIFile ) ) /* saveRolloutPosition -- saves the position of the rollout in the ini file */ fn saveRolloutPosition theRlt theINIFile = ( local thePos = getDialogPos theRlt try ( setINISetting theINIFile theRlt.name "pos_x" (thePos.x as string) setINISetting theINIFile theRlt.name "pos_y" (thePos.y as string) ) catch ( messageBox ("Unable to write correctly to the file "+theINIFile+".") beep:false ) ) -- Returns the Functions File fn MPMLoadFunctionsFile theINIFile = ( local functionFilePath = "" if (doesFileExist theINIFile) then ( -- INI file exists if (hasINISetting theINIFile "functions" "path") then ( -- Functions path exists, fill the function variable if not(doesFileExist (p = getINISetting theINIFile "functions" "path")) then ( -- The file linked to the functions path does not exist print "1" writeFunctionFile MPManagerINIFile ) ) else ( -- Functions path keys don't exist, ask user to find them and write them print "2" writeFunctionFile MPManagerINIFile ) ) else ( -- INI file doesn't exist print "3" writeFunctionFile MPManagerINIFile ) /* FIX FIX FIX */ try ( MPMFunctionsFile = getINISetting theINIFile "functions" "path" fileIn MPMFunctionsFile ) catch () ) fn writeFunctionFile theINIFile = ( local functionFilePath = "" messageBox ("You are about to locate the "+MPMFunctionsFilename+" file.\n\nPlease note: for network rendering, this file MUST be visible to the render nodes\n using the same path that is located in your "+MPManagerINIFile+" file.\n\nIf the file is not there currently, please cancel and save it to the network now.\n") beep:false if ((f = getOpenFileName caption:("Locate the "+MPMFunctionsFilename+" file.") filename:MPMFunctionsFilename) != undefined) then ( print "writefunctionfile 1" try ( setINISetting theINIFile "functions" "path" f return true ) catch ( return false ) ) else return false ) /************************************************************************************************************/ rollout rlt_MPManager "MPManager v1.0" ( multiListBox mlst_Layers "Layers of non-Matte objects:" items:#() height:17 width:160 offset:[0,5] groupBox grp_MatteProperties "Matte object properties" width:180 height:240 offset:[170,-247] spinner spn_alphaContribution "Alpha Contribution " range:[-1,1,-1] type:#float fieldWidth:35 offset:[-7,-224] groupBox grp_DirectLight "Direct light" width:160 height:80 offset:[180,0] checkbox chk_Shadows "" offset:[310,-70] label lbl_Shadows "Shadows" offset:[104,-19] checkbox chk_AffectAlpha "" offset:[310,0] label lbl_AffectAlpha "Affect Alpha" offset:[97,-19] spinner spn_brightness "Brightness " range:[0,1,1] type:#float fieldWidth:35 offset:[-14,2] groupBox grp_RRGI "Reflection/Refraction/GI" width:160 height:110 offset:[180,6] spinner spn_reflection "Reflection Amount " range:[0,1,1] type:#float fieldWidth:35 offset:[-15,-94] spinner spn_refraction "Refraction Amount " range:[0,1,1] type:#float fieldWidth:35 offset:[-15,0] spinner spn_gi "GI Amount " range:[0,1,1] type:#float fieldWidth:35 offset:[-15,0] label lbl_noGI "No GI on other mattes" offset:[80,0] checkbox chk_noGI "" offset:[312,-17] checked:true --groupBox grp_Setup "Setup" offset:[0,17] width:130 height:50 checkBox chk_oVRayMtlWrapper "Override VRayOverrideMtls to Matte" offset:[0,19] enabled:false checkBox chk_oXRefs "Override XRefs" checked:overrideXRefs enabled:true button btn_Setup "Setup Matte Pass" offset:[0,5] align:#left button btn_Reset "Reset Pass" offset:[-30,-27] fn loadLayerListBox = ( theItems = for i=0 to layerManager.count-1 collect (layerManager.getLayer i).name mlst_Layers.items = theItems ) fn updateSelectedLayerNameArray = ( local layersSel = mlst_Layers.selection as array selectedLayerNameArray = for i = 1 to layersSel.count collect mlst_Layers.items[layersSel[i]] ) on btn_Setup pressed do ( local selectedLayerNameAsString = "" updateSelectedLayerNameArray() -- Separates the Array into strings to pass to MPMsetupMattePass for l in selectedLayerNameArray do selectedLayerNameAsString += (l + ";") g_layerNameArr = selectedLayerNameAsString g_optionsArr = #(AlphaContribution,Shadows,AffectAlpha,Brightness,ReflectionAmt,RefractionAmt,GIAmt,noGI) MPMsetupMattePass g_layerNameArr oWrappers:overrideWrappers oXrefs:overrideXrefs optionsArr:g_optionsArr ) on btn_Reset pressed do ( resetMatteObjects objects if (overrideXRefs) then resetMatteXrefObjects() ) on spn_alphaContribution changed val do AlphaContribution = val on chk_Shadows changed state do Shadows = state on chk_AffectAlpha changed state do AffectAlpha = state on spn_brightness changed val do Brightness = val on spn_reflection changed val do ReflectionAmt = val on spn_refraction changed val do RefractionAmt = val on spn_gi changed val do GIAmt = val on chk_noGI changed state do noGI = state on chk_oVRayMtlWrapper changed state do overrideWrappers = state on chk_oXRefs changed state do overrideXRefs = state on rlt_MPManager open do ( clearListener() loadRolloutPosition rlt_MPManager MPManagerINIFile MPMLoadFunctionsFile MPManagerINIFile print "MPManager Loaded..." loadLayerListBox() ) on rlt_MPManager close do ( saveRolloutPosition rlt_MPManager MPManagerINIFile if (queryBox "Reset all objects to original settings?" title:"Reset All objects?" beep:false) then ( resetMatteObjects objects if (overrideXRefs) then resetMatteXrefObjects() ) ) ) createDialog rlt_MPManager 373 335
fn loadRolloutPosition theRlt theINIFile = ( if (doesFileExist theINIFile) and (hasINISetting theINIFile theRlt.name "pos_x") and (hasINISetting theINIFile theRlt.name "pos_y") then ( local thePos = point2 0 0 thePos.x = (getINISetting theINIFile theRlt.name "pos_x") as float thePos.y = (getINISetting theINIFile theRlt.name "pos_y") as float setDialogPos theRlt thePos ) else ( -- ini file doesn't exist, create it saveRolloutPosition theRlt theINIFile ) ) fn saveRolloutPosition theRlt theINIFile = ( local thePos = getDialogPos theRlt try ( setINISetting theINIFile theRlt.name "pos_x" (thePos.x as string) setINISetting theINIFile theRlt.name "pos_y" (thePos.y as string) ) catch ( messageBox ("Unable to write correctly to the file "+theINIFile+".") beep:false ) ) fn isOnMatteLayer matteLayerArr theobj = ( if (idx = findItem matteLayerArr theobj.layer.name) == 0 then true else false ) fn MPMsetupMattePass theLayerNames oWrappers:false oXrefs:true optionsArr:#(AlphaContribution,Shadows,AffectAlpha,Brightness,ReflectionAmt,RefractionAmt,GIAmt,noGI) = ( if (theLayerNames != "") and (theLayerNames != undefined) then ( local layerNamesArr = filterString theLayerNames ";" local matteObjectsArr = #() local nonMatteObjectsArr = #() g_layerNameArr = layerNamesArr g_optionsArr = optionsArr -- Making sure options array is valid if ((optionsArr[1] >= -1.0) and (optionsArr[1] <= 1.0)) and ((optionsArr[2] == true) or (optionsArr[2] == false)) and ((optionsArr[3] == true) or (optionsArr[3] == false)) and ((optionsArr[4] >= 0) and (optionsArr[4] <= 1.0)) and ((optionsArr[5] >= 0) and (optionsArr[5] <= 1.0)) and ((optionsArr[6] >= 0) and (optionsArr[6] <= 1.0)) and ((optionsArr[7] >= 0) and (optionsArr[7] <= 1.0)) and ((optionsArr[8] == true) or (optionsArr[8] == false)) then ( for o in objects do ( for l in layerNamesArr where (l != "") and (l != undefined) do ( if (o.layer.name == l) then append nonMatteObjectsArr o else append matteObjectsArr o ) ) /* done separating */ resetMatteObjects nonMatteObjectsArr resetMatteXrefObjects() for o in matteObjectsArr do ( setUserProp o "VRay_Matte_Enable" on setUserProp o "VRay_Matte_Alpha" optionsArr[1] setUserProp o "VRay_Matte_Shadows" optionsArr[2] setUserProp o "VRay_Matte_ShadowAlpha" optionsArr[3] setUserProp o "VRay_Matte_ShadowBrightness" optionsArr[4] setUserProp o "VRay_Matte_ReflectionAmount" optionsArr[5] setUserProp o "VRay_Matte_RefractionAmount" optionsArr[6] setUserProp o "VRay_Matte_GIAmount" optionsArr[7] setUserProp o "VRay_Matte_GI_OtherMattes" optionsArr[8] ) /* done setting up matte objects */ if oXrefs then ( print "...Overriding XRefs" MPMSetupMatteXrefs layerNamesArr optionsArr -- Setup Callback Mechanism callbacks.removeScripts id:#MPMOverrideXrefs --callbacks.addScript #preRenderFrame "format \"g_layerNameArr: %\n\" g_layerNameArr" id:#MPMOverrideXrefs --callbacks.addScript #preRenderFrame "format \"g_optionsArr: %\n\" g_optionsArr" id:#MPMOverrideXrefs -- Ridiculous workaround local to_exec = "fileIn \"" + MPMFunctionsFile + "\"" ---------------------- callbacks.addScript #preRender to_exec id:#MPMOverrideXrefs persistent:true callbacks.addScript #preRender "MPMSetupMatteXrefs g_layerNameArr g_optionsArr" id:#MPMOverrideXrefs persistent:true ) else print "...Not Overriding XRefs" true ) else ( print "!!! Options Array not valid, needs 8 arguments with values between those listed in the script" false ) ) else ( print "!!! Please specify the Layer Names to generate a matte pass." false ) ) fn MPMSetupMatteXrefs layNameArr theOptionsArr = ( if (local xrefCount = xrefs.getXRefFileCount()) != 0 then ( /*try ( deleteFile "Q:/Colin/MPManager/XrefWrite.txt" ) catch () fs = openFile "Q:/Colin/MPManager/XrefWrite.txt" mode:"w+" format "layNameArr: %\n" layNameArr to:fs format "theOptionsArr: %\n" (theOptionsArr as string) to:fs format "xrefCount: %\n" (xrefCount as string) to:fs*/ for i = 1 to xrefCount do ( -- get each xref scene in file local xrscene = xrefs.getXRefFile i -- xrscene is set to the xref scene file /*format "xrscene: %\n" xrscene to:fs format "xrscene.tree.children: %\n" (xrscene.tree.children as string) to:fs*/ --format "layNameArr: %\n" layNameArr --format "theOptionsArr: %\n" theOptionsArr for x in (xrscene.tree.children) do ( -- for each object in the xref if (isOnMatteLayer layNameArr x) then ( try ( setUserProp x "VRay_Matte_Enable" on setUserProp x "VRay_Matte_Alpha" theOptionsArr[1] setUserProp x "VRay_Matte_Shadows" theOptionsArr[2] setUserProp x "VRay_Matte_ShadowAlpha" theOptionsArr[3] setUserProp x "VRay_Matte_ShadowBrightness" theOptionsArr[4] setUserProp x "VRay_Matte_ReflectionAmount" theOptionsArr[5] setUserProp x "VRay_Matte_RefractionAmount" theOptionsArr[6] setUserProp x "VRay_Matte_GIAmount" theOptionsArr[7] setUserProp x "VRay_Matte_GI_OtherMattes" theOptionsArr[8] --format "+ Object % as a matte object\n" x.name to:fs ) catch () ) else ( -- else object is non-matte try ( resetMatteObjects x --format "- Object % as non-matte object\n" x.name to:fs ) catch () ) ) -- end each object ) -- end all xrefs done -- close fs ) -- end xref file count ) fn resetMatteObjects objArr = ( for o in objArr do ( setUserProp o "VRay_Matte_Enable" off setUserProp o "VRay_Matte_Alpha" 1.0 setUserProp o "VRay_Matte_Shadows" off setUserProp o "VRay_Matte_ShadowAlpha" off setUserProp o "VRay_Matte_ShadowBrightness" 1.0 setUserProp o "VRay_Matte_ReflectionAmount" 1.0 setUserProp o "VRay_Matte_RefractionAmount" 1.0 setUserProp o "VRay_Matte_GIAmount" 1.0 setUserProp o "VRay_Matte_GI_OtherMattes" true ) ) fn resetMatteXrefObjects = ( if (local xrefCount = xrefs.getXRefFileCount()) != 0 then ( for i = 1 to xrefCount do ( -- get each xref scene in file local xrscene = xrefs.getXRefFile i -- xrscene is set to the xref scene file for x in (xrscene.tree.children) do ( -- for each object in the xref setUserProp x "VRay_Matte_Enable" off setUserProp x "VRay_Matte_Alpha" 1.0 setUserProp x "VRay_Matte_Shadows" off setUserProp x "VRay_Matte_ShadowAlpha" off setUserProp x "VRay_Matte_ShadowBrightness" 1.0 setUserProp x "VRay_Matte_ReflectionAmount" 1.0 setUserProp x "VRay_Matte_RefractionAmount" 1.0 setUserProp x "VRay_Matte_GIAmount" 1.0 setUserProp x "VRay_Matte_GI_OtherMattes" true ) ) ) callbacks.removeScripts id:#MPMOverrideXrefs ) ( MPMsetupMattePass g_layerNameArr oWrappers:overrideWrappers oXrefs:overrideXRefs optionsArr:g_optionsArr )
Comment