Interpolation of particle spawning point

Hi,

I have an issue with the particle emitter. At every frame, I move my emitter like this :
[java] particleEmitter.setLocalTranslation(emissionPoint);
[/java]
Problem is that the particles are emitted at the emitter location, without interpolating this location from last frame to this one.

So whatever is my ParticlePerSec value, the effect is discontinued.

Does JMonkey manage this interpolation in a way or another? Or do I need to manage it myself? and in this last case, Where do you suggest to begin?

Thanks in advance.

Ben

Try this
http://hub.jmonkeyengine.org/javadoc/com/jme3/effect/ParticleEmitter.html#setInWorldSpace(boolean)

Thanks for the advise. I’ve tested to spawn particles in the emitter local space, adding the inverse velocity of the movement. This trick make the particle appear static in world space (only on straight move, though).

Anyway, the problem is the same : particle are emitted at each frame at the particle emitter location, regardless of the emitter position change since last frame.

at the speed of 10 meters per second and a fps of 30, we have 30 particle emission points with 33 cm between each, which is insuficient for the effect I need (Contrails at the wingtip of a plane).

Heberger image

Oh, but that is how particles work. They are discreet … particles so of course they are emitted where the locator is when it is time to emit a particle. A better way to do contrails is probably to make a line and use a custom shader.
I recall there was a discussion about contrails by someone making a space game a while ago, try to search for it.

Look at this post :wink:

else you can increase the number of particles emitted per second…

@haze said: else you can increase the number of particles emitted per second...

The problem is not the number of particles emitted but the place where they are emitted. increasing the number of particles will give me more particles on the same emission point.

I will try some extension of the ParticleEmitter, to make them spawned at the good location and time regarding the position and emission time of the last update, by interpolating.

@methusalah said: The problem is not the number of particles emitted but the place where they are emitted. increasing the number of particles will give me more particles on the same emission point.

I will try some extension of the ParticleEmitter, to make them spawned at the good location and time regarding the position and emission time of the last update, by interpolating.

But if you have more particles per second, you will have more emission tick…so less intervall between them…less gap…

This is what I first thought, yes. But as I said in the first post, the ParticleEmitter emit always on its location, without taking car of its last location, since last update.

So the emitter check its tpf, then emit the correct number of particle, and influence them to have proper age, but not proper location ! so if the mover is running fast, you can see the locations at each frame like on the picture.

If the soft runs at 250fps it’s not a problem but at 30/60fps, with tiny particles, it creates that ugly effect.

Here is a result. I think it is correct.
Hebergeur d'image

And the very tiny code modification in the updateParticleState method. Hope to see it in a future update.
[java]
private Vector3f lastPos;
private void updateParticleState(float tpf) {

    [...]

    // Spawns particles within the tpf timeslot with proper age
    float originalTPF = tpf;
    float interval = 1f / particlesPerSec;
    tpf += timeDifference;
    while (tpf > interval){
        tpf -= interval;
        Particle p = emitParticle(min, max);
        if (p != null){
            p.life -= tpf;
            p.position.interpolate(lastPos, 1-tpf/originalTPF);
            if (p.life <= 0){
                freeParticle(lastUsed);
            }else{
                updateParticle(p, tpf, min, max);
            }
        }
    }
    timeDifference = tpf;
    lastPos = new Vector3f(getWorldTranslation());

    [...]
}[/java]

The best way to get fixes/patches in is to make a pull request on GitHub. The second best is to post a diff-format snippet here on the forum. Although a pull request has like a million times bigger chance to be seen by the core devs.

Thanks I will try it

http://hub.jmonkeyengine.org/forum/topic/interpolation-of-particle-spawning-point-when-emitter-has-moved/