Particle.getPosition - how to interpret the coordinates?


I'm just writing a fireworks simulator. Until now, everything works fine but now I want to implement a rocket which explodes two times: after some time, the particles of the first Explosion should explode a second time.

For that I need to know the Localtranslations of every Particle in relation to the explosion center.

But when I grab them by using Explosion.getParticle(0).getPosition() for example, I get some weird coordinates that make no sense for me. The values in there are ten times bigger than the Localtranslation of the explosion itself.

How can I get my translation from these numbers or is there another way to archieve that?



as far as i know, particles are usually released into world coordinates, so they don't have a relationship with its particlesystem anymore.

But why do you need to localTranslation of the particle? You want to create another explosion at the location of the particle, so you need its world location anyway no?

The particle files are attached to a single node which holds the localTranslation, so it would be nice if I set the localTranslation of the secondary explosions. But that would not be the problem.

But now how can I set the world coordinates of a ParticleMesh/Node? I cannot find any function like "setWorldCoordinates" to do this. I just tried with ParticleMesh.setWorldEmit, but it seems not to have any effect.

I also tried to calculate the translation by subtracting the translation of the rocket-node (which is attached directly to the root-Node) from the particle position. But also this seems not to be correct, the coords are far away from the explosion.

maybe particlesMesh.setOriginOffset() helps.

if the particleMesh's local and worldtranslation is 0 (not attached to any moved node), you should be able to set the originoffset (or local translation sould work too i guess) to the particles world translation.

If it dosen't work out, try to make a simple as possible testcase,


I just tried it out and it seems to work a bit better. The explosions are now inside the first explosion, but not at the right position. Maybe this is a scaling problem - but I dont know how to make the secondary explosions look smaller without scaling them.

I attached a testcase to this post, maybe this will help you…

The file is a .zip but I had to rename it to .txt so I could attach it here. Just download it and rename it back to .zip so it should work.

says its an corrupt zip file.

A simple (simplegame) testcase shouldn't be to big to post as code here tho.

The problem is that I'm using an external .jme file to load the particles, so you need that file too to make the testcase work.

I uploaded it now to a ftp server of mine, you can download the file archive here:

I tried it out on my system (ubuntu 8.10) and I was able to download & unpack the files from there. Hope it works for you too…

the issue seems to be the downscaling of the secondaries.

You need to multiply the offset with 1/scale.


There is another thing:
You are spawning a new thread where you attach a new explosion to the scene.
Thats usually a bad idea and can result in index out of bound exceptions and such.

Better use a Controller instead of the TimedTask.

This is a modified example, the location of the single particles still seems to be off a bit.

package particle;

import java.util.Timer;
import java.util.TimerTask;

import com.jme.image.Texture;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.Controller;
import com.jme.scene.shape.Box;
import com.jme.scene.state.BlendState;
import com.jme.scene.state.TextureState;
import com.jme.scene.state.ZBufferState;
import com.jme.util.TextureManager;
import com.jme.util.resource.ResourceLocatorTool;
import com.jme.util.resource.SimpleResourceLocator;
import com.jmex.effects.particles.ParticleFactory;
import com.jmex.effects.particles.ParticleMesh;
import com.jmex.effects.particles.SimpleParticleInfluenceFactory;

public class TestFireworks extends SimpleGame {
    float secondaryScale = 0.3f;
    ParticleMesh primary;
    ParticleMesh[] secondarys = new ParticleMesh[20];
    Box[] secondaryPos = new Box[20];

    protected void simpleInitGame() {
        try {
                    new SimpleResourceLocator(TestFireworks.class
                    new SimpleResourceLocator(TestFireworks.class
        } catch (URISyntaxException e) {


        cam.setLocation(new Vector3f(0, -50, 200));

        final Timer t = new Timer();
        TimerTask task = new TimerTask() {
            public void run() {

        t.schedule(task, 300, 4000);


    private void shoot() {
        final Timer t = new Timer();
        TimerTask task = new TimerTask() {
            public void run() {

        t.schedule(task, 2000, 200);

    private void attachSecondarys() {
        for (int i = 0; i < secondarys.length; i++) {
            try {
            } catch (InterruptedException e) {
            Vector3f pos = primary.getParticle(i).getPosition();
//            secondaryPos[i] = new Box("", pos, 0.5f, 0.5f, 0.5f);
//            rootNode.attachChild(secondaryPos[i]);

    private void loadParticles() {
        primary = createExplosion();
        for (int i = 0; i < secondarys.length; i++) {
            secondarys[i] = createExplosion();

    public static void main(String[] args) {
        SimpleGame app = new TestFireworks();
    private ParticleMesh createExplosion() {
        BlendState blendState = display.getRenderer().createBlendState();

        TextureState texState = display.getRenderer().createTextureState();
        Texture tex = TextureManager.loadTexture(ResourceLocatorTool.locateResource(
                ResourceLocatorTool.TYPE_TEXTURE, "spark.jpg"));

        ZBufferState zbufferState = display.getRenderer().createZBufferState();
        final ParticleMesh particleGeom = ParticleFactory.buildParticles("explosion", 30);
        // add a gravity effect to the particle effect
        particleGeom.addInfluence(SimpleParticleInfluenceFactory.createBasicGravity(new Vector3f(0, -1.00f, 0), true));
        particleGeom.setEmissionDirection(new Vector3f(0.0f, 1.0f, 0.0f));
        // allow to shoot particles in all directions (360