FK/IK Snap (In Progress)

Hi!

I’m currently working on a FK to IK snapper that will work with my walker rig. What I’m trying to do is make it so that you can easily match the IK foot control to the basic position and location of the ankle joint after moving said joint with FK control.

To say it another way: when you move from IK to FK, you’re all good. Everything stays where it should. You can then rotate the joints around and animate them as you wish, but if you want to switch back to IK mode, you’d have to manually match the position and rotation of your foot. That’s no fun. So this script is supposed to help a bit with that.

Given a driven object and a target, it will simply match that driven object to that target’s location and rotation in world space.

Yet that was the easy part. The hard part was getting it to work right with my reverse foot setup. I think I found a way though. This image explains it a bit:

So as you can see, you can add this after you’ve placed all your rig controls.

  1. Add your “snap” group and move it to the position of the ankle.
  2. Your other controls have now been moved from their normal position. I fixed this by adding in a second group above the ORIENT group. Moving that group back to the origin (0,0,0) will put your control back in its proper place.
    1. This MUST be done only after you’ve moved your “snap” group into place. That’s because it needs to inherit the pivot point location of the snap group in order to be able to easily just move it back to the origin.
  3. Done!

I think that’s it. I added a locator and first oriented it to the goot joint so that it correctly points to the foot pivot point. Then, I took that X rotation value and added it into a part of my script that will ensure that nothing gets double-rotated. I then, parent constrained it to the foot joint so that it will inherit the rotation of the foot joint.

What that means is my IK control will match both the position and rotation of the foot. Well, at least the upper part of the foot. If the toe is rotated, I don’t have a way yet to match that (because of my reverse foot setup. Fortunately, it shouldn’t result in too much snapping…

That being said, I need to figure out a way to fix that.

Here’s the script:

import maya.cmds as cmds

class TransRotSnap(object):
    def __init__(self,ctrl,loc,rotComp):
        self.ctrl = ctrl
        self.loc = loc
        self.rotComp = rotComp

    def fkIKsnap(self):
        locPos = cmds.xform(self.loc,q=1,t=1,ws=1)
        locRot = cmds.xform(self.loc,q=1,ro=1,ws=1)
        # these values are the compensated values from the orient group
        cmds.xform(self.ctrl,t=(locPos[0],locPos[1],locPos[2]),a=1,ws=1)
        cmds.xform(self.ctrl,ro=(locRot[0]-self.rotComp,locRot[1],locRot[2]),a=1,ws=1)

trSnap = TransRotSnap("snap","locator1",23.103)
trSnap.fkIKsnap()

Advertisements
Image

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s