Simple trick to finding the perfect pole vector position, so that when you create your constraint, your joint chain wont move at all! :)
// ik chain joint list
string $ikJoints[] = {"joint1","joint2","joint3"};
// find joint positions
float $pos1[] = `xform -q -ws -piv $ikJoints[0]`;
float $pos2[] = `xform -q -ws -piv $ikJoints[1]`;
float $pos3[] = `xform -q -ws -piv $ikJoints[2]`;
// create a 3 vertex plane between the joints and add a move vertex node
string $rpPlane[] = `polyCreateFacet -ch on -tx 1 -s 1
-p $pos1[0] $pos1[1] $pos1[2]
-p $pos3[0] $pos3[1] $pos3[2]
-p $pos2[0] $pos2[1] $pos2[2]`;
string $polyMove[] = `polyMoveVertex -constructionHistory 1 -random 0 ($rpPlane[0] + ".vtx[2]")`;
// now move that vertex back or forwards or whatever direction you need
setAttr ($polyMove[0] + ".localTranslate") -type double3 0 -5 0 ;
// snap your controller to the vertex and it'll be in the perfect position!
0 comments:
Post a Comment