Game Development Reference
In-Depth Information
@Override
public void update(float delta) {
world.stepSimulation(delta, 5 , 1/60f);
}
@Override
public void dispose() {
world.dispose();
collisionConfiguration.dispose();
dispatcher.dispose();
broadphase.dispose();
solver.dispose();
}
@Override
public btDiscreteDynamicsWorld getWorld() {
return world ;
}
@Override
public void remove(btRigidBody body) {
world.removeRigidBody(body);
((UserData) body.userData).dispose();
}
}
As you can see, BulletWorld implements MyBulletInterface . Here, Bullet
is initiated and the dynamics world is created by providing the properties of
the dynamics world. The update() function will step the dynamics world
and remove() will remove and dispose of the given rigid body from the
dynamics world.
Also, observe that while disposing, the btDiscreteDynamicsWorld parameter
is disposed before all other world parameters such as dispatcher and
broadphase . Otherwise, you will get a runtime exception while disposing
of the following files:
3.
Add the following to BulletObjects.java :
public class BulletObjects extends BulletWorld {
private static final Vector3 temp = new Vector3();
private static final Vector3 localIneria = new Vector3(1,
1, 1);
private btCollisionShape boxShape, coneShape, sphereShape,
cylinderShape, groundShape;
private Model boxModel, coneModel, sphereModel,
cylinderModel, groundModel;
 
Search WWH ::




Custom Search