More particle oddities

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

solved the first problem



needed to add

setWritable(false);

to the zstate settings  :roll:



the second problem is still there



now off to bed :lol:


:smiley: Fixed the second issue, adding zbufferstate to the fence with setWritable(false) option

I love such posts.  :)  Nice work figuring it out.

renanse said:

I love such posts.  :)  Nice work figuring it out.


thanks!

i just wrote it down here because i trust the forum database better than my memory (besides my memory doesn't have a direct search function  )

and it might be of some use for other newbies like me  :P

did you forget your last login details too ??





Just that i remeber another user had exactly the same icon ( ? is it that guy out of evil dead )

theprism said:

did you forget your last login details too ??

what details? this is my first user on these forums

theprism said:

Just that i remeber another user had exactly the same icon ( ? is it that guy out of evil dead )

yep, it's bruce campell!
it's one of the builtin avatars of the smf forums, i haven't had time to chage it to my own avatar, will do soon.

i picked him for the evil dead trilogy    haven't laughted harder than watching army of darkness