Nifty HUD and projection

I have a conflict, in this tutorial is created a new ViewPort to use it in the NiftyJmeDisplay. But I have to use my guiViewPort of jme, because anyway I like to have my HUD?! I think a 2. NiftyJmeDisplay is not possible. Maybe I’m completely wrong. My target is to have the chat, menu … to have in normal 2D. And things like minimap in form of projecting into a texture. How do u handle this?

When it’s not possible I think the best way is projecting the whole interface.

I’m not sure I can understand it completly but.

Im pretty sure you can have multiple niftyjmedisplays, you just have to use different viewports.
Eg one with the guiviewport and one using a custom viewport where the resulting texter is used from.

import com.jme3.app.SimpleApplication;
import com.jme3.niftygui.NiftyJmeDisplay;
import com.jme3.renderer.ViewPort;

public class MultipleViewportsTest extends SimpleApplication
{
	@Override
	public void simpleInitApp()
	{
		NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(getAssetManager(), getInputManager(), getAudioRenderer(), getGuiViewPort());

		ViewPort niftyView = renderManager.createPreView("NiftyView", getCamera());
		NiftyJmeDisplay niftyDisplay2 = new NiftyJmeDisplay(getAssetManager(), getInputManager(), getAudioRenderer(), niftyView);

		getGuiViewPort().addProcessor(niftyDisplay);
		getGuiViewPort().addProcessor(niftyDisplay2);
	}

	public static void main(String[] args)
	{
		MultipleViewportsTest t = new MultipleViewportsTest();
		t.start();
	}
}

WARNUNG: An event service by the name NiftyEventBusalready exists.  Perhaps multiple threads tried to create a service about the same time?
org.bushe.swing.event.EventServiceExistsException: An event service by the name NiftyEventBusalready exists.  Perhaps multiple threads tried to create a service about the same time?
	at org.bushe.swing.event.EventServiceLocator.setEventService(EventServiceLocator.java:123)
	at de.lessvoid.nifty.Nifty.initalizeEventBus(Nifty.java:222)
	at de.lessvoid.nifty.Nifty.initialize(Nifty.java:202)
	at de.lessvoid.nifty.Nifty.<init>(Nifty.java:143)
	at com.jme3.niftygui.NiftyJmeDisplay.<init>(NiftyJmeDisplay.java:159)
	at de.boldt.exo.client.MultipleViewportsTest.simpleInitApp(MultipleViewportsTest.java:15)
	at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:226)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:130)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:207)
	at java.lang.Thread.run(Thread.java:745)

So if I understand correctly, you want to render two different Nifty screens at the same time, one in your gui viewport and another one onto a texture which is applied in the scene somewhere.

This would require two viewports which in turns would require two nifty instances as I don’t believe you can have to nifty screens open at the same time. Nifty will not allow you to create two instances as the event bus uses a constant for a name and creating a second nifty blows up as the eventbus already exists for that name. I could be wrong but last time I tried this that’s what happened.

So the question I suppose is if there is any way of using the same nifty instance and just project a specific screen layer to the other viewport. I don’t know if that’s possible.

One obvious thing is that if the mini map and other things that you want to put in 3D space doesn’t need to be interactable then you can just render the them to a texture outside of Nifty and do it that way instead.

Exactly, the event service already existing name is happening, thats why I wrote I think its not possible to have multiple displays. Yes, maybe its the better way not using nifty when I dont need to interact with it. It seemed to me to be the easier way to use nifty for everything, but ok.

Thank you.