PDA

View Full Version : IK/FK without blend move ?


MoutMout
02-08-2008, 04:43 PM
Hi cgsociety!

I'm searching how to make better rig than I do now, I work with maya 8 and I can't find how to make a IK/FK switch without a blend ( I don't want my "skin bones" to follow an IK or FK setup, I want it to rest in place even when I switch )

If anyone cans help me or tells me some tips to find this technic it'll be great and helpfull !

Thanks !

Cheers,
M0utm0ut ^^

labbejason
02-08-2008, 05:45 PM
You could probably keep your existing setup, and just incorporate IK/FK snapping options, so when you blend the arm will stay still.

MoutMout
02-08-2008, 09:29 PM
just incorporate IK/FK snapping options

I'm sorry but I did'nt find this option, I've tried in maya help file and on the web and I 've found nothing

Can you tell me more about this and I will search how it works

Thanks for your answer :)

MoutMout
02-08-2008, 10:13 PM
I've found this link but there is nothing about IK/FK snap...
http://www.jawa9000.com/Technical/fk-ik-arm/fk-ik-arm.htm#gimble
Other answers?

Please help it is for work.

Thanks

labbejason
02-08-2008, 10:20 PM
Well, it's not built in.. You have to script it. You would have two buttons, one to snap your IK chain to the FK, and FK to IK. So before you blend, you would just snap to the appropriate chain, and your arm won't move while you blend.

MoutMout
02-09-2008, 04:07 PM
Thanks i get it but the point is I don't know melscript, I mean, I used it for simple thing but for do this technic it seems to be not simple lol

If anyone can halp me again thx and thanks a lot for the advices labbejason :)

prettyh8machine
02-13-2008, 05:32 PM
The problem with switching without moving is a classic problem of cyclic dependency. Therefore, you can't really set it up in the rig to automatically stay in place while being able to switch only using utility nodes etc. unless there's some sort of bi-directional constraining process used (which I'm yet to study). For now, as mentioned above, the best way clearly is to write mel routines to snap from one mode to another. The code is rather simple. I'll post it as soon as I make a small UI for it because sending you a piece of code without any interface will probably confuse you a bit. I wrote it for testing purposes. If you're interested and in a hurry, I can paste my script over here and you can change it around a bit to use for our own purposes.

Cheers

MoutMout
02-13-2008, 08:40 PM
Hey thanks a lot dude!

I was thinking that this thread gonna die soon but it wont
Sure it'll help me a lot if you can explain this here...so i'm waiting for your answer and thx again!

:bounce:

prettyh8machine
02-13-2008, 09:17 PM
Lol. No dude its not dead. Just gimme some time and I'll post it for you.

Cheers

MoutMout
02-16-2008, 12:34 PM
lol...ok I'm waiting for, thx!

prettyh8machine
02-17-2008, 01:56 AM
Ok dude, I'm attaching a sample FK/IK arm that I had from a test I did a few months ago. It is definitely not an ultimate FK/IK arm but its got a few things like IK/FK stretchy and forearm twist etc. I don't know if you needed it or not but I didn't have time to remove the functionality as such. I'm just sending it to you as it is.

Also, I'm pasting this small MEL script that you'll just have to source and a small window with two buttons will appear. Those buttons should be used whenever you wanna switch modes. Again, a very temporary sort of code just to show you how can one do it. Also, if you need to use it for your Arm, you'll have to change a few names as for the sake of this test, I just hardcoded a few names.

Here's the maya 8.5 file (Just right-click and save target as): http://cgcrap.com/upload/FK_IK_Arm_Test_01.ma

It's in ascii format so in case you wanna run it in 8.0, just open it up in a textpad and change the version requirements to 8.0 in the top few lines.

Here's the MEL script:


proc switchToFK()
{
setAttr "arm_ctrl.switchTo" 0;
$oc1 = `orientConstraint -offset 0 0 0 -weight 1 shldr_ik shldr_ctrl_fk`;
$oc2 = `orientConstraint -offset 0 0 0 -skip x -skip z -weight 1 elbow_ik elbow_ctrl_fk`;
$oc3 = `orientConstraint -offset 0 0 0 -weight 1 wrist_ik wrist_ctrl_fk`;

$scale = `getAttr armLen_cnd.outColorR`;
setAttr shldr_ctrl_fk.stretch $scale;
setAttr elbow_ctrl_fk.stretch $scale;

delete $oc1 $oc2 $oc3;
select -cl;
}

proc switchToIK()
{
setAttr "arm_ctrl.switchTo" 1;
$pc1 = `pointConstraint -offset 0 0 0 -weight 1 wrist_ctrl_fk wrist_ctrl_ik`;
$rot = `xform -q -os -ro wrist_ctrl_fk`;
xform -os -ro $rot[0] $rot[1] $rot[2] wrist_ctrl_ik;

$tempvec = `duplicate poleVector`;
setAttr ($tempvec[0]+".translate") 0 0 0;
setAttr ($tempvec[0]+".rotate") 0 0 0;

$tempfkctrl = `duplicate shldr_ctrl_fk`;
setAttr -l false -k true ($tempfkctrl[0]+".tx");
setAttr -l false -k true ($tempfkctrl[0]+".ty");
setAttr -l false -k true ($tempfkctrl[0]+".tz");

makeIdentity -apply true -t 0 -r 1 -s 0 -n 0 $tempfkctrl[0];
parent -w $tempfkctrl[0];
parent $tempvec $tempfkctrl[0];
setAttr ($tempvec[0]+".translate") 0 0 0;

orientConstraint -offset 0 0 0 -weight 1 shldr_ctrl_fk $tempfkctrl[0];
pointConstraint -offset 0 0 0 -weight 1 $tempvec poleVector;
orientConstraint -offset 0 0 0 -weight 1 $tempvec poleVector;

delete $pc1 $tempfkctrl[0];
select -cl;
}

string $ui_wind = `window -title "Snap IK<->FK" -rtf true`;
columnLayout -adj true;
button -label "IK->FK" -c "switchToFK";
button -label "FK->IK" -c "switchToIK";
showWindow $ui_wind;



Just copy paste and source it (I hope you know how to source a MEL script in Maya). Please make a careful note of how I'm using the names of the joints/controls etc. in the script. If you wanna make it run on your own rig, you'll have to change the appropriate names. I should've commented it heavily but since I wrote it in a hurry just for the demo purposes, I didn't bother to. I'll try and post the details of what exactly I'm doing in the MEL in case its not too obvious. Let me know if the file I'm sending to you doesn't work with this script or some bug comes up. I quickly checked it again and found it working rather fine at my end but then again, I didn't test it thoroughly. Some minor bug might come up..do report me back in that case.

Cheers

CGTalk Moderation
02-17-2008, 01:56 AM
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.