// =========================================================================== // 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. // =========================================================================== // // // Creation Date: July 16, 1999 // // Description: // This script is the blend clip option box // // Input Arguments: // None. // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { // Blend weight type // // 1: linear blend // 2: ease in/out // if ($forceFactorySettings || !`optionVar -exists blendClipWeightCurve`) { optionVar -intValue blendClipWeightCurve 1; } // Rotation interpolation // // 0: Quaternion // 1: Euler // if ($forceFactorySettings || !`optionVar -exists blendClipRotInterp`) { optionVar -intValue blendClipRotInterp 0; } if (`optionVar -exists blendClipRotType`) { optionVar -remove blendClipRotType; } } // // Procedure Name: // blendClipSetup // // Description: // Update the state of the option box UI to reflect the option values. // // Input Arguments: // parent - Top level parent layout of the option box UI. // Required so that UI object names can be // successfully resolved. // // forceFactorySettings - Whether the option values should be set to // default values. // // Return Value: // None. // global proc blendClipSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings. setOptionVars( $forceFactorySettings ); setParent $parent; // Set the correct menu int $weightCurve = `optionVar -query blendClipWeightCurve`; if ($weightCurve < 1 || $weightCurve > 4) { $weightCurve = 1; } // Set the correct rotation interpolation int $rotInterp = `optionVar -query blendClipRotInterp`; optionMenuGrp -e -sl $weightCurve blendClipWeightMenuGrp; optionMenuGrp -e -sl ($rotInterp+1) blendClipRotMenuGrp; } // // Procedure Name: // blendClipCallback // // Description: // Update the option values with the current state of the option box UI. // // Input Arguments: // parent - Top level parent layout of the option box UI. Required so // that UI object names can be successfully resolved. // // doIt - Whether the command should execute. // // clipEd - The name of the Clip Editor. // // Return Value: // None. // global proc blendClipCallback (string $parent, int $doIt, string $clipEd) { setParent $parent; int $selected = `optionMenuGrp -q -sl blendClipWeightMenuGrp`; optionVar -intValue blendClipWeightCurve $selected; int $rotInterp = `optionMenuGrp -q -sl blendClipRotMenuGrp`; optionVar -intValue blendClipRotInterp ($rotInterp-1); if ($doIt) performBlendClip false $clipEd; } proc string blendClipWidgets( string $parent ) { setParent $parent; string $tabForm = `columnLayout -adj true`; optionMenuGrp -label (uiRes("m_performBlendClip.kInitialWeightCurve")) blendClipWeightMenuGrp; menuItem (uiRes("m_performBlendClip.kLinear")); menuItem (uiRes("m_performBlendClip.kEaseIn")); menuItem (uiRes("m_performBlendClip.kEaseOut")); menuItem (uiRes("m_performBlendClip.kEaseInOut")); optionMenuGrp -label (uiRes("m_performBlendClip.kRotationInterp")) blendClipRotMenuGrp; menuItem (uiRes("m_performBlendClip.kQuaternion")); menuItem (uiRes("m_performBlendClip.kEuler")); return $tabForm; } global proc blendClipOptions (string $clipEd) { string $commandName = "blendClip"; string $applyTitle = "Blend"; // Build the option box "methods" // string $callback = ($commandName + "Callback"); string $setup = ($commandName + "Setup"); // Get the option box. // // The value returned is the name of the layout to be used as // the parent for the option box UI. // string $layout = getOptionBox(); setParent $layout; setOptionBoxCommandName($commandName); setUITemplate -pushTemplate DefaultTemplate; waitCursor -state 1; tabLayout -scr true -tv false; // To get the scroll bars string $parent = `columnLayout -adjustableColumn 1`; blendClipWidgets $parent; waitCursor -state 0; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performBlendClip.kCreateBlend")) -command ($callback + " " + $parent + " " + 1 + " \"" + $clipEd + "\"") $applyBtn; // 'Save' button. // string $saveBtn = getOptionBoxSaveBtn(); button -edit -command ($callback + " " + $parent + " " + 0 + "\"" + $clipEd + "\"; hideOptionBox") $saveBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Set the option box title. // setOptionBoxTitle (uiRes("m_performBlendClip.kBlendClipOptions")); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "BlendClip" ); // Set the current values of the option box. // eval (($setup + " " + $parent + " " + 0)); // Show the option box. // showOptionBox(); } // // Procedure Name: // assembleCmd // // Description: // Construct the command that will apply the option box values. // // Input Arguments: // The name of the clip editor used to call this option box. // // Return Value: // None. // proc string assembleCmd(string $clipEd) { string $cmd; setOptionVars(false); int $weightCurve = `optionVar -query blendClipWeightCurve`; int $rotInterp = `optionVar -query blendClipRotInterp`; $cmd = ("doBlendClip( \""+$clipEd+"\", "+$weightCurve+", "+$rotInterp+");"); return $cmd; } // // Procedure Name: // performBlendClip // // Description: // Add a blend between two clips. A blend node will be created and // a weighting curve will be added to the blend node. // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // // Return Value: // None. // global proc string performBlendClip (int $action, string $clipEd) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Retrieve the option settings // setOptionVars(false); // Get the command. // $cmd = `assembleCmd($clipEd)`; // Execute the command with the option settings. // if ($cmd != "") evalEcho($cmd); break; // Show the option box. // case 1: blendClipOptions($clipEd); break; case 2: // Get the command. // $cmd = `assembleCmd($clipEd)`; } return $cmd; }