![]() |
Box2D
2.2.1
A 2D Physics Engine for Games
|
00001 /* 00002 * Copyright (c) 2011 Erin Catto http://box2d.org 00003 * 00004 * This software is provided 'as-is', without any express or implied 00005 * warranty. In no event will the authors be held liable for any damages 00006 * 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 00009 * freely, subject to the following restrictions: 00010 * 1. The origin of this software must not be misrepresented; you must not 00011 * claim that you wrote the original software. If you use this software 00012 * in a product, an acknowledgment in the product documentation would be 00013 * appreciated but is not required. 00014 * 2. Altered source versions must be plainly marked as such, and must not be 00015 * misrepresented as being the original software. 00016 * 3. This notice may not be removed or altered from any source distribution. 00017 */ 00018 00019 #include <Box2D/Common/b2Math.h> 00020 00022 struct b2Color 00023 { 00024 b2Color() {} 00025 b2Color(float32 r, float32 g, float32 b) : r(r), g(g), b(b) {} 00026 void Set(float32 ri, float32 gi, float32 bi) { r = ri; g = gi; b = bi; } 00027 float32 r, g, b; 00028 }; 00029 00032 class b2Draw 00033 { 00034 public: 00035 b2Draw(); 00036 00037 virtual ~b2Draw() {} 00038 00039 enum 00040 { 00041 e_shapeBit = 0x0001, 00042 e_jointBit = 0x0002, 00043 e_aabbBit = 0x0004, 00044 e_pairBit = 0x0008, 00045 e_centerOfMassBit = 0x0010 00046 }; 00047 00049 void SetFlags(uint32 flags); 00050 00052 uint32 GetFlags() const; 00053 00055 void AppendFlags(uint32 flags); 00056 00058 void ClearFlags(uint32 flags); 00059 00061 virtual void DrawPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) = 0; 00062 00064 virtual void DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color) = 0; 00065 00067 virtual void DrawCircle(const b2Vec2& center, float32 radius, const b2Color& color) = 0; 00068 00070 virtual void DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color) = 0; 00071 00073 virtual void DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color) = 0; 00074 00077 virtual void DrawTransform(const b2Transform& xf) = 0; 00078 00079 protected: 00080 uint32 m_drawFlags; 00081 };