Game Development Reference
In-Depth Information
private Array<btRigidBody> bodies = new Array<btRigidBody>();
private btDefaultMotionState sphereMotionState;
@Override
public void create() {
...
// Initiating Bullet Physics
Bullet.init();
//setting up the world
collisionConfiguration = new btDefaultCollisionConfiguration();
dispatcher = new btCollisionDispatcher(collisionConfiguration);
broadphase = new btDbvtBroadphase();
solver = new btSequentialImpulseConstraintSolver();
world = new btDiscreteDynamicsWorld(dispatcher, broadphase,
solver, collisionConfiguration);
world.setGravity(new Vector3(0, -9.81f, 1f));
// creating ground body
btCollisionShape groundshape = new btBoxShape(new Vector3(20, 1 /
2f, 20));
shapes.add(groundshape);
btRigidBodyConstructionInfo bodyInfo = new
btRigidBodyConstructionInfo(0, null, groundshape, Vector3.Zero);
this.bodyInfos.add(bodyInfo);
btRigidBody body = new btRigidBody(bodyInfo);
bodies.add(body);
world.addRigidBody(body);
// creating sphere body
sphereMotionState = new
btDefaultMotionState(sphereInstance.transform);
sphereMotionState.setWorldTransform(sphereInstance.transform);
final btCollisionShape sphereShape = new btSphereShape(1f);
shapes.add(sphereShape);
bodyInfo = new btRigidBodyConstructionInfo(1, sphereMotionState,
sphereShape, new Vector3(1, 1, 1));
this.bodyInfos.add(bodyInfo);
body = new btRigidBody(bodyInfo);
bodies.add(body);
 
Search WWH ::




Custom Search