CollisionShape groundShape = new StaticPlaneShape(new Vector3f(0, 1, 0), 0.25f);
// Initialise 'ballShape' to a sphere with a radius of 3 metres.
CollisionShape ballShape = new SphereShape(3);
// Initialise 'groundMotionState' to a motion state that simply assigns the origin [0, 0, 0] as the origin of
// the ground.
MotionState groundMotionState = new DefaultMotionState(new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(0, 0, 0), 1.0f)));
// Initialise 'groundBodyConstructionInfo' to a value that contains the mass, the motion state, the shape, and the inertia (= resistance to change).
RigidBodyConstructionInfo groundBodyConstructionInfo = new RigidBodyConstructionInfo(0, groundMotionState, groundShape, new Vector3f(0, 0, 0));
// 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.
// 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);
// 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);