Examples and tutorials » Bullet Physics

Integration of Bullet Physics into Magnum.

Image

A rotating table full of cubes that you can shoot down, showcasing the BulletIntegration library together with SceneGraph using BulletIntegration::MotionState, visualizing various properties of the Bullet physics world using BulletIntegration::DebugDraw. Everything is rendered in at most three draw calls using instanced Shaders::PhongGL.

Key controls

  • Arrow keys rotate the camera around
  • mouse click shoots an object
  • S toggles between a box (larger, lighter) or a sphere (smaller but heavier) to shoot
  • D toggles draw mode (solid + wireframe debug overlay, just solid or just wireframe debug)

Credits

This example was originally contributed by Jan Dupal and further improved by Max Schwarz. The example makes use of the Bullet Physics library, see documentation of the BulletIntegration namespace for license information.

Source

Full source code is linked below and also available in the magnum-examples GitHub repository. This example depends on the BulletIntegration library which is not a part of the core Magnum repository, see its documentation for usage instructions.

The ports branch contains additional patches for Emscripten support that aren't present in master in order to keep the example code as simple as possible.