pslib
Class ParentParticle

java.lang.Object
  extended by pslib.GenericParticle
      extended by pslib.DynamicParticle
          extended by pslib.ParentParticle
All Implemented Interfaces:
PSConstants
Direct Known Subclasses:
BoidParticle, OrbiterParticle

public class ParentParticle
extends DynamicParticle

ParentParticle Class

The ParentParticle object allows multiple DynamicParticle objects to be attached to a single parent particle. Attached objects inherit the position and velocity properties of the parent.

This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library. If not, see http://www.gnu.org/licenses/.


Field Summary
 
Fields inherited from interface pslib.PSConstants
CAM2D_LOOK, CAM2D_RIGHT, CAM2D_UP, CORNER, INVERSE, INVERSE_TRIANGULAR, LEADING, LINEAR, MIDPOINT, NONE, STATIC, TRAILING, TRIANGULAR
 
Constructor Summary
ParentParticle(int b)
          Create a new object instance with the specified buffer size
ParentParticle(int b, int d)
          Create a new object instance with the specified buffer size and decay time
 
Method Summary
 int activeParticles()
          Return the amount of active particles
 boolean attach(DynamicParticle p)
          Attach a particle to the buffer
 int attach(DynamicParticle[] p)
          Attach an array of particles to the buffer
 int attachedParticles()
          Return the total attached particles
 void clear()
          Clear the buffer
 ParentParticle copy()
          Return a copy of this particle
 void debug(processing.opengl.PGraphicsOpenGL pgl)
          Render the particle location to the specified OpenGL renderer
 void debug(processing.opengl.PGraphicsOpenGL pgl, PSVector cpv, PSVector ctv, PSVector cuv)
          Render the particle location to the specified OpenGL renderer
 int getBufferSize()
          Return the buffer size
 boolean isDead()
          Return true if this particle and all attached particles are dead
 void map(ParentParticle p)
          Map the properties of this particle to that specified.
 boolean remove(DynamicParticle p)
          Remove a particle from the buffer
 void render(processing.opengl.PGraphicsOpenGL pgl)
          Render all attached particles to the specified OpenGL renderer
 void render(processing.opengl.PGraphicsOpenGL pgl, PSVector cpv, PSVector ctv, PSVector cuv)
          Render all attached particles to the specified OpenGL renderer
 void setAlpha(float a)
          Set the alpha value of all attached particles
 void setBufferSize(int s)
          Set the buffer size
 void setColour(PSColour c)
          Set the colour of all attached particles
 void setColour(PSColour c, int t)
          Set the colour of all attached particles with the specified fade time
 void setColour(WeightedList<PSColour> c)
          Set the colour of all attached particles
 void setColour(WeightedList<PSColour> c, int t)
          Set the colour of all attached particles with the specified fade time
 void setPosition(PSVector v)
          Set the position of this particle and any attached particles
 void setVelocity(PSVector v)
          Set the velocity of this particle and any attached particles
 DynamicParticle[] toArray()
          Return all active particles as an array
 void update()
          Update this and all attached particles
 
Methods inherited from class pslib.DynamicParticle
clearBehaviour, getBehaviour, getDecay, getDecayTime, getInitialDecayTime, getMass, getRenderAlpha, getRenderSize, getSnapshot, isDynamic, map, setAlphaEnvelope, setBehaviour, setBehaviour, setDecayTime, setMass, setSizeEnvelope
 
Methods inherited from class pslib.GenericParticle
getAlpha, getColour, getPosition, getSize, getVelocity, setSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParentParticle

public ParentParticle(int b)
Create a new object instance with the specified buffer size

Parameters:
b - buffer size

ParentParticle

public ParentParticle(int b,
                      int d)
Create a new object instance with the specified buffer size and decay time

Parameters:
b - buffer size
d - decay (ms)
Method Detail

setPosition

public void setPosition(PSVector v)
Set the position of this particle and any attached particles

Overrides:
setPosition in class GenericParticle
Parameters:
v - position vector

setVelocity

public void setVelocity(PSVector v)
Set the velocity of this particle and any attached particles

