Back to index

supertuxkart  0.5+dfsg1
btIDebugDraw.h
Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2005 Gino van den Bergen / Erwin Coumans http://continuousphysics.com
00003 
00004 Permission is hereby granted, free of charge, to any person or organization
00005 obtaining a copy of the software and accompanying documentation covered by
00006 this license (the "Software") to use, reproduce, display, distribute,
00007 execute, and transmit the Software, and to prepare derivative works of the
00008 Software, and to permit third-parties to whom the Software is furnished to
00009 do so, all subject to the following:
00010 
00011 The copyright notices in the Software and this entire statement, including
00012 the above license grant, this restriction and the following disclaimer,
00013 must be included in all copies of the Software, in whole or in part, and
00014 all derivative works of the Software, unless such copies or derivative
00015 works are solely in the form of machine-executable object code generated by
00016 a source language processor.
00017 
00018 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00019 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00020 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
00021 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
00022 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
00023 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00024 DEALINGS IN THE SOFTWARE.
00025 */
00026 
00027 
00028 #ifndef IDEBUG_DRAW__H
00029 #define IDEBUG_DRAW__H
00030 
00031 #include "btVector3.h"
00032 
00033 
00034 class  btIDebugDraw
00035 {
00036        public:
00037 
00038        enum   DebugDrawModes
00039        {
00040               DBG_NoDebug=0,
00041               DBG_DrawWireframe = 1,
00042               DBG_DrawAabb=2,
00043               DBG_DrawFeaturesText=4,
00044               DBG_DrawContactPoints=8,
00045               DBG_NoDeactivation=16,
00046               DBG_NoHelpText = 32,
00047               DBG_DrawText=64,
00048               DBG_ProfileTimings = 128,
00049               DBG_EnableSatComparison = 256,
00050               DBG_DisableBulletLCP = 512,
00051               DBG_EnableCCD = 1024,
00052               DBG_MAX_DEBUG_DRAW_MODE
00053        };
00054 
00055        virtual ~btIDebugDraw() {};
00056 
00057        virtual void  drawLine(const btVector3& from,const btVector3& to,const btVector3& color)=0;
00058        
00059        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)
00060        {
00061               drawTriangle(v0,v1,v2,color,alpha);
00062        }
00063        virtual       void   drawTriangle(const btVector3& v0,const btVector3& v1,const btVector3& v2,const btVector3& color, btScalar alpha)
00064        {
00065               drawLine(v0,v1,color);
00066               drawLine(v1,v2,color);
00067               drawLine(v2,v0,color);
00068        }
00069 
00070        virtual void  drawContactPoint(const btVector3& PointOnB,const btVector3& normalOnB,btScalar distance,int lifeTime,const btVector3& color)=0;
00071 
00072        virtual void  reportErrorWarning(const char* warningString) = 0;
00073 
00074        virtual void  draw3dText(const btVector3& location,const char* textString) = 0;
00075        
00076        virtual void  setDebugMode(int debugMode) =0;
00077        
00078        virtual int          getDebugMode() const = 0;
00079 
00080        inline void drawAabb(const btVector3& from,const btVector3& to,const btVector3& color)
00081        {
00082 
00083               btVector3 halfExtents = (to-from)* 0.5f;
00084               btVector3 center = (to+from) *0.5f;
00085               int i,j;
00086 
00087               btVector3 edgecoord(1.f,1.f,1.f),pa,pb;
00088               for (i=0;i<4;i++)
00089               {
00090                      for (j=0;j<3;j++)
00091                      {
00092                             pa = btVector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1],            
00093                                    edgecoord[2]*halfExtents[2]);
00094                             pa+=center;
00095 
00096                             int othercoord = j%3;
00097                             edgecoord[othercoord]*=-1.f;
00098                             pb = btVector3(edgecoord[0]*halfExtents[0], edgecoord[1]*halfExtents[1],     
00099                                    edgecoord[2]*halfExtents[2]);
00100                             pb+=center;
00101 
00102                             drawLine(pa,pb,color);
00103                      }
00104                      edgecoord = btVector3(-1.f,-1.f,-1.f);
00105                      if (i<3)
00106                             edgecoord[i]*=-1.f;
00107               }
00108        }
00109 };
00110 
00111 
00112 #endif //IDEBUG_DRAW__H
00113