Game Development Reference
In-Depth Information
world.addRigidBody(body);
}
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);
world.stepSimulation(Gdx.graphics.getDeltaTime(), 5);
sphereMotionState.getWorldTransform(sphereInstance.transform);
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();
for (btRigidBody body : bodies) {
body.dispose();
}
sphereMotionState.dispose();
for (btCollisionShape shape : shapes)
shape.dispose();
for (btRigidBodyConstructionInfo info : bodyInfos)
info.dispose();
world.dispose();
collisionConfiguration.dispose();
dispatcher.dispose();
broadphase.dispose();
solver.dispose();
Gdx.app.log(this.getClass().getName(), "Disposed");
}
}
The highlighted parts are the addition to our previous code. After execution, we see
the ball falling and colliding with the ground.
 
Search WWH ::




Custom Search