Problem with a custom Box

Hi…it me again  :smiley:



I have a bit of trouble determining a problem that im having with a Box object. I have extended the Box into Board (here is the constructor):


public Board()
    {
        //board = new Box("Board", new Vector3f(0f, -0.2f, 0.8f), 3.5f, 0.1f, 3.5f);
        super("board");
        this.setModelBound(new BoundingBox());
        this.updateModelBound();
       
    }



I have added the following instance method to Board:


public void draw(Node node, Boolean randomColor)
    {
        this.updateGeometry(new Vector3f(0f, -0.2f, 1.0f), 3.5f, 0.1f, 3.7f);
        //board.updateGeometry(new Vector3f(0f, 0f, 0.0f), 3.5f, 0.3f, 1.5f);
        if (randomColor == true)
        {
            this.setRandomColors();
            this.setLightCombineMode(LightCombineMode.Off);
        }
        this.updateModelBound();
        node.attachChild(this);
    }



Now I call this from the BaseGame class which i have extended again (from the method initGame() ):


board.draw(rootNode, true);
cam.setLocation(new Vector3f(0f,7.3f,8f));
cam.lookAt(object.getWorldTranslation(), new Vector3f(0,1,0));
cam.update();
board.setRenderState(lightState);
board.updateRenderState();



----

The board gets rendered properly. But I see another layer of 'shading' on it which prevents the board to look fully 3D. Here is a screenshot of the problem:
http://www.mofirouz.com/jme/box.jpg

Hope someone can help me out with this one.

Thanks
Mo

Looks like it's missing a ZBufferState to me.



ZBufferState buf = DisplaySystem.getDisplaySystem().getRenderer().createZBufferState();
        buf.setEnabled(true);
        buf.setFunction(ZBufferState.TestFunction.LessThanOrEqualTo);
        node.setRenderState(buf);

Hey,

Thanks for the reply.



I added this zbuffer to the Draw() in the Board object, and there was no difference whatsoever.



Can you enlighten me on how I should use this - if I am using this wrongly.



Thanks

Mo

Hey. Sorry.



That was a beautiful fix.



THANK YOU…

Mo