本文整理汇总了Java中de.lessvoid.nifty.Nifty.addXml方法的典型用法代码示例。如果您正苦于以下问题:Java Nifty.addXml方法的具体用法?Java Nifty.addXml怎么用?Java Nifty.addXml使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.lessvoid.nifty.Nifty
的用法示例。
在下文中一共展示了Nifty.addXml方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import de.lessvoid.nifty.Nifty; //导入方法依赖的package包/类
private void init() {
guiNode.detachAllChildren();
sceneNode.detachAllChildren();
voronoi = new Voronoi();
Nifty nifty = app.getNifty();
screenController = new PolygonalScreenController(this);
nifty.registerScreenController(screenController);
nifty.addXml("org/shaman/terrain/polygonal/PolygonalScreen.xml");
nifty.gotoScreen("Polygonal");
}
示例2: initNifty
import de.lessvoid.nifty.Nifty; //导入方法依赖的package包/类
private void initNifty() {
Nifty nifty = app.getNifty();
screenController = new SketchTerrainScreenController(this);
nifty.registerScreenController(screenController);
nifty.addXml("org/shaman/terrain/sketch/SketchTerrainScreen.xml");
nifty.gotoScreen("SketchTerrain");
sendAvailablePresets();
// nifty.setDebugOptionPanelColors(true);
}
示例3: simpleInitApp
import de.lessvoid.nifty.Nifty; //导入方法依赖的package包/类
@Override
public void simpleInitApp() {
System.out.println("Main.simpleInitApp() is being called here.");
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);
/** Create a new NiftyGUI object */
Nifty nifty = niftyDisplay.getNifty();
// How do I set the screen here?
/** Read your XML and initialize your custom ScreenController */
MainScreenController screenController = new MainScreenController(this);
stateManager.attach(screenController);
// [...] boilerplate init nifty omitted
nifty.fromXml("Interface/startGameScreen.xml", "startGameScreen", screenController);
nifty.addXml("Interface/hudScreen.xml");
//nifty.fromXml("Interface/hudScreen.xml", "hudScreen", screenController);
// attach the Nifty display to the gui view port as a processor
guiViewPort.addProcessor(niftyDisplay);
this._nifty = nifty;
System.out.println("In the Main.simpleInitApp() method, nifty is: " + nifty.toString());
// Q: How do I determine if "startGame" is the correct string to pass the above method?
// A: I think this (second parameter) is the ID of the screen in the given file.
//
// nifty.fromXml("Interface/startGameScreen.xml", "startGame"); // Once I have a screencontroller, we will use the commented version
// nifty.fromXml("Interface/helloworld.xml", "start", new MySettingsScreenController(data));
flyCam.setDragToRotate(true); // This may cause complications without additional on/off logic.
// if we have additional screens to load, just call them like this:
// nifty.fromXml("Interface/startGameScreen.xml", "startGame");
// We need to call LoadGameFromScreen() next!! If it won't be called from a screen,
// then it needs to be called here instead!
// Need to disable mouse cursor when ready to start actual game: mouseInput.setCursorVisible(false);
LoadGameFromScreen();
if (settings.getRenderer().startsWith("LWJGL")) {
BasicShadowRenderer bsr = new BasicShadowRenderer(assetManager, 512);
bsr.setDirection(new Vector3f(-0.5f, -0.3f, -0.3f).normalizeLocal());
viewPort.addProcessor(bsr);
}
}
示例4: enable
import de.lessvoid.nifty.Nifty; //导入方法依赖的package包/类
@Override
protected void enable() {
app.enableWater(0);
app.setSkyEnabled(true);
app.setCameraEnabled(true);
map = (Heightmap) properties.get(KEY_HEIGHTMAP);
originalMap = map.clone();
scaledMap = originalMap;
app.setTerrain(map);
originalMapScale = app.getHeightmapSpatial().getLocalScale().clone();
originalTemperature = (Heightmap) properties.get(KEY_TEMPERATURE);
if (originalTemperature == null) {
originalTemperature = new Heightmap(originalMap.getSize());
originalTemperature.fillHeight(0.5f);
}
temperature = originalTemperature.clone();
originalMoisture = (Heightmap) properties.get(KEY_MOISTURE);
if (originalMoisture == null) {
originalMoisture = new Heightmap(originalMap.getSize());
originalMoisture.fillHeight(0.5f);
}
moisture = originalMoisture.clone();
Nifty nifty = app.getNifty();
screenController = new WaterErosionScreenController(this, originalMap.getSize());
nifty.registerScreenController(screenController);
nifty.addXml("org/shaman/terrain/erosion/WaterErosionScreen.xml");
nifty.gotoScreen("WaterErosion");
temperatureMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
moistureMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Light/Lighting.j3md");
heightDiffMaterial = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
updateTextures();
brushSphere = new Geometry("brush", new Sphere(32, 32, 1));
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", new ColorRGBA(1, 1, 1, 0.5f));
mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
brushSphere.setMaterial(mat);
brushSphere.setQueueBucket(RenderQueue.Bucket.Transparent);
sceneNode.attachChild(brushSphere);
brushSphere.setCullHint(Spatial.CullHint.Always);
brushSphere.setLocalScale(brushSize*TerrainHeighmapCreator.TERRAIN_SCALE);
solverMaterial = new Material(app.getAssetManager(), "org/shaman/terrain/shader/TerrainLightingExt.j3md");
solverMaterial.setBoolean("useTriPlanarMapping", true);
solverMaterial.setFloat("Shininess", 0.0f);
Texture darkRock = app.getAssetManager().loadTexture("org/shaman/terrain/rock2.jpg");
darkRock.setWrap(Texture.WrapMode.Repeat);
solverMaterial.setTexture("DiffuseMap", darkRock);
solverMaterial.setFloat("DiffuseMap_0_scale", 1/16f);
Texture grass = app.getAssetManager().loadTexture("org/shaman/terrain/grass.jpg");
grass.setWrap(Texture.WrapMode.Repeat);
solverMaterial.setTexture("DiffuseMap_1", grass);
solverMaterial.setFloat("DiffuseMap_1_scale", 1/8f);
Texture water = app.getAssetManager().loadTexture("org/shaman/terrain/textures/Water.jpg");
water.setWrap(Texture.WrapMode.Repeat);
solverMaterial.setTexture("DiffuseMap_2", water);
solverMaterial.setFloat("DiffuseMap_2_scale", 1/8f);
registerListener();
riverSourceNode = new Node("river sources");
sceneNode.attachChild(riverSourceNode);
}
示例5: enable
import de.lessvoid.nifty.Nifty; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected void enable() {
app.enableWater(0);
app.setSkyEnabled(true);
app.setCameraEnabled(true);
map = (Heightmap) properties.get(KEY_HEIGHTMAP);
temperature = (Heightmap) properties.get(KEY_TEMPERATURE);
moisture = (Heightmap) properties.get(KEY_MOISTURE);
water = (Heightmap) properties.get(KEY_WATER);
riverSources = (List<? extends RiverSource>) properties.get(KEY_RIVER_SOURCES);
if (properties.containsKey(KEY_TERRAIN_SCALE)) {
scaleFactor = (float) properties.get(KEY_TERRAIN_SCALE);
} else {
LOG.warning("no terrain scale factor defined, use default one");
scaleFactor = 0.5f; //test
}
LOG.info("terrain scale factor: "+scaleFactor);
Nifty nifty = app.getNifty();
screenController = new VegetationScreenController(this);
nifty.registerScreenController(screenController);
nifty.addXml("org/shaman/terrain/vegetation/VegetationScreen.xml");
nifty.gotoScreen("Vegetation");
app.setTerrain(map);
originalMapScale = app.getHeightmapSpatial().getLocalScale().clone();
app.getHeightmapSpatial().setLocalScale(originalMapScale.x * scaleFactor, originalMapScale.y, originalMapScale.z * scaleFactor);
brushSphere = new Geometry("brush", new Sphere(32, 32, 1));
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", new ColorRGBA(1, 1, 1, 0.5f));
mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
brushSphere.setMaterial(mat);
brushSphere.setQueueBucket(RenderQueue.Bucket.Transparent);
sceneNode.attachChild(brushSphere);
brushSphere.setCullHint(Spatial.CullHint.Always);
guiBrushSizeChanged(brushSize);
registerListener();
//initial biomes
Vectorfield biomes = new Vectorfield(map.getSize(), Biome.values().length);
for (int x=0; x<map.getSize(); ++x) {
for (int y=0; y<map.getSize(); ++y) {
float m = clamp(moisture.getHeightAt(x, y));
float t = clamp(temperature.getHeightAt(x, y));
float h = map.getHeightAt(x, y);
if (h<=0) {
biomes.setScalarAt(x, y, Biome.OCEAN.ordinal(), 1);
} else {
Biome b = Biome.getBiome(t, 1-m);
biomes.setScalarAt(x, y, b.ordinal(), 1);
}
}
}
materialCreator = new BiomesMaterialCreator(app.getAssetManager(), biomes);
app.forceTerrainMaterial(materialCreator.getMaterial(textured));
recording = new Recording(app, app.getCamera(), sceneNode);
}
示例6: initializeNifty
import de.lessvoid.nifty.Nifty; //导入方法依赖的package包/类
private void initializeNifty() throws PromiseException
{
inputSystem = new LwjglInputSystem();
try
{
inputSystem.startup();
}
catch (Exception ex)
{
throw new Error(ex);
}
nifty = new Nifty(new LwjglRenderDevice(), new NullSoundDevice(), inputSystem, new AccurateTimeProvider());
NiftyResourceLoader niftyResourceLoader = nifty.getResourceLoader();
niftyResourceLoader.removeAllResourceLocations();
// nifty first tries stuff on the class path (needed for its internal files)
niftyResourceLoader.addResourceLocation(new ClasspathLocation());
// Then try the same reference as a resource key
// (add this second so that zones can not override nifty build-ins)
niftyResourceLoader.addResourceLocation(new DBNiftyResourceLocation(resourceDB));
TriggerOnShowEffect.registerEffect(nifty);
SpriteAnimationEffect.registerEffect(nifty);
BackgroundColorSpriteEffect.registerEffect(nifty);
BackgroundColorAnimated.registerEffect(nifty);
ClockTextEffect.registerEffect(nifty);
niftyCameraImpl = new NiftyCameraImpl(resourceDB, mapEntities, mapClassic, stars);
CameraNiftyController.registerControl(nifty, niftyCameraImpl);
boolean first = true;
/*{
Logger logger = Logger.getLogger("de.lessvoid.nifty");
logger.setLevel(Level.FINER);
ConsoleHandler handler = new ConsoleHandler();
handler.setLevel(Level.FINER);
logger.addHandler(handler);
}*/
for (String res : networkedGame.niftyGuiResources)
{
if (first)
{
nifty.fromXmlWithoutStartScreen(res);
first = false;
}
else
{
nifty.addXml(res);
}
}
mainScreen = nifty.getScreen("aphelion-main");
if (mainScreen == null)
{
throw new PromiseException("Missing nifty-gui screen: aphelion-main");
}
ScreenController screenControl = mainScreen.getScreenController();
if (screenControl instanceof MainScreenController)
{
((MainScreenController) screenControl).aphelionBind(networkedGame);
}
nifty.gotoScreen("aphelion-main");
}