Tag: space switching

Better space switching

I learned about space switching years ago. I did’t think there was problem until recently …

How about having a prop control, that can drive the hand or the other way round ?

Of course I’m not setting each other as their “space” target. The evil cycle warning still shows because the target is having connections to all the space groups, no matter active or not. My solution is to add an extra loop of SetDrivenKey in space switching codes, setting nodeState of unused space groups to “block“.

// ----------------------------------------------
//   Block unused space groups
// ----------------------------------------------
for ($i=0; $i<`size $space`; $i++) {
     for ($j=0; $j<`size $spaceG`; $j++) {
         string $state = ($i == $j) ? 0 : 2;
         setDrivenKeyframe -cd "ctrl.space" -dv $i -at "nodeState" -v $state $spaceG[$j];
     }
 }

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.