|
@@ -75,7 +75,6 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
|
|
private static final EmitterShape DEFAULT_SHAPE = new EmitterPointShape(Vector3f.ZERO);
|
|
private static final EmitterShape DEFAULT_SHAPE = new EmitterPointShape(Vector3f.ZERO);
|
|
|
private static final ParticleInfluencer DEFAULT_INFLUENCER = new DefaultParticleInfluencer();
|
|
private static final ParticleInfluencer DEFAULT_INFLUENCER = new DefaultParticleInfluencer();
|
|
|
-
|
|
|
|
|
private ParticleEmitterControl control;
|
|
private ParticleEmitterControl control;
|
|
|
private EmitterShape shape = DEFAULT_SHAPE;
|
|
private EmitterShape shape = DEFAULT_SHAPE;
|
|
|
private ParticleMesh particleMesh;
|
|
private ParticleMesh particleMesh;
|
|
@@ -110,19 +109,19 @@ public class ParticleEmitter extends Geometry {
|
|
|
public static class ParticleEmitterControl implements Control {
|
|
public static class ParticleEmitterControl implements Control {
|
|
|
|
|
|
|
|
ParticleEmitter parentEmitter;
|
|
ParticleEmitter parentEmitter;
|
|
|
-
|
|
|
|
|
- public ParticleEmitterControl(){
|
|
|
|
|
|
|
+
|
|
|
|
|
+ public ParticleEmitterControl() {
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- public ParticleEmitterControl(ParticleEmitter parentEmitter){
|
|
|
|
|
|
|
+
|
|
|
|
|
+ public ParticleEmitterControl(ParticleEmitter parentEmitter) {
|
|
|
this.parentEmitter = parentEmitter;
|
|
this.parentEmitter = parentEmitter;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
public Control cloneForSpatial(Spatial spatial) {
|
|
public Control cloneForSpatial(Spatial spatial) {
|
|
|
return this; // WARNING: Sets wrong control on spatial. Will be
|
|
return this; // WARNING: Sets wrong control on spatial. Will be
|
|
|
- // fixed automatically by ParticleEmitter.clone() method.
|
|
|
|
|
|
|
+ // fixed automatically by ParticleEmitter.clone() method.
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
public void setSpatial(Spatial spatial) {
|
|
public void setSpatial(Spatial spatial) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -153,21 +152,21 @@ public class ParticleEmitter extends Geometry {
|
|
|
public ParticleEmitter clone() {
|
|
public ParticleEmitter clone() {
|
|
|
ParticleEmitter clone = (ParticleEmitter) super.clone();
|
|
ParticleEmitter clone = (ParticleEmitter) super.clone();
|
|
|
clone.shape = shape.deepClone();
|
|
clone.shape = shape.deepClone();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Reinitialize particle list
|
|
// Reinitialize particle list
|
|
|
clone.setNumParticles(particles.length);
|
|
clone.setNumParticles(particles.length);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
clone.faceNormal = faceNormal.clone();
|
|
clone.faceNormal = faceNormal.clone();
|
|
|
clone.startColor = startColor.clone();
|
|
clone.startColor = startColor.clone();
|
|
|
clone.endColor = endColor.clone();
|
|
clone.endColor = endColor.clone();
|
|
|
clone.particleInfluencer = particleInfluencer.clone();
|
|
clone.particleInfluencer = particleInfluencer.clone();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// remove wrong control
|
|
// remove wrong control
|
|
|
clone.controls.remove(control);
|
|
clone.controls.remove(control);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// put correct control
|
|
// put correct control
|
|
|
clone.controls.add(new ParticleEmitterControl(clone));
|
|
clone.controls.add(new ParticleEmitterControl(clone));
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Reinitialize particle mesh
|
|
// Reinitialize particle mesh
|
|
|
switch (meshType) {
|
|
switch (meshType) {
|
|
|
case Point:
|
|
case Point:
|
|
@@ -183,7 +182,7 @@ public class ParticleEmitter extends Geometry {
|
|
|
}
|
|
}
|
|
|
clone.particleMesh.initParticleData(clone, clone.particles.length);
|
|
clone.particleMesh.initParticleData(clone, clone.particles.length);
|
|
|
clone.particleMesh.setImagesXY(clone.imagesX, clone.imagesY);
|
|
clone.particleMesh.setImagesXY(clone.imagesX, clone.imagesY);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return clone;
|
|
return clone;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -201,8 +200,8 @@ public class ParticleEmitter extends Geometry {
|
|
|
|
|
|
|
|
meshType = type;
|
|
meshType = type;
|
|
|
|
|
|
|
|
- this.setNumParticles(numParticles);
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
// Must create clone of shape/influencer so that a reference to a static is
|
|
// Must create clone of shape/influencer so that a reference to a static is
|
|
|
// not maintained
|
|
// not maintained
|
|
|
shape = shape.deepClone();
|
|
shape = shape.deepClone();
|
|
@@ -223,7 +222,8 @@ public class ParticleEmitter extends Geometry {
|
|
|
default:
|
|
default:
|
|
|
throw new IllegalStateException("Unrecognized particle type: " + meshType);
|
|
throw new IllegalStateException("Unrecognized particle type: " + meshType);
|
|
|
}
|
|
}
|
|
|
- particleMesh.initParticleData(this, particles.length);
|
|
|
|
|
|
|
+ this.setNumParticles(numParticles);
|
|
|
|
|
+// particleMesh.initParticleData(this, particles.length);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -330,10 +330,17 @@ public class ParticleEmitter extends Geometry {
|
|
|
for (int i = 0; i < numParticles; i++) {
|
|
for (int i = 0; i < numParticles; i++) {
|
|
|
particles[i] = new Particle();
|
|
particles[i] = new Particle();
|
|
|
}
|
|
}
|
|
|
|
|
+ //We have to reinit the mesh's buffers with the new size
|
|
|
|
|
+ particleMesh.initParticleData(this, particles.length);
|
|
|
|
|
+ particleMesh.setImagesXY(this.imagesX, this.imagesY);
|
|
|
firstUnUsed = 0;
|
|
firstUnUsed = 0;
|
|
|
lastUsed = -1;
|
|
lastUsed = -1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public int getMaxNumParticles() {
|
|
|
|
|
+ return particles.length;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Returns a list of all particles (shouldn't be used in most cases).
|
|
* Returns a list of all particles (shouldn't be used in most cases).
|
|
|
*
|
|
*
|
|
@@ -1117,12 +1124,12 @@ public class ParticleEmitter extends Geometry {
|
|
|
super.read(im);
|
|
super.read(im);
|
|
|
InputCapsule ic = im.getCapsule(this);
|
|
InputCapsule ic = im.getCapsule(this);
|
|
|
shape = (EmitterShape) ic.readSavable("shape", DEFAULT_SHAPE);
|
|
shape = (EmitterShape) ic.readSavable("shape", DEFAULT_SHAPE);
|
|
|
-
|
|
|
|
|
- if (shape == DEFAULT_SHAPE){
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (shape == DEFAULT_SHAPE) {
|
|
|
// Prevent reference to static
|
|
// Prevent reference to static
|
|
|
shape = shape.deepClone();
|
|
shape = shape.deepClone();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
meshType = ic.readEnum("meshType", ParticleMesh.Type.class, ParticleMesh.Type.Triangle);
|
|
meshType = ic.readEnum("meshType", ParticleMesh.Type.class, ParticleMesh.Type.Triangle);
|
|
|
int numParticles = ic.readInt("numParticles", 0);
|
|
int numParticles = ic.readInt("numParticles", 0);
|
|
|
this.setNumParticles(numParticles);
|
|
this.setNumParticles(numParticles);
|
|
@@ -1161,17 +1168,17 @@ public class ParticleEmitter extends Geometry {
|
|
|
particleMesh.setImagesXY(imagesX, imagesY);
|
|
particleMesh.setImagesXY(imagesX, imagesY);
|
|
|
|
|
|
|
|
particleInfluencer = (ParticleInfluencer) ic.readSavable("influencer", DEFAULT_INFLUENCER);
|
|
particleInfluencer = (ParticleInfluencer) ic.readSavable("influencer", DEFAULT_INFLUENCER);
|
|
|
- if (particleInfluencer == DEFAULT_INFLUENCER){
|
|
|
|
|
|
|
+ if (particleInfluencer == DEFAULT_INFLUENCER) {
|
|
|
particleInfluencer = particleInfluencer.clone();
|
|
particleInfluencer = particleInfluencer.clone();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- if (im.getFormatVersion() == 0){
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (im.getFormatVersion() == 0) {
|
|
|
// compatibility before the control inside particle emitter
|
|
// compatibility before the control inside particle emitter
|
|
|
// was changed:
|
|
// was changed:
|
|
|
// find it in the controls and take it out, then add the proper one in
|
|
// find it in the controls and take it out, then add the proper one in
|
|
|
- for (int i = 0; i < controls.size(); i++){
|
|
|
|
|
|
|
+ for (int i = 0; i < controls.size(); i++) {
|
|
|
Object obj = controls.get(i);
|
|
Object obj = controls.get(i);
|
|
|
- if (obj instanceof ParticleEmitter){
|
|
|
|
|
|
|
+ if (obj instanceof ParticleEmitter) {
|
|
|
controls.remove(i);
|
|
controls.remove(i);
|
|
|
// now add the proper one in
|
|
// now add the proper one in
|
|
|
controls.add(new ParticleEmitterControl(this));
|
|
controls.add(new ParticleEmitterControl(this));
|
|
@@ -1180,11 +1187,11 @@ public class ParticleEmitter extends Geometry {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// compatability before gravity was not a vector but a float
|
|
// compatability before gravity was not a vector but a float
|
|
|
- if (gravity == null){
|
|
|
|
|
|
|
+ if (gravity == null) {
|
|
|
gravity = new Vector3f();
|
|
gravity = new Vector3f();
|
|
|
gravity.y = ic.readFloat("gravity", 0);
|
|
gravity.y = ic.readFloat("gravity", 0);
|
|
|
}
|
|
}
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
// since the parentEmitter is not loaded, it must be
|
|
// since the parentEmitter is not loaded, it must be
|
|
|
// loaded separately
|
|
// loaded separately
|
|
|
control = getControl(ParticleEmitterControl.class);
|
|
control = getControl(ParticleEmitterControl.class);
|