As of Web Driver 3.0, particle effects are now accessible in code
through the WTSpout object. If you
have used WTStudio, you may recognize this object as an Emitter. A spout
is a particle generator that continuously creates 2D sprites in 3D space.
You're probably most familiar with seeing them used for fire or smoke.
Spouts have many different properties, allowing you to create a wide variety
of effects.
You are looking head-on at a spout. Drag the mouse
around to spin the view and use + and - to zoom.
You can set most of the properties of the spout using the
controls on this web page. Just type in new numbers and click
away to update. Click the "Show size box" checkbox to gauge the
relative size of your spout as you zoom. Below are some brief descriptions of each
of the properties of the spout.
Note that when a property has a Min and Max value, the actual value will be
random over time between these two limits. All you have to do if you don't want
the property to be random is to simply set the Max equal to the Min.
Mode - use this to stop and start the spout. When stopping the spout,
you will most likely want to use mode 1 so that particles that have already been
generated don't get removed from the stage until they die off naturally.
Rate - tells the spout how many particles to emit per second. Go easy
here. Your code may not have to handle each particle individually, but
the Web Driver does!
Source point width and depth - usually particles are generated from a single
point in space, but make these dimensions greater than 0 to have them generate randomly
along the length of a line or inside a rectangle.
External force - think of this vector as your gravity vector. After
particles are emitted, they will accelerate in the direction of this vector.
This force is always defined in the world coordinate system.
Speed - how fast the particles move when they are emitted.
Angle - the size of the cone within which particles are emitted. Set
the Max value to 0 to shoot the particles in a straight line, or 360 to shoot
them in all directions. In most cases, you will want to set the Min value to
0. But if the Min value is greater than zero, the effect will be a cone
inside which no particles will be emitted. For example, if both the Min and
Max are set to 180, particles will be emitted outward in a flat circle.
Life - how long does each particle last?
Scale - particles have two scale values...one at the start of its
life and one at the end. This allows you to have particles grow or shrink
over their lifetime.
Alpha - Just like you do with scale, you can adjust the transparency
(alpha) of the particles are different points in their life. Enter 0 for
completely transparent up to 255 for fully opaque.
A texture or surface shader must first be applied to a spout before
it is visible. This lab uses surface shaders, which give you more control over
the look, but there's no reason you can't use textures.
Spouts inherit from the WTGroup object, which is the Web Driver's frame of
reference object. This is handy because the spout exists in your scene's
heirarchy. By default, the spout shoots particles in the Y direction; you can
rotate the spout if you wish to have it shoot particles in a different direction.
You can also set the color range of particles using setColorRange.
The color of the sprite is blended with the texture. By default all sprites
are colored white.
When a spout is created, one pixel of the bitmap will correspond to
approximately 0.4 world units when it becomes a sprite. You will probably want
to use setScaleRange to size your sprites just right.
Emitter objects extracted from a WTStudio level can be casted
to a WTSpout
object type.
Particles are emitted at the end of the rate interval, not the
beginning. So, if you set your rate to only 1 particle per second, you won't see
any particles until after 1 second has passed.