Explode effect, not founding meshes

Hello,



Sorry for my English :slight_smile:



I have one problem with this:



public void doExplode()

{

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

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

debris_mat.setTexture(“m_Texture”, Bomberman.getInstance().getAssetManager().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);

debris.setLocalTranslation(_bomb.getLocalTranslation().clone());

debris.emitAllParticles();

Bomberman.getInstance().getRootNode().attachChild(debris);

Bomberman.getInstance().getRootNode().updateGeometricState();

}



90% of time i get error likes this:



SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

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

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

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

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

at bomberman.objects.Bomb.doExplode(Bomb.java:73)

at bomberman.objects.Bomb.plant(Bomb.java:51)

at bomberman.system.Control.onAction(Control.java:56)

at com.jme3.input.InputManager.invokeActions(InputManager.java:114)

at com.jme3.input.InputManager.onMouseButtonEvent(InputManager.java:274)

at com.jme3.input.lwjgl.LwjglMouseInput.update(LwjglMouseInput.java:74)

at com.jme3.input.InputManager.update(InputManager.java:401)

at com.jme3.app.Application.update(Application.java:416)

at com.jme3.app.SimpleBulletApplication.update(SimpleBulletApplication.java:270)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:112)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:101)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:166)

at java.lang.Thread.run(Unknown Source)





What i doing wrong?



Thanks for help!

I’m having the same problem when rendering a framebuffer to texture with a node with particles in it. Might be related?


SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException: Geometry: Spark has null mesh
at com.jme3.scene.Geometry.updateWorldBound(Geometry.java:180)
at com.jme3.scene.Spatial.updateGeometricState(Spatial.java:625)
at com.jme3.scene.Node.updateGeometricState(Node.java:185)
at mygame.Portal.setupOffscreenView(Portal.java:138)
at mygame.Portal.setTexture(Portal.java:58)
at mygame.Main.shootPortal(Main.java:193)
at mygame.Main.onAction(Main.java:169)

try adding

[java]

rootNode.updateLogicalState(tpf);

rootNode.updateGeometricState();

[/java]

as first lines in your simpleUpdate() method. This is a workaround and will not be necessary in the future I guess.

Cheers,

Normen

Thanks for the reply, but the workaround didn’t do the trick for me. Still throws the same error, I guess it has something to do with the way particles are implemented.

For now, I’ll just turn off the particles.

Uhm, this exception can only happen when rootNode.updateLogicalState() has not been called after the particles were added. But that should happen after simpleUpdate() has been called… When or where do you add the particles?

Cheers,

Normen

I had the same, if you replace the throw new Exception with a return it works for now (Effect is visible and no other problems (I use a kinda similar effect currently for the bulletimpacts in NewHorizons)))

You shouldn’t call updateGeometricState() unnecessarily. I see you’re calling it after attaching the particle.

At this point of time, you should only call updateGeometricState() if you need to retrieve the world bound, but even then it might cause issues. I suggest you remove all unneeded calls to updateGeometricState().

[java]

public Texture setupOffscreenView(){



Camera offCamera = new Camera(1024, 1024);



// create a pre-view. a view that is rendered before the main view

ViewPort offView = renderManager.createPreView(“Offscreen View”, offCamera);

offView.setClearEnabled(true);

offView.setBackgroundColor(ColorRGBA.DarkGray);



// create offscreen framebuffer

FrameBuffer offBuffer = new FrameBuffer(1024, 1024, 0);



//setup framebuffer’s cam

offCamera.setFrustumPerspective(45f, 1f, 1f, 1000f);

offCamera.setLocation(new Vector3f(0f, 10f, 10f));

offCamera.lookAt(new Vector3f(0f, 10f, 10f),Vector3f.UNIT_Y);



//setup framebuffer’s texture

Texture2D offTex = new Texture2D(1024, 1024, Format.RGB8);



//setup framebuffer to use texture

offBuffer.setDepthBuffer(Format.Depth);

offBuffer.setColorTexture(offTex);



//set viewport to render to offscreen framebuffer

offView.setOutputFrameBuffer(offBuffer);





// attach the scene to the viewport to be rendered

offView.attachScene(rootNode);



return offTex;

}[/java]

I used the code from the TestRenderToTexture.java which is giving me problems when I add particles to the rootnode. Is it something with the framebuffer?



EDIT: I removed updateGeometricState as much as possible.

I had this problem too. I tried :

rootNode.updateLogicalState(tpf);

rootNode.updateGeometricState();



but that didnt work.

so now after setting up the ParticleEmitter I’m just directly calling

debris.update(0);



I realise its not ideal, but for now it creates the mesh and everything works.

whats still annoying for me though is that If I don’t immediately add the emitter to the rootNode, then an exception is also thrown,

and I cannot remove it from the rootNode at all without an exception being thrown. even if I killAllParticles first.

That’s really strange. The particle mesh should get created on the first call to updateLogicalState() and thats it.

Could you provide a test case showing the issue(s)?

It’s the same issue i’m having here:

http://hub.jmonkeyengine.org/groups/general-2/forum/topic/particleemitter-has-null-geometry/#post-111436



I’m using lastest release. I’ll try directly calling the update method of the particleeemitter.