MetaFusion/Reference/SuperRiggingEditor/scripts/SGSetHeadNeutralJointTranslation.mel
2025-02-03 22:58:41 +08:00

69 lines
1.8 KiB
Plaintext

//******************************************************************************
//
// 版权所有: 玉溪时光科技有限公司
// 联系邮箱: q.100@qq.com
// 开发日期: 2023/08/08
//
//******************************************************************************
global proc SGSetHeadNeutralJointTranslation (){
string $headMeshe = `SGGetMeshes -m 0`;
string $teethMeshe = `SGGetMeshes -m 1`;
string $eyeLeftMeshe = `SGGetMeshes -m 3`;
string $eyeRightMeshe = `SGGetMeshes -m 4`;
if(!`objExists $headMeshe` || !`objExists $teethMeshe` || !`objExists $eyeLeftMeshe` || !`objExists $eyeRightMeshe`){
return;
}
string $json = `SGDescriptor -ti "jointsInfo"`;
string $object[] = `SGReadJson -f $json -k "head" -t "object"`;
string $namespace = "DHIhead:";
int $count = `size($object)`;
if($count) {
SGProgressBar -sp;
string $locator = "MetaHumanLocatorTemp";
if(!`objExists $locator`){
spaceLocator -n $locator;
}
SGProgressBar -max $count;
SGProgressBar -t ("Set Head Joint Translation...");
float $pos[] = `SGGetNeutralJointTranslations -h`;
if($count != size($pos)/3){
error "count error......";
return;
}
for($i=0; $i<$count; $i++){
SGProgressBar -apr 1;
string $joints[] = `SGReadJson -d $object[$i] -k "joint" -t "string"`;
string $joint;
if(`namespace -ex $namespace`){
$joint = $namespace + $joints[0];
}
else{
$joint = $joints[0];
}
int $enable[] = `SGReadJson -d $object[$i] -k "locate" -t "bool"`;
if($enable[0]){
float $x = $pos[$i*3];
float $y = $pos[$i*3+1];
float $z = $pos[$i*3+2];
setAttr -type float3 ($locator + ".t") $x $y $z;
delete `pointConstraint -weight 1 $locator $joint`;
}
}
delete $locator;
SGRefreshNeutralJointTranslation;
SGProgressBar -ep;
refresh;
}
}