Ball.rotateZ = sim(time) * $magnitude + 6;
Ball : Object name
The object name which is affected by this expression. Object means all exist light, camera, locator, shader, model in a scene.
rotateZ : Attribute name
The name of the attribute affected by this expression. Like rotateZ , there are attributes of object as translateX or scaleY. Attribute name can be seen as "Object.Attribute".
= : Assignment Operator
This is same as math. This operator assigns the attribute the result of the statement on the right side of =. Ball.rotateZ receives the value of the statement sin(time) + 6.
Sin : Function
This is the function that maya has. Function returns a special value by an entry called "argument". In this example, the argument is time. An argument places in the brackets (e.g, sin(time)) and if there are 2 or more arguments, they distinguished by ','.
In this example, function Sin gets the argument Time and returns the value. When time is 0, the function returns 'sin(0)=0'. When time is 90, the function returns 'sin(90)=1'.
time, $magnitude : variable
A variable is like a place saves a changing value. You can assign a value to a variable or read a variable's value.
The 'time' is a predefined in maya, which has the animation time at the current frame. You can red but not set the value these kind of predefined variable.
'$magnitude' is defined by user, you wouldn't know what value it has by only this example. You can read and set the value for these kind of variable and the name should be begin with '$'.
*, + : Arithmetic Operator
An operation such as +, -, *, / or < (less). Apart from arithmetic operator, there is Logical Operator which operates AND, OR, NOT.
6 : Constant
An unchanging number which means 'number'.
; : Terminator
This is very VERY important. When you forget this to put in the end of statement, it occurs an error. Because, without semicolon, the programme doesn't know where is the end of statement. You MUST end each statement with a semicolon. This rule affects to other programming like C / C++ as well.
+ Additional Element
//, /*~*/ : Comment
You can add comments to your expressions to explain the purpose. The maya programme ignores the following comments when you put '//'.
If it is a single line :
If (frame == 0) Ball.scaleY=5; // initialization
If it is a multi line :
/*
This is an example of multi-line comments
Blah blah blah
*/
Reference
- Jeon Gye do, 2000. MEL 4 Artists. [online] Available at: <http://gyedo.pe.kr/zbxe/mayaExpression> [Accessed 25 February 2011]
No comments:
Post a Comment