// =========================================================================== // 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. // =========================================================================== // // hikKeyingModeOperation.mel // // Description: // Utility methods Related to the keying. // These methods could trigger UI updates in any part of the // unified character context. // /////////////////////////////////////////////////////////////////////// // Local methodes... /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Global methodes... /////////////////////////////////////////////////////////////////////// global proc hikCreateKeyingGroups(string $pCharacter, string $keyingGroups[]) { int $kgCount = size($keyingGroups); // Create a full-body keying group $keyingGroups[$kgCount] = `keyingGroup -empty -name ($pCharacter + "_FullBodyKG") -cat "FullBody" -minimizeRotation 1`; setAttr ($keyingGroups[$kgCount]+".isHistoricallyInteresting") 0; $kgCount++; // Create body part keying groups. // Make these keying groups sub-groups of the full-body keying group // so that they are automatically keyed when the full-body keying // group is keyed. // int $bodyPartCount = `hikBodyPart -count`; for ($i = 0; $i < $bodyPartCount; $i++) { string $bp = `hikBodyPart -getName $i`; $keyingGroups[$kgCount] = `keyingGroup -empty -name ($pCharacter + "_" + $bp + "BPKG") -cat "BodyPart" -minimizeRotation 1`; setAttr ($keyingGroups[$kgCount]+".isHistoricallyInteresting") 0; keyingGroup -e -add $keyingGroups[0] $keyingGroups[$kgCount]; $kgCount++; } } global proc hikAddToKeyingGroups(string $node, int $isIkEffector, string $keyingGroups[]) // // NOTE: FK and IK nodes passed to this method should already be linked to an existing // rig. // { // If the user doesn't want to use keying groups, don't do anything if (size($keyingGroups) == 0) return; int $kg = 0; if ($isIkEffector) { int $ikId = hikGetEffectorID($node); $kg = `hikBodyPart -forEffector $ikId` + 1; // +1 because first kg is the fullbody keyingGroup -e -add $keyingGroups[$kg] ($node + ".translate") ($node + ".rotate"); } else { string $ctrlRig[] = `listConnections -s 0 -d 1 ($node + ".ControlSet")`; string $ctrlRigAndAttr[] = `listConnections -s 0 -d 1 -p 1 ($node + ".ControlSet")`; // Bail if no control rig exists... // if ( size($ctrlRig) == 0 || size($ctrlRigAndAttr) == 0 ) return; // Extract the fk node id // string $hikFKName = stringRemovePrefix($ctrlRigAndAttr[0], ($ctrlRig[0] + ".")); int $fkId = hikGetNodeIdFromName($hikFKName); if( $fkId == 0 ) { // Skip Reference, this node should not be member of any KG return; } $kg = `hikBodyPart -forNode $fkId` + 1; // +1 because first kg is the fullbody keyingGroup -e -add $keyingGroups[$kg] ($node + ".rotate"); if ($fkId == 1) { // If hips, add translation... // keyingGroup -e -add $keyingGroups[$kg] ($node + ".translate"); } } // Make this object an activator for the full body // and body part keying groups // keyingGroup -e -act $keyingGroups[0] $node; keyingGroup -e -act $keyingGroups[$kg] $node; } global proc hikSetModalKey(string $keyType) // // Set a key for the given type regardless of the actual HIK Mode // Valid types are: "FullBody", "BodyPart" and "Selection" // { /* */ string $filterName = $keyType; if ($keyType == "Selection") { $filterName = "NoKeyingGroups"; } string $existingFilter = `keyingGroup -q -setActiveFilter`; if ($existingFilter != $filterName) { keyingGroup -setActiveFilter $filterName; } if (size(`ls -sl`) == 0) { warning((uiRes("m_hikKeyingModeOperation.kWarningSetModalKey")) ); } else { setKeyframe; } if ($existingFilter != $filterName) { // restore the previous filter // keyingGroup -setActiveFilter $existingFilter; } } global proc hikSetKeyingMode() { string $filterName[] = { "FullBody", "BodyPart", "NoKeyingGroups" }; // Get the keying mode off the FBIK keying mode option var if( !`optionVar -exists keyFullBody` ) { // BodyPart mode is the default optionVar -intValue keyFullBody 2; } int $mode = `optionVar -q keyFullBody`; if( $mode > 0 && $mode < 4) { keyingGroup -setActiveFilter $filterName[$mode-1]; } fbikDoSelectionChanged(); if (`headsUpDisplay -ex HUDHikKeyingMode`) { headsUpDisplay -refresh HUDHikKeyingMode; } if (`headsUpDisplay -ex HUDFbikKeyingMode`) { headsUpDisplay -refresh HUDFbikKeyingMode; } }