Mercurial > touhou
comparison stageviewer.py @ 45:e01e88b06a13
Fix camera handling, should be much closer to the original, now
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Mon, 22 Aug 2011 09:11:16 +0200 |
parents | a10e3f44a883 |
children | ab826bc29aa2 |
comparison
equal
deleted
inserted
replaced
44:c435e83a8e70 | 45:e01e88b06a13 |
---|---|
74 # Draw everything | 74 # Draw everything |
75 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) | 75 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) |
76 | 76 |
77 fog_b, fog_g, fog_r, _, fog_start, fog_end = background.fog_interpolator.values | 77 fog_b, fog_g, fog_r, _, fog_start, fog_end = background.fog_interpolator.values |
78 x, y, z = background.position_interpolator.values | 78 x, y, z = background.position_interpolator.values |
79 unknownx, dy, dz = background.position2_interpolator.values | 79 dx, dy, dz = background.position2_interpolator.values |
80 | 80 |
81 glFogi(GL_FOG_MODE, GL_LINEAR) | 81 glFogi(GL_FOG_MODE, GL_LINEAR) |
82 glFogf(GL_FOG_START, fog_start) | 82 glFogf(GL_FOG_START, fog_start) |
83 glFogf(GL_FOG_END, fog_end) | 83 glFogf(GL_FOG_END, fog_end) |
84 glFogfv(GL_FOG_COLOR, (fog_r / 255., fog_g / 255., fog_b / 255., 1.)) | 84 glFogfv(GL_FOG_COLOR, (fog_r / 255., fog_g / 255., fog_b / 255., 1.)) |
90 # 192. = 384. / 2. = width / 2. | 90 # 192. = 384. / 2. = width / 2. |
91 # 224. = 448. / 2. = height / 2. | 91 # 224. = 448. / 2. = height / 2. |
92 # 835.979370 = 224./math.tan(math.radians(15)) = (height/2.)/math.tan(math.radians(fov/2)) | 92 # 835.979370 = 224./math.tan(math.radians(15)) = (height/2.)/math.tan(math.radians(fov/2)) |
93 # This is so that objects on the (O, x, y) plane use pixel coordinates | 93 # This is so that objects on the (O, x, y) plane use pixel coordinates |
94 gluLookAt(192., 224., - 835.979370 * dz, | 94 gluLookAt(192., 224., - 835.979370 * dz, |
95 192., 224. - dy, 750 - 835.979370 * dz, 0., -1., 0.) #TODO: 750 might not be accurate | 95 192. + dx, 224. - dy, 0., 0., -1., 0.) |
96 #print(glGetFloat(GL_MODELVIEW_MATRIX)) | 96 #print(glGetFloat(GL_MODELVIEW_MATRIX)) |
97 glTranslatef(-x, -y, -z) | 97 glTranslatef(-x, -y, -z) |
98 | 98 |
99 for texture_key, (nb_vertices, vertices, uvs, colors) in background.objects_by_texture.items(): | 99 for texture_key, (nb_vertices, vertices, uvs, colors) in background.objects_by_texture.items(): |
100 glBindTexture(GL_TEXTURE_2D, texture_manager[texture_key]) | 100 glBindTexture(GL_TEXTURE_2D, texture_manager[texture_key]) |