Notifications
Clear all

[Closed] Need help writing an expression

Hi guys,

I posted over on the Area Max rigging forum a few days ago but that place is a ghost town. Thought this might be the better place since it will probably involve a scripted controller. I apologize if this is should be posted somewhere else.

I'm trying to replicate this network from a Maya tutorial over to Max:

[img] http://studentpages.scad.edu/%7Ejdoubl20/images/JTDsmartBlinkFinal.jpg [/img]

The tutorial is here: [ http://studentpages.scad.edu/~jdoubl20/JTDsmartBlinks.html ]( http://studentpages.scad.edu/%7Ejdoubl20/JTDsmartBlinks.html) 
It shows how to set up an eyeball with tracking eyelids.

The main headache is the bottom lid because it needs to track the eyeball slowly whenever the eye's cornea is above the lower lid, and it needs to track the eyeball very closely whenever the cornea collides with the lower lid. To further complicate things the lid can be opened and closed which then changes that push threshold.

I wrote an expression that almost works but it runs in to the problem the author describes in the Advanced Smart Blink Step-By-Step section, point # 9. He talk's about the cornea push threshold (the point where the cornea collides with the bottom lid) cancelling out any positive movement of the lid. So basically the character can't squint.
if ( eyeRotation + corneaPush/10 > corneaPush/10 - (corneaPush + lowLid_spinner)/10,
    ((-lowLid_spinner)/10) + (eyeRotation + ( (corneaPush + lowLid_spinner) /10 )) * .90, 
    ((-lowLid_spinner)/10) + (eyeRotation + ( (corneaPush + lowLid_spinner) /10 )) * .30)
The author addresses this problem using a clamp node but I don't know how to do that in script.

I wrote a second expression that solves the squinting problem but breaks the cornea push threshold and causes the lid to jump / abruptly change values as the cornea collides with the eyelid.
if ( eyeRotation + corneaPush/10 > corneaPush/10 - (corneaPush + lowLid_spinner)/10,
    ((-lowLid_spinner * 1.9)/10) + ((eyeRotation + ( (corneaPush + lowLid_spinner) /10 )) * .90) - (corneaPush/10 * .90), 
    ((-lowLid_spinner * 1.3)/10) + (eyeRotation + ( (corneaPush + lowLid_spinner) /10 )) * .30) - (corneaPush/10 * .30)
I have a feeling that the answer is somewhere in between and will involve setting up more conditional statements but the math is starting to get really confusing.

If anyone knows the answer I would desperately appreciate it. I have started on this, run in to trouble and started over more times than I can count. Embarrassingly I have been trying to solve this off an on for more than 6 months :( I just can't crack the code.

Here is the max file with a version of each expression controller:
[ http://dl.dropbox.com/u/3850172/CGTalk/eyeRig%20lid%20expressions.max ]( http://dl.dropbox.com/u/3850172/CGTalk/eyeRig%20lid%20expressions.max) 

Thank you for any help!

2 Replies
 PEN

Hmm, don’t really have time to rip apart the MEL and see what they are doing. But in just a quick think about it and what I have done in the past you need to have the top lid reference the angle of the lower and vice versa. That value can be taken from the amount the upper or lower lid has been moved by the eye + manual control. From that you can determine how much the eye lid needs to be moved to close. That value needs to be a multiplier and not an if statement. Without doing it I’m not sure what the clamp is needed for but in Max you can use an Limit Controller if needed on the final output.

Hey Paul! It’s awesome to have you weigh in! Your website is a goldmine!

On this setup, to get the upper lid to close with the blink spinner I just instanced the bottom lid controller and stuck it in a list controller for the upper lid. Then the blink spinner gradually inverts the list weights so that when blink is at -5.0 the upper lid controller equals the instance of the lower lid controller, keeping them closed no matter what. It’s different than the way it’s done in the tutorial, maybe that’s what’s causing me the trouble with the lower lid?

The main thing I was concerned with was getting the lower lid to behave, getting it to be pushed out of the way by the cornea but still retaining the ability to squint when the lower lid spinner pushes it up past that cornea threshold. Currently the threshold seems to override the spinner once the lid and cornea meet, which keeps the lower lid from being able to slide over the cornea at all.

If I’m understanding you right I need to instead have the blink controlled by angle reference and that would solve the problems I’m getting with the lower lid behaviors?