Tranparency

make sure to setTwoSidedLighting(false) and render the transparent objects in the transparent queue.





import com.jme.app.SimpleGame;
import com.jme.bounding.BoundingBox;
import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.math.Vector3f;
import com.jme.renderer.Renderer;
import com.jme.scene.shape.Box;
import com.jme.scene.state.AlphaState;
import com.jme.scene.state.MaterialState;
import com.jme.system.DisplaySystem;

public class TestTrans extends SimpleGame {
    MaterialState ms;
    private float alpha = 1;
   
    public static void main(String[] args) {
        TestTrans t = new TestTrans();
        t.start();
    }
   
    @Override
    protected void simpleInitGame() {
        lightState.setTwoSidedLighting(false);

        AlphaState as = DisplaySystem.getDisplaySystem().getRenderer().createAlphaState();
        as.setBlendEnabled(true);
        as.setSrcFunction(AlphaState.SB_SRC_ALPHA);
        as.setDstFunction(AlphaState.DB_ONE_MINUS_SRC_ALPHA);
        as.setTestFunction(AlphaState.TF_GREATER);
        as.setTestEnabled(true);      
       
        ms = display.getRenderer().createMaterialState();
       
        for (int i = 0; i < 5; i++) {
            Box b = new Box("jo", new Vector3f(),1,1,1);
            b.setModelBound(new BoundingBox());
            b.updateModelBound();
            b.getLocalTranslation().x += i*2.7f;
            b.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);
            b.setRenderState(as);
            b.setRenderState(ms);
            rootNode.attachChild(b);
        }
       
        KeyBindingManager.getKeyBindingManager().add("cycle", KeyInput.KEY_SPACE);
    }
   
    @Override
    protected void simpleUpdate() {
        if (KeyBindingManager.getKeyBindingManager().isValidCommand("cycle", true)) {
            alpha += 0.5f*tpf;
            if (alpha > 1) {
                alpha = 0;
            }
            System.out.println("alpha: " +alpha);
            ms.getDiffuse().a = alpha;
            ms.getAmbient().a = alpha;
            ms.getSpecular().a = alpha;
            ms.getEmissive().a = alpha;
        }
    }
}

Sorry… I forgot to say thank you.



It works perfectly.

Perhaps you can also just cull it from rendering.  In JME2 you would use:



spatial.setCullHint(CullHint.Always);