Game Development Reference
In-Depth Information
This class will generate the rigid bodies with specific sizes. Observe that
we have only created a single instance of btCollisionShape and Model
for each basic shape in the init() function. However, they are called in
other functions repeatedly. This is because we only need a single instance of
btCollisionShape and Model to create a rigid body and a model instance.
This helps save memory.
4.
Add the following to MyCollisionWorld.java :
public class MyCollisionWorld extends BulletObjects {
public static final MyCollisionWorld instance = new
MyCollisionWorld();
private MyCollisionWorld() {
super();
}
@Override
public void init() {
super.init();
}
}
Observe that the constructor is private . Hence, this class cannot be called
from other classes. Similarly, the constructors of the base classes are all
protected so that only MyCollisionWorld can call it. However, we have a
static final instance of MyCollisionWorld , which is public. This is to ensure
that only one instance of the dynamics world is available in the game.
5.
Add the following to Items.java :
public enum Items {
GROUND, CONE, BOX, CYLINDER, SPHERE, RAY_PICKING;
}
6.
Add the following to UserData.java :
public class UserData implements Disposable {
public static final Array<UserData> data = new
Array<UserData>();
private static final Vector3 temp = new Vector3();
final ModelInstance instance;
final btMotionState motionState;
final btRigidBody body;
 
Search WWH ::




Custom Search