// =========================================================================== // 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: Jan 14, 2005 // // Description: // This script is the set Full Body IK Keys option box dialogs. // // Input Arguments: // None. // // Return Value: // None. // proc setOptionVars (int $forceFactorySettings) { // Key full body // if ($forceFactorySettings || !`optionVar -exists keyFullBody`) { optionVar -intValue keyFullBody 1; } // Set IK Key - this determines what is the reach value to be keyed. if ($forceFactorySettings || !`optionVar -exists fbikKeyOption`) { //3 == simple key optionVar -intValue fbikKeyOption 3; } } proc doCycleReachKeyingOption() // Description: // Cycle through the valid values of the fbikKeyOption option var. { setOptionVars (0); if (`optionVar -query fbikKeyOption` == 1) { optionVar -intValue fbikKeyOption 2; print( (uiRes("m_performSetFullBodyIKKeys.kFullBodyFKReachKey")) ); if (`radioButtonGrp -query -exists fbikKeyOptionRB`) radioButtonGrp -edit -select 2 fbikKeyOptionRB; } else if (`optionVar -query fbikKeyOption` == 2) { optionVar -intValue fbikKeyOption 3; print( (uiRes("m_performSetFullBodyIKKeys.kFullBodySimpleReachKey")) ); if (`radioButtonGrp -query -exists fbikKeyOptionRB`) radioButtonGrp -edit -select 3 fbikKeyOptionRB; } else { optionVar -intValue fbikKeyOption 1; print( (uiRes("m_performSetFullBodyIKKeys.kFullBodyIKReachKey")) ); if (`radioButtonGrp -query -exists fbikKeyOptionRB`) radioButtonGrp -edit -select 1 fbikKeyOptionRB; } } // // Procedure Name: // setFullBodyIKKeysSetup // // 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 setFullBodyIKKeysSetup (string $parent, int $forceFactorySettings) { // Retrieve the option settings // setOptionVars( $forceFactorySettings ); if (`optionVar -query keyFullBody` == 1) { radioButtonGrp -edit -select 1 keyFullBodyRB; } else if (`optionVar -query keyFullBody` == 2) { radioButtonGrp -edit -select 2 keyFullBodyRB; } else { radioButtonGrp -edit -select 3 keyFullBodyRB; } if (`optionVar -query fbikKeyOption` == 1) { radioButtonGrp -edit -select 1 fbikKeyOptionRB; } else if (`optionVar -query fbikKeyOption` == 2) { radioButtonGrp -edit -select 2 fbikKeyOptionRB; } else { radioButtonGrp -edit -select 3 fbikKeyOptionRB; } setParent $parent; } // // Procedure Name: // setFullBodyIKKeysCallback // // 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. // // Return Value: // None. // global proc setFullBodyIKKeysCallback (string $parent, int $doIt) { setParent $parent; // Set the value of the persistent variable "keyFullBody" to // that of the option box. optionVar -intValue keyFullBody `radioButtonGrp -query -select keyFullBodyRB`; // HIK relies on this keying mode too. Need to update the global, active filter. // Ideally, we would listen for any changes to the keyFullBody optionVar, but // Maya does not have any such callbacks/scriptJobs, so we do things the ugly way. // if (`exists hikSetKeyingMode`) { hikSetKeyingMode(); } if (`radioButtonGrp -query -select fbikKeyOptionRB` == 1) { optionVar -intValue fbikKeyOption 1; } else if (`radioButtonGrp -query -select fbikKeyOptionRB` == 2) { optionVar -intValue fbikKeyOption 2; } else { optionVar -intValue fbikKeyOption 3; } if ($doIt) { performSetFullBodyIKKeys false; addToRecentCommandQueue "performSetFullBodyIKKeys false" "SetFullBodyIKKeys"; } } proc string setFullBodyIKKeysWidgets( string $parent ) { setParent $parent; string $tabForm = `columnLayout -adjustableColumn true`; radioButtonGrp -numberOfRadioButtons 3 -label (uiRes("m_performSetFullBodyIKKeys.kKeyMode")) -columnWidth 2 120 -columnWidth 3 120 -columnWidth 4 120 -label1 (uiRes("m_performSetFullBodyIKKeys.kAll")) -label2 (uiRes("m_performSetFullBodyIKKeys.kBodyPart")) -label3 (uiRes("m_performSetFullBodyIKKeys.kSelected")) keyFullBodyRB; radioButtonGrp -numberOfRadioButtons 3 -label (uiRes("m_performSetFullBodyIKKeys.kReachKeyMode")) -vertical -label1 (uiRes("m_performSetFullBodyIKKeys.kIKKey")) -label2 (uiRes("m_performSetFullBodyIKKeys.kFKKey")) -label3 (uiRes("m_performSetFullBodyIKKeys.kSimpleKey")) fbikKeyOptionRB; return $tabForm; } global proc setFullBodyIKKeysOptions () { string $commandName = "setFullBodyIKKeys"; // 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 -scrollable true -tabsVisible false; // To get the scroll bars string $parent = `columnLayout -adjustableColumn 1`; setFullBodyIKKeysWidgets $parent; waitCursor -state 0; setUITemplate -popTemplate; // 'Apply' button. // string $applyBtn = getOptionBoxApplyBtn(); button -edit -label (uiRes("m_performSetFullBodyIKKeys.kApply")) -command ($callback + " " + $parent + " " + 1) $applyBtn; // 'Key' button. // string $keyBtn = getOptionBoxSaveBtn(); button -edit -label (uiRes("m_performSetFullBodyIKKeys.kKey")) -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox") $keyBtn; // 'Reset' button. // string $resetBtn = getOptionBoxResetBtn(); button -edit -command ($setup + " " + $parent + " " + 1) $resetBtn; // Set the option box title. // setOptionBoxTitle((uiRes("m_performSetFullBodyIKKeys.kSetFBIKKeysOptions"))); // Customize the 'Help' menu item text. // setOptionBoxHelpTag( "SetFullBodyIKKeys" ); // 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: // None. // // Return Value: // None. // proc string assembleCmd() { string $cmd; setOptionVars(false); headsUpDisplay -refresh HUDHikKeyingMode; int $setFullBodyKey = `optionVar -query keyFullBody`; int $keyingMode = $setFullBodyKey; if($setFullBodyKey == 3) { //we want to key in "selected" keying mode, but the actual keying mode to //pass to doSetFullBodyIKKeysArgList is 4 in this case. $keyingMode = 4; } int $setIKKeys = `optionVar -query fbikKeyOption`; $cmd = "doSetFullBodyIKKeysArgList 3 { \"" + $keyingMode + "\", \"" + $setIKKeys + "\", \"\" };"; return $cmd; } // // Procedure Name: // performSetFullBodyIKKeys // // // Input Arguments: // 0 - Execute the command. // 1 - Show the option box dialog. // 2 - Return the command. // // Return Value: // None. // global proc string performSetFullBodyIKKeys (int $action) { string $cmd = ""; switch ($action) { // Execute the command. // case 0: // Retrieve the option settings // setOptionVars(false); // Get the command. // $cmd = `assembleCmd`; // Execute the command with the option settings. // eval($cmd); break; // Show the option box. // case 1: setFullBodyIKKeysOptions; break; case 2: // Get the command. // $cmd = `assembleCmd`; break; case 3: doCycleReachKeyingOption; break; } return $cmd; }