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