Overrides:
setVelocity in class GenericParticle
Parameters:
v - velocity vector

setColour

public void setColour(PSColour c)
Set the colour of all attached particles

Overrides:
setColour in class GenericParticle
Parameters:
c - colour

setColour

public void setColour(PSColour c,
                      int t)
Set the colour of all attached particles with the specified fade time

Overrides:
setColour in class GenericParticle
Parameters:
c - colour
t - fade time (ms)

setColour

public void setColour(WeightedList<PSColour> c)
Set the colour of all attached particles

Particle colour will be assigned at random from the specified WeightedList

Parameters:
c - colour list

setColour

public void setColour(WeightedList<PSColour> c,
                      int t)
Set the colour of all attached particles with the specified fade time

Particle colour will be assigned at random from the specified WeightedList

Parameters:
c - colour list
t - fade time (ms)

setAlpha

public void setAlpha(float a)
Set the alpha value of all attached particles

Overrides:
setAlpha in class GenericParticle
Parameters:
a - alpha

getBufferSize

public final int getBufferSize()
Return the buffer size

Returns:
the buffer size

attachedParticles

public final int attachedParticles()
Return the total attached particles

Returns:
the total attached particles

setBufferSize

public final void setBufferSize(int s)
Set the buffer size

If the new size is less than the current active particle count, particles will be culled eldest first.

Parameters:
s - buffer size

activeParticles

public final int activeParticles()
Return the amount of active particles

Returns:
the amount of active particles

toArray

public final DynamicParticle[] toArray()
Return all active particles as an array

Returns:
all active particles as an array

isDead

public boolean isDead()
Return true if this particle and all attached particles are dead

Overrides:
isDead in class DynamicParticle
Returns:
trues if this particle and all attached particles are dead

attach

public boolean attach(DynamicParticle p)
Attach a particle to the buffer

Parameters:
p - particle
Returns:
true if the particle was successfully attached

attach

public int attach(DynamicParticle[] p)
Attach an array of particles to the buffer

Parameters:
p - particle
Returns:
the amount of particles attached

remove

public boolean remove(DynamicParticle p)
Remove a particle from the buffer

If multiple references to the particle exist, they will all be removed.

Parameters:
p - DynamicParticle
Returns:
true if the particle was found and removed

clear

public final void clear()
Clear the buffer


update

public void update()
Update this and all attached particles

Overrides:
update in class DynamicParticle

render

public void render(processing.opengl.PGraphicsOpenGL pgl)
Render all attached particles to the specified OpenGL renderer

Overrides:
render in class DynamicParticle
Parameters:
pgl - OpenGL renderer

render

public void render(processing.opengl.PGraphicsOpenGL pgl,
                   PSVector cpv,
                   PSVector ctv,
                   PSVector cuv)
Render all attached particles to the specified OpenGL renderer

Overrides:
render in class DynamicParticle
Parameters:
pgl - OpenGL renderer
cpv - camera position vector
ctv - camera target vector
cuv - camera up vector;

debug

public void debug(processing.opengl.PGraphicsOpenGL pgl)
Render the particle location to the specified OpenGL renderer

Overrides:
debug in class DynamicParticle
Parameters:
pgl - OpenGL renderer

debug

public void debug(processing.opengl.PGraphicsOpenGL pgl,
                  PSVector cpv,
                  PSVector ctv,
                  PSVector cuv)
Render the particle location to the specified OpenGL renderer

Overrides:
debug in class DynamicParticle
Parameters:
pgl - OpenGL renderer
cpv - camera position vector
ctv - camera target vector
cuv - camera up vector

copy

public ParentParticle copy()
Return a copy of this particle

The returned object will contain a copy of all attached particles within this object and will adhere to the rules defined in the DynamicParticle.map() method.

Overrides:
copy in class DynamicParticle
Returns:
a copy of this particle
See Also:
DynamicParticle

map

public final void map(ParentParticle p)
Map the properties of this particle to that specified.

The returned object takes a copy of all attached particles within this object. DynamicParticle variables are mapped based on the rules defined in DynamicParticle.map().

Parameters:
p - particle
See Also:
DynamicParticle