Class Particle
java.lang.Object
com.ardor3d.extension.effect.particle.Particle
- All Implemented Interfaces:
Savable
Particle
defines a single Particle of a Particle system. Generally, you would not interact with this
class directly.-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionParticle()
Empty constructor - mostly for use with Savable interfaceParticle
(ParticleSystem parent) Normal use constructor. -
Method Summary
Modifier and TypeMethodDescriptionint
double
double
getMass()
int
void
init()
Cause this particle to reset it's lifespan, velocity, color, age and size per the parent's settings. status is set to Status.Available and location is set to 0,0,0.void
init
(ReadOnlyVector3 velocity, ReadOnlyVector3 position, double lifeSpan) Cause this particle to reset it's color, age and size per the parent's settings. status is set to Status.Available.void
void
read
(InputCapsule capsule) void
recreateParticle
(double lifeSpan) Reset particle conditions.void
resetAge()
Resets current age to 0void
setPosition
(Vector3 position) Set the position of the particle in space.void
setStartIndex
(int index) Set the starting index where this particle is represented in its parent's geometry datavoid
setStatus
(Particle.Status status) Set the status of this particle.void
Sets a triangle model to use for particle calculations when using particle type ParticleType.GeomMesh.void
setVelocity
(Vector3 velocity) Set the current velocity of this particleboolean
updateAndCheck
(double secondsPassed) update position (using current position and velocity), color (interpolating between start and end color), size (interpolating between start and end size), spin (using parent's spin speed) and current age of particle.void
updateVerts
(Camera cam) Update the vertices for this particle, taking size, spin and viewer into consideration.void
write
(OutputCapsule capsule)
-
Constructor Details
-
Particle
public Particle()Empty constructor - mostly for use with Savable interface -
Particle
Normal use constructor. Sets up the parent and particle type for this particle.- Parameters:
parent
- the particle collection this particle belongs to
-
-
Method Details
-
init
public void init()Cause this particle to reset it's lifespan, velocity, color, age and size per the parent's settings. status is set to Status.Available and location is set to 0,0,0. Actual geometry data is not affected by this call, only particle params. -
init
Cause this particle to reset it's color, age and size per the parent's settings. status is set to Status.Available. Location, velocity and lifespan are set as given. Actual geometry data is not affected by this call, only particle params.- Parameters:
velocity
- new initial particle velocityposition
- new initial particle positionlifeSpan
- new particle lifespan in ms
-
recreateParticle
public void recreateParticle(double lifeSpan) Reset particle conditions. Besides the passed lifespan, we also reset color, size, and spin angle to their starting values (as given by parent.) Status is set to Status.Available.- Parameters:
lifeSpan
- the recreated particle's new lifespan
-
updateVerts
Update the vertices for this particle, taking size, spin and viewer into consideration. In the case of particle type ParticleType.GeomMesh, the original triangle normal is maintained rather than rotating it to face the camera or parent vectors.- Parameters:
cam
- Camera to use in determining viewer aspect. If null, or if parent is not set to camera facing, parent's left and up vectors are used.
-
updateAndCheck
public boolean updateAndCheck(double secondsPassed) update position (using current position and velocity), color (interpolating between start and end color), size (interpolating between start and end size), spin (using parent's spin speed) and current age of particle. If this particle's age is greater than its lifespan, it is set to status DEAD.
- Parameters:
secondsPassed
- number of seconds passed since last update.- Returns:
- true if this particle is not ALIVE (in other words, if it is ready to be reused.)
-
killParticle
public void killParticle() -
resetAge
public void resetAge()Resets current age to 0 -
getCurrentAge
public int getCurrentAge()- Returns:
- the current age of the particle in ms
-
getPosition
- Returns:
- the current position of the particle in space
-
setPosition
Set the position of the particle in space.- Parameters:
position
- the new position in world coordinates
-
getStatus
- Returns:
- the current status of this particle.
- See Also:
-
setStatus
Set the status of this particle.- Parameters:
status
- new status of this particle- See Also:
-
getVelocity
- Returns:
- the current velocity of this particle
-
setVelocity
Set the current velocity of this particle- Parameters:
velocity
- the new velocity
-
getCurrentColor
- Returns:
- the current color applied to this particle
-
getStartIndex
public int getStartIndex()- Returns:
- the start index of this particle in relation to where it exists in its parent's geometry data.
-
setStartIndex
public void setStartIndex(int index) Set the starting index where this particle is represented in its parent's geometry data- Parameters:
index
- the starting index where this particle is represented in its parent's geometry data
-
getMass
public double getMass()- Returns:
- the mass of this particle. Only used by ParticleInfluences such as drag.
-
getInvMass
public double getInvMass()- Returns:
- the inverse mass of this particle. Often useful for skipping constant division by mass calculations. If the mass is 0, the inverse mass is considered to be positive infinity. Conversely, if the mass is positive infinity, the inverse is 0. The inverse of negative infinity is considered to be -0.
-
setTriangleModel
Sets a triangle model to use for particle calculations when using particle type ParticleType.GeomMesh. The particle will maintain the triangle's ratio and plane of orientation. It will spin (if applicable) around the triangle's normal axis. The triangle should already have its center and normal fields calculated before calling this method.- Parameters:
t
- the triangle to model this particle after.
-
getTriangleModel
- Returns:
- the triangle model used by this particle
- See Also:
-
write
- Specified by:
write
in interfaceSavable
- Throws:
IOException
-
read
- Specified by:
read
in interfaceSavable
- Throws:
IOException
-
getClassTag
- Specified by:
getClassTag
in interfaceSavable
-