2013-11-14 47 views
1

我一直在用子彈擺弄一下,現在我想繪製調試。 我有一個工作子彈物理和一切的opengl世界。帶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(); 

必須有東西我錯過了,因爲我沒有得到任何線框或任何運行時。

+0

我知道這是一條舊消息,但是當我搜索到它時,它彈出到頂部。是否碰巧在你的GLDebugDrawer類中實現了這些方法中的任何一個? – Jamie

回答

1

有一個在http://sio2interactive.forumotion.net/t599-enabling-bullet-debug-draw-code-included一組簡單的可用代碼應該是相對簡單的來修改你的代碼,看起來你可能需要改變bt_dynamicsWorld->setDebugDrawer(debugDraw);bt_dynamicsWorld->setDebugDrawer(&debugDraw);(不知道的,雖然不知道你怎麼會有你的框架設置

+1

嘿,謝謝你的回覆。看看那篇文章,並遵循它,但我仍然沒有得到任何通過。如果我做'bt_dynamicsWorld-> setDebugDrawer(&debugDraw);'我得到這個:'不能將參數1從'GLDebugDrawer **'轉換爲'btIDebugDraw *' '。 – b0Gd4N