Particles inheriting textures

Having a bit of trouble getting the particle effects to work properly. Just for testing, I'm attaching what was supposed to be a smoke trail to the player ship, copied more or less directly from TestParticleSystem. Apparently, the particles decide to use the texture from the ship's model instead of smallflare.jpg. I tried putting an extra node in between the player and particle TriMesh, but same result.



Another thing I find weird, manager.getParticles().updateModelBound() causes a NullPointerException in BoundingSphere.recurseMini(). This happens even in TestParticleSystem. When commenting out that line, TestParticleSystem seems to work just fine however.



I'm probably missing something trivial here, but I can't wrap my head around it. Any help? :slight_smile:



Node node = new Node("node");
ParticleManager manager = new ParticleManager(300);
manager.setGravityForce(new Vector3f(0.0f, 0.0f, 0.0f));
manager.setEmissionDirection(new Vector3f(0,1,0));
manager.setParticlesOrigin(new Vector3f(0,0,0));
manager.setInitialVelocity(.06f);
manager.setStartSize(.5f);
manager.setEndSize(5.0f);
manager.setParticlesMinimumLifeTime(1200f);
manager.setStartColor(new ColorRGBA(0.8f, 0.8f, 0.8f, 1f));
manager.setEndColor(new ColorRGBA(0.1f, 0.1f, 0.2f, 0f));
manager.setEmissionMaximumAngle(0f);
manager.setControlFlow(false);
manager.setRandomMod(0.2f);
manager.warmUp(60);
manager.setParticlesOrigin(new Vector3f());

AlphaState as1 = MoseuGameClient.getInstance().getDisplay().getRenderer().createAlphaState();
as1.setBlendEnabled(true);
as1.setSrcFunction(AlphaState.SB_SRC_ALPHA);
as1.setDstFunction(AlphaState.DB_ONE);
as1.setTestEnabled(true);
as1.setTestFunction(AlphaState.TF_GREATER);
as1.setEnabled(true);

TextureState ts = MoseuGameClient.getInstance().getDisplay().getRenderer().createTextureState();
try {
   ts.setTexture(TextureManager.loadTexture(new File(System.getProperty("user.dir") + "/flaresmall.jpg").toURL(), Texture.MM_LINEAR_LINEAR, Texture.FM_LINEAR));
} catch (MalformedURLException e) {
   e.printStackTrace();
}
ts.setEnabled(true);

ZBufferState zstate = MoseuGameClient.getInstance().getDisplay().getRenderer().createZBufferState();
zstate.setEnabled(false);
node.setRenderState(ts);
node.setRenderState(as1);
node.setRenderState(zstate);
manager.getParticles().addController(manager);
//manager.getParticles().setModelBound(new BoundingSphere());
//manager.getParticles().updateModelBound();
model.attachChild(node);
node.attachChild(manager.getParticles());


Calling updateRenderState() on your attached particles should enable the texture and other render states.



Please post more details about the exception (e.g. stack trace)… TestParticleSystem works fine over here.

Heh, knew I was missing something simple. Thank you!



Here’s the exception I’m getting, but I checked around the forum and it seems it has already been fixed: http://www.jmonkeyengine.com/jmeforum/index.php?topic=1875.0

Guess I should fetch the newest version from CVS again. :slight_smile:



java.lang.NullPointerException
   at com.jme.bounding.BoundingSphere.recurseMini(Unknown Source)
   at com.jme.bounding.BoundingSphere.calcWelzl(Unknown Source)
   at com.jme.bounding.BoundingSphere.computeFromPoints(Unknown Source)
   at com.jme.scene.Geometry.updateModelBound(Unknown Source)
   at TestParticleSystem.simpleInitGame(TestParticleSystem.java:87)
   at com.jme.app.SimpleGame.initGame(Unknown Source)
   at com.jme.app.BaseGame.start(Unknown Source)
   at TestParticleSystem.main(TestParticleSystem.java:23)