Class ParticleBuffer

java.lang.Object
tripleplay.particle.ParticleBuffer

public class ParticleBuffer extends Object
Contains the basic metadata for an array of particles: position, velocity, scale, rotation, birth time, lifespan.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final int[]
    A liveness flag for each particle.
    static final int
    The offset of the alpha + red tint in the particle buffer.
    static final int
    The offset of the birth time in the particle buffer.
    final float[]
    The particle data.
    static final int
    The offset of the green + blue tint in the particle buffer.
    static final int
    The offset of the lifespan in the particle buffer.
    static final int
    The offset of the m00 transform element in the particle buffer.
    static final int
    The offset of the m01 transform element in the particle buffer.
    static final int
    The offset of the m10 transform element in the particle buffer.
    static final int
    The offset of the m11 transform element in the particle buffer.
    static final int
    The total number of fields per particle.
    static final int
    The offset of the tx transform element in the particle buffer.
    static final int
    The offset of the ty transform element in the particle buffer.
    static final int
    The offset of the x coordinate of the velocity in the particle buffer.
    static final int
    The offset of the y coordinate of the velocity in the particle buffer.
  • Constructor Summary

    Constructors
    Constructor
    Description
    ParticleBuffer(int maxParticles)
    Creates a particle buffer that can hold up to maxParticles particles.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(int count, float now, List<? extends Initializer> initters)
    Adds count particles to this buffer, and initializes them with initters.
    int
    apply(List<? extends Effector> effectors, float now, float dt)
    Applies the supplied effectors to all (live) particles in this buffer.
    static String
    dump(float[] data, int index, int start)
    Returns a string representation of the specified particle's data.
    boolean
    isAlive(int partidx)
    Returns true if the specified particle is alive.
    boolean
     
    static void
    multiply(float[] data, int start, float m00, float m01, float m10, float m11, float tx, float ty)
    Multiplies the specified particle's transform with the supplied matrix.
    void
    render(ParticleBatch batch, float width, float height)
    Renders the particles to the supplied shader.
    void
    setAlive(int partidx, boolean isAlive)
    Sets the particle in question to alive or not.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • BIRTH

      public static final int BIRTH
      The offset of the birth time in the particle buffer.
      See Also:
    • LIFESPAN

      public static final int LIFESPAN
      The offset of the lifespan in the particle buffer.
      See Also:
    • VEL_X

      public static final int VEL_X
      The offset of the x coordinate of the velocity in the particle buffer.
      See Also:
    • VEL_Y

      public static final int VEL_Y
      The offset of the y coordinate of the velocity in the particle buffer.
      See Also:
    • M00

      public static final int M00
      The offset of the m00 transform element in the particle buffer.
      See Also:
    • M01

      public static final int M01
      The offset of the m01 transform element in the particle buffer.
      See Also:
    • M10

      public static final int M10
      The offset of the m10 transform element in the particle buffer.
      See Also:
    • M11

      public static final int M11
      The offset of the m11 transform element in the particle buffer.
      See Also:
    • TX

      public static final int TX
      The offset of the tx transform element in the particle buffer.
      See Also:
    • TY

      public static final int TY
      The offset of the ty transform element in the particle buffer.
      See Also:
    • ALPHA_RED

      public static final int ALPHA_RED
      The offset of the alpha + red tint in the particle buffer. This is (A*256+R) where A and R are integer values in the range [0...256).
      See Also:
    • GREEN_BLUE

      public static final int GREEN_BLUE
      The offset of the green + blue tint in the particle buffer. This is (G*256+B) where G and B are integer values in the range [0...256).
      See Also:
    • NUM_FIELDS

      public static final int NUM_FIELDS
      The total number of fields per particle.
      See Also:
    • data

      public final float[] data
      The particle data.
    • alive

      public final int[] alive
      A liveness flag for each particle.
  • Constructor Details

    • ParticleBuffer

      public ParticleBuffer(int maxParticles)
      Creates a particle buffer that can hold up to maxParticles particles.
  • Method Details

    • dump

      public static String dump(float[] data, int index, int start)
      Returns a string representation of the specified particle's data.
    • multiply

      public static void multiply(float[] data, int start, float m00, float m01, float m10, float m11, float tx, float ty)
      Multiplies the specified particle's transform with the supplied matrix.
    • isAlive

      public boolean isAlive(int partidx)
      Returns true if the specified particle is alive.
    • setAlive

      public void setAlive(int partidx, boolean isAlive)
      Sets the particle in question to alive or not.
    • isFull

      public boolean isFull()
    • add

      public void add(int count, float now, List<? extends Initializer> initters)
      Adds count particles to this buffer, and initializes them with initters.
    • apply

      public int apply(List<? extends Effector> effectors, float now, float dt)
      Applies the supplied effectors to all (live) particles in this buffer.
      Returns:
      the number of live particles to which the effectors were applied.
    • render

      public void render(ParticleBatch batch, float width, float height)
      Renders the particles to the supplied shader.