Game Development Reference
In-Depth Information
models.add(sphereModel);
sphereInstance = new ModelInstance(sphereModel);
sphereinstance.transform.trn(0, 10, 0);
}
public void render() {
Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.
getHeight());
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT |
GL20.GL_DEPTH_BUFFER_BIT);
modelBatch.begin(cam);
modelBatch.render(groundInstance, environment);
modelBatch.render(sphereInstance, environment);
modelBatch.end();
}
@Override
public void dispose() {
modelBatch.dispose();
for (Model model : models)
model.dispose();
}
}
The ground is actually a thin box created using ModelBuilder just like the sphere.
Now that we have created a simple 3D scene, let's add some physics using the
following code:
public class MyCollisionTest extends ApplicationAdapter {
...
private btDefaultCollisionConfiguration collisionConfiguration;
private btCollisionDispatcher dispatcher;
private btDbvtBroadphase broadphase;
private btSequentialImpulseConstraintSolver solver;
private btDiscreteDynamicsWorld world;
private Array<btCollisionShape> shapes = new
Array<btCollisionShape>();
private Array<btRigidBodyConstructionInfo> bodyInfos = new
Array<btRigidBody.btRigidBodyConstructionInfo>();
 
Search WWH ::




Custom Search