// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // Procedure Name: // AErenderLayerNoScroll // // Description Name; // Creates the attribute editor controls for the renderLayer Node // // Input Value: // nodeName // // Output Value: // None // global string $AErenderLayerOverrideAttrs[] = { "castsShadows", "receiveShadows", "motionBlur", "primaryVisibility", "smoothShading", "visibleInRefractions", "visibleInReflections", "doubleSided", "opposite", "depthJitter", "ignoreSelfShadowing" }; global string $AErenderLayerOverrideLabels[]; // // Global Procedure: // AErenderLayerPreset // // Description: // Procedure to klobber the attrPreset menu with a customized menu // for applying built-in presets or managing user presets with the // "nodePreset" command. // // Note: // See also AEshowPresetMenu() for how the menu is configured. // global proc AErenderLayerPreset( string $messagePlug ) { string $nodeName = plugNode($messagePlug); string $headerParent = `setParent AEnodeNameHeaderLayout`; string $presetMenu = $headerParent+"|AEpresetButton|menu"; // Update the preset button to indicate whether a users preset have // been created or not. The width is specified so the control will // maintain its with as the label changes size. // string $presets[] = `nodePreset -list $nodeName`; if( size($presets) > 0 ){ button -e -label (uiRes("m_AErenderLayerNoScroll.kPresets")) -w 70 -h 20 AEpresetButton; } else { button -e -label (uiRes("m_AErenderLayerNoScroll.kPresets2")) -w 70 -h 20 AEpresetButton; } popupMenu -e -postMenuCommand ("commitAENotes($gAECurrentTab);"+ "renderLayerPresetMenu \""+$presetMenu+"\" \""+$nodeName+"\"") $presetMenu; } // // Local Procedure: // hasIntOverride // // Description: // Return true if the script has a named expression. // proc int hasIntOverride( string $overrideScript, string $name ) { return match($name+"=[0-9]+", $overrideScript) != ""; } // // Local Procedure: // intOverrideValue // // Description: // Return the value assigned to the named expression. If the // expression does not yet exist, the default is returned. // proc int intOverrideValue( string $overrideScript, string $name, int $default ) { int $value = $default; string $override = match($name+"=[0-9]+", $overrideScript); if ($override != "") { $value = substitute($name+"=", $override, ""); } return $value; } // // Local Procedure: // addIntToScript // // Description: // Add the expression "name=value" to the specified script. The // expression will be replaced if one already exists. // proc string addIntToScript( string $overrideScript, string $name, int $value ) { // Does the override already exist ? if (!hasIntOverride($overrideScript, $name)) { // No, append a new override if ($overrideScript != "") { $overrideScript += " "; } $overrideScript += $name + "=" + $value; } else { // Yes, replace the existing value $overrideScript = substitute($name+"=[0-9]+", $overrideScript, $name+"="+$value); } return $overrideScript; } // // Local Procedure: // removeIntFromScript // // Description: // Remove the named expression from the specified script. // proc string removeIntFromScript( string $overrideScript, string $name ) { // Is this the first override ? if (match("^"+$name+"=[0-9]+", $overrideScript) != "") { // Yes, remove all trailing spaces too $overrideScript = substitute($name+"=[0-9]+[ ]*", $overrideScript, ""); } else { // No, remove all leading spaces too $overrideScript = substitute("[ ]*"+$name+"=[0-9]+", $overrideScript, ""); } return $overrideScript; } // // Global Procedure: // AErenderLayerOverrideChanged // // Description: // The user has modified an override control in the AE, update the // layer's attributeOverrideScript to reflect the active overrides and // values. // global proc AErenderLayerOverrideChanged( string $control, string $attributeOverrideScriptPlug ) { string $script = `getAttr $attributeOverrideScriptPlug`; global string $AErenderLayerOverrideAttrs[]; if (stringArrayContains($control, $AErenderLayerOverrideAttrs)) { // Handle radio button groups No override / force off / force on. // int $value = `radioButtonGrp -query -select ("Radio"+$control)`; switch ($value) { case 1: // No override $script = removeIntFromScript($script, $control); break; case 2: // Force off $script = addIntToScript($script, $control, 0); break; case 3: // Force on $script = addIntToScript($script, $control, 1); break; } } else if ($control == "geometryAntiAliasingOverride" || $control == "geometryAntiAliasing") { // Handle check box and int slider. The check box toggles the // override, the slider holds the value. // int $isEnabled = `checkBoxGrp -q -value1 geometryAntiAliasingOverride`; if ($isEnabled) { intSliderGrp -e -enable true geometryAntiAliasing; int $value = `intSliderGrp -q -value geometryAntiAliasing`; $script = addIntToScript($script, "geometryAntialiasingOverride", 1); $script = addIntToScript($script, "antialiasingLevel", $value); } else { intSliderGrp -e -enable false geometryAntiAliasing; $script = removeIntFromScript($script, "geometryAntialiasingOverride"); $script = removeIntFromScript($script, "antialiasingLevel"); } } else if ($control == "shadingSamplesOverride" || $control == "shadingSamples" || $control == "maxShadingSamples") { // Handle check box and two int sliders. The check box toggles the // override, the sliders hold values. // int $isEnabled = `checkBoxGrp -q -value1 shadingSamplesOverride`; if ($isEnabled) { intSliderGrp -e -enable true shadingSamples; intSliderGrp -e -enable true maxShadingSamples; int $value1 = `intSliderGrp -q -value shadingSamples`; int $value2 = `intSliderGrp -q -value maxShadingSamples`; $script = addIntToScript($script, "shadingSamplesOverride", 1); $script = addIntToScript($script, "shadingSamples", $value1); $script = addIntToScript($script, "maxShadingSamples", $value2); } else { intSliderGrp -e -enable false shadingSamples; intSliderGrp -e -enable false maxShadingSamples; $script = removeIntFromScript($script, "shadingSamplesOverride"); $script = removeIntFromScript($script, "shadingSamples"); $script = removeIntFromScript($script, "maxShadingSamples"); } } else if ($control == "visibilitySamplesOverride" || $control == "maxVisibilitySamples") { // Handle check box and int slider. The check box toggles the // override, the slider holds the value. // int $isEnabled = `checkBoxGrp -q -value1 visibilitySamplesOverride`; if ($isEnabled) { intSliderGrp -e -enable true maxVisibilitySamples; int $value = `intSliderGrp -q -value maxVisibilitySamples`; $script = addIntToScript($script, "maxVisibilitySamplesOverride", 1); $script = addIntToScript($script, "maxVisibilitySamples", $value); } else { intSliderGrp -e -enable false maxVisibilitySamples; $script = removeIntFromScript($script, "maxVisibilitySamplesOverride"); $script = removeIntFromScript($script, "maxVisibilitySamples"); } } else if ($control == "volumeSamplesOverride" || $control == "volumeSamples") { // Handle check box and int slider. The check box toggles the // override, the slider holds the value. // int $isEnabled = `checkBoxGrp -q -value1 volumeSamplesOverride`; if ($isEnabled) { intSliderGrp -e -enable true volumeSamples; int $value = `intSliderGrp -q -value volumeSamples`; $script = addIntToScript($script, "volumeSamplesOverride", 1); $script = addIntToScript($script, "volumeSamples", $value); } else { intSliderGrp -e -enable false volumeSamples; $script = removeIntFromScript($script, "volumeSamplesOverride"); $script = removeIntFromScript($script, "volumeSamples"); } } evalEcho ( "setAttr "+ $attributeOverrideScriptPlug+ " -type \"string\" \""+ $script+ "\""); } // // Global Procedure: // AErenderLayerNewGroup // // Description: // The user has clicked on the "Map" button for the shading group // override, create a new shading group and connect it to the // render layer node. // global proc AErenderLayerNewGroup( string $shadingGroupOverridePlug ) { createRenderNode -shadersSG ("connectAttr %nodeSG.message "+$shadingGroupOverridePlug) ""; } // // Global Procedure: // AErenderLayerReplaceGroup // // Description: // The user has typed the name of a shading group into the text field, // connect the specified shading group to the render layer node. // global proc AErenderLayerReplaceGroup( string $shadingGroupOverridePlug, string $dashSource, string $node ) { connectAttr -f ($node+".message") $shadingGroupOverridePlug; } // // Global Procedure: // AErenderLayerOverrideNew // // Description: // Procedure to build the custom controls used to override // shading group assignment and render stats for all members // of the layer. // global proc AErenderLayerOverrideNew( string $shadingGroupOverridePlug, string $attributeOverrideScriptPlug ) { setUITemplate -pst attributeEditorTemplate; attrNavigationControlGrp -label (uiRes("m_AErenderLayerNoScroll.kShadingGroup")) shadingGroupOverride; separator -style "none" -height 10; string $labels[]; $labels[0] = (uiRes("m_AErenderLayerNoScroll.kCastShadows")); $labels[1] = (uiRes("m_AErenderLayerNoScroll.kReceiveShadows")); $labels[2] = (uiRes("m_AErenderLayerNoScroll.kMotionBlur")); $labels[3] = (uiRes("m_AErenderLayerNoScroll.kPrimVisibility")); $labels[4] = (uiRes("m_AErenderLayerNoScroll.kSmoothShading")); $labels[5] = (uiRes("m_AErenderLayerNoScroll.kVisInRefra")); $labels[6] = (uiRes("m_AErenderLayerNoScroll.kVisInRefl")); $labels[7] = (uiRes("m_AErenderLayerNoScroll.kDoubleSided")); $labels[8] = (uiRes("m_AErenderLayerNoScroll.kOpposite")); $labels[9] = (uiRes("m_AErenderLayerNoScroll.kDepthJitter")); $labels[10]= (uiRes("m_AErenderLayerNoScroll.kIgnSelfShadow")); global string $AErenderLayerOverrideAttrs[]; rowColumnLayout -numberOfColumns 4 -columnWidth 1 145 -columnWidth 2 85 -columnWidth 3 85 -columnWidth 4 85; text -label ""; text -label (uiRes("m_AErenderLayerNoScroll.kUseScene")); text -label (uiRes("m_AErenderLayerNoScroll.kForceOn")); text -label (uiRes("m_AErenderLayerNoScroll.kForceOff")); setParent ..; for ($i=0 ; $i