MetaFusion/Reference/SuperRiggingEditor/scripts/SGBatchAddBlendShape.mel

108 lines
3.9 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>: 2024/09/24
//
//******************************************************************************
global proc SGBatchAddBlendShape (int $lod, string $meshes[]){
int $mesheIndices[] = `SGGetMeshes -lod $lod`;
SGProgressBar -sp;
for ($mesheIndex in $mesheIndices) {
string $meshe = `SGGetMeshes -m $mesheIndex`;
if(`objExists $meshe`){
string $lod_meshe = `SGGetMeshes -i $mesheIndex`;
string $head = `match "[^_]+" $lod_meshe`;
if(stringArrayContains($head, $meshes)){
string $blendShape = $lod_meshe + "_blendShapes";
if(!`objExists $blendShape`){
blendShape -automatic -n $blendShape $meshe;
if($head == "head"){
int $targetCount = 0;
int $count = `SGGetBlendShapes -tc $targetCount`;
SGProgressBar -max $count;
SGProgressBar -t ("[" + $blendShape + "] Creating Target Mesh...");
for($index=0; $index<$count; $index++){
SGProgressBar -apr 1;
string $bsName = `SGGetBlendShapes -bsn $targetCount $index`;
duplicate -rr -n $bsName $meshe;
if($lod == 0){
SGSetBlendShapes -ct $mesheIndex $index $bsName;
}
blendShape -e -tc on -t $meshe $index $bsName 1 -w $index 0 $blendShape;
delete $bsName;
}
}
else if($head == "teeth" || $head == "saliva"){
int $targetCount = 1;
int $count = `SGGetBlendShapes -tc $targetCount`;
SGProgressBar -max $count;
SGProgressBar -t ("[" + $blendShape + "] Creating Target Mesh...");
for($index=0; $index<$count; $index++){
SGProgressBar -apr 1;
string $bsName = `SGGetBlendShapes -bsn $targetCount $index`;
duplicate -rr -n $bsName $meshe;
if($lod == 0 && $head == "teeth"){
SGSetBlendShapes -ct $mesheIndex $index $bsName;
}
blendShape -e -tc on -t $meshe $index $bsName 1 -w $index 0 $blendShape;
delete $bsName;
}
}
else if($head == "eyeLeft"){
int $targetCount = 3;
int $count = `SGGetBlendShapes -tc $targetCount`;
SGProgressBar -max $count;
SGProgressBar -t ("[" + $blendShape + "] Creating Target Mesh...");
for($index=0; $index<$count; $index++){
SGProgressBar -apr 1;
string $bsName = `SGGetBlendShapes -bsn $targetCount $index`;
duplicate -rr -n $bsName $meshe;
if($lod == 0){
SGSetBlendShapes -ct $mesheIndex $index $bsName;
}
blendShape -e -tc on -t $meshe $index $bsName 1 -w $index 0 $blendShape;
delete $bsName;
}
}
else if($head == "eyeRight"){
int $targetCount = 4;
int $count = `SGGetBlendShapes -tc $targetCount`;
SGProgressBar -max $count;
SGProgressBar -t ("[" + $blendShape + "] Creating Target Mesh...");
for($index=0; $index<$count; $index++){
SGProgressBar -apr 1;
string $bsName = `SGGetBlendShapes -bsn $targetCount $index`;
duplicate -rr -n $bsName $meshe;
if($lod == 0){
SGSetBlendShapes -ct $mesheIndex $index $bsName;
}
blendShape -e -tc on -t $meshe $index $bsName 1 -w $index 0 $blendShape;
delete $bsName;
}
}
else if($head == "eyeshell" || $head == "eyelashes" || $head == "eyeEdge" || $head == "cartilage"){
int $targetCount = 8;
int $count = `SGGetBlendShapes -tc $targetCount`;
SGProgressBar -max $count;
SGProgressBar -t ("[" + $blendShape + "] Creating Target Mesh...");
for($index=0; $index<$count; $index++){
SGProgressBar -apr 1;
string $bsName = `SGGetBlendShapes -bsn $targetCount $index`;
duplicate -rr -n $bsName $meshe;
if($lod == 0 && $head == "cartilage"){
SGSetBlendShapes -ct $mesheIndex $index $bsName;
}
blendShape -e -tc on -t $meshe $index $bsName 1 -w $index 0 $blendShape;
delete $bsName;
}
}
}
}
}
}
SGProgressBar -ep;
}