I managed to create a shape from a texture, but the shape seems to be flipped horizotally... It's upside down...
What am i doing wrong??
Thx for the help!
This is my code:
//load texture that will represent the physics body
_polygonTexture = contentManager.Load<Texture2D>("Texture");
//Create an array to hold the data from the texture
uint data = new uint[_polygonTexture.Width * _polygonTexture.Height];
//Transfer the texture data to the array
//Find the vertices that makes up the outline of the shape in the texture
_verts = PolygonTools.CreatePolygon(data, _polygonTexture.Width, false);
//Since it is a concave polygon, we need to partition it into several smaller convex polygons
_list = BayazitDecomposer.ConvexPartition(_verts);
Vector2 vertScale = new Vector2(ConvertUnits.ToSimUnits(1)) * 10f;
foreach (Vertices verti in _list)
//Create a single body with multiple fixtures
_Ground = BodyFactory.CreateCompoundPolygon(_World, _list, 1);
_Ground.BodyType = BodyType.Static;
_Ground.Position = new Vector2(0, -100);
Have you tried the MSTerrain.ApplyTexture() method? It will create a body in the shape of your texture. You can find an example of this in the Testbed project called "DestructibleTerrainMSTest.cs". That example sounds exactly like what you are trying to
The MSTerrain seems to work.
Thx for pushing me in the right direction!