[10262] | 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> |
---|
[10280] | 14 | #include <OgreFrameListener.h> |
---|
[10262] | 15 | |
---|
| 16 | namespace orxonox |
---|
| 17 | { |
---|
| 18 | class _ToolsExport BulletDebugDrawer : public btIDebugDraw, public Ogre::FrameListener |
---|
| 19 | { |
---|
| 20 | public: |
---|
| 21 | BulletDebugDrawer(Ogre::SceneManager* sceneManager); |
---|
| 22 | ~BulletDebugDrawer(); |
---|
| 23 | virtual void drawLine(const btVector3& from, const btVector3& to, const btVector3& color); |
---|
| 24 | // virtual void drawTriangle(const btVector3& v0, const btVector3& v1, const btVector3& v2, const btVector3& color, btScalar); |
---|
| 25 | virtual void drawSphere (const btVector3& p, btScalar radius, const btVector3& color); |
---|
| 26 | virtual void drawSphere(btScalar radius, const btTransform& transform, const btVector3& color); |
---|
| 27 | virtual void drawBox(const btVector3& bbMin, const btVector3& bbMax, const btVector3& color); |
---|
| 28 | virtual void drawBox(const btVector3& bbMin, const btVector3& bbMax, const btTransform& trans, const btVector3& color); |
---|
| 29 | virtual void drawCylinder(btScalar radius, btScalar halfHeight, int upAxis, const btTransform& transform, const btVector3& color); |
---|
| 30 | virtual void drawCone(btScalar radius, btScalar height, int upAxis, const btTransform& transform, const btVector3& color); |
---|
| 31 | // virtual void drawPlane(const btVector3& planeNormal, btScalar planeConst, const btTransform& transform, const btVector3& color); |
---|
| 32 | |
---|
| 33 | virtual void drawContactPoint(const btVector3& PointOnB, const btVector3& normalOnB, btScalar distance, int lifeTime, const btVector3& color); |
---|
| 34 | |
---|
| 35 | virtual void reportErrorWarning(const char* warningString); |
---|
| 36 | virtual void draw3dText(const btVector3& location, const char* textString); |
---|
| 37 | |
---|
| 38 | virtual void setDebugMode(int debugMode); |
---|
| 39 | virtual int getDebugMode() const; |
---|
| 40 | |
---|
| 41 | void configure(bool bFill, float fillAlpha); |
---|
| 42 | |
---|
| 43 | protected: |
---|
| 44 | bool frameStarted(const Ogre::FrameEvent& evt); |
---|
| 45 | bool frameEnded(const Ogre::FrameEvent& evt); |
---|
| 46 | |
---|
| 47 | private: |
---|
| 48 | struct ContactPoint |
---|
| 49 | { |
---|
| 50 | Ogre::Vector3 from; |
---|
| 51 | Ogre::Vector3 to; |
---|
| 52 | Ogre::ColourValue color; |
---|
| 53 | size_t dieTime; |
---|
| 54 | }; |
---|
| 55 | |
---|
| 56 | bool bFill_; |
---|
| 57 | DebugDrawer* drawer_; |
---|
| 58 | |
---|
| 59 | DebugDrawModes mDebugMode; |
---|
| 60 | std::vector<ContactPoint>* mContactPoints; |
---|
| 61 | std::vector<ContactPoint> mContactPoints1; |
---|
| 62 | std::vector<ContactPoint> mContactPoints2; |
---|
| 63 | }; |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | #endif /* _BulletDebugDrawer_H__ */ |
---|