1
\$\begingroup\$

I am fairly new to using Quads, so I'm not sure how I can properly describe this issue in all honesty or to even hazard a guess as to why it's happening, so I have a screenshot to illustrate. image of red and while lines, with a white dotted line connecting two

So the white lines are actually Quads, the Red lines are just rectangles. So if you can see the issue, for some reason every "now & again" I will get this issue were I get this somewhat looking "dotted line" which will sometimes be a full end-to-end line.

I'm not too sure what's causing this issue, I have a feeling it has something to-do with the way I'm drawing the quads, I don't think it's an incorrect vertices purely because the because of the thickness of the line, this leads me to believe it's the rendering:

effect.CurrentTechnique.Passes[0].Apply();
device.DrawUserPrimitives<VertexPositionColorTexture>(PrimitiveType.TriangleStrip, vertices, 0, totalNumberOfQuads);

This is the order I'm adding the vertices:

  1. Top Left Segment Corner
  2. Top Right Segment Corner
  3. Bottom Left Segment Corner
  4. Bottom Right Segment Corner

So after getting the vertices in the correct order, things are now even stranger, as this is an image of the current output:

enter image description here

Here's my Current Code, including the rendering: http://pastebin.com/yK5yBZy0

\$\endgroup\$
4
  • \$\begingroup\$ I think you made a typo when saying the red lines were just rectangles, I assume you mean triangles? Since rectangles are quads. (but not all quads are rectangles!) \$\endgroup\$
    – House
    Commented Apr 16, 2012 at 16:28
  • \$\begingroup\$ No, i use a 2D "DrawLine" function via SpriteBatch to draw those, just for a debug purpose to see what the issue was. \$\endgroup\$
    – dan369
    Commented Apr 16, 2012 at 16:38
  • \$\begingroup\$ If you pack the vertices for quads, then draw them like triangles, you're going to have a bad time. \$\endgroup\$
    – House
    Commented Apr 16, 2012 at 18:22
  • \$\begingroup\$ gotcha - dl.dropbox.com/u/13874083/screenshots/screen120416-193701.png. Well thanks for your help :), i did actually in the end up using the TriangleLists using the clockwise winding on the indices. :D. Thanks again \$\endgroup\$
    – dan369
    Commented Apr 16, 2012 at 18:38

1 Answer 1

3
\$\begingroup\$

Keep in mind that the order you insert your vertices into your array matters too. Additionally, it looks like you're drawing a PrimitiveType.TriangleStrip, not quads. It looks like XNA doesn't have a primitive type for quads. You can index them yourself though, as seen in this tutorial..

If you're using triangles (or quads) to draw lines like your image shows, you can have the issue you're experiencing by essentially having a line that has zero height, or close to zero. I imagine this could happen if you're arranging your vertices for quads but then drawing them as triangle strips. So either use the tutorial I mentioned above, or use triangle strips like in this tutorial.

EDIT

The vertices for quads (and triangles) should be defined in clockwise order. Your order is wrong for quads. image of triangle with clockwise arrow

You should swap the last two with each other OR the first two with each other, if you want clockwise order. Ensure that you also look at the tutorial I linked. It will describe the proper way to draw the quads.

\$\endgroup\$
3
  • \$\begingroup\$ Well this is how i am arranging the vertices, from the Top-Left first, then to the Top Right & Then the bottom 2. Like so - pastebin.com/vthKVgKY And yes, it seems so, looking at the vertices, and some of the distance between them is small. \$\endgroup\$
    – dan369
    Commented Apr 16, 2012 at 16:09
  • \$\begingroup\$ Well, i've changed the order of the vertices as you can see here and have the defined my own indexes to use when drawing, as so; pastebin.com/yK5yBZy0. But here's the output: dl.dropbox.com/u/13874083/screenshots/screen120416-174023.png. \$\endgroup\$
    – dan369
    Commented Apr 16, 2012 at 16:38
  • \$\begingroup\$ As for drawing with TriangleLists, that looked even worse. So i'd like to stick with using TriangleSTripes if that's at all possible. You can see in the image it still resembles the sorta output i'd like. But i get that "tearing" like effect :/ \$\endgroup\$
    – dan369
    Commented Apr 16, 2012 at 16:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .