I downloaded the release file found here, but I'm just not sure where to start. In my game I have a number of oblongs and a sphere, I want all of these to collide with one another. (They all have meshes and associated bounding volumes)

edit - I just realised the cuboids actually have AABB's associated with them. I guess I'll have to change that at least.

did you take a look into the manual under chapter 4.4 Integration overview I know it's very spartan but it does describe the basic process. So if you look at that and the code for the example Demos then you shouldn't have too many problems.
–
PeterTFeb 4 '12 at 9:26

Also check the examples in the bullet folder, there are a bunch of 'em
–
Maik SemderFeb 4 '12 at 12:38

@MaikSemder I wasn't quite sure how to open specific ones. are make files linux only?
–
Asher EinhornFeb 4 '12 at 13:13

actually notes on how to open the examples would be incredibly helpful, then I could just see how they've linked things together there. I will google around for this but I thought I should ask while I can.
–
Asher EinhornFeb 4 '12 at 13:18

That depends on what platform you are. For visual studio on windows there is an .sln file for the examples, i assume that is what you use. Just search for the sln file in the bullet folder.
–
Maik SemderFeb 5 '12 at 2:26

1 Answer
1

First create a world object (i.e. btDiscreteDynamicsWorld) to drive your physics simulation.

You should already have a class such as GameObject that perhaps stores a model along with its bounding box and position/orientation in the world. Replace the position/orientation information with an instance of a physics body object (i.e. btRigidBody) and when rendering the model, use the information provided by the body instead. When creating the body you'll need to provide its mass and collision shape which should match the bounding volumes you already have. I've talked about this in your other question too.

Add each of your game object's bodies to the world object.

Update the simulation by stepping the world (i.e. calling stepSimulation on your world).

I cringe before I ask but... how do I do the very very basic stuff like simply including the right files in my game? If you need specifics I'm looking for the files that will deal with rigid body collisions. Also thank you very much for the help so far!

Well, it would appear from your comment that you've never worked with external C++ libraries before. It's been a while since I did this, but this is how I remember the process to be (in Visual Studio).

And here's the basic steps you will have to follow to fulfill the conditions above...

1. Preparation Step

First of all, extract the file you downloaded into a known directory, e.g. C:\Bullet. You'll need to know the path to this folder later.

Inside there are two folders that you will need to reference in your project. The first is the src folder which holds the .h header files that you will include in your source code. The second is the lib folder which will hold the .lib library files that you will link to your project. Notice that including and linking are two different things.

But the lib folder should be empty for now, because you haven't built the engine yet. So refer to the manual on how to build the project using CMake and Visual Studio for instance. It's on page 7.

After you succeed, you should have at least three files in the libfolder: BulletDynamics.lib, BulletCollision.lib and LinearMath.lib (I am guessing from the manual). Now to make the connection between Bullet and your project...

2. Include Headers

First of all, you'll need to add the C:\Bullet\src folder to your project's include path options. You can do so in Visual Studio by right-clicking on your project, navigating to Configuration Properties -> C/C++ -> General -> Additional Include Directories and writing the directory path in there.

After setting that up, you can simply do #include “btBulletDynamicsCommon.h” on your code. That header seems to serve as an hub to all features you require.

3. Link Libraries

Finally you'll need to link the libraries mentioned above. Frist, under Configuration Properties -> Linker -> General -> Additional Library Directories add the path to the lib folder, or in other words, C:\Bullet\lib.

Then, under Configuration Properties -> Linker -> Input-> Additional Dependencies, add the name of the libraries to the list of dependencies. Separate each library with a ; and don't forget the file extension. So for instance, you might add this to the end of the list: BulletDynamics.lib;BulletCollision.lib;LinearMath.lib.

I cringe before I ask but... how do I do the very very basic stuff like simply including the right files in my game? If you need specifics I'm looking for the files that will deal with rigid body collisions. Also thank you very much for the help so far!
–
Asher EinhornFeb 4 '12 at 13:14

@AsherEinhorn No problem, this did stumble me too the first time I worked with C++ libraries a couple of years ago.
–
David GouveiaFeb 4 '12 at 14:00

Yeah, it's one of those things I've just kind of avoided up until now, all the code in my games is mine, but trying to write my own physics engine is just a waste of time when other people have done them better than I probably ever will.
–
Asher EinhornFeb 4 '12 at 14:02