Texture to Polygon in Farseer Physics Engage 3.1

Topics: Developer Forum
Nov 27, 2010 at 3:55 PM

Hi, everybody!

 

First I apologise for the bad English, because, I`am Russian.
I have started to use Farseer Physics Engage 3.1 and have faced a problem. I try to receive polygon from a texture and then high-grade to work with him. I tried to realise it as in a documentation example:

 

texture2D = Content.Load<Texture2D>(nameTexture);
uint[] data = new uint[texture2D.Height * texture2D.Width];
texture2D.GetData(data);
Vertices vertices = PolygonTools.CreatePolygon(data, texture2D.Width, texture2D.Height, true);
Vector2FP scale = new Vector2FP(.01f, .01f);
vertices.Scale(ref scale);
var list = BayazitDecomposer.ConvexPartition(vertices);
fixture = FixtureFactory.CreateCompoundPolygon(world, list, 1);
fixture[0].Body.BodyType = BodyType.Dynamic;

 

 

How I can draw now this fixture in XNA?

I tried to do various focuses with it, but it turns out so the body does not coincide with the drawn texture.

Prompt, please. It is urgent.

Thanks in advance, Alexey.

 

 

Coordinator
Nov 27, 2010 at 4:06 PM

Drawing stuff is really out of scope for a physics engine...

Farseer Physic Engine uses the MKS (Meter-Kilo-Second) system as units. For you this means that you will have to convert between meters and pixels in order for you to draw it on the screen. You can do that by creating a projection and view matrix - then you reference the matrices in your SpriteBatch object.

We already do this in the samples, I recommend you take a look at see how it is done.

Nov 27, 2010 at 5:56 PM

Thanks for a prompt reply!
And when there will be new samples?
I have one more question: whether is DebugViewXNA in Farseer Physics Engine 3.1?



And when there will be new samples?

I have one more question: whether is DebugViewXNA in Farseer Physics Engine 3.1?
Nov 27, 2010 at 6:26 PM

The samples are already there. If you get the latest changeset it contains all samples, the engine and also DebugViewXNA

Regards,
Thorsten