-
Notifications
You must be signed in to change notification settings - Fork 0
/
visualiztion.py
68 lines (51 loc) · 1.73 KB
/
visualiztion.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
64
65
66
67
68
from gym_hyrosphere.envs.visualization import *
from gym_hyrosphere.envs.physics import *
def main():
pg.init()
glutInit([])
display = (800, 600)
pg.display.set_mode(display, DOUBLEBUF|OPENGL)
gluPerspective(45, display[0]/display[1], 0.1, 30.0)
glTranslatef(0.0, 0.0, -3)
hyrosphere = HyroSphere(t_len=1.0, mass=8, dot_masses=[1.0]*4, position=[0.0,0.0,0.0])
cam = LookAtCamera(rotation=[90,0,0], distance=1.0)
while True:
for event in pg.event.get():
if event == pg.QUIT:
pg.quit()
quit()
elif event.type == KEYDOWN:
if event.key == K_ESCAPE:
pg.quit()
quit()
elif event.key == K_e:
R, dRdt = hyrosphere.move(dt=0.01,ksi_new=[0.0,0.0,0.0,0.5])
keys = pg.key.get_pressed()
if keys[K_UP]:
cam.distance -= 0.05
if keys[K_DOWN]:
cam.distance += 0.05
if keys[K_LEFT]:
cam.roty -= 3
if keys[K_RIGHT]:
cam.roty += 3
if keys[K_w]:
cam.rotx += 3
if keys[K_s]:
cam.rotx -= 3
if keys[K_q]:
cam.rotz += 3
if keys[K_a]:
cam.rotz -= 3
glClearColor(1.0, 1.0, 1.0, 1.0)
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
#glEnable(GL_LIGHTING)
cam.push()
R, dRdt = hyrosphere.move(dt=0.01,ksi_new=np.zeros(4))
K = np.append(R, [np.zeros(3), np.asarray([0,0,-hyrosphere.radius])], axis=0)
drawHyrosphere(hyrosphere)
pg.display.flip()
cam.pop()
pg.time.wait(20)
if __name__ == "__main__":
main()