27 February 2011

Creation Expression VS Runtime Expression

You can apply creation expression and runtime expression to the particles. It can be used separately and both together at the same time. If you connect expression to ordinary object, you can set expressions to each different attributes, however, you can set creation expression and runtime expression to only one particle bearing no relation to attribute.



Creation expression evaluated only once for each particle when particle is born. If particles came out from emitter, these particles won't be affected by the expression after they born.

1.  Create new scene. Select Particle - Particle Tool - Option box. Check Creat particle grid. Click and drag to make particle on to the top view. Press Enter.


2.  Go to the particleShape node and scroll down to Add Dynamics Attribute. Click Color and add Per Particle Attribute.


3.  Right mouse button click on new RGB PP attribute box and select Creation expression. Enter below expression.

    particleShape1.rgbPP = <<rand(1), rand(1), rand(1)>>;



4.  Playback the animation. particle's colours look all same in frame 1, 10, 21. This is because the expression evaluated once at the particle birth.

Frame 1

Frame 10



































Frame 21




















Runtime expression evaluated at least once per particle per frame but not at particle birth. For the same instance as creation expression, particles from emitter will be affected by the expression
even after their birth.

1.  Create new scene and repeat 1 and 2 as above example.

2.  Right mouse click on to the RGB PP attribute box and click  
     Runtime expression before dynamics. Enter below expression.

     particleShape1.rgbPP = <<rand(1), rand(1), rand(1)>>;


3.  Playback the animation. You will see the colour of particles changes each every frames.




Creation expression and Runtime expression using at the same time

1.  Go to the rgbPP attribute of above runtime expression example. Right mouse click the box next to the RGBPP and select creation expression. Enter the below expression. Create.

     particleShape1.rgbPP = <<1, 1, 0.2>>;



2. Now the particle RGBPP node has two expressions which are Runtime expression before dynamics and Creation expression. Playback the animation. At the frame 1, all particles will be yellow. After frame 2, particles' colour will change every frames.


Frame 1

Frame 10
Frame 21

















































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].
  • Marc-André Guindon., 2005. Learning Maya 7 : The Special Effects Handbook. Unknown: Sybex

No comments:

Post a Comment