[10190] | 1 | /** |
---|
| 2 | * Originally from http://www.ogre3d.org/tikiwiki/BulletDebugDrawer&structure=Cookbook |
---|
| 3 | * This source code is released into the Public Domain. |
---|
| 4 | * |
---|
| 5 | * Modified by Fabian 'x3n' Landau by using DebugDrawer and Orxonox specific utilities (e.g. output). |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #ifndef _BulletDebugDrawer_H__ |
---|
| 9 | #define _BulletDebugDrawer_H__ |
---|
| 10 | |
---|
| 11 | #include "tools/ToolsPrereqs.h" |
---|
| 12 | |
---|
| 13 | #include <btBulletCollisionCommon.h> |
---|
| 14 | |
---|
| 15 | namespace orxonox |
---|
| 16 | { |
---|
| 17 | class _ToolsExport BulletDebugDrawer : public btIDebugDraw, public Ogre::FrameListener |
---|
| 18 | { |
---|
| 19 | public: |
---|
| 20 | BulletDebugDrawer(Ogre::SceneManager* sceneManager); |
---|
| 21 | ~BulletDebugDrawer(); |
---|
| 22 | virtual void drawLine(const btVector3& from, const btVector3& to, const btVector3& color); |
---|
| 23 | // virtual void drawTriangle(const btVector3& v0, const btVector3& v1, const btVector3& v2, const btVector3& color, btScalar); |
---|
| 24 | virtual void drawSphere (const btVector3& p, btScalar radius, const btVector3& color); |
---|
| 25 | virtual void drawSphere(btScalar radius, const btTransform& transform, const btVector3& color); |
---|
| 26 | virtual void drawBox(const btVector3& bbMin, const btVector3& bbMax, const btVector3& color); |
---|
| 27 | virtual void drawBox(const btVector3& bbMin, const btVector3& bbMax, const btTransform& trans, const btVector3& color); |
---|
[10191] | 28 | virtual void drawCylinder(btScalar radius, btScalar halfHeight, int upAxis, const btTransform& transform, const btVector3& color); |
---|
| 29 | virtual void drawCone(btScalar radius, btScalar height, int upAxis, const btTransform& transform, const btVector3& color); |
---|
[10190] | 30 | // virtual void drawPlane(const btVector3& planeNormal, btScalar planeConst, const btTransform& transform, const btVector3& color); |
---|
| 31 | |
---|
| 32 | virtual void drawContactPoint(const btVector3& PointOnB, const btVector3& normalOnB, btScalar distance, int lifeTime, const btVector3& color); |
---|
| 33 | |
---|
| 34 | virtual void reportErrorWarning(const char* warningString); |
---|
| 35 | virtual void draw3dText(const btVector3& location, const char* textString); |
---|
| 36 | |
---|
| 37 | virtual void setDebugMode(int debugMode); |
---|
| 38 | virtual int getDebugMode() const; |
---|
| 39 | |
---|
[10193] | 40 | void configure(bool bFill, float fillAlpha); |
---|
| 41 | |
---|
[10190] | 42 | protected: |
---|
| 43 | bool frameStarted(const Ogre::FrameEvent& evt); |
---|
| 44 | bool frameEnded(const Ogre::FrameEvent& evt); |
---|
| 45 | |
---|
| 46 | private: |
---|
| 47 | struct ContactPoint |
---|
| 48 | { |
---|
| 49 | Ogre::Vector3 from; |
---|
| 50 | Ogre::Vector3 to; |
---|
| 51 | Ogre::ColourValue color; |
---|
| 52 | size_t dieTime; |
---|
| 53 | }; |
---|
| 54 | |
---|
[10193] | 55 | bool bFill_; |
---|
| 56 | DebugDrawer* drawer_; |
---|
| 57 | |
---|
[10190] | 58 | DebugDrawModes mDebugMode; |
---|
| 59 | std::vector<ContactPoint>* mContactPoints; |
---|
| 60 | std::vector<ContactPoint> mContactPoints1; |
---|
| 61 | std::vector<ContactPoint> mContactPoints2; |
---|
| 62 | }; |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | #endif /* _BulletDebugDrawer_H__ */ |
---|