35 const float k_restitution = 0.4f;
78 poly1.
Set(vertices, 3);
85 xf2.
q.
Set(-0.3524
f * b2_pi);
93 poly2.
Set(vertices, 3);
109 float gravity = 10.0f;
116 float radius =
b2Sqrt(2.0
f * I / mass);
124 jd.
maxForce = 0.5f * mass * gravity;
125 jd.
maxTorque = 0.2f * mass * radius * gravity;
139 for (
int i = 0; i < 10; ++i)
149 float gravity = 10.0f;
154 float radius =
b2Sqrt(2.0
f * I / mass);
163 jd.
maxTorque = 0.1f * mass * radius * gravity;
float maxForce
The maximum friction force in N.
b2Fixture * CreateFixture(const b2FixtureDef *def)
b2Vec2 localAnchorA
The local anchor point relative to bodyA's origin.
b2Vec2 b2Mul(const b2Mat22 &A, const b2Vec2 &v)
float density
The density, usually in kg/m^2.
const b2Vec2 & GetLocalCenter() const
Get the local position of the center of mass.
void SetGravity(const b2Vec2 &gravity)
Change the global gravity vector.
float maxTorque
The maximum friction torque in N-m.
b2Vec2 localAnchorB
The local anchor point relative to bodyB's origin.
void ApplyForce(const b2Vec2 &force, const b2Vec2 &point, bool wake)
b2Vec2 GetXAxis() const
Get the x-axis.
void SetZero()
Set this vector to all zeros.
void SetTwoSided(const b2Vec2 &v1, const b2Vec2 &v2)
Set this as an isolated edge. Collision is two-sided.
Friction joint definition.
void SetAsBox(float hx, float hy)
void Step(Settings &settings) override
A rigid body. These are created via b2World::CreateBody.
b2Joint * CreateJoint(const b2JointDef *def)
bool collideConnected
Set this flag to true if the attached bodies should collide.
void Set(float x_, float y_)
Set this vector to some specified coordinates.
b2Vec2 GetWorldVector(const b2Vec2 &localVector) const
float angle
The world angle of the body in radians.
void Set(const b2Vec2 *points, int32 count)
void ApplyTorque(float torque, bool wake)
b2Vec2 GetWorldPoint(const b2Vec2 &localPoint) const
int RegisterTest(const char *category, const char *name, TestCreateFcn *fcn)
void DrawString(int x, int y, const char *string,...)
GLFWwindow * g_mainWindow
virtual void Step(Settings &settings)
b2Body * bodyA
The first attached body.
float restitution
The restitution (elasticity) usually in the range [0,1].
b2Body * CreateBody(const b2BodyDef *def)
b2Body * bodyB
The second attached body.
float friction
The friction coefficient, usually in the range [0,1].
void Set(float angle)
Set using an angle in radians.