Example Particle Goals on a Surface

Now that we have talked about goals between particles, we will explore setting goals for particles on a NURBS surface (Figure 19.8). First, let's look at a patch and see how we can control particles on it by setting goals at particular U and V coordinates (UVs). Figure 19.9 shows how the UVs are arranged on a NURBS patch.

Figure 19.5 partOne and partTwo with goal weights.

Goal"

q___goal vector V2

partOne

VI + V2 = V3 /

vector << 0, -2, 0 >>

VI

/ result vector V3

«

partOne result

Figure 19.6 How Maya combines velocity vectors with goal attraction.
Figure 19.7 Script Editor's file menu.
Figure 19.8 Particles attracted to a surface.

u 1 vO

U 1 V 1

uOvO

u 0 v 1

Figure 19.9 U and V parameters on NURBS patch.

Figure 19.9 U and V parameters on NURBS patch.

If you have experience with texture mapping, you might be familiar with how texture mapping using UVs works. As you distort and manipulate the patch, the UVs stick to the surface, as shown in Figure 19.10.

We can attract a particle to a particular point on a surface selected by its U and V value by using two particle attributes, goalU and goalV. The first step is to make a NURBS plane. For this example, let's use the standard Maya NURBS plane because the UVs are guaranteed to be well behaved. If you use a plane or any other patch that you have made though an extrude or loft, you have to watch the construction of the curves and make sure that your UVs are properly placed. To create the NURBS plane, type the following in the Script Editor:

nurbsPlane -p 0 0 0 -ax 0 1 0 -w 1 -lr 1 -d 3 -u 1 -v 1 -ch 1;

(If you wish to see what some of the flags mean for this command, see the online MEL documentation.) Figure 19.11 shows the resulting plane. If

Figure 19.11 The resulting plane.

your plane looks too small, you can scale it up. The UVs will scale up with the surface. If you do not see the isoparams on your plane, select it and press "3" to set the display of the surface to full resolution.

Let's add an emitter with a rate of two particles per second. To do this, use the Maya interface rather than MEL. From the Particles menu in the Dynamics menu, go to the Create Emitter option box, making sure that the options are set to Omni with an emission rate of 2. Click Create to make the emitter.

Then, move the emitter up in Y 3 units to get it out of the way of the plane. Following is the MEL code to create the emitter, just for reference. As you can see, the Maya interface takes care of some relationships between the particles and the emitter.

particle -n particle1;

connectDynamic -em emitter1 particle1;

Now, make the nurbsPlane the goal for the particles. Again, we can create the goal relationship from the Maya menu or make the connection in MEL. Select Window > Outliner. This a handy window to have up all the time since you can directly select objects inside hierarchies instead of hunting for them in the camera window. Select particle1, and then hold down the Ctrl key to select the nurbsPlane. Now go to the Particles window, and select the Goal section. Alternatively, if you would like to use MEL to set up the goal, type the following in the Script Editor, and press Enter:

goal -w 1.0 -utr 0 -g nurbsPlane1 particle1;

Now, let's set the particle render type to sphere, like before. Select the particle object, and open the Attribute Editor; click the Particle Render Type button, and then select sphere. Or, to set the render type in MEL, type the following in the Script Editor, and press Enter:

setAttr particle1Shape.particleRenderType 4;

Click the Current Render Type button to load the options for that type. Only one new render option, radius, will appear for the sphere render type. A setting of 0.5 should be fine. Remember the MEL code for doing this in Example 1?

addAttr -is true -ln radius -at "float" -min 0 -max 1 -dv 0.5 particle1Shape;

To see how the patch goal (nurbsPlane) affects the particles, set your playback start time to 1 and your playback end time to 360 in the Maya interface and play, or use the following MEL command:

playbackOptions -min 1 -max 360; Now play. Figure 19.12 shows the result.

Figure 19.12 Particles attracted to plane's components.

If you select the nurbsPlane and switch to component mode by pressing F9, you can see that a particle will settle at each of the control vertices (CVs). The default UV goal assignment is to match up newly created particles to the UV locations of CVs on the goal surface sequentially. Because this usually will not produce the desired effect, we have to add some attributes to the particle system that will enable a more arbitrary UV to particle relation. With the particle system selected (particlel), open the Attribute Editor (Ctrl-A) to add some new attributes.

0 0

Post a comment

  • Receive news updates via email from this site