//****************************************************************************** // // 版权所有: 玉溪时光科技有限公司 // 联系邮箱: q.100@qq.com // 开发日期: 2024/04/08 // //****************************************************************************** global proc SGPresetsSettings () { if (!`window -ex SuperRiggingEditor`){ return; } if (`window -ex presetsSettingsWin`){ deleteUI -window presetsSettingsWin; } //if(`SGDescriptor -l` == "ZH"){ //} string $jsonfile = `SGDescriptor -ti "jointsInfo"`; window -p SuperRiggingEditor -w 310 -h 100 -t "Presets Settings" -s true -tb true presetsSettingsWin; formLayout sgPresetsFormLayout; textField -tx $jsonfile sgTopologyInfo; separator -height 10 -style "in" sgPresetsSeparatorA; columnLayout -adj 1 -columnAttach "both" 5 -rowSpacing 2 -columnWidth 150 sgPresetsColumnLayoutA; button -l "Select Head Vertexs" -al "center" -c "SGSelectVertexs 0 head;" ; button -l "Save Head Vertexs" -al "center" -c "SGSaveVertexs 0 head;" ; separator -height 10 -style "in"; button -l "Select Teeth Vertexs" -al "center" -c "SGSelectVertexs 1 teeth;" ; button -l "Save Teeth Vertexs" -al "center" -c "SGSaveVertexs 1 teeth;" ; separator -height 10 -style "in"; button -l "Select EyeLeft Vertexs" -al "center" -c "SGSelectVertexs 3 eyeLeft;" ; button -l "Save EyeLeft Vertexs" -al "center" -c "SGSaveVertexs 3 eyeLeft;" ; separator -height 10 -style "in"; button -l "Select EyeRight Vertexs" -al "center" -c "SGSelectVertexs 4 eyeRight;" ; button -l "Save EyeRight Vertexs" -al "center" -c "SGSaveVertexs 4 eyeRight;" ; //separator -height 10 -style "in"; setParent..; columnLayout -adj 1 -columnAttach "both" 5 -rowSpacing 2 -columnWidth 150 sgPresetsColumnLayoutB; //separator -height 10 -style "in"; button -l "Select Body Vertexs" -al "center" -c "SGSelectVertexs 50 body;" ; button -l "Save Body Vertexs" -al "center" -c "SGSaveVertexs 50 body;" ; separator -height 10 -style "in"; button -l "Select Neck Vertexs" -al "center" -c "SGSelectVertexs 0 neck;" ; button -l "Save Neck Vertexs" -al "center" -c "SGSaveVertexs 0 neck;" ; separator -height 10 -style "in"; button -l "Select HeadEye Vertexs" -al "center" -c "SGSelectVertexs 0 headEye;" ; button -l "Save HeadEye Vertexs" -al "center" -c "SGSaveVertexs 0 headEye;" ; separator -height 10 -style "in"; button -l "Select HeadMouth Vertexs" -al "center" -c "SGSelectVertexs 0 headMouth;" ; button -l "Save HeadMouth Vertexs" -al "center" -c "SGSaveVertexs 0 headMouth;" ; //separator -height 10 -style "in"; setParent..; columnLayout -adj 1 -columnAttach "both" 5 -rowSpacing 2 -columnWidth 150 sgPresetsColumnLayoutC; separator -height 10 -style "in"; button -l "The Closest Ooint Of The Head" -al "center" -c "SGGetClosestPointOnMesh 0;" ; button -l "The Closest Ooint Of The Body" -al "center" -c "SGGetClosestPointOnMesh 50" ; button -l "The Closest Ooint Of The Teeth" -al "center" -c "SGGetClosestPointOnMesh 1;" ; separator -height 10 -style "in"; button -l "Write Joints Default Position" -al "center" -c "SGWriteJointsDefaultPosition;" ; separator -height 10 -style "in"; setParent..; setParent..; formLayout -e -attachForm sgTopologyInfo "top" 3 -attachForm sgTopologyInfo "left" 0 -attachForm sgTopologyInfo "right" 0 -attachNone sgTopologyInfo "bottom" -attachControl sgPresetsSeparatorA "top" 1 sgTopologyInfo -attachForm sgPresetsSeparatorA "left" 0 -attachForm sgPresetsSeparatorA "right" 0 -attachNone sgPresetsSeparatorA "bottom" -attachControl sgPresetsColumnLayoutA "top" 1 sgPresetsSeparatorA -attachForm sgPresetsColumnLayoutA "left" 0 -attachPosition sgPresetsColumnLayoutA "right" 0 51 -attachNone sgPresetsColumnLayoutA "bottom" -attachControl sgPresetsColumnLayoutB "top" 1 sgPresetsSeparatorA -attachPosition sgPresetsColumnLayoutB "left" 0 49 -attachForm sgPresetsColumnLayoutB "right" 0 -attachNone sgPresetsColumnLayoutB "bottom" -attachControl sgPresetsColumnLayoutC "top" 1 sgPresetsColumnLayoutA -attachForm sgPresetsColumnLayoutC "left" 0 -attachForm sgPresetsColumnLayoutC "right" 0 -attachNone sgPresetsColumnLayoutC "bottom" sgPresetsFormLayout; showWindow presetsSettingsWin; } //SGPresetsSettings; global proc SGSelectVertexs (int $meshIndex, string $region) { string $openfile = `SGDescriptor -ti "vertexsInfo"`; string $mesh = `SGGetMeshes -m $meshIndex`; int $vertexs[] = `SGReadJson -f $openfile -k $region -t "int"`; string $cmd = "select -cl;"; for($vertex in $vertexs){ $cmd += "select -add " + $mesh + ".vtx[" + $vertex + "];\n"; } eval($cmd); } global proc SGSaveVertexs (int $meshIndex, string $region) { string $jsonfile = `SGDescriptor -ti "vertexsInfo"`; string $mesh = `SGGetMeshes -m $meshIndex`; string $sel[] = `ls -sl -fl`; int $Indices[]; for($s in $sel){ string $buffer[]; int $numTokens = `tokenize $s "[]" $buffer`; string $meshBuffer = $buffer[0]; if(!`gmatch $meshBuffer ($mesh + "*")`){ error -n "Model Selection Error..."; return; } $Indices[size($Indices)] = $buffer[1]; } SGWriteJson -of $jsonfile -sf $jsonfile -k $region -t "int" $Indices; } global proc SGGetClosestPointOnMesh (int $meshIndex) { string $openfile = `SGDescriptor -ti "jointsInfo"`; string $mesh = `SGGetMeshes -m $meshIndex`; string $closestPointNode = `createNode closestPointOnMesh`; connectAttr -f ($mesh + ".worldMesh[0]") ($closestPointNode + ".inMesh"); string $key = "head" ; if($meshIndex == 50){ $key = "body" ; } string $cmd = "select -cl;"; string $object[] = `SGReadJson -f $openfile -k $key -t "object"`; for($i=0; $i