📄 particlecontroller.java
字号:
}
/**
* Get how soon after the last update the manager will send updates to the
* particles.
*
* @return The precision.
*/
public float getPrecision() {
return precision;
}
/**
* Set how soon after the last update the manager will send updates to the
* particles. Defaults to .01f (10ms)<br>
* <br>
* This means that if an update is called every 2ms (e.g. running at 500
* FPS) the particles position and stats will be updated every fifth frame
* with the elapsed time (in this case, 10ms) since previous update.
*
* @param precision
* in seconds
*/
public void setPrecision(float precision) {
this.precision = precision;
}
/**
* Get the variance possible on the release rate. 0.0f = no variance 0.5f =
* between releaseRate / 2f and 1.5f * releaseRate
*
* @return release variance as a percent.
*/
public float getReleaseVariance() {
return releaseVariance;
}
/**
* Set the variance possible on the release rate.
*
* @param variance
* release rate +/- variance as a percent (eg. .5 = 50%)
*/
public void setReleaseVariance(float variance) {
this.releaseVariance = variance;
}
/**
* Does this manager regulate the particle flow?
*
* @return true if this manager regulates how many particles per sec are
* emitted.
*/
public boolean isControlFlow() {
return controlFlow;
}
/**
* Set the regulate flow property on the manager.
*
* @param regulate
* regulate particle flow.
*/
public void setControlFlow(boolean regulate) {
this.controlFlow = regulate;
}
/**
* Does this manager use the particle's bounding volume to limit updates?
*
* @return true if this manager only updates the particles when they are in view.
*/
public boolean isUpdateOnlyInView() {
return updateOnlyInView;
}
/**
* Set the updateOnlyInView property on the manager.
*
* @param updateOnlyInView
* use the particle's bounding volume to limit updates.
*/
public void setUpdateOnlyInView(boolean updateOnlyInView) {
this.updateOnlyInView = updateOnlyInView;
}
/**
* @return the camera to be used in updateOnlyInView situations. If null,
* the current displaySystem's renderer camera is used.
*/
public Camera getViewCamera() {
return viewCamera;
}
/**
* @param viewCamera
* sets the camera to be used in updateOnlyInView situations. If
* null, the current displaySystem's renderer camera is used.
*/
public void setViewCamera(Camera viewCamera) {
this.viewCamera = viewCamera;
}
/**
* Get the Spatial that holds all of the particle information for display.
*
* @return Spatial holding particle information.
*/
public Spatial getParticles() {
return particles;
}
/**
* Return the number this manager has warmed up
*
* @return int
*/
public int getIterations() {
return iterations;
}
/**
* Sets the iterations for the warmup and calls warmUp with the number of
* iterations as the argument
*
* @param iterations
*/
public void setIterations(int iterations) {
this.iterations = iterations;
}
/**
* Add an external influence to this particle controller.
*
* @param influence
* ParticleInfluence
*/
public void addInfluence(ParticleInfluence influence) {
if (influences == null) influences = new ArrayList<ParticleInfluence>(1);
influences.add(influence);
}
/**
* Remove an influence from this particle controller.
*
* @param influence
* ParticleInfluence
* @return true if found and removed.
*/
public boolean removeInfluence(ParticleInfluence influence) {
if (influences == null) return false;
return influences.remove(influence);
}
/**
* Returns the list of influences acting on this particle controller.
*
* @return ArrayList
*/
public ArrayList<ParticleInfluence> getInfluences() {
return influences;
}
public void clearInfluences() {
if (influences != null)
influences.clear();
}
/**
* Subscribe a listener to receive mouse events. Enable event generation.
*
* @param listener to be subscribed
*/
public void addListener( ParticleControllerListener listener ) {
if ( listeners == null ) {
listeners = new ArrayList<ParticleControllerListener>();
}
listeners.add( listener );
}
/**
* Unsubscribe a listener. Disable event generation if no more listeners.
*
* @param listener to be unsuscribed
* @see #addListener(ParticleControllerListener)
*/
public void removeListener( ParticleControllerListener listener ) {
if ( listeners != null ) {
listeners.remove( listener );
}
}
/**
* Remove all listeners and disable event generation.
*/
public void removeListeners() {
if ( listeners != null ) {
listeners.clear();
}
}
/**
* Check if a listener is allready added to this ParticleController
* @param listener listener to check for
* @return true if listener is contained in the listenerlist
*/
public boolean containsListener( ParticleControllerListener listener ) {
if ( listeners != null ) {
return listeners.contains( listener );
}
return false;
}
/**
* Get all added ParticleController listeners
* @return ArrayList of listeners added to this ParticleController
*/
public ArrayList<ParticleControllerListener> getListeners() {
return listeners;
}
/**
* Runs the update method of this particle manager for iteration seconds
* with an update every .1 seconds (IE <code>iterations</code> * 10
* update(.1f) calls). This is used to "warm up" and get the particle
* manager going.
*
* @param iterations
* The number of iterations to warm up.
*/
public void warmUp(int iterations) {
// first set the initial positions of all the verts
particles.initAllParticlesLocation();
iterations *= 10;
for (int i = iterations; --i >= 0;)
update(.1f);
}
public void write(JMEExporter e) throws IOException {
super.write(e);
OutputCapsule capsule = e.getCapsule(this);
capsule.write(particles, "particleMesh", null);
capsule.write(releaseVariance, "releaseVariance", 0);
capsule.write(precision, "precision", 0);
capsule.write(controlFlow, "controlFlow", false);
capsule.write(updateOnlyInView, "updateOnlyInView", false);
capsule.write(iterations, "iterations", 0);
capsule.writeSavableArrayList(influences, "influences", null);
}
@SuppressWarnings("unchecked")
public void read(JMEImporter e) throws IOException {
super.read(e);
InputCapsule capsule = e.getCapsule(this);
particles = (ParticleSystem)capsule.readSavable("particleMesh", null);
releaseVariance = capsule.readFloat("releaseVariance", 0);
precision = capsule.readFloat("precision", 0);
controlFlow = capsule.readBoolean("controlFlow", false);
updateOnlyInView = capsule.readBoolean("updateOnlyInView", false);
iterations = capsule.readInt("iterations", 0);
influences = capsule.readSavableArrayList("influences", null);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -