示例#1
0
  void initPhysics() {
    // collision configuration contains default setup for memory, collision
    // setup. Advanced users can create their own configuration.
    CollisionConfiguration collisionConfiguration = new DefaultCollisionConfiguration();

    // use the default collision dispatcher. For parallel processing you
    // can use a diffent dispatcher (see Extras/BulletMultiThreaded)
    CollisionDispatcher dispatcher = new CollisionDispatcher(collisionConfiguration);

    // the maximum size of the collision world. Make sure objects stay
    // within these boundaries
    // Don't make the world AABB size too large, it will harm simulation
    // quality and performance
    Vector3f worldAabbMin = new Vector3f(-100, -100, -100);
    Vector3f worldAabbMax = new Vector3f(100, 100, 100);
    int maxProxies = 1024;
    AxisSweep3 overlappingPairCache = new AxisSweep3(worldAabbMin, worldAabbMax, maxProxies);
    // BroadphaseInterface overlappingPairCache = new SimpleBroadphase(
    //		maxProxies);

    // the default constraint solver. For parallel processing you can use a
    // different solver (see Extras/BulletMultiThreaded)
    SequentialImpulseConstraintSolver solver = new SequentialImpulseConstraintSolver();

    dynamicsWorld =
        new DiscreteDynamicsWorld(dispatcher, overlappingPairCache, solver, collisionConfiguration);

    dynamicsWorld.setGravity(new Vector3f(0, -5, 0));
  }
 public BulletPhysicsRenderer(WorldRenderer parent) {
   _broadphase = new DbvtBroadphase();
   _defaultCollisionConfiguration = new DefaultCollisionConfiguration();
   _dispatcher = new CollisionDispatcher(_defaultCollisionConfiguration);
   _sequentialImpulseConstraintSolver = new SequentialImpulseConstraintSolver();
   _discreteDynamicsWorld =
       new DiscreteDynamicsWorld(
           _dispatcher,
           _broadphase,
           _sequentialImpulseConstraintSolver,
           _defaultCollisionConfiguration);
   _discreteDynamicsWorld.setGravity(new Vector3f(0f, -10f, 0f));
   _parent = parent;
   _blockItemFactory =
       new BlockItemFactory(
           CoreRegistry.get(EntityManager.class), CoreRegistry.get(PrefabManager.class));
   _timer = CoreRegistry.get(Timer.class);
 }