|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjme.entity.effects.ParticleEmitter
ParticleEmitter
controls and maintains a number of
Particle
s. The emitter handles creation of a particle
setting the particles attributes to those defined by the user
creating the emitter. An emitter updates the particle during
a call to update
setting it's new position, size,
color and transparency.
Size and color have a start and end value, where these values
are interpolated through the life of the particle.
Another important note is that the gravity value is what handles
the updating of the velocity of individual particles. When a
particle is first created, it's velocity is in a random direction.
It is not until the gravity takes hold that it will travel in
the desired direction. This adds realism to the particle emitter.
Constructor Summary | |
ParticleEmitter(int numParticles)
Constructor instantiates a new ParticleEmitter
object, intializing the particle array for the number of
particles this emitter is responsible for. |
Method Summary | |
void |
loopAnimation(boolean value)
loopAnimation determines whether to continue animating
the particles after the first batch. |
void |
render()
render renders a quad for each particle using
a billboarding effect so that the particle is always facing
the viewport. |
void |
setEndColor(Vector endColor)
setEndColor sets the final color of the particle
just before it dies. |
void |
setEndSize(Vector endSize)
setEndSize sets the final size of the particle
just before it dies. |
void |
setFade(float fade)
setFade sets the fade value of the particles. |
void |
setFriction(float friction)
setFriction sets the value that the particles
slow down during their travels. |
void |
setGravity(Vector gravity)
setGravity sets the value of the forces that will
be acting upon the particles. |
void |
setPosition(Vector position)
setPosition sets the position of the emitter. |
void |
setSpeed(float speed)
setSpeed sets the speed at which the particle engine
updates. |
void |
setStartColor(Vector startColor)
setStartColor sets the starting color of the
particle. |
void |
setStartSize(Vector startSize)
setStartSize sets the starting size of the
particle. |
void |
setTexture(java.lang.String filename)
setTexture assigns the texture to be
associated with the particles. |
void |
update(float timeFraction)
update updates each particles position, velocity, life,
color and size. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ParticleEmitter(int numParticles)
ParticleEmitter
object, intializing the particle array for the number of
particles this emitter is responsible for.
numParticles
- the number of particles that will be
on screen at any one time.Method Detail |
public void update(float timeFraction)
update
updates each particles position, velocity, life,
color and size. If a particles life has reached zero, it is considered
dead and will be replaced by a new particle.
timeFraction
- the time factor between frames.public void render()
render
renders a quad for each particle using
a billboarding effect so that the particle is always facing
the viewport. This gives us a very good three dimensional
effect using two dimensional objects.
public void setFriction(float friction)
setFriction
sets the value that the particles
slow down during their travels. A typical value will be anywhere
between 1 and 10. A negative value will cause the particle to
travel in the opposite direction.
friction
- the new friction value.public void setEndColor(Vector endColor)
setEndColor
sets the final color of the particle
just before it dies. This color is interpolated with the
start color.
endColor
- the final color of the particle.public void setEndSize(Vector endSize)
setEndSize
sets the final size of the particle
just before it dies. This size is interpolated with the
start size.
endSize
- the final size of the particle.public void setGravity(Vector gravity)
setGravity
sets the value of the forces that will
be acting upon the particles. This value is what determines
the direction of the particles velocity.
gravity
- the forces that will be acting on the particle.public void setStartColor(Vector startColor)
setStartColor
sets the starting color of the
particle. This color is interpolated with the final
color.
startColor
- the starting color of the particles.public void setStartSize(Vector startSize)
setStartSize
sets the starting size of the
particle. This size is interpolated with the final size.
startSize
- the starting size of the particles.public void setFade(float fade)
setFade
sets the fade value of the particles. The
final fade value is determined by multiplying the fade value by
two and then multiplying by a random number between 0 and 1. Therefore,
the fade value determines the minimum and fade * 2 is the maximum.
fade
- the fade value of the particles.public void setPosition(Vector position)
setPosition
sets the position of the emitter. This
will determine the initial position of each particle as they are
generated.
position
- public void setSpeed(float speed)
setSpeed
sets the speed at which the particle engine
updates. By default the speed is 1.
speed
- the speed of the updates.public void setTexture(java.lang.String filename)
setTexture
assigns the texture to be
associated with the particles.
filename
- the image file of the texture.public void loopAnimation(boolean value)
loopAnimation
determines whether to continue animating
the particles after the first batch. That is, a fire would continue
to burn, but there would only be a single explosion.
value
- true loop, false only create a single batch.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |