|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpslib.GenericParticle
pslib.DynamicParticle
public class DynamicParticle
DynamicParticle Class
The DynamicParticle object extends the functionality of the GenericParticle class by permitting dynamic behaviour over a particle life-span defined within the constructor.
Envelopes may be assigned to both particle alpha and size parameters allowing the modulation of variables dependent on the current particle decay. Similarly PSBehaviours may be attached to the particle, permitting per-frame modulation of parameters.
The results of alpha and size modulation envelopes may be obtained through the getRenderAlpha() and getRenderSize() functions. Calls to setAlpha() and setSize() will allow modification of the base value for the modulation envelope, while calls to getAlpha() and getSize() will return this base value.
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 | |
---|---|
DynamicParticle()
Create a new static object instance |
|
DynamicParticle(int d)
Create a new dynamic object instance with the specified decay time |
Method Summary | |
---|---|
void |
clearBehaviour()
Clear the particle behaviours |
DynamicParticle |
copy()
Return a copy of this DynamicParticle |
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 |
protected PSBehaviour[] |
getBehaviour()
Return the attached particle behaviour array |
float |
getDecay()
Return the current decay value between 1 and 0 |
int |
getDecayTime()
Return the remaining decay time in milliseconds |
int |
getInitialDecayTime()
Return the decay time specified on particle creation in milliseconds |
float |
getMass()
Return the particle mass |
float |
getRenderAlpha()
Return the modulated particle alpha value |
float |
getRenderSize()
Return the modulated particle size value |
StaticParticle |
getSnapshot()
Return a StaticParticle containing the current particle position, colour, modulated alpha, modulated size and remaining decay time. |
boolean |
isDead()
Return true if the particle is dead |
boolean |
isDynamic()
Return true if the particle is dynamic and is therefore decaying |
void |
map(DynamicParticle p)
Map the properties of this particle to that specified preserving references |
void |
render(processing.opengl.PGraphicsOpenGL pgl)
Render the particle to the specified OpenGL renderer |
void |
render(processing.opengl.PGraphicsOpenGL pgl,
PSVector cpv,
PSVector ctv,
PSVector cuv)
Render the particle to the specified OpenGL renderer |
void |
setAlphaEnvelope(PSRange e)
Set the particle alpha modulation envelope for dynamic particles |
void |
setBehaviour(PSBehaviour b)
Set the particle behaviour |
void |
setBehaviour(PSBehaviour[] b)
Set the particle behaviour |
void |
setDecayTime(int t)
Set the particle decay time |
void |
setMass(float m)
Set the particle mass |
void |
setSizeEnvelope(PSRange e)
Set the particle size modulation envelope for dynamic particles |
void |
update()
Update the particle |
Methods inherited from class pslib.GenericParticle |
---|
getAlpha, getColour, getPosition, getSize, getVelocity, setAlpha, setColour, setColour, setPosition, setSize, setVelocity |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DynamicParticle()
public DynamicParticle(int d)
d
- decay time (ms)Method Detail |
---|
public void setDecayTime(int t)
Calls to the function will reset the current particle decay curve and begin a new curve of the duration specified.
t
- decay time (ms)public float getDecay()
public int getDecayTime()
public int getInitialDecayTime()
public boolean isDynamic()
public boolean isDead()
public void setMass(float m)
Default: 1.0
m
- masspublic float getMass()
public void setBehaviour(PSBehaviour b)
b
- behaviourpublic void setBehaviour(PSBehaviour[] b)
The specified behaviours will be applied in the order in which the exist within the array
b
- behaviourprotected PSBehaviour[] getBehaviour()
public void clearBehaviour()
public void setAlphaEnvelope(PSRange e)
The alpha modulation value is a scalar applied to the particle alpha as specified with setAlpha(). For example, a minimum value of 0.5 and a maximum value of 2.0 with a LINEAR mode and a curve exponent of 1.0 will result in a modulation of particle alpha between half and double its specified value throughout the duration of the particle.
e
- envelopepublic float getRenderAlpha()
public void setSizeEnvelope(PSRange e)
The alpha modulation value is a scalar applied to the particle alpha as specified with setSize(). For example, a minimum value of 0.5 and a maximum value of 2.0 with a LINEAR mode and a curve exponent of 1.0 will result in a modulation of particle size between half and double its specified value throughout the duration of the particle.
e
- public float getRenderSize()
public StaticParticle getSnapshot()
public void update()
public void render(processing.opengl.PGraphicsOpenGL pgl)
render
in class GenericParticle
pgl
- OpenGL rendererpublic void render(processing.opengl.PGraphicsOpenGL pgl, PSVector cpv, PSVector ctv, PSVector cuv)
render
in class GenericParticle
pgl
- OpenGL renderercpv
- camera position vectorctv
- camera target vectorcuv
- camera up vectorpublic void debug(processing.opengl.PGraphicsOpenGL pgl)
The debug method renders the particle as a GenericParticle object discarding any dynamic modifications to particle properties.
pgl
- OpenGL rendererpublic void debug(processing.opengl.PGraphicsOpenGL pgl, PSVector cpv, PSVector ctv, PSVector cuv)
The debug method renders the particle as a GenericParticle object discarding any dynamic modifications to particle properties.
pgl
- OpenGL renderercpv
- camera position vectorctv
- camera target vectorcuv
- camera up vectorpublic DynamicParticle copy()
The returned object takes a copy of position, velocity, colour, alpha, size and mass variables, while references to particle alpha envelope, size envelope and attached behaviours are used. This decision was made to facilitate particle templates, which would rarely require independent envelopes or behaviours.
public final void map(DynamicParticle p)
The returned object takes a copy of position, velocity, colour, alpha, size and mass variables, while references to particle alpha envelope, size envelope and attached behaviours are used. This decision was made to facilitate particle templates, which would rarely require independent envelopes or behaviours.
p
- particle
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |