This project has moved and is read-only. For the latest updates, please go here.

# How do I create body for irregular 2D objects

 Topics: Developer Forum, User Forum Wiki Link: [discussion:270355]
 emwhytee Aug 25, 2011 at 12:35 PM Edited Aug 25, 2011 at 1:03 PM Im trying to create a body of a 2D sprite that is irregular using Farseer 3.3.1. Do I have to create set of vertices to create the shape? And then which function would work, BodyFactory.CreateCompoundPolygon or BodyFactory.CreatePolygon? HellGate Aug 25, 2011 at 5:44 PM take a look at this: http://farseerphysics.codeplex.com/discussions/254993 emwhytee Aug 25, 2011 at 9:24 PM Edited Aug 25, 2011 at 9:27 PM Thanks Hellgate, I looked at the discussion and the farseer samples provided and did that Now I'm having the following problem. http://pic.twitter.com/UUZXyBQ Here is the code     ```basketTexture = Content.Load(@"Textures\bucket"); // data from texture uint[] data = new uint[basketTexture.Width * basketTexture.Height]; // Transfer the texture data to array basketTexture.GetData(data); // Find the vertices Vertices textureVertices = PolygonTools.CreatePolygon(data, basketTexture.Width, false); Vector2 centroid = -textureVertices.GetCentroid(); textureVertices.Translate(ref centroid); basketOrigin = -centroid; textureVertices = SimplifyTools.ReduceByDistance(textureVertices, 4f); List list = BayazitDecomposer.ConvexPartition(textureVertices); //scale the vertices from graphics space to sim space Vector2 vertScale = new Vector2(ConvertUnits.ToSimUnits(1)) * _scale; foreach (Vertices vertices in list) { vertices.Scale(ref vertScale); } //Create a single body with multiple fixtures _compound = BodyFactory.CreateCompoundPolygon(world, list, 1f, BodyType.Dynamic); _compound.BodyType = BodyType.Dynamic; ``` HellGate Aug 26, 2011 at 9:56 AM where at your code does the error apper? i think here: Vertices textureVertices = PolygonTools.CreatePolygon(data, basketTexture.Width, false); emwhytee Aug 26, 2011 at 11:05 AM ```This line causes the problem _compound = BodyFactory.CreateCompoundPolygon(world, list, 1f, BodyType.Dynamic);``` emwhytee Aug 26, 2011 at 12:20 PM Ah I solved the problem. scale was set to 0. Now how would i get to collide the object with other body object. It other body just seems to go through it. And Applying force on this body makes it rotate rather move in particular directions HellGate Aug 27, 2011 at 11:57 AM emwhytee wrote: Ah I solved the problem. scale was set to 0. Now how would i get to collide the object with other body object. It other body just seems to go through it. And Applying force on this body makes it rotate rather move in particular directions applying a force at the origin can't cause a rotation! and may check the collision category