Simple, like this:
----
|/|/
----
int ndx = 0;
for (int r = 0; r < h1->rows-1; r ++) {
glBegin(GL_TRIANGLE_STRIP); {
for (int c = 0; c < h1->cols; c ++, ndx ++) {
int cols = h1->cols;
glVertex3fv(h1->verts[ndx+cols].xyz);
glVertex3fv(h1->verts[ndx].xyz);
}
glEnd();
}
}
More complex, but lends itself to simplification over distance, like this:
----
|\/|
----
|/\|
----
for (int r = 1; r < h1->rows-1; r += 2) {
for (int c = 1; c < h1->cols-1; c += 2) {
int cols = h1->cols;
int mid = r*cols + c;
glBegin(GL_TRIANGLE_FAN); {
glVertex3fv(h1->verts[mid].xyz);
glVertex3fv(h1->verts[mid-1].xyz);
glVertex3fv(h1->verts[mid-cols-1].xyz);
glVertex3fv(h1->verts[mid-cols].xyz);
glVertex3fv(h1->verts[mid-cols+1].xyz);
glVertex3fv(h1->verts[mid+1].xyz);
glVertex3fv(h1->verts[mid+cols+1].xyz);
glVertex3fv(h1->verts[mid+cols].xyz);
glVertex3fv(h1->verts[mid+cols-1].xyz);
glVertex3fv(h1->verts[mid-1].xyz);
}
glEnd();
}
}
No comments:
Post a Comment