circleBudy.Position dont change position

Topics: Developer Forum, User Forum
Sep 7, 2012 at 9:18 PM

Hi, im doing something whit farseer and W8 i have this code to create the circle shape, but dont move, nay missing step.

 

 _world = new FarseerPhysics.Dynamics.World( xna.Vector2.Zero);

Vertices circle = PolygonTools.CreateCircle(50, 25);
List<Vertices> _listaCirculo = new List<Vertices>();
 _listaCirculo.Add(circle);

Body circleBudy = BodyFactory.CreateCompoundPolygon(_world, _listaCirculo, 1, new xna.Vector2(10,10));
circleBudy.BodyType = BodyType.Dynamic;
circleBudy.Position = new xna.Vector2(200, 200);

and using this code for draw the circle whit SharpDX

foreach (Fixture fixture in circleBudy.FixtureList)
{
  PolygonShape pol = (PolygonShape)fixture.Shape;
  DrawingPointF pointStart;
  DrawingPointF pointEnd;
       for (int i = 0; i < pol.Vertices.Count; i++)
       {
            pointStart.X = pol.Vertices[i].X;
            pointStart.Y = pol.Vertices[i].Y;
            if (i == (pol.Vertices.Count - 1))
            {
               pointEnd.X = pol.Vertices[0].X;
               pointEnd.Y = pol.Vertices[0].Y;
            }else
            {
               pointEnd.X = pol.Vertices[i + 1].X;
               pointEnd.Y = pol.Vertices[i + 1].Y;
            }
        deviceContext.DrawLine(pointStart, pointEnd, brush);
       }
}

Sep 8, 2012 at 10:31 AM

http://box2d.org/2012/03/shape-coordinates/

The vertices of a shape are in local coordinates. You should apply the body transform to them before drawing. See the DebugViewXNA for an example.