ik/fk Switch snap and switch...not a blend


#1

In maya I am trying to create an Ik/Fk switch where when you change modes you don’t get a pop. I have most of it figured out. I know that when going from FK to IK you record the rotate channels of the IK joints and input those numbers into the FK rotate channels. And for FK to IK you move the ikHandle to the end joint on the FK chain. The point where i get stuck is when dealing with the pole vector on the IK. if the pole vector is not in its default position then the switch wont work for me, i’ll still get a pop. If anyone has had success figuring this out please let me know.
Thanks…Aaron


#2

You generate whats known as a fake pole vector for the fk, for the ik pole vector to match. A locator constrained between the hand and upper arm, looking at the elbow - then a locator parented to this locator coming away from the elbow, along the direction of the first.


#3

I did an experiment just like this yesterday. I got my ik poleVector to query where my fk elbow joint is. I did not place my poleVec away from the elbow like the norm. I placed it exactly where the elbow joint is.

The more tricky part is to get the ik controls to follow the fk motion when it is in FK mode. Because if an animator has a ball constrainted to that control, and he switches over from ik to fk, sure there’s no pop, but the ball will not follow the hand…


#4

hi eerg,

i recently worked out a new arm / leg setup with switching , that exactly works as you describe it . ( except , that i use the ikHandle.ikBlend attribute for ikFk-Arms and no 3-bone-method )

FK2IK :
query rotations of the bones in IK-mode -> set Rotations for the FK_ctrls , also set the scale Values .

IK2FK:
query world-translation ( xform -ws -q -translation FKhandCtrl ) of FKCtrl and world-Space-rotation ( float $rot[] = xform -ws -q -rotation FKhandCtrl )
and set ( xform -rotation $rot[0] $rot[1] $rot[2] IKhandCtrl )

that is about the way to go …

it takes time to figure everything out , but in the end it could also be a blendable system - as you just use e.g. the FK-pose of the character and get the IK-pose .


more tricky is then , if you work work with “stretchFactor” and other stretch-attributes .

oh man , it took me , weeks and months to figure out , how to get my rig working that way …


#5

eek - do you have your 3dsmax scripts available still anywhere? I’ve just moved back over to max after years of maya and seem to remember you had a few interesting one’s that you made. Um… actually maybe I’m mistaken, were any of them made available to the public at any point?


#6

Hey Steve, yes theres a few here i posted. But they all stem from this:

Fk/IK Blended method:

I will just use bones for this, you could add shape controllers and advise you do to hold the sliders and buttons etc.
Step 0:

In the top viewport create a helpers>point object name it “root”.

Step 1:

In the top Viewport build a fk arm chain including the upper arm, lower arm and hand. With the names:

“fk_upper”
“fk_lower”
“fk_hand”

Make a helpers>point object, calling it "fk_lookat" select it and assign it a animation>constraints>position constraint and select the “fk_upper” bone.
Select the “fk_lookat” point object again and go into the motion>position>position>position constraint rollout press ‘Add Position Target’ and press the “fk_hand” bone.
Select the “fk_lookat” point object gain and assign it a animation>constraints>lookAt constraint. Select the “fk_lower” bone.

Create a new helpers>point object, show parameters rollout>display>box checked. Name it “fk_swivel” and align it both positionally and orientationally to the “fk_lookat” .
Select the “fk_swivel” point,change the ‘reference coardynates’ to ‘local mode’ and in ‘move mode’ move along the x axis the point away from the elbow. Link the “fk_swivel”
point object to the “fk_lookat” point object.

Step 2:

Copy this chain with the names:

“def_upper”
“def_lower”
“def_hand”

move it slightly down.

Step 3:

Copy this chain with the names:

“ik_upper”
“ik_lower”
“ik_hand”

Move it slightly down.

Run an ‘HI’ (history independant) iksolver from the “ik_upper” to the 'ik_hand" bones, call it “ik_control” .

Create a helpers>point object and place it away from the elbow. Call it “ik_swivel”

Select the ik handle (the blue cross at “ik_hand” ) and go into the motion panel>IK Solver Properties rollout>Ik solver Plane.
Click the ‘None’ button below ‘pick target:’ and select the “ik swivel” point object.

create a helpers>point object with the name “ik_hand_control” show>display box checked. Select the “ik_hand_control”, in the heirachy>pivot>adjust pivot rollout press ‘align to world’. Align the “ik_hand_control” point object to the “ik_hand” bone both positional and orientationally.

