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