2017-06-08 21:28:33 +00:00
|
|
|
import math
|
|
|
|
|
|
|
|
NUM_VERTS_X = 30
|
|
|
|
NUM_VERTS_Y = 30
|
2019-04-27 14:31:15 +00:00
|
|
|
totalVerts = NUM_VERTS_X * NUM_VERTS_Y
|
|
|
|
totalTriangles = 2 * (NUM_VERTS_X - 1) * (NUM_VERTS_Y - 1)
|
2017-06-08 21:28:33 +00:00
|
|
|
offset = -50.0
|
|
|
|
TRIANGLE_SIZE = 1.
|
2019-04-27 14:31:15 +00:00
|
|
|
waveheight = 0.1
|
|
|
|
gGroundVertices = [None] * totalVerts * 3
|
|
|
|
gGroundIndices = [None] * totalTriangles * 3
|
|
|
|
|
|
|
|
i = 0
|
|
|
|
|
|
|
|
for i in range(NUM_VERTS_X):
|
|
|
|
for j in range(NUM_VERTS_Y):
|
|
|
|
gGroundVertices[(i + j * NUM_VERTS_X) * 3 + 0] = (i - NUM_VERTS_X * 0.5) * TRIANGLE_SIZE
|
|
|
|
gGroundVertices[(i + j * NUM_VERTS_X) * 3 + 1] = (j - NUM_VERTS_Y * 0.5) * TRIANGLE_SIZE
|
|
|
|
gGroundVertices[(i + j * NUM_VERTS_X) * 3 +
|
|
|
|
2] = waveheight * math.sin(float(i)) * math.cos(float(j) + offset)
|
|
|
|
|
|
|
|
index = 0
|
|
|
|
for i in range(NUM_VERTS_X - 1):
|
|
|
|
for j in range(NUM_VERTS_Y - 1):
|
|
|
|
gGroundIndices[index] = 1 + j * NUM_VERTS_X + i
|
|
|
|
index += 1
|
|
|
|
gGroundIndices[index] = 1 + j * NUM_VERTS_X + i + 1
|
|
|
|
index += 1
|
|
|
|
gGroundIndices[index] = 1 + (j + 1) * NUM_VERTS_X + i + 1
|
|
|
|
index += 1
|
|
|
|
gGroundIndices[index] = 1 + j * NUM_VERTS_X + i
|
|
|
|
index += 1
|
|
|
|
gGroundIndices[index] = 1 + (j + 1) * NUM_VERTS_X + i + 1
|
|
|
|
index += 1
|
|
|
|
gGroundIndices[index] = 1 + (j + 1) * NUM_VERTS_X + i
|
|
|
|
index += 1
|
2017-06-08 21:28:33 +00:00
|
|
|
|
|
|
|
#print(gGroundVertices)
|
|
|
|
#print(gGroundIndices)
|
|
|
|
|
|
|
|
print("o Terrain")
|
|
|
|
|
2019-04-27 14:31:15 +00:00
|
|
|
for i in range(totalVerts):
|
|
|
|
print("v "),
|
|
|
|
print(gGroundVertices[i * 3 + 0]),
|
|
|
|
print(" "),
|
|
|
|
print(gGroundVertices[i * 3 + 1]),
|
|
|
|
print(" "),
|
|
|
|
print(gGroundVertices[i * 3 + 2])
|
2017-06-08 21:28:33 +00:00
|
|
|
|
2019-04-27 14:31:15 +00:00
|
|
|
for i in range(totalTriangles):
|
|
|
|
print("f "),
|
|
|
|
print(gGroundIndices[i * 3 + 0]),
|
|
|
|
print(" "),
|
|
|
|
print(gGroundIndices[i * 3 + 1]),
|
|
|
|
print(" "),
|
|
|
|
print(gGroundIndices[i * 3 + 2]),
|
|
|
|
print(" ")
|