Hello, I think, that I am new in here. How can I create multiple fixture of a 3 rectangles ?
Is this correct ?
b2BodyDef bd;
bd.type = b2_dynamicBody;
b2Body* body = m_world->CreateBody(&bd);
b2FixtureDef fd;
fd.shape = &circleShape;
fd.density = 1;
b2PolygonShape polygonShape;
fd.shape = &polygonShape;
polygonShape.SetAsBox( 1, 1 ); // create first rectangle at 0,0, width 2, height 2
body->CreateFixture(&fd);
polygonShape.SetAsBox( 1, 1 ); // create second rectangle at 0,0; width 2, height 2
polygonShape.centroid = -1, 0; // move rectangle center to -1,0
body->CreateFixture(&fd); // create fixture with the first rectangle
polygonShape.SetAsBox( 1, 1 ); // create second rectangle at 0,0; width 2, height 2
polygonShape.centroid = +1, 0; // move rectangle center to +1,0
body->CreateFixture(&fd); // create fixture with the first rectangle
Is this correct ?
b2BodyDef bd;
bd.type = b2_dynamicBody;
b2Body* body = m_world->CreateBody(&bd);
b2FixtureDef fd;
fd.shape = &circleShape;
fd.density = 1;
b2PolygonShape polygonShape;
fd.shape = &polygonShape;
polygonShape.SetAsBox( 1, 1 ); // create first rectangle at 0,0, width 2, height 2
body->CreateFixture(&fd);
polygonShape.SetAsBox( 1, 1 ); // create second rectangle at 0,0; width 2, height 2
polygonShape.centroid = -1, 0; // move rectangle center to -1,0
body->CreateFixture(&fd); // create fixture with the first rectangle
polygonShape.SetAsBox( 1, 1 ); // create second rectangle at 0,0; width 2, height 2
polygonShape.centroid = +1, 0; // move rectangle center to +1,0
body->CreateFixture(&fd); // create fixture with the first rectangle