annotate data/ST/make_stage.py @ 296:c074783d0847

Implement hardcoded function 8 for Remilia.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 02 Mar 2012 09:38:35 +0100
parents 1bc0ad774ed4
children 016f6b937893
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
115
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
1 from pytouhou.formats.std import Stage, Model
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
2 from pytouhou.formats.anm0 import Animations
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
3 from pytouhou.vm.anmrunner import ANMRunner
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
4 from pytouhou.game.sprite import Sprite
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
5 from pytouhou.resource.anmwrapper import AnmWrapper
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
6 from pytouhou.opengl.sprite import get_sprite_rendering_data
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
7
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
8 ground = Model(quads=[(14, -100.0, -46*3, 0.5, (192+100)*2, 46*3),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
9 (0, 192.0 - 40, -46.0, 0.0, 0, 0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
10 (0, 192.0 - 40, -46.0*2, 0.0, 0, 0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
11 (0, 192.0 - 40, -46.0*3, 0.0, 0, 0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
12 (11, -100.0, -46*3, 0.0, 220, 46*3),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
13 (11, 192*2+100.0-220, -46*3, 0.0, 220, 46*3),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
14 (12, 120.0, -46*3, -0.1, 0, 46*3),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
15 (13, 192*2-120-14, -46*3, -0.1, 0, 46*3)])
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
16
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
17 tree = Model(quads=[(9, 0.0, 0.0, 0.0, 0, 0)])
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
18 tree2 = Model(quads=[(10, 0.0, 0.0, 0.0, 0, 0)])
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
19
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
20 models = [ground, tree, tree2]
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
21
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
22
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
23 instances = [(0, 0.0, -46*3*-1, 0.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
24 (0, 0.0, -46*3*0, 0.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
25 (0, 0.0, -46*3*1, 0.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
26 (0, 0.0, -46*3*2, 0.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
27 (0, 0.0, -46*3*3, 0.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
28 (0, 0.0, -46*3*4, 0.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
29 (0, 0.0, -46*3*5, 0.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
30 (0, 0.0, -46*3*6, 0.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
31 (0, 0.0, -46*3*7, 0.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
32 (0, 0.0, -46*3*8, 0.0),
121
1bc0ad774ed4 More impressive data, use a wider range of things, and document things!
Thibaut Girka <thib@sitedethib.com>
parents: 120
diff changeset
33 (0, 0.0, -46*3*9, 0.0),
1bc0ad774ed4 More impressive data, use a wider range of things, and document things!
Thibaut Girka <thib@sitedethib.com>
parents: 120
diff changeset
34 (0, 0.0, -46*3*10, 0.0),
115
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
35 #Trees
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
36 (1, 40.0, -46*3*1, -50.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
37 (1, 40.0, -46*3*2, -50.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
38 (1, 40.0, -46*3*3, -50.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
39 (1, 40.0, -46*3*4, -50.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
40 (1, 40.0, -46*3*5, -50.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
41 (1, 40.0, -46*3*6, -50.0),
121
1bc0ad774ed4 More impressive data, use a wider range of things, and document things!
Thibaut Girka <thib@sitedethib.com>
parents: 120
diff changeset
42 (1, 40.0, -46*3*7, -50.0),
1bc0ad774ed4 More impressive data, use a wider range of things, and document things!
Thibaut Girka <thib@sitedethib.com>
parents: 120
diff changeset
43 (1, 40.0, -46*3*8, -50.0),
115
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
44
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
45 (1, 40.0+40, -46*3*1-20, -50.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
46 (1, 40.0+40, -46*3*2-20, -50.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
47 (1, 40.0+40, -46*3*3-20, -50.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
48 (1, 40.0+40, -46*3*4-20, -50.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
49 (1, 40.0+40, -46*3*5-20, -50.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
50 (1, 40.0+40, -46*3*6-20, -50.0),
121
1bc0ad774ed4 More impressive data, use a wider range of things, and document things!
Thibaut Girka <thib@sitedethib.com>
parents: 120
diff changeset
51 (1, 40.0+40, -46*3*7-20, -50.0),
1bc0ad774ed4 More impressive data, use a wider range of things, and document things!
Thibaut Girka <thib@sitedethib.com>
parents: 120
diff changeset
52 (1, 40.0+40, -46*3*8-20, -50.0),
115
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
53
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
54 (2, 192*2-30-40.0, -46*3*1, -50.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
55 (2, 192*2-30-40.0, -46*3*2, -50.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
56 (2, 192*2-30-40.0, -46*3*3, -50.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
57 (2, 192*2-30-40.0, -46*3*4, -50.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
58 (2, 192*2-30-40.0, -46*3*5, -50.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
59 (2, 192*2-30-40.0, -46*3*6, -50.0),
121
1bc0ad774ed4 More impressive data, use a wider range of things, and document things!
Thibaut Girka <thib@sitedethib.com>
parents: 120
diff changeset
60 (2, 192*2-30-40.0, -46*3*7, -50.0),
1bc0ad774ed4 More impressive data, use a wider range of things, and document things!
Thibaut Girka <thib@sitedethib.com>
parents: 120
diff changeset
61 (2, 192*2-30-40.0, -46*3*8, -50.0),
115
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
62
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
63 (2, 192*2-30-40.0-50.0, -46*3*1-20, -50.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
64 (2, 192*2-30-40.0-50.0, -46*3*2-20, -50.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
65 (2, 192*2-30-40.0-50.0, -46*3*3-20, -50.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
66 (2, 192*2-30-40.0-50.0, -46*3*4-20, -50.0),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
67 (2, 192*2-30-40.0-50.0, -46*3*5-20, -50.0),
121
1bc0ad774ed4 More impressive data, use a wider range of things, and document things!
Thibaut Girka <thib@sitedethib.com>
parents: 120
diff changeset
68 (2, 192*2-30-40.0-50.0, -46*3*6-20, -50.0),
1bc0ad774ed4 More impressive data, use a wider range of things, and document things!
Thibaut Girka <thib@sitedethib.com>
parents: 120
diff changeset
69 (2, 192*2-30-40.0-50.0, -46*3*7-20, -50.0),
1bc0ad774ed4 More impressive data, use a wider range of things, and document things!
Thibaut Girka <thib@sitedethib.com>
parents: 120
diff changeset
70 (2, 192*2-30-40.0-50.0, -46*3*8-20, -50.0)]
115
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
71
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
72
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
73 # Bounding boxes
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
74 anm_wrapper = AnmWrapper([Animations.read(open('stg1bg.anm', 'rb'))])
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
75 for model in models:
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
76 vertices = []
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
77 for script_index, ox2, oy2, oz2, width_override, height_override in model.quads:
120
4300a832f033 Small refactoring and massive performance improvement
Thibaut Girka <thib@sitedethib.com>
parents: 117
diff changeset
78 sprite = Sprite(width_override, height_override)
115
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
79 anmrunner = ANMRunner(anm_wrapper, script_index, sprite)
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
80 anmrunner.run_frame()
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
81 key, (vertices2, uvs2, colors2) = get_sprite_rendering_data(sprite)
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
82 vertices.extend((x + ox2, y + oy2, z + oz2) for x, y, z in vertices2)
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
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)
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
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)
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
85 model.bounding_box = (xmin, ymin, zmin, xmax - xmin, ymax - ymin, zmax - zmin)
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
86
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
87
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
88 stage = Stage()
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
89 stage.name = 'Test by ThibG'
117
1ec8be40880f [Data] Fix a crash with 102h.exe (missing music), and fix bullet sizes
Thibaut Girka <thib@sitedethib.com>
parents: 115
diff changeset
90 stage.bgms = ('', 'bgm/th06_15.mid'), ('', ''), ('', ''), ('', '')
115
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
91 stage.models = models
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
92 stage.object_instances = instances
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
93 stage.script = [(0, 1, (50, 0, 50, 300.0, 800.0)),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
94 (0, 2, (0.0, 400.0, 0.3)),
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
95 (0, 0, (0.0, 0.0, 0.0)),
121
1bc0ad774ed4 More impressive data, use a wider range of things, and document things!
Thibaut Girka <thib@sitedethib.com>
parents: 120
diff changeset
96 (2100, 0, (0.0, -800.0, 0.0)),
1bc0ad774ed4 More impressive data, use a wider range of things, and document things!
Thibaut Girka <thib@sitedethib.com>
parents: 120
diff changeset
97 (3200, 0, (0.0, 0.0, 0.0)),
1bc0ad774ed4 More impressive data, use a wider range of things, and document things!
Thibaut Girka <thib@sitedethib.com>
parents: 120
diff changeset
98 (6500, 0, (0.0, 0.0, 0.0))]
115
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
99
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
100 with open('stage1.std', 'wb') as file:
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
101 stage.write(file)
f0e6ae22d29a Add sample data
Thibaut Girka <thib@sitedethib.com>
parents:
diff changeset
102