表示関係バグを修正。
取得してくるジョイントが変な事があったので修正。
ゼロウエイトをリストに入れるか入れないかのチェックボックス追加
スクロールレイアウトを調整
また使いながら調整していく。
コンポーネントエディターのウエイト調整よりだいぶ楽になった。
global proc yjp_weightedit_balance(int $num)
{
global float $yjp_weightedit_float[];
float $val[],$total;
int $c = 0;
float $holdfloat = 0.0;
float $changeval[];
float $a,$v;
string $joint,$label;
int $n,$count[];
int $m =1;
string $control[] = `rowColumnLayout -q -ca yjp_WeightEditQueueLayout`;
float $step = `floatField -q -v yjpWeigtEditStepField`;
//ホールド状態の処理
for ($n=0;$n<size($control);$n += 5)
{
$count[$c] = 0;
$val[$c] = `floatSliderGrp -q -v $control[$n+2]`;
if(`checkBox -q -v $control[$n]`)
{
//ホールド
$holdfloat += $val[$c];
}
else if($num == $c)
{
$joint = `floatSliderGrp -q -l $control[$n+2]`;
setAttr ($joint + ".type") 18;
setAttr ($joint + ".drawLabel") 1;
setAttr ($joint + ".displayHandle") 1;
//動かしたスライダ
$holdfloat += $val[$c];
}
else
{
//変化させるスライダ
$count[$c] = 1;
if($val[$c] < 0.01)
{
$val[$c] = 0.1;
}
$v += $val[$c];
}
$c++;
}
$total = 1 - $holdfloat;
//print ("total " + $total +"\n");
$a = $total / $v;
float $w[],$all;
for ($c=0;$c<size($val);$c++)
{
if($count[$c])
{
$val[$c] = $val[$c]*$a;
$w[$c] = $val[$c];
$all = $val[$c];
}
//print ("val " + $val[$c] +"\n");
}
$w = `sort $w`;
$w[size($w)-1] = $w[size($w)-1] + ($total - $all);
$c = 0;
for ($n=0;$n<size($control);$n += 5)
{
if($num == $c || `checkBox -q -v $control[$n]`){}
else
{
$yjp_weightedit_float[$c] = $val[$c];
floatSliderGrp -e -fmx $total -v $val[$c] $control[$n+2];
}
$c++;
}
if(`checkBox -q -v yjp_weightedit_ac`)
{
yjp_weightedit_apply;
}
}
global proc yjp_weightedit_apply()
{
string $vtxArray[] = `ls -sl`;
if(size($vtxArray) == 0)return ;
string $node[];
tokenize $vtxArray[0] "." $node;
string $sc = `findRelatedSkinCluster $node[0]`;
string $control[] = `rowColumnLayout -q -ca yjp_WeightEditQueueLayout`;
float $step = `floatField -q -v yjpWeigtEditStepField`;
string $SkinScript,$jointList_out;
float $weight;
int $n;
for( $n=0 ; $n<size($control); $n += 5 )
{
$weight = `floatSliderGrp -q -v $control[$n+2]`;
$jointList_out = `floatSliderGrp -q -l $control[$n+2]`;
$SkinScript += ( "-tv " + $jointList_out + " " + $weight + " " );
}
if( $SkinScript != "" )
{
for ($n=0;$n<size($vtxArray);$n++)
{
$SkinScript = ("skinPercent " + $SkinScript + $sc + " " + $vtxArray[$n] );
undoInfo -swf off;
eval( $SkinScript );
print ($SkinScript +"\n");
undoInfo -swf on;
}
}
}
global proc yjp_weightedit_get()
{
string $node[];
string $sourcevtxArray[] = `ls -sl`;
string $window[] = `rowColumnLayout -q -ca yjp_WeightEditQueueLayout`;
if(size($window))deleteUI $window;
if(size($sourcevtxArray) == 0)return ;
if(!`gmatch $sourcevtxArray[0] "*.vtx*"`)return ;
global float $yjp_weightedit_float[];
tokenize $sourcevtxArray[0] "." $node;
string $sourcobj = $node[0];
string $scA = `findRelatedSkinCluster $sourcobj`;
//print ($sourcobj + " sourcobj " + $scA + "\n") ;
int $n,$i;
float $weight[];
string $jointList[];
if(`checkBox -q -v yjp_weightedit_hz`)
{
$weight = `skinPercent -ib 0.0001 -q -v $scA $sourcevtxArray[0]`;
$jointList = `skinPercent -ib 0.0001 -q -t $scA $sourcevtxArray[0]`;
}
else
{
$weight = `skinPercent -ib 0.0000 -q -v $scA $sourcevtxArray[0]`;
$jointList = `skinPercent -ib 0.0000 -q -t $scA $sourcevtxArray[0]`;
}
string $labeltxt = "";
float $step = `floatField -q -v yjpWeigtEditStepField`;
$h = 60;
window -e -h $h yjp_WeightEditwindow;
for ($n=0 ; $n < size($jointList) ; $n++)
{
int $bool = 0;
int $hid = 1;
//getAttr ($jointList[$n] + ".objectColor");
setAttr ($jointList[$n] + ".lockInfluenceWeights") 0;
$yjp_weightedit_float[$n] = $weight[$n];
if($weight[$n] == 0)
{
$bool = 1;
$hid = 0;
}
$labeltxt = `getAttr ($jointList[$n] + ".otherType")`;
string $hcb = `checkBox -w 30 -l "" -v $bool -p yjp_WeightEditQueueLayout -onc ("yjp_weightedit_Hold 1 " + $n) -ofc ("yjp_weightedit_Hold 0 " + $n)`;
textField -w 80 -tx $labeltxt -p yjp_WeightEditQueueLayout -cc ("yjp_weightedit_JointLabel " + $n);
floatSliderGrp -en $hid -w 320 -p yjp_WeightEditQueueLayout -cw 1 70 -cw 2 40 -cw 3 200 -cw 4 200 -label $jointList[$n] -field true
-minValue 0 -maxValue 1.0
-fieldMinValue 0 -fieldMaxValue 1.0
-s $step
-ss $step
-dc ("yjp_weightedit_balance " + $n)
-cc ("yjp_weightedit_JointUnhilite " + $n)
-value $weight[$n];
button -en $hid -w 20 -l "<" -p yjp_WeightEditQueueLayout -c ("yjp_weightedit_step -1 " + $n);
button -en $hid -w 20 -l ">" -p yjp_WeightEditQueueLayout -c ("yjp_weightedit_step 1 " + $n);
$h += 23;
}
window -e -h $h yjp_WeightEditwindow;
}
global proc yjp_weightedit_step(int $di,int $num)
{
string $control[] = `rowColumnLayout -q -ca yjp_WeightEditQueueLayout`;
int $c =0;
for ($n=0;$n<size($control);$n += 5)
{
if($c == $num)
{
float $val = `floatField -q -v yjpWeigtEditStepField` ;
$val = $val * $di;
$val += `floatSliderGrp -q -v $control[$n+2]`;
floatSliderGrp -e -v $val $control[$n+2];
}
$c++;
}
yjp_weightedit_balance $num;
}
global proc yjp_weightedit_Reset()
{
global float $yjp_weightedit_float[];
string $control[] = `rowColumnLayout -q -ca yjp_WeightEditQueueLayout`;
int $n;
int $c =0;
for ($n=0;$n<size($control);$n += 5)
{
floatSliderGrp -e -v $yjp_weightedit_float[$c] $control[$n+2];
$c++;
}
yjp_weightedit_apply;
}
global proc yjp_weightedit_Hold(int $bool ,int $num)
{
string $control[] = `rowColumnLayout -q -ca yjp_WeightEditQueueLayout`;
int $n;
int $c =0;
string $joint;
int $en = 1;
if($bool)
{
$en = 0;
}
for ($n=0;$n<size($control);$n += 5)
{
if($c == $num)
{
//ホールド
$joint = `floatSliderGrp -q -l $control[$n+2]`;
checkBox -e -v $bool $control[$n];
floatSliderGrp -e -en $en $control[$n+2];
button -e -en $en $control[$n+3];
button -e -en $en $control[$n+4];
setAttr ($joint + ".lockInfluenceWeights") $bool;
}
$c++;
}
}
global proc yjp_weightedit_JointLabel(int $num)
{
int $n;
int $c = 0;
string $control[] = `rowColumnLayout -q -ca yjp_WeightEditQueueLayout`;
for ($n=0;$n<size($control);$n += 5)
{
if($c == $num)
{
string $label = `textField -q-tx $control[$n+1]`;
string $joint = `floatSliderGrp -q -l $control[$n+2]`;
setAttr ($joint + ".type") 18;
$labeltxt = `setAttr -type "string" ($joint + ".otherType") $label`;
}
$c++;
}
}
global proc yjp_weightedit_JointUnhilite(int $num)
{
int $n;
int $c = 0;
string $control[] = `rowColumnLayout -q -ca yjp_WeightEditQueueLayout`;
for ($n=0;$n<size($control);$n += 5)
{
string $joint = `floatSliderGrp -q -l $control[$n+2]`;
setAttr ($joint + ".drawLabel") 0;
setAttr ($joint + ".displayHandle") 0;
}
}
global proc yjp_weightedit_autoget()
{
global int $yjp_WeightEditJob;
if (`checkBox -q -v yjp_weightedit_ag`)
{
if (`scriptJob -ex $yjp_WeightEditJob`)scriptJob -force -kill $yjp_WeightEditJob;
$yjp_WeightEditJob =`scriptJob -p "yjp_WeightEditwindow" -e "SelectionChanged" "yjp_weightedit_get"`;
print ("yjp_WeightEditJob " + $yjp_WeightEditJob+ "\n") ;
}
else
{
scriptJob -kill $yjp_WeightEditJob -force;
print ("yjp_WeightEditJobkill " + $yjp_WeightEditJob+ "\n") ;
}
}
global proc yjp_weightedit_paint()
{
checkBox -e -v 0 yjp_weightedit_ag;
checkBox -e -v 0 yjp_weightedit_ac;
artUserPaintCtx artUserPaintCtx;
artUserPaintCtx -e -pm 1 -ic "yjp_weightedit_apply" artUserPaintCtx;
}
global proc yjp_WeightEdit()
{
if(`window -q -ex yjp_WeightEditwindow`) deleteUI yjp_WeightEditwindow;
window -s 1 -t "WeightEdit 1.4" -rtf true yjp_WeightEditwindow;
string $no = "";
global int $yjp_WeightEditJob;
string $form = `formLayout`;
string $Buttton = `columnLayout -adjustableColumn true`;
rowColumnLayout -nc 9 -cw 1 70 -cw 2 60 -cw 3 50 -cw 4 70 -cw 5 60 -cw 6 30 -cw 8 40 -cw 8 50 -cw 9 50;
//button -h 25 -w 60 -l "Reset" -c "yjp_weightedit_Reset";
checkBox -w 70 -l "HideZero" -v 1 -cc "yjp_weightedit_get" yjp_weightedit_hz;
checkBox -w 60 -l "AutoGet" -v 1 -cc "yjp_weightedit_autoget" yjp_weightedit_ag;
button -h 25 -w 50 -l "Get_vtx" -c "yjp_weightedit_get";
checkBox -w 60 -l "AutoApply" -v 0 yjp_weightedit_ac;
button -h 25 -w 50 -l "Apply" -c "yjp_weightedit_apply" ;
text -l "snap";
floatField -w 40 -v 0.01 -pre 3 yjpWeigtEditStepField ;
button -h 25 -w 50 -l "Paint" -c ("yjp_weightedit_paint;");
button -h 25 -w 50 -l "Close" -c ("deleteUI -window yjp_WeightEditwindow;");
setParent ..;
rowColumnLayout -nc 5 -cw 1 40 -cw 2 60 -cw 3 100 -cw 4 240 -cw 5 40 ;
text -l "Hold";
text -l "Label";
text -l "Joint";
text -l "Value";
text -l "step";
setParent ..;
setParent ..;
string $WES = `scrollLayout -horizontalScrollBarThickness 16 -verticalScrollBarThickness 16 yjp_WeightEditscrollLayout`;
rowColumnLayout -nc 5 -cw 1 30 -cw 2 80 -cw 3 320 -cw 4 20 -cw 5 20 yjp_WeightEditQueueLayout;
setParent ..;
setParent ..;
formLayout -edit
-attachForm $Buttton "top" 0
-attachNone $Buttton "bottom"
-attachForm $Buttton "left" 5
-attachForm $Buttton "right" 5
-attachForm $WES "top" 50
-attachForm $WES "bottom" 0
-attachForm $WES "left" 0
-attachForm $WES "right" 0
$form;
window -e -wh 500 180 yjp_WeightEditwindow;
showWindow yjp_WeightEditwindow;
$yjp_WeightEditJob =`scriptJob -p "yjp_WeightEditwindow" -e "SelectionChanged" "yjp_weightedit_get"`;
}
0 件のコメント:
コメントを投稿