48 float hs[10] = {0.25f, 1.0f, 4.0f, 0.0f, 0.0f, -1.0f, -2.0f, -2.0f, -1.25f, 0.0f};
50 float x = 20.0f, y1 = 0.0f, dx = 5.0f;
52 for (
int32 i = 0; i < 10; ++i)
61 for (
int32 i = 0; i < 10; ++i)
124 b2Body* prevBody = ground;
125 for (
int32 i = 0; i < N; ++i)
133 b2Vec2 anchor(160.0
f + 2.0
f * i, -0.125
f);
140 b2Vec2 anchor(160.0
f + 2.0
f * N, -0.125
f);
179 vertices[0].
Set(-1.5
f, -0.5
f);
180 vertices[1].
Set(1.5
f, -0.5
f);
181 vertices[2].
Set(1.5
f, 0.0
f);
182 vertices[3].
Set(0.0
f, 0.9
f);
183 vertices[4].
Set(-1.15
f, 0.9
f);
184 vertices[5].
Set(-1.5
f, 0.2
f);
185 chassis.
Set(vertices, 6);
216 float dampingRatio = 0.7f;
217 float omega = 2.0f *
b2_pi * hertz;
224 jd.
damping = 2.0f * mass1 * dampingRatio * omega;
235 jd.
damping = 2.0f * mass2 * dampingRatio * omega;
b2Fixture * CreateFixture(const b2FixtureDef *def)
float lowerAngle
The lower angle for the joint limit (radians).
float density
The density, usually in kg/m^2.
void Initialize(b2Body *bodyA, b2Body *bodyB, const b2Vec2 &anchor)
float lowerTranslation
The lower translation limit, usually in meters.
void Initialize(b2Body *bodyA, b2Body *bodyB, const b2Vec2 &anchor, const b2Vec2 &axis)
const b2Vec2 & GetPosition() const
void SetTwoSided(const b2Vec2 &v1, const b2Vec2 &v2)
Set this as an isolated edge. Collision is two-sided.
void SetAsBox(float hx, float hy)
void SetMotorSpeed(float speed)
Set the motor speed, usually in radians per second.
A rigid body. These are created via b2World::CreateBody.
float maxMotorTorque
The maximum motor torque, usually in N-m.
void Keyboard(int key) override
b2Joint * CreateJoint(const b2JointDef *def)
void Set(float x_, float y_)
Set this vector to some specified coordinates.
bool enableMotor
Enable/disable the joint motor.
bool enableLimit
Enable/disable the joint limit.
float upperAngle
The upper angle for the joint limit (radians).
void Set(const b2Vec2 *points, int32 count)
void ApplyAngularImpulse(float impulse, bool wake)
int RegisterTest(const char *category, const char *name, TestCreateFcn *fcn)
bool enableLimit
A flag to enable joint limits.
void DrawString(int x, int y, const char *string,...)
void Step(Settings &settings) override
float motorSpeed
The desired motor speed in radians per second.
virtual void Step(Settings &settings)
float damping
Suspension damping. Typically in units of N*s/m.
float stiffness
Suspension stiffness. Typically in units N/m.
b2Body * CreateBody(const b2BodyDef *def)
float friction
The friction coefficient, usually in the range [0,1].
float upperTranslation
The upper translation limit, usually in meters.