HelloMousePick Question

I was running the HelloMousePick and I noticed that if I move in and put the cube behind me, the mouse also disappears. Why does it do that?



The problem stems from the fact that the test mixes scenegraph objects and gui/ortho objects. The mouse disappears when the box is not on the screen because it falls in a scenegraph whose worldbound describes the boundingbox around the Spatial b. Thus, if b is not on the screen, the mouse is culled as well. You can fix this first issue by setting forceView on rootNode or removing the boundingbox from b, but that leaves another issue… at some positions where the box is really close to the camera, the mouse disappears… I haven’t looked that over much but I imagine the mouse is being affected by the zbufferstate that’s set on rootNode…

In practice, it is best to have GUI/ortho items on a seperate root node. You can see that the fps counter is fine in all the above situations. It’s on a seperately rendered node called fpsNode. If you change HelloMousePick to attach the mouse (am) to fpsNode instead of rootNode, everything will behave as it should.

Thanks renanse. That makes a lot of sense. I will play around with some of your suggestions so I can learn what’s going on.


You can also use the RenderQueue.

Edit: Fixed Spelling


In this case, it’s not the renderqueue though… The mouse not drawing at all is due to culling.

Is there something we could do to change this, just in case for some wacky reason someone wanted a GUI on their scene node? Like a GUI bounds? Or what about a default bounds for all objects, that is either 0 or infinity?

What would the bounds be for ortho objects though?? Even if it had a 2d bounds, it would not really exist in the 3d world and would not be easily compatible with culling. Mixing 2d gui items into your 3d scenegraph is just poor planning, imho.