Hi guys
i have create my simple terrain generator that calculate vertex and normal
vertex are all at same distance the only difference consist in the height that is generated random
this is my algorithm
private void drawPlan(Vertex[][] vertex, Vector[][] normals, GL2 gl) {
for(int z = 0; z < zSubdivision-1; z++) {
gl.glBegin(GL2.GL_TRIANGLE_STRIP);
for(int x = 0; x < xSubdivision ; x++) {
gl.glNormal3f(normals[x][z].x, normals[x][z].y, normals[x][z].z);
gl.glVertex3f(vertex[x][z].x, vertex[x][z].y, vertex[x][z].z);
gl.glNormal3f(normals[x][z+1].x, normals[x][z+1].y, normals[x][z+1].z);
gl.glVertex3f(vertex[x][z+1].x, vertex[x][z+1].y, vertex[x][z+1].z);
}
gl.glEnd();
}
}
now i would like to add texture and calculate correctly the coordinate of my texture
is there already a know algorithm that calculate for plan draw with triangles the texture coordinate?
i suppose that the a texture must enter correctly in 8 triangles draw as hire bottom and so repeated for all the group of 8 trinagles
x--x--x
| / | / |
x--x--x
| / | / |
x--x--x
but because the triangle strip is calculated by a double cycle that consider only z and z+1 for each strip
i have to calculate texture coordinate for first half of image in the first cycle and after second half in the second cycle and repeat
is this right any advice ?
there is a better way to do it?
thanks