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

Apply texture to polygon help!

Topics: Developer Forum, Project Management Forum, User Forum
Mar 16, 2011 at 3:43 AM
Edited Mar 16, 2011 at 3:47 AM

Hello, i am beginner programer with farseer but, i have followed a tutorial relative to transform a Texture2D to a Polygon.

I successfully created the polygon but i want to keep the original texture in the Polygon, and not a material.

I used this example:


public static List<Fixture> addTxtToWorld(World w, ContentManager content, String txtName, object mat, Vector2 pos,Vector2 scale)
            Texture2D txt = content.Load<Texture2D>(txtName);
            uint[] data = new uint[txt.Width * txt.Height];
            Vertices verts = PolygonTools.CreatePolygon(data, txt.Width, txt.Height, true);
            verts.Scale(ref scale);
            List<Vertices> _list = BayazitDecomposer.ConvexPartition(verts);
            List<Fixture> compund = FixtureFactory.CreateCompoundPolygon(w, _list, 1, pos, mat);
            compund[0].Body.BodyType = BodyType.Dynamic;
            return compund;


I have tried unsuccessfully apply a Debug material of the current texture but it doesn't work, instead of a polygon filled with the all texture i get a polygon with a lot of tiny repeats of the texture.

I hava tried several ways but i can't understand who the fixture get its texture.

Tanks for the help, sry for my poor english.