Drawing Shape in DebugView (Farseer)
Posted
by
keyvan kazemi
on Game Development
See other posts from Game Development
or by keyvan kazemi
Published on 2012-04-07T16:30:18Z
Indexed on
2012/04/07
17:48 UTC
Read the original article
Hit count: 234
XNA
As the title says, I need to draw a shape/polygon in Farseer using debugview. I have this piece of code which converts a Texture to polygon:
//load texture that will represent the tray
trayTexture = Content.Load<Texture2D>("tray");
//Create an array to hold the data from the texture
uint[] data = new uint[trayTexture.Width * trayTexture.Height];
//Transfer the texture data to the array
trayTexture.GetData(data);
//Find the vertices that makes up the outline of the shape in the texture
Vertices verts = PolygonTools.CreatePolygon(data, trayTexture.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));
foreach (Vertices verti in _list)
{
verti.Scale(ref vertScale);
}
tray = BodyFactory.CreateCompoundPolygon(MyWorld, _list, 10);
Now in DebugView I guess I have to use "DrawShape" method which requires:
DrawShape(Fixture fixture, Transform xf, Color color)
My question is how can I get the variables needed for this method, namely Fixture and Transform?
© Game Development or respective owner