DetectVertices, texture to Polygon nightmare

Topics: Developer Forum, User Forum
Mar 2, 2011 at 3:42 PM

Hi,

I try to make a single fixture from a Texture2D to make it clickable (with World.TextPoint) and movable, I'm working on it since many hours. Is it really possible to do it ? Why all the methods I try to test have failed ?? (area not detected on click or assert errors)

            #region textureConverter

            uint[] data = new uint[texture.Width * texture.Height];
            texture.GetData(data);
            Vertices vertices = TextureConverter.DetectVertices(
                data,
                texture.Width,
                texture.Height);

            Vector2 scale = new Vector2(0.01f);
            vertices.Scale(ref scale);

            List<Vertices> list = BayazitDecomposer.ConvexPartition(vertices);


            //rectangle = FixtureFactory.CreateLoopShape(
            //    world,
            //    vertices,
            //    1,
            //    Vector2.Zero);


            //rectangle = FixtureFactory.CreatePolygon(
            //    world,
            //    vertices,
            //    1,
            //    Vector2.Zero
            //    );

            //List<Fixture> final = FixtureFactory.CreateCompoundPolygon(
            //    world,
            //    list,
            //    1f,
            //    Vector2.Zero);


            #endregion
Does somebody know a good method to do it in farseer 3.2 ? :s Thanks in advance :)
Mar 4, 2011 at 3:54 PM

nobody can help me ? :(

Coordinator
Mar 4, 2011 at 9:12 PM

The samples shows you how to do it. Check out the TextureVerticesTest from the Testbed project