// the maximum size of the collision world. Make sure objects stay
// within these boundaries
// TODO: AxisSweep3
// Don't make the world AABB size too large, it will harm simulation
// quality and performance
Vector3f worldAabbMin = new Vector3f(-100000, -100000, -100000);
Vector3f worldAabbMax = new Vector3f(100000, 100000, 100000);
overlappingPairCache = new AxisSweep3(worldAabbMin, worldAabbMax);
//overlappingPairCache = new AxisSweep3(worldAabbMin, worldAabbMax,
// MAX_PROXIES);
// overlappingPairCache = new SimpleBroadphase(MAX_PROXIES);
// the default constraint solver. For parallel processing you can use a
// different solver (see Extras/BulletMultiThreaded)
SequentialImpulseConstraintSolver sol = new SequentialImpulseConstraintSolver();
solver = sol;
// TODO: needed for SimpleDynamicsWorld
// sol.setSolverMode(sol.getSolverMode() &
// ~SolverMode.SOLVER_CACHE_FRIENDLY.getMask());
myWorld = new DiscreteDynamicsWorld(dispatcher, overlappingPairCache,
solver, collisionConfiguration);
// dynamicsWorld = new SimpleDynamicsWorld(dispatcher,
// overlappingPairCache, solver, collisionConfiguration);
myWorld.setGravity(new Vector3f(0f, 3, 0f));
// create a few basic rigid bodies
// CollisionShape groundShape = new BoxShape(new Vector3f(50f, 50f,
// 50f));
CollisionShape groundShape = new StaticPlaneShape(
new Vector3f(0, -1, 0), 1);
collisionShapes.add(groundShape);
Transform groundTransform = new Transform();
groundTransform.setIdentity();
groundTransform.origin.set(this.scaleVal(600), this.scaleVal(1600),
this.scaleVal(600));
CollisionShape constrainPlane = new StaticPlaneShape(new Vector3f(0, 0,
1), 1);
Vector3f localInertia2 = new Vector3f(0, 0, 0);
Transform planeTransform = new Transform();
planeTransform.setIdentity();
planeTransform.origin.set(this.scaleVal(600), this.scaleVal(600),
this.scaleVal(0));
// using motionstate is recommended, it provides interpolation
// capabilities, and only synchronizes 'active' objects
DefaultMotionState myMotionState2 = new DefaultMotionState(
planeTransform);
RigidBodyConstructionInfo rbInfo2 = new RigidBodyConstructionInfo(0,
myMotionState2, constrainPlane, localInertia2);
RigidBody body2 = new RigidBody(rbInfo2);
this.constrainPlane2D = body2;
// We can also use DemoApplication::localCreateRigidBody, but for
// clarity it is provided here:
{
float mass = 0f;
// rigidbody is dynamic if and only if mass is non zero, otherwise
// static
boolean isDynamic = (mass != 0f);
Vector3f localInertia = new Vector3f(0, 0, 0);
if (isDynamic) {
groundShape.calculateLocalInertia(mass, localInertia);
}
// using motionstate is recommended, it provides interpolation