Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics/src/bullet/LinearMath/btIDebugDraw.h @ 2431

Last change on this file since 2431 was 2192, checked in by rgrieder, 16 years ago

Reverted all changes of attempt to update physics branch.

  • Property svn:eol-style set to native
File size: 3.8 KB
Line 
1/*
2Copyright (c) 2005 Gino van den Bergen / Erwin Coumans http://continuousphysics.com
3
4Permission is hereby granted, free of charge, to any person or organization
5obtaining a copy of the software and accompanying documentation covered by
6this license (the "Software") to use, reproduce, display, distribute,
7execute, and transmit the Software, and to prepare derivative works of the
8Software, and to permit third-parties to whom the Software is furnished to
9do so, all subject to the following:
10
11The copyright notices in the Software and this entire statement, including
12the above license grant, this restriction and the following disclaimer,
13must be included in all copies of the Software, in whole or in part, and
14all derivative works of the Software, unless such copies or derivative
15works are solely in the form of machine-executable object code generated by
16a source language processor.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
21SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
22FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
23ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24DEALINGS IN THE SOFTWARE.
25*/
26
27
28#ifndef IDEBUG_DRAW__H
29#define IDEBUG_DRAW__H
30
31#include "btVector3.h"
32
33
34///The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations.
35///Typical use case: create a debug drawer object, and assign it to a btCollisionWorld or btDynamicsWorld using setDebugDrawer and call debugDrawWorld.
36///A class that implements the btIDebugDraw interface has to implement the drawLine method at a minimum.
37class   btIDebugDraw
38{
39        public:
40
41        enum    DebugDrawModes
42        {
43                DBG_NoDebug=0,
44                DBG_DrawWireframe = 1,
45                DBG_DrawAabb=2,
46                DBG_DrawFeaturesText=4,
47                DBG_DrawContactPoints=8,
48                DBG_NoDeactivation=16,
49                DBG_NoHelpText = 32,
50                DBG_DrawText=64,
51                DBG_ProfileTimings = 128,
52                DBG_EnableSatComparison = 256,
53                DBG_DisableBulletLCP = 512,
54                DBG_EnableCCD = 1024,
55                DBG_MAX_DEBUG_DRAW_MODE
56        };
57
58        virtual ~btIDebugDraw() {};
59
60        virtual void    drawLine(const btVector3& from,const btVector3& to,const btVector3& color)=0;
61       
62        virtual void    drawTriangle(const btVector3& v0,const btVector3& v1,const btVector3& v2,const btVector3& /*n0*/,const btVector3& /*n1*/,const btVector3& /*n2*/,const btVector3& color, btScalar alpha)
63        {
64                drawTriangle(v0,v1,v2,color,alpha);
65        }
66        virtual void    drawTriangle(const btVector3& v0,const btVector3& v1,const btVector3& v2,const btVector3& color, btScalar /*alpha*/)
67        {
68                drawLine(v0,v1,color);
69                drawLine(v1,v2,color);
70                drawLine(v2,v0,color);
71        }
72
73        virtual void    drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color)=0;
74
75        virtual void    reportErrorWarning(const char* warningString) = 0;
76
77        virtual void    draw3dText(const btVector3& location,const char* textString) = 0;
78       
79        virtual void    setDebugMode(int debugMode) =0;
80       
81        virtual int             getDebugMode() const = 0;
82
83        inline void drawAabb(const btVector3& from,const btVector3& to,const btVector3& color)
84        {
85
86                btVector3 halfExtents = (to-from)* 0.5f;
87                btVector3 center = (to+from) *0.5f;
88                int i,j;
89
90                btVector3 edgecoord(1.f,1.f,1.f),pa,pb;
91                for (i=0;i<4;i++)
92                {
93                        for (j=0;j<3;j++)
94                        {
95                                pa = btVector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1],               
96                                        edgecoord[2]*halfExtents[2]);
97                                pa+=center;
98
99                                int othercoord = j%3;
100                                edgecoord[othercoord]*=-1.f;
101                                pb = btVector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1],       
102                                        edgecoord[2]*halfExtents[2]);
103                                pb+=center;
104
105                                drawLine(pa,pb,color);
106                        }
107                        edgecoord = btVector3(-1.f,-1.f,-1.f);
108                        if (i<3)
109                                edgecoord[i]*=-1.f;
110                }
111        }
112};
113
114
115#endif //IDEBUG_DRAW__H
116
Note: See TracBrowser for help on using the repository browser.