69 lines
1.8 KiB
Plaintext
69 lines
1.8 KiB
Plaintext
|
//******************************************************************************
|
|||
|
//
|
|||
|
// <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 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;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|