smallarrows.GIF
titlebar_image

Expressions and Set Driven Key

Expressions

List of Mel commands
Go to Help->Maya Scripting Reference->MEL Command Reference



Add expressions to a channel
Select Object
Select the channel to add an expressionto in the Channel Box (ie. Translate Z)
Select Edit->Expressions from the Channel Box
Type in the code under Expression:
Hit Create or Edit



Wheels on a car  apply to the wheel rotate in z channel
rz =  car.tx /   (2*3.1416)  *  1   *   360
wheel  car            pi        wheel size     1 rotation
You need an object named car for this to work. When car moves in the X axis the wheel spins in Z.



Windshield wipers apply to the wiper rotate in x channel
rx =   (sin  (.9  *  time) *  45) +   10
wiper  sine  speed   time   degree  offset for position



Volumetric squashing for a ball
apply to the ball scale in X channel  sx = 1/sy
apply to the ball scale in Z channel  sz = 1/sy
X and Z change when you move the object in the Y axis.



Start an Expression at a Certain Frame
output yes if frame is greater than 20, uses backward single quote (same key as "~")

$c = "no";

if (`currentTime -query` > 20) {
    $c = "yes";
}
print $c;



Embedded Sin Waves for a Random Effect
ty = (sin(time)*(sin(time*.2)+.1))+1;



Use noise for a random effect
ty = noise(time);



:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Set Driven Key
This is similar to expressions, except Maya writes the expression for you.
Go to the Animation section of Maya
animation_module

Create two shapes

Key->Set Driven Key->Set...
Select the controller shape

Click Load Driver Button in Driven Key window

Select the other shape

Click Load Driven Button in Driven Key window

Select both shapes

Select the channels you would like to control
Driver Translate x
Driven Rotate x for example

Click key Button in Driven Key window, this establishes the neutral position

Translate, Rotate, etc. the two objects

Select both objects

Click key Button in Driven Key window, this establishes the neutral position

You could use this to create control handles for your IK skeleton


smallarrows.GIF

© 1988-2024 36 years