Tag: maya

Soft IK

If you haven’t heard of soft IK before, please read http://www.softimageblog.com/archives/108. Andy Nicholas explains the problem very clearly. Essentially it adds a “soft” distance and slow down the movement causing the pop with a formula. Andy showed this in Softimage but the idea works anywhere.

Below are some lines of expression showing the ideas in maya. They are running node-based in my final rig but making the setup works in expression first is faster for me.

// -----------------------------------------------------------
//     $d : current distance betw ends
//     $D : initial distance betw ends
//     $S : IK softness
//
//     softJ_start & softJ_end
//         a 2-joint chain with it's IK parented under e.g. foot ctrl
//         the main IK is point constrainted to softJ_end
// -----------------------------------------------------------

float $S = ctrl.soft;
float $D_soft = $D - $S;
float $new_d = $d;

if ( $d > $D_soft ) {
    float $x = $d - $D_soft;
    $new_d = $D_soft + $S *( 1-exp(-$x) );
}

softJ_end.ty = $new_d;

Space switching + fk/ik snapping

Finally, space switching and fk/ik snapping work using scriptJob. Mel procedures are stored in scriptNode and called by scriptJob once the file is loaded. This is the method I learned by breaking Stewart of Animation Mentor.

The trickest part is “keyable” space switching. Since I’m using scriptJob’s “attributeChange” event, if the “space” attribute is directly keyed, scrubbing the timeline will change the value and unexpectedly invoke the proc.

My solution is to move the keys to another attribute.

  1. Create the space switching attribute, “space”, as non-keyable and hidden.
  2. Create another attribute, “spaceNow”, which is keyable, driving original “space” ( as a space indicator and not to be changed directly by user ).
  3. Create one more attribute, “spaceSwitch”, which is non-keyable, used to change space non-pop, and used by attributeChange event.

Having attributes in single control I could key the transform and space at once. This avoids missing selection or keys if I want to adjust timing later.

By the way, you still need to use the copy and paste worldspace fix if the position of control changes before or after the switching frame.


Rotate Order

Arrrr . . . it’s been a while doing bunch of various stuff. Finally I got sth to share while scripting my autorig system.

Usually I don’t care about gimbal lock since I discovered the “euler filter” button in graph editor. And I always thought that better rotate order means cleaner animation curves only. Recently I found another case showing the importance of proper rotate order.

Imagine a standard 3-joint IK arm (say, left arm) with simple pole vector setup. When the character moves his arm ( ikHandle ) forward and about to the right, the upper arm joint’s rotation would pop from (0, -89.x, 0) to crazy values like (180, -89.x, -180). It took me a while to think about it . . .

A better rotate order seems to help.

Here is the best gimbal lock explanation I’ve seen https://www.youtube.com/watch?v=zc8b2Jo7mno.