// Set the restitution, also known as the bounciness or spring, to 0.25. The restitution may range from 0.0
// not bouncy) to 1.0 (extremely bouncy).
groundBodyConstructionInfo.restitution = 0.25f;
// Initialise 'groundRigidBody', the final variable representing the ground, to a rigid body with the previously
// assigned construction information.
RigidBody groundRigidBody = new RigidBody(groundBodyConstructionInfo);
// Add the ground to the JBullet world.
dynamicsWorld.addRigidBody(groundRigidBody);
// Initialise 'ballMotion' to a motion state that assigns a specified location to the ball.
MotionState ballMotion = new DefaultMotionState(new Transform(DEFAULT_BALL_TRANSFORM));
// Calculate the ball's inertia (resistance to movement) using its mass (2.5 kilograms).
Vector3f ballInertia = new Vector3f(0, 0, 0);
ballShape.calculateLocalInertia(2.5f, ballInertia);
// Composes the ball's construction info of its mass, its motion state, its shape, and its inertia.
RigidBodyConstructionInfo ballConstructionInfo = new RigidBodyConstructionInfo(2.5f, ballMotion, ballShape, ballInertia);
// Set the restitution, also known as the bounciness or spring, to 0.5. The restitution may range from 0.0
// not bouncy) to 1.0 (extremely bouncy).
ballConstructionInfo.restitution = 0.5f;
ballConstructionInfo.angularDamping = 0.95f;
// Initialise 'controlBall', the final variable representing the controlled ball, to a rigid body with the
// previously assigned construction information.
controlBall = new RigidBody(ballConstructionInfo);
// Disable 'sleeping' for the controllable ball.
controlBall.setActivationState(CollisionObject.DISABLE_DEACTIVATION);
// Add the control ball to the set of balls (more may be added by pressing 'g').
balls.add(controlBall);
// Add the control ball to the JBullet world.