Now we have keyed three joints
in the neutral position and they are now bound to "nHandControl".
While you did this, Maya pumped out valuable information
for us.
setDrivenKeyframe -cd nHandControl.Index jIndex_base.rotateZ;
setDrivenKeyframe -cd nHandControl.Index jIndex_middle.rotateZ;
setDrivenKeyframe -cd nHandControl.Index jIndex_top.rotateZ;
We are not going to do anything withthis now, but keep these
lines in the back of your head.
Continue setting up the finger. At "nHandControl.index"
= -10 rotate the joints a bit backwards
and set keys to
all of them. WRITE DOWN THE VALUES YOU GET!!! in
Notepad or somewhere because these values are
important when we want to use MEL later.
A rule of thumb is to go all the way till it looks good
and then a bit further so the animators can exaggerate it.
These are my settings.
indexCurl -10
base 16.381
middle 15.998
top 22.056
indexCurl 10
base -110.892
middle -108.836
top -81.881

OK, the indexfinger is rigged. Now let's see if we can
use the MEL to something useful here. But first a question
for you:
- "If you want to edit the rotation value of "jIndex_base"
when "handControl.index" has
a value of 10, what do
you do?
A) I open the "Set Driven Key" Window and
key the joint one more time.
B) Easy, I just run one single line of MEL code.
If your answer was A, read on. If your answer was B, well
then you already know the easier way to do this :)
Obviously Maya used the command "setDrivenKeyframe"
to set Driven Keyframes. I looked it up in the Maya
MEL command reference. ( help
MEL command reference ) and found out that the flags I have
to use was
-driverValue ( -dv ) and -value ( -v). When you want to
check if something works, use some insane values to
see the changes. If you wonder if a light is behaving correctly
with its intensity 1 boost it up to 100 or more to
get a direct feedback. Here I don't have to go crazy to
check because it will be very obvious that something
changed. I am going to try and edit "jIndex_middle's"
value when "nHandControl.index"
has a value of "10".
I write this line in my scriptEditor and run it:
setDrivenKeyframe -dv 10 -v -25 nHandControl.Index
jIndex_middle.rotateZ;
I can see that it works when I slide the nHandControl.index
value. And so can you on the image below.
Compared to the image above you can clearly see that the
angle on jIndex_middle no longer rotate
all the
-108.836 degrees,but -25
degrees.

Yes! A new era to rigging has begun :) Let's analyse what
we just did and use it to rig the middle finger.
setDrivenKeyframe -cd nHandControl.Index jIndex_middle.rotateZ;
This is the sentence originally found in the script Editor.
- "setDrivenKeyframe": Basicly
the command that tells us that we are setting a driven
key.
- "-cd": Short for currentDriver.
What this flag does is to tell Maya that she shall use
the first stated
object as the driver.
- "nHandControl.Index jIndex_middle.rotateZ":
Tells Maya to key the values of these two selected
attributes.
But our editline did not look like that. The reason is
because I don't want to depend on a selection. That's
actually the whole point with this. Therefore I need a way
to insert custom values. As you remember, my
line looked like this:
setDrivenKeyframe -dv 10 -v -25 nHandControl.Index
jIndex_middle.rotateZ;
When I looked up the command in the MEL command reference
I noticed that the way you should set this up is
setDrivenKeyframe [flags] [objects];
- "setDrivenKeyframe": We should
know what this does by now.
- "-dv": short for driverValue.
This is where we set the value of the driver.
- "-v": Short for value. This
is where we set the value of the driven
- "-cd": Short for currentDriver.You
state that nHandControl is the current driver.
- "nHandControl.Index jIndex_middle.rotateZ":
Then we list the driver first and then the driven.
With our clever brains we should be able to understand
what to do next. nHandControl still runs the show and
our next thing to rig will be the middle finger. The new
lines of code will then be:
//This is to set the neutral position
setDrivenKeyframe -dv 0 -v 0 -cd nHandControl.Middle
jMiddle_base.rotateZ;
setDrivenKeyframe -dv 0 -v 0 -cd nHandControl.Middle jMiddle_middle.rotateZ;
setDrivenKeyframe -dv 0 -v 0 -cd nHandControl.Middle jMiddle_top.rotateZ;
//This is to set the negative position
setDrivenKeyframe -dv -10-v 16.381 -cd nHandControl.Middle
jMiddle_base.rotateZ;
setDrivenKeyframe -dv -10-v 15.998 -cd nHandControl.Middle
jMiddle_middle.rotateZ;
setDrivenKeyframe -dv -10 -v 22.056 -cd nHandControl.Middle
jMiddle_top.rotateZ;
//And this is to set the positive position
(grip)
setDrivenKeyframe -dv 10-v -110.892 -cd nHandControl.Middle
jMiddle_base.rotateZ;
setDrivenKeyframe -dv 10 -v -108.836 -cd nHandControl.Middle
jMiddle_middle.rotateZ;
setDrivenKeyframe -dv 10 -v -81.881 -cd nHandControl.Middle
jMiddle_top.rotateZ;
Obviously you don't need to include the flag -cd when editing,
but the rig isn't affected by it anyway. So keep it
there to use the script as both a creation and a possible
editchart.
Now, if you're smart you'll gather all these lines for
all the fingers and put them in the same MEL file for later
editing. Let's come up with a scenario again. Scenarios
are fun :) You have rigged a monster with 10.000
fingers.... Of course you are told to correct this. The
rotation of all the middle joints are set up at "100"
and
the animation supervisor wants it to be "130"
because the animators don't feel they get freedom to
exaggerate as I talked about earlier. Instead of banging
your head against the wall you say "Give me three
minutes. " What's even more rewarding is the supervisors
face when you say a huge change like that will take
three minutes. You fire up conText or whatever textEditor
you use and replace "100" with "130".
Most editors can
replace multiple numbers, words etc. etc. with another one.
( This will not work if you have all the basejoints
at a value of 100 for instance, but since you know that
this might happen you coded all the basejoints to 101.
Stay ahead of corrections :) ) Then you load the MEL-script
into Maya and run it once. Overwrite the file and
tell the animators to try it out. They are satisfied and
you can go home to your girlfriend while these
animators are the ones working overtime with their new rig
getting into their own fights when they come home
at 11 pm. :)
|