Usable Nifty GUI on a Texture?


I have a Nifty GUI set up on a texture, as in the Nifty GUI Tutorial. I want the GUI to be functional; when the user clicks on GUI elements where they show up in the final rendered scene, I want the click events to be forwarded back to the Nifty GUI. I set [java]flyCam.setDragToRotate(true);[/java] in my SimpleApplication, which gets me a mouse cursor, but the rendered-to-texture Nifty GUI is currently oblivious to all user input.

I’m thinking I have to manually set up picking, somehow determine the texture coordinates of the picked location, and throw an event to Nifty GUI. There’s a tutorial for picking, but I need to know how to get the texture coordinates from a [java]CollisionResult[/java], and how to send a fake click event to Nifty GUI.

Alternately, is there some existing way to make rendered-to-texture GUIs functional?

No-one has written the more “advanced” collision documentation yet, but it will come. But I don’t know whether that is the best/only solution.

I could have sworn I tested whether this GUI on the texture was functional when I wrote the tutorial, but apparently I only tested the arow / tab / return keys… (They should work for you.) Grrr.

I tried it with today’s build, yup, not clickable the way it is. I don’t know what I am doing, sometimes it registers a click and it selects an item from the menu… Sorry, we will need to investigate this.

Yes, clicking on a GUI thats on a texture isn’t handled. What you said is correct, you would have to raycast on the GUI mesh to find the UV coords of the clicked point, and then send a click event with the correct coordinates to the nifty gui.

Currently NiftyGui uses its own input handler that implements RawInputListener, to support clicking on the texture, you just have to implement your own RawInputListener that will handle mouse events in a different way.

Does the picking API support pulling out texture coordinates? It looks like CollisionResult only gives world coordinates.

How do I convert world coordinates to texture coordinates? And what NiftyGUI class is the RawInputListener?