changeset 601:016f6b937893

Make sample data build again.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 25 Oct 2014 18:57:10 +0200
parents 2a748aa29c3f
children c84227022765
files data/Makefile data/ST/Makefile data/ST/face00a.script data/ST/face03a.script data/ST/make_stage.py data/ST/msg1.script data/ST/player00.script data/ST/player00.svg pytouhou/ui/opengl/sprite.pyx
diffstat 9 files changed, 130 insertions(+), 68 deletions(-) [+]
line wrap: on
line diff
--- a/data/Makefile
+++ b/data/Makefile
@@ -8,7 +8,7 @@ ST.DAT: ST
 
 
 CM.DAT: ST
-	thdat c6 CM.DAT ST/etama*
+	thdat c6 CM.DAT ST/etama* ST/face00* ST/player*
 
 
 clean:
--- a/data/ST/Makefile
+++ b/data/ST/Makefile
@@ -1,74 +1,35 @@
-all: stg1bg.png stg1bg.anm stage1.std face03a.anm face03b.anm face42.png eff01.png eff01.anm stg1enm2.anm ecldata1.ecl stg1enm.png stg1enm.anm stg1enm2.anm msg1.dat etama3.anm etama3.png etama4.anm etama4.png
-
-face42.png: face.svg
-	inkscape -e face42.png face.svg
-
-
-stg1bg.png: stg1bg.svg
-	inkscape -e stg1bg.png stg1bg.svg
-
-
-stg1enm.png: stg1enm.svg
-	inkscape -e stg1enm.png stg1enm.svg
-
+PNG := stg1bg.png face.png eff01.png stg1enm.png etama3.png etama4.png player00.png
+ANM := stg1bg.anm face00a.anm face00b.anm face00c.anm face03a.anm face03b.anm eff01.anm stg1enm2.anm stg1enm.anm stg1enm2.anm etama3.anm etama4.anm player00.anm
+OTHER := stage1.std ecldata1.ecl msg1.dat
 
-eff01.png: eff01.svg
-	inkscape -e eff01.png eff01.svg
-
-
-stg1bg.anm: stg1bg.script
-	thanm c stg1bg.anm stg1bg.script
-
-
-stg1enm.anm: stg1enm.script
-	thanm c stg1enm.anm stg1enm.script
-
-
-face03a.anm: face03a.script
-	thanm c face03a.anm face03a.script
+all: $(PNG) $(ANM) $(OTHER)
 
-
-face03b.anm: face03a.script
-	thanm c face03b.anm face03a.script
-
-
-eff01.anm: eff01.script
-	thanm c eff01.anm eff01.script
-
-
-etama3.anm: etama3.script
-	thanm c etama3.anm etama3.script
-
+%.png: %.svg
+	inkscape -e $@ $<
 
-etama4.anm: etama4.script
-	thanm c etama4.anm etama4.script
-
-
-etama3.png: etama3.svg
-	inkscape -e etama3.png etama3.svg
-
-
-etama4.png: etama4.svg
-	inkscape -e etama4.png etama4.svg
-
-
-stg1enm2.anm: stg1enm2.script
-	thanm c stg1enm2.anm stg1enm2.script
-
+%.anm: %.script
+	thanm c $@ $<
 
 ecldata1.ecl: make_ecl.py
-	PYTHONPATH=../../ python2 make_ecl.py
-
+	PYTHONPATH=../../ python3 make_ecl.py
 
 stage1.std: make_stage.py
-	PYTHONPATH=../../ python2 make_stage.py
-
+	PYTHONPATH=../../ python3 make_stage.py
 
 msg1.dat: msg1.script
 	thmsg c6 msg1.script msg1.dat
 
+# Those should have their own script.
+face00b.anm: face03a.script
+	thanm c $@ $<
+
+face00c.anm: face03a.script
+	thanm c $@ $<
+
+face03b.anm: face03a.script
+	thanm c $@ $<
 
 clean:
-	rm -f stg1bg.png stg1bg.anm stage1.std face03a.anm face03b.anm face42.png eff01.png eff01.anm stg1enm2.anm ecldata1.ecl stg1enm.png stg1enm.anm stg1enm2.anm msg1.dat etama3.anm etama3.png etama4.anm etama4.png
+	$(RM) $(PNG) $(ANM) $(OTHER)
 
 .PHONY: all clean
new file mode 100644
--- /dev/null
+++ b/data/ST/face00a.script
@@ -0,0 +1,25 @@
+ENTRY 0
+Name: data/face/face.png
+#Name2: data/face/face03b_a.png
+Format: 1
+Width: 256
+Height: 256
+
+Sprite: 0 128*256+0+0
+Sprite: 1 128*256+128+0
+
+Script: 0
+Instruction: 0 0 1 0
+Instruction: 0 0 15
+
+script: 1
+instruction: 0 0 1 0
+instruction: 0 0 15
+
+script: 2
+instruction: 0 0 1 0
+instruction: 0 0 15
+
+script: 3
+instruction: 0 0 1 0
+instruction: 0 0 15
--- a/data/ST/face03a.script
+++ b/data/ST/face03a.script
@@ -1,5 +1,5 @@
 ENTRY 0
