# point combination (rectangle)

This topic is 5132 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Could anyone explain to me how the the "logic" of the combination of points by creating a rectangle is or works? for example we got 4 points and 6 vertices and we want to create a rectangle. We made it by guessing the combination but we were not able to realize the logic behind it. (especially in which order DX wants the points to be and what should be drawn first (hypotenuse or kathede(spelled right?))?)

##### Share on other sites
There are three ways of drawing a rectangle -- triangle list, triangle strip, and triangle fan. The order of the vertices are different for each. Also, there are two ways to break up a rectangle into two triangles, but I'm only going to show one (you can figure out the other).
1             2 +-----------+ |\          | |  \        | |    \      | |      \    | |        \  | |          \| +-----------+3             4
The first thing you need to know is the "winding order". When looking at the "front" side of a triangle, the order of the vertices follows the winding order. The normal winding order for D3D is clockwise (CW). The normal winding order for OpenGL is counter-clockwise (CCW). I am going to assume CW.

Triangle list -

A triangle list is simply a list of triangles. The triangles don't need to be adjacent and the their order doesn't matter. You make the list by specifying the three vertices for each triangle according to the winding order. To make the rectangle above using a triangle list, simply list the vertices in this order: 1-4-3-1-2-4. 1-4-3 is the first triangle (4-3-1 or 3-1-4 also work), and the second triangle is 1-2-4 (2-4-1 and 4-1-2 also work).

Triangle strip -

In the triangle list above, you will notice that vertices 1 and 4 were listed twice. A triangle strip is a way of specifying a list of triangles without duplicating vertices. Basically, after the first triangle, each triangle is specified by a vertex combined with the previous two vertices in the strip. The vertices in the first triangle are specified according to the winding order. The triangle strip for the rectangle above is 3-1-4-2. 3-1-4 makes the first triangle and 1-4-2 makes the second triangle. Two things to note: 1. Because each triangle uses the vertices from the previous two triangles, you have to get the order just right. 2. You will notice that the winding order is reversed in every other triangle. The renderer automatically accounts for this.

Triangle fan -

There is another way to order vertices so that you don't have to duplicate them. In a triangle fan, you specify the "root" vertex, then the first vertex of the first triangle, and then every vertex that follows is combined with the first vertex and the previous vertex to make a triangle. Vertexes are specified according to the winding order. The triangle fan for the rectangle above is 1-2-4-3. 1-2-4 makes the first triangle, and 1-4-3 makes the second. 4-3-1-2 would also work.

Thank you !

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633722
• Total Posts
3013549
×