pslib
Class BoidParticle

java.lang.Object
  extended by pslib.GenericParticle
      extended by pslib.DynamicParticle
          extended by pslib.ParentParticle
              extended by pslib.BoidParticle
All Implemented Interfaces:
PSConstants

public class BoidParticle
extends ParentParticle

BoidParticle Class

The BoidParticle object extends the functionality of the ParentParticle object by incorporating flocking simulation. Boid position is calculated based on the rules of separation, cohesion and alignment of flock members as defined by Reynolds.

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
BoidParticle()
          Create a new static object instance with the default buffer size of 1
BoidParticle(int b)
          Create a new static object instance with the specified buffer size
BoidParticle(int b, int d)
          Create a new dynamic object instance with the specified buffer size and decay time
 
Method Summary
 BoidParticle copy()
          Return a copy of this particle
 void map(BoidParticle p)
          Map the properties of this particle to that specified preserving references
 void setBoundToPlace(PSVector c, float r)
          Set the bound-to-place location and radius
 void setCheckDistance(float d)
          Set the boid check distance
 void setDamping(float d)
          Set the boid velocity damping amount
 void setForceScalars(float s, float a, float c, float b)
          Set the boid force
 void setMaxForce(float f)
          Set the maximum acceleration force for the boid
 void setMaxVelocity(float v)
          Set the maximum velocity for the boid
 void setSeparationDistance(float d)
          Set the boid separation distance
 void update(GenericParticle[] pa)
          Update the boid
 
Methods inherited from class pslib.ParentParticle
activeParticles, attach, attach, attachedParticles, clear, debug, debug, getBufferSize, isDead, map, remove, render, render, setAlpha, setBufferSize, setColour, setColour, setColour, setColour, setPosition, setVelocity, toArray, update
 
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

BoidParticle

public BoidParticle()
Create a new static object instance with the default buffer size of 1


BoidParticle

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

Parameters:
b - buffer size

BoidParticle

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

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

setForceScalars

public void setForceScalars(float s,
                            float a,
                            float c,
                            float b)
Set the boid force

Parameters:
s - separation
a - alignment
c - cohesion
b - bound-to-place

setSeparationDistance

public void setSeparationDistance(float d)
Set the boid separation distance

The separation distance is the distance which the boid will attempt to maintain between itself and its neighbours.

Default: 60.0

Parameters:
d - separation distance

setCheckDistance

public void setCheckDistance(float d)
Set the boid check distance

Boid velocity is calculated based on all surrounding boids within the specified radius.

Default: 60.0

Parameters:
d - check distance

setBoundToPlace

public void setBoundToPlace(PSVector c,
                            float r)
Set the bound-to-place location and radius

Boids will attempt to stay within the spherical area specifed. If the central point is specified as null, the boid will not adhere to the bound-to-place rule.

Default: null, 0.0

Parameters:
c - central point
r - radius

setDamping

public void setDamping(float d)
Set the boid velocity damping amount

Default: 0.01

Parameters:
d - damping

setMaxVelocity

public void setMaxVelocity(float v)
Set the maximum velocity for the boid

Default: 5.0

Parameters:
v - maximum velocity

setMaxForce

public void setMaxForce(float f)
Set the maximum acceleration force for the boid

Default: 0.1

Parameters:
f - maximum force

update

public void update(GenericParticle[] pa)
Update the boid

Boid velocity and position is calculated based on the position and velocity data for each GenericParticle within the specified array

Parameters:
pa - GenericParticle array

copy

public BoidParticle copy()
Return a copy of this particle

The returned particle will copy of all of this objects variables and will adhere to the rules defined in DynamicParticle.map().

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

map

public final void map(BoidParticle p)
Map the properties of this particle to that specified preserving references

The returned object takes a copy of all orbiter particle variables. DynamicParticle variables are mapped based on the rules defined in DynamicParticle.map().

Parameters:
p - particle
See Also:
DynamicParticle