//****************************************************************************** // // 版权所有: 玉溪时光科技有限公司 // 联系邮箱: q.100@qq.com // 开发日期: 2023/08/08 // //****************************************************************************** global proc SGDuplicateTarget (string $target, int $index){ string $head = `SGGetMeshes -m 0`; string $root_targets_grp = "root_targets_grp"; if(!`objExists $root_targets_grp`) { group -em -n $root_targets_grp; } for($i=0; $i<9; $i++){ string $mesheDeploy = `SGGetMeshes -i $i`; string $blendShape = $mesheDeploy + "_blendShapes"; if(!`objExists $blendShape`){ continue; } string $attrWeight = $blendShape + ".weight"; int $count = `getAttr -size $attrWeight`; string $currentBlendShapeList[] = `listAttr -m $attrWeight`; if(!stringArrayContains($target, $currentBlendShapeList) || $count == 0){ continue; } string $meshe = `SGGetMeshes -m $i`; string $mesheTarget = $mesheDeploy + "_" + $target; duplicate -rr -n $mesheTarget $meshe; string $target_grp = $target + "_grp"; if(!`objExists $target_grp`) { group -em -n $target_grp; parent $target_grp $root_targets_grp; } parent $mesheTarget $target_grp; setAttr -lock false ($mesheTarget + ".tx"); setAttr -lock false ($mesheTarget + ".ty"); setAttr -lock false ($mesheTarget + ".tz"); setAttr -lock false ($mesheTarget + ".rx"); setAttr -lock false ($mesheTarget + ".ry"); setAttr -lock false ($mesheTarget + ".rz"); setAttr -lock false ($mesheTarget + ".sx"); setAttr -lock false ($mesheTarget + ".sy"); setAttr -lock false ($mesheTarget + ".sz"); string $axis = `upAxis -q -axis`; float $pos[] = `polyEvaluate -b $head`; float $distanceX = $pos[1] - $pos[0]; float $distanceU; if($axis == "y"){ $distanceU = $pos[3] - $pos[2]; } else if($axis == "z"){ $distanceU = $pos[5] - $pos[4]; } int $row = $index%30; int $column = $index/30; float $movex = ($row + 1) * $distanceX; float $movey = $column * $distanceU * -1; setAttr ($mesheTarget + ".tx") $movex; if($axis == "y"){ setAttr ($mesheTarget + ".ty") $movey; } else if($axis == "z"){ setAttr ($mesheTarget + ".tz") $movey; } } }