Hi all
I feel bad for asking so many questions about the same thing, but i can’t find any clear documentation about particles in jme (maybe i’ll write some if i manage to understand it well)
let’s see.
First problem: camera facing and zbuffer
If i set the particles to be camera-facing, i see them as if they were not blended, or as if they were facing the oposite direction the whould be facing
as seen here
if i set the particles to not be facing the camera, they blend as expected from one side, but not from the other
In the particle demos, zbuffer check are dissabled for particles, but i can’t do this here, because they’ll hide the model and the terrain even if they shouldn’t
Second problem: more zbuffer
The fence objet is set to be transparent, but it ocluides other transparent objects as the particles, as seen here
code of the particle setup (almost the same)
private void initParticles() {
dust = ParticleFactory.buildParticles("dust particles", 300);
dust.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);
dust.setReleaseRate(0);
dust.setStartSize(.08f);
dust.setEndSize(.16f);
dust.setInitialVelocity(0.0035f);
dust.setMaximumAngle(FastMath.HALF_PI);
dust.setMinimumAngle(FastMath.HALF_PI);
dust.setMinimumLifeTime(250);
dust.setMaximumLifeTime(500);
dust.setControlFlow(false);
dust.setCameraFacing(true);
dust.setParticleType(ParticleMesh.PT_QUAD);
dust.setStartColor(new ColorRGBA(1f, 1f, 1f, 0));
dust.setEndColor(new ColorRGBA(1f, 1f, 1f, .5f));
dust.setEmitterTransform(new TransformMatrix(y90, Vector3f.ZERO));
dust.setParticleSpinSpeed(5);
dust.warmUp(150);
AlphaState transparency = display.getRenderer().createAlphaState();
transparency.setBlendEnabled(true);
transparency.setSrcFunction(AlphaState.SB_SRC_ALPHA);
transparency.setDstFunction(AlphaState.DB_ONE);
transparency.setTestEnabled(true);
transparency.setTestFunction(AlphaState.TF_GREATER);
transparency.setEnabled(true);
dust.setRenderState(transparency);
TextureState tex = display.getRenderer().createTextureState();
Texture tx = TextureManager.loadTexture(ResourceLocatorTool
.locateResource(ResourceLocatorTool.TYPE_TEXTURE, "dust.png"),
Texture.MM_LINEAR, Texture.FM_LINEAR);
tex.setTexture(tx);
tex.setEnabled(true);
dust.setRenderState(tex);
ZBufferState zstate = display.getRenderer().createZBufferState();
// set to the same function as the root node but i've tried every function with
// same results (except for those that make the quads allways visible / invisible)
zstate.setFunction(ZBufferState.CF_LEQUAL);
zstate.setEnabled(true);
dust.setRenderState(zstate);
dust.setModelBound(new BoundingSphere());
dust.updateModelBound();
root.attachChild(dust);
dust.updateRenderState();
}
and the code for the fence transparency
...
AlphaState transparency = DisplaySystem.getDisplaySystem().getRenderer().createAlphaState();
transparency.setBlendEnabled(true);
transparency.setSrcFunction(AlphaState.SB_SRC_ALPHA);
transparency.setDstFunction(AlphaState.DB_ONE);
transparency.setTestEnabled(true);
transparency.setTestFunction(AlphaState.TF_GREATER);
transparency.setEnabled(true);
forceField.setRenderState(transparency);
forceField.updateRenderState();
...
// and no zbuffer state for the forceField
thanks again!! :D