Trivial StandardGame questions

Hi Iam trying to get started with jME.



From what I got from the docs, StandardGame seems to be the preferred way to create a "real" game. So I created a simple Standardgame and added additionally to the DebugGameState my own gamestate which adds just a box to its rootNode.

The problem is that when I "fly" around the box I noticed that the Z-Order of the faces is wrong. Some faces are in the front which should be hidden in that moment and so on.

This is the ctor of my gamestate:



 public MyGameState()
    {
        super("my gs");

        Box box = new Box("my box", new Vector3f(0, 0, 0), 2, 2, 2);
        box.setRandomColors();
        box.setModelBound(new BoundingSphere());
        box.updateModelBound();
        box.updateRenderState();
        getRootNode().attachChild(box);
    }



Then I have additional Questions. There is FixedFrameRateGame, VariableTimestepGame and so on. Which kind of game is StandardGame regarding to timestep and framerate?

Thank you in advance!

Do you have a Z-buffer renderstate defined on any of your scene elements? You might be missing this.

codymanix said:
There is FixedFrameRateGame, VariableTimestepGame and so on. Which kind of game is StandardGame regarding to timestep and framerate?


StandardGame is a configurable system that allows fixed frame-rate, vertical syncing, or can simply maximize processor usage to get the maximum FPS.  This is where StandardGame can come in really handy is that it allows you to develop your game and either make this configurable by the user or simply hard-code it in your game and have the ability to change it later if you choose to.

The DebugGameState defines a ZBufferState, but this is not my code:



        ZBufferState zbs = DisplaySystem.getDisplaySystem().getRenderer().createZBufferState();

        zbs.setEnabled(true);

        zbs.setFunction(ZBufferState.CF_LEQUAL);

        rootNode.setRenderState(zbs);



Additionally I have nothing more, as I said the code is trivial; this is my main:



public static void main(String[] args) throws Exception

    {

        // Instantiate StandardGame

        StandardGame game = new StandardGame("A Simple Test");

        // Show settings screen

        if (GameSettingsPanel.prompt(game.getSettings()))

        {

            game.start();

            DebugGameState state = new DebugGameState();                             

            GameStateManager.getInstance().attachChild(state);

            state.setActive(true);

           

            MyGameState mstate = new MyGameState();

            GameStateManager.getInstance().attachChild(mstate);

            mstate.setActive(true);

        }

    }

Add that code to MyGameState for the ZBuffer and see if that makes a difference…you'll also need to call rootNode.updateRenderState() afterwards if I recall.

Yes thank you, that did the trick, I had to add the following code to my own gamestate.

It seems that per default there is no ZBuffer and that each GameState has to declare its own ZBufferState. Additionally, updateRenderState() has to be called afterwards, otherwise nothing happens :slight_smile:



                // Create ZBuffer for depth

        ZBufferState zbs = DisplaySystem.getDisplaySystem().getRenderer().createZBufferState();

        zbs.setEnabled(true);

        zbs.setFunction(ZBufferState.CF_LEQUAL);

        rootNode.setRenderState(zbs);

       

                // Finish up

        rootNode.updateRenderState();

        rootNode.updateWorldBound();

        rootNode.updateGeometricState(0.0f, true);