Texture to polygon

Oct 17, 2013 at 3:17 AM
I see that the Farseer Physics Engine supports texture to polygon as documented Here. How would you do this in this port? I can't seem to figure out how to get a reference to GameInstance in order to call
Texture2D polygonTexture = GameInstance.Content.Load<Texture2D>("Texture");
Coordinator
Oct 17, 2013 at 5:16 PM
Unfortunately, that functionality is limited to XNA resources, so won't work in a XAML app.

Using physicshelperxaml, you could create a Path element that outlines the bitmap (you would need to draw this out manually). First put the image inside a Canvas element. Then draw a Path inside the same canvas and make sure the Path is the first child in the Canvas. Set the Canvas Visibility to Collapsed so it isn't seen by the user.

The older "Physics Helper" library had code that was similar as the texture to polygon you're mentioning, but it was a bit slow and I never ported it to the newer Physics Helper XAML library. But if you're interested in dissecting that code, it is at https://physicshelper.codeplex.com/
Oct 18, 2013 at 12:42 PM
Thank you for your answer. I'll check that out!