PDA

View Full Version : Switch IK/FK using selection?


Malkalypse
04-05-2012, 07:44 PM
I want to try something out, but can't quite figure out what I need to do to make it work.

I have an IK chain setup on a simple leg, and would like to be able to enable/disable it based on whether specific bones are selected. For example, if I select part of the foot, the IK chain would be set to enabled, but if I select the thigh or calf, it would be turned off.

What do you think? Is there anyone out there who can tell me how to accomplish this?

denisT
04-05-2012, 11:40 PM
I want to try something out, but can't quite figure out what I need to do to make it work.

I have an IK chain setup on a simple leg, and would like to be able to enable/disable it based on whether specific bones are selected. For example, if I select part of the foot, the IK chain would be set to enabled, but if I select the thigh or calf, it would be turned off.

What do you think? Is there anyone out there who can tell me how to accomplish this?

let me ask you first. do you think it's something simple or not?
you have to understand that this kind of task has to use a callback or when construct...

Malkalypse
04-06-2012, 12:17 AM
Yeah, I kind of got that impression. I was hoping initially that I might be able to wire it, but the IK Solver enabled state is not wire-able.

I went as far as trying to set up a general callback using "when select $ changes..." but I keep getting the error "Runtime error: Change handler setup requires a MAX object or MAX object collection, got: undefined" and it seems to me that a script that will fail just because nothing in the scene is currently selected can't possibly be very stable.

So what are some of my other options here?

denisT
04-06-2012, 02:14 AM
i see the only one solution for your case. it's the using of the when construct. i would do it with a CA assign to the start or the end bone of the IK chain.
the CA has to create a handle on create and load events. it's a handle to when select change. we have to capture any selection change of every bone of our IK chain. depending on what bone was selected we will set IK enabled to ON or OFF.
i don't say it's the right idea but that's the only way how to handle the event.

Malkalypse
04-06-2012, 05:49 AM
After some consideration, I've decided it's not worth the trouble. Not because it would be a pain in the @$$ to do (which it would), but because the results of turning the IK system on and off during an animation are pretty horrendous.

I'll just use a blended system after all. :rolleyes:

denisT
04-07-2012, 03:30 AM
I'll just use a blended system after all. :rolleyes:
i'm not a big fan of ik/fk blended system. it's like carrying two near-empty trunks and changing things between them on the run when you can carry only one and change a hand.

Malkalypse
04-07-2012, 03:44 PM
What kind of system do you prefer? Pseudo FK?

denisT
04-07-2012, 04:34 PM
What kind of system do you prefer? Pseudo FK?
i'm using a simple ik/fk system, and standard ik solvers. the only thing that i added it's my own ui to toggle ik and fk.
when you switch from ik to fk you have to align fk bones to positions at the moment of switch, and set transform keys.
when you switch from fk to ik you have to snap ik controls to match fk bones position, and set transforms keys.
max doesn't do it automatically, so i need my own ui. usually it's a custom attribute added to main ik control.

mrfred
04-07-2012, 09:54 PM
hmmm interesting just a question tho: How do you align the IK swivel angle with the FK rotation?


The rest is as far as I know is pretty straight foward ( unless i'm totally wrong)

denisT
04-07-2012, 10:27 PM
hmmm interesting just a question tho: How do you align the IK swivel angle with the FK rotation?
The rest is as far as I know is pretty straight foward ( unless i'm totally wrong)
i don't use the swivel angle directly. i'm using Vector_Handle_Target. and it's not very difficult to get its position if you know that it must be on the same plane as the ik-chained bones. to get the plane you can use 3 points - startjoint, endjoind, and the middle one. the other way is to get plane's normal as a cross product of bones directions.

mrfred
04-07-2012, 10:46 PM
oops the Vector_Handle_Target is actually what I meant and after thinking about it I came up with pretty much what you said about the 3 joints plane axis and that the target will be on that plane's axis.

too bad that aligning the target on the FK mid joints and pushing it out wont work :/ it would've been too easy :P

I'll try to script that later on this weekend

mrfred
04-08-2012, 07:01 PM
after adding a mesh select modifier ( and stealing this idea from another post :rolleyes: ) and manually created a 3point plane (start,mid,end Ik joint) and attached the the vertex to the FK controller using linked Xform
I came up with:


VertPos= getvert $Plane001 2
$Ctrl_L_UpVectorKnee003.transform = translate (matrixFromNormal (getNormal $Plane001 2)) VertPos
in coordsys #local move $Ctrl_L_UpVectorKnee003 [-10,0,0]
$Ctrl_R_Ik_hand.transform= $Ctrl_R_Fk_hand.transform


It seems to be working fine :) Im using the vertex normal ( the one located in the elbow)
to align my target and push it out after.

CGTalk Moderation
04-08-2012, 07:01 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.