comparison pytouhou/ui/sprite.pyx @ 279:3539520fff93

Fix sprite rotation/translation. ANM translations are done *after* rotation, lasers are handled differently.
author Thibaut Girka <thib@sitedethib.com>
date Wed, 08 Feb 2012 18:43:39 +0100
parents f037bca24f2d
children f3099ebf4f61
comparison
equal deleted inserted replaced
278:615c0bb6064b 279:3539520fff93
36 36
37 vertmat.scale2d(width, height) 37 vertmat.scale2d(width, height)
38 if sprite.mirrored: 38 if sprite.mirrored:
39 vertmat.flip() 39 vertmat.flip()
40 40
41 if sprite.allow_dest_offset:
42 vertmat.translate(sprite.dest_offset[0], sprite.dest_offset[1], sprite.dest_offset[2])
43 rx, ry, rz = sprite.rotations_3d 41 rx, ry, rz = sprite.rotations_3d
44 if sprite.automatic_orientation: 42 if sprite.automatic_orientation:
45 rz += pi/2. - sprite.angle 43 rz += pi/2. - sprite.angle
46 elif sprite.force_rotation: 44 elif sprite.force_rotation:
47 rz += sprite.angle 45 rz += sprite.angle
51 vertmat.rotate_x(-rx) 49 vertmat.rotate_x(-rx)
52 if ry: 50 if ry:
53 vertmat.rotate_y(ry) 51 vertmat.rotate_y(ry)
54 if rz: 52 if rz:
55 vertmat.rotate_z(-rz) #TODO: minus, really? 53 vertmat.rotate_z(-rz) #TODO: minus, really?
54 if sprite.allow_dest_offset:
55 vertmat.translate(sprite.dest_offset[0], sprite.dest_offset[1], sprite.dest_offset[2])
56 if sprite.corner_relative_placement: # Reposition 56 if sprite.corner_relative_placement: # Reposition
57 vertmat.translate(width / 2., height / 2., 0.) 57 vertmat.translate(width / 2., height / 2., 0.)
58 58
59 x_1 = 1. / sprite.anm.size[0] 59 x_1 = 1. / sprite.anm.size[0]
60 y_1 = 1. / sprite.anm.size[1] 60 y_1 = 1. / sprite.anm.size[1]