/** * Attaches many state to the AppStateManager in a way that is guaranteed * that they will all get initialized before any of their updates are run. * The same state cannot be attached twice and will be ignored. * * @param states The states to attach */ public void attachAll(Iterable<AppState> states){ synchronized (this.states){ for( AppState state : states ) { attach(state); } } }
/** * Create a new VR application and attach the given {@link AppState app states}.<br> * The application scene is made of a {@link #getRootNode() root node} that holds the scene spatials * and a {@link #getGuiNode() GUI node} that is the root of the Graphical user interface. * @param initialStates the {@link AppState app states} to attach to the application. */ public VRApplication(AppState... initialStates) { this(); if (initialStates != null) { for (AppState a : initialStates) { if (a != null) { stateManager.attach(a); } } } }
@Override public void simpleInitApp() { BulletAppState bulletAppState = new BulletAppState() { @Override public void physicsTick(PhysicsSpace space, float timeStep) { physicsTime += timeStep; } }; bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL); stateManager.attach(bulletAppState); }
/** * Create a new instance of <code>LegacyApplication</code>, preinitialized * with the specified set of app states. */ public LegacyApplication( AppState... initialStates ) { initStateManager(); if (initialStates != null) { for (AppState a : initialStates) { if (a != null) { stateManager.attach(a); } } } }
private void initStateManager(){ stateManager = new AppStateManager(this); // Always register a ResetStatsState to make sure // that the stats are cleared every frame stateManager.attach(new ResetStatsState()); }
private void initStateManager(){ stateManager = new AppStateManager(this); // Always register a ResetStatsState to make sure // that the stats are cleared every frame stateManager.attach(new ResetStatsState()); }
@Override public void simpleUpdate(float tpf) { if (frame % 4 == 0) { System.out.println(++count); bulletAppState = new BulletAppState(); bulletAppState.setThreadingType(ThreadingType.PARALLEL); stateManager.attach(bulletAppState); } else if (frame % 4 == 2) { stateManager.detach(bulletAppState); } frame++; if (count == 70) { System.exit(0); } } }
/** * Transition this state from detached to initializing. Should be invoked * only by a subclass or by the AppStateManager. * * @param stateManager (not null) */ public void stateAttached(AppStateManager stateManager) { if (!initialized) { startPhysics(); } if (threadingType == ThreadingType.PARALLEL) { PhysicsSpace.setLocalThreadPhysicsSpace(pSpace); } if (debugEnabled) { debugAppState = new BulletDebugAppState(pSpace); stateManager.attach(debugAppState); } }
@Override public void simpleInitApp() { bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); bulletAppState.setDebugEnabled(true); setupKeys(); setupJoint(); }
@Override public void simpleInitApp() { bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); bulletAppState.setDebugEnabled(true); setupKeys(); setupJoint(); }
@Override public void simpleInitApp() { bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); bulletAppState.setDebugEnabled(true); setupKeys(); setupFloor(); buildPlayer(); }
@Override public void simpleInitApp() { Box b = new Box(1, 1, 1); Geometry geom = new Geometry("Box", b); Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md"); mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg")); geom.setMaterial(mat); rootNode.attachChild(geom); System.out.println("Attaching test state."); stateManager.attach(new TestState()); }
@Override public void simpleInitApp() { bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); bulletAppState.setDebugEnabled(true); PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace()); setupKeys(); buildPlayer(); }
@Override public void initialize(AppStateManager stateManager, Application app) { super.initialize(stateManager, app); //only generate data and attach node when we are actually attached (or picking) initData(); application = (SimpleApplication) app; application.getRootNode().attachChild(getRootNode()); application.getStateManager().attach(physicsState); }
@Override public void simpleInitApp() { bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); bulletAppState.setDebugEnabled(true); inputManager.addMapping("Pull ragdoll up", new MouseButtonTrigger(0)); inputManager.addListener(this, "Pull ragdoll up"); PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace()); createRagDoll(); }
@Override public void simpleInitApp() { BulletAppState bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); String sinbadPath = "Models/Sinbad/SinbadOldAnim.j3o"; Node sinbad = (Node) assetManager.loadModel(sinbadPath); Node extender = new Node(); for (Spatial child : sinbad.getChildren()) { extender.attachChild(child); } sinbad.attachChild(extender); //Note: PhysicsRagdollControl is still a WIP, constructor will change KinematicRagdollControl ragdoll = new KinematicRagdollControl(0.5f); sinbad.addControl(ragdoll); stop(); } }
@Override public void simpleInitApp() { bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); bulletAppState.setDebugEnabled(true); bullet = new Sphere(32, 32, 0.4f, true, false); bullet.setTextureMode(TextureMode.Projected); bulletCollisionShape = new SphereCollisionShape(0.4f); PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace()); PhysicsTestHelper.createBallShooter(this, rootNode, bulletAppState.getPhysicsSpace()); // add ourselves as collision listener getPhysicsSpace().addCollisionListener(this); }
@Override public void simpleInitApp() { /** Set up Physics Game */ bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); //bulletAppState.getPhysicsSpace().enableDebug(assetManager); /** Configure cam to look at scene */ cam.setLocation(new Vector3f(0, 4f, 6f)); cam.lookAt(new Vector3f(2, 2, 0), Vector3f.UNIT_Y); /** Initialize the scene, materials, inputs, and physics space */ initInputs(); initMaterials(); initWall(); initFloor(); initCrossHairs(); }
@Override public void simpleInitApp() { stateManager.attach(bulletAppState); initCrossHair(); Spatial s = assetManager.loadModel("Models/Elephant/Elephant.mesh.xml"); s.setLocalScale(0.1f); CollisionShape collisionShape = CollisionShapeFactory.createMeshShape(s); Node n = new Node("elephant"); n.addControl(new RigidBodyControl(collisionShape, 1)); n.getControl(RigidBodyControl.class).setKinematic(true); bulletAppState.getPhysicsSpace().add(n); rootNode.attachChild(n); bulletAppState.setDebugEnabled(true); }
@Override public void simpleInitApp() { bulletAppState = new BulletAppState(); bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL); stateManager.attach(bulletAppState); setupKeys(); prepareBullet(); prepareEffect(); createLight(); createSky(); createTerrain(); createWall(); createCharacter(); setupChaseCamera(); setupAnimationController(); setupFilter(); }