2009

Table Of Contents
8 Turn on Add Per Particle Attribute, then click the Add Attribute button.
This adds an rgbPP attribute to the particle shape node for Bubbles.
Because youre adding this attribute as a per particle attribute, you can
give each particle a different color.
Using creation expressions to set a constant color
To set an attribute that doesnt change during the animation (the particle
color), youll use a creation expression. A creation expression executes when
you go to the start time. It doesnt execute while the animation plays. (For
emitted particles, a creation expression executes for a particular particle when
it is emitted.)
To create a creation expression
1 In the Per Particle (Array) Attributes section of the Attribute Editor,
right-click the rgbPP box and select Creation Expression from the pop-up
menu. Note that the shape node of Bubbles (BubblesShape) is displayed
in the Expression Editor.
When you use an expression to control particle attributes, make sure the
selected object in the Expression Editor is a particle shape node, not the
transform node of the particle object. If a particle objects transform node
is selected, move the mouse pointer to the scene view and press the down
arrow key to select the particle shape node.
2 Enter this expression and then click the Create button:
BubblesShape.rgbPP = <<1,0,0>>;
When you click the Create button in the Expression Editor, Maya checks
the syntax of the expression. Assuming you made no typing errors, the
expression executes once for each of the 100 particles.
The expression colors all particles in the object red. The double angle
brackets << and >> enclose a vector that sets the red, green, and blue
components of the rgbPP attribute to 1, 0, and 0. In the RGB color scheme,
this gives the object a red color.
If the particles are uncolored, check that youve turned on Shading >
Smooth Shade All. This shading mode is necessary for particles to show
the color assigned in an expression.
3 Play the animation. The particles remain red.
586 | Chapter 12 Expressions