Game Development Reference
In-Depth Information
walker. Because the pole is very long, it resists rotation allowing them to use it to
maintain balance.
We have a special case built in to this function. If we define the mass to be zero,
we also set the local inertia to (0,0,0) . This will prevent the object from rotating as
a result of collisions. In addition, Bullet uses a mass of zero to imply that you really
want it to have an infinite mass, and hence don't want the object to move as result of
forces like gravity. This is useful for environmental objects that don't move, such as
a ground planes walls, and so on.
The center of mass ( COM ) of an object is an important property in Newtonian phys-
ics and it's just as important in physics simulations. Bullet will assume that the rigid
body's COM is equal to its world position, unless told otherwise. Shifting the COM to
some other location can be achieved through the usage of compound shapes, which
will be explored more in Chapter 7 , Collision Shapes .
Rendering our objects
We also need a more universal system to render our objects: one that chooses a
different rendering function based on the type of object being rendered. The source
code for this chapter now features a new DrawShape() function, which accepts a
btCollisionShape pointer of any derived type, determines which type of shape
it is using some of Bullet's internal enumerators, and then renders the appropriate
shape.
Note
Since DrawBox() only covers boxes for now, we will be returning to this function
later to expand on the additional shapes we introduce.
This change requires us to move the coloring and positioning of our objects (the
glColor3f() , glPushMatrix() , and glPopMatrix() calls) out of DrawBox()
and into DrawShape() , to spare us from duplicating the same instructions each time
we render.
Search WWH ::




Custom Search