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 Summary
Modifier and TypeFieldDescriptionprotected BoundingBox
Not used by the simulation, it should represent the bounding box containing all the particlesprotected static final float
the default time step used to update the simulationfloat
Time step, DO NOT CHANGE MANUALLYfloat
Time step, DO NOT CHANGE MANUALLYControls the emission of the particlesUpdate the properties of the particlesName of the controllerParticles componentsControls the graphical representation of the particlesTransform flagsCurrent transform of the controller DO NOT CHANGE MANUALLY -
Constructor Summary
ConstructorDescriptionParticleController
(String name, Emitter emitter, ParticleControllerRenderer<?, ?> renderer, Influencer... influencers) -
Method Summary
Modifier and TypeMethodDescriptionvoid
activateParticles
(int startIndex, int count) Generally called by the Emitter.protected void
allocateChannels
(int maxParticleCount) protected void
bind()
Bind the sub systems to the controller Called once during the init phase.protected void
Updates the bounding box using the position channel.copy()
void
dispose()
void
draw()
Updates the renderer used by this controller, usually this means the particles will be draw inside a batch.void
end()
End the simulation.<K extends Influencer>
KfindInfluencer
(Class<K> influencerClass) void
getTransform
(Matrix4 transform) Set the given matrix to the current transformation matrix.void
init()
Initialize the controller.boolean
void
killParticles
(int startIndex, int count) Generally called by the Emitter.void
load
(AssetManager manager, ResourceData data) void
Postmultiplies the current transformation with the given matrix.void
<K extends Influencer>
voidremoveInfluencer
(Class<K> type) Removes the Influencer of the given type.<K extends Influencer>
booleanreplaceInfluencer
(Class<K> type, K newInfluencer) Replaces the Influencer of the given type with the one passed as parameter.void
reset()
Reset the simulation.void
rotate
(Quaternion rotation) Post-multiplies the current transformation with a rotation matrix represented by the given quaternion.void
Post-multiplies the current transformation with a rotation matrix by the given angle around the given axis.void
save
(AssetManager manager, ResourceData data) 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.void
Postmultiplies the current transformation with a scale matrix represented by the given scale vector.void
setTransform
(float x, float y, float z, float qx, float qy, float qz, float qw, float scale) Sets the current transformation.void
setTransform
(Matrix4 transform) Sets the current transformation to the given one.void
setTranslation
(Vector3 translation) void
start()
Start the simulation.void
Postmultiplies the current transformation with a translation matrix represented by the given translation.void
update()
Updates the particles datavoid
update
(float deltaTime) Updates the particles datavoid
-
Field Details
-
DEFAULT_TIME_STEP
protected static final float DEFAULT_TIME_STEPthe default time step used to update the simulation- See Also:
-
name
Name of the controller -
emitter
Controls the emission of the particles -
influencers
Update the properties of the particles -
renderer
Controls the graphical representation of the particles -
particles
Particles components -
particleChannels
-
transform
Current transform of the controller DO NOT CHANGE MANUALLY -
scale
Transform flags -
boundingBox
Not used by the simulation, it should represent the bounding box containing all the particles -
deltaTime
public float deltaTimeTime step, DO NOT CHANGE MANUALLY -
deltaTimeSqr
public float deltaTimeSqrTime step, DO NOT CHANGE MANUALLY
-
-
Constructor Details
-
ParticleController
public ParticleController() -
ParticleController
public ParticleController(String name, Emitter emitter, ParticleControllerRenderer<?, ?> renderer, Influencer... influencers)
-
-
Method Details
-
setTransform
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
Post-multiplies the current transformation with a rotation matrix represented by the given quaternion. -
rotate
Post-multiplies the current transformation with a rotation matrix by the given angle around the given axis.- Parameters:
axis
- the rotation axisangle
- the rotation angle in degrees
-
translate
Postmultiplies the current transformation with a translation matrix represented by the given translation. -
setTranslation
-
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
Postmultiplies the current transformation with a scale matrix represented by the given scale vector. -
mul
Postmultiplies the current transformation with the given matrix. -
getTransform
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
- Returns:
- a copy of this controller
-
dispose
public void dispose() -
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
- Returns:
- the influencer having the given type.
-
removeInfluencer
Removes the Influencer of the given type. -
replaceInfluencer
Replaces the Influencer of the given type with the one passed as parameter. -
write
- Specified by:
write
in interfaceJson.Serializable
-
read
- Specified by:
read
in interfaceJson.Serializable
-
save
- Specified by:
save
in interfaceResourceData.Configurable
-
load
- Specified by:
load
in interfaceResourceData.Configurable
-