|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpslib.GenericParticle
pslib.DynamicParticle
pslib.GenericEmitter
public class GenericEmitter
GenericEmitter Class
The GenericEmitter class extends the functionality of the DynamicParticle class by allowing further DynamicParticles to be attached. Attached particles may then be subjected to a random initial velocity and any attached PSForce objects or PSBehaviour objects.
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 | |
---|---|
GenericEmitter(int b)
Create a new object instance with the specified buffer size |
|
GenericEmitter(int b,
int d)
Create a new object instance with the specified buffer size and decay time |
Method Summary | |
---|---|
boolean |
attach(DynamicParticle p)
Attach a particle to the emitter |
int |
attach(DynamicParticle[] pa)
Attach an array of particles to the emitter |
int |
attachedParticles()
Return the current particle count |
void |
clear()
Clear all attached particles |
void |
clearForces()
Remove all attached forces |
GenericEmitter |
copy()
Return a copy of this emitter |
void |
debug(processing.opengl.PGraphicsOpenGL pgl)
Render the emitter location to the specified OpenGL renderer |
void |
debug(processing.opengl.PGraphicsOpenGL pgl,
PSVector cpv,
PSVector ctv,
PSVector cuv)
Render the emitter location to the specified OpenGL renderer |
int |
getBufferSize()
Return the emitter buffer size |
PSVector |
getDimensionScalars()
Return a reference to the emitter dimension scalar vector |
protected PSVector |
getEmissionVector(PSVector d,
float s)
|
protected PSVector |
getRadialVector()
|
boolean |
isDead()
Return true if this and all attached particles are dead |
void |
map(GenericEmitter e)
Map the properties of this e to that specified preserving references |
boolean |
remove(DynamicParticle p)
Remove the specified particle from the emitter |
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 emitter 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 |
setDimensionScalars(PSVector v)
Set the emitter dimension scalars |
void |
setDirection(PSVector d)
Set the particle emission direction |
void |
setDirectionMode(int m)
Set the direction mode - STATIC, LEADING, TRAILING |
void |
setForces(PSForce f)
Attach a force to the emitter |
void |
setForces(PSForce[] f)
Attach an array of forces to the emitter |
void |
setInitialVelocity(float v)
Set the initial velocity scalar for attached particles |
void |
setInitialVelocity(float min,
float max)
Set the initial velocity scalar range for attached particles |
void |
setMaxVelocity(float v)
Set the maximum velocity for all attached particles |
void |
setParticleStealing(boolean b)
Enable/disable particle stealing |
void |
setRadius(float r)
Set the particle creation radius |
void |
setRadius(float min,
float max)
Set the particle creation radius range |
void |
setSpeed(float s)
Set the particle speed multiplier |
void |
setSpread(float s)
Set the particle emission spread |
DynamicParticle[] |
toArray()
Return all attached particles as an array |
void |
update()
Update this all attached particles |
protected void |
updateParticle(DynamicParticle p)
Update the specified particle |
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, setPosition, setSize, setVelocity |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GenericEmitter(int b)
b
- buffer sizepublic GenericEmitter(int b, int d)
b
- buffer sized
- decay (ms)Method Detail |
---|
public void setColour(PSColour c)
setColour
in class GenericParticle
c
- colourpublic void setColour(PSColour c, int t)
setColour
in class GenericParticle
c
- colourt
- fade time (ms)public void setColour(WeightedList<PSColour> c)
Particle colour will be assigned at random from the specified WeightedList
c
- colour listpublic void setColour(WeightedList<PSColour> c, int t)
Particle colour will be assigned at random from the specified WeightedList
c
- colour listt
- fade time (ms)public void setAlpha(float a)
setAlpha
in class GenericParticle
a
- alphapublic final void setSpeed(float s)
s
- speed multiplierpublic final void setInitialVelocity(float v)
Initial particle velocity is calculated as the inverse of the parent velocity multiplied by the specified values.
Default: 1.0
v
- scalarpublic final void setInitialVelocity(float min, float max)
Initial particle velocity is calculated as the inverse of the parent velocity multiplied by a random value between the specified limits.
Default: 1.0, 2.0
min
- max
- public final void setRadius(float r)
The particle creation radius specifies the distance from the emitter at which particles will be created.
Default: 0.0
r
- radiuspublic final void setRadius(float min, float max)
The particle creation radius range specifies the minimum and maximum distances from the emitter at which particles will be created.
Default: 0.0, 0.0
min
- minimummax
- maximumpublic final void setDirection(PSVector d)
Default: (0.0, -1.0, 0.0)
d
- direction vectorpublic final void setSpread(float s)
The particle emission spread specifies the emission cone for the emitter. A value of 1.0 will result in spherical emission, while a value of 0.0 will result in emission along the direction vector.
Default: 1.0
s
- spreadpublic final void setMaxVelocity(float v)
Default: 5.0
v
- maximum velocitypublic final void setDirectionMode(int m)
The direction mode allows the particle emission direction to be modified based on the emitter velocity. The STATIC mode will result in particle emission along the direction vector, while LEADING and TRAILING will result in particle emission along the velocity vector and inverse velocity vector respectively.
Default: STATIC
m
- modepublic final void setDimensionScalars(PSVector v)
The dimension scalar vector defines the dimensionality of the emitter. For example, a dimension scalar vector of (1.0, 1.0, 0.0) result in all attached particles being emitted only on the two dimensional xy plane.
All attached forces and targets will also be assigned the dimension scalar vector of their parent emitter.
v
- public final PSVector getDimensionScalars()
public final void setParticleStealing(boolean b)
If particle stealing is enabled and the buffer is full then older particles will be removed to allow for newer ones to be attached.
public boolean isDead()
isDead
in class DynamicParticle
public final DynamicParticle[] toArray()
The function finds all non-null and alive particles within the buffer and copies references to them into the returned array. As such it is not particularly efficient and should not be thought of as a direct reference to the particle buffer.
public final void setBufferSize(int s)
The emitter buffer size dictates the maximum total particles that may be attached to the emitter. If the specified size is less than the current buffer size, attached particles will be culled, eldest first.
s
- sizepublic final int getBufferSize()
public final int attachedParticles()
public void render(processing.opengl.PGraphicsOpenGL pgl)
render
in class DynamicParticle
pgl
- OpenGL rendererpublic void render(processing.opengl.PGraphicsOpenGL pgl, PSVector cpv, PSVector ctv, PSVector cuv)
render
in class DynamicParticle
pgl
- OpenGL renderercpv
- camera position vectorctv
- camera target vectorcuv
- camera up vectorpublic void debug(processing.opengl.PGraphicsOpenGL pgl)
debug
in class DynamicParticle
pgl
- OpenGL rendererpublic void debug(processing.opengl.PGraphicsOpenGL pgl, PSVector cpv, PSVector ctv, PSVector cuv)
debug
in class DynamicParticle
pgl
- OpenGL renderercpv
- camera position vectorctv
- camera target vectorcuv
- camera up vectorpublic void update()
update
in class DynamicParticle
protected void updateParticle(DynamicParticle p)
p
- particlepublic final boolean attach(DynamicParticle p)
When a particle is attached to the emitter, the particle position and velocity vectors will be modified to reflect the behaviour of the emitter. References to both vectors will, however, be preserved.
p
- particle
public final int attach(DynamicParticle[] pa)
pa
- particle array
public final boolean remove(DynamicParticle p)
If multiple references to the particle exist, they will all be removed
p
- particle
public final void clear()
public final void setForces(PSForce f)
f
- forcepublic final void setForces(PSForce[] f)
f
- force arraypublic final void clearForces()
public GenericEmitter copy()
The returned copy will contain an empty buffer the same size as that of the source particle and will adhere to the rules defined in the map() function of this object.
copy
in class DynamicParticle
public final void map(GenericEmitter e)
The returned object takes a copy of all emitter variables, with the exception for the dimension scalar vector for which a reference is used. DynamicParticle variables are mapped based on the rules defined in the DynamicParticle map() function.
e
- emitterDynamicParticle
protected PSVector getRadialVector()
protected PSVector getEmissionVector(PSVector d, float s)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |