-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenvironment_3D.py
39 lines (30 loc) · 1011 Bytes
/
environment_3D.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
import pygame
from pygame.locals import *
from OpenGL.GL import *
from OpenGL.GLU import *
class Environment3D:
def __init__(self):
self.all_vertices = []
self.all_edges = []
self.display = "lines"
def add_structure(self, vertices, edges):
self.all_vertices.append(vertices)
self.all_edges.append(edges)
def flush(self):
self.all_vertices = []
self.all_edges = []
def create_environment(self):
if self.display == "lines":
glBegin(GL_LINES)
for i in range(len(self.all_vertices)):
for edge in self.all_edges[i]:
for vertex in edge:
glVertex3fv(self.all_vertices[i][vertex])
glEnd()
def print_info(self):
for i in range(len(self.all_vertices)):
for edge in self.all_edges[i]:
print(edge)
print()
for vertice in self.all_vertices[i]:
print(vertice)