PDA

View Full Version : 3dsmax: expression controller problem!


h4di
03-16-2011, 05:55 PM
Hi,
Having followed DVD1 rigging tutorial from CG Academy, Iíve faced difficulties with the last session where the author implements float expression controller to avoid detaching the foot from the upper bones. I donít understand why and how writing an expression would make the foot attached to the bone system.
Here, I try to explain the problem briefly:

>>If you watch this video you donít need to read all the details below. the problem is demonstrated visually. you can watch it from HERE (https://docs.google.com/leaf?id=0Bw83Zhd0BmZ8MDM3OTM2YTYtNTVjNi00NzJlLWI1NTItZDYzMjU1NzJlYzY5&sort=name&layout=list&num=50)

Ok, I have 2 hierarchy of bones. The first one is thigh and calf and the second is foot. There is an IK solver defined for the thigh and calf and the goal of the solver is linked to the knot bone of the foot rig.
The first bone in the foot rig is linked to a spline (as a controller object). You can see all the relations in the image below:

http://up.vatandownload.com/images/7uwu4egl9n5iz24odij2.jpg

As you can see, as I move the controller object the foot detaches from the upper rig. So I am going to use expression controller for the X Position track for the calf knot bone to avoid the problem.

http://up.vatandownload.com/images/vhths7pv9rbgc0xee8k.jpg

I zero out the calf knot bone controllers and then I replace the X Position track of that knot bone with a float expression controller.
I define a scalar variable and set itís value to the distance between the two points which is illustrated here.

http://up.vatandownload.com/images/qpqtoieh2mq5uhsdxm1.jpg

I define two other vector variable: th and an. I assign the th to the helper point which I put on top of the thigh bone earlier and then I assign the an to the foot knot bone and in the expression window I put this code and press evaluate:
Length (an-th)-con

http://up.vatandownload.com/images/8pjbg81epdzzlx6jf6se.jpg

The problem is disappeared and the foot move alongside with the upper rig. But I donít understand this equation and I donít understand what does it do to the X Position track of the calf knot bone.

Any help is highly requested and appreciated.
Thank you
Hadi

eek
03-17-2011, 02:49 AM
The problem is disappeared and the foot move alongside with the upper rig. But I donít understand this equation and I donít understand what does it do to the X Position track of the calf knot bone.

Any help is highly requested and appreciated.
Thank you
Hadi


So basically your controlling the length of the lower bone, using its child i.e the bone that sets the end-effector.

length (an-th)

So length() (function) gets the distance from the origin [0,0,0] to a vector. With (an-th) your taking away the position of the foot from the thigh, and getting the length from the origin to this vector. And then i guess taking this value away from 'con' which im guessing is the upper leg length.

You'r putting the expression of the x.position controller because in max the vector that runs down the length of the bone is x, and by changing the bones child position your changing the length of the bone itself. i.e

A bones length is determined by the x position value of its child.

cheers,

h4di
03-22-2011, 12:31 PM
Charles, thanks. :)
yes, reading your answer and thinking hard :)) I almost came to an understanding of how this equation works.
Following the tutorial, new problems have emerged. At the end of the tutorial the author
reaches to this one:

if ((length(an-th)-con)/2>0, (length(an-th)-con)/2, 0)

I'm struggling with this one. I think I need to know more about IK solvers and how they work.

thanks again
cheers

eek
03-22-2011, 03:03 PM
Charles, thanks. :)
yes, reading your answer and thinking hard :)) I almost came to an understanding of how this equation works.
Following the tutorial, new problems have emerged. At the end of the tutorial the author
reaches to this one:

if ((length(an-th)-con)/2>0, (length(an-th)-con)/2, 0)

I'm struggling with this one. I think I need to know more about IK solvers and how they work.

thanks again
cheers

so lets break it down - If, else, then statements in expression controllers work using commas in parenthesis. i.e

if ( condition, then do this, else do that)

The first part of the expression of the condition is if (length(an-th)-con)/2 >0) , we already know what length(an-th)-con is - Where taking away the length of the upper leg from the distance between the upper leg and ankle. But where now dividing this result by 2.

Now there's a condition here ">0" - this symbol ">" in mathematics means greater than and it returns a true or false boolean, so we can read the first part of the expression like so:

if ((the distance from the hips to the ankle) minus the upper leg length) divided by 2 is greater than zero... pass true of false

Now we move past the condition to the then and else clause - we've already set the condition part. and its result (true or false) will lead to the 'then' or 'else' part. If the condition is met the expression will continue to the 'then', else it will move to the, you guessed it 'else' part.

So lets read this again:

if ((the distance from the hips to the ankle) minus the upper leg length) divided by 2 is greater than zero then (do this) else (do that)


The 'then' clause is identical to the initial condition without returning a boolean using ">0" i.e it doesn't return a true or false flag it returns the actual value. So let read this again:


if ((the distance from the hips to the ankle) minus the upper leg length) divided by 2 is greater than zero

then

return ((the distance from the hips to the ankle) minus the upper leg length) divided by 2


Now the 'else' clause is only met if ((the distance from the hips to the ankle) minus the upper leg length) divided by 2 is NOT greater than zero so reading this fully we get:

if ((the distance from the hips to the ankle) minus the upper leg length) divided by 2 is greater than zero we

return ((the distance from the hips to the ankle) minus the upper leg length) divided by 2,

else we return zero


Basically its returning half the length of the ((distance from the upperleg to the ankle) minus the upperleg length) if this ((an-th)-con)/2) is greater than zero. Im guessing its for stretching the length of the joint.

Remember you control the length of the parent bone by moving its child down its own x position axis. Or the axis that runs the length of the bone.

CGTalk Moderation
03-22-2011, 03:03 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.