Now its time to make these locators into goals. We'll set up one
completely with all of its expressions and then add the second.
10. Select the particle and the freezeField0 and choose particles>goal.
11. Open the attribute editor for the particle shape. In the section for goal weights and objects hit the button for goalWeight0PP and the button for goalWorldPosition0PP.
Whenever you add a goal to this particle a new set of these buttons will appear. Each goal will be numbered starting with zero. This is why I named the first locator "freezeField0." it makes it easier to keep track of what's going on when I start writing expressions.
12. In the per-particle array attributes, right-click over the goalWeight0PP attribute and choose creation expression.
13. In the expression editor enter
This essentially turns off the goal, but that's ok. for this exercise the goal is really a positional locator. It doesn't need to attract or affect the particles at all.
14. In the expression editor switch to "runtime before dynamics"
15. The first thing we'll do is create a variable to hold the information contained in the goalWorldPosition0PP attribute. We'll call the vairable "$goal0Pos".
The variable will have to be a vector as the goal's position is a vector.
Enter this:
Tip: Try switching the particle type to numeric and hit the add attribute for current render type button. In the field for attribute name enter goalWorldPosition0PP. When you play the animation you can see this attribute expressed as a vector in the perspective window.
16. Next we'll create a variable to contain the particle's positionPP, we'll call it $pos.
Enter this line in the expression editor below the previous one:
17. Now we'll create a distance variable for the range of the field. This is already visually represented by the fieldRange sphere we created who's scale is related to the fieldSize attribute on the freezeField locator.
The range is essentially the radius of the sphere or half the field size attribute. Enter this in the next line of the expression editor:
18. The heart of this expression will be a conditional statement that says "if the absolute value of the difference between the particle's position and the goal's world position is less that the size of the freeze field's range, set the velocity of the particle to zero."
10. Select the particle and the freezeField0 and choose particles>goal.
11. Open the attribute editor for the particle shape. In the section for goal weights and objects hit the button for goalWeight0PP and the button for goalWorldPosition0PP.
Whenever you add a goal to this particle a new set of these buttons will appear. Each goal will be numbered starting with zero. This is why I named the first locator "freezeField0." it makes it easier to keep track of what's going on when I start writing expressions.
12. In the per-particle array attributes, right-click over the goalWeight0PP attribute and choose creation expression.
13. In the expression editor enter
particleShape1.goalWeight0PP=0;
This essentially turns off the goal, but that's ok. for this exercise the goal is really a positional locator. It doesn't need to attract or affect the particles at all.
14. In the expression editor switch to "runtime before dynamics"
15. The first thing we'll do is create a variable to hold the information contained in the goalWorldPosition0PP attribute. We'll call the vairable "$goal0Pos".
The variable will have to be a vector as the goal's position is a vector.
Enter this:
vector $goal0Pos=particleShape1.goalWorldPosition0PP;
Tip: Try switching the particle type to numeric and hit the add attribute for current render type button. In the field for attribute name enter goalWorldPosition0PP. When you play the animation you can see this attribute expressed as a vector in the perspective window.
16. Next we'll create a variable to contain the particle's positionPP, we'll call it $pos.
Enter this line in the expression editor below the previous one:
vector $pos=particleShape1.position;
17. Now we'll create a distance variable for the range of the field. This is already visually represented by the fieldRange sphere we created who's scale is related to the fieldSize attribute on the freezeField locator.
The range is essentially the radius of the sphere or half the field size attribute. Enter this in the next line of the expression editor:
float $range0=.5*freezeField0.fieldSize;
18. The heart of this expression will be a conditional statement that says "if the absolute value of the difference between the particle's position and the goal's world position is less that the size of the freeze field's range, set the velocity of the particle to zero."
Author: robotball
Submitted: 2005-10-09 23:31:21 UTC
Tags:
Software: Maya
Views: 55,009
Related Items
-
Realistic sexy posed brunette woman in multiple outfits vinyl and lingerie 3D Model
$69.00 (USD) -
Elephant 3d textured model 3ds max and maya scene files 3D Model
$30.00 (USD) -
Tire and Rim 3D Model
$9.00 (USD) -
Kangaroo Rigged and Animated 3D Model
$30.00 (USD) -
j-7 3D Model
$120.00 (USD) -
Blonde woman in jeans and sweater - aXYZ design - AWom0004-CS / Rigged for 3D Max + Character Studio 3D Model
$49.00 (USD) -
7.62x25 Tokarev Cartridge 3D Model
$25.00 (USD) -
7.62x51 NATO Cartridge 3D Model
$25.00 (USD) -
7.62x39 Cartridge 3D Model
$25.00 (USD)