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)
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:
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.
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.
like:
SceneGraphVisitor visitor = new SceneGraphVisitor() {
@Override
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()
}
}
};
yourModelSpatial.breadthFirstTraversal(visitor);