What is the proper way to debug draw Bullet physics in libGDX so that I may see the btCollisionObjects
that I am setting up?
So far I have the below, but it doesn't appear that the btCollisionObjects
are appearing.
public void render(float delta) {
debugDrawer.begin(cam);
collisionWorld.debugDrawWorld();
debugDrawer.end();
modelBatch.begin(cam);
...
modelBatch.end();
}
@Override
public void show() {
Bullet.init();
...
collisionConfig = new btDefaultCollisionConfiguration();
dispatcher = new btCollisionDispatcher(collisionConfig);
broadphase = new btDbvtBroadphase();
collisionWorld = new btCollisionWorld(dispatcher, broadphase, collisionConfig);
debugDrawer = new DebugDrawer();
collisionWorld.setDebugDrawer(debugDrawer);
debugDrawer.setDebugMode(btIDebugDraw.DebugDrawModes.DBG_MAX_DEBUG_DRAW_MODE);
}
Create your first libGDX game. React to user input. Show different screens in your game. Use OpenGL to draw your game. Use images in your game. Add music and sound effects. Cross-platform code.
Well Proven libGDX is a well proven and reliable framework with a sound base and documentation. Furthermore, there are plenty of gamesbuilt on top of libGDX, many of which are open source. Active Community Get great support from a very welcoming communityof game and application developers or take a look at our extensive third-party ecosystem.
After you have created your very first libGDX project, we highly recommend our A Simple Game and Extending the Simple Game pages. If you’re completely new to game dev and have never developed a game before, this (even more straight-forward) tutorial by tann is also worth a look as an alternative.
libGDX Jam June 2022 June 1, 2022 With our 21st collaboration, the libGDX Jam continues the time honoured tradition of making awesome games using the best framework out there. We encourage ca... libGDX 1.11.0 May 11, 2022 We are proud to present a new major release of libGDX: version 1.11.0! libGDX Jam March 2022 February 28, 2022
Hopefully this will still help you 3 months after the fact, because your snippets definitely helped me! ;)
I put your code snippets into my app, and was able to get debug drawing working fine.
For the record, I'm using a dynamicsWorld instead, but swapped out code and it works.
dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, constraintSolver, collisionConfig);
The one thing I would suggest is swapping when you draw the models and when you draw the debug. If you put the debug second, it will get drawn last, and thus on top of the models. Otherwise you will experience the debug draw being covered up by the models. Try this instead:
public void render(float delta) {
modelBatch.begin(cam);
...
modelBatch.end();
debugDrawer.begin(cam);
collisionWorld.debugDrawWorld();
debugDrawer.end();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With