108 lines
3.9 KiB
Plaintext
108 lines
3.9 KiB
Plaintext
//******************************************************************************
|
|
//
|
|
// 版权所有: 玉溪时光科技有限公司
|
|
// 联系邮箱: q.100@qq.com
|
|
// 开发日期: 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;
|
|
}
|