Skip to content

Commit 2241e99

Browse files
committed
wip animated_mesh.py
1 parent f07f458 commit 2241e99

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from processing import *
2+
3+
mesh = None
4+
grid_size = 20
5+
spacing = 10.0
6+
7+
def setup():
8+
size(800, 600)
9+
mode_3d()
10+
global mesh = geometry_create(TriangleList)
11+
12+
def draw():
13+
# TODO: maybe all of this should be in `setup()`
14+
global grid_size
15+
16+
for z in range(grid_size):
17+
for x in range(grid_size):
18+
px = x * spacing - offset
19+
pz = z * spacing - offset
20+
geometry_color(mesh, x/grid_size, 0.5, z/grid_size, 1.0)
21+
geometry_normal(mesh, 0.0,1.0,0.0)
22+
geometry_vertex(mesh, px, 0.0, pz)
23+
for z in range(grid_size-1):
24+
for x in range(grid_size-1):
25+
tl = z * grid_size + x
26+
tr = tl + 1
27+
bl = (z + 1) * grid_size + x
28+
br = bl + 1
29+
30+
geometry_index(mesh, tl)
31+
geometry_index(mesh, bl)
32+
geometry_index(mesh, tr)
33+
34+
geometry_index(mesh, tr)
35+
geometry_index(mesh, bl)
36+
geometry_index(mesh, br)
37+
38+
39+
40+
41+
# TODO: this should happen implicitly on module load somehow
42+
run()

0 commit comments

Comments
 (0)