Class Particle

java.lang.Object
com.ardor3d.extension.effect.particle.Particle
All Implemented Interfaces:
Savable

public class Particle extends Object implements Savable
Particle defines a single Particle of a Particle system. Generally, you would not interact with this class directly.
  • Constructor Details

    • Particle

      public Particle()
      Empty constructor - mostly for use with Savable interface
    • Particle

      public Particle(ParticleSystem parent)
      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

      public 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. 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 velocity
      position - new initial particle position
      lifeSpan - 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

      public void updateVerts(Camera cam)
      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

      public Vector3 getPosition()
      Returns:
      the current position of the particle in space
    • setPosition

      public void setPosition(Vector3 position)
      Set the position of the particle in space.
      Parameters:
      position - the new position in world coordinates
    • getStatus

      public Particle.Status getStatus()
      Returns:
      the current status of this particle.
      See Also:
    • setStatus

      public void setStatus(Particle.Status status)
      Set the status of this particle.
      Parameters:
      status - new status of this particle
      See Also:
    • getVelocity

      public Vector3 getVelocity()
      Returns:
      the current velocity of this particle
    • setVelocity

      public void setVelocity(Vector3 velocity)
      Set the current velocity of this particle
      Parameters:
      velocity - the new velocity
    • getCurrentColor

      public ColorRGBA 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

      public void setTriangleModel(Triangle t)
      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

      public Triangle getTriangleModel()
      Returns:
      the triangle model used by this particle
      See Also:
    • write

      public void write(OutputCapsule capsule) throws IOException
      Specified by:
      write in interface Savable
      Throws:
      IOException
    • read

      public void read(InputCapsule capsule) throws IOException
      Specified by:
      read in interface Savable
      Throws:
      IOException
    • getClassTag

      public Class<? extends Particle> getClassTag()
      Specified by:
      getClassTag in interface Savable