C# XNA Farseer物理问题

C# XNA Farseer物理问题,c#,xna,physics,farseer,C#,Xna,Physics,Farseer,因此,我有一个游戏对象,通过从文件加载纹理并将其转换来创建实体: Texture2D polygonTexture = Texture2D.FromStream(Game.graphicsDevice, File.OpenRead(filepath)); uint[] data = new uint[polygonTexture.Width * polygonTexture.Height]; polygonTexture.G

因此,我有一个游戏对象,通过从文件加载纹理并将其转换来创建实体:

            Texture2D polygonTexture = Texture2D.FromStream(Game.graphicsDevice, File.OpenRead(filepath));
            uint[] data = new uint[polygonTexture.Width * polygonTexture.Height];
            polygonTexture.GetData(data);

            //convert it to a polygon
            Vertices textureVertices = PolygonTools.CreatePolygon(data, polygonTexture.Width, false);
            Vector2 centroid = -textureVertices.GetCentroid();
            textureVertices.Translate(ref centroid);
            Vector2 origin = -centroid;
            textureVertices = SimplifyTools.ReduceByDistance(textureVertices, 4f);
            List<Vertices> list = BayazitDecomposer.ConvexPartition(textureVertices);
            Vector2 vertScale = new Vector2(ConvertUnits.ToSimUnits(1));
            foreach (Vertices vertices in list)
            {
                vertices.Scale(ref vertScale);
            }

            //creat the body from the verticies
            Body compound = BodyFactory.CreateCompoundPolygon(Game.world, list, 1f, BodyType.Dynamic);
            compound.BodyType = BodyType.Dynamic;

            //set the object's verticies to the polygon and the texture to its image
            obj.body = compound;

图像根本没有显示出来。我做错了什么?

我强烈建议您打开Farseer版本中包含的DebugView。它将使您更好地了解代码的运行情况。Farseer完全独立于图形代码。
    GraphicsDevice.Clear(bgColor);
    spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null,     null, null, camera2D.get_transformation(graphicsDevice));

    obj.body.Position = new Vector2(0, 0);
    spriteBatch.Draw(polygonTexture,
    ConvertUnits.ToDisplayUnits(obj.body.Position),
                        null,
                        obj.tint,
                        obj.body.Rotation,
                        Vector2.Zero, 1f,
                        SpriteEffects.None,
                        obj.layer);

            spriteBatch.End();