comparison data/ST/make_stage.py @ 601:016f6b937893

Make sample data build again.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 25 Oct 2014 18:57:10 +0200
parents 1bc0ad774ed4
children
comparison
equal deleted inserted replaced
600:2a748aa29c3f 601:016f6b937893
1 from pytouhou.formats.std import Stage, Model 1 from pytouhou.formats.std import Stage, Model
2 from pytouhou.formats.anm0 import Animations 2 from pytouhou.formats.anm0 import ANM0
3 from pytouhou.vm.anmrunner import ANMRunner 3 from pytouhou.vm.anmrunner import ANMRunner
4 from pytouhou.game.sprite import Sprite 4 from pytouhou.game.sprite import Sprite
5 from pytouhou.resource.anmwrapper import AnmWrapper 5 from pytouhou.ui.opengl.sprite import get_sprite_vertices
6 from pytouhou.opengl.sprite import get_sprite_rendering_data
7 6
8 ground = Model(quads=[(14, -100.0, -46*3, 0.5, (192+100)*2, 46*3), 7 ground = Model(quads=[(14, -100.0, -46*3, 0.5, (192+100)*2, 46*3),
9 (0, 192.0 - 40, -46.0, 0.0, 0, 0), 8 (0, 192.0 - 40, -46.0, 0.0, 0, 0),
10 (0, 192.0 - 40, -46.0*2, 0.0, 0, 0), 9 (0, 192.0 - 40, -46.0*2, 0.0, 0, 0),
11 (0, 192.0 - 40, -46.0*3, 0.0, 0, 0), 10 (0, 192.0 - 40, -46.0*3, 0.0, 0, 0),
69 (2, 192*2-30-40.0-50.0, -46*3*7-20, -50.0), 68 (2, 192*2-30-40.0-50.0, -46*3*7-20, -50.0),
70 (2, 192*2-30-40.0-50.0, -46*3*8-20, -50.0)] 69 (2, 192*2-30-40.0-50.0, -46*3*8-20, -50.0)]
71 70
72 71
73 # Bounding boxes 72 # Bounding boxes
74 anm_wrapper = AnmWrapper([Animations.read(open('stg1bg.anm', 'rb'))]) 73 anm = ANM0.read(open('stg1bg.anm', 'rb'))[0]
75 for model in models: 74 for model in models:
76 vertices = [] 75 vertices = []
77 for script_index, ox2, oy2, oz2, width_override, height_override in model.quads: 76 for script_index, ox2, oy2, oz2, width_override, height_override in model.quads:
78 sprite = Sprite(width_override, height_override) 77 sprite = Sprite(width_override, height_override)
79 anmrunner = ANMRunner(anm_wrapper, script_index, sprite) 78 anmrunner = ANMRunner(anm, script_index, sprite)
80 anmrunner.run_frame() 79 vertices2 = get_sprite_vertices(sprite)
81 key, (vertices2, uvs2, colors2) = get_sprite_rendering_data(sprite)
82 vertices.extend((x + ox2, y + oy2, z + oz2) for x, y, z in vertices2) 80 vertices.extend((x + ox2, y + oy2, z + oz2) for x, y, z in vertices2)
83 xmin, ymin, zmin = min(x for x, y, z in vertices), min(y for x, y, z in vertices), min(z for x, y, z in vertices) 81 xmin, ymin, zmin = min(x for x, y, z in vertices), min(y for x, y, z in vertices), min(z for x, y, z in vertices)
84 xmax, ymax, zmax = max(x for x, y, z in vertices), max(y for x, y, z in vertices), max(z for x, y, z in vertices) 82 xmax, ymax, zmax = max(x for x, y, z in vertices), max(y for x, y, z in vertices), max(z for x, y, z in vertices)
85 model.bounding_box = (xmin, ymin, zmin, xmax - xmin, ymax - ymin, zmax - zmin) 83 model.bounding_box = (xmin, ymin, zmin, xmax - xmin, ymax - ymin, zmax - zmin)
86 84