Back to index

supertuxkart  0.5+dfsg1
DebugCastResult.h
Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
00004 
00005 This software is provided 'as-is', without any express or implied warranty.
00006 In no event will the authors be held liable for any damages arising from the use of this software.
00007 Permission is granted to anyone to use this software for any purpose, 
00008 including commercial applications, and to alter it and redistribute it freely, 
00009 subject to the following restrictions:
00010 
00011 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
00012 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00013 3. This notice may not be removed or altered from any source distribution.
00014 */
00015 
00016 #ifndef DEBUG_CAST_RESULT_H
00017 #define DEBUG_CAST_RESULT_H
00018 
00019 #include "BulletCollision/NarrowPhaseCollision/btConvexCast.h"
00020 #include "LinearMath/btTransform.h"
00021 #include "GL_ShapeDrawer.h"
00022 #include "GlutStuff.h"
00023 #ifdef WIN32
00024 #include <windows.h>
00025 #endif
00026 //think different
00027 #if defined(__APPLE__) && !defined (VMDMESA)
00028 #include <OpenGL/gl.h>
00029 #include <OpenGL/glu.h>
00030 #else
00031 #include <GL/gl.h>
00032 #endif
00033 struct btDebugCastResult : public btConvexCast::CastResult
00034 {
00035 
00036        btTransform   m_fromTrans;
00037        const btPolyhedralConvexShape* m_shape;
00038        btVector3     m_linVel;
00039        btVector3 m_angVel;
00040        GL_ShapeDrawer* m_shapeDrawer;
00041 
00042        btDebugCastResult(const btTransform& fromTrans,const btPolyhedralConvexShape* shape,
00043                                    const btVector3& linVel,const btVector3& angVel,GL_ShapeDrawer* drawer)
00044        :m_fromTrans(fromTrans),
00045        m_shape(shape),
00046        m_linVel(linVel),
00047        m_angVel(angVel)
00048        {
00049        }
00050 
00051        virtual void drawCoordSystem(const btTransform& tr)  
00052        {
00053               btScalar m[16];
00054               tr.getOpenGLMatrix(m);
00055               glPushMatrix();
00056               btglLoadMatrix(m);
00057               glBegin(GL_LINES);
00058               btglColor3(1, 0, 0);
00059               btglVertex3(0, 0, 0);
00060               btglVertex3(1, 0, 0);
00061               btglColor3(0, 1, 0);
00062               btglVertex3(0, 0, 0);
00063               btglVertex3(0, 1, 0);
00064               btglColor3(0, 0, 1);
00065               btglVertex3(0, 0, 0);
00066               btglVertex3(0, 0, 1);
00067               glEnd();
00068               glPopMatrix();
00069        }
00070 
00071        virtual void  DebugDraw(btScalar   fraction)
00072        {
00073        
00074               btScalar m[16];
00075               btTransform hitTrans;
00076               btTransformUtil::integrateTransform(m_fromTrans,m_linVel,m_angVel,fraction,hitTrans);
00077               hitTrans.getOpenGLMatrix(m);
00078               m_shapeDrawer->drawOpenGL(m,m_shape,btVector3(1,0,0),btIDebugDraw::DBG_NoDebug);
00079        }
00080 };
00081 
00082 
00083 #endif //DEBUG_CAST_RESULT_H