Package tripleplay.particle
Class ParticleBuffer
java.lang.Object
tripleplay.particle.ParticleBuffer
Contains the basic metadata for an array of particles: position, velocity, scale, rotation,
birth time, lifespan.
-
Field Summary
Modifier and TypeFieldDescriptionfinal 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
ConstructorDescriptionParticleBuffer
(int maxParticles) Creates a particle buffer that can hold up tomaxParticles
particles. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(int count, float now, List<? extends Initializer> initters) Addscount
particles to this buffer, and initializes them withinitters
.int
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
isFull()
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.
-
Field Details
-
BIRTH
public static final int BIRTHThe offset of the birth time in the particle buffer.- See Also:
-
LIFESPAN
public static final int LIFESPANThe offset of the lifespan in the particle buffer.- See Also:
-
VEL_X
public static final int VEL_XThe offset of the x coordinate of the velocity in the particle buffer.- See Also:
-
VEL_Y
public static final int VEL_YThe offset of the y coordinate of the velocity in the particle buffer.- See Also:
-
M00
public static final int M00The offset of the m00 transform element in the particle buffer.- See Also:
-
M01
public static final int M01The offset of the m01 transform element in the particle buffer.- See Also:
-
M10
public static final int M10The offset of the m10 transform element in the particle buffer.- See Also:
-
M11
public static final int M11The offset of the m11 transform element in the particle buffer.- See Also:
-
TX
public static final int TXThe offset of the tx transform element in the particle buffer.- See Also:
-
TY
public static final int TYThe offset of the ty transform element in the particle buffer.- See Also:
-
ALPHA_RED
public static final int ALPHA_REDThe 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_BLUEThe 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_FIELDSThe total number of fields per particle.- See Also:
-
data
public final float[] dataThe particle data. -
alive
public final int[] aliveA liveness flag for each particle.
-
-
Constructor Details
-
ParticleBuffer
public ParticleBuffer(int maxParticles) Creates a particle buffer that can hold up tomaxParticles
particles.
-
-
Method Details
-
dump
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
Addscount
particles to this buffer, and initializes them withinitters
. -
apply
Applies the supplied effectors to all (live) particles in this buffer.- Returns:
- the number of live particles to which the effectors were applied.
-
render
Renders the particles to the supplied shader.
-