-
Notifications
You must be signed in to change notification settings - Fork 5
/
bbox.py
63 lines (56 loc) · 1.79 KB
/
bbox.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
51
52
53
54
55
56
57
58
59
60
61
62
63
import numpy
import moderngl
from demosys.opengl.vao import VAO
def bbox(width=1.0, height=1.0, depth=1.0):
"""
Generates a bounding box with (0.0, 0.0, 0.0) as the center.
This is simply a box with ``LINE_STRIP`` as draw mode.
Keyword Args:
width (float): Width of the box
height (float): Height of the box
depth (float): Depth of the box
Returns:
A :py:class:`demosys.opengl.vao.VAO` instance
"""
width, height, depth = width / 2.0, height / 2.0, depth / 2.0
pos = numpy.array([
width, -height, depth,
width, height, depth,
-width, -height, depth,
width, height, depth,
-width, height, depth,
-width, -height, depth,
width, -height, -depth,
width, height, -depth,
width, -height, depth,
width, height, -depth,
width, height, depth,
width, -height, depth,
width, -height, -depth,
width, -height, depth,
-width, -height, depth,
width, -height, -depth,
-width, -height, depth,
-width, -height, -depth,
-width, -height, depth,
-width, height, depth,
-width, height, -depth,
-width, -height, depth,
-width, height, -depth,
-width, -height, -depth,
width, height, -depth,
width, -height, -depth,
-width, -height, -depth,
width, height, -depth,
-width, -height, -depth,
-width, height, -depth,
width, height, -depth,
-width, height, -depth,
width, height, depth,
-width, height, -depth,
-width, height, depth,
width, height, depth,
], dtype=numpy.float32)
vao = VAO("geometry:cube", mode=moderngl.LINE_STRIP)
vao.buffer(pos, '3f', ["in_position"])
return vao