Here's the basic steps you'll need to folow:
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).
And take some time to read the manual as it has a lot of information too.
Edit to address comment
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).
For starters I quote the manual which already explains what you need:
- #include “btBulletDynamicsCommon.h” in your source file
- Required include path: Bullet/src folder
- Required libraries: BulletDynamics, BulletCollision, LinearMath
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.
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
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,
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:
After this you should be able to build and run your project.