I want to a “what you see is what you get”-scene-editor which enables to place and delete simple jme3 built-in shapes and custom meshes on a solid floor.
Placing the objects is no problem (using MouseButtonTrigger-handling, raycasting and just creating a new Shape at that position)
But… Only click into the scene and letting the shape appear… this is not what I want: When I click into the scene I want that a context menu appears because I want to
display context information about the scenepoint that I have hit with my mouseclick
to have more possibilitys for scene manipulation: I want to have Menu-Items like… “add sphere”, “add cube”, “delete obstacle”, “change texture” and so on. It would also be nice if the menu could be nested.
Is that possible using nifty?
As a first try I try to modify nifty examples. This is the xml I use:
The problem with this code is that the nifty screen (or the panel (or whatever)) occludes my scene. In addition, my mouse-cursor is immobile. What can I do?
For context menus I use nifty builders to build the menu dynamically. I create a panel and place it in a suitable position on the screen then place my buttons/whatever within that.
The nifty screen will always be above the rest of the scene unless you display it on some geometry/quad or something. For the rest thats surely possible, maybe you’ll need to do some custom Nifty Controllers for some things, check the Nifty Bible.
…but you can edit scenes visually in the SDK and easily add items to its add menus.
Heres an example of a fully functional plugin for the SDK that allows adding a box using the SceneComposer/SceneExplorer, including automatic undo support, it will appear in the “New Spatial” submenu:
@normen said:
The nifty screen will always be above the rest of the scene unless you display it on some geometry/quad or something. For the rest thats surely possible, maybe you'll need to do some custom Nifty Controllers for some things, check the Nifty Bible.
..but you can edit scenes visually in the SDK and easily add items to its add menus.
Heres an example of a fully functional plugin for the SDK that allows adding a box using the SceneComposer/SceneExplorer, including automatic undo support, it will appear in the "New Spatial" submenu:
[java]@org.openide.util.lookup.ServiceProvider(service = NewSpatialAction.class)
public class NewBoxAction extends AbstractNewSpatialAction {
Sounds simple. What I want is, that the functionality is in my software. Your code is an extention for the SceneComposer/SceneExplorer (which is external software, isnt it?) menus. If I got it right, these menus work inside the SceneComposer/SceneExplorer only(?) Is it easy to embedd in custom SimpleAplications? (If yes.. how?)
@zarch said:
For context menus I use nifty builders to build the menu dynamically. I create a panel and place it in a suitable position on the screen then place my buttons/whatever within that.
I just checked out this tutorial about creating nifty things without xml:
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:nifty_gui_java_layout?s[]=nifty&s[]=java
In that tutorial it looks like that you always have to define a screen. (To me it looks that this is always required, even if you want to have a context menu with dynamic position.) Do you have a solution without a screen or (at least) where the nifty screen is not occluding your scene? Can you post a code example please?
Just create the nifty screen, add a layer into it that’s transparent (probably absolute layout) then add the popup menu as a smaller panel within that.
Nifty layers always fill the full screen, but they default to transparent…