How to use Bullet Physics engine in Vrui applications

Bullet is an open source physics engine featuring 3D collision detection and dynamics. It has been adopted in game engines like Ogre3D so it would be great to embed Bullet in an Vrui application for immersive environments as well. This post shows you one simple way to make a Bullet Demo program work in Vrui.

There are a bunch of demo programs in Demos folder of Bullet. We will convert DynamicControlDemo into a Vrui application. The chart below shows the inheritance stack of a Bullet demo application and Vrui application. The subtle issue here is Bullet demo programs use GLUT to render window (OpenGL context…) and handle the camera (gluLookAt..) while these functionalities are provided by Vrui as well. So after putting DynamicControlDemo code in a Vrui application, we need to get rid of the unnecessary GLUT code.


Bullet and Vrui application stacks

The structure of our final Vrui application would be:

Structure of our final Vrui application

Structure of our final Vrui application

I’m using the latest Bullet 2.82 and Vrui 3.001 for this demo. I create a new Vrui application in the ExamplePrograms folder of Vrui, and this is the source code of the final Vrui application including the makefile. You just need to drop this off in your src/Vrui3.0/ExamplePrograms/ and compile the folder with “make”. And boom, if you run the BulletDemo executable in ./bin/ folder, you would see the Vrui app running:

Bullet robots in Vrui application

Bullet robots in Vrui application

Because we are not using GLUT in the code, there are several things to note:

  • glutSwapBuffers function is commented out
  • glutScreenWidth and glutScreenHeight are initialized with values from Vrui::VRScreen
  • Use of const_cast in void BulletDemo::display(GLContextData& contextData) const because some  functions of DemoApplication being called are not const.

Finally, since Vrui handles keyboard and mouse by their Tools concept, you will have to create new Tools to recover  the functionality of mouse/keyboard in the original Bullet demo app.

For my project, after embedding Bullet in Vrui successfully, I created a model of CyberGloves in Bullet, yayy!! now I can grasp objects in a virtual world !

Right hand hovering about to grab objects

Right hand hovering about to grab objects


, , , ,

  • Pingback: 3DTouch: A modular wearable 3D input device | Anh Nguyen()

  • Pearlene

    I read a lot of interesting posts here. Probably you spend a lot of time writing, i know how to save
    you a lot of work, there is an online tool that creates readable, SEO friendly posts
    in seconds, just type in google – laranitas free content

  • Nikhil

    Hey Anh,

    I got this to compile. However I wanted to point out that your inheritance diagrams are upside down :). I am hoping they are not inheritance diagrams but they definitely look like that.


    • Hehe, thanks Nikhil. Wondering what cool demo would this enable in the CAVE. :)

      PS: Yes, great point. The diagrams are upside down now that I’m looking at them…

  • M