# Building a shape out of two rectangles

I would like to build a body with Farseer out of two rectangles so it looks like this:

I am a real beginner, so please describe it carefully.

-
I tried to make the shape out of the texture, but this hasen't worked. But I think the shape is not so complex, so I asked if it is possible to make this with 2 rectange. Making one big rectange works well, but the collision isn't very well, though the corners – Michael Jun 6 '12 at 14:14
What version of Farseer are you using? – Richard Marskell - Drackir Jun 6 '12 at 15:00
The newest: 3.3.1 – Michael Jun 6 '12 at 15:17
Create two rectangle fixtures, and attach them to the same body. One of the fixtures will have a rotation of 90 degrees, in respect to the other fixture. – Jon Jun 6 '12 at 16:20
how do you do this? I haven't found this in the Farseers Documentation. – Michael Jun 6 '12 at 16:35

There are two ways you can do this:

1. With Fixtures
I recommend doing it this way as it's much easier to manage. Here's the code with comments:

``````//Create the initial body + 1 fixture in the shape of a rectangle
// The fixture is 2 world units wide and 1 world unit high
Body body = BodyFactory.CreateRectangle(world, 2, 1, density);
//Create a new fixture on the body.
body.CreateFixture(
//The new fixture is a PolygonShape (CreateFixture accepts a Shape parameter)
new PolygonShape(
//This method returns a list of vertices which represent the shape of the fixture.
//  Note the parameters are HALF width/height and that we've set
//  it up so it's already "rotated".
PolygonTools.CreateRectangle(0.5f, 1)
, density));
//Set up body data
body.BodyType = BodyType.Dynamic;
//Etc...
``````

Note: I've spanned some lines in order to explain what's going on, you obviously don't need to do this.

2. With Bodies
You should also be able to weld two bodies together like this:

``````//Create the first body with a width of 3 and height of 1
Body part1 = BodyFactory.CreateRectangle(world, 3, 1, density);
//Create the second body
Body part2 = BodyFactory.CreateRectangle(world, 3, 1, density);
//Rotate the body by pi / 2 radians (90 degrees)
part2.Rotation = MathHelper.PiOver2;
//Use a weld joint to stick them together
JointFactory.CreateWeldJoint(world, part1, part2, Vector2.Zero, Vector2.Zero)
``````
-

You should be able to create a Body with 2 Fixtures attached if Farseer follows what Box2D does.

I've never used Farseer but the following is what can be done in Box2D and there should be something similar in Farseer:

Create 2 PolygonShapes using function below

``````void SetAsBox(float32 hx, float32 hy); //default centers each fixture at center of body
``````

For example `tallRect` and `wideRect` are PolygonShapes

``````tallRect.SetAsBox(1,2);
wideRect.SetAsBox(2,1);
``````

Create two Fixtures, one for each shape and attach both shapes to your Body using

``````myBody.CreateFixture(a);
myBody.CreateFixture(b);
``````

I created something like this:

-