|
|
|
@ -32,6 +32,8 @@ |
|
|
|
|
|
|
|
|
|
package com.jme3.niftygui; |
|
|
|
|
|
|
|
|
|
import com.jme3.asset.AssetInfo; |
|
|
|
|
import com.jme3.asset.AssetKey; |
|
|
|
|
import com.jme3.asset.AssetManager; |
|
|
|
|
import com.jme3.audio.AudioRenderer; |
|
|
|
|
import com.jme3.input.InputManager; |
|
|
|
@ -43,8 +45,12 @@ import com.jme3.renderer.queue.RenderQueue; |
|
|
|
|
import com.jme3.texture.FrameBuffer; |
|
|
|
|
import de.lessvoid.nifty.Nifty; |
|
|
|
|
import de.lessvoid.nifty.tools.TimeProvider; |
|
|
|
|
import de.lessvoid.nifty.tools.resourceloader.ResourceLoader; |
|
|
|
|
import de.lessvoid.nifty.tools.resourceloader.ResourceLocation; |
|
|
|
|
import java.io.InputStream; |
|
|
|
|
import java.net.URL; |
|
|
|
|
|
|
|
|
|
public class NiftyJmeDisplay extends TimeProvider implements SceneProcessor { |
|
|
|
|
public class NiftyJmeDisplay implements SceneProcessor { |
|
|
|
|
|
|
|
|
|
protected boolean inited = false; |
|
|
|
|
protected Nifty nifty; |
|
|
|
@ -55,10 +61,22 @@ public class NiftyJmeDisplay extends TimeProvider implements SceneProcessor { |
|
|
|
|
protected SoundDeviceJme soundDev; |
|
|
|
|
protected Renderer renderer; |
|
|
|
|
protected ViewPort vp; |
|
|
|
|
|
|
|
|
|
protected ResourceLocationJme resourceLocation; |
|
|
|
|
|
|
|
|
|
protected int w, h; |
|
|
|
|
|
|
|
|
|
public NiftyJmeDisplay() { |
|
|
|
|
protected class ResourceLocationJme implements ResourceLocation { |
|
|
|
|
|
|
|
|
|
public InputStream getResourceAsStream(String path) { |
|
|
|
|
AssetKey<Object> key = new AssetKey<Object>(path); |
|
|
|
|
AssetInfo info = assetManager.locateAsset(key); |
|
|
|
|
return info.openStream(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public URL getResource(String path) { |
|
|
|
|
throw new UnsupportedOperationException(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public NiftyJmeDisplay(AssetManager assetManager, |
|
|
|
@ -70,13 +88,17 @@ public class NiftyJmeDisplay extends TimeProvider implements SceneProcessor { |
|
|
|
|
w = vp.getCamera().getWidth(); |
|
|
|
|
h = vp.getCamera().getHeight(); |
|
|
|
|
|
|
|
|
|
resourceLocation = new ResourceLocationJme(); |
|
|
|
|
ResourceLoader.removeAllResourceLocations(); |
|
|
|
|
ResourceLoader.addResourceLocation(resourceLocation); |
|
|
|
|
|
|
|
|
|
soundDev = new SoundDeviceJme(assetManager, audioRenderer); |
|
|
|
|
renderDev = new RenderDeviceJme(this); |
|
|
|
|
inputSys = new InputSystemJme(inputManager); |
|
|
|
|
if (inputManager != null) |
|
|
|
|
inputManager.addRawInputListener(inputSys); |
|
|
|
|
|
|
|
|
|
nifty = new Nifty(renderDev, soundDev, inputSys, this); |
|
|
|
|
nifty = new Nifty(renderDev, soundDev, inputSys, new TimeProvider()); |
|
|
|
|
inputSys.setNifty(nifty); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|