debugging - libGDX 中的调试绘图

标签 debugging libgdx bulletphysics

在 libGDX 中调试 draw Bullet 物理的正确方法是什么,以便我可以看到 btCollisionObjects我正在设置?

到目前为止,我有以下内容,但似乎没有 btCollisionObjects正在出现。

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);
}

最佳答案

希望这在事后 3 个月后仍能对您有所帮助,因为您的片段肯定对我有帮助! ;)

我将您的代码片段放入我的应用程序中,并且能够使调试绘图正常工作。

作为记录,我使用的是 dynamicsWorld,但换掉了代码并且它可以工作。

dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher, broadphase, constraintSolver, collisionConfig);

我建议的一件事是在绘制模型和绘制调试时进行交换。如果您将调试放在第二位,它将最后绘制,因此位于模型之上。否则,您将体验到被模型掩盖的调试绘图。试试这个:

public void render(float delta) {

    modelBatch.begin(cam);
    ...
    modelBatch.end();

    debugDrawer.begin(cam);
    collisionWorld.debugDrawWorld();
    debugDrawer.end();
}

关于debugging - libGDX 中的调试绘图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23798844/

相关文章:

c# - API函数不一致404错误

android - 如何使用 libgdx 创建 Android UI 元素

java - 浮点变量在没有明确归属的情况下被更改

c++ - Bullet物理引擎静态库安装问题

bullet - 有没有人有关于如何使用 Bullet Physics/jBullet 进行 voronoi 粉碎的示例/教程?

java - 如何在 IntelliJ 中从 jar 反编译的类中设置断点以进行远程调试

c++ - 在 Visual Studio 中调试时,我可以将一些 C/C++ 结构内容保存到磁盘吗?

c - 调试宏奇怪的行为

ios - 将 ipa 提交到 App Store 时出错

c++ - 很少的刚体导致子弹物理缓慢