Autodesk Maya Tutorial: Mastering Set Driven Key for Advanced Rigging
Autodesk Maya Tutorial: Mastering Set Driven Key for Advanced Rigging
Welcome back, animators and riggers! I'm Prof. Dr. Zeeshan Bhatti, and today on Zeeshan Academy, we're diving into one of the most powerful and versatile tools in the Maya rigging artist's toolkit: Set Driven Key (SDK).
If you've ever wanted to create complex, intuitive relationships between attributes—like having a character's brow furrow automatically when they raise their eyelids, or building a clean control panel for facial expressions—then this tutorial is for you. We'll not only learn how to use SDKs to build a simple facial rig but also how to create a custom GUI to control it all, using the very MEL scripts you provided.
What is a Set Driven Key?
Forget the traditional concept of keyframing animation over time. A Set Driven Key establishes a relationship where the value of one attribute (the "Driver") directly controls the value of another attribute (the "Driven").
Think of it like a gear system:
Driver: The gear you turn.
Driven: The gear that turns as a result.
In our case, we'll create a slider that drives the rotation of a character's jaw bone. This allows for non-linear, customizable control that is essential for sophisticated character rigs.
Part 1: Building a Jaw Rig with Set Driven Key
Let's start with a practical example: opening and closing a character's mouth.
Step 1: Create the Control and the Geometry
Create a simple polygon cube. Scale it to resemble a head. This is our "Head_Geo".
Create a NURBS circle (Create > NURBS Primitives > Circle). This will be our control. Name it "Jaw_CTRL".
Place the Jaw_CTRL in front of the face. Freeze its transformations (Modify > Freeze Transformations).
Step 2: Create the Jaw Joint
Switch to the Rigging menu set.
Create a joint (Skeleton > Create Joints). Click once for the root (at the pivot of the head) and again near the bottom of the "mouth" for the jaw tip. Press Enter. Name it "Jaw_Joint".
Parent the Jaw_Joint to the Jaw_CTRL (Select Jaw_Joint, then Shift-select Jaw_CTRL, press p).
Step 3: Skin the Geometry
Select the Jaw_Joint, then Shift-select the Head_Geo.
Go to Skin > Bind Skin > Smooth Bind. Now, when you rotate the joint, the geometry should deform.
Step 4: The Magic - Setting the Driven Key Now, we'll make the control's translate Y drive the jaw's rotation.
Open the Set Driven Key window: Animate > Set Driven Key > Set...
Load the Driver:
Select the Jaw_CTRL.
In the SDK window, click Load Driver.
On the right, you'll see its attributes. Select translateY.
Load the Driven:
Select the Jaw_Joint.
In the SDK window, click Load Driven.
On the right, select the rotateX attribute (assuming this is the axis that opens the mouth).
Set the First Key (Mouth Closed):
Ensure the Jaw_CTRL is at its original position (translateY = 0).
Ensure the Jaw_Joint is not rotated (rotateX = 0). This is the closed mouth state.
In the SDK window, click Key. You've set the first relationship: translateY 0 drives rotateX 0.
Set the Second Key (Mouth Open):
Move the Jaw_CTRL upward on the Y-axis (e.g., translateY = 5).
Rotate the Jaw_Joint on the X-axis to open the mouth (e.g., rotateX = 45).
Click Key again.
Step 5: Test Your Rig! Now, slowly move the Jaw_CTRL up and down. The jaw should open and close smoothly. You've just created your first Set Driven Key rig!
Part 2: Building a Custom Control GUI with MEL
Manipulating controls in the viewport is great, but for a clean, professional rig, a custom GUI is unbeatable. Let's use your scripts to build one.
Step 1: Create the Main Window We'll start by creating the window and its basic layout.
mel
// Create the main window for our facial rigwindow-title"Zeeshan Academy - Facial Rig"-widthHeight300400;// Define a simple column layout to stack our controlscolumnLayout-adjustableColumn true;// Add a title texttext-label"Facial Control Panel"-font"boldLabelFont";
Step 2: Add Control Sliders Let's add a slider for our jaw control. The attrFieldSliderGrp command is perfect as it gives us a slider, a field, and a label.
mel
// Create a slider for the Jaw controlattrFieldSliderGrp-min0-max10-columnWidth32070100-attribute"Jaw_CTRL.translateY"-label"Jaw Open"jawSlider;
-min/-max: Defines the slider's range.
-columnWidth3: Sets the width for the number, slider, and field.
-attribute: This directly links the GUI element to our control's attribute in the scene! This is the most powerful part.
// Add some spacetext-label"";// A regular button to select the jaw controlbutton-width130-height25-label"Select Jaw CTRL"-annotation"Selects the Jaw Control"-command"select -r Jaw_CTRL";// A symbol button for a hand control (using a placeholder image)symbolButton-image"sphere.xpm"-command"select -r Hand_CTRL"-annotation"Select Hand CTRL";
The -command flag runs a MEL command when pressed. Here, it's a simple select command.
Step 4: Add a Checkbox for System Switching For more complex rigs (like IK/FK switching), a checkbox is ideal.
mel
// Add more spacetext-label"";// A checkbox for an IK/FK switchcheckBox-label"IK / FK Switch"-width130-height19-annotation"Switch between IK and FK controls"-onCommand"setAttr IK_FK_CTRL.switch 1"// Command when checked-ofc"setAttr IK_FK_CTRL.switch 0";// Command when unchecked
Step 5: Show the Window Finally, we need to display the window we've built.
mel
// Show the completed windowshowWindow;
Putting It All Together: Your Final MEL Script
Here is the complete script you can paste into the Maya Script Editor (make sure to be in the MEL tab) and execute.
mel
// Check if window exists and delete it to avoid errorsif(`window-exists facialRigWindow`) deleteUI facialRigWindow;// Create the main window for our facial rigwindow-title"Zeeshan Academy - Facial Rig"-widthHeight300400 facialRigWindow;// Define a simple column layout to stack our controlscolumnLayout-adjustableColumn true;// Add a title texttext-label"Facial Control Panel"-font"boldLabelFont";// Create a slider for the Jaw controlattrFieldSliderGrp-min0-max10-columnWidth32070100-at"Jaw_CTRL.translateY"-l"Jaw Open" jawSlider;// Add some spacetext-label"";// A regular button to select the jaw controlbutton-w130-h25-label"Select Jaw CTRL"-ann"Selects the Jaw Control"-c"select -r Jaw_CTRL";// A symbol button for a hand controlsymbolButton-image"sphere.xpm"-c"select -r Hand_CTRL"-ann"Select Hand CTRL";// Add more spacetext-label"";// A checkbox for an IK/FK switchcheckBox-label"IK / FK Switch"-w130-h19-ann"Switch between IK and FK controls"-onc"setAttr IK_FK_CTRL.switch 1"-ofc"setAttr IK_FK_CTRL.switch 0";// Show the completed windowshowWindow;
Conclusion: You Are Now a Driver Master!
Congratulations! You've not only learned how to create intuitive rigging relationships with Set Driven Key but also how to build a professional-looking control panel using MEL. This combination is the foundation of creating robust, user-friendly character rigs that animators will love.
The principles you've learned here can be expanded to rig entire faces—where one slider could control the corners of the mouth, the cheeks, and even create nose wrinkles all at once.
For a visual walkthrough of this entire process, don't forget to check out the detailed video tutorial on the Zeeshan Academy YouTube channel!
Following are few quick scipts to create MEL GUI components:
create a windowwindow;
// define the layout of controls added
// to the window.columnLayout;
// create some texttext -label "hello world";
// show the window we last createdshowWindow;
sir i am using maya 2014. but there is no property editor. how can i find it? plz help me.
ReplyDelete