Box2D: b2Draw.h Source File

| Box2D 2.3.0 A 2D Physics Engine for Games

b2Draw.h
1 /*
2 * Copyright (c) 2011 Erin Catto http://box2d.org
3 *
4 * This software is provided 'as-is', without any express or implied
5 * warranty. In no event will the authors be held liable for any damages
6 * arising from the use of this software.
7 * Permission is granted to anyone to use this software for any purpose,
8 * including commercial applications, and to alter it and redistribute it
9 * freely, subject to the following restrictions:
10 * 1. The origin of this software must not be misrepresented; you must not
11 * claim that you wrote the original software. If you use this software
12 * in a product, an acknowledgment in the product documentation would be
13 * appreciated but is not required.
14 * 2. Altered source versions must be plainly marked as such, and must not be
15 * misrepresented as being the original software.
16 * 3. This notice may not be removed or altered from any source distribution.
17 */
18
19 #ifndef B2_DRAW_H
20 #define B2_DRAW_H
21
22 #include <Box2D/Common/b2Math.h>
23
25 struct b2Color
26 {
27 b2Color() {}
28 b2Color(float32 r, float32 g, float32 b, float32 a = 1.0f) : r(r), g(g), b(b), a(a) {}
29 void Set(float32 ri, float32 gi, float32 bi, float32 ai = 1.0f) { r = ri; g = gi; b = bi; a = ai; }
30 float32 r, g, b, a;
31 };
32
35 class b2Draw
36 {
37 public:
38 b2Draw();
39
40 virtual ~b2Draw() {}
41
42 enum
43 {
44 e_shapeBit = 0x0001,
45 e_jointBit = 0x0002,
46 e_aabbBit = 0x0004,
47 e_pairBit = 0x0008,
48 e_centerOfMassBit = 0x0010
49 };
50
52 void SetFlags(uint32 flags);
53
55 uint32 GetFlags() const;
56
58 void AppendFlags(uint32 flags);
59
61 void ClearFlags(uint32 flags);
62
64 virtual void DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) = 0;
65
67 virtual void DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) = 0;
68
70 virtual void DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color) = 0;
71
73 virtual void DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color) = 0;
74
76 virtual void DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color) = 0;
77
80 virtual void DrawTransform(const b2Transform& xf) = 0;
81
82 protected:
83 uint32 m_drawFlags;
84 };
85
86 #endif
b2Transform
Definition: b2Math.h:350
b2Draw::e_centerOfMassBit
draw center of mass frame
Definition: b2Draw.h:48
b2Draw::GetFlags
uint32 GetFlags() const
Get the drawing flags.
Definition: b2Draw.cpp:31
b2Draw::DrawSolidCircle
virtual void DrawSolidCircle(const b2Vec2 &center, float32 radius, const b2Vec2 &axis, const b2Color &color)=0
Draw a solid circle.
b2Draw::DrawSegment
virtual void DrawSegment(const b2Vec2 &p1, const b2Vec2 &p2, const b2Color &color)=0
Draw a line segment.
b2Color
Color for debug drawing. Each value has the range [0,1].
Definition: b2Draw.h:25
b2Draw::e_pairBit
draw broad-phase pairs
Definition: b2Draw.h:47
b2Draw::SetFlags
void SetFlags(uint32 flags)
Set the drawing flags.
Definition: b2Draw.cpp:26
b2Draw::e_shapeBit
draw shapes
Definition: b2Draw.h:44
b2Draw::DrawCircle
virtual void DrawCircle(const b2Vec2 &center, float32 radius, const b2Color &color)=0
Draw a circle.
b2Draw::DrawSolidPolygon
virtual void DrawSolidPolygon(const b2Vec2 *vertices, int32 vertexCount, const b2Color &color)=0
Draw a solid closed polygon provided in CCW order.
b2Draw::ClearFlags
void ClearFlags(uint32 flags)
Clear flags from the current flags.
Definition: b2Draw.cpp:41
b2Draw
Definition: b2Draw.h:35
b2Draw::DrawPolygon
virtual void DrawPolygon(const b2Vec2 *vertices, int32 vertexCount, const b2Color &color)=0
Draw a closed polygon provided in CCW order.
b2Draw::e_jointBit
draw joint connections
Definition: b2Draw.h:45
b2Draw::e_aabbBit
draw axis aligned bounding boxes
Definition: b2Draw.h:46
b2Vec2
A 2D column vector.
Definition: b2Math.h:53
b2Draw::DrawTransform
virtual void DrawTransform(const b2Transform &xf)=0
b2Draw::AppendFlags
void AppendFlags(uint32 flags)
Append flags to the current flags.
Definition: b2Draw.cpp:36