[SOLVED]RenParticleEditor - what is it saving?

Hi!

I want to use the particle system I have made in RenParticleEditor, but I really don't know how to use the generated .jme file  in my jME project.

Can somebody help me and explain, what to do with that .jme file ?

You can load that Spatial with BinaryImporter, and attach it to your scene directly.

Thanks - your solution seems to work very fine, with one exception however.



That’s how the Spatial looks in the Particle Editor:





That’s how it looks after adding it to the scene in my simple application:





What shall I do to have the transparency work well?



Here’s a piece of my source code :


        try {
           
            Spatial ogien = (Spatial)BinaryImporter.getInstance().load(Gra.class.getClassLoader().getResourceAsStream("pl/bestia/datafiles/ogieniek2.jme"));
            ogien.setLocalTranslation(500f,Gra.teren.getHeight(500f,500f)+2,500f);
           
            ogien.setModelBound(new BoundingBox());
            ogien.updateModelBound();
            ogien.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);
            rootNode.attachChild(ogien);
        } catch (IOException ex) {
            ex.printStackTrace();
        }

The particles are missing a non-writable zbuffer state when loaded.

Add:


                ZBufferState zbuf = DisplaySystem.getDisplaySystem().getRenderer().createZBufferState();
                zbuf.setWritable(false);
                ogien.setRenderState(zbuf);
                ogien.updateRenderState();


And it should look just as it does in the editor.

@renanse: maybe the ZBufferState could be saved with the particles to simplify things?

Thank you very much, it works now! :slight_smile:

In general, your scene is going to need a zbufferstate like that anyhow, but sure… it wouldn’t hurt.



edit: what was I smoking yesterday? 

Uh… apparently yet another thing I haven't understood yet - I need a non-writeable ZBufferState in any scene, in general? Why?

You need a writable ZBufferState which draws fragment if depth < scene depth (its closer) in a scene with opaque objects. It must replace the depth value at that point, otherwise you will have depth artifacts. The result is that all fragments with the closest depth value are drawn to the framebuffer, which is what you usually want.

Yes I know about the writable depth buffer :slight_smile: But I thought renanse was implying that there must be a non-writable one as well?

Wait… why does the particle suppose to have a non-writable zbuffer? Wouldn't that mean that everything drawn after the particle would be drawn over it?

Only transparent faces that come after the particle, since it's in QUEUE_TRANSPARENT. It's intended here, because that way the particles don't have to be additive or depth sorted and still render somewhat naturally.

Of course it may be better to render them once more after that, only to the depth buffer… Would one need another AlphaState for that?

renanse said:

In general, your scene is going to need a zbufferstate like that anyhow, but sure... it wouldn't hurt.


I have a ZbufferState in my rootNode, but I had to make another, non-writable one for my particles. ;)

Shall I always use non-writable ZBufferState when working with transparent objects ?
Momoko_Fan said:

Wait.. why does the particle suppose to have a non-writable zbuffer? Wouldn't that mean that everything drawn after the particle would be drawn over it?

Yes, particle must be drawn after other stuff - you can put it in the transparent queue for that.

It is not a Spatial. It is a ParticleMesh! Or at least you can use .forceRespawn() this way.