當前位置: 首頁>>代碼示例>>Java>>正文


Java SimpleApplication類代碼示例

本文整理匯總了Java中com.jme3.app.SimpleApplication的典型用法代碼示例。如果您正苦於以下問題:Java SimpleApplication類的具體用法?Java SimpleApplication怎麽用?Java SimpleApplication使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SimpleApplication類屬於com.jme3.app包,在下文中一共展示了SimpleApplication類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: PlayerManager

import com.jme3.app.SimpleApplication; //導入依賴的package包/類
/**
 * Constructor for the client.
 * @param app Game application.
 * @param coursePath Course path the players follow.
 * @param bullet Bullet app state with which to create player physics.
 * @param totalPlayers Total number of players in game.
 * @param localPlayerIdx Order of client player starting at 0.
 */
public PlayerManager(SimpleApplication app, CoursePath coursePath,
                     BulletAppState bullet, int totalPlayers,
                     int localPlayerIdx) {
  this.application = app;
  this.coursePath = coursePath;
  this.bullet = bullet;
  this.players = new Spatial[totalPlayers];
  for (int i = 0; i < totalPlayers; ++i) {
    Spatial player = createPlayer(this.application.getRootNode(), i);
    this.players[i] = player;
    if (i == localPlayerIdx) {
      this.localPlayer = player;
    }
  }
  positionPlayers(players);
}
 
開發者ID:meoblast001,項目名稱:seally-racing,代碼行數:25,代碼來源:PlayerManager.java

示例2: initialize

import com.jme3.app.SimpleApplication; //導入依賴的package包/類
@Override
public void initialize(AppStateManager stateManager, Application app) {
	super.initialize(stateManager, app);
	
	this.app = app;
	
	chunksNode.updateGeometricState();
	
	app.getViewPort().attachScene(chunksNode);
	
	active = true;
	
	new TraceableThread(this::loadChunks, "chunk-loader").start();
	new TraceableThread(this::meshChunks, "chunk-mesher").start();
	
	BitmapFont font = app.getAssetManager().loadFont("Interface/Fonts/Console.fnt");
	
	debugText = new BitmapText(font);
	debugText.setSize(font.getCharSet().getRenderedSize());
	debugText.setColor(ColorRGBA.White);
	debugText.setText("");
	debugText.setLocalTranslation(0.0f, 0.0f, 1.0f);
	debugText.updateGeometricState();
	
	((SimpleApplication)app).getGuiNode().attachChild(debugText);
}
 
開發者ID:quadracoatl,項目名稱:quadracoatl,代碼行數:27,代碼來源:ChunkManagingState.java

示例3: createServer