-Name: data/face/face42.png
+Name: data/face/face.png
 #Name2: data/face/face03b_a.png
 Format: 1
 Width: 256
--- a/data/ST/make_stage.py
+++ b/data/ST/make_stage.py
@@ -1,9 +1,8 @@
 from pytouhou.formats.std import Stage, Model
-from pytouhou.formats.anm0 import Animations
+from pytouhou.formats.anm0 import ANM0
 from pytouhou.vm.anmrunner import ANMRunner
 from pytouhou.game.sprite import Sprite
-from pytouhou.resource.anmwrapper import AnmWrapper
-from pytouhou.opengl.sprite import get_sprite_rendering_data
+from pytouhou.ui.opengl.sprite import get_sprite_vertices
 
 ground = Model(quads=[(14, -100.0, -46*3, 0.5, (192+100)*2, 46*3),
                       (0, 192.0 - 40, -46.0, 0.0, 0, 0),
@@ -71,14 +70,13 @@ instances = [(0, 0.0, -46*3*-1, 0.0),
 
 
 # Bounding boxes
-anm_wrapper = AnmWrapper([Animations.read(open('stg1bg.anm', 'rb'))])
+anm = ANM0.read(open('stg1bg.anm', 'rb'))[0]
 for model in models:
     vertices = []
     for script_index, ox2, oy2, oz2, width_override, height_override in model.quads:
         sprite = Sprite(width_override, height_override)
-        anmrunner = ANMRunner(anm_wrapper, script_index, sprite)
-        anmrunner.run_frame()
-        key, (vertices2, uvs2, colors2) = get_sprite_rendering_data(sprite)
+        anmrunner = ANMRunner(anm, script_index, sprite)
+        vertices2 = get_sprite_vertices(sprite)
         vertices.extend((x + ox2, y + oy2, z + oz2) for x, y, z in vertices2)
     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)
     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)
--- a/data/ST/msg1.script
+++ b/data/ST/msg1.script
@@ -0,0 +1,13 @@
+entry 0
+@0
+	3;0;0;Coucou.
+	4;60
+@60
+	5;0;5
+	5;1;5
+	13;0
+@61
+	0
+	13;0
+@0
+	0
new file mode 100644
--- /dev/null
+++ b/data/ST/player00.script
@@ -0,0 +1,50 @@
+ENTRY 0
+Name: data/player/player00.png
+Format: 1
+Width: 256
+Height: 256
+
+Sprite: 0 15*30+1+1
+Sprite: 1 8*8+40+40
+Sprite: 2 8*8+40+40
+
+# Player
+Script: 0
+Instruction: 0 0 1 0
+Instruction: 0 0 15
+
+Script: 1
+Instruction: 0 0 1 0
+Instruction: 0 0 15
+
+Script: 2
+Instruction: 0 0 1 0
+Instruction: 0 0 15
+
+Script: 3
+Instruction: 0 0 1 0
+Instruction: 0 0 15
+
+Script: 4
+Instruction: 0 0 1 0
+Instruction: 0 0 15
+
+# Bullet
+Script: 64
+Instruction: 0 0 1 1
+Instruction: 0 0 15
+
+# Bullet cancellation
+Script: 96
+Instruction: 0 0 1 1
+Instruction: 0 0 15
+
+# Orbs
+Script: 128
+Instruction: 0 0 1 2
+Instruction: 0 0 15
+
+Script: 129
+Instruction: 0 0 1 2
+Instruction: 0 0 15
+
new file mode 100644
--- /dev/null
+++ b/data/ST/player00.svg
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" version="1.1">
+  <path d="M 0.5,22 8,4 15.5,22 z" fill="#b3b3b3" stroke="none"/>
+  <circle cx="43" cy="43" r="4"/>
+</svg>
--- a/pytouhou/ui/opengl/sprite.pyx
+++ b/pytouhou/ui/opengl/sprite.pyx
@@ -34,6 +34,16 @@ cdef RenderingData* get_sprite_rendering
     return <RenderingData*>sprite._rendering_data
 
 
+def get_sprite_vertices(Sprite sprite):
+    if sprite.changed:
+        render_sprite(sprite)
+    data = <RenderingData*>sprite._rendering_data
+    return [(data.pos[0], data.pos[1], data.pos[2]),
+            (data.pos[3], data.pos[4], data.pos[5]),
+            (data.pos[6], data.pos[7], data.pos[8]),
+            (data.pos[9], data.pos[10], data.pos[11])]
+
+
 cdef void render_sprite(Sprite sprite) nogil:
     cdef Matrix vertmat