Class ParticleController

java.lang.Object
com.badlogic.gdx.graphics.g3d.particles.ParticleController
All Implemented Interfaces:
ResourceData.Configurable, Json.Serializable

public class ParticleController extends Object implements Json.Serializable, ResourceData.Configurable
Base class of all the particle controllers. Encapsulate the generic structure of a controller and methods to update the particles simulation.
  • Field Details

    • DEFAULT_TIME_STEP

      protected static final float DEFAULT_TIME_STEP
      the default time step used to update the simulation
      See Also:
    • name

      public String name
      Name of the controller
    • emitter

      public Emitter emitter
      Controls the emission of the particles
    • influencers

      public Array<Influencer> influencers
      Update the properties of the particles
    • renderer

      public ParticleControllerRenderer<?,?> renderer
      Controls the graphical representation of the particles
    • particles

      public ParallelArray particles
      Particles components
    • particleChannels

      public ParticleChannels particleChannels
    • transform

      public Matrix4 transform
      Current transform of the controller DO NOT CHANGE MANUALLY
    • scale

      public Vector3 scale
      Transform flags
    • boundingBox

      protected BoundingBox boundingBox
      Not used by the simulation, it should represent the bounding box containing all the particles
    • deltaTime

      public float deltaTime
      Time step, DO NOT CHANGE MANUALLY
    • deltaTimeSqr

      public float deltaTimeSqr
      Time step, DO NOT CHANGE MANUALLY
  • Constructor Details

  • Method Details

    • setTransform

      public void setTransform(Matrix4 transform)
      Sets the current transformation to the given one.
      Parameters:
      transform - the new transform matrix
    • setTransform

      public void setTransform(float x, float y, float z, float qx, float qy, float qz, float qw, float scale)
      Sets the current transformation.
    • rotate

      public void rotate(Quaternion rotation)
      Post-multiplies the current transformation with a rotation matrix represented by the given quaternion.
    • rotate

      public void rotate(Vector3 axis, float angle)
      Post-multiplies the current transformation with a rotation matrix by the given angle around the given axis.
      Parameters:
      axis - the rotation axis
      angle - the rotation angle in degrees
    • translate

      public void translate(Vector3 translation)
      Postmultiplies the current transformation with a translation matrix represented by the given translation.
    • setTranslation

      public void setTranslation(Vector3 translation)
    • scale

      public void scale(float scaleX, float scaleY, float scaleZ)
      Postmultiplies the current transformation with a scale matrix represented by the given scale on x,y,z.
    • scale

      public void scale(Vector3 scale)
      Postmultiplies the current transformation with a scale matrix represented by the given scale vector.
    • mul

      public void mul(Matrix4 transform)
      Postmultiplies the current transformation with the given matrix.
    • getTransform

      public void getTransform(Matrix4 transform)
      Set the given matrix to the current transformation matrix.
    • isComplete

      public boolean isComplete()
    • init

      public void init()
      Initialize the controller. All the sub systems will be initialized and binded to the controller. Must be called before any other method.
    • allocateChannels

      protected void allocateChannels(int maxParticleCount)
    • bind

      protected void bind()
      Bind the sub systems to the controller Called once during the init phase.
    • start

      public void start()
      Start the simulation.
    • reset

      public void reset()
      Reset the simulation.
    • end

      public void end()
      End the simulation.
    • activateParticles

      public void activateParticles(int startIndex, int count)
      Generally called by the Emitter. This method will notify all the sub systems that a given amount of particles has been activated.
    • killParticles

      public void killParticles(int startIndex, int count)
      Generally called by the Emitter. This method will notify all the sub systems that a given amount of particles has been killed.
    • update

      public void update()
      Updates the particles data
    • update

      public void update(float deltaTime)
      Updates the particles data
    • draw

      public void draw()
      Updates the renderer used by this controller, usually this means the particles will be draw inside a batch.
    • copy

      public ParticleController copy()
      Returns:
      a copy of this controller
    • dispose

      public void dispose()
    • getBoundingBox

      public BoundingBox getBoundingBox()
      Returns:
      a copy of this controller, should be used after the particle effect has been loaded.
    • calculateBoundingBox

      protected void calculateBoundingBox()
      Updates the bounding box using the position channel.
    • findInfluencer

      public <K extends Influencer> K findInfluencer(Class<K> influencerClass)
      Returns:
      the influencer having the given type.
    • removeInfluencer

      public <K extends Influencer> void removeInfluencer(Class<K> type)
      Removes the Influencer of the given type.
    • replaceInfluencer

      public <K extends Influencer> boolean replaceInfluencer(Class<K> type, K newInfluencer)
      Replaces the Influencer of the given type with the one passed as parameter.
    • write

      public void write(Json json)
      Specified by:
      write in interface Json.Serializable
    • read

      public void read(Json json, JsonValue jsonMap)
      Specified by:
      read in interface Json.Serializable
    • save

      public void save(AssetManager manager, ResourceData data)
      Specified by:
      save in interface ResourceData.Configurable
    • load

      public void load(AssetManager manager, ResourceData data)
      Specified by:
      load in interface ResourceData.Configurable