90 b2Body* ground = m_world->CreateBody(&bd);
99 vertices[0].
Set(-0.5
f, 0.0
f);
100 vertices[1].
Set(0.5
f, 0.0
f);
101 vertices[2].
Set(0.0
f, 1.5
f);
102 m_polygons[0].Set(vertices, 3);
107 vertices[0].
Set(-0.1
f, 0.0
f);
108 vertices[1].
Set(0.1
f, 0.0
f);
109 vertices[2].
Set(0.0
f, 1.5
f);
110 m_polygons[1].Set(vertices, 3);
115 float b = w / (2.0f +
b2Sqrt(2.0
f));
119 vertices[0].
Set(0.5
f * s, 0.0
f);
120 vertices[1].
Set(0.5
f * w, b);
121 vertices[2].
Set(0.5
f * w, b + s);
122 vertices[3].
Set(0.5
f * s, w);
123 vertices[4].
Set(-0.5
f * s, w);
124 vertices[5].
Set(-0.5
f * w, b + s);
125 vertices[6].
Set(-0.5
f * w, b);
126 vertices[7].
Set(-0.5
f * s, 0.0
f);
128 m_polygons[2].Set(vertices, 8);
132 m_polygons[3].SetAsBox(0.5
f, 0.5
f);
140 memset(m_bodies, 0,
sizeof(m_bodies));
145 if (m_bodies[m_bodyIndex] != NULL)
147 m_world->DestroyBody(m_bodies[m_bodyIndex]);
148 m_bodies[m_bodyIndex] = NULL;
163 m_bodies[m_bodyIndex] = m_world->CreateBody(&bd);
168 fd.
shape = m_polygons + index;
171 m_bodies[m_bodyIndex]->CreateFixture(&fd);
180 m_bodies[m_bodyIndex]->CreateFixture(&fd);
190 if (m_bodies[i] != NULL)
192 m_world->DestroyBody(m_bodies[i]);
216 bool enabled = m_bodies[i]->IsEnabled();
217 m_bodies[i]->SetEnabled(!enabled);
241 m_world->QueryAABB(&callback, aabb);
247 m_textLine += m_textIncrement;
248 g_debugDraw.DrawString(5, m_textLine,
"Press 'a' to enable/disable some bodies");
249 m_textLine += m_textIncrement;
250 g_debugDraw.DrawString(5, m_textLine,
"Press 'd' to destroy a body");
251 m_textLine += m_textIncrement;
const b2Transform & GetTransform() const
virtual void DrawCircle(const b2Vec2 ¢er, float radius, const b2Color &color)=0
Draw a circle.
b2Fixture * CreateFixture(const b2FixtureDef *def)
float density
The density, usually in kg/m^2.
bool ReportFixture(b2Fixture *fixture) override
void Step(Settings &settings) override
B2_API bool b2TestOverlap(const b2Shape *shapeA, int32 indexA, const b2Shape *shapeB, int32 indexB, const b2Transform &xfA, const b2Transform &xfB)
Determine if two generic shapes overlap.
virtual void DrawPoint(const b2Vec2 &p, float size, const b2Color &color)=0
Draw a point.
float RandomFloat()
Random number in range [-1,1].
void SetTwoSided(const b2Vec2 &v1, const b2Vec2 &v2)
Set this as an isolated edge. Collision is two-sided.
Color for debug drawing. Each value has the range [0,1].
A rigid body. These are created via b2World::CreateBody.
void Set(float x_, float y_)
Set this vector to some specified coordinates.
float angle
The world angle of the body in radians.
void ComputeAABB(b2AABB *aabb, const b2Transform &transform, int32 childIndex) const override
An axis aligned bounding box.
int RegisterTest(const char *category, const char *name, TestCreateFcn *fcn)
virtual void Step(Settings &settings)
const b2Vec2 & GetWorldCenter() const
Get the world position of the center of mass.
float friction
The friction coefficient, usually in the range [0,1].
void Keyboard(int key) override