MEL is the acronym for Maya Embedded Language, it is the programming language that translate Maya’s Graphical User Interface (GUI).

Expressions are MEL commands that are implemented in the Expression Editor, and are calculated at every frame. A valuable tool, it is easily one of the most powerful features that Maya has to offer.

Tip: By default, all constraints/nodes are evaluating. When working with Expressions, use the Evaluate All/Disable All (EnableAll; DisableAll;) options along with Interactive Playback (InteractivePlayback;) for debugging/troubleshooting.

A weighted character mesh, deformed only by joints through the use of Expressions.

The mesh shown is weighted to a max of 4 influences per vertex. See below images for the full body expression script used, or here for the posing demo, and the Python script/tool used in the scene.

Main considerations:
– as the hand rotates/twists, the mesh going up the arm has diminished twists based on the hand rotation value (forearm, biceps)
– as the forearm bends inward, the elbow pulls back to have a sharper point
– as the arms are stretched forward, the back/shoulder blades are pulled back so as not to cave in, and the chest is pulled forward and inward
– as the arms are stretched back, the back/shoulder blades are inward, and the chest is pulled outward and towards the back
– as the arm is raised overhead, the armpit comes into the body, and the shoulders/traps keep shape coming inward to the neck
– belt strap deformation to accommodate rotations in the arm, shoulder, and chest/back/armpit areas
– as the body twists, the waist area has diminished twist values
– as a leg is raised, the pack around the belt transforms up and rotates outward

Get the song here.

An example of using more complex MEL script procedures in the Expression Editor to create more powerful deformations.
The mesh shown is weighted to a maximum of 3 influences per vertex. Below are the procedures for finding the distance between two vectors, and how to get the length ratio between 3 vectors (when paired with the first procedure).

///// Get the distance between 2 vectors /////

global proc float getDistance(string $startPointName, string $endPointName)
{
vector $startPoint = `xform -query -worldSpace -translation $startPointName`;
vector $endPoint = `xform -query -worldSpace -translation $endPointName`;
$distance = $startPoint – $endPoint;
return $distance;
}

///// Get the length ratio between 3 vectors /////

global proc float getLengthRatio(string $pointOne, string $startPoint, string $pointTwo)
{
float $lengthSideA = getDistance ($pointOne, $startPoint);
float $lengthSideB = getDistance ($startPoint, $pointTwo);
float $lengthSideC = getDistance ($pointOne, $pointTwo);

float $lengthSideAB = $lengthSideA + $lengthSideB ;

float $lengthRatio = $lengthSideC / $lengthSideAB ;
return $lengthRatio;
}

A few more examples of using simple MEL commands/scripts in the Expression Editor to create dynamic deformations.

The meshes shown are weighted to a maximum of 3 influences per vertex. Below are example expressions to create the counter-twists, and mirroring animations.

/////// Shoulder muscle twists /////////

LeftShoulderTwist.rotateX = LeftArm.rotateX * -.75;
RightShoulderTwist.rotateX = RightArm.rotateX * -.75;

/////// Hip/Thigh muscle twists /////////

LeftLegTwist.rotateX = LeftLeg.rotateX * -.75;
RightLegTwist.rotateX = RightLeg.rotateX * -.75;

/////// Mirror the rotatation values on the left leg over to the right leg /////////

RightLeg.rotateX = LeftLeg.rotateX*-1;
RightLeg.rotateY = LeftLeg.rotateY*-1;
RightLeg.rotateZ = LeftLeg.rotateZ;

An example tool window developed in MEL.

See below images for the complete tool script.