private PhysicsSpace getPhysicsSpace() { return bulletAppState.getPhysicsSpace(); } }
@Override public void simpleInitApp() { bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); bulletAppState.setDebugEnabled(true); PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace()); setupKeys(); buildPlayer(); }
@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); } } }
public Boolean call() throws Exception { pSpace.update(getPhysicsSpace().getAccuracy() * getSpeed()); pSpace.distributeEvents(); long update = System.currentTimeMillis() - detachedPhysicsLastUpdate; detachedPhysicsLastUpdate = System.currentTimeMillis(); executor.schedule(detachedPhysicsUpdate, Math.round(getPhysicsSpace().getAccuracy() * 1000000.0f) - (update * 1000), TimeUnit.MICROSECONDS); return true; } };
@Override public void simpleInitApp() { bulletAppState = new BulletAppState(); bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL); stateManager.attach(bulletAppState); bulletAppState.getPhysicsSpace().setAccuracy(1f/30f); rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", EnvMapType.CubeMap));
@Override public void simpleInitApp() { bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); // bulletAppState.getPhysicsSpace().enableDebug(assetManager); cam.setFrustumFar(150f); flyCam.setMoveSpeed(10); setupKeys(); PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace()); // setupFloor(); buildPlayer(); DirectionalLight dl = new DirectionalLight(); dl.setDirection(new Vector3f(-0.5f, -1f, -0.3f).normalizeLocal()); rootNode.addLight(dl); dl = new DirectionalLight(); dl.setDirection(new Vector3f(0.5f, -0.1f, 0.3f).normalizeLocal()); // rootNode.addLight(dl); }
@Override public void simpleInitApp() { bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); bulletAppState.setDebugEnabled(true); setupKeys(); setupJoint(); }
private void initData() { getRootNode(); physicsState = new BulletAppState(); physicsState.startPhysics(); physicsState.getPhysicsSpace().setGravity(Vector3f.ZERO); //horizon physicsState.getPhysicsSpace().add(new RigidBodyControl(poiHorizonCollisionShape, 0)); int hashCode = inParentPosition.hashCode(); Vector3f[] positions = getPositions(poiCount, hashCode); for (int i = 0; i < positions.length; i++) { Vector3f vector3f = positions[i]; Geometry poiGeom = new Geometry("poi", poiMesh); poiGeom.setLocalTranslation(vector3f); poiGeom.setMaterial(poiMaterial); RigidBodyControl control = new RigidBodyControl(poiCollisionShape, 0); //!!! Important control.setApplyPhysicsLocal(true); poiGeom.addControl(control); physicsState.getPhysicsSpace().add(poiGeom); rootNode.attachChild(poiGeom); } //add balls after so first 10 geoms == locations for (int i = 0; i < positions.length; i++) { Vector3f vector3f = positions[i]; Geometry ball = getRandomBall(vector3f); physicsState.getPhysicsSpace().add(ball); rootNode.attachChild(ball); } }
protected void createPhysicsEngineAndAttachItToScene() { bulletAppState = new BulletAppState(); // physics engine based in jbullet bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL); bulletAppState.setEnabled(true); stateManager.attach(bulletAppState); //bulletAppState.getPhysicsSpace().setAccuracy(1 / 200f); if(physicsDebugging) { bulletAppState.getPhysicsSpace().enableDebug(assetManager); } // to show the collision wireframes }
new Quaternion(0.005797257f, 0.91812664f, -0.39601657f, 0.013443171f)); BulletAppState bulletAppState = new BulletAppState(); bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL); stateManager.attach(bulletAppState); bulletAppState.getPhysicsSpace().setAccuracy(1 / 60f); bulletAppState.setDebugEnabled(true);
@Override public void simpleInitApp() { flyCam.setEnabled(false); BulletAppState bulletAppState = new BulletAppState(); bulletAppState.setDebugEnabled(true); bulletAppState.setSpeed(0f); stateManager.attach(bulletAppState); PhysicsSpace space = bulletAppState.getPhysicsSpace(); float radius = 1f; CollisionShape sphere = new SphereCollisionShape(radius); CollisionShape box = new BoxCollisionShape(Vector3f.UNIT_XYZ); RigidBodyControl rbc = new RigidBodyControl(box); rbc.setEnabled(false); rbc.setPhysicsSpace(space); rootNode.addControl(rbc); BetterCharacterControl bcc = new BetterCharacterControl(radius, 4f, 1f); bcc.setEnabled(false); bcc.setPhysicsSpace(space); rootNode.addControl(bcc); GhostControl gc = new GhostControl(sphere); gc.setEnabled(false); gc.setPhysicsSpace(space); rootNode.addControl(gc); } }
public void simpleInitApp() { setupKeys(); bulletAppState = new BulletAppState(); bulletAppState.setEnabled(true); stateManager.attach(bulletAppState); PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace()); initWall(2,1,1); setupLight();
/** * Initialize this state prior to its 1st update. Should be invoked only by * a subclass or by the AppStateManager. * * @param stateManager the manager for this state (not null) * @param app the application which owns this state (not null) */ public void initialize(AppStateManager stateManager, Application app) { this.app = app; this.stateManager = stateManager; startPhysics(); }
@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 bulletAppState = new BulletAppState(); stateManager.attach(bulletAppState); String sinbadPath = "Models/Sinbad/SinbadOldAnim.j3o";
public Boolean call() throws Exception { pSpace.update(tpf * getSpeed()); return true; } };
private void cleanupData() { physicsState.stopPhysics(); //TODO: remove all objects? physicsState = null; rootNode = null; }
/** * Allocate a physics space and start physics. * <p> * Physics starts automatically after the state is attached. To start it * sooner, invoke this method. */ public void startPhysics() { if (initialized) { return; } switch (threadingType) { case PARALLEL: boolean success = startPhysicsOnExecutor(); assert success; assert pSpace != null; break; case SEQUENTIAL: pSpace = new PhysicsSpace(worldMin, worldMax, broadphaseType); pSpace.addTickListener(this); break; default: throw new IllegalStateException(threadingType.toString()); } initialized = true; }
@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); }
@Override public void simpleInitApp() { bulletAppState = new BulletAppState(); bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL); stateManager.attach(bulletAppState); setupKeys(); bulletAppState.getPhysicsSpace().addAll(terrain); sphere.addControl(new RigidBodyControl(new SphereCollisionShape(r), 2)); rootNode.attachChild(sphere); bulletAppState.getPhysicsSpace().add(sphere);