How can I make the particle be always on the top of the screen?

hey, does anyone know how ParticleEmitter works in a camNode, not rootNode?
I mean I has created a ParticleEmitter, but with an background image, it always does not show anything, if I remove the background, the ParticleEmitter works fine.
So I just don’t know how to fix this problem.
I already search a lot of posts but no one can help me.
this is an example, the “running” image and background image inside the java code are attached
[java]
package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh;
import com.jme3.effect.ParticleMesh.Type;
import com.jme3.material.Material;
import com.jme3.material.RenderState.BlendMode;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector4f;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.queue.RenderQueue.Bucket;
import com.jme3.scene.CameraNode;
import com.jme3.texture.Texture;
import tonegod.gui.core.Element;
import tonegod.gui.core.Screen;

/**

  • test

  • @author normenhansen
    */
    public class Main extends SimpleApplication {

    public static void main(String[] args) {
    Main app = new Main();
    app.start();
    }
    CameraNode camNode = new CameraNode(“camNode”, cam);

    @Override
    public void simpleInitApp() {
    Screen screen = new Screen(this);
    ParticleEmitter animation = new ParticleEmitter(“Forward”, ParticleMesh.Type.Triangle, 1);
    Material material = new Material(assetManager,
    “Common/MatDefs/Misc/Unshaded.j3md”);
    Texture texture = assetManager.loadTexture(“Textures/running.png”);
    material.setTexture(“ColorMap”, texture);
    animation.setMaterial(material);
    animation.setHighLife(5);
    animation.setLowLife(5);
    animation.setImagesX(8);
    animation.setImagesY(1);
    //why only 1 parameter? If I could put x and y values I think it would work
    animation.setStartSize(0.65f);
    animation.setEndSize(0.65f);
    animation.setGravity(0, 0, 0);
    Element background = new Element(
    screen,
    “hello”, // UID
    new Vector2f(0, 0), // position
    new Vector2f(5760, 3240), // dimensions
    new Vector4f(1, 1, 1, 1), // resizeBorders
    “Images/map.jpg”);
    camNode.attachChild(background);
    camNode.attachChild(animation);
    rootNode.attachChild(camNode);
    }

    @Override
    public void simpleUpdate(float tpf) {
    //TODO: add update code
    }

    @Override
    public void simpleRender(RenderManager rm) {
    //TODO: add render code
    }
    }

[/java]

Sizes on the GUI node are in pixels. You have set the sizes on your particles to be less than a pixel large!

<cite>@zarch said:</cite> Sizes on the GUI node are in pixels. You have set the sizes on your particles to be less than a pixel large!

sorry, I don’t get it, could you tell me more?Thanks

delete

Size on the GUI node is in pixels.

Size 1 = 1 pixel. Size 2 = 2 pixels

You have set the particles to be 0.65 pixels size.

That’s smaller than a pixel.

Your monitor might not show anything at all, or at most will be showing a single dot.

I don’t know how much clearer it can be :s

<cite>@zarch said:</cite> Size on the GUI node is in pixels.

Size 1 = 1 pixel. Size 2 = 2 pixels

You have set the particles to be 0.65 pixels size.

That’s smaller than a pixel.

Your monitor might not show anything at all, or at most will be showing a single dot.

I don’t know how much clearer it can be :s

even that I set the pixel size to be more than 100, the problem is still there, the background image still cover the particle and I don’t know why, anyway, thanks for reply.

this is the output with the particle in the center of screen

What Z did you position them at? The GUI node is in parallel projection but there is still a z dimension.

…and I think the gui bucket is sorted by the z of the object rather than nearest point like the opaque/transparent buckets.

<cite>@zarch said:</cite> What Z did you position them at? The GUI node is in parallel projection but there is still a z dimension.
<cite>@pspeed said:</cite> ...and I think the gui bucket is sorted by the z of the object rather than nearest point like the opaque/transparent buckets.

I think I got the idea,
set the background image has z = 0, and set the particle has z >0
is that right ?
However, when I try to do this, the problem is still there
still, how can I make the particle always on the top of the screen?
here is the code I try:
[java]
package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.effect.ParticleEmitter;
import com.jme3.effect.ParticleMesh;
import com.jme3.material.Material;
import com.jme3.material.RenderState.BlendMode;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector4f;
import com.jme3.renderer.RenderManager;
import com.jme3.renderer.queue.RenderQueue.Bucket;
import com.jme3.scene.CameraNode;
import com.jme3.texture.Texture;
import tonegod.gui.core.Element;
import tonegod.gui.core.Screen;

/**

  • test

  • @author normenhansen
    */
    public class Main extends SimpleApplication {

    public static void main(String args) {
    Main app = new Main();
    app.start();
    }
    CameraNode camNode = new CameraNode(“camNode”, cam);

    @Override
    public void simpleInitApp() {
    Screen screen = new Screen(this);
    ParticleEmitter animation = new ParticleEmitter(“Forward”, ParticleMesh.Type.Triangle, 1);
    Material material = new Material(assetManager,
    “Common/MatDefs/Misc/Unshaded.j3md”);
    Texture texture = assetManager.loadTexture(“Textures/running.png”);
    material.setTexture(“ColorMap”, texture);
    animation.setMaterial(material);
    animation.setHighLife(5);
    animation.setLowLife(5);
    animation.setImagesX(8);
    animation.setImagesY(1);
    //why only 1 parameter? If I could put x and y values I think it would work
    animation.setStartSize(0.65f);
    animation.setEndSize(0.65f);
    animation.setGravity(0, 0, 0);

      material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
      animation.setQueueBucket(Bucket.Transparent);
      Element background = new Element(
              screen,
              "hello", // UID
              new Vector2f(0, 0), // position
              new Vector2f(5760, 3240), // dimensions
              new Vector4f(1, 1, 1, 1), // resizeBorders
              "Images/map.jpg");
      background.setLocalTranslation(0, 0, 0);
      animation.setLocalTranslation(0, 0, 5f);
      camNode.attachChild(background);
      camNode.attachChild(animation);
      rootNode.attachChild(camNode);
    

    }

    @Override
    public void simpleUpdate(float tpf) {
    //TODO: add update code
    }

    @Override
    public void simpleRender(RenderManager rm) {
    //TODO: add render code
    }
    }

[/java]

Negative z points towards you, not positive… and your size of your particles is still less than one world unit…

Oh, wait … you are adding them to a camera node not the GU node… in which case world units would be correct.

However you are setting the size to one in pixels and the size of the other in world units.

I think you really need to go read again on what the root node, the GUI node (and to a lesser extent cam nodes) all do.

Maybe take a step back and describe what you are trying to achieve rather than what you have done so far to try and get there.

problem is solved after I try to use viewPort.