圈出顶点

时间:2015-07-15 14:31:10

标签: c# polygon geometry farseer

我想在Farseer中使用Vertices创建一个圆圈:

Vertices circleVertices = PolygonTools.CreateCircle(ConvertUnits.ToSimUnits(96), 10);

如您所见,半径为96像素,并且有10条边。到目前为止没问题!
接下来我想显示它(在DebugViewXNA的帮助下):

Body circleBody = BodyFactory.CreatePolygon(_world, circleVertices, 1f);
circleBody.BodyType = BodyType.Static;

现在我收到一个断言错误:

   at FarseerPhysics.Collision.Shapes.PolygonShape.set_Vertices(Vertices value) in d:\Dateien\Downloads\Farseer Physics Engine 3.5 HelloWorld\Farseer Physics Engine 3.5 HelloWorld\Farseer Physics Engine 3.5\Collision\Shapes\PolygonShape.cs:line 90.
   at FarseerPhysics.Collision.Shapes.PolygonShape..ctor(Vertices vertices, Single density) in d:\Dateien\Downloads\Farseer Physics Engine 3.5 HelloWorld\Farseer Physics Engine 3.5 HelloWorld\Farseer Physics Engine 3.5\Collision\Shapes\PolygonShape.cs:line 50.
   at FarseerPhysics.Factories.FixtureFactory.AttachPolygon(Vertices vertices, Single density, Body body, Object userData) in d:\Dateien\Downloads\Farseer Physics Engine 3.5 HelloWorld\Farseer Physics Engine 3.5 HelloWorld\Farseer Physics Engine 3.5\Factories\FixtureFactory.cs:line 66.
   at FarseerPhysics.Factories.BodyFactory.CreatePolygon(World world, Vertices vertices, Single density, Vector2 position, Object userData) in d:\Dateien\Downloads\Farseer Physics Engine 3.5 HelloWorld\Farseer Physics Engine 3.5 HelloWorld\Farseer Physics Engine 3.5\Factories\BodyFactory.cs:line 112.
   at FarseerPhysics.Factories.BodyFactory.CreatePolygon(World world, Vertices vertices, Single density, Object userData) in d:\Dateien\Downloads\Farseer Physics Engine 3.5 HelloWorld\Farseer Physics Engine 3.5 HelloWorld\Farseer Physics Engine 3.5\Factories\BodyFactory.cs:line 106.
   at FarseerPhysics.Samples.Game1.LoadContent() in d:\Dateien\Downloads\Farseer Physics Engine 3.5 HelloWorld\Farseer Physics Engine 3.5 HelloWorld\Farseer Physics HelloWorld 3.5\Game1.cs:line 124.
   at Microsoft.Xna.Framework.Game.Initialize()
   at Microsoft.Xna.Framework.Game.RunGame(Boolean useBlockingRun)
   at Microsoft.Xna.Framework.Game.Run()

我对Vertices定义的矩形做了同样的事情:

Vertices groundVertices = new Vertices();
groundVertices.Add(new Vector2(0, 5));
groundVertices.Add(new Vector2(ConvertUnits.ToSimUnits(800), 5));
groundVertices.Add(new Vector2(ConvertUnits.ToSimUnits(800), ConvertUnits.ToSimUnits(480)));
groundVertices.Add(new Vector2(0, ConvertUnits.ToSimUnits(480)));

Body groundBody = BodyFactory.CreatePolygon(_world, groundVertices, 1f);
groundBody.BodyType = BodyType.Static;

这从来没有出现过问题 为什么圈子也无法运作?

0 个答案:

没有答案