forked from jvan/vroom-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcubes.vroom
executable file
·42 lines (29 loc) · 985 Bytes
/
cubes.vroom
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env vroom-wrapper
from vroom import *
# Functions
def toggleLighting(toggle):
Global.UseLighting = not Global.UseLighting
def toggleColor(toggle):
Global.UseColor = not Global.UseColor
def setColor(c):
c = c if Global.UseColor else c[0]
material(c) if Global.UseLighting else color(c)
# vroom callbacks
def init():
setMainMenuTitle('Cubes')
addMainMenuItem('Lighting', toggleLighting, type='toggle')
addMainMenuItem('Color', toggleColor, type='toggle')
Global.UseLighting = False
Global.UseColor = False
NUM_CUBES = 1000
Global.vertices = list(random_vertex_generator(NUM_CUBES, -100.0, 100.0))
Global.colors = list(random_color_generator(NUM_CUBES))
def display():
lighting(Global.UseLighting)
cube_style = 'solid' if Global.UseLighting else 'wireframe'
for (v,c) in zip(Global.vertices, Global.colors):
pushMatrix()
translate(v)
setColor(c)
cube(3.0, style=cube_style)
popMatrix()