Wrote half of it two days ago, I'll finish it up tonight or tomorrow. It is a whole MattePass manager, it isn't just for xrefs, but it does support xrefs as well. I think you'll find it comprehensive.
-Colin
-Colin
-- Rollouts global rlt_MPManager -- Functions global loadRolloutPosition global saveRolloutPosition global loadLayerListBox global MPMsetupMattePass global resetMatteObjects -- 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 overrideWrappers = false global overrideXRefs = true 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 ) ) /* MPMsetupMattePass */ /* theLayerNames - String variable with the layer names separated by semicolons, to create a matte pass for the layer "People" and "Trees" pass "People;Trees" to this variable */ /* oVRayMtlWrapper - [True/False] turning this on will override all VRayMtlWrapper to matte settings if they are assigned to a matte layer options - Array variable of options you can pass to set the matte options in this order [min/max]: AlphaContribution: [-1.0 / 1.0] Shadows: [true/false] AffectAlpha: [true/false] Brightness: [0/1.0] ReflectionAmt: [0/1.0] RefractionAmt: [0/1.0] GIAmt: [0/1.0] noGI: [true/false] To set a matte pass for the layer "People" using an Alpha contribution of -1.0, Direct light Shadows to true pass this to MPMsetupMattePass MPMsetupMattePass "People" options:#(-1,true,false,1,1,1,1,true) */ fn MPMsetupMattePass theLayerNames oVRayMtlWrapper:false options:#(AlphaContribution,Shadows,AffectAlpha,Brightness,ReflectionAmt,RefractionAmt,GIAmt,noGI) = ( if (theLayerNames != "") and (theLayerNames != undefined) then ( local layerNamesArr = filterString theLayerNames ";" local matteObjectsArr = #() local nonMatteObjectsArr = #() /* Separates the objects into two arrays for the matte objects and non matte objects */ 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 */ /* Set matte objects */ for o in matteObjectsArr do ( setUserProp o "VRay_Matte_Enable" on setUserProp o "VRay_Matte_Alpha" options[1] setUserProp o "VRay_Matte_Shadows" options[2] setUserProp o "VRay_Matte_ShadowAlpha" options[3] setUserProp o "VRay_Matte_ShadowBrightness" options[4] setUserProp o "VRay_Matte_ReflectionAmount" options[5] setUserProp o "VRay_Matte_RefractionAmount" options[6] setUserProp o "VRay_Matte_GIAmount" options[7] setUserProp o "VRay_Matte_GI_OtherMattes" options[8] ) /* done setting up matte objects */ /* Set non matte objects */ resetMatteObjects nonMatteObjectsArr /* Set VRayMtlWrappers to matte objects if true */ if oVRayMtlWrapper then ( /* local mtlWrapper = getClassInstances VRayMtlWrapper -- Array of MtlWrapper materials on the objects for i = 1 to mtlWrapper.count do ( local geoMtls = for d in (refs.dependents mtlWrapper[i]) where (isKindOf d GeometryClass) or (isKindOf d Shape) collect d for o in matteObjectsArr do ( for j in geoMtls do ( if (idx = findItem matteObjectsArr j) != 0 then ( ) ) ) ) */ ) ) else print "Please specify the Layer Names to generate a matte pass." ) /* Resets all objects to the default VRayProperties */ 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 ) ) /************************************************************************************************************/ 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:false 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 + ";") MPMsetupMattePass selectedLayerNameAsString oVRayMtlWrapper:overrideWrappers options:#(AlphaContribution,Shadows,AffectAlpha,Brightness,ReflectionAmt,RefractionAmt,GIAmt,noGI) ) on btn_Reset pressed do ( resetMatteObjects objects ) 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 print "MPManager Loaded..." loadLayerListBox() ) on rlt_MPManager close do ( saveRolloutPosition rlt_MPManager MPManagerINIFile ) ) createDialog rlt_MPManager 373 335
Comment