-
Notifications
You must be signed in to change notification settings - Fork 222
/
cube.py
50 lines (44 loc) · 1.27 KB
/
cube.py
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
42
43
44
45
46
47
48
49
50
class Cube:
def __init__(self, w, h, d):
self.w = w
self.h = h
self.d = d
self.vertices = [
# Cube composed of 6 quads
# Front
(-w/2, -h/2, d/2),
(w/2, -h/2, d/2),
(w/2, h/2, d/2),
(-w/2, h/2, d/2),
# Left
(-w/2, -h/2, d/2),
(-w/2, -h/2, -d/2),
(-w/2, h/2, -d/2),
(-w/2, h/2, d/2),
# Right
(w/2, -h/2, d/2),
(w/2, -h/2, -d/2),
(w/2, h/2, -d/2),
(w/2, h/2, d/2),
# Back
(-w/2, -h/2, -d/2),
(w/2, -h/2, -d/2),
(w/2, h/2, -d/2),
(-w/2, h/2, -d/2),
# Top
(-w/2, -h/2, d/2),
(-w/2, -h/2, -d/2),
(w/2, -h/2, -d/2),
(w/2, -h/2, d/2),
# Bottom
(-w/2, h/2, d/2),
(-w/2, h/2, -d/2),
(w/2, h/2, -d/2),
(w/2, h/2, d/2)
]
def create(self):
for i in range(6):
beginShape(QUADS)
for j in range(4):
vertex(self.vertices[j+4*i][0], self.vertices[j+4*i][1], self.vertices[j+4*i][2])
endShape()