MetaFusion/Reference/SuperRiggingEditor/scripts/SGBlendShapeFindFlipTarget.mel

101 lines
2.6 KiB
Plaintext
Raw Normal View History

2025-02-03 22:58:41 +08:00
//******************************************************************************
//
// <20><>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>: <20><>Ϫʱ<CFAA><CAB1><EFBFBD>Ƽ<EFBFBD><C6BC><EFBFBD><EFBFBD>޹<EFBFBD>˾
// <20><>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>: q.100@qq.com
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: 2023/08/08
//
//******************************************************************************
global proc SGBlendShapeFindFlipTarget (int $axis, int $targetIdsA[], int $targetIdsB[], string $blendShape){
if(!`objExists $blendShape`)
{
warning -n ("No Exists BlendShape:" + $blendShape);
return;
}
if(size($targetIdsA) != size($targetIdsB))
{
warning -n ("Unequal Mirror Targets...");
return;
}
int $originalSymmetry = `symmetricModelling -q -s`;
string $symmetrySpace, $symmetryAxis;
if ($originalSymmetry)
{
$symmetrySpace = `symmetricModelling -q -about`;
if ($symmetrySpace == "topo")
$symmetryAxis = blendShapeGetTopoSymmetryEdge();
else
$symmetryAxis = `symmetricModelling -q -axis`;
}
for ($i=0;$i<size($targetIdsA);$i++)
{
int $targetA = $targetIdsA[$i];
int $targetB = $targetIdsB[$i];
int $exist = 0;
string $targetName = $blendShape + ".weight[" + $targetA + "]";
$targetName = `aliasAttr -q $targetName`;
if(`objExists $targetName`) {
$exist = 1;
rename $targetName ($targetName+"_temp");
}
string $targetMeshA[] = `sculptTarget -e -regenerate true -target $targetA $blendShape`;
string $targetMeshShapeA[] = `listRelatives -s $targetMeshA[0]`;
disconnectAttr ($targetMeshShapeA[0]+".worldMesh[0]") ($blendShape+".inputTarget[0].inputTargetGroup["+$targetA+"].inputTargetItem[6000].inputGeomTarget");
connectAttr -f ($targetMeshShapeA[0]+".worldMesh[0]") ($blendShape+".inputTarget[0].inputTargetGroup["+$targetB+"].inputTargetItem[6000].inputGeomTarget");
delete $targetMeshA;
if($exist){
rename ($targetName+"_temp") $targetName;
}
}
int $geometryIndices[] = `blendShape -q -gi $blendShape`;
string $cmd;
for($geometry in $geometryIndices)
{
$cmd += "blendShape -e ";
for($targetId in $targetIdsB)
{
$cmd += "-ft " + $geometry + " " + $targetId + " ";
}
if ($axis == 4)
{
$cmd += "-ss 0 ";
}
else
{
$cmd += "-ss 1 ";
if ($axis == 1)
$cmd += "-sa x ";
else if ($axis == 2)
$cmd += "-sa y ";
else if ($axis == 3)
$cmd += "-sa z ";
}
$cmd += $blendShape + "; ";
}
if (!$originalSymmetry || size($symmetryAxis) == 0)
$cmd += "eval -ue 0 \"symmetricModelling -s 0\";";
else if ($symmetrySpace == "topo")
$cmd += "eval -ue 0 \"symmetricModelling -e -about " + $symmetrySpace + " -s 1 " + $symmetryAxis + "\";";
else
$cmd += "eval -ue 0 \"symmetricModelling -e -about " + $symmetrySpace + " -axis " + $symmetryAxis + " -s 1\";";
//print $cmd;
eval($cmd);
}