リグをMELで自動的に作成するプログラムを作成してみます。
足の部分を作るMELスクリプトです。
global proc string makeCube(float $sx, float $sy, float $sz, float $tx, float $ty, float $tz)
{
string $name = `curve -d 1 -p -1 0 -1 -p 1 0 -1 -p 1 0 1 -p -1 0 1 -p -1 0 -1 -p -1 2 -1 -p 1 2 -1 -p 1 0 -1 -p 1 0 1 -p 1 2 1 -p 1 2 -1 -p -1 2 -1 -p -1 2 1 -p 1 2 1 -p 1 0 1 -p -1 0 1 -p -1 2 1 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16`;
scale $sx $sy $sz;
move $tx $ty $tz;
return $name;
}
global proc makeLeg(int $flag, string $wast)
{
float $tx; // 各部品の位置X座標
string $leg; // 足根元
string $knee; // ひざ
string $heel; // かかと
string $foot; // 足
string $toe; // つま先
string $ik; // 足全体のIKHandle
string $ikfoot; // 足のIKHandle
string $iktoe; // つま先のIKHandle
string $loc; // ひざロケータ
if($flag == 0)
{
// 右足の各部品名
$tx = -2.0;
$leg = $wast + "rightLeg";
$knee = $wast + "rightKnee";
$heel = $wast + "rightHeel";
$foot = $wast + "rightFoot";
$toe = $wast + "rightToe";
$ik = $wast + "rightIkHandle";
$ikfoot = $wast + "rightFootIk";
$iktoe = $wast + "rightToeIk";
$loc = $wast + "rightLocator";
}
else
{
// 左足の各部品名
$tx = 2.0;
$leg = $wast + "leftLeg";
$knee = $wast + "leftKnee";
$heel = $wast + "leftHeel";
$foot = $wast + "leftFoot";
$toe = $wast + "leftToe";
$ik = $wast + "leftIkHandle";
$ikfoot = $wast + "leftFootIk";
$iktoe = $wast + "leftToeIk";
$loc = $wast + "leftLocator";
}
// ジョイント作成
joint -p $tx 10 0 -n $leg $wast;
joint -p $tx 5 0 -n $knee $leg;
joint -p $tx 0 0 -n $heel;
joint -p $tx -1 2 -n $foot;
joint -p $tx -1 3 -n $toe;
// 優先角設定
rotate -r 10 0 0 $knee;
joint -e -spa -ch $knee;
rotate -r -10 0 0 $knee;
// ikハンドル作成
ikHandle -sol ikRPsolver -sj $leg -ee $heel -n $ik;
ikHandle -sol ikSCsolver -sj $heel -ee $foot -n $ikfoot;
ikHandle -sol ikSCsolver -sj $foot -ee $toe -n $iktoe;
// 足コントローラ用カーブ作成
string $footct = makeCube(0.533, 0.846, 1.102, $tx, -1.2, 0.9);
string $heelct = makeCube(0.291, 0.448, 0.717, $tx, -1.172, -0.408);
string $toect = makeCube(0.328, 0.297, 0.523, $tx, -1.189, 2.528);
// 足コントローラ作成
parent $ik $footct;
parent $heelct $footct;
parent $toect $heelct;
setAttr ($toect+".rotatePivotZ") -0.72;
select -r $toect;
select -add $iktoe;
parentConstraint -mo -weight 1;
setAttr ($heelct+".rotatePivotZ") 0.42;
select -r $heelct;
select -add $ik;
parentConstraint -mo -weight 1;
select -r $heelct;
select -add $ikfoot;
parentConstraint -mo -weight 1;
// ひざコントローラ
spaceLocator -n $loc;
move $tx 5 5;
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0;
poleVectorConstraint -weight 1 $loc $ik;
}
string $myWast = "myWast1"; joint -p 0 12 0 -n $myWast; // 左足作成 makeLeg(1, $myWast); // 右足作成 makeLeg(0, $myWast);