Is there a way how I can use Buttons (Jbuttons), Labels etc… in JME? In my scenario, I want to use it as a menu, and then it switches back to 3D and vice versa. What code can I use to ‘switch off (and on)’ 3D?
You can only have a opengl window inside a swing panel which then could be “surrounded” by other swing elements. See the TestAwtPanel test for this. Let me remind you right off that you cannot modify the scene from the AWT thread (that is the thread that all button presses are processed on) and have to use Callables to modify the scene.
Thanks for the prompt reply. It looks quite complicated. I guess I should learn Nifty Gui whenever I get a little chance. Is there any finished simple example of Nifty?
TestNiftyGui.java
TestNiftyExamples.java
Thanks
The other alternative is to create your own buttons and labels using regular scene graph components. It’s not overly difficult depending on how much you need. If you have a “do it yourself” spirit and not many components to write then it might be easier than learning nifty. Maybe.
I absolutely love creating things myself. However, what do I need to do to make my shapes face the camera to appear as true shapes?
For example, if you add a Quad in a Geometry to the guiNode, it will face the camera in 2D and be positioned in screen coordinates.
[java]
Quad q = new Quad(100,20);
Geometry g = new Geometry("my quad", q);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md" );
mat.setColor( ColorRGBA.Red );
g.setMaterial(mat);
g.setLocalTranslation( 100, 100, 0 );
guiNode.attachChilde(g);
[/java]
…off the top of my head… should make a red rectangle. The Unshaded material can also accept textures, etc…
This is the sort of approach I use for all of the newer GUIs in Mythruna.
Man… thanks. A lot! This is really helpful! If I could +100 you, I’d do it right now.