// =========================================================================== // 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. // =========================================================================== global proc AEStingrayPBSOpen() { eval("shaderfx -start -sfxnode $StingrayPBSActiveShaderName[0]"); } global proc AEStingrayPBSReplaceUI() { eval("shaderfx -replaceUI -sfxnode $StingrayPBSActiveShaderName[0]"); } global proc AEStingrayPBSPropUI() { eval("shaderfx -nodeUI -sfxnode $StingrayPBSActiveShaderName[0]"); } /// \brief This file defines the attribute editor for our Shaderfx Shader. /// \param $nodeName - the name of the node instance to display. /// global proc AEStingrayPBSTemplate( string $nodeName ) { // the following controls will be in a scrollable layout editorTemplate -beginScrollLayout; editorTemplate -beginLayout "Stingray" -collapse 0; editorTemplate -label "Engine Resource" -addControl "engineresource"; editorTemplate -endLayout; // add shaderfx selected node properties and shader attributes layout: editorTemplate -beginLayout "ShaderFX" -collapse 0; editorTemplate -callCustom "StingrayPBSOpenNew" "StingrayPBSOpenReplace" ""; editorTemplate -endLayout; // include/call base class/node attributes AEdependNodeTemplate $nodeName; // add any extra attributes that have been added editorTemplate -addExtraControls; // Find the "Extra Attributes" frameLayout and hide it. editorTemplate -callCustom AEStingrayPBS_suppressExtraNew AEStingrayPBS_suppressExtraReplace; editorTemplate -endScrollLayout; } global proc StingrayPBSOpenNew( string $attrName ) { // register global for active node name. // we need this because Maya only creates the template ones and does not run // this function again for other shaderfx nodes created. // during StingrayPBSOpenReplace we get the opportunity to update what is the active (selected) shaderfx node global string $StingrayPBSActiveShaderName[]; // Since maya passes us an attribute ( nodename.attributeName) we strip the attributes since we only want the node name tokenize($attrName, ".", $StingrayPBSActiveShaderName); // Normally here we would create a UI control and connect to an attribute // But all we need is a button to launch shaderfx button -label "Open ShaderFX" -width 100 -command ("AEStingrayPBSOpen()"); frameLayout -label "Settings" -collapse 0 StingrayPBSSettings; setParent ..; frameLayout -label "Attributes" -collapse 0 StingrayPBSProperties; setParent ..; // update node property UI or attribute UI: AEStingrayPBSPropUI(); } global proc StingrayPBSOpenReplace( string $attrName ) { // normally here we would make a connection between the new attribute and UI control // But for us, we only have a button the user needs to press to open ShaderFX // So we just store the new object // see StingrayPBSOpenNew() for details on below: global string $StingrayPBSActiveShaderName[]; tokenize($attrName, ".", $StingrayPBSActiveShaderName); // open the node UI if one is already open for this new node, // otherwise it gets confusing who we are editing: AEStingrayPBSReplaceUI(); // update node property UI or attribute UI: AEStingrayPBSPropUI(); } global proc AEStingrayPBS_suppressExtraNew() { string $sExtraParent = `setParent ..`; string $sa[] = `layout -q -ca $sExtraParent`; string $sExtra; // label string may be localized, look up the localized value // Beware, the resource format or id could change some day. string $extraLabel = `uiRes("s_TPStemplateStrings.rExtraAttributes")`; for ( $sExtra in $sa ) { if ( `objectTypeUI -isType frameLayout $sExtra` && `frameLayout -q -l $sExtra` == $extraLabel ) { frameLayout -e -manage 0 -visible 0 $sExtra; break; } } } global proc AEStingrayPBS_suppressExtraReplace() {}