1) Create a Simple Expression in MAYA
- Insert two objects in the scene (e.g. polySpheres) and name the two
objects "ball_1" and "ball_2"
file -f -new;
DisplayShaded;
polySphere -name "ball_1";
move -r 10 0 0;
polySphere -name "ball_2";
select -cl;
- Open the Expression Editor
- Create a new expression like the following and press the Create-Button.
Make sure the new expression is named.
ball_2.translateY= ball_1.translateX;
- Move "ball_1" interactivly in x-Direction - "ball_2"
will follow the movement in y-Direction
|
2) Create a Conditioned Expression
Expressions are written in MEL. All known methods of procedural proamming
can as well be used within the expression editor
- Open again the expression editor
- Set the Select-Filter to "By Expression Name" and than select
the old expression
- Change the old expression to
- Move the other ball interactivly
|
3) Mix procedural Programming and Expressions
Expressions can call previously defined procedures and functions like
any other cammand:
- add a third ball to the scene
polySphere -name "ball_3";
select -cl;
- open the script editor and define the following procedure.
proc kickBall() {
int $counter= 0;
int $actualTime= `currentTime -q`;
for($counter= 0; $counter < 25; $counter++) {
float $oldZ= `getAttr ball_3.translateZ`;
setAttr ball_3.translateZ ($oldZ + 0.5);
currentTime -e $actualTime;
}
}
-
open the expression - editor and add the following expression
- move the first ball by setting a key-frame animation
|