Visualization using the SPORT graphics engine

The HelloLibbulletjme app (introduced on the previous page) is simple, readable and complete. However, as a console app, its output is limited to text.

Text provides scant insight into what the physics simulation is doing. For most people, pictures are much easier to understand.

For the purpose of this tutorial series, we’ve created a graphics engine named SPORT (the Simple Physics-ORienTed engine). SPORT enables us to visualize physics objects without adding much code to the tutorial apps. It is open-source, written in Java, and available from GitHub and Maven Central.

HelloSport

HelloSport (also in Kotlin) is a direct conversion of HelloLibbulletjme into a SPORT app.

Details to note:

  1. The app is declared as a subclass of BasePhysicsApp<PhysicsSpace>, indicating that it will simulate a plain PhysicsSpace.

  2. The app implements the 3 abstract methods of BasePhysicsApp (createSpace, populateSpace, and updateSpace), which are all invoked automatically.

  3. BasePhysicsApp automatically loads the Libbulletjme native library.

  4. BasePhysicsApp provides:

    1. the physicsSpace field to access the space and

    2. the visualizeShape() method to visualize the shape of a collision object.

  5. Whereas HelloLibbulletjme used update(intervalSeconds, 0) to simulate one step at a time, HelloSport attempts real-time simulation using update(intervalSeconds).

Running HelloSport should open a window on your computer’s desktop and play a brief animation of a sphere falling onto a horizontal surface.

Pressing Esc should close the window and terminate the app.

Hereafter, all our tutorial apps will use SPORT. Additional features of SPORT will be introduced as needed.

Summary

  • SPORT is a graphics engine, created specifically for Libbulletjme tutorials.

  • SPORT provides a simple toolkit for visualizing 3-D physics.