Tips & Tricks
Basics : Particles & Expression
Date: 20th Apr 2009
Maya Particles : Fountain with Expression Monday, April 20, 2009 3:12 PM
As per the earlier exercise we have a pretty neat looking simulation of a line of fountains. While we can appreciate the over look and simulation, there are things that we may want to add up to make this simulation even better. We notice that all the fountains are identical in look. So let us try making things a bit more different. Would this not be more better looking, if we could make the fountain move like a wave. That each fountain go on and off at different times and make this look more interesting.
This can ofcourse be done with simple keyframing, but then, the flexibility will be found wanting as each and every emitter will have to be edited to get the precise look.
P a g e | 1
Tips & Tricks Basics : Particles & Expression Date: 20th Apr 2009 We need to think what is the most common attributes needed to get this effect: All the particles should look the same hence number of particles and their spread should be the same All particles should move the same way and same height…hence the speed should be the same While the speed is the same in height, we do not want all to be at the same height all the time…perhaps if this could be cycled. This can be done quite simply: We select the emitter and create a runtime expression: This create a simple sin wave and makes the particles get emitted in a wave fashion. However the particles emit height is not enough…we can add a multiplier to the above expression as we desire Hence the expression would be Emitter1.speed= sin (time *10); While all this is fine…and each emitter is added with this expression. We notice that all are doing the same. Hence all the emitters are emitting and stopping at the same time. What we need is and offset to all of these. We can of course edit each of these expressions (for the speed of each emitter), but then controlling them is still a problem. Therefore the logical thing to do is have a "central Command" or an object whose attributes drive the particles. Hence we create a locator. (one can create any type of object as per choice). To this object we will add various attributes Modify >> Add Attribute
P a g e | 2
Tips & Tricks
Basics : Particles & Expression
Date: 20th Apr 2009
The attributes (for this exercise) is: 1. Number of particles the emitter has to emit (i.e rate) 2. Overall speed of all particles 3. How the particles are spread 4. Offset speed of each emitter
The data type is important, whether the data is to be in vectors or integers or float…etc. Using Modify >> Edit Attribute one can modify attributes. The key question to newbies is how does one know what value to put in. This is really simple. 1. Number of particles the emitter has to emit (i.e rate) : Leave the minimum and maximum blank as we do not need end limits. As a particle cannot be in decimal (1/2 particle etc). The data type is integer 2. Overall speed of all particles : normally the speed of the particles is around 20. hence to be flexible the minimum is set to zero and the maximum is set to 100. This data type is set to integer (though one may set it to be a float) 3. How the particles are spread: Normal particle spread is 0 to 1. hence the same values are set for minimum and maximum. And since the values are in decimals, we use the date type float. 4. Offset speed of each emitter: this is the key attribute and hence we want more control. The data type is float. The minimum and maximum values are kepe at ‐100 and 100 respectively. While doing the exercise, these values were fixed at much higher value than eventually needed. So let us put the proper expression on each emitter. Emitter1 : emitter1.speed = (locator1.Overall_speed * (sin (time + ((locator1.Offset_speed/10) *1)))); Let us decipher what this "complex expression" is about.
P a g e | 3
Tips & Tricks Basics : Particles & Expression Date: 20th Apr 2009 We all know of sin (time) being the sine wave function based on time. Time is calculate in seconds. We all know that Overall_speed is the base speed for all particles from all the emitters. That leaves the "complex part" (Locator1.Offset_speed /10 ) * 1 This is a simple principle of 1st in row, 2nd in row, 3rd in row…etc. In this exercise we have 10 emitters. Hence the overall offset (offset from the first emitter to the last emitter) is divided into 10 equal parts and then multipled by the emitter number. Hence the first emitter is (Locator1.Offset_speed /10 ) * 1 The second is (Locator1.Offset_speed /10 ) * 2 . . . . . . The last is (Locator1.Offset_speed /10 ) * 10 In order to get the desired effect change the value of the offset speed. Note this can even be in the negative Note this can even be animated.
Prem Moraes
Digitally signed by Prem Moraes DN: cn=Prem Moraes, o=Autodesk India Ltd., ou=M&E,
[email protected], c=IN Date: 2009.04.20 17:41:30 +05'30'
P a g e | 4