Game Development Reference
In-Depth Information
from.getZ());
glVertex3f(to.getX(), to.getY(), to.getZ());
glEnd();
}
The DebugDrawer class must be handed over to the world object through a call
to setDebugDrawer() . In each render call, we will ask the world object to render
the debug information through a call to debugDrawWorld() . This will cause the
world to determine what needs to be rendered, based on which debug flags are set
in m_debugFlags , and leave the actual rendering to our DebugDrawer class. Note
that the only reason it can accept and use it is because it was derived from the
btIDebugDraw interface class. If this seems confusing, it's worth brushing up on
the concepts of Polymorphism .
The following is a snippet from the Keyboard() function, which allows us to change
a single debug flag. These flags must come from Bullet's own internal enumerator of
values, since it uses this to decide what to render for us.
case 'w':
// toggle wireframe debug drawing
m_pDebugDrawer->ToggleDebugFlag(btIDebugDraw::DBG_DrawWireframe);
break;
Now our application can render debug lines and AABB volumes through a press of
W or B , respectively. The following screenshot shows the application with debug ren-
dering enabled:
Search WWH ::




Custom Search