## Thursday, June 3, 2010

### IK/FK Switch Ratio Expressions

Rather than using a constraint to two joints then changing the contraint values, sometimes I'll use and expression to drive the roll joints in arms/legs or whatever.

`//roll joint  |wrist IK joint|ratio|switch controller   |wrist FK joint|ratio|switch controllerroll_jnt.rx = ((wristIK_jnt.rx * .3)*switch.IKFK) + ((wristFK_jnt.rx * .3)*abs(switch.IKFK - 1));`

In this expression I am multiplying the wrists rotation by a ratio (0.3) to get the amount of rotation I want on the roll joint. For the IK I am then multiplying it by the value of the switch which goes from 0-1. That way if I'm in FK mode it doesn't get any influence. For the FK you do the same thing but subtract 1 and take the absolute value to get 0-1 but reversed from the attribute.

So:
IK MODE
x = ((30 * 0.3) * 1) + ((60 * 0.3) * abs(1 - 1))
x = (9 * 1) + (18 * abs(0))
x = 9 + 0
x = 9

FK MODE
x = ((30 * 0.3) * 0) + ((60 * 0.3) * abs(0 - 1))
x = (9 * 0) + (18 * abs(-1))
x = 0 + 18
x = 18

Not really MEL but still a handy trick.

#### 0 comments: 