Debug Drawing Help

Killcam
Posts: 11
Joined: Tue Nov 09, 2010 7:03 pm

Debug Drawing Help

Post by Killcam »

Is there any example of bullet debug drawing, or could somebody explain me what exactly the manual means?

I have tried to understand the way it works from the examples but I do not seem to be able to create my own code on this.
jstolarz
Posts: 14
Joined: Thu Dec 09, 2010 9:32 pm
Location: Glendale, California

Re: Debug Drawing Help

Post by jstolarz »

For examples, in the demo code, look at Demos/OpenGL/GLDebugDrawer.h/.cpp.
Essentially, you need to build a class the inherits from btIDebugDraw (http://www.continuousphysics.com/Bullet ... gDraw.html). Then you need to implement a few of the virtual functions:
setDebugMode
getDebugMode
reportErrorWarning
draw3dText
drawLine
drawContactPoint

In my case, some of these (like draw3dText) are just stubs for now.

Once that's done, just register it with your collision/dynamics world:

Code: Select all

world->setDebugDrawer(&yourDebugDrawClass)
and call

Code: Select all

world->debugDrawWorld()
once you've made a collision/dynamics step.
Killcam
Posts: 11
Joined: Tue Nov 09, 2010 7:03 pm

Re: Debug Drawing Help

Post by Killcam »

Thank you, I'll try as soon as I have some time.
Killcam
Posts: 11
Joined: Tue Nov 09, 2010 7:03 pm

Re: Debug Drawing Help

Post by Killcam »

Sorry for double-posting, but I would like to ask one more thing. Should I be able to use the "public btIDebugDraw" as a default one instead of building a new one?
jstolarz
Posts: 14
Joined: Thu Dec 09, 2010 9:32 pm
Location: Glendale, California

Re: Debug Drawing Help

Post by jstolarz »

Nope, because it has the above mentioned virtual functions that you must define. Bullet has no knowledge of how you'd like to render things out, or where to do it. Oh I should mention that in the above post I forgot about the calls to setDebugMode() that you'll want to make in order to decide what to display.