// =========================================================================== // 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: // AEswatchDisplay // // Description: // Creates swatches for all rendering nodes // // Input Value: // nodeName // // Output Value: // None // // // Procedure Name: // defineLabel // // global proc string defineLabel ( string $nodeName ) { // check on the classification of the node // to give the swatch image the correct // label string $type = `nodeType $nodeName`; string $classification[] = `getClassification $type`; string $allClass[]; tokenize ( $classification[0], "/", $allClass ); string $firstClass = $allClass[0]; string $label; switch ($firstClass) { case "shader": $label = (uiRes("m_AEswatchDisplay.kMaterialSample")); break; case "texture": $label = (uiRes("m_AEswatchDisplay.kTextureSample")); break; case "light": $label = (uiRes("m_AEswatchDisplay.kIntensitySample")); break; case "utility": $label = (uiRes("m_AEswatchDisplay.kUtilitySample")); break; case "camera": $label = (uiRes("m_AEswatchDisplay.kCameraSample")); break; case "imageplane": $label = (uiRes("m_AEswatchDisplay.kImagePlaneSample")); break; case "postprocess": $label = (uiRes("m_AEswatchDisplay.kPostProcessSample")); break; case "shadingEngine": $label = (uiRes("m_AEswatchDisplay.kShadingGroupSample")); break; default: $label = (uiRes("m_AEswatchDisplay.kSample")); break; } return $label; } // // Procedure Name: // AEswatchDisplayNew // // global proc AEswatchDisplayNew ( string $nodeName, string $msg ) { global int $gTextColumnWidthIndex; string $nodeType = `objectType $nodeName`; string $swatchDisplayForm = "swatchDisplayForm_" + $nodeType; formLayout $swatchDisplayForm; text swatchLabel; // Please note that -rs (renderSize) flag needs to be specified // in order to let swatch preview dpi scaling friendly. // However AEspotLightPreviewPortNew doesn't require it. swatchDisplayPort -rs 64 -wh 64 64 swatchDisplay; setParent ..; formLayout -e -af swatchLabel top 0 -af swatchLabel bottom 0 -an swatchLabel left -aof swatchLabel right (-$gTextColumnWidthIndex) -ac swatchDisplay left 5 swatchLabel -af swatchDisplay top 0 -af swatchDisplay bottom 0 -an swatchDisplay right $swatchDisplayForm; AEswatchDisplayReplace( $nodeName, $msg ); } // // Procedure Name: // AEswatchDisplayReplace // // global proc AEswatchDisplayReplace ( string $nodeName, string $msg ) { string $node[]; tokenize($msg, ".", $node); // Please make sure that the render priority specified by -rp // has the same value with the predefined priority for AE. // For details, please refer to the documentation of swatchDisplayPort command. swatchDisplayPort -edit -sn $node[0] -ann (uiRes("m_AEswatchDisplay.kRefreshSwatch")) -pc ("updateFileNodeSwatch(\"" + $node[0] + "\")") -rp 3 swatchDisplay; string $label = `defineLabel $node[0]`; text -e -label $label swatchLabel; } // // Procedure Name: // AEswatchDisplay // // global proc AEswatchDisplay ( string $nodeName ) { editorTemplate -callCustom ("AEswatchDisplayNew " + $nodeName ) ("AEswatchDisplayReplace " + $nodeName ) "message"; }