Noob Question - Wiki GUI Turorial 1

I was running through the tutorial, and I had a couple little questions about some discrepencies I found from what I expected. Could someone tell me if I might be doing something wrong, or is the tutorial just a little dated?



This is the wiki article I’m talking about:http://www.jmonkeyengine.com/wiki/doku.php?id=our_first_hud_example


  1. The square Quad that is rendered to the screen does not automatically render to the centre of the screen like the picture suggests. It seems to render in the bottom-left corner of the screen (under the FPS text). In order to centre it, I had to insert the following line into the simpleinit() method:

hudQuad.setLocalTranslation(new Vector3f(display.getWidth() / 2, display.getHeight() / 2, 0));


I assume this is because it defaults to creating the quad at the origin.

2. When I turn on the normals (N-key in SimpleGame), the normals at the corners where the quad WOULD be (ie. centred at 0,0,0) if it wasn't attached to the HUD are drawn. I assume this is a bug?

3. Lastly, when I turn the camera away from the cylinder, the Quad on the HUD dissapears (I'm guessing its culled for some reason). As well, the lighting state for the Quad doesn't seem to be turned off as it should. In order to fix this, I didn't attach the hudNode to the rootNode (ie. the 'rootNode.attachChild(hudNode);' line was removed), and added the following to draw it later:


protected void simpleRender(){
  display.getRenderer().draw(hudNode);
}


This cleared up the culling problem AND the lighting problem.

Am I the only one with this problem? Or am I going crazy?  :)

Nope, you aren't going crazy. This tutorial was written a long time ago, and needs to be updated. Thanks for this list, I'll update it to take care of these problems.

astruyk said:
Lastly, when I turn the camera away from the cylinder, the Quad on the HUD dissapears (I'm guessing its culled for some reason).

The same happened to me with my mouse - the mouse cursor disappeared when nothing in the RootNode was within sight of the camera. The mouse was used like in the Hello MousePick Tutorial.

The devs are in fact discussing this strange behaviour already (the dissappearing rootNode). Thanks for providing a good example.

Your "fix" is actually the correct way to do things in jME.  HUD and 3d scene elements are best kept in seperate scene trees.