PolygonShape Vertices to Texture ?

Topics: Developer Forum
Sep 13, 2011 at 3:31 PM
Edited Sep 14, 2011 at 5:33 AM


I am pretty new to XNA and Farseer Physics, just diving into the subject, but think it is pretty awesome.

One thing I cannot find any directions on is how to create a Texture, as such can be rendered by spritebatch, from a Farseer PolygonShape / Vertices. There are many examples of getting texture from content, i.e. pre-defined graphics files, and converting that to vertices and thus to a polygonshape, but not the other way around.

In the Farseer Samples (I am talking about 3.3.1), there is, however, some sample code with a class AssetCreator with one method "TextureFromShape". In case of a polygon, this method calls another, private, method "TextureFromVertices" with some pretty hefty code that does seem to do the job, but not without -again- relying on some pre-defined textures saved as content png files.

Is simplyfing / customizing this code the way forward or is there a simpler way to convert Vertices to Texture?

Thanks in advance...

Sep 26, 2011 at 11:27 PM

please som1 answer

Sep 27, 2011 at 6:33 AM

It looks like hacking and re-using parts of the demo project is the way forward. See also: This topic