Reputation: 809
I am hoping someone can shed some light on this issue for me. If I am given a point (i, j, k), I can make the following cube:
8______K_______7 1 = i , j , k
/| /| 2 = i+1, j , k
L/ | J/ | 3 = i+1, j+1, k
/ |H / | 4 = i , j+1, k
5/______I_____/6 |G 5 = i , j , k+1
| | | | 6 = i+1, j , k+1
| | | | 7 = i+1, j+1, k+1
E| 4|________|F__|3 8 = i , j+1, k+1
| / c | /
| /D | /B
|/___________|/
1 A 2
where the numbers 1-8 are each of the cube's vertices and the letters A-L are the midpoints of each edge of the cube.
I am trying to implement a marching cube algorithm, but I do not know what order to give the points for each triangular plane I find. For example, if vertex 1 is marked, then I would need to draw a plane from E-D-A. Similarly, if vertex 7 is marked I would need to draw a plane from K-J-G. Is there a rule for the order to give coordinates in 3D space for openGL?
Upvotes: 5
Views: 417
Reputation: 162164
Is there a rule for the order to give coordinates in 3D space for openGL?
OpenGL defines front and back side of a face by the winding of the vertices in screen space. If the vertices of a face in screen space are in counterclock order, the front face is considered visible. Clockwise order => backface. Normals should point into front face direction.
Upvotes: 2