Mercurial > touhou
comparison stageviewer.py @ 11:548662d70860
Add some explanations to the magic constants
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Wed, 03 Aug 2011 15:25:26 +0200 |
parents | 059ea0ea8d38 |
children | 58bc264aba38 |
comparison
equal
deleted
inserted
replaced
10:059ea0ea8d38 | 11:548662d70860 |
---|---|
260 z = z1 + (z2 - z1) * truc | 260 z = z1 + (z2 - z1) * truc |
261 | 261 |
262 | 262 |
263 glMatrixMode(GL_MODELVIEW) | 263 glMatrixMode(GL_MODELVIEW) |
264 glLoadIdentity() | 264 glLoadIdentity() |
265 # Some explanations on the magic constants: | |
266 # 192. = 384. / 2. = width / 2. | |
267 # 224. = 448. / 2. = height / 2. | |
268 # 835.979370 = 224./math.tan(math.radians(15)) = (height/2.)/math.tan(math.radians(fov/2)) | |
269 # This is so that objects on the (O, x, y) plane use pixel coordinates | |
265 gluLookAt(192., 224., - 835.979370 * dz, | 270 gluLookAt(192., 224., - 835.979370 * dz, |
266 192., 224. - dy, 750 - 835.979370 * dz, 0., -1., 0.) #TODO: 750 might not be accurate | 271 192., 224. - dy, 750 - 835.979370 * dz, 0., -1., 0.) #TODO: 750 might not be accurate |
267 #print(glGetFloat(GL_MODELVIEW_MATRIX)) | 272 #print(glGetFloat(GL_MODELVIEW_MATRIX)) |
268 glTranslatef(-x, -y, -z) | 273 glTranslatef(-x, -y, -z) |
269 | 274 |
270 glDrawArrays(GL_QUADS, 0, nb_vertices) | 275 glDrawArrays(GL_QUADS, 0, nb_vertices) |
276 | |
277 #TODO: show the game itself | |
278 # It is displayed on (0, 0, 0), (0, 448, 0), (388, 448, 0), (388, 0, 0) | |
279 # using a camera at (192, 224, -835.979370) looking right behind itself | |
280 # Depth test should be disabled when rendering the game | |
271 | 281 |
272 pygame.display.flip() | 282 pygame.display.flip() |
273 clock.tick(120) | 283 clock.tick(120) |
274 frame += 1 | 284 frame += 1 |
275 | 285 |