Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/tools/BulletDebugDrawer.h @ 10191

Last change on this file since 10191 was 10191, checked in by landauf, 10 years ago

added customized visualization for cylinders and cones to BulletDebugDrawer.
improved DebugDrawer by making circle, cylinder, and sphere rotatable. added rendering function for cones.

File size: 2.8 KB
Line 
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
15namespace 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);
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);
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
40        protected:
41            bool frameStarted(const Ogre::FrameEvent& evt);
42            bool frameEnded(const Ogre::FrameEvent& evt);
43
44        private:
45            struct ContactPoint
46            {
47                Ogre::Vector3 from;
48                Ogre::Vector3 to;
49                Ogre::ColourValue color;
50                size_t dieTime;
51            };
52
53            DebugDrawer* drawer;
54            DebugDrawModes mDebugMode;
55            std::vector<ContactPoint>* mContactPoints;
56            std::vector<ContactPoint> mContactPoints1;
57            std::vector<ContactPoint> mContactPoints2;
58    };
59}
60
61#endif /* _BulletDebugDrawer_H__ */
Note: See TracBrowser for help on using the repository browser.