Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Labeling vertices clockwise on a grid

Author
Message
Sid Sinister
21
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 24th May 2010 05:53
Hey guys, I'm trying to figure out the method to the madness of counting vertices on, what will be, a terrain grid. I know the following link is C#, and I'm actually doing this in XNA, but the concept is universal so I thought I'd ask it here since DBP get's the most traffic, lol.

http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series1/Indices.php





How they heck are they counting this? It doesn't even look clockwise to me! Yet, according to common practice, vertices are drawn in a clockwise manner, otherwise, they are culled. The first image doesn't even make sense.

Does anyone understand the pattern here? I just want to be able to know this so I can understand what's going on here. I hate using code I don't know.

On a funny note, I remember doing something very similar to this a few years ago with Jason P Sage as he was teaching me how to do this in DBP with memblocks. Meanwhile, I guess I'll try and look that up!

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
Current Project: http://strewnfield.wordpress.com/ (Last updated 06/11/09)
Visigoth
21
Years of Service
User Offline
Joined: 8th Jan 2005
Location: Bakersfield, California
Posted: 24th May 2010 08:39 Edited at: 24th May 2010 09:01
actually, I think they are just indexes to vertices.
First, you build a list of vertex positions.
the list is indexed with the numbers in your diagrams.
Then, the list of faces reference the list of vertexes.
In your face list, you decide the handedness.

So, in your first drawing, you would have a list of 5 vertexes.
vert 0, xpos,ypos,zpos
vert 1, xpos,ypos,zpos
etc....

Then, you define a list of faces, 3 verts each: there would only be two in this example.
(actually, faces are zero based as well, but I labled them 1 and 2)
//right handed
face 1 , vert0,vert3,vert1
face 2 , vert1,vert4,vert2

//left handed
face 1, vert0,vert1,vert3
face 2, vert1,vert2,vert4

the example in your link is explaining the technique to have shared verts. One big advantage to this is, move any one vert, and any faces connected to that vert also get moved.

notice in the face list (or indice list, as it is properly called) that the two triangles share the vert1 vertex.

also, different applications have different handedness. Not every program is righthanded winding. DirectX is flexible enough to allow for both methods. If you ever need to flip faces, you can just swap any two indices.

Hope this helps.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th May 2010 16:09
My own version of CREATE OBJECT PLANE lays out the vertices horizontally from one side to the other, then returns back to the original side before counting again, ie a 5x5 cell grid has 0 to 5 along the top from left to right, then 6 to 11 on the next row, then 12 to 17 on the next etc.

Then they are all linked together into faces using the index buffer, ie the first face would have index values of 6, 0, 1, the next face would be 6, 1, 7, and then repeat to complete all other faces - this is where the clockwise winding order comes in.

Sid Sinister
21
Years of Service
User Offline
Joined: 10th Jul 2005
Location:
Posted: 24th May 2010 18:49
Ah, alright, that makes sense. Thanks for the help you two. The indices are basically what you make them. As long as you define them in the same winding fashion, no matter what numbers you call them, it'll all still work out. Of course, you want to have a system going so you can procedurally go through all the points.

"If I have seen a little further it is by standing on the shoulders of Giants" - Isaac Newton
Current Project: http://strewnfield.wordpress.com/ (Last updated 06/11/09)
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base

Login to post a reply

Server time is: 2026-07-25 08:29:27
Your offset time is: 2026-07-25 08:29:27