Game Development Reference
In-Depth Information
Creating our first physics object
Bullet maintains the same modular design of its core components even down to indi-
vidual physics objects. This allows us to customize physics objects through their com-
ponents by interchanging or replacing them at will.
Three components are necessary to build a physics object in Bullet:
• A collision shape , defining the object's volume and how it should respond to
the collisions with other collision shapes
• A motion state , which keeps track of the motion of the object
• A collision object , which acts as a master controller of the object, managing
the previously mentioned components and the physical properties of the ob-
ject
We'll cover some essential theory on these components before we build one in code.
We'll also make some changes to our rendering system so that we can observe the
effects of gravity on our object.
Note
Continue
from
here
using
the
Chapter3.2_CreatingOurFirstPhysicsObject project files.
The collision shape
The collision shape represents the volume of an object in space, be it a box, a sphere,
a cylinder, or some other more complex shape. Collision shapes do not care about the
rules of the world. They only care about how they should interact with other shapes,
and so it is the collision shape's responsibility to inform Bullet what kind of shape it is,
so that it can respond appropriately.
We will cover more varieties and intricacies of collision shapes in Chapter 7 , Collision
Shapes , but for now we will build a simple collision shape component using
btBoxShape . This object's only requirement is to define its size upon creation.
Search WWH ::




Custom Search