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?
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());