Select the “ik_control” handle and assign it a animation>constraints>position constraint, select the “ik_hand_control” point object.
Select the “ik_hand” bone and assign it a animation>constraints>orientation constraint, select the “ik_hand_control” point object.

Step 4:

Select the “def_upper” bone and assign it an animation>constraints>orientation constraint. Select the “fk_upper” bone. Select the “def_upper”
bone again and in the motion>rotation>orientation constraint rollout press 'Add orientation target’ and select the “ik_upper” bone.

Select the “def_lower” bone and assign it an animation>constraints>orientation constraint. Select the “fk_lower” bone. Select the “def_lower”
bone again and in the motion>rotation>orientation constraint rollout press ‘Add orientation target’ and select the “ik_lower” bone.

Select the “def_hand” bone and assign it an animation>constraints>orientation constraint. Select the “fk_hand” bone. Select the “def_hand”
bone again and in the motion>rotation>orientation constraint rollout press ‘Add orientation target’ and select the “ik_hand” bone.

Step 5:

Select the “def_hand” bone, in the modifiers panel>modifiers list assign a ‘Attribute Holder’. Select the “def_hand” bone again and open a new
maxscript>new script. Evaluate this code:

Code:
[left] [left] ikfk_ca = attributes ikfk_attribs ( parameters ikfk_params rollout: ikfk_roll ( ‘ikfk_blend’ type:#float ui:ikfk_slider animatable:true ) rollout ikfk_roll “IK-FK Options” ( slider ikfk_slider “IK-FK Blend:” range:[0,100,0] ticks:0 group “Snap:” ( button snap_fk “FK to IK” across:2 width: 65 button snap_ik “IK to FK” width: 65 ) on snap_fk pressed do ( $fk_upper.transform = $ik_upper.transform $fk_lower.transform = $ik_lower.transform $fk_hand.transform = $ik_hand.transform ) on snap_ik pressed do ( $ik_hand_control.pos = $fk_hand.pos $ik_swivel.pos = $fk_swivel.pos ) ) ) custAttributes.add $def_hand.modifiers[1] ikfk_ca[/left]
[/left]

Step 6:
Select the “def_upper” bone and go to animation>wire parameters…>transform>rotation>orientation constraint>orientation weight 0 then
select the “def_hand” bone and go to modifed objects>Attibute Holder>ikfk_attribs>ikfk_blend.

In the bottom left window type:

“100-ikfk_blend” then press the ‘<—’ button and ‘connect’.

In the top left window select the ‘orientation weight 1’ and in the bottom left window type:

“ikfk_blend” then press the ‘<—’ button and ‘connect’ and close the window.

Select the “def_lower” bone and go to animation>wire parameters…>transform>rotation>orientation constraint>orientation weight 0 then
select the “def_hand” bone and go to modifed objects>Attibute Holder>ikfk_attribs>ikfk_blend.

In the bottom left window type:

“100-ikfk_blend” then press the ‘<—’ button and ‘connect’.

In the top left window select the ‘orientation weight 1’ and in the bottom left window type:

“ikfk_blend” then press the ‘<—’ button and ‘connect’ and close the window.

Select the “def_hand” bone and go to animation>wire parameters…>transform>rotation>orientation constraint>orientation weight 0 then
select the “def_hand” bone and go to modifed objects>Attibute Holder>ikfk_attribs>ikfk_blend.

In the bottom left window type:

“100-ikfk_blend” then press the ‘<—’ button and ‘connect’.

In the top left window select the ‘orientation weight 1’ and in the bottom left window type:

“ikfk_blend” then press the ‘<—’ button and ‘connect’ and close the window.

Step 7:

Parent the “fk_upper”,“def_upper” and “ik_upper” bones to the “root” point object.
Align these three to the “root” point positionally. Align the “ik_swivel” point to the “fk_swivel” point positionally.

Also this is in no way a an advanced setup, its just here to help you get off the start post.

http://forums.cgsociety.org/showthr…ghlight=ik%2Ffk

Heres some more on the seamless snap method. Theres also the fk driven IK, but i dont like the issues of drift.

http://forums.cgsociety.org/showthread.php?t=234020&highlight=ikfk


#7

Create an empty grp(FK pole vector), snap it to the IK pole vector’s position.
Now parent constraint it to the FK Shoulder joint(or upper arm joint)

Now in the script,
duplicate the IK pole vector
select FK pole vector and the duplicate
pointConstraint
copy pos values from duplicate to the original IK pole vector
delete the duplicate

Works like magic :smiley:


#8

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.