Particle Emitter Sample Code: Null Mesh

Hey guys,



Just running the smoke particle emitter example (http://code.google.com/p/jmonkeyengine/source/browse/branches/jme3/src/test/jme3test/effect/TestMovingParticle.java):



Seems like something’s missing / has changed as it keeps on throwing a java.lang.NullPointerException: Geometry: MyEmitter Emitter has null mesh exception.



Thought I’d let you know.



EDIT: Same for the “Hello Effects” tutorials.

But the TestExplosionEffect doesn’t crash?

It seems other people have this issue as well, I added it to the issue tracker:

http://code.google.com/p/jmonkeyengine/issues/detail?id=237

1 Like

Thanks Momoko.



No, it doesn’t crash. Just throws this exception (and of course the effect isn’t rendered).

Hi Momoko,



Issue 237: Particles do not work (http://code.google.com/p/jmonkeyengine/issues/detail?id=237) appears is marked as fixed. However using the latest nightly build, I’m still getting the same exception. Anything that I should do differently?

[java] ParticleEmitter fire = new ParticleEmitter(“Emitter”, ParticleMesh.Type.Triangle, 30);

Material mat_red = new Material(assetManager, “Common/MatDefs/Misc/Particle.j3md”);

mat_red.setTexture(“m_Texture”, assetManager.loadTexture(“Effects/Explosion/flame.png”));

fire.setMaterial(mat_red);

fire.setImagesX(2); fire.setImagesY(2); // 2x2 texture animation

fire.setEndColor( new ColorRGBA(1f, 0f, 0f, 1f)); // red

fire.setStartColor(new ColorRGBA(1f, 1f, 0f, 0.5f)); // yellow

fire.setStartVel(new Vector3f(0, 2, 0));

fire.setStartSize(1.5f);

fire.setEndSize(0.1f);

fire.setGravity(0);

fire.setLowLife(0.5f);

fire.setHighLife(3f);

fire.setVariation(0.3f);

rootNode.attachChild(fire);



ParticleEmitter debris = new ParticleEmitter(“Debris”, ParticleMesh.Type.Triangle, 10);

Material debris_mat = new Material(assetManager, “Common/MatDefs/Misc/Particle.j3md”);

debris_mat.setTexture(“m_Texture”, assetManager.loadTexture(“Effects/Explosion/Debris.png”));

debris.setMaterial(debris_mat);

debris.setImagesX(3); debris.setImagesY(3); // 3x3 texture animation

debris.setRotateSpeed(4);

debris.setSelectRandomImage(true);

debris.setStartVel(new Vector3f(0, 4, 0));

debris.setStartColor(new ColorRGBA(1f, 1f, 1f, 1f));

debris.setGravity(6f);

debris.setVariation(.60f);

rootNode.attachChild(debris);

debris.emitAllParticles();

[/java]

I tried this exact code on my PC and it works fine

Works for all builds prior Nov. 5. I suppose there is no way that the latest builds are different to what you are using?

Hi all,

I have this problem too.



I wanted to add the smoke effect, so I think to use the code of TestParticleEmitter.java,

but when I add it to my class: az1.java, this error happens:



java.lang.NullPointerException: Geometry: Emitter has null mesh

at com.jme3.scene.Geometry.updateWorldBound(Geometry.java:180)

at com.jme3.scene.Spatial.updateGeometricState(Spatial.java:643)

at com.jme3.scene.Node.updateGeometricState(Node.java:185)

at pueblo.az1.simpleUpdate(az1.java:1527)



That line is inside this method:



public void simpleUpdate(float tpf) {



rootNode.updateGeometricState();



}



I known that TestParticleEmitter.java doesn´t use the simpleUpdate method,

but i don´t know how can I fix the error in my class.



Any suggestion?

I guess both of you are calling updateGeometricState() inside simpleUpdate()? There’s no solution then, since particles need updateLogicalState() called before that.

Normen should add local updates support to the physics, that might help alleviate the requirement for updateGeometricState()

2 Likes

Its in, theres just some problem with the character node and I dont think its in the physics… Seems like setTransformUpdate() is called somewhere its not needed or something…

“I guess both of you are calling updateGeometricState() inside simpleUpdate()?” - Yup, I am. So, I should just call updateLogicalState() prior to updateGeometricState()?

Then all your animations etc. will run twice as fast. Just try removing the updateGeometricState() line, there were some fixes to local updates lately, maybe you dont need to anymore.

2 Likes

OK, thanks. I will give that a go later on,

Confirmed. Works. Thanks!