Monday, March 11, 2013

IK / FK Snapping

A quick demonstration video utilizing a few of the concepts I have been working on in regards with rigging. This video features a look at Spacial Toggling and IK / FK Snapping using Maya's mel script.



Also, here is the script I created in order to achieve the IK / FK Snapping:

int $lArmIKFK = `getAttr ctr_l_hand_attributes.ik_to_fk_snap`;

if ($lArmIKFK == 2) {

//FK to IK Variables

float $lFKUpperArmRX = `getAttr ik_l_shoulder_jnt.rx`;
float $lFKUpperArmRY = `getAttr ik_l_shoulder_jnt.ry`;
float $lFKUpperArmRZ = `getAttr ik_l_shoulder_jnt.rz`;

float $lFKForearmRX = `getAttr ik_l_elbow_jnt.rx`;
float $lFKForearmRY = `getAttr ik_l_elbow_jnt.ry`;
float $lFKForearmRZ = `getAttr ik_l_elbow_jnt.rz`;

float $lFKWristRX = `getAttr ik_l_wrist_jnt.rx`;
float $lFKWristRY = `getAttr ik_l_wrist_jnt.ry`;
float $lFKWristRZ = `getAttr ik_l_wrist_jnt.rz`;

//FK to IK Function

setAttr ctr_l_fk_upperArm.rx $lFKUpperArmRX;
setAttr ctr_l_fk_upperArm.ry $lFKUpperArmRY;
setAttr ctr_l_fk_upperArm.rz $lFKUpperArmRZ;

setAttr ctr_l_fk_forearm.rx $lFKForearmRX;
setAttr ctr_l_fk_forearm.ry $lFKForearmRY;
setAttr ctr_l_fk_forearm.rz $lFKForearmRZ;

setAttr ctr_l_fk_wrist.rx $lFKWristRX;
setAttr ctr_l_fk_wrist.ry $lFKWristRY;
setAttr ctr_l_fk_wrist.rz $lFKWristRZ;
}

else if ( $lArmIKFK == 1) {

//IK to FK Variables

string $lIKWristMover[] = `listConnections ctr_l_hand_attributes.l_ik_wrist`;
string $lFKWristTarget[] = `listConnections ctr_l_hand_attributes.l_fk_wrist`;
string $lIKPVMover[] = `listConnections ctr_l_hand_attributes.l_ik_PV`;
string $lFKPVTarget[] = `listConnections ctr_l_hand_attributes.l_fk_PV_LOC`;

float $lFKWristPos[] = `xform -q -ws -rp $lFKWristTarget[0]`;
float $lFKWristRot[] = `xform -q -ws -ro $lFKWristTarget[0]`;
float $lFKPVPos[] = `xform -q -ws -rp $lFKPVTarget[0]`;


//IK to FK Function

move -ws -rpr $lFKWristPos[0] $lFKWristPos[1] $lFKWristPos[2] $lIKWristMover[0];
xform -ws -ro $lFKWristRot[0] $lFKWristRot[1] $lFKWristRot[2] $lIKWristMover[0];
move -ws -rpr $lFKPVPos[0] $lFKPVPos[1] $lFKPVPos[2] $lIKPVMover[0];

}