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 BoundingBoxboundingBoxNot used by the simulation, it should represent the bounding box containing all the particlesprotected static floatDEFAULT_TIME_STEPthe default time step used to update the simulationfloatdeltaTimeTime step, DO NOT CHANGE MANUALLYfloatdeltaTimeSqrTime step, DO NOT CHANGE MANUALLYEmitteremitterControls the emission of the particlesArray<Influencer>influencersUpdate the properties of the particlesjava.lang.StringnameName of the controllerParticleChannelsparticleChannelsParallelArrayparticlesParticles componentsParticleControllerRenderer<?,?>rendererControls the graphical representation of the particlesVector3scaleTransform flagsMatrix4transformCurrent 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 voidactivateParticles(int startIndex, int count)Generally called by the Emitter.protected voidallocateChannels(int maxParticleCount)protected voidbind()Bind the sub systems to the controller Called once during the init phase.protected voidcalculateBoundingBox()Updates the bounding box using the position channel.ParticleControllercopy()voiddispose()voiddraw()Updates the renderer used by this controller, usually this means the particles will be draw inside a batch.voidend()End the simulation.<K extends Influencer>
KfindInfluencer(java.lang.Class<K> influencerClass)BoundingBoxgetBoundingBox()voidgetTransform(Matrix4 transform)Set the given matrix to the current transformation matrix.voidinit()Initialize the controller.booleanisComplete()voidkillParticles(int startIndex, int count)Generally called by the Emitter.voidload(AssetManager manager, ResourceData data)voidmul(Matrix4 transform)Postmultiplies the current transformation with the given matrix.voidread(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.voidreset()Reset the simulation.voidrotate(Quaternion rotation)Post-multiplies the current transformation with a rotation matrix represented by the given quaternion.voidrotate(Vector3 axis, float angle)Post-multiplies the current transformation with a rotation matrix by the given angle around the given axis.voidsave(AssetManager manager, ResourceData data)voidscale(float scaleX, float scaleY, float scaleZ)Postmultiplies the current transformation with a scale matrix represented by the given scale on x,y,z.voidscale(Vector3 scale)Postmultiplies the current transformation with a scale matrix represented by the given scale vector.voidsetTransform(float x, float y, float z, float qx, float qy, float qz, float qw, float scale)Sets the current transformation.voidsetTransform(Matrix4 transform)Sets the current transformation to the given one.voidsetTranslation(Vector3 translation)voidstart()Start the simulation.voidtranslate(Vector3 translation)Postmultiplies the current transformation with a translation matrix represented by the given translation.voidupdate()Updates the particles datavoidupdate(float deltaTime)Updates the particles datavoidwrite(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:
writein interfaceJson.Serializable
-
read
public void read(Json json, JsonValue jsonMap)
- Specified by:
readin interfaceJson.Serializable
-
save
public void save(AssetManager manager, ResourceData data)
- Specified by:
savein interfaceResourceData.Configurable
-
load
public void load(AssetManager manager, ResourceData data)
- Specified by:
loadin interfaceResourceData.Configurable
-
-