ways to look at expressions     Time based / procedure-driven animation

Controllers / calculations for user extensions

Basic examples (review maya docs)

Ball.scaleY = Ball.scaleY + 0.1                 incrementing a value

Ball.scaleY += 0.1                                       [ +=   -=  *=   /= ]

Ball.translateX += 0.1

Conditional "IF" statements for resetting

if ( frame == 1 ) tx = 0 ;                                "==" tests equivalence

"!=" tests "not equivalent"

Two predefined variables are

"time" and "frame"

time = frame / framerate

Ball.scaleY = time + 1                                 24fps 1 frame = 0.0417

Ball.scaleY = time/5 + 1                             30fps 1 frame = 0.0333

float \$tDisp = time;

print (\$tDisp + “\n”);

Attributes controlling others

Ball.scaleY = ball.scaleX

Joint2.rz = joint1.rz                                       joints_exp.mb

One xform related to another / and with offset

Cube.scaleY = ball.scaleY

Cube.scaleY = ball.scaleY * 2

Incrementing a user-defined variable

Fundamentals book examples

bounce

bounce with friction

The standard order of operations applies to scripts in Maya.  For example, in the expression

3 + 5 * 9                                 PG 43 of MEL book

Even thought the addition takes place first in the sentence, the multiplication is performed first.
( ) [ ]

! ++ --

* / % ^

+ -

< <= > >=

== |=

&&

||

? ;

= += -= *= /=

Definition of variables

Defining PI as a variable                            float \$pi = 3.14159265

Using PI to for rolling ball / wheel            rolling_balls_exp.mb

Using sin and other functions

bouncing ball

Sin() web page

(sin(value *  frequencymultplier) * amplitude) +/- offset

Sin/cos – circling                                         spiral_out.mb

Reverse order

Abs(sin/cos)

Rolling cube                                     rolling_cube.mb

Max( ) - foot walking

L.ty = max(0,cos(time));                  simple_feet_exp.mb

L.tz = sin(time);

R.ty = max(0,cos(time + 3.1416)

R.tz = sin(time + 3.1416)

Linstep() and smoothstep()

Random functions – web page

Rand()                                                           tail_wagging_rand.mb

Noise()                                                          tail_waggin_noise.mb

Shrand()

Random direction motioni

Modulus to change direction periodically           random_travel.mb

Time offset from an object with anim curve

`getAttr –t (frame – 2) pCube1.ty`                         timeoffset_follow

EYES example from book pg 49

Creating a custom attribute:

Using the connection editor to attach to another attribute

Results in a 1 to 1 correlation

Addressing the new attribute in an expression:

Book example: Create "Ball.revolutions"  as a float from 0 to 1

Create expression as " Ball.rotateY = ball.revolutions * 360 "

MEL command to create custom attributes:
The History window output reveals two MEL commands

the "keyable" flag can be used with AddAttr

(Also can use –smx (soft max value) in addition to max)

Custom Attribute Examples –

Walking_exp_ctrls.mb

Walking_travel_ctrls.mb

Hip_blender_ctrl,mb

Fundamentals_book examples:

Unicycle

Circling

Inward spiral

Magnets

Windblownflower

Bottlebobble

Bullies