3d Particles - TemplateMesh

Hi everyone, I wanted to use these cool particle effects features, but I noticed that the sample code looks completely outdated and broken.

 @Override
    public void simpleInitApp() {

        // Since we actually use a full lit material for these particles we need
        // to add a light to the scene in order to see anything.
        DirectionalLight dl = new DirectionalLight();
        dl.setDirection(new Vector3f(-0.1f,-0.7f,-1).normalizeLocal());
        dl.setColor(new ColorRGBA(0.6f, 0.60f, 0.60f, 1.0f));
        rootNode.addLight(dl);

// A standard lit material is used, this rock texture was taking from the
// jme3 test data but you can easily substitute your own.
        Material rock = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
        rock.setTexture("DiffuseMap", assetManager.loadTexture("Textures/Rock.PNG"));
        rock.setFloat("Shininess", 100f);

// A PointSource is actually a fully featured Spatial object, in this case
// we simply adjust its translation, but it can actually be attached to the
// scene graph and the source will automatically move as the Node to which
// it is attached is transformed.
        PointSource source = new PointSource(new Vector3f(-5,-5,-5), new Vector3f(5,5,5));
        source.setLocalTranslation(0, 10, -20);

// A TemplateMesh uses any number of standard meshes to be the template for
// each 3d particle. This model was generated simply by taking a cube in
// Blender and running a fracture script on it to generate 20 fragments.
        Node n = (Node) assetManager.loadModel("Models/FracturedCube.j3o");
        Mesh[] templates = new Mesh[n.getChildren().size()];
        int i = 0;
        for (Spatial s: n.getChildren()) {
            Geometry g = (Geometry)((Node)s).getChild(0);
            templates[i++] = g.getMesh();
        }

// Construct the new particle controller
        ParticleController rockCtrl = new ParticleController(
                "TemplateMesh",
// The TemplateMesh uses the rock material we created previously, the two boolean
// flags say that we are not interested in vertex colours but we do want the vertex
// normals. The array of meshes extracted from the model is then passed in to use
// as models for each particle.
                new TemplateMesh(rock, false, true, templates),
// A maximum of 64 particles at once, each lasting for 5 to 5.5 seconds.
                64,
                5,
                5.5f,
// Particles are emitted from the source that we created and positioned earlier
                source,
// Emit 8 particles per second
                new RegularEmission(8),
// The "sprites" in this case are the available templates. The TemplateMesh has
// one spriteColumn for each template it has been provided, so the standard
// RandomSpriteInfluencer just causes one to be picked at random each time a
// particle is emitted.
                new RandomSpriteInfluencer(),
// Rocks fall.
                new GravityInfluencer(new Vector3f(0, -4, 0)),
// Rocks spin.
                new RotationInfluencer(new Vector3f(-2, -2, -2), new Vector3f(2, 2, 2), false));

        rootNode.attachChild(rockCtrl.getGeometry());
    }

Could you write me the updated code for these features? Thanks in advance.

Edit: I’m using jme3.3.2

There are currently 3 different particle systems for jme available that I’m aware of. The default one that comes with jme, 2 different implementations for effekseer and Particle Monkey which improves on the built in particle system.

The documentation page you linked refers to a particle system based on t0neg0d’s particle emitter which is a name I haven’t heard in years. So either it’s something that’s flown under my radar, or, more likely, the page you linked is ~5 years out of date. The only question is whether the system the docs page talks about has ever made it into the particle system included in jme, or is it a dead side branch. Someone who’s been around for longer than me might be able to tell, as the last commits in the repository linked in the docs page are from roughly around the time started using JME.

1 Like

Thank you for the quick support, could you tell me where I can find the latest version of the t0neg0d library? I’d like to try two features in particular:

  1. Next Generation Particle Emitters :: jMonkeyEngine Docs
  2. Next Generation Particle Emitters :: jMonkeyEngine Docs

Could you tell me if the other libraries have similar functions?

all i know about is TonegodGUI library:

but i didnt seen anything about Particles, maybe its within GUI lib?

2 Likes

I have come across this library before, I believe the most updated version is this:

But it doesn’t contain any ParticleController.

The library the official documentation points to is this:

Should I give up and go directly to the new libraries or to Effekseer?

On that wiki page the example videos were made by a user named zarch… which is yet a separate particle system from tonegod. The libraries have a nasty mostly-political sad relationship.

And yep, according to the linked source:

Tim = Zarch.

There is a longer story here about “why we can’t have nice things” but I probably shouldn’t go into it as it’s a tragic story and doesn’t change the fact that these are old libraries and zarch was essentially chased off by the ordeal, I think.

2 Likes

And if you want a Gradle based version you can check this fork

2 Likes

6 actually :slightly_smiling_face:

JME’s builtin one, tonegod’s one, zarch’s one, particle monkey (based on tonegod), jme-effekseer pure java, jme-effekseer native.

2 Likes

Particle monkey has that feature. It’s one of the ones I retained when I rewrote the library. I believe one of the examples I have uses a mesh to use for particle emission. That being said, I don’t think it handles animated meshes yet. Technically you could use it with static particles to do some interesting things.

I have another release I’ve been working on, but it has been held up since I wanted it to work with an SDK and I’ve probably rewritten that like 4 or 5 times now for the different SDKs.

3 Likes

Thank you, I’ll do some tests also with your library. Unfortunately, creating particle effects via code is not very convenient, there are too many variables. A graphic editor would help a lot.

if you need graphic editor, then jme-effekseer have one (effekseer editor).

jme-effekseer (java one) disadvantage:

  • do not support all editor settings

advantage:

  • use basic JME particle system

jme-effekseer native disadvantage:

  • its tricky and use big native lib that use different rendering way. (so its riscy if break for someone)

advantage:

  • support all editor settings
2 Likes

@capdevon you can also check @javasabr jmonkeyBuilder , it uses redefined jme basic particle system & if you have t0neg0d installed you can edit it via jmonkeyBuilder , I know it’s a little bit outdated but just have a look at source code may you benefit from , I havenot yet dig deeper into jme Builder source code but it’s a great tool !

1 Like