Game Development Reference
In-Depth Information
const btVector3 &vert1 =
vertices[indices[i]];
const btVector3 &vert2 =
vertices[indices[i+1]];
const btVector3 &vert3 =
vertices[indices[i+2]];
glVertex3f (vert1.x(), vert1.y(),
vert1.z());
glVertex3f (vert2.x(), vert2.y(),
vert2.z());
glVertex3f (vert3.x(), vert3.y(),
vert3.z());
}
glEnd();
DrawBox() creates a closed box object based on the size of the dimensions we
wish to build it from. The input parameter is btVector3 , providing the three dimen-
sions of the box. DrawBox() then uses the concept of indices to iterate through the
number of vertices we want, without having to repeat the data. We could create the
box from 36 different points, but really there are only eight unique points on a box.
Indexes work by labelling each of these eight points with a unique number (index)
from 0 to 7 , and use those to define the triangles, instead. Here is a screenshot of
our box with no lighting applied:
Search WWH ::




Custom Search