From MegaGlest
Jump to: navigation, search

The spread values of the particles help determine the direction component of each particle's velocity in a particle splash system.

How it works[edit]

For each component (x, y & z), a (0.0 -> 1.0) is multiplied by a random number (in the range -1.0 -> 1.0), and the resulting number (which is also in the range -1.0 -> 1.0) has b (in the range -1.0 -> 1.0) added to it. For the x and z components a and b are the horizontal-spread numbers, and for y it uses the vertical-spread.


The a in horizontal-spread determines the amount of the velocity that points out from the splash center, if a=0.0 (and b=0.0) then the particles will have no velocity in the x or z directions and will only move up or down, depending on the vertical-spread.

If a is not 0.0, then the x and z components of the resulting velocity vector will not be zero either and the particle will by directed (horizontally, believe it or not) away from the center of the splash.

The magnitude of a in this way is only important if the vertical-spread a is not 0.0, if the vertical-spread a is 0.0 then a horizontal-spread a of 0.1 and 1.0 will give identical results, the direction has no vertical part to it, it will always point horizontally away from the splash center (such as the Archmage's ice-nova).

So for vertical-spread the a is much the same as in horizontal, it determines if there will be any vertical component to the initial velocity vector, and if so, how much compared to the horizontal a (unless the horizontal a is 0.0 of course, in which case the magnitude of the vertical a is largely irrelevant).

The b in vertical-spread can then be used to fine tune the result of multiplying a by a random number between -1.0 and 1.0. The result of the multiplication is also guaranteed to be in the range -1.0 to 1.0, which could be down or up. As b can be itself -1.0 to 1.0 and is added after the multiply, you can completely cancel out any downward pointing velocities (+1.0), or partially (so most, but not all, head upwards) (+0.x), or likewise have no upward traveling ones (-1.0), or favor downward ones (-0.x).

Horizontal-spread has a b too, but unfortunately, it is currently of little use. Firstly, it biases both x and z with the same number, and secondly, its aligned to the global axis, not the attack direction vector. This may be changed in the future in one of Glest's forks.


Splash spread horiz 1 0 vert 1 0.jpg

Splash spread horiz 1 0 vert 1 1.jpg

Splash spread horiz 1 0 vert 1 -1.jpg

Splash spread horiz 0 0 vert 1 1.jpg

See also[edit]