Drawing/transforming PolygonShape vertices for drawing

Mar 22, 2011 at 7:23 AM
Edited Mar 22, 2011 at 7:25 AM

I have a simple rectangle PolygonShape.  I want to draw it in XNA using a LineList, for example.  The problem is that the vertices stored in the PolygonShape object are untransformed.  Now, it appears that I can get the transform of a Body, which theoretically I can apply to each of the vertices to use for drawing my LineList.  But unfortunately this Transform isn't a Matrix, so I can't simply use Vector2.Transform.  Before I start reverse engineering the FarseerPhysics.Common.Transform class, is there an easy way to accomplish what I want?  I assume there must be, as physics objects are pretty useless if you can't draw them properly on screen. :)

Developer
Mar 22, 2011 at 9:46 AM

What you are looking for is probably body.position and body.rotation. Either you pass that to Matrix.CreateTranslation/Rotation or you could alternatively use MathUtils.Multiply in FarseerPhysics.Common.MathUtils. Have a look at the DrawShape method in the debug view for further reference.

Mar 23, 2011 at 5:52 AM

Thanks, it's simpler than I feared. :)