Particle Emitter Bug

It seems a recent nightly build deprecated several methods regarding particle emitters created two noticeable problems.

  1. Setting an initial velocity when gravity is set to 0 doesn’t seem to affect particles at all. They simply stand at their spawning point.

    Example:

    [java]

    emitter.setGravity(0, 0, 0);

    emitter.getParticleInfluencer().setVelocityVariation(0.0f);

    emitter.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, -6));

    [/java]
  2. Gravity seems to affect particles before their appearance By this I mean that the initial velocity of particles gets faster faster in the direction of gravity. (previously, they would all spawn at the given initial velocity AND THEN get affected by gravity)

    On a side note, the addition of being able to set the direction of gravity is very nice :slight_smile:

    Also, is it possible to created a clipping plane for particles so they don’t get rendered under the world?



    Here’s a stand-alone application which demonstrates the first problem, the emitter’s and particle’s size, shape and velocity are the same as in my game.

    For some reason, I cannot replicate the second one in a stand-alone application. Hence I wonder what kind of variable change could cause this problem. (I previously was using a gravity of 0 and initial velocity in the desired direction, so the bug could always have been present in my case)

    [java]

    import com.jme3.app.SimpleApplication;

    import com.jme3.effect.ParticleEmitter;

    import com.jme3.effect.ParticleMesh;

    import com.jme3.effect.shapes.EmitterBoxShape;

    import com.jme3.material.Material;

    import com.jme3.math.ColorRGBA;

    import com.jme3.math.Vector3f;



    public class EmitterTest extends SimpleApplication

    {

    public static void main(final String[] args)

    {

    final EmitterTest app = new EmitterTest();

    app.start();

    }



    @Override

    public void simpleInitApp()

    {

    flyCam.setMoveSpeed(20);

    final ParticleEmitter debris = new ParticleEmitter(“Debris”, ParticleMesh.Type.Triangle, 20000);

    final Material debris_mat = new Material(assetManager, “Common/MatDefs/Misc/Particle.j3md”);

    debris_mat.setTexture(“Texture”, assetManager.loadTexture(“Effects/Explosion/Debris.png”));

    debris.setShape(new EmitterBoxShape(new Vector3f(-5, -5, 0f), new Vector3f(5, 5, 0f)));

    debris.setMaterial(debris_mat);

    debris.setParticlesPerSec(200);

    debris.setImagesX(3);

    debris.setImagesY(3); // 3x3 texture animation

    debris.setRotateSpeed(4);

    debris.setSelectRandomImage(true);

    debris.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, -6));

    debris.setStartColor(new ColorRGBA(1f, 1f, 1f, 1f));

    debris.setGravity(0f, 0f, 0.0f);

    debris.setStartSize(0.02f);

    debris.setEndSize(0.02f);

    debris.getParticleInfluencer().setVelocityVariation(Float.MIN_VALUE);

    rootNode.attachChild(debris);

    debris.emitAllParticles();

    }

    }

    [/java]

@Kaelthas: make you can look at this?

OK, I made a fix to that.

I forgot to set the initial velocity value and probably that caused problems.