PDA

View Full Version : FK/IK seamless switching in maya


KFrigault
02-06-2006, 04:34 AM
I would like to create a leg set up that would allow me to switch from IK to fk and back again seamlessly. What I am trying to acheive is have the FK joints to follow the IK joints when moving the IK control so that when I switch form IK to FK the leg is already in position. I also would like the reverse.

I have had limited success and all the tutorials on the web seem to have the same result. When switching from FK to IK you have to position the IK control to the FK joints, what I would like to avoid this step by having the Ik follow the FK and vice versa. I know it's possible just not the how.

Goon
02-06-2006, 06:06 AM
why would that be better?
If the fk bones aren't in use, it doesn't matter where they are, it only matters that they are matched to the ik position at the time of the transition. It just seems that you'd be adding unneccessary calculations.
also, i've never seen any tutorials on a ikfk switching solution that doesn't rely on a simple blend. can you post the link?

also, while I realize you are looking for an instantaneous transition between the two, by having one follow around the other, it makes a blend between the two across several frames impossible because of cycling issues. I'm not sure in what cases that would be useful, but it might come up, particularly if the animator deletes or shifts keys pertaining to the transition

eek
02-06-2006, 06:39 AM
I posted a max script on this forum around a year ago. That did seamless ik/fk snapping - it had pinning too. The issue arose changing keys afterwards, it became really hard to tweak, and not intuitive for the animator. You hit a button its ik, you hit it again its fk, you could change the length of the blend but it still had key problems. Its based on the 3 bone setup, but basically aligns one chain to the other then flips the blend in two frames.

Im looking into keith lango's fk driven ik, it seems pretty nice to setup, the only issue i see is drift. But that can be fixed, pretty easyish.

eek

Goon
02-06-2006, 07:05 AM
Im looking into keith lango's fk driven ik, it seems pretty nice to setup, the only issue i see is drift. But that can be fixed, pretty easyish.
eek

Could you post the link for that, if there is one? Doesn't seem to be on his site
thx

eek
02-06-2006, 07:20 AM
hey Goon,

Theres no pics, it was just what Keith and Mark where talking about, in a thread here in 2004. Basically you just drive an ik chain with fk controls, its one chain basically with a floating heirachy. This why you get the problem with drift as if the ik handles moves off the fk driver (as it will), you need a way to bring it back. This is not hard to do if you basically ramp the handle back to 0,0,0 because its under a parent. So you just make a slider that ramps it back from its current position to base. something like a = a-b for position space.

What i was thinking is when the ik drifts off, you ramp the fk rotation to the ik handle postion and the ik to 0 0 0. Its easy with the ik, but ramping the fk back to the ik position maybe a little more difficult as i need rotation data, its easy in the fact that you can use slerp() In max you can use ExTm to expose angles and floats, but in maya i dont know. Also i dont know if its in local or world space - i always get these mixed up.

eek

steveblake
02-06-2006, 12:43 PM
Try jsIKFKsnap (http://www.highend3d.com/maya/downloads/mel_scripts/animation/3101.html) - which works very well with a standard 3 chain setup.

Here's the orginal CGCHAR thread. (http://www.cgchar-animation.com/forum/index.php/topic,2938.0.html) ..and the beginning of a script Javier was writing at the time...


"i did this simple script that sets FK keys based on IKs position, so u can pose your character with IK and run the script and itll set correct FK keys and zero the IK translation. of course this is working only on the example scene Keith posted but it can easily be changed. this is more of an idea rather than final product. also it needs some more code to make it work when arm is part of bigger hierarchy."

//////////////////////////
proc FKkey(){
$up = `xform -q -ro up_arm`;
$lo = `xform -q -ro lo_arm`;
$hand = `xform -q -a -ws -ro handIK_FK_CTRL`;
move -a -os 0 0 0 handIK_FK_CTRL;
rotate -os $up[0] $up[1] $up[2] upArm_FK_CTRL;
rotate -os $lo[0] $lo[1] $lo[2] loArm_FK_CTRL;
rotate -ws -a $hand[0] $hand[1] $hand[2] handIK_FK_CTRL;
setKeyframe -at rotate upArm_FK_CTRL;
setKeyframe -at rotate loArm_FK_CTRL;
setKeyframe -at rotate handIK_FK_CTRL;
}
FKkey;
///////////////////////////////

Here you go: (FK Snap)
I used Kustaa's script as a base for the snap FK..

proc snapFK(){
int $theTime = `currentTime -q`;
currentTime -e ($theTime-1);
setKeyframe -at rotate upArm_FK_CTRL;
setKeyframe -at rotate loArm_FK_CTRL;
setKeyframe -at rotate handIK_FK_CTRL;
setKeyframe -at translate handIK_FK_CTRL;
currentTime -e $theTime;
$up = `xform -q -ro up_arm`;
$lo = `xform -q -ro lo_arm`;
$handR = `xform -q -a -ws -ro handIK_FK_CTRL`;
$handT = `xform -q -a -ws -t handIK_FK_CTRL`;

move -a -os 0 0 0 handIK_FK_CTRL;
rotate -os $up[0] $up[1] $up[2] upArm_FK_CTRL;
rotate -os $lo[0] $lo[1] $lo[2] loArm_FK_CTRL;
rotate -ws -a $handR[0] $handR[1] $handR[2] handIK_FK_CTRL;
setKeyframe -at rotate upArm_FK_CTRL;
setKeyframe -at rotate loArm_FK_CTRL;
setKeyframe -at rotate handIK_FK_CTRL;
setKeyframe -at translate handIK_FK_CTRL;
}
snapFK;

ps - I've also dug up Keith's setup - hope he doesn't mind me posting it here...

Goon
02-06-2006, 07:05 PM
sweet! thanks eek and steveblake.

KFrigault
02-06-2006, 11:06 PM
Thanks for all the info. This show help me out quite a bit

CGTalk Moderation
02-06-2006, 11:06 PM
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.