STEP-BY-STEP : EXPRESSIONS IN MAYA

 

1) Create a Simple Expression in MAYA

  1. 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;

  2. Open the Expression Editor



  3. 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;



  4. 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

  1. Open again the expression editor

  2. Set the Select-Filter to "By Expression Name" and than select the old expression



  3. Change the old expression to



  4. Move the other ball interactivly

 

3) Mix procedural Programming and Expressions

Expressions can call previously defined procedures and functions like any other cammand:

  1. add a third ball to the scene

    polySphere -name "ball_3";
    select -cl;

  2. 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;
        }
    }
    
  3. open the expression - editor and add the following expression


  4. move the first ball by setting a key-frame animation

 

This website has been archived and is no longer maintained.