[SOLVED] Accessing ParticleEmitter in Scene Composer

Hi all. Is there a way to access the ParticleEmitter in SceneComposer through java code? I wanted to make a CustomControl that changes the color of the ParticleEmitter. Just need to know how to get the ParticleEmiiter from SceneComposer through code. Thanks 8)

K Out!

Its a normal spatial, so rootNode.getChild(name);

1 Like

:facepalm: I’m such a dummy. Thanks Normen =D , I forgot I could take it from the rootNode :lol:

Here is the code for it if anyone else happens to come across this problem :smiley:

ParticleEmitter particle = (ParticleEmitter)((Node) spatial).getChild(“Emitter”);

Sorry for bring back old topics but when I use node.getChild(0);
It pop up a error about the jme3.scene.Node cannot cast to jme3.effect.ParticleEmitter.
Here is my code:

explo =
Node node = new Node(“ParticleNode”);

effect = (ParticleEmitter) node.getChild(0);

I want to let the particle in Explosion.j3o to emit all of the time. Does this is a bug or the code had some error ? Thanks everyone !

This means that the root of the Explosion.j3o file is a node, not a particle emitter. You’ll need to find out where the particle emitter is actually attached in the contents of the j3o.

Ya, thanks you. :grinning: I fix the code and it is working !
Here is my code after fix:

ParticleEmitter shockwave = (ParticleEmitter) 
1 Like

Please note, you dont need to know it(child name/etc) each time.

If you dont need select exact thing from scene graph, you can select first one or just every.

    SceneGraphVisitor visitor = new SceneGraphVisitor() {
      public void visit(Spatial spatial) {
          if(spatial instanceof ParticleEmitter){
            // it is particle emitter. use (ParticleEmitter)spatial
          } else if(spatial instanceof Node){
            // it is Node. use (Node)spatial
          } else if(spatial instanceof Geometry){
            // it is Geometry. use (Geometry)spatial. example ((Geometry)spatial).getMesh()
1 Like