// =========================================================================== // 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: 2005 // // Description: // Connect an existing cacheFile node to an existing blend node. // If the no objects are specified, connect the first channel // of the cache file node to the first object controlled by the blend. // If an array of objects and channels is specified, connect to // the blend such that there is a one-to-one correspondence between // the specified objects and the specified cache channel. // global proc string doCacheConnect( string $cacheBlend, string $cacheFileNode, string $objects[], string $channels[] ) { if (size($channels) == 0) { cacheFileCombine -keepWeights -e -connectCache $cacheFileNode $cacheBlend; } else { int $chanCount = size($channels); int $ii, $objCount = size($objects); // if there is one object, assume it owns all the channels // otherwise assume 1 channel per object, and the calling proc is responsible for checking // yes, we know the many obj/many channel case has never worked properly if ($objCount > 1) { for ($ii = 0; $ii < $objCount; $ii++) { int $geomIndex = `cacheFileCombine -object $objects[$ii] -q -oi $cacheBlend`; string $combineCmd = "cacheFileCombine -keepWeights "; $combineCmd += (" -cnm \"" + $channels[$ii] + "\"" ); $combineCmd += (" -oi " + $geomIndex ); $combineCmd += (" -e -connectCache "+$cacheFileNode); $combineCmd += (" "+$cacheBlend); eval $combineCmd; } } else { int $geomIndex = `cacheFileCombine -object $objects[0] -q -oi $cacheBlend`; string $combineCmd = "cacheFileCombine -keepWeights "; for ($ii = 0; $ii < $chanCount; $ii++) { $combineCmd += (" -cnm \"" + $channels[$ii] + "\"" ); } // $combineCmd += (" -oi " + $geomIndex ); $combineCmd += (" -e -connectCache "+$cacheFileNode); $combineCmd += (" "+$cacheBlend); eval $combineCmd; } } return $cacheFileNode; }