// =========================================================================== // 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. // =========================================================================== // // hikLiveConnectionOperations.mel // // Description: // Contains LiveConnection methods that affect the unified character context. // These methods could trigger UI updates in any part of the // unified character context. // /////////////////////////////////////////////////////////////////////// // Local procedures /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // Global LiveConnection operations. /////////////////////////////////////////////////////////////////////// global proc string hikGetLiveStateClient( string $pCharacter, int $pCreate ) { // If the specified character is connected to a character state client node // return it. if( size($pCharacter) < 1 ) return ""; string $outputCharacterDefn = ($pCharacter + ".OutputCharacterDefinition"); string $clientConnections[] = `listConnections -type "HIKCharacterStateClient" -s 0 -d 1 $outputCharacterDefn`; if ( size($clientConnections) > 0 ) { return $clientConnections[0]; } else if( $pCreate ) { // Client node does not exist, create one string $newSrc = `createNode HIKCharacterStateClient`; connectAttr -f $outputCharacterDefn ($newSrc+".InputCharacterDefinition"); setAttr ($newSrc +".frameRate") 60; setAttr -type "string" ($newSrc +".deviceName") ("Constraint::"+$pCharacter); $refNode = hikGetSkNode( $pCharacter, 0 ); if( $refNode != "" ) { connectAttr ($refNode+".worldMatrix[0]") ($newSrc+".referenceGX"); // Provide CharacterStateClient node with scaling hints in case used streaming protocol // does not supports scalign transport $hipsNode = hikGetSkNode( $pCharacter, 1 ); float $hipsScale[] = {1.0, 1.0, 1.0 }; if( $hipsNode != "" ) { $hipsScale = `getAttr ($hipsNode+".scale")`; } setAttr ($newSrc+".hipsScale") $hipsScale[0] $hipsScale[1] $hipsScale[2]; } return $newSrc; } else { return ""; } } global proc hikSetLiveState( string $pCharacter, int $pState ) { string $srcNode = hikGetLiveStateClient( $pCharacter, $pState ); if( $srcNode != "" ) { string $livePlug = ( $srcNode + ".live" ); if( $pState ) { string $outPlug = ( $srcNode + ".OutputCharacterState" ); setAttr $livePlug 0; getAttr -silent $outPlug; setAttr $livePlug 1; } else { setAttr $livePlug 0; } } }