Create expression
1. Set the new project and new scene. Set the time length long enough to playback the sequence such as 400 frames.
2. Type "sphere" in command line and press enter. It will create a new nurbs sphere.
3. Change the name of the sphere in channel box as "Ball".
4. Select the ball. Go to Window - Animation Editor - Expression Editor, run Expression Editor.
5. Type in "ScaleBallWidth" in the box of Expression Name.
6. Type "Ball.scaleX = Ball.scaleZ = time +1;" in the expression box.
You should distinguish upper and lower case correctly. Placing semicolon is important as well.
It means the end of the expression.
7. Click "Create" and playback the animation. If any error occurs, it will show in the response area next to the command line. You will see the ball expanding widely as time goes by.
Analyze expression
Above expression can be broken down as
Ball.scaleX = time+ 1;
Ball.scaleY = time+1;
Ball.scaleX : scaleX attribute of "Ball" object
Ball.scaleX = time+1 : setting the value of Ball.scaleX to time. "time" is predefined variable in maya and means the time (second) from the first frame to the current frame.
time = (Current frame - First frame) / frame per second
By setting the scaleX and Y's value as time+1, it increases continuously.
Create expression
1. Create a new scene and create a sphere. Change the name of sphere to "Balloon".
Select the sphere and go to Window - Animation Editor - Expression Editor.
Type "RisingBalloon" in the expression name box, type below expression.
if ( time <2 )
Balloon.scaleY = time;
if ( time >=2 )
Balloon.translateY = time;
Press Create and playback your animation.
Analyze expression
if ( time < 2 ) : if time is less than 2
Balloon.scaleY = time :
Balloon's scaleY increases as time. It won't increases after 2, because it is no longer affected
by if statement since time is same as 2.
if ( time >= 2 ) : if time is greater than 2
Balloon.translateY = time :
When time is less than 2, it won't move but since when time is equal to 2, the Balloon's
translateY will increase.
Frame 1 |
Frame 38 |
Frame 86 |
Reference
- Jo Sang Bum., 2002. programming with MAYA MEL & Expression. Seoul: Ahn Dae Sik
- Autodesk Maya 2011, 2010. Autodesk Maya Online Help : Introduction. [online] Available at : < file:///Applications/Autodesk/maya2011/docs/Maya2011/en_US/index.html?url=./files/GS_Introduction.htm,topicNumber=d0e1838 > [Accessed 25 February 2011].
- 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