Author Topic: DebugDraw For Box2D  (Read 9262 times)

mitch

  • Guest
DebugDraw For Box2D
« on: June 18, 2012, 09:31:20 am »
Debug Draw in Box2D is a special feature that draws all the bodies in the physics world on the screen for debugging purposes.  It is helpful because sometimes you can't tell if your image is in the wrong location or your physics body is in the wrong location.  To use Debug Draw you have to write your own class that handles the drawing, which is what I have done.

All the code is available at https://github.com/mitch8/DragonFire-DebugDraw with an example to help you get started.

-Mitch

nednones

  • Guest
Re: DebugDraw For Box2D
« Reply #1 on: June 18, 2012, 10:13:38 am »
Awesome! Nice code Mitch!

DeadSn0wMan

  • Guest
Re: DebugDraw For Box2D
« Reply #2 on: August 03, 2012, 03:11:28 pm »
If this works I can't thank you enough....

JB

  • Guest
Re: DebugDraw For Box2D
« Reply #3 on: August 05, 2012, 01:42:38 pm »
Can anybody get this working? I put all the files in a project provided by mitch to try it out but get errors in the following section:

Code: [Select]
// setup DebugDraw
m_world->SetDebugDraw(&m_debugDraw);
m_debugDraw.SetFlags(b2Draw::e_shapeBit + b2Draw::e_jointBit);

Error: Argument of type "DebugDraw" is incompatible with parameter of type "b2DebugDraw*"
"Debug draw has no member "SetFlags"

ajaypatel

  • Guest
Re: DebugDraw For Box2D
« Reply #4 on: August 09, 2012, 12:17:43 pm »
hi mitch thanx for the code but sorry this is my error i got...,
c:\dragonfiresdk\samples\box2d draw\render.h(7) : error C2504: 'b2Draw' : base class undefined
how do i short it out....?
thanx again
mr patel

mitch

  • Guest
Re: DebugDraw For Box2D
« Reply #5 on: August 24, 2012, 12:44:40 pm »
Hi,

Sorry about the late reply, I didn't get a notification about this.  I have not come across either of those errors so I'm not quite sure what the problem is.

@ JB - do you have "DebugDraw m_debugDraw;" at the top of you code and both Render.cpp and Render.h set to build?  You'll have to drag and drop the files into the Solution Explorer otherwise they will not be included in the project so they won't build.

@ ajaypatel - same advice, make sure that you drag and drop all of the files into the solution explorer.  Same with the Box2D files, I use DragonFireSDK version 1 that did not come with Box2D,  so I had to manually drag and drop the files from http://www.box2d.org/ into the solution explorer.   Because of this I also use a newer version of Box2D.  The current version is 2.2.1 but I think DragonFireSDK comes with 2.1.2,  so there could be some small differences that cause it not to build.

ajaypatel

  • Guest
Re: DebugDraw For Box2D
« Reply #6 on: August 27, 2012, 01:39:09 pm »
thanx for reply mitch.....,
sorry to say my jumpbox2d is working fine....& even i used box2d on different place & it's working fine but the error i discribed & jb discribed is still there.....please help me becuase i m working individually on massive project & if i got box2d in my project with all debug draw function it will be great for my project....,
thanx in advance mitch...
ajay patel

mitch

  • Guest
Re: DebugDraw For Box2D
« Reply #7 on: August 27, 2012, 03:57:58 pm »
Your right, there would be link errors not compile errors if you didn't have the files imported correctly.  The code is incompatible with version 2.1.2.  However, I just updated the code, it was an easy fix, Box2D names stuff differently in the new version.

Download the new code from https://github.com/mitch8/DragonFire-DebugDraw and add "V212" to your preprocessor definitions to let the code know you are using an older version.

glina126

  • Guest
Re: DebugDraw For Box2D
« Reply #8 on: October 23, 2012, 06:53:13 am »
hah nice! this is is exactly what i was trying to reproduce since last night. But you did a much better job. Im stuck at rotating objects atm. Thanks for the beautiful code!

tlawork

  • Guest
Re: DebugDraw For Box2D
« Reply #9 on: June 04, 2014, 07:57:36 pm »
at risk of resurrecting old topic - this topic is so important it should be pinned.....

TODDL
« Last Edit: June 05, 2014, 08:23:49 am by tlawork »