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;
@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);
}
<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
<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;
@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);