Class ParticleController
- java.lang.Object
-
- com.badlogic.gdx.graphics.g3d.particles.ParticleController
-
- All Implemented Interfaces:
ResourceData.Configurable
,Json.Serializable
public class ParticleController extends java.lang.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
Fields Modifier and Type Field Description protected BoundingBox
boundingBox
Not used by the simulation, it should represent the bounding box containing all the particlesprotected static float
DEFAULT_TIME_STEP
the default time step used to update the simulationfloat
deltaTime
Time step, DO NOT CHANGE MANUALLYfloat
deltaTimeSqr
Time step, DO NOT CHANGE MANUALLYEmitter
emitter
Controls the emission of the particlesArray<Influencer>
influencers
Update the properties of the particlesjava.lang.String
name
Name of the controllerParticleChannels
particleChannels
ParallelArray
particles
Particles componentsParticleControllerRenderer<?,?>
renderer
Controls the graphical representation of the particlesVector3
scale
Transform flagsMatrix4
transform
Current transform of the controller DO NOT CHANGE MANUALLY
-
Constructor Summary
Constructors Constructor Description ParticleController()
ParticleController(java.lang.String name, Emitter emitter, ParticleControllerRenderer<?,?> renderer, Influencer... influencers)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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
calculateBoundingBox()
Updates the bounding box using the position channel.ParticleController
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(java.lang.Class<K> influencerClass)
BoundingBox
getBoundingBox()
void
getTransform(Matrix4 transform)
Set the given matrix to the current transformation matrix.void
init()
Initialize the controller.boolean
isComplete()
void
killParticles(int startIndex, int count)
Generally called by the Emitter.void
load(AssetManager manager, ResourceData data)
void
mul(Matrix4 transform)
Postmultiplies the current transformation with the given matrix.void
read(Json json, JsonValue jsonMap)
<K extends Influencer>
voidremoveInfluencer(java.lang.Class<K> type)
Removes the Influencer of the given type.<K extends Influencer>
booleanreplaceInfluencer(java.lang.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
rotate(Vector3 axis, float angle)
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
scale(Vector3 scale)
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
translate(Vector3 translation)
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
write(Json json)
-
-
-
Field Detail
-
DEFAULT_TIME_STEP
protected static final float DEFAULT_TIME_STEP
the default time step used to update the simulation- See Also:
- Constant Field Values
-
name
public java.lang.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 Detail
-
ParticleController
public ParticleController()
-
ParticleController
public ParticleController(java.lang.String name, Emitter emitter, ParticleControllerRenderer<?,?> renderer, Influencer... influencers)
-
-
Method Detail
-
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 axisangle
- 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(java.lang.Class<K> influencerClass)
- Returns:
- the influencer having the given type.
-
removeInfluencer
public <K extends Influencer> void removeInfluencer(java.lang.Class<K> type)
Removes the Influencer of the given type.
-
replaceInfluencer
public <K extends Influencer> boolean replaceInfluencer(java.lang.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 interfaceJson.Serializable
-
read
public void read(Json json, JsonValue jsonMap)
- Specified by:
read
in interfaceJson.Serializable
-
save
public void save(AssetManager manager, ResourceData data)
- Specified by:
save
in interfaceResourceData.Configurable
-
load
public void load(AssetManager manager, ResourceData data)
- Specified by:
load
in interfaceResourceData.Configurable
-
-