Add control over angle of ParticleSystem emission area

Issue #1172 open
PauloT
created an issue

Hi everyone, first of all: Great work on Love2D -- A lot to love about it!

Any chance of providing an angle option to better control the spatial distribution of generated particles?

My motivation is that I am creating a bird's-eye-view sailing simulator, and I'm trying to use particle generators to draw waves on the water surface (with one rectangular generator for each wave crest), and I would like to make the wave crests respond to changes in wind direction --- I know I can draw the whole particle system at a varying angle, but the effect is quite different (looks just like a camera rotation, not like a change in the water surface).

Other cool effects enabled by this option would be for instance flaming swords at any angle...

My initial proposal was adding an optional 'angle' argument to method setPosition, but a better alternative might be adding it to setAreaSpread. Either of these would make for a localized code change, which wouldn't break backwards compatibility.

Comments (6)

  1. Josh Wood (SK83RJOSH)

    This would be very useful, I needed something similar to this quite a few times and wasn't happy with the solutions. Not sure about the proposed API here but having some ability to rotate the particle system (and not just the particles it emits) would be great!

    I think setAngle would be the best option since it's inline with the Body API, though it would obviously be somewhat ambiguous since setRotation is very similar.

    The only question I have is whether or not rotation should affect just the origin of particles, or also things like spread direction, gravity, and initial velocity? If so, should the behavior somehow be configurable? Would it be best to ultimately expose this type of option as an additional parameter to setAreaSpread to avoid this issue and the aforementioned ambiguity?

  2. PauloT reporter

    Hi Joshua, thanks for the support and the ideas!

    I agree with your last proposal, adding the optional angle argument to method setAreaSpread can be better --- this angle should anyway only be significant if an area spread is defined.

    For instance, with a gaussian area distribution and a non-zero angle, particle generation could look like this figure:

    Multi-variate gaussian distribution

    (Matrix notation can make 2-D gaussians seem complicated, but with a coordinate-system rotation they're simpler)

    Having the initial velocity of particles depend on their exact position within the emitter area would be an additional nice-to-have, but would require defining more emitter parameters (rotational speed, center of rotation...) and how these would interact with several other settings for initial particle speed/spin/rotation/etc. --- Quite some more work to specify and implement.

  3. Josh Wood (SK83RJOSH)

    This would only affect particle origins and not their movement, it should ideally be exposed as an optional argument for setAreaSpread.

    Here's a visual aid / use case (the sword could be any object that has an arbitrary rotation):

    Untitled-1.png

  4. Log in to comment