Backface culling

I'm having some difficulty with unwanted backface culling.



According to the documentation, as I understand it, backface culling is disabled by default in jME and one has to use the CullState to enable it.



However, my application is acting as if backface culling is turned on somewhere and I have to brute force turn it off with



GL11.glDisable(GL11.GL_CULL_FACE);



I tried using CullState.setCullFace( CullState.Face.None ) but when I enable that, the entire object vanishes!  All of the objects within the scene are TriMeshes and they all have some degree of transparency or another set, thus they're being rendered  with TriMesh.setRenderQueueMode( Renderer.QUEUE_TRANSPARENT ).



I need to render front and back faces because in my application, the objects may be open at the top or bottom and so I need to be able to see inside the object, if that makes any sense.



I'm using StandardGame, if that matters.



I'm sure I'm doing something dimwitted but what dimwitted thing is, of course, the question. . .



Suggestions and RTFMs (preferably with references other than anatomical) are welcome.

Core-Dump said:

Try to disable the CullState and see if that helps.


Nope.  Doesn't do a thing.  That is, I create and disable the CullState as follows:

        CullState cs = renderer.createCullState();
        cs.setCullFace( CullState.Face.None );
        cs.setPolygonWind( CullState.PolygonWind.CounterClockWise );
        cs.setEnabled( false );

        mesh.setRenderState( cs );
        mesh.updateRenderState();

and only the front facing polygons of the object are rendered.  Combinations and permutations of the CullState.Face and CullState.Polygonwind all produce the visibly identical result.

Turning the CullState on with

        cs.setEnabled( true );

makes everything vanish.

Core-Dump said:

Both a CullState.Face.None  and disabling the CullState should result in GL11.glDisable(GL11.GL_CULL_FACE).


That's what I gathered from looking at the code, but something else also seems to be happening.

Core-Dump said:

But with an enabled CullState the CullState's Polygon winding will be used (where counter clockwise is default).
If your TriMeshes use Clockwise polygon winding, use a enabled CullState and set the polygon winding.


I've tried it both ways (CW and CCW), but it produces the same result; that is, no objects rendered.

Try to disable the CullState and see if that helps.



Both a CullState.Face.None  and disabling the CullState should result in GL11.glDisable(GL11.GL_CULL_FACE).



But with an enabled CullState the CullState's Polygon winding will be used (where counter clockwise is default).

If your TriMeshes use Clockwise polygon winding, use a enabled CullState and set the polygon winding.



see:

http://code.google.com/p/jmonkeyengine/source/browse/trunk/src/com/jme/scene/state/lwjgl/LWJGLCullState.java

do your objects have a boundingbox set ? (setModelBound()/updateModelBound())

Core-Dump said:

do your objects have a boundingbox set ? (setModelBound()/updateModelBound())


Yep.

Found the problem.



Somewhere along the way, I'd inadvertently set my ZBufferState.setFunction() to GreaterThan instead of LessThan.



D'oh!