PDA

View Full Version : Help with expresions and IK


jesusguijarro
02-13-2007, 09:50 AM
Hi,

Iīm trying a expresion to work with IK but I have no success. The Ik Chain is a leg, what I want to do is when rotating tight bone picht (Bone_1) Bone_4 must move like in pose frame -1 (see picture).
It works ok with FK but when trying to acomodate the expresion to IK it seems that is not reading the change IK mades in pitch tight bone. The expresions in FK read as folllows:
Var
PercentRange([Skeleton_Bone_1: pitch],[Skeleton_Bone_1: pitch@0],[Skeleton_Bone_1: pitch@0-1])

Var_1
CycleBranchMorphFrame(Skeleton_Bone_4,Skeleton_Bone_4,motion,-1,var)

When I make the Ik chain and move the Goal the expresion doesn't works despite have change the variable var to:
Var
PercentRange([Skeleton_Bone_1:wpitch],[Skeleton_Bone_1:wpitch@0],[Skeleton_Bone_1:wpitch@0-1])

Have attached the two scenes in a zip, any help is gong to be very valued cose I don't now what to do for it to work.

Suricate
02-13-2007, 08:53 PM
Make sure that the IK is evaluated before the expressions. To do this you can use the 'IK2D' expression (instead of using the IK settings from the 'Animate' tab). That way you can exactly determine when IK gets evaluated. There's a tutorial about using the 'IK2D' expression in the docs.

jesusguijarro
02-14-2007, 12:55 PM
Hi Suricate,

The problem is that when using IK is that the expresion "percent range" driving the IK always get a value of 0 regardless of the IK applied to Skeleton_Bone_1:pitch, have tried change the Skeleton_Bone_1:pitch to Skeleton_Bone_1:wpitch and also change the ik for IK2d expresion but "pertent range" expresion donīt get the IK value from Skeleton_Bone_1:pitch. I don't now how to make it works

Suricate
02-14-2007, 03:55 PM
I had a closer look at your files now. There are a couple of things that cause problems:

1. The most important thing to note is that when accessing motion values other than the current, messiah sees only those values that are generated through keyframes. It does not see the values that are a result of expressions (since that would mean an complete evaluation of the scene on a frame other than the current, which might result in circular dependencies). Therefore [Skeleton_Bone:wpitch@0-1] is the keyframed value of the bone at frame -1, which is the same as the value at frame 0. That's why the 'PercentRange' expressions always results in 0.0. You can change that by keying the computed values of the hierarchy at frame -1.

2. Using the world rotation might lead to unexpected results, since usually a rotation in space can be expressed through many combinations of Euler angles. E.g. an heading/pitch/bank rotation of 0 degrees/110 degrees/0 degrees is the same as 180 degrees/70 degrees/0 degrees. Usually the world rotation is calculated in such a way that heading will stay in the range of -180..180 degrees and pitch will stay in the range -90..90 degrees. Therefore the value of [Skeleton_Bone_1:wpitch] will not go past 90 or -90.
For that reasons it is better if your IK chain starts with the 'Skeleton_Bone_1' bone and (this is important) that you use a pivot for that bone to zero out its rotation. Then you can use [Skeleton_Bone_1:Pitch] (the parent rotation) for the 'PercentRange' expression.

I attached a scene file with these changes. Hope that helps.

jesusguijarro
02-14-2007, 05:35 PM
Thanks a lot for the file and your help.

CGTalk Moderation
02-14-2007, 05:35 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.