import com.jme3.app.SimpleApplication; //導入依賴的package包/類
public static void createServer(){
    serverApp = new SimpleApplication() {
        @Override
        public void simpleInitApp() {
        }
    };
    serverApp.start();

    try {
        Server server = Network.createServer(5110);
        server.start();

        ObjectStore store = new ObjectStore(server);
        store.exposeObject("access", new ServerAccessImpl());
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:19,代碼來源:TestRemoteCall.java

示例4: makeFloor

import com.jme3.app.SimpleApplication; //導入依賴的package包/類
public static void makeFloor(SimpleApplication app) {    	
      Box box=new Box(160,.2f,160);
      Geometry floor=new Geometry("the Floor",box);
      floor.setLocalTranslation(0,-4f,0);
      Material mat1=new Material(app.getAssetManager(),"Common/MatDefs/Light/Lighting.j3md");
      mat1.setColor("Diffuse",new ColorRGBA(.54f,.68f,.16f,1f));
      mat1.setBoolean("UseMaterialColors",true);
      floor.setMaterial(mat1);
      
      CollisionShape floorcs=new MeshCollisionShape(floor.getMesh());
RigidBodyControl floor_phy=new RigidBodyControl(floorcs,0);
floor.addControl(floor_phy);
floor_phy.setPhysicsLocation(new Vector3f(0,-30,0));		
app.getStateManager().getState(BulletAppState.class).getPhysicsSpace().add(floor_phy);		
app.getRootNode().attachChild(floor);			
  }
 
開發者ID:riccardobl,項目名稱:jme3-bullet-vhacd,代碼行數:17,代碼來源:Commons.java

示例5: initialize

import com.jme3.app.SimpleApplication; //導入依賴的package包/類
@Override
public void initialize(AppStateManager stateManager, Application app) {
    super.initialize(stateManager, app);
    
    this.app = (SimpleApplication)app;
    this.ed = this.app.getStateManager().getState(EntityDataState.class).getEntityData();
    this.entities = this.ed.getEntities(Transform.class, Billboard.class);
    
    this.inputManager = this.app.getInputManager();
    this.inputManager.addMapping("Update", new KeyTrigger(KeyInput.KEY_W),
                                           new KeyTrigger(KeyInput.KEY_S),
                                           new KeyTrigger(KeyInput.KEY_A),
                                           new KeyTrigger(KeyInput.KEY_D),
                                           new KeyTrigger(KeyInput.KEY_Q),
                                           new KeyTrigger(KeyInput.KEY_Z));
    this.inputManager.addListener(analogListener, "Update");
}
 
開發者ID:Ev1lbl0w,項目名稱:zombie-survival,代碼行數:18,代碼來源:BillboardAppState.java

示例6: initialize

import com.jme3.app.SimpleApplication; //導入依賴的package包/類
@Override
public void initialize(AppStateManager stateManager, Application app) {
    super.initialize(stateManager, app);
    this.app = app;
    if (assetManager == null) {
        assetManager = app.getAssetManager();
    }
    if (guiNode == null && app instanceof SimpleApplication) {
        guiNode = ((SimpleApplication) app).getGuiNode();
    }
    if (guiNode == null || assetManager == null) {
        throw new NullPointerException("guiNode or assetManager not specified!");
    }
    splash = new Picture("Splash Image");
    splash.setImage(assetManager, pictureLocation, false);

    guiNode.attachChild(splash);
}
 
開發者ID:matthewseal,項目名稱:MoleculeViewer,代碼行數:19,代碼來源:SplashAppState.java

示例7: initControls

import com.jme3.app.SimpleApplication; //導入依賴的package包/類
public void initControls(InputManager inputManager) {
    inputManager.deleteMapping(SimpleApplication.INPUT_MAPPING_EXIT);

    inputManager.addMapping("open_menu", new KeyTrigger(KeyInput.KEY_ESCAPE));
    inputManager.addMapping("view_atom", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
    inputManager.addListener(new ActionListener() {
        @Override
        public void onAction(String name, boolean isPressed, float tpf) {
            if ("open_menu".equals(name) && isPressed) {
                NiftyAppState s = stateManager.getState(NiftyAppState.class);
                if ("menu".equals(s.nifty.getCurrentScreen().getScreenId())) {
                    s.exitMenu();
                } else {
                    s.openMenu();
                }
            } else if ("view_atom".equals(name) && isPressed) {
                triggerViewAtom();
            }
        }
    }, "open_menu", "view_atom");
}
 
開發者ID:matthewseal,項目名稱:MoleculeViewer,代碼行數:22,代碼來源:MVAppState.java

示例8: registerAction_PlayAnimation

import com.jme3.app.SimpleApplication; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public static void registerAction_PlayAnimation(AnimationExplorer exp, SimpleApplication app) {
	exp.treeItemActions.add(new Action("play", (evt) -> {
		TreeItem<Object> treeItem = ((TreeItem<Object>)evt.getSource());
		Object target = treeItem.getValue();
		if (target instanceof Animation) {
			AnimControl ac = ((Spatial)treeItem.getParent().getValue()).getControl(AnimControl.class);
			ac.clearChannels();

			Animation ani = ((Animation)target);
			AnimChannel channel = ac.createChannel();
			channel.setAnim(ani.getName());
			channel.setLoopMode(LoopMode.DontLoop);
			channel.setSpeed(1f);
		}
	}));
}
 
開發者ID:davidB,項目名稱:jme3_ext_spatial_explorer,代碼行數:18,代碼來源:Actions4Animation.java

示例9: registerAction_SaveAsJ3O

import com.jme3.app.SimpleApplication; //導入依賴的package包/類
@SuppressWarnings("unchecked")
	public static void registerAction_SaveAsJ3O(SpatialExplorer se, SimpleApplication app) {
		FileChooser fileChooser = new FileChooser();
		fileChooser.getExtensionFilters().addAll(
			new FileChooser.ExtensionFilter("jMonkeyEngine Object (*.j3o)", "*.j3o")
		);
		se.treeItemActions.add(new Action("Save as .j3o", (evt) -> {
			System.out.println("target : " + evt.getTarget());
			File f0 = fileChooser.showSaveDialog(
					null
//					((MenuItem)evt.getTarget()).getGraphic().getScene().getWindow()
//					((MenuItem)evt.getTarget()).getParentPopup()
			);
			if (f0 != null) {
				File f = (f0.getName().endsWith(".j3o"))? f0 : new File(f0.getParentFile(), f0.getName() + ".j3o");
				app.enqueue(()->{
					Spatial target = ((TreeItem<Spatial>)evt.getSource()).getValue();
					new BinaryExporter().save(target, f);
					return null;
				});
			}
		}));
	}
 
開發者ID:davidB,項目名稱:jme3_ext_spatial_explorer,代碼行數:24,代碼來源:Helper.java

示例10: registerAction_ShowWireframe

import com.jme3.app.SimpleApplication; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public static void registerAction_ShowWireframe(SpatialExplorer se, SimpleApplication app) {
	se.treeItemActions.add(new Action("Show Wireframe", (evt) -> {
		Spatial target = ((TreeItem<Spatial>)evt.getSource()).getValue();
		app.enqueue(() -> {
			target.breadthFirstTraversal(new SceneGraphVisitorAdapter(){
				public void visit(Geometry geom) {
					RenderState r = geom.getMaterial().getAdditionalRenderState();
					boolean wireframe = false;
					try {
						Field f = r.getClass().getDeclaredField("wireframe");
						f.setAccessible(true);
						wireframe = (Boolean) f.get(r);
					} catch(Exception exc) {
						exc.printStackTrace();
					}
					r.setWireframe(!wireframe);
				}
			});
			return null;
		});
	}));
}
 
開發者ID:davidB,項目名稱:jme3_ext_spatial_explorer,代碼行數:24,代碼來源:Helper.java

示例11: registerAction_ShowBound

import com.jme3.app.SimpleApplication; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public static void registerAction_ShowBound(SpatialExplorer se, SimpleApplication app) {
	Material matModel = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
	matModel.setColor("Color", ColorRGBA.Orange);
	Material matWorld = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
	matWorld.setColor("Color", ColorRGBA.Red);

	se.treeItemActions.add(new Action("Show Bounds", (evt) -> {
		Spatial target = ((TreeItem<Spatial>)evt.getSource()).getValue();
		app.enqueue(() -> {
			target.breadthFirstTraversal(new SceneGraphVisitorAdapter(){
				public void visit(Geometry geom) {
					ShowBoundsControl ctrl = geom.getControl(ShowBoundsControl.class);
					if (ctrl != null) {
						geom.removeControl(ctrl);
					} else {
						geom.addControl(new ShowBoundsControl(matModel, matWorld));
					}
				}
			});
			return null;
		});
	}));
}
 
開發者ID:davidB,項目名稱:jme3_ext_spatial_explorer,代碼行數:25,代碼來源:Helper.java

示例12: registerAction_Remove

import com.jme3.app.SimpleApplication; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public static void registerAction_Remove(SpatialExplorer se, SimpleApplication app) {
	se.treeItemActions.add(new Action("Remove", (evt) -> {
		TreeItem<Spatial> treeItem = ((TreeItem<Spatial>)evt.getSource());
		Spatial target = treeItem.getValue();
		app.enqueue(() -> {
			if (target.getParent() != null) {
				target.removeFromParent();
				Platform.runLater(() ->{
					se.update(treeItem.getParent().getValue(), treeItem.getParent());
				});
			}
			return null;
		});
	}));
}
 
開發者ID:davidB,項目名稱:jme3_ext_spatial_explorer,代碼行數:17,代碼來源:Helper.java

示例13: registerBarAction_ShowFrustums

import com.jme3.app.SimpleApplication; //導入依賴的package包/類
public static void registerBarAction_ShowFrustums(SpatialExplorer se, SimpleApplication app) {
	se.barActions.add(makeAction("Show Frustums", FontAwesome.Glyph.VIDEO_CAMERA, (evt) -> {
		app.enqueue(() -> {
			Node grp = (Node) app.getRootNode().getChild("_frustums");
			if (grp != null) {
				grp.removeFromParent();
			} else {
				grp = new Node("_frustums");
				app.getRootNode().attachChild(grp);
				Set<Camera> cameras = new HashSet<>();
				for(ViewPort vp : app.getRenderManager().getMainViews()) {
					Camera cam = vp.getCamera();
					if (!cameras.contains(cam)) {
						grp.attachChild(createFrustum(cam, app.getAssetManager()));
						cameras.add(cam);
					}
				}
			}
			return null;
		});
	}));
}
 
開發者ID:davidB,項目名稱:jme3_ext_spatial_explorer,代碼行數:23,代碼來源:Helper.java

示例14: setupSpatialExplorerWithAll

import com.jme3.app.SimpleApplication; //導入依賴的package包/類
public static void setupSpatialExplorerWithAll(SimpleApplication app, final Node exploreNode) {
	app.enqueue(() -> {
		AppStateSpatialExplorer ase = new AppStateSpatialExplorer(exploreNode);
		SpatialExplorer se = ase.spatialExplorer;
		Helper.registerAction_Refresh(se);
		Helper.registerAction_ShowLocalAxis(se, app);
		Helper.registerAction_ShowWireframe(se, app);
		Helper.registerAction_ShowBound(se, app);
		Helper.registerAction_SaveAsJ3O(se, app);
		Helper.registerAction_Remove(se, app);
		Helper.registerBarAction_ShowFps(se, app);
		Helper.registerBarAction_ShowStats(se, app);
		Helper.registerBarAction_SceneInWireframe(se, app);
		Helper.registerBarAction_ShowFrustums(se, app);
		Actions4Animation.registerAllActions(se, app);
		Actions4Bullet.registerAllActions(se, app);
		app.getStateManager().attach(ase);
		return null;
	});
}
 
開發者ID:davidB,項目名稱:jme3_ext_spatial_explorer,代碼行數:21,代碼來源:Helper.java

示例15: sampleCube

import com.jme3.app.SimpleApplication; //導入依賴的package包/類
public static Spatial sampleCube(SimpleApplication app) {
	Geometry cube = Helper.makeShape("cube", new Box(0.5f, 0.5f, 0.5f), ColorRGBA.Brown, app.getAssetManager(), false);
	cube.setUserData("sample String", "string");
	cube.setUserData("sample int", 42);
	cube.setUserData("sample float", 42.0f);
	cube.setUserData("sample vector3f", new Vector3f(-2.0f, 3.0f, 4.0f));
	AnimControl ac = new AnimControl();
	Animation aniY = new Animation("Y basic translation", 10);
	aniY.addTrack(new SpatialTrack(new float[]{0, 5 , 10}, new Vector3f[]{new Vector3f(0, -5, 0), new Vector3f(0, 5, 0), new Vector3f(0, -5, 0)}, null, null));
	ac.addAnim(aniY);
	Animation aniX = new Animation("X basic translation", 10);
	aniX.addTrack(new SpatialTrack(new float[]{0, 5 , 10}, new Vector3f[]{new Vector3f(-5, 0, 0), new Vector3f(5, 0, 0), new Vector3f(-5, 0, 0)}, null, null));
	ac.addAnim(aniX);
	Animation aniZ = new Animation("Z basic translation", 10);
	aniZ.addTrack(new SpatialTrack(new float[]{0, 5 , 10}, new Vector3f[]{new Vector3f(0, 0, -5), new Vector3f(0, 0, 5), new Vector3f(0, 0, -5)}, null, null));
	ac.addAnim(aniZ);
	cube.addControl(ac);
	return cube;
}
 
開發者ID:davidB,項目名稱:jme3_ext_spatial_explorer,代碼行數:20,代碼來源:Demo.java


注:本文中的com.jme3.app.SimpleApplication類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。