2010

Table Of Contents
To create a runtime expression
1 In the Per Particle (Array) Attributes section of the Attribute Editor,
right-click the rgbPP box and select Runtime Before Dynamics Expression
from the pop-up menu.
2 Enter this runtime expression:
BubblesShape.rgbPP = sphrand(1);
3 Click the Create button to compile the expression.
4 Play the animation.
The particles flicker in random colors as the animation plays back. The
runtime expression controls the rgbPP attribute during playback. Because
rgbPP is a per particle attribute, the runtime expression executes for each
particle in the object for each frame. For each particle, the expression
assigns the rgbPP attribute the output from the execution of the sphrand
function with an argument of 1. The sphrand function is one of Mayas
many built-in mathematical functions that are useful in expressions.
The sphrand function with an argument of 1 assigns each particles rgbPP
color a random vector. The vector represents a random point in a spherical
region of radius 1. The left, middle, and right rgbPP color components
get a value no less than -1 and no greater than 1. (R, G, and B values less
than 0 are treated as 0a black color).
The sphrand function returns a different random vector each execution,
so each particle receives a different random rgbPP value, and therefore,
a different color. The color changes each frame.
5 Rewind and play the animation again.
The particles become red when you go to the start time, and random
colors during playback.
Using runtime expressions | 647