まだちゃんと動かない
とりあえずメモ
計画の機能はほとんど入れたが肝心なところの
UI内で1になるようにスライダーを動かそうとしているがいい方法がまだ見つからない
yjp_weightedit_balanceこれがダメです。使わないでください。
簡単に出来そうなものだけど、なぜか動かない。
今回、思いついた新しい処理は
フライダーUIを毎回新しく置き換えている。
追加するとUIの名前が自動で付くので触ったコントロールがどれか取得しにくいが
なんとかできました。
まだ使い物にならないけど
global proc yjp_weightedit_balance(int $num)
{
global float $yjp_weightedit_float[];
float $val[],$total;
int $c = 0;
int $f = 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`;
//ホールド状態の処理
for ($n=0;$n<size($control);$n += 4)
{
$count[$c] = 0;
$val[$c] = `floatSliderGrp -q -v $control[$n+2]`;
$joint = `floatSliderGrp -q -l $control[$n+2]`;
$label = `textField -q-tx $control[$n+1]`;
$labeltxt = `setAttr -type "string" ($joint + ".otherType") $label`;
if(`checkBox -q -v $control[$n]`)
{
setAttr ($joint + ".lockInfluenceWeights") 1;
$holdfloat += $val[$c];
}
else if($num == $c)
{
setAttr ($joint + ".lockInfluenceWeights") 0;
$holdfloat += $val[$c];
if($yjp_weightedit_float[$c] < $val[$c])
{
$m = -1;
}
}
else
{
$count[$c] = 1;
$changeval[$f] = $val[$c];
$v += $changeval[$f];
$total = 1 - $val[$c];
}
$c++;
$f++;
}
$a = $total / $v;
for ($c=0;$c<size($val);$c++)
{
if($count[$c])
{
$val[$c] = $val[$c]*$a;
}
}
print ("total " + $total +"\n");
$c = 0;
for ($n=0;$n<size($control);$n += 4)
{
if($num == $c || `checkBox -q -v $control[$n]`){}
else
{
$yjp_weightedit_float[$c] = $val[$c];
floatSliderGrp -e -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`;
string $SkinScript,$jointList_out;
float $weight;
int $n;
for( $n=0 ; $n<size($control); $n+=4 )
{
$weight = `floatSliderGrp -q -v $control[$n+2]`;
$jointList_out = `floatSliderGrp -q -l $control[$n+2]`;
$SkinScript += ( "-tv " + $jointList_out + " " + $weight + " " );
}
if( $SkinScript != "" )
{
$SkinScript = ("skinPercent " + $SkinScript + $sc + " " + $vtxArray[0] );
eval( $SkinScript );
print ($SkinScript +"\n");
}
}
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[];
$weight = `skinPercent -ib 0.00001 -q -v $scA $sourcevtxArray[0]`;
$jointList = `skinPercent -ib 0.00001 -q -t $scA $sourcevtxArray[0]`;
int $bool;
string $labeltxt = "";
float $step = `floatField -q -v yjpWeigtEditStepField`;
for ($n=0 ; $n < size($jointList) ; $n++)
{
$yjp_weightedit_float[$n] = $weight[$n];
$bool = `getAttr ($jointList[$n] + ".lockInfluenceWeights")`;
$labeltxt = `getAttr ($jointList[$n] + ".otherType")`;
checkBox -w 30 -l "" -v $bool -p yjp_WeightEditQueueLayout;
textField -w 80 -tx $labeltxt -p yjp_WeightEditQueueLayout;
floatSliderGrp -w 320 -p yjp_WeightEditQueueLayout -cw 1 70 -cw 2 40 -cw 3 220 -label $jointList[$n] -field true
-minValue 0 -maxValue 1.0
-fieldMinValue 0 -fieldMaxValue 1.0
-s $step
-dc ("yjp_weightedit_balance " + $n)
-value $weight[$n];
button -en 0 -w 30 -l "Del" -p yjp_WeightEditQueueLayout ;
}
}
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 += 4)
{
floatSliderGrp -e -v $yjp_weightedit_float[$c] $control[$n+2];
$c++;
}
}
global proc yjp_WeightEdit()
{
if(`window -q -ex yjp_WeightEditwindow`) deleteUI yjp_WeightEditwindow;
window -s 1 -t "WeightEdit" yjp_WeightEditwindow;
string $no = "";
columnLayout -adjustableColumn true;
rowColumnLayout -nc 8 -cw 1 60 -cw 2 35 -cw 3 50 -cw 4 60 -cw 5 60 -cw 6 60 -cw 7 60 -cw 8 60;
checkBox -w 40 -l "Auto" -v 0 yjp_weightedit_ac;
text -l "snap";
floatField -w 50 -v 0.01 yjpWeigtEditStepField ;
button -h 25 -w 60 -l "Get_weight" -c "yjp_weightedit_get";
button -h 25 -w 60 -l "Reset" -c "yjp_weightedit_Reset";
button -en 0-h 25 -w 60 -l "Add_joint" ;
button -h 25 -w 60 -l "apply" -c "yjp_weightedit_apply" ;
button -h 25 -w 60 -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 "Delete";
setParent ..;
scrollLayout -horizontalScrollBarThickness 16 -verticalScrollBarThickness 16 -h 400 yjp_WeightEditscrollLayout;
rowColumnLayout -nc 4 -cw 1 30 -cw 2 80 -cw 3 320 -cw 4 30 yjp_WeightEditQueueLayout;
setParent ..;
setParent ..;
setParent ..;
window -e -wh 485 180 yjp_WeightEditwindow;
showWindow yjp_WeightEditwindow;
yjp_weightedit_get;
}
0 件のコメント:
コメントを投稿