Effects in the GUI node

Hi all,



I’m wanting to add a bit of a “flourish” with some particle effects and ideally I’d like them to appear on top of the nifty GUI.



I tried attaching the particle emitter to the gui node (with appropriate starting co-ords) but while there was no error there was also no particles…is this something that is possible to achieve? I’ve a fall back plan if it isn’t easy but thought I’d ask here first :slight_smile:



Thanks,

Z

Do particle emitters need to be scaled larger to be visible as more than one pixel on the guiNode? I know this is the case for geometries.



Perhaps a non-ambient light source also needs to be attached to the guiNode.

Particles are unlit I believe. I changed the start size to 2f and end size to 5f, moved the emitter to new EmitterBoxShape(new Vector3f(100,100,0), new Vector3f(111,100,0)) and attached the emitter to the guiNode

Is it possible your Z-order (being 0) is underneath everything? Try something like 1.0f or higher and see what happens.

I was trying it in an empty screen (I have a test project for such things) so it can’t have been that. It worked fine attached to the root node, not at all attached to the gui node. (I’m wondering if its something to do with buckets).



Having said that I’ve decided that I don’t need it here as I’m going to do the pyros on the 3d object not the gui anyway so this isn’t a blocking problem any more. I would still like to know how to do this for future applications though so I’ll leave the question open.

Without code it’s hard to guess, but given that screen real-estate is rather limited, it’s also possible that your particles ended up being outside the screen if you didn’t do a translation to screen space.



I’ve also never tried that, so it might be possible that it’s not really doable.

Just got the same problem here.



The part I’m working on right now is a 2D vehicle controlled over a map. Your vehicle gets damaged by environmental events and when you’ve lots your shields and all your crew the ship is supposed to “explode” but nothing happens when the emitter is tied to the guiNode. :confused: Rather disappointing.



Nothing fancy going on. Using the basic explosion palette.



[java]

// Harvester is on planet, check if hit by environmental stuff.

hurtVehicle(harvester.getLocation(), tpf);

if (harvester.isDestroyed()) {

// harvester has just been destroyed. Start the explosion particles.

/** Explosion effect. Uses Texture from jme3-test-data library! */

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

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

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

debris.setMaterial(debris_mat);

debris.setImagesX(3);

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

debris.setRotateSpeed(4);

debris.setSelectRandomImage(true);

debris.getParticleInfluencer().setInitialVelocity(new Vector3f(0, 0, 4));

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

debris.setEndColor(new ColorRGBA(1f, 0f, 0f, 1f));

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

debris.getParticleInfluencer().setVelocityVariation(.60f);

debris.setLocalTranslation(harvester.getLocation().x, harvester.getLocation().y, 0.9f);

mapSurfaceNode.attachChild(debris);

debris.emitAllParticles();

}

[/java]



Oddly enough, if I comment the “setLocalTranslation(…)” I can see some of the debris flying around but underneath the Quad that is the map. With that line uncommented there is nothing at all. Anyway, nothing that I can see.

Why don’t you create another viewport on top of the default one, and put your particle effects there? just make sure it does not clear color

Thanks for the suggestion, but the question is, why is this necessary? Or, why doesn’t it work on a GUI’ed node?

GUI space is not WorldSpace, by default emitters are in world space, but you can try setWorldSpace(false).

But honestly this is not intended to work in a gui viewport, there are plenty of things that could make this fail (parallel projection, diffent coordinate system etc…).

I don’t say it can’t work, i just say that it’s not made for this.

Creating an additional viewport and putting the emitter into it looked more straight forward to me.

So some time to necro a thread.
I bumped into this issue today and finally found a solution, as I was lazy enough to not follow my own advice.

when placing a ParticleEmitter in the GUI you have to set those attribute for it to display :

        effect.setLocalTranslation(500,200,1); //doesn't have to be this just pick somewhere on screen
        effect.setLocalScale(20f); // scale it to your need so it's not few pixels wide
        effect.setInWorldSpace(false); // use this or it will ignore previous line
        effect.setQueueBucket(RenderQueue.Bucket.Gui); // that's the trick!!
        effect.setFaceNormal(Vector3f.UNIT_Z); //that's the second trick!!

hope that helps someone.

6 Likes