SuperTuxKart
Loading...
Searching...
No Matches
irr_debug_drawer.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2006-2015 Joerg Henrichs
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 3
8// of the License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19#ifndef HEADER_IRR_DEBUG_DRAWER_HPP
20#define HEADER_IRR_DEBUG_DRAWER_HPP
21
22#include "btBulletDynamicsCommon.h"
23
24#include <SColor.h>
25#include "utils/vec3.hpp"
26#include <map>
27#include <vector>
28
32class IrrDebugDrawer : public btIDebugDraw
33{
34public:
39 enum DebugModeType { DM_NONE = 0x00,
40 DM_KARTS_PHYSICS = 0x01,
41 DM_NO_KARTS_GRAPHICS = 0x02
42 };
43 DebugModeType m_debug_mode;
44
45 std::map<video::SColor, std::vector<float> > m_lines;
46
47 Vec3 m_camera_pos;
48
49protected:
50 virtual void setDebugMode(int debug_mode) {}
55 virtual int getDebugMode() const
56 { return m_debug_mode==DM_NONE ? DBG_NoDebug
57 : DBG_DrawWireframe;}
58public:
60 void render(float dt);
62 virtual void drawLine(const btVector3& from, const btVector3& to,
63 const btVector3& color);
65 virtual void drawContactPoint(const btVector3& Point_on_b,
66 const btVector3& normal_on_b,
67 btScalar distance,int life_time,
68 const btVector3& color) {}
69 virtual void reportErrorWarning(const char* warningString) {}
70 virtual void draw3dText(const btVector3& location,
71 const char* textString) {}
73 bool debugEnabled() const {return m_debug_mode!=0;}
74 void nextDebugMode();
75 void setDebugMode(DebugModeType mode);
76
77 void beginNextFrame();
78 const std::map<video::SColor, std::vector<float> >& getLines() const { return m_lines; }
79}; // IrrDebugDrawer
80
81#endif
82/* EOF */
83
Definition: irr_debug_drawer.hpp:33
void nextDebugMode()
Activates the next debug mode, or switches the mode off again.
Definition: irr_debug_drawer.cpp:37
virtual void drawContactPoint(const btVector3 &Point_on_b, const btVector3 &normal_on_b, btScalar distance, int life_time, const btVector3 &color)
optional debug methods
Definition: irr_debug_drawer.hpp:65
bool debugEnabled() const
Returns true if debug mode is enabled.
Definition: irr_debug_drawer.hpp:73
virtual int getDebugMode() const
Callback for bullet: if debug drawing should be done or not.
Definition: irr_debug_drawer.hpp:55
virtual void drawLine(const btVector3 &from, const btVector3 &to, const btVector3 &color)
Draws a line.
Definition: irr_debug_drawer.cpp:58
DebugModeType
The drawing mode to use: If bit 0 is set, draw the bullet collision shape of karts If bit 1 is set,...
Definition: irr_debug_drawer.hpp:39
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35