//****************************************************************************** // // 版权所有: 玉溪时光科技有限公司 // 联系邮箱: q.100@qq.com // 开发日期: 2023/08/08 // //****************************************************************************** global proc SGBindPoseReset(string $objs[]){ SGProgressBar -sp; SGProgressBar -max `size($objs)`; for($obj in $objs){ SGProgressBar -t ("[" + $obj + "] Bind Pose Reset..."); SGProgressBar -apr 1; string $skinCluster = `findRelatedSkinCluster $obj`; if(`objExists $skinCluster`){ string $blendShape = `SGGetBlendShape $obj`; string $copyName[] = `duplicate -n ($obj + "_CopyTarget") $obj`; blendShape $copyName[0]; delete -ch $copyName[0]; string $bone[] = `skinCluster -q -inf $skinCluster`; skinCluster -tsb $bone $copyName[0]; copySkinWeights -nm -sa closestPoint -ia closestJoint -ia oneToOne $obj $copyName[0]; skinCluster -e -ub $obj; string $targetShape[] = `pickWalk -d down $copyName[0]`; if(`objExists $blendShape`) { string $orig[] = `SGGetOrigName $obj`; catchQuiet (`connectAttr -f ($orig[0]+".outMesh") ($blendShape+".originalGeometry[0]")`); catchQuiet (`connectAttr -f ($orig[0]+".worldMesh[0]") ($blendShape+".input[0].inputGeometry")`); currentTime 0 ; connectAttr -f ($targetShape[0]+".outMesh") ($orig[0]+".inMesh"); currentTime 1 ; disconnectAttr ($targetShape[0]+".outMesh") ($orig[0]+".inMesh"); currentTime 0 ; } else{ string $orig[] = `SGGetOrigShapeName $obj`; if(size($orig) != 0){ currentTime 0 ; connectAttr -f ($targetShape[0]+".outMesh") ($orig[0]+".inMesh"); currentTime 1 ; disconnectAttr ($targetShape[0]+".outMesh") ($orig[0]+".inMesh"); currentTime 0 ; int $origvertex[] = `polyEvaluate -v $orig[0]`; for ($nums = 0 ; $nums < $origvertex[0]; $nums++) { setAttr -type float3 ($orig[0] + ".controlPoints[" + $nums + "]") 0 0 0; } } else{ string $stillShape[] = `pickWalk -d down $obj`; currentTime 0 ; connectAttr -f ($targetShape[0]+".outMesh") ($stillShape[0]+".inMesh"); currentTime 1 ; disconnectAttr ($targetShape[0]+".outMesh") ($stillShape[0]+".inMesh"); currentTime 0 ; } } skinCluster -n $skinCluster -tsb $bone $obj; copySkinWeights -nm -sa closestPoint -ia closestJoint -ia oneToOne $copyName[0] $obj; delete $copyName[0]; } } SGProgressBar -ep; } global proc string[] SGGetOrigName(string $geo){ string $orig[]; clear $orig ; if ($geo == "" || objExists($geo) != true){ return $orig; } else { string $shapeMesh[] = `listRelatives -s $geo`; for ($num = 0; $num < size($shapeMesh); $num++) { if(`gmatch $shapeMesh[$num] "*Orig*"`){ $orig[size($orig)] = $shapeMesh[$num]; } } return $orig; } } global proc string[] SGGetOrigShapeName(string $geo){ string $orig[]; clear $orig ; if ($geo == "" || objExists($geo) != true){ return $orig; } else { string $shapeMesh[] = `listRelatives -s $geo`; for ($num = 0; $num < size($shapeMesh); $num++) { if(`gmatch $shapeMesh[$num] "*Orig*"`){ string $real[] = `listConnections $shapeMesh[$num]`; if (size($real) != 0){ string $m; for ($m in $real) { if( `gmatch $m "*groupParts*"` ){ $orig[size($orig)] = $shapeMesh[$num]; } } } } } return $orig; } }