101 | 101 |
glRotatef(4, 1, 0, 0)
|
102 | 102 |
|
103 | 103 |
glPushMatrix()
|
104 | |
glRotatef(rot, 0, 1, 0)
|
|
104 |
glRotatef(rot, 0, 1, 0)
|
105 | 105 |
glBegin(GL_QUADS)
|
106 | 106 |
for quad, normal in quads:
|
107 | 107 |
glNormal3f(*normal)
|
|
112 | 112 |
|
113 | 113 |
glPopMatrix()
|
114 | 114 |
|
115 | |
def show_voxels(voxel_map):
|
116 | |
dist = -np.linalg.norm(voxel_map.hi - voxel_map.lo)
|
|
115 |
def draw_points(points, rot, res):
|
|
116 |
glPushMatrix()
|
|
117 |
glColor3fv((1., 0.7, 0.))
|
|
118 |
glRotatef(4, 1, 0, 0)
|
|
119 |
|
|
120 |
glPushMatrix()
|
|
121 |
glRotatef(rot, 0, 1, 0)
|
|
122 |
glBegin(GL_TRIANGLES)
|
|
123 |
for point in points:
|
|
124 |
glNormal3f(1, 0, 0)
|
|
125 |
for delta in [[0, 0, 0], [0, res, 0], [0, 0, res]]:
|
|
126 |
glVertex3f(*(point[:3] + delta))
|
|
127 |
# glNormal3f(0, 0, 1)
|
|
128 |
# for delta in [[0, 0, 0], [0, res, 0], [res, 0, 0]]:
|
|
129 |
# glVertex3f(*(point[:3] + delta))
|
|
130 |
glEnd()
|
|
131 |
glPopMatrix()
|
|
132 |
|
|
133 |
glPopMatrix()
|
|
134 |
|
|
135 |
|
|
136 |
def draw_loop(draw_func, size):
|
|
137 |
dist = -np.linalg.norm(size)
|
117 | 138 |
w = 800
|
118 | 139 |
h = 800
|
119 | 140 |
pygame.init()
|
120 | 141 |
pygame.display.set_mode((w, h), OPENGL|DOUBLEBUF)
|
121 | 142 |
|
122 | 143 |
glEnable(GL_DEPTH_TEST)
|
123 | |
glClearColor(.2, .2, .3, 1.)
|
|
144 |
glClearColor(.0, .0, .1, 1.)
|
124 | 145 |
|
125 | 146 |
glMatrixMode(GL_PROJECTION)
|
126 | 147 |
glLoadIdentity()
|
|
138 | 159 |
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (1., 1., 1., 1.))
|
139 | 160 |
glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, (50.,))
|
140 | 161 |
|
141 | |
quads = voxels_to_quads(voxel_map)
|
142 | 162 |
rot = 0
|
143 | 163 |
while True:
|
144 | 164 |
event = pygame.event.poll()
|
|
148 | 168 |
|
149 | 169 |
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
|
150 | 170 |
|
151 | |
draw_quads(quads, rot)
|
|
171 |
draw_func(rot=rot)
|
152 | 172 |
pygame.display.flip()
|
153 | |
pygame.time.wait(3)
|
154 | 173 |
rot += 2.
|