How do I get the particle effects into my scene?

I need some particle effects for my class project. (explosions, thrusters, weapons, etc.) Unfortunately, that’s one of the missing sections in the wiki user guide and the javadoc is also sketchy. I found this webstart program when searching the forums though: I’m not exactly sure where it comes from or what it’s for, since I can’t find any other link to it.

I’ve made some suitable effects using that editor, now how is the best way to get them into my program? Can I import a saved file directly? Do all of the settings translate to function calls I can manually enter in code?

yes, a file that you saved from the RenParticleEditor can and should be imported directly like that:

        ParticleMesh myparticle =

I'm getting a

java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String

when I try to import the file. The stack trace indicates the exception originates in jME:

    at com.jme.util.export.binary.BinaryInputCapsule.readString(
   at com.jme.util.export.binary.BinaryInputCapsule.readEnum(
   at com.jme.util.export.binary.BinaryImporter.readObject(
   at com.jme.util.export.binary.BinaryImporter.load(
   at com.jme.util.export.binary.BinaryImporter.load(
   at com.jme.util.export.binary.BinaryImporter.load(
   at testing.ModelLoader.particleLoader(
   at testing.Main.simpleInitGame(
   at testing.Main.main(

I don't understand why this isn't working. Am I using the wrong version of the editor? The editor can load the files fine. I'm using jME 2.0, was it meant for 1.0? The problem manifests on the line when I try to invoke the BinaryImporter.getInstance().load() method.

best thing would be to start the RenParticleEditor out of the test cases of the same version you use for the actual game you are making.

Start the Editor out of 2.0 source if you use jme 2.0 for your game, and the same for 1.0 or 0.11 or whatever.

Okay, I've figured out how to run the new editor version and I've got the effect to load in my scene, but the particles are missing the texture! It seems like the editor is saving the absolute path to the texture instead of embedding the texture data into the exported file like you'd expect. This means it breaks in my project.

Isn't there some way to change the particle texture in code? Can I just set the texture to "none" in the editor, then load the particle separately and add it to the effect later in my project? Or would it be easier to tweak the editor code to embed the data properly? The wiki and javadoc were no help.

If you have a texture ResourceLocator set up in your app it should find the textures without need for any changes.

Embedding the textures in a particle effect file would mean you would be loading the same textures over and over again, assuming you use the same particle texture in more than one effect (almost always the case).

Got it working using the ResourceLocatorTool and a relative path. :smiley:

The ResourceLocatorTool has no javadoc information btw.

I'd like to add these directions to the wiki user's guide now, since the particle article is missing. Is there a more current webstart version of the editor I can link to?

:? It's still not blending properly. It looks good in the editor, but not in my scene. Is there an extra step to enable this or something? Do I have to enable/disable lighting, or enable transparency or set additive blend mode in my code or something?

I'm just importing it into a SimpleGame extension in the simpleInitGame method.

Don't think you need to change lighting or blending manually, but iirc you will need to put it in the Transparent render queue.


Still not working. :frowning:

I've invoked .setRenderQueueMode(Renderer.QUEUE_TRANSPARENT); on the node with the effect. It looks just like it did before. I also tried setting "Render Queue" control to "TRANSPARENT" in the editor. It still looks fine in the editor, but I get square or triangular artifacts (depending on whether I use quads or triangle particles) around all the particles in my scene. It doesn't seem to be blending additively either, since it's darker in the middle in my scene than in the editor.

Add a BlendState

Still not working. Why doesn't the importer already handle this? I've tried adding a BlendState, but I have no idea if I'm doing it right.

      final BlendState bs = this.display.getRenderer().createBlendState();

"jet" is my ParticleSystem that I loaded from the editor file.

Pasted some code which should work. I'm sure most of it came from the wiki or jmetest originally.

Disclaimer - I only just tested it on a Mac with JME2, neither of which I'm familiar with so it might not be optimal.

   public static Node loadParticleEffect(URL fileURL) {
      Savable l = null;
      try {
         BinaryImporter binaryImporter = new BinaryImporter();
         l = binaryImporter.load(fileURL);
      } catch(Exception err) {
         System.err.println("Error loading .jme file:" + err);
         System.err.println("URL was: " + fileURL);
         return null;
      Node particleNode = new Node();
      if(l instanceof Node) {
         particleNode = (Node)l;
      } else {
         System.err.println("Error loading particle effect.");
         return null;
      particleNode.setModelBound(new BoundingBox());
      ZBufferState zs = DisplaySystem.getDisplaySystem().getRenderer().createZBufferState();
      return particleNode;

That's getting closer. The line


seems to fix the blending. However, I'm still getting slight artifacts at the edge of the quads that aren't visible in the editor. I might be able to make this less noticable with a different texture though. Also, calling updatemodelbound() makes one of the effects disappear completely. I wonder if it sets the bound around the emitter (which is inside one of my meshes) instead of around the entire extent of the effect. Is it a big problem if I just don't call that method?

Another thing, my test have been in a SimpleGame extension, but I want to use a FixedLogicrate game for the project. There's a little more overhead, but it makes timing easier. I'm using the exact same particle loader method as in SimpleGame, but my effects aren't showing up at all. The models load fine, is there something specific to particle effects I forgot to initialize?