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

Polygon Drawing..

Feb 7, 2009 at 5:15 PM
Hi, right now, I create vertices for polygon, not from a image file.
How do I draw polygon shape in XNA? VertexBuffer?(that would be so complicated, especially the corrdinate );
It seems that spriteBatch only support rectangle shape..

Thanks for your advice.
Feb 7, 2009 at 5:26 PM
This is not really a physics question, but I answer you anyway.

I'm not familiar with any methods of drawing a whole polygon in XNA. There might be one, but I have not encountered it yet.
If you just want to draw an outline of your polygon, you can draw lines from one polygon to the next, but if you want the shape filled, you might need to perform triangulation.

All SpriteBatch does is to function like a drawing buffer. You can input any texture into it and it will draw it on the screen.
You might want to have a look at GraphicsDevice.DrawUserPrimitives() to draw simple shapes.

Oh, and the XNA samples (from Farseer Physics) contains easily drawn shapes. Take a look at it.
Feb 7, 2009 at 11:03 PM
Here is a library posted on ziggyware a couple days ago to draw shapes, try it out: here.
Feb 8, 2009 at 1:21 AM
To be honest you need to buy a book and read through the examples. Most people using Farseer use SpriteBatchs because they are doing 2D graphics and are using sprites. XNA only renders triangles, but it's not that difficult to get a triangle fan from a polygon (get the book and read it). I'm not trying to sound harsh or like I won't help you but rendering is one of the most important parts of making a game. If you can't afford to buy a book from Amazon, I'll photocopy a few pages from one of my books and send it to you. I'd also like to point out that XNA is one of the simplest real 3D frameworks to perform rendering with. It's a great way to learn how the C++ frameworks (DirectX and OpenGL) work.