Car physics (side on)

Hi there,

I have made an attempt of porting the second tutorial on this website:

http://www.emanueleferonato.com/2009/04/06/two-ways-to-make-box2d-cars/

In to C++, unfortunately when I run it the forces do not seem to behave correctly as the carts get pulled apart and doesn't drive correctly. I spent a little bit of time messing around with some of the forces (reducing gravity, increasing the density of the axles, etc.) and managed to get something that felt a little better, but I'm not clear why I am not able to get my simulation to behave as the tutorial example does.

I'm almost certainly there is a problem with what I'm doing, but after looking at it for a while, I can't spot the problem, so I thought I'd post here in case anyone can hazard a guess at what I'm doing wrong. I have uploaded a video of my simulation here:

http://www.youtube.com/watch?v=nVISbPA5yHA

And what follows is Box2D's dump of the objects in my world, which consists of a couple of terrain objects and the cart. I am unaware why these is quite as much in the dump as there is - I expected there to only be a small number of bodies.

Any help that can be offered would be received gratefully.

Steve

Code:
b2Vec2 g(0.000000000000000e+000f, -1.000000000000000e+001f);
m_world->SetGravity(g);
b2Body** bodies = (b2Body**)b2Alloc(59 * sizeof(b2Body*));
b2Joint** joints = (b2Joint**)b2Alloc(4 * sizeof(b2Joint*));
{
  b2BodyDef bd;
  bd.type = b2BodyType(2);
  bd.position.Set(4.783333301544190e+000f, 2.253910303115845e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(0);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[0] = m_world->CreateBody(&bd);

  {
    b2FixtureDef fd;
    fd.friction = 5.000000000000000e+000f;
    fd.restitution = 2.000000029802322e-001f;
    fd.density = 1.000000014901161e-001f;
    fd.isSensor = bool(0);
    fd.filter.categoryBits = uint16(1024);
    fd.filter.maskBits = uint16(50);
    fd.filter.groupIndex = int16(0);
    b2CircleShape shape;
    shape.m_radius = 6.999999880790710e-001f;
    shape.m_p.Set(0.000000000000000e+000f, 0.000000000000000e+000f);

    fd.shape = &shape;

    bodies[0]->CreateFixture(&fd);
  }
}
{
  b2BodyDef bd;
  bd.type = b2BodyType(2);
  bd.position.Set(1.883333325386047e+000f, 2.253910303115845e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(0);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[1] = m_world->CreateBody(&bd);

  {
    b2FixtureDef fd;
    fd.friction = 5.000000000000000e+000f;
    fd.restitution = 2.000000029802322e-001f;
    fd.density = 1.000000014901161e-001f;
    fd.isSensor = bool(0);
    fd.filter.categoryBits = uint16(1024);
    fd.filter.maskBits = uint16(50);
    fd.filter.groupIndex = int16(0);
    b2CircleShape shape;
    shape.m_radius = 6.999999880790710e-001f;
    shape.m_p.Set(0.000000000000000e+000f, 0.000000000000000e+000f);

    fd.shape = &shape;

    bodies[1]->CreateFixture(&fd);
  }
}
{
  b2BodyDef bd;
  bd.type = b2BodyType(2);
  bd.position.Set(3.333333253860474e+000f, 3.333333253860474e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[2] = m_world->CreateBody(&bd);

  {
    b2FixtureDef fd;
    fd.friction = 5.000000000000000e-001f;
    fd.restitution = 2.000000029802322e-001f;
    fd.density = 1.000000000000000e+000f;
    fd.isSensor = bool(0);
    fd.filter.categoryBits = uint16(1024);
    fd.filter.maskBits = uint16(50);
    fd.filter.groupIndex = int16(0);
    b2PolygonShape shape;
    b2Vec2 vs[8];
    vs[0].Set(1.013397455215454e+000f, -5.232051014900208e-001f);
    vs[1].Set(1.413397431373596e+000f, -1.216025471687317e+000f);
    vs[2].Set(1.586602449417114e+000f, -1.116025447845459e+000f);
    vs[3].Set(1.186602473258972e+000f, -4.232051372528076e-001f);
    shape.Set(vs, 4);

    fd.shape = &shape;

    bodies[2]->CreateFixture(&fd);
  }
}
{
  b2BodyDef bd;
  bd.type = b2BodyType(2);
  bd.position.Set(3.333333253860474e+000f, 3.333333253860474e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[3] = m_world->CreateBody(&bd);

  {
    b2FixtureDef fd;
    fd.friction = 5.000000000000000e-001f;
    fd.restitution = 2.000000029802322e-001f;
    fd.density = 1.000000000000000e+000f;
    fd.isSensor = bool(0);
    fd.filter.categoryBits = uint16(1024);
    fd.filter.maskBits = uint16(50);
    fd.filter.groupIndex = int16(0);
    b2PolygonShape shape;
    b2Vec2 vs[8];
    vs[0].Set(-1.413397431373596e+000f, -1.216025471687317e+000f);
    vs[1].Set(-1.013397455215454e+000f, -5.232051014900208e-001f);
    vs[2].Set(-1.186602473258972e+000f, -4.232051372528076e-001f);
    vs[3].Set(-1.586602449417114e+000f, -1.116025447845459e+000f);
    shape.Set(vs, 4);

    fd.shape = &shape;

    bodies[3]->CreateFixture(&fd);
  }
}
{
  b2BodyDef bd;
  bd.type = b2BodyType(2);
  bd.position.Set(3.333333253860474e+000f, 3.333333253860474e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[4] = m_world->CreateBody(&bd);

  {
    b2FixtureDef fd;
    fd.friction = 5.000000000000000e-001f;
    fd.restitution = 2.000000029802322e-001f;
    fd.density = 2.000000000000000e+000f;
    fd.isSensor = bool(0);
    fd.filter.categoryBits = uint16(1024);
    fd.filter.maskBits = uint16(50);
    fd.filter.groupIndex = int16(0);
    b2PolygonShape shape;
    b2Vec2 vs[8];
    vs[0].Set(6.700961589813232e-001f, -2.858982607722282e-002f);
    vs[1].Set(1.070096135139465e+000f, -7.214102149009705e-001f);
    vs[2].Set(1.329903841018677e+000f, -5.714101791381836e-001f);
    vs[3].Set(9.299038052558899e-001f, 1.214101687073708e-001f);
    shape.Set(vs, 4);

    fd.shape = &shape;

    bodies[4]->CreateFixture(&fd);
  }
  {
    b2FixtureDef fd;
    fd.friction = 5.000000000000000e-001f;
    fd.restitution = 2.000000029802322e-001f;
    fd.density = 2.000000000000000e+000f;
    fd.isSensor = bool(0);
    fd.filter.categoryBits = uint16(1024);
    fd.filter.maskBits = uint16(50);
    fd.filter.groupIndex = int16(0);
    b2PolygonShape shape;
    b2Vec2 vs[8];
    vs[0].Set(-1.070096135139465e+000f, -7.214102149009705e-001f);
    vs[1].Set(-6.700961589813232e-001f, -2.858982607722282e-002f);
    vs[2].Set(-9.299038052558899e-001f, 1.214101687073708e-001f);
    vs[3].Set(-1.329903841018677e+000f, -5.714101791381836e-001f);
    shape.Set(vs, 4);

    fd.shape = &shape;

    bodies[4]->CreateFixture(&fd);
  }
  {
    b2FixtureDef fd;
    fd.friction = 5.000000000000000e-001f;
    fd.restitution = 2.000000029802322e-001f;
    fd.density = 2.000000000000000e+000f;
    fd.isSensor = bool(0);
    fd.filter.categoryBits = uint16(1024);
    fd.filter.maskBits = uint16(50);
    fd.filter.groupIndex = int16(0);
    b2PolygonShape shape;
    b2Vec2 vs[8];
    vs[0].Set(-1.500000000000000e+000f, -3.000000119209290e-001f);
    vs[1].Set(1.500000000000000e+000f, -3.000000119209290e-001f);
    vs[2].Set(1.500000000000000e+000f, 3.000000119209290e-001f);
    vs[3].Set(-1.500000000000000e+000f, 3.000000119209290e-001f);
    shape.Set(vs, 4);

    fd.shape = &shape;

    bodies[4]->CreateFixture(&fd);
  }
}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(6.333333492279053e+000f, 2.133333444595337e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[5] = m_world->CreateBody(&bd);

  {
    b2FixtureDef fd;
    fd.friction = 2.000000029802322e-001f;
    fd.restitution = 0.000000000000000e+000f;
    fd.density = 0.000000000000000e+000f;
    fd.isSensor = bool(0);
    fd.filter.categoryBits = uint16(2);
    fd.filter.maskBits = uint16(1272);
    fd.filter.groupIndex = int16(0);
    b2ChainShape shape;
    b2Vec2 vs[8];
    vs[0].Set(0.000000000000000e+000f, 0.000000000000000e+000f);
    vs[1].Set(8.566666603088379e+000f, 1.466666698455811e+000f);
    vs[2].Set(1.050000000000000e+001f, 1.433333277702332e+000f);
    vs[3].Set(1.389999961853027e+001f, 2.400000095367432e+000f);
    vs[4].Set(1.693333244323731e+001f, 3.133333444595337e+000f);
    vs[5].Set(1.833333396911621e+001f, 3.633333444595337e+000f);
    vs[6].Set(1.920000076293945e+001f, 3.866666555404663e+000f);
    vs[7].Set(1.923333358764648e+001f, 1.000000014901161e-001f);
    shape.CreateChain(vs, 8);
    shape.m_prevVertex.Set(-1.073741760000000e+008f, -1.073741760000000e+008f);
    shape.m_nextVertex.Set(-1.073741760000000e+008f, -1.073741760000000e+008f);
    shape.m_hasPrevVertex = bool(0);
    shape.m_hasNextVertex = bool(0);

    fd.shape = &shape;

    bodies[5]->CreateFixture(&fd);
  }
}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(0.000000000000000e+000f, 2.133333444595337e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[6] = m_world->CreateBody(&bd);

  {
    b2FixtureDef fd;
    fd.friction = 2.000000029802322e-001f;
    fd.restitution = 0.000000000000000e+000f;
    fd.density = 0.000000000000000e+000f;
    fd.isSensor = bool(0);
    fd.filter.categoryBits = uint16(2);
    fd.filter.maskBits = uint16(1272);
    fd.filter.groupIndex = int16(0);
    b2ChainShape shape;
    b2Vec2 vs[3];
    vs[0].Set(0.000000000000000e+000f, 0.000000000000000e+000f);
    vs[1].Set(2.770000076293945e+001f, 6.666667014360428e-002f);
    vs[2].Set(2.770000076293945e+001f, -2.066666603088379e+000f);
    shape.CreateChain(vs, 3);
    shape.m_prevVertex.Set(-1.073741760000000e+008f, -1.073741760000000e+008f);
    shape.m_nextVertex.Set(-1.073741760000000e+008f, -1.073741760000000e+008f);
    shape.m_hasPrevVertex = bool(0);
    shape.m_hasNextVertex = bool(0);

    fd.shape = &shape;

    bodies[6]->CreateFixture(&fd);
  }
}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(2.720000076293945e+001f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[7] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(2.613333320617676e+001f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[8] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(2.506666755676270e+001f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[9] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(2.400000000000000e+001f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[10] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(2.293333244323731e+001f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[11] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(2.186666679382324e+001f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[12] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(2.079999923706055e+001f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[13] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(1.973333358764648e+001f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[14] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(1.866666603088379e+001f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[15] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(1.760000038146973e+001f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[16] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(1.653333282470703e+001f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[17] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(1.546666622161865e+001f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[18] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(1.439999961853027e+001f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[19] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(1.333333301544190e+001f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[20] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(1.226666641235352e+001f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[21] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(1.119999980926514e+001f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[22] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(1.013333320617676e+001f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[23] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(9.066666603088379e+000f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[24] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(8.000000000000000e+000f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[25] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(6.933333396911621e+000f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[26] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(5.866666793823242e+000f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[27] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(4.800000190734863e+000f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[28] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(3.733333349227905e+000f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[29] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(2.666666746139526e+000f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[30] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(1.600000023841858e+000f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[31] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(5.333333611488342e-001f, 5.333333611488342e-001f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[32] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(2.720000076293945e+001f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[33] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(2.613333320617676e+001f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[34] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(2.506666755676270e+001f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[35] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(2.400000000000000e+001f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[36] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(2.293333244323731e+001f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[37] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(2.186666679382324e+001f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[38] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(2.079999923706055e+001f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[39] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(1.973333358764648e+001f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[40] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(1.866666603088379e+001f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[41] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(1.760000038146973e+001f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[42] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(1.653333282470703e+001f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[43] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(1.546666622161865e+001f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[44] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(1.439999961853027e+001f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[45] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(1.333333301544190e+001f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[46] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(1.226666641235352e+001f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[47] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(1.119999980926514e+001f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[48] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(1.013333320617676e+001f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[49] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(9.066666603088379e+000f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[50] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(8.000000000000000e+000f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[51] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(6.933333396911621e+000f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[52] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(5.866666793823242e+000f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[53] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(4.800000190734863e+000f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[54] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(3.733333349227905e+000f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[55] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(2.666666746139526e+000f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[56] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(1.600000023841858e+000f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[57] = m_world->CreateBody(&bd);

}
{
  b2BodyDef bd;
  bd.type = b2BodyType(0);
  bd.position.Set(5.333333611488342e-001f, 1.600000023841858e+000f);
  bd.angle = 0.000000000000000e+000f;
  bd.linearVelocity.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  bd.angularVelocity = 0.000000000000000e+000f;
  bd.linearDamping = 1.000000000000000e+000f;
  bd.angularDamping = 1.000000000000000e+000f;
  bd.allowSleep = bool(4);
  bd.awake = bool(2);
  bd.fixedRotation = bool(0);
  bd.bullet = bool(0);
  bd.active = bool(32);
  bd.gravityScale = 1.000000000000000e+000f;
  bodies[58] = m_world->CreateBody(&bd);

}
{
  b2RevoluteJointDef jd;
  jd.bodyA = bodies[2];
  jd.bodyB = bodies[0];
  jd.collideConnected = bool(0);
  jd.localAnchorA.Set(1.450000047683716e+000f, -1.079422950744629e+000f);
  jd.localAnchorB.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  jd.referenceAngle = 0.000000000000000e+000f;
  jd.enableLimit = bool(0);
  jd.lowerAngle = 0.000000000000000e+000f;
  jd.upperAngle = 0.000000000000000e+000f;
  jd.enableMotor = bool(1);
  jd.motorSpeed = 0.000000000000000e+000f;
  jd.maxMotorTorque = 0.000000000000000e+000f;
  joints[0] = m_world->CreateJoint(&jd);
}
{
  b2RevoluteJointDef jd;
  jd.bodyA = bodies[3];
  jd.bodyB = bodies[1];
  jd.collideConnected = bool(0);
  jd.localAnchorA.Set(-1.449999928474426e+000f, -1.079422950744629e+000f);
  jd.localAnchorB.Set(0.000000000000000e+000f, 0.000000000000000e+000f);
  jd.referenceAngle = 0.000000000000000e+000f;
  jd.enableLimit = bool(0);
  jd.lowerAngle = 0.000000000000000e+000f;
  jd.upperAngle = 0.000000000000000e+000f;
  jd.enableMotor = bool(1);
  jd.motorSpeed = 0.000000000000000e+000f;
  jd.maxMotorTorque = 0.000000000000000e+000f;
  joints[1] = m_world->CreateJoint(&jd);
}
{
  b2PrismaticJointDef jd;
  jd.bodyA = bodies[4];
  jd.bodyB = bodies[2];
  jd.collideConnected = bool(0);
  jd.localAnchorA.Set(1.299999952316284e+000f, -8.196153640747070e-001f);
  jd.localAnchorB.Set(1.299999952316284e+000f, -8.196153640747070e-001f);
  jd.localAxisA.Set(-4.999999701976776e-001f, 8.660254478454590e-001f);
  jd.referenceAngle = 0.000000000000000e+000f;
  jd.enableLimit = bool(1);
  jd.lowerTranslation = -3.000000119209290e-001f;
  jd.upperTranslation = 5.000000000000000e-001f;
  jd.enableMotor = bool(1);
  jd.motorSpeed = 0.000000000000000e+000f;
  jd.maxMotorForce = 0.000000000000000e+000f;
  joints[2] = m_world->CreateJoint(&jd);
}
{
  b2PrismaticJointDef jd;
  jd.bodyA = bodies[4];
  jd.bodyB = bodies[3];
  jd.collideConnected = bool(0);
  jd.localAnchorA.Set(-1.299999952316284e+000f, -8.196153640747070e-001f);
  jd.localAnchorB.Set(-1.299999952316284e+000f, -8.196153640747070e-001f);
  jd.localAxisA.Set(4.999999701976776e-001f, 8.660254478454590e-001f);
  jd.referenceAngle = 0.000000000000000e+000f;
  jd.enableLimit = bool(1);
  jd.lowerTranslation = -3.000000119209290e-001f;
  jd.upperTranslation = 5.000000000000000e-001f;
  jd.enableMotor = bool(1);
  jd.motorSpeed = 0.000000000000000e+000f;
  jd.maxMotorForce = 0.000000000000000e+000f;
  joints[3] = m_world->CreateJoint(&jd);
}
b2Free(joints);
b2Free(bodies);
joints = NULL;
bodies = NULL;
Correct me if I'm wrong but it looks ok until you 'drive' it....?
My first guess would be perhaps you are giving the motor speed in degrees when it should be radians.
It might help to also post the controlling code as well.
Thank you for your reply. The video doesn't make it so clear (unless you have been looking it compared to the flash site for some time) but even in the stationary pose the car looks to be under a lot more 'strain' (being pushed down and beginning to buckle) than the version on the Flash site. When you start driving the issues start to become a lot clearer, a lot quicker, but I don't actually think the fault is in the steering code. However, the reason I am posting here is that I don't know the answer, so I will gladly post my steering code in case it is actually causing problems.

Code:
bool Update( )
   {
      if ( ! m_Initialised )
         return false;

      bool left   = Pi.IO.Keyboard.IsKeyDown( PiKeyboard::LEFT );      // 37
      bool up      = Pi.IO.Keyboard.IsKeyDown( PiKeyboard::UP );      // 38
      bool right   = Pi.IO.Keyboard.IsKeyDown( PiKeyboard::RIGHT );   // 39
      bool down   = Pi.IO.Keyboard.IsKeyDown( PiKeyboard::DOWN );      // 40

      m_Motors[ 0 ]->SetMotorSpeed( 15.f * b2_pi * (down ? 1 : up ? -1 : 0));
      m_Motors[ 0 ]->SetMaxMotorTorque(down || up ? 17 : 0.5f);

      m_Motors[ 1 ]->SetMotorSpeed( 15.f * b2_pi * (down ? 1 : up ? -1 : 0));
      m_Motors[ 1 ]->SetMaxMotorTorque(down || up ? 12 : 0.5f);

      m_Springs[ 0 ]->SetMaxMotorForce( 30.f + fabs( 800.f * powf( m_Springs[ 0 ]->GetJointTranslation( ), 2.f ) ) );
      //spring1.SetMotorSpeed(-4*Math.pow(spring1.GetJointTranslation(), 1));
      m_Springs[ 0 ]->SetMotorSpeed( ( m_Springs[ 0 ]->GetMotorSpeed( ) - 10.f * m_Springs[ 0 ]->GetJointTranslation( ) ) * 0.4f );         

      m_Springs[ 1 ]->SetMaxMotorForce( 20.f + fabs( 800.f * powf( m_Springs[ 1 ]->GetJointTranslation( ), 2.f ) ) );
      m_Springs[ 1 ]->SetMotorSpeed( -4.f * powf( m_Springs[ 1 ]->GetJointTranslation( ), 1.f ) );

      m_Cart.GetBody( )->ApplyTorque( 30.f * ( left ? 1: right ? -1 : 0 ) );

      return true;
   }


Again, this code is just taken from the tutorial for now.

Thanks again,

Steve
I have just tried porting the second example into the Box2D test bed and it more or less works as expected, so it must just be an issue with something setting up in my custom simulator.

I'll look a little more into my new Box2D test, as it still doesn't quite behave correctly, but it is rather close, just feels like a parameter or two not being set right maybe (mistake when porting the Flash -> C++).

Steve
I suspect the settings for motor speed for the prismatic joints making up the 'springs' are incorrect. For starters they are different for each spring which seems odd - one of them is taking into account the current speed of the joint and the other is not. If you look in the comments on the original page it seems like you are not the only one having trouble like this.

To be honest I think the best advice would be to use wheel joints instead of the prismatic+revolute combo, since they're exactly what you are looking for and are considerably easier to set up and tweak. I would bet that if wheel joints existed when Emanuele did the tutorial, he would have used them instead. Look at the 'car' test for a basic example of using wheel joints.
Cool, just been looking at the car example, it is indeed of interest to me, thank you for pointing that out.

Below I have attached my two ports of the Flash code I originally linked to; the top down version seems to work correctly, and the side on one works reasonably, not exactly the same as the Flash version (don't know why) but maybe of interest to someone as reference (then again maybe not as the Car example in the test bed is probably better in most ways).

Top down

Code:
/*
* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
*
* This software is provided 'as-is', without any express or implied
* warranty.  In no event will the authors be held liable for any damages
* arising from the use of this software.
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/

#ifndef VEHICLE_H
#define VEHICLE_H

static const float   MAX_STEER_ANGLE         = b2_pi / 3.f;
static const float   STEER_SPEED            = 1.5f;
static const float   SIDEWAYS_FRICTION_FORCE   = 10.f;
static const float   HORSEPOWERS            = 100.f;   // Tweak: was 40.
static const b2Vec2   CAR_STARTING_POS      ( 10.0f,  10.0f );

class Vehicle : public Test
{
public:

   Vehicle( )
   : kLeftRearWheelPosition(  - 1.5f,   1.9f )
   , kRightRearWheelPosition(   1.5f,   1.9f )
   , kLeftFrontWheelPosition( - 1.5f, - 1.9f )
   , kRightFrontWheelPosition(  1.5f, - 1.9f )
   {   
      // TWEAK.
      m_world->SetGravity(b2Vec2(0.f, 0.f));

      // Initialise.
      m_EngineSpeed   = 0.f;
      m_SteeringAngle   = 0.f;

      //Create some static stuff
      b2BodyDef * staticDef = new b2BodyDef();
      staticDef->position.Set(5,20);
      b2PolygonShape * staticBox = new b2PolygonShape();
      staticBox->SetAsBox(5,5);
      m_world->CreateBody(staticDef)->CreateFixture(staticBox, 0.f);
      staticDef->position.x = 25;
      m_world->CreateBody(staticDef)->CreateFixture(staticBox, 0.f);
      staticDef->position.Set(15, 24);
      m_world->CreateBody(staticDef)->CreateFixture(staticBox, 0.f);

      // define our body
      b2BodyDef * bodyDef = new b2BodyDef();
      bodyDef->type = b2_dynamicBody;
      bodyDef->linearDamping = 1;
      bodyDef->angularDamping = 1;
      bodyDef->position = CAR_STARTING_POS;

      m_Body = m_world->CreateBody(bodyDef);
      // TODO:
      //body->SetMassFromShapes( );

      b2BodyDef * leftWheelDef = new b2BodyDef();
      leftWheelDef->type = b2_dynamicBody;
      leftWheelDef->position = CAR_STARTING_POS + kLeftFrontWheelPosition;
      m_LeftWheel = m_world->CreateBody(leftWheelDef);

      b2BodyDef * rightWheelDef = new b2BodyDef();
      rightWheelDef->type = b2_dynamicBody;
      rightWheelDef->position = CAR_STARTING_POS + kRightFrontWheelPosition;
      m_RightWheel = m_world->CreateBody(rightWheelDef);

      b2BodyDef * leftRearWheelDef = new b2BodyDef();
      leftRearWheelDef->type = b2_dynamicBody;
      leftRearWheelDef->position = CAR_STARTING_POS + kLeftRearWheelPosition;
      m_LeftRearWheel = m_world->CreateBody(leftRearWheelDef);

      b2BodyDef * rightRearWheelDef = new b2BodyDef();
      rightRearWheelDef->type = b2_dynamicBody;
      rightRearWheelDef->position = CAR_STARTING_POS + kRightRearWheelPosition;
      m_RightRearWheel = m_world->CreateBody(rightRearWheelDef);

      // define our shapes
      b2PolygonShape * boxDef = new b2PolygonShape();
      boxDef->SetAsBox(1.5f,2.5f);
      // TODO:
      //boxDef->density = 1;
      m_Body->CreateFixture(boxDef, 1.f);

      //Left Wheel shape
      b2PolygonShape * leftWheelShapeDef = new b2PolygonShape();
      leftWheelShapeDef->SetAsBox(0.2f,0.5f);
      // TODO:
      //leftWheelShapeDef->density = 1;
      m_LeftWheel->CreateFixture(leftWheelShapeDef, 1.f);

      //Right Wheel shape
      b2PolygonShape * rightWheelShapeDef = new b2PolygonShape();
      rightWheelShapeDef->SetAsBox(0.2f,0.5f);
      // TODO:
      //rightWheelShapeDef.density = 1;
      m_RightWheel->CreateFixture(rightWheelShapeDef, 1.f);

      //Left Wheel shape
      b2PolygonShape * leftRearWheelShapeDef = new b2PolygonShape();
      leftRearWheelShapeDef->SetAsBox(0.2f,0.5f);
      // TODO:
      //leftRearWheelShapeDef->density = 1;
      m_LeftRearWheel->CreateFixture(leftRearWheelShapeDef, 1.f);

      //Right Wheel shape
      b2PolygonShape * rightRearWheelShapeDef = new b2PolygonShape();
      rightRearWheelShapeDef->SetAsBox(0.2f,0.5f);
      /// TODO:
      //rightRearWheelShapeDef->density = 1;
      m_RightRearWheel->CreateFixture(rightRearWheelShapeDef, 1.f);

      // TODO:
      //body->SetMassFromShapes();
      //leftWheel->SetMassFromShapes();
      //rightWheel->SetMassFromShapes();
      //leftRearWheel->SetMassFromShapes();
      //rightRearWheel->SetMassFromShapes();

      b2RevoluteJointDef * leftJointDef = new b2RevoluteJointDef();
      leftJointDef->Initialize(m_Body, m_LeftWheel, m_LeftWheel->GetWorldCenter());
      leftJointDef->enableMotor = true;
      leftJointDef->maxMotorTorque = 100;

      b2RevoluteJointDef * rightJointDef = new b2RevoluteJointDef();
      rightJointDef->Initialize(m_Body, m_RightWheel, m_RightWheel->GetWorldCenter());
      rightJointDef->enableMotor = true;
      rightJointDef->maxMotorTorque = 100;

      m_LeftJoint = (b2RevoluteJoint*)m_world->CreateJoint(leftJointDef);
      m_RightJoint = (b2RevoluteJoint*)m_world->CreateJoint(rightJointDef);

      b2PrismaticJointDef * leftRearJointDef = new b2PrismaticJointDef();
      leftRearJointDef->Initialize(m_Body, m_LeftRearWheel, m_LeftRearWheel->GetWorldCenter(), b2Vec2(1,0));
      leftRearJointDef->enableLimit = true;
      leftRearJointDef->lowerTranslation = leftRearJointDef->upperTranslation = 0;

      b2PrismaticJointDef * rightRearJointDef = new b2PrismaticJointDef();
      rightRearJointDef->Initialize(m_Body, m_RightRearWheel, m_RightRearWheel->GetWorldCenter(), b2Vec2(1,0));
      rightRearJointDef->enableLimit = true;
      rightRearJointDef->lowerTranslation = rightRearJointDef->upperTranslation = 0;

      m_world->CreateJoint(leftRearJointDef);
      m_world->CreateJoint(rightRearJointDef);
   }

   void Keyboard(unsigned char key)
   {
      switch ( key )
      {
         case 'w':
         {
            m_Body->SetAwake( true );
            m_EngineSpeed = -HORSEPOWERS;
         }
         break;
         case 's':
         {
            m_EngineSpeed = HORSEPOWERS;
         }
         break;
         case 'a':
         {
            m_SteeringAngle = MAX_STEER_ANGLE;
         }
         break;
         case 'd':
         {
            m_SteeringAngle = -MAX_STEER_ANGLE;
         }
         break;
      }
   }

   void KeyboardUp(unsigned char key)
   {
      switch ( key )
      {
         case 'w':
         case 's':
         {
            m_EngineSpeed = 0.f;
         }
         break;

         case 'd':
         case 'a':
         {
            m_SteeringAngle = 0.f;
         }
         break;
      }
   }

   void KillOrthogonalVelocity2(b2Body * targetBody, float gripStrength)
   {
      b2Vec2 localPoint(0,0);
      b2Vec2 velocity = targetBody->GetLinearVelocityFromLocalPoint(localPoint);
      b2Vec2 sidewaysAxis = targetBody->GetTransform( ).q.GetYAxis( ); //.R.col2.v2;
      sidewaysAxis *= b2Dot( velocity, sidewaysAxis ); // stop sideways slide

      // if gripStrength is not 1, allow some sideways slip - mix zero sideways grip with full grip, using gripStrength
      b2Vec2 linearVelocity = sidewaysAxis;
      if ( gripStrength != 1.0f )
      {
         linearVelocity = ( gripStrength * sidewaysAxis ) + ((1.0f - gripStrength) * velocity);
      }
      targetBody->SetLinearVelocity( linearVelocity );
   }

   void KillOrthogonalVelocity(b2Body * targetBody)
   {
      b2Vec2 localPoint(0,0);
      b2Vec2 velocity = targetBody->GetLinearVelocityFromLocalPoint(localPoint);

      b2Vec2 sidewaysAxis = targetBody->GetTransform().q.GetYAxis();// GetXForm().R.col2.Copy();
      sidewaysAxis *= b2Dot(velocity, sidewaysAxis);

      // Allow some slide...
      //sidewaysAxis += 0.75f * ( velocity - sidewaysAxis );

      targetBody->SetLinearVelocity(sidewaysAxis);//targetBody.GetWorldPoint(localPoint));
   }

   void Step(Settings* settings)
   {
      Test::Step(settings);

#if 0
      KillOrthogonalVelocity( m_LeftWheel );
      KillOrthogonalVelocity( m_RightWheel );
      KillOrthogonalVelocity( m_LeftRearWheel );
      KillOrthogonalVelocity( m_RightRearWheel );
#else
      float grip = m_LeftWheel->GetLinearVelocity( ).Length( );

      grip = std::min( grip, 15.f );

      grip = grip / 15.f;

      grip = 1.f - grip;

      grip = std::max( grip, 0.3f );

      m_debugDraw.DrawString(5, m_textLine, "Grip : %3.2f", grip);

      KillOrthogonalVelocity2( m_LeftWheel, grip );
      KillOrthogonalVelocity2( m_RightWheel, grip );
      KillOrthogonalVelocity2( m_LeftRearWheel, grip );
      KillOrthogonalVelocity2( m_RightRearWheel, grip );
#endif

      //Driving
      b2Vec2 ldirection = m_LeftWheel->GetTransform().q.GetYAxis();// ->GetXForm().R.col2;
      ldirection *= m_EngineSpeed;
      b2Vec2 rdirection = m_RightWheel->GetTransform().q.GetYAxis();//->GetXForm().R.col2;
      rdirection *= m_EngineSpeed;

      m_LeftWheel->ApplyForce(ldirection, m_LeftWheel->GetPosition());
      m_RightWheel->ApplyForce(rdirection, m_RightWheel->GetPosition());

      //Steering
      float mspeed;
      mspeed = m_SteeringAngle - m_LeftJoint->GetJointAngle();
      m_LeftJoint->SetMotorSpeed(mspeed * STEER_SPEED);
      mspeed = m_SteeringAngle - m_RightJoint->GetJointAngle();
      m_RightJoint->SetMotorSpeed(mspeed * STEER_SPEED);

      // Update camera.
      settings->viewCenter.x = m_Body->GetPosition().x;
   }

   static Test* Create()
   {
      return new Vehicle;
   }

private:

   b2Body *   m_Body;

   b2Body *   m_LeftWheel;
   b2Body *   m_RightWheel;
   b2Body *   m_LeftRearWheel;
   b2Body *   m_RightRearWheel;

   b2RevoluteJoint *   m_LeftJoint;
   b2RevoluteJoint *   m_RightJoint;

   float m_EngineSpeed;
   float m_SteeringAngle;

   const b2Vec2   kLeftRearWheelPosition;
   const b2Vec2   kRightRearWheelPosition;
   const b2Vec2   kLeftFrontWheelPosition;
   const b2Vec2   kRightFrontWheelPosition;
};

#endif


Side on

Code:
/*
* Copyright (c) 2006-2009 Erin Catto http://www.box2d.org
*
* This software is provided 'as-is', without any express or implied
* warranty.  In no event will the authors be held liable for any damages
* arising from the use of this software.
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/

#ifndef VEHICLESIDEON_H
#define VEHICLESIDEON_H

static const float   VEHICLE_SIDE_ON_MAX_STEER_ANGLE   = b2_pi / 3.f;
static const float   VEHICLE_SIDE_STEER_SPEED      = 1.5f;
static const float   VEHICLE_SIDEWAYS_FRICTION_FORCE   = 10.f;
static const float   VEHICLE_HORSEPOWERS            = 100.f;   // Tweak: was 40.
static const b2Vec2   VEHICLE_CAR_STARTING_POS      ( 10.0f,  10.0f );

class VehicleSideOn : public Test
{
public:

   VehicleSideOn( )
   : m_Cart( NULL )
   {   
      m_Axles[ 0 ] = NULL;
      m_Axles[ 1 ] = NULL;
      m_Wheels[ 0 ] = NULL;
      m_Wheels[ 1 ] = NULL;
      m_Springs[ 0 ] = NULL;
      m_Springs[ 1 ] = NULL;
      m_Motors[ 0 ] = NULL;
      m_Motors[ 1 ] = NULL;

      m_Up   = false;
      m_Down   = false;
      m_Left   = false;
      m_Right   = false;

      // Gravity.
      m_world->SetGravity( b2Vec2( 0.f, -10.f ) );

      // Add the ground.
      {
         b2BodyDef bodyDef;
         bodyDef.position.Set( 0.f, 0.5f );
         b2Body * body = m_world->CreateBody( &bodyDef );

         b2PolygonShape boxDef;
         boxDef.SetAsBox( 50.f, 0.5f );

         b2Fixture * pFixture = body->CreateFixture( &boxDef, 0.f );
         pFixture->SetFriction( 1.f );

         boxDef.SetAsBox( 1.f, 2.f, b2Vec2( -50.f, 0.5f ), 0.f );
         pFixture = body->CreateFixture( &boxDef, 0.f );
         pFixture->SetFriction( 1.f );

         boxDef.SetAsBox( 1.f, 2.f, b2Vec2( 50.f, 0.5f ), 0.f );
         pFixture = body->CreateFixture( &boxDef, 0.f );
         pFixture->SetFriction( 1.f );

         boxDef.SetAsBox( 3.f, 0.5f, b2Vec2( 5.f, 1.5f ), b2_pi / 4.f );
         pFixture = body->CreateFixture( &boxDef, 0.f );
         pFixture->SetFriction( 1.f );

         boxDef.SetAsBox( 3.f, 0.5f, b2Vec2( 3.5f, 1.f ), b2_pi / 8.f );
         pFixture = body->CreateFixture( &boxDef, 0.f );
         pFixture->SetFriction( 1.f );

         boxDef.SetAsBox( 3.f, 0.5f, b2Vec2( 9.f, 1.5f ), -b2_pi / 4.f );
         pFixture = body->CreateFixture( &boxDef, 0.f );
         pFixture->SetFriction( 1.f );

         boxDef.SetAsBox( 3.f, 0.5f, b2Vec2( 10.5f, 1.f ), -b2_pi / 8.f );
         pFixture = body->CreateFixture( &boxDef, 0.f );
         pFixture->SetFriction( 1.f );
      }

      // Add random rubble on ground.
      {
         b2CircleShape circleDef;

         for ( int i = 0; i < 30; i++ )
         {
            circleDef.m_radius = ( ( rand( ) % 100 ) / 100.f ) / 20.f + 0.02f;

            b2BodyDef bodyDef;
            bodyDef.type = b2_dynamicBody;
            bodyDef.position.Set( ( float )( rand( ) % 35 + 15 ), 1.f );
            bodyDef.allowSleep = true;
            bodyDef.linearDamping = 0.1f;
            bodyDef.angularDamping = 0.1f;

            b2Body * body = m_world->CreateBody( &bodyDef );

            b2Fixture * pFixture = body->CreateFixture( &circleDef, 0.01f );
            pFixture->SetFriction( 0.1f );
            pFixture->SetRestitution( 0.5f );
         }
      }

      // Add m_Cart.
      {
         b2BodyDef bodyDef;
         bodyDef.type = b2_dynamicBody;
         bodyDef.position.Set( 0.f, 3.5f );

         m_Cart = m_world->CreateBody( &bodyDef );

         b2PolygonShape boxDef;

         boxDef.SetAsBox( 1.5f, 0.3f );
         b2Fixture * pFixture = m_Cart->CreateFixture( &boxDef, 2.f );
         pFixture->SetFriction( 0.5f );
         pFixture->SetRestitution( 0.2f );
         b2Filter filter = pFixture->GetFilterData( );
         filter.groupIndex = -1;
         pFixture->SetFilterData( filter );

         boxDef.SetAsBox( 0.4f, 0.15f, b2Vec2( -1.f, -0.3f ), b2_pi / 3.f );
         pFixture = m_Cart->CreateFixture( &boxDef, 2.f );
         pFixture->SetFriction( 0.5f );
         pFixture->SetRestitution( 0.2f );
         filter = pFixture->GetFilterData( );
         filter.groupIndex = -1;
         pFixture->SetFilterData( filter );

         boxDef.SetAsBox( 0.4f, 0.15f, b2Vec2( 1.f, -0.3f ), -b2_pi / 3.f );
         pFixture = m_Cart->CreateFixture( &boxDef, 2.f );
         pFixture->SetFriction( 0.5f );
         pFixture->SetRestitution( 0.2f );
         filter = pFixture->GetFilterData( );
         filter.groupIndex = -1;
         pFixture->SetFilterData( filter );
      }

      // Add the axles.
      {
         b2BodyDef bodyDef;
         bodyDef.type = b2_dynamicBody;
         bodyDef.position.Set( 0.f, 3.5f );

         m_Axles[ 0 ] = m_world->CreateBody( &bodyDef );

         b2PolygonShape boxDef;
         boxDef.SetAsBox( 0.4f, 0.1f, b2Vec2( -1.f - 0.6f * cosf( b2_pi / 3.f ), -0.3f - 0.6f * sinf( b2_pi / 3.f ) ), b2_pi / 3.f );
         b2Fixture * pFixture = m_Axles[ 0 ]->CreateFixture( &boxDef, 1.f );
         pFixture->SetFriction( 0.5f );
         pFixture->SetRestitution( 0.2f );
         b2Filter filter = pFixture->GetFilterData( );
         filter.groupIndex = -1;
         pFixture->SetFilterData( filter );


         b2PrismaticJointDef prismaticJointDef;
         prismaticJointDef.Initialize( m_Cart, m_Axles[ 0 ], m_Axles[ 0 ]->GetWorldCenter( ), b2Vec2( cosf( b2_pi / 3.f ), sinf( b2_pi / 3.f ) ) );
         prismaticJointDef.lowerTranslation = -0.3f;
         prismaticJointDef.upperTranslation = 0.5f;
         prismaticJointDef.enableLimit = true;
         prismaticJointDef.enableMotor = true;

         m_Springs[ 0 ] = ( b2PrismaticJoint *)m_world->CreateJoint( &prismaticJointDef );

         // --

         m_Axles[ 1 ] = m_world->CreateBody( &bodyDef );

         boxDef.SetAsBox( 0.4f, 0.1f, b2Vec2( 1.f + 0.6f * cosf( -b2_pi / 3.f ), -0.3f + 0.6f * sinf( -b2_pi / 3.f ) ), -b2_pi / 3.f );
         pFixture = m_Axles[ 1 ]->CreateFixture( &boxDef, 1.f );
         pFixture->SetFriction( 0.5f );
         pFixture->SetRestitution( 0.2f );
         filter = pFixture->GetFilterData( );
         filter.groupIndex = -1;
         pFixture->SetFilterData( filter );

         prismaticJointDef.Initialize( m_Cart, m_Axles[ 1 ], m_Axles[ 1 ]->GetWorldCenter( ), b2Vec2( -cosf( b2_pi / 3.f ), sinf( b2_pi / 3.f ) ) );

         m_Springs[ 1 ] = ( b2PrismaticJoint *)m_world->CreateJoint( &prismaticJointDef );
      }

      // Add wheels.
      {
         b2CircleShape circleDef;
         circleDef.m_radius = 0.7f;

         for ( int i = 0; i < 2; i++ )
         {
            b2BodyDef bodyDef;
            bodyDef.type = b2_dynamicBody;
            if ( i == 0 )
               bodyDef.position.Set( m_Axles[ 0 ]->GetWorldCenter( ).x - 0.3f * cosf( b2_pi/3.f), m_Axles[ 0 ]->GetWorldCenter( ).y - 0.3f * sinf( b2_pi / 3.f ) );
            else
               bodyDef.position.Set( m_Axles[ 1 ]->GetWorldCenter( ).x + 0.3f * cosf(-b2_pi/3.f), m_Axles[ 1 ]->GetWorldCenter( ).y + 0.3f * sinf(-b2_pi / 3.f ) );
            
            bodyDef.allowSleep = false;

            b2Body * & wheel = ( i == 0 ) ? m_Wheels[ 0 ] : m_Wheels[ 1 ];

            wheel = m_world->CreateBody( &bodyDef );

            b2Fixture * pFixture = wheel->CreateFixture( &circleDef, 0.1f );
            pFixture->SetFriction( 5.f );
            pFixture->SetRestitution( 0.2f );
            b2Filter filter = pFixture->GetFilterData( );
            filter.groupIndex = -1;
            pFixture->SetFilterData( filter );
         }
      }

      // Add joints.
      b2RevoluteJointDef revoluteJointDef;
      revoluteJointDef.enableMotor = true;

      revoluteJointDef.Initialize( m_Axles[ 0 ], m_Wheels[ 0 ], m_Wheels[ 0 ]->GetWorldCenter( ) );
      m_Motors[ 0 ] = ( b2RevoluteJoint *) m_world->CreateJoint( &revoluteJointDef );

      revoluteJointDef.Initialize( m_Axles[ 1 ], m_Wheels[ 1 ], m_Wheels[ 1 ]->GetWorldCenter( ) );
      m_Motors[ 1 ] = ( b2RevoluteJoint *) m_world->CreateJoint( &revoluteJointDef );
   }

   void Keyboard(unsigned char key)
   {
      switch ( key )
      {
         case 'w':
            m_Up = true;
            break;
         case 's':
            m_Down = true;
            break;
         case 'a':
            m_Left = true;
            break;
         case 'd':
            m_Right = true;
            break;
      }
   }

   void KeyboardUp(unsigned char key)
   {
      switch ( key )
      {
         case 'w':
            m_Up = false;
            break;
         case 's':
            m_Down = false;
            break;
         case 'a':
            m_Left = false;
            break;
         case 'd':
            m_Right = false;
            break;
      }
   }


   void Step(Settings* settings)
   {
      m_Motors[ 0 ]->SetMotorSpeed( 15.f * b2_pi * ( m_Down ? 1 : m_Up ? -1 : 0 ) );
      m_Motors[ 0 ]->SetMaxMotorTorque( m_Down || m_Up ? 17.f : 0.5f );

      m_Motors[ 1 ]->SetMotorSpeed( 15.f * b2_pi * ( m_Down ? 1 : m_Up ? -1 : 0 ) );
      m_Motors[ 1 ]->SetMaxMotorTorque( m_Down || m_Up ? 12.f : 0.5f );

      m_Springs[ 0 ]->SetMaxMotorForce( 30.f + fabs( 800.f * powf( m_Springs[ 0 ]->GetJointTranslation( ), 2.f ) ) );
      //m_Springs[ 0 ]->SetMotorSpeed(-4*powf(m_Springs[ 0 ]->GetJointTranslation(), 1));
      m_Springs[ 0 ]->SetMotorSpeed( ( m_Springs[ 0 ]->GetMotorSpeed( ) - 10.f * m_Springs[ 0 ]->GetJointTranslation( ) ) * 0.4f );         

      m_Springs[ 1 ]->SetMaxMotorForce( 20.f + fabs( 800.f * powf( m_Springs[ 1 ]->GetJointTranslation( ), 2.f ) ) );
      m_Springs[ 1 ]->SetMotorSpeed( -4.f * powf( m_Springs[ 1 ]->GetJointTranslation( ), 1.f ) );

      m_Cart->ApplyTorque( 30.f * ( m_Left ? 1 : m_Right ? -1 : 0 ) );

      // Update camera.
      settings->viewCenter.x = m_Cart->GetPosition( ).x;

      Test::Step( settings );
   }

   static Test* Create()
   {
      return new VehicleSideOn;
   }

private:
   b2Body *         m_Cart;
   b2Body *         m_Axles[ 2 ];
   b2Body *         m_Wheels[ 2 ];
   b2PrismaticJoint *   m_Springs[ 2 ];
   b2RevoluteJoint *   m_Motors[ 2 ];

   bool            m_Up;
   bool            m_Down;
   bool            m_Left;
   bool            m_Right;
};

#endif


If anyone has any questions, then feel free to post, but it is unlikely I will have an answer! 😮)

Steve

Original thread: https://box2d.org/forum/viewtopic.php?t=7663