145 lines
4.6 KiB
Plaintext
145 lines
4.6 KiB
Plaintext
//******************************************************************************
|
|
//
|
|
// 版权所有: 玉溪时光科技有限公司
|
|
// 联系邮箱: q.100@qq.com
|
|
// 开发日期: 2023/08/08
|
|
//
|
|
//******************************************************************************
|
|
|
|
global proc SGCreateLOD (int $index){
|
|
if(!`pluginInfo -q -l "Unfold3D"`){
|
|
loadPlugin "Unfold3D";
|
|
}
|
|
if($index == 0){
|
|
int $lods[] = {1,2,3,4,5,6,7};
|
|
for ($lod in $lods){
|
|
SGCreateLOD $lod;
|
|
}
|
|
}
|
|
else{
|
|
string $axis = `upAxis -q -axis`;
|
|
if($axis == "y"){
|
|
$axis = "YAxisUp";
|
|
}
|
|
else if($axis == "z"){
|
|
$axis = "ZAxisUp";
|
|
}
|
|
|
|
string $meshes[] = {"head","teeth","saliva","eyeLeft","eyeRight","eyeshell","eyelashes","eyeEdge","cartilage","body"};
|
|
|
|
string $headGrp = "head_lod"+$index+"_grp";
|
|
string $headMesh = "head_lod"+$index+"_mesh";
|
|
|
|
if(!`objExists $headGrp`){
|
|
group -em -name $headGrp;
|
|
}
|
|
if(!`objExists $headMesh`){
|
|
SGGetMeshes -cml $index;
|
|
int $headLod[] = `SGGetMeshes -lod 0`;
|
|
int $createLod[] = `SGGetMeshes -lod $index`;
|
|
for($c in $createLod){
|
|
string $create = `SGGetMeshes -i $c`;
|
|
if($c >= 50){
|
|
delete $create;
|
|
continue;
|
|
}
|
|
int $exist = 0;
|
|
for($h in $headLod){
|
|
if($h >= 50){
|
|
continue;
|
|
}
|
|
if(`gmatch $create ($meshes[$h]+"*")`){
|
|
string $mesh = `SGGetMeshes -m $h`;
|
|
if(`objExists $mesh`){
|
|
parent $create $headGrp;
|
|
string $suv[] = `polyUVSet -q -currentUVSet $mesh`;
|
|
string $tuv[] = `polyUVSet -q -currentUVSet $create`;
|
|
if(`size($suv)` != 1){
|
|
error ($mesh + ": There are multiple uvSet!!!" );
|
|
}
|
|
if(`size($tuv)` != 1){
|
|
error ($create + ": There are multiple uvSet!!!" );
|
|
}
|
|
if(`gmatch $create "eyeshell*"`){
|
|
polyUVSet -cp -uvSet $suv[0] $mesh;
|
|
polyUVSet -cuv -uvSet "uvSet1" $mesh;
|
|
u3dLayout -res 256 -scl 1 -spc 0.0029296875 -mar 0.0029296875 -box 0 1 0.5 1 $mesh;
|
|
polyUVSet -cp -uvSet $tuv[0] $create;
|
|
polyUVSet -cuv -uvSet "uvSet1" $create;
|
|
u3dLayout -res 256 -scl 1 -spc 0.0029296875 -mar 0.0029296875 -box 0 1 0.5 1 $create;
|
|
|
|
transferAttributes -transferPositions 1 -transferNormals 1 -transferUVs 0 -transferColors 0
|
|
-sampleSpace 3 -sourceUvSpace "uvSet1" -targetUvSpace "uvSet1"
|
|
-searchMethod 3 -flipUVs 0 -colorBorders 1 $mesh $create;
|
|
transferShadingSets -sampleSpace 0 -searchMethod 3 $mesh $create;
|
|
polySoftEdge -a 180 -ch 1 $create;
|
|
polyNormalPerVertex -ufn true $create;
|
|
DeleteHistory $create;
|
|
|
|
polyUVSet -cuv -uvSet $suv[0] $mesh;
|
|
polyUVSet -delete -uvSet "uvSet1" $mesh;
|
|
polyUVSet -cuv -uvSet $tuv[0] $create;
|
|
polyUVSet -delete -uvSet "uvSet1" $create;
|
|
}
|
|
else{
|
|
transferAttributes -transferPositions 1 -transferNormals 1 -transferUVs 0 -transferColors 0
|
|
-sampleSpace 3 -sourceUvSpace $suv[0] -targetUvSpace $tuv[0]
|
|
-searchMethod 3 -flipUVs 0 -colorBorders 1 $mesh $create;
|
|
transferShadingSets -sampleSpace 0 -searchMethod 3 $mesh $create;
|
|
polySoftEdge -a 180 -ch 1 $create;
|
|
polyNormalPerVertex -ufn true $create;
|
|
DeleteHistory $create;
|
|
}
|
|
$exist = 1;
|
|
}
|
|
}
|
|
}
|
|
if(!$exist){
|
|
delete $create;
|
|
}
|
|
}
|
|
}
|
|
else{
|
|
warning ($headMesh + " Existed!!!");
|
|
}
|
|
|
|
if($index < 4){
|
|
string $bodyGrp = "body_lod"+$index+"_grp";
|
|
string $bodyMesh = "body_lod"+$index+"_mesh";
|
|
if(!`objExists $bodyGrp`){
|
|
group -em -name $bodyGrp;
|
|
}
|
|
if(!`objExists $bodyMesh`){
|
|
string $mesh = `SGGetMeshes -m 50`;
|
|
if(`objExists $mesh`){
|
|
int $bodyIndex = 50 + $index;
|
|
SGGetMeshes -cm $bodyIndex;
|
|
parent $bodyMesh $bodyGrp;
|
|
string $suv[] = `polyUVSet -q -currentUVSet $mesh`;
|
|
string $tuv[] = `polyUVSet -q -currentUVSet $bodyMesh`;
|
|
if(`size($suv)` != 1){
|
|
error ($mesh + ": There are multiple uvSet!!!" );
|
|
}
|
|
if(`size($tuv)` != 1){
|
|
error ($bodyMesh + ": There are multiple uvSet!!!" );
|
|
}
|
|
transferAttributes -transferPositions 1 -transferNormals 1 -transferUVs 0 -transferColors 0
|
|
-sampleSpace 3 -sourceUvSpace $suv[0] -targetUvSpace $tuv[0]
|
|
-searchMethod 3 -flipUVs 0 -colorBorders 1 $mesh $bodyMesh;
|
|
transferShadingSets -sampleSpace 0 -searchMethod 3 $mesh $bodyMesh;
|
|
polySoftEdge -a 180 -ch 1 $bodyMesh;
|
|
polyNormalPerVertex -ufn true $bodyMesh;
|
|
DeleteHistory $bodyMesh;
|
|
string $bodyMeshShape[] = `listRelatives -s $bodyMesh`;
|
|
setAttr ($bodyMeshShape[0]+".displayColors") 0;
|
|
}
|
|
}
|
|
else{
|
|
warning ($bodyMesh + " Existed!!!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|