This project has moved and is read-only. For the latest updates, please go here.

Vertices.CreatePolygon for Silverlight?

Dec 22, 2008 at 12:04 PM
From what I understand CreatePolygon method should be platform independent as it only receives as input an array of uint. There is an example somewhere of how to use this method with Silverlight? I only found an example in documentation that seem to be for XNA platform. I am trying to load a bitmap 'texture' and automatically create the body/geom for it. I didn't found a way to obtain the bitmap data from a BitmapImage that is used as an image source in Silverlight, any hints would be greatly appreciated. 

Dec 22, 2008 at 12:43 PM
Yep, the Vertices.CreatePolygon() method is platform independent. I'm not sure how well it works with Silverlight, I have not tried it with Silverlight yet.
However, the Physics Helper project does have a UIElement to Farseer Physics object method inside of it. (see project here:

I have written down on our todo list that we should try and create the advanced samples in silverlight.
Dec 22, 2008 at 1:50 PM
Thanks for the quick replay! It seems that my problem is more silverlight related (how to get the bitmap data of an sliverlight image). I will have a look at the helper project, thanks.
Dec 28, 2008 at 12:12 PM
It seems that the references project uses System.Windows.Media.VisualTreeHelper.FindElementsInHostCoordinates to determine if a point is inside or outside of a UIElement. This doesn't help with an image. Also it seems that there is no way of accessing the bitmap row data in Silverlight... 
The solution I come up with is to code a custom tool to generate the texture image perimeter as a list of points in a console windows application. I then include the list of points in my silverligh user controls in a Path control that is transformed to a list of vertices and used to create the body. The solution is not dynamic as I initially intended but works great and allows small adjustments of the auto generated texture perimeter...