I am currently making an inventory system and therefore need to display some item icons to the user (similar to minecraft inventory). The GUI is made with Nnfty so I want to use nifty for those inventory slots too. Logically, I want to use a TextureAtlas for storing all item icons but unfortunately I couldn“t find any way of setting a nifty components (image or background-image of a panel) image via a TextureAtlas. To me it looks like if it would only support a String for a single image.
Not sure if you mean the actual class TextureAtlas. If so, you could probably set the texture like this:
Element icon = inventory.findElementById("Icon1234");
ImageRenderer renderer = icon.getRenderer(ImageRenderer.class);
renderer.setImage( new NiftyImage(_nifty.getRenderEngine(), new RenderImageJme(atlas.getAtlasTexture("DiffuseMap")) );
The latest version of Nifty (1.4? the one that comes with the jme 3.1 alpha) supports automatic generation of an atlas. It uses one single texture that is populated with all the images that you add. You have to use a certain constructor of NiftyJmeDisplay to activate the atlas. But AFAIK this prevents you from using jme-generated textures (like from a viewport that is rendered to a texture).
You can also draw your atlas yourself and then use something like:
Sry for my late reply. I googled Nifties imageModes, but I couldn“t find a useful documentation. What do these numerical parameters mean? Is there somewhere the source rectangle I want to use of the given texture, or what do they mean?
Additionally, I appreciate every source for nifties image modes.