35 const b2Vec2& normal,
float fraction)
override 63 b2Body* ground = m_world->CreateBody(&bd);
66 float y1 = 2.0f * cosf(x1 / 10.0
f *
b2_pi);
67 for (
int32 i = 0; i < 80; ++i)
70 float y2 = 2.0f * cosf(x2 / 10.0
f * b2_pi);
83 vertices[0].
Set(-0.5
f, 0.0
f);
84 vertices[1].
Set(0.5
f, 0.0
f);
85 vertices[2].
Set(0.0
f, 1.5
f);
86 m_polygons[0].Set(vertices, 3);
91 vertices[0].
Set(-0.1
f, 0.0
f);
92 vertices[1].
Set(0.1
f, 0.0
f);
93 vertices[2].
Set(0.0
f, 1.5
f);
94 m_polygons[1].Set(vertices, 3);
99 float b = w / (2.0f +
b2Sqrt(2.0
f));
103 vertices[0].
Set(0.5
f * s, 0.0
f);
104 vertices[1].
Set(0.5
f * w, b);
105 vertices[2].
Set(0.5
f * w, b + s);
106 vertices[3].
Set(0.5
f * s, w);
107 vertices[4].
Set(-0.5
f * s, w);
108 vertices[5].
Set(-0.5
f * w, b + s);
109 vertices[6].
Set(-0.5
f * w, b);
110 vertices[7].
Set(-0.5
f * s, 0.0
f);
112 m_polygons[2].Set(vertices, 8);
116 m_polygons[3].SetAsBox(0.5
f, 0.5
f);
120 m_circle.m_radius = 0.5f;
124 memset(m_bodies, 0,
sizeof(m_bodies));
131 if (m_bodies[m_bodyIndex] != NULL)
133 m_world->DestroyBody(m_bodies[m_bodyIndex]);
134 m_bodies[m_bodyIndex] = NULL;
150 m_bodies[m_bodyIndex] = m_world->CreateBody(&bd);
155 fd.
shape = m_polygons + index;
158 m_bodies[m_bodyIndex]->CreateFixture(&fd);
163 fd.
shape = &m_circle;
166 m_bodies[m_bodyIndex]->CreateFixture(&fd);
176 if (m_bodies[i] != NULL)
178 m_world->DestroyBody(m_bodies[i]);
209 m_textLine += m_textIncrement;
214 b2Vec2 point2 = point1 + d;
218 m_world->RayCast(&callback, point1, point2);
236 m_angle += 0.25f *
b2_pi / 180.0f;
b2Fixture * CreateFixture(const b2FixtureDef *def)
float density
The density, usually in kg/m^2.
void DrawPoint(const b2Vec2 &p, float size, const b2Color &color) override
Draw a point.
float RandomFloat()
Random number in range [-1,1].
float ReportFixture(b2Fixture *fixture, const b2Vec2 &point, const b2Vec2 &normal, float fraction) override
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 Step(Settings &settings) override
void Keyboard(int key) override
void Set(float x_, float y_)
Set this vector to some specified coordinates.
float angle
The world angle of the body in radians.
int RegisterTest(const char *category, const char *name, TestCreateFcn *fcn)
void DrawString(int x, int y, const char *string,...)
virtual void Step(Settings &settings)
void DrawSegment(const b2Vec2 &p1, const b2Vec2 &p2, const b2Color &color) override
Draw a line segment.
float friction
The friction coefficient, usually in the range [0,1].