【问题标题】:Bullet debug drawer with OpenGL带有 OpenGL 的 Bullet 调试抽屉
【发布时间】:2013-11-27 10:06:16
【问题描述】:

我一直在摆弄项目符号,现在我想绘制调试。 我有一个 opengl 世界,里面有可用的子弹物理和一切。

我尝试过的是: 我创建了一个这样的类 GLDebugDrawer:

#include "LinearMath/btIDebugDraw.h"

class GLDebugDrawer : public btIDebugDraw
{
   int m_debugMode;

public:

   GLDebugDrawer();
   virtual ~GLDebugDrawer();

   virtual void   drawLine(const btVector3& from, const btVector3& to, const btVector3& fromColor, const btVector3& toColor);

   virtual void   drawLine(const btVector3& from, const btVector3& to, const btVector3& color);

   virtual void   drawSphere(const btVector3& p, btScalar radius, const btVector3& color);

   virtual void   drawTriangle(const btVector3& a, const btVector3& b, const btVector3& c, const btVector3& color, btScalar alpha);

   virtual void   drawContactPoint(const btVector3& PointOnB, const btVector3& normalOnB, btScalar distance, int lifeTime, const btVector3& color);

   virtual void   reportErrorWarning(const char* warningString);

   virtual void   draw3dText(const btVector3& location, const char* textString);

   virtual void   setDebugMode(int debugMode);

   virtual int      getDebugMode() const { return m_debugMode; }

};

然后在游戏中我包含这个标题并创建它的一个实例。

在初始化 bt 世界的地方,我将调试绘制类型设置如下:

debugDraw->DBG_DrawWireframe; // this breaks when I run the app
debugDraw->setDebugMode(btIDebugDraw::DBG_DrawWireframe); // so does this
debugDraw->setDebugMode(1); // this doesn't

然后我将调试设置为这样的子弹世界:

bt_dynamicsWorld->setDebugDrawer(debugDraw);

最后,我在渲染子弹体后渲染调试图,如下所示:

bt_dynamicsWorld->debugDrawWorld();

一定有什么我错过了,因为我在运行时没有得到任何线框或任何东西。

【问题讨论】:

  • 我知道这是一条旧消息,但是当我搜索时它弹出到顶部。您是否碰巧在您的 GLDebugDrawer 类中实际实现了这些方法中的任何一个?

标签: c++ visual-studio debugging opengl bullet


【解决方案1】:

http://sio2interactive.forumotion.net/t599-enabling-bullet-debug-draw-code-included 提供了一组简单的代码,用于修改代码应该相对简单,看起来您可能需要将 bt_dynamicsWorld->setDebugDrawer(debugDraw); 更改为 bt_dynamicsWorld->setDebugDrawer(&debugDraw);(虽然不确定,但不知道)您如何设置框架。

【讨论】:

  • 你好。谢谢回复。我看过那篇文章并关注了它,但我仍然没有得到任何东西。如果我这样做bt_dynamicsWorld->setDebugDrawer(&debugDraw); 我会得到这个:cannot convert argument 1 from 'GLDebugDrawer **' to 'btIDebugDraw *'
【解决方案2】:

首先,您必须将实例化类的引用传递给 setDebugDrawer 函数,如下所示:

GLDebugDrawer MyDrawer;
...
bt_dynamicsWorld->setDebugDrawer(&MyDrawer);

其次,同样重要的是,您必须定义在 GLDebugDrawer 类中布置的虚函数,以便当子弹调用这些函数之一来绘制调试信息时,您的调试抽屉实际上可以在屏幕上绘制一些东西